-
Notifications
You must be signed in to change notification settings - Fork 55
/
0001-add-imtl-support-in-sample_encode.patch
649 lines (601 loc) · 23 KB
/
0001-add-imtl-support-in-sample_encode.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
From ca1e2319314c3653a85e717c96dfa46b11df4448 Mon Sep 17 00:00:00 2001
From: Ric Li <[email protected]>
Date: Wed, 2 Nov 2022 16:06:39 +0800
Subject: [PATCH] add imtl support in sample_encode
add imtl dependency and command line args
add st20p in pipeline encode
encode with mtl frame
fix the command args
fix mtlfps arg
eliminate a memcpy with ext frame api
bump dependency to "mtl"
enable dma_dev config
wait to get a frame in loadframe (#1)
fix the green frames issue
do not encode last null frame
fix the format print
---
CMakeLists.txt | 1 +
builder/FindPackages.cmake | 10 ++
samples/sample_encode/CMakeLists.txt | 2 +-
.../sample_encode/include/pipeline_encode.h | 43 +++++
samples/sample_encode/src/pipeline_encode.cpp | 160 +++++++++++++++++-
samples/sample_encode/src/sample_encode.cpp | 153 ++++++++++++++++-
6 files changed, 362 insertions(+), 7 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 97038ae9..beac42be 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -202,6 +202,7 @@ message(" CMAKE_INSTALL_FULL_DATADIR : ${CMAKE_INSTALL_FULL_DATADI
message("Enable:")
message(" ENABLE_OPENCL : ${ENABLE_OPENCL}")
if( CMAKE_SYSTEM_NAME MATCHES Linux )
+ message(" ENABLE_IMTL : ${ENABLE_IMTL}")
message(" ENABLE_X11 : ${ENABLE_X11}")
message(" ENABLE_X11_DRI3 : ${ENABLE_X11_DRI3}")
message(" ENABLE_WAYLAND : ${ENABLE_WAYLAND}")
diff --git a/builder/FindPackages.cmake b/builder/FindPackages.cmake
index dcca1410..85e0168e 100644
--- a/builder/FindPackages.cmake
+++ b/builder/FindPackages.cmake
@@ -222,6 +222,10 @@ function(configure_universal_target target)
set(LOCAL_CFLAGS "${LOCAL_CFLAGS} -DENABLE_V4L2_SUPPORT" )
endif()
+ if(ENABLE_IMTL)
+ set(LOCAL_CFLAGS "${LOCAL_CFLAGS} -DENABLE_IMTL_SUPPORT" )
+ endif()
+
if(ENABLE_MONDELLO)
set(LOCAL_CFLAGS "${LOCAL_CFLAGS} -DENABLE_MONDELLO_SUPPORT" )
endif()
@@ -274,6 +278,10 @@ function(configure_pthread_target target)
set(SCOPE_LIBS ${SCOPE_LIBS} pthread PARENT_SCOPE)
endfunction()
+function(configure_mtl_target target)
+ set(SCOPE_LIBS ${SCOPE_LIBS} mtl PARENT_SCOPE)
+endfunction()
+
function(configure_libavutil_target target)
configure_target(${ARGV0} "${PKG_LIBAVUTIL_CFLAGS}" "${PKG_LIBAVUTIL_LIBRARY_DIRS}")
@@ -397,6 +405,8 @@ function(configure_dependencies target dependencies variant)
configure_dl_target(${ARGV0})
elseif(${dependency} STREQUAL pthread)
configure_pthread_target(${ARGV0})
+ elseif(${dependency} STREQUAL mtl)
+ configure_mtl_target(${ARGV0})
elseif(${dependency} STREQUAL libavutil)
if(ENABLE_FFMPEG)
if(PKG_LIBAVUTIL_FOUND)
diff --git a/samples/sample_encode/CMakeLists.txt b/samples/sample_encode/CMakeLists.txt
index 1c3bfe0a..3f4a2996 100644
--- a/samples/sample_encode/CMakeLists.txt
+++ b/samples/sample_encode/CMakeLists.txt
@@ -6,7 +6,7 @@ include_directories (
list( APPEND LIBS_VARIANT sample_common )
-set(DEPENDENCIES libmfx dl pthread)
+set(DEPENDENCIES libmfx dl pthread mtl)
make_executable( shortname universal )
install( TARGETS ${target} RUNTIME DESTINATION ${MFX_SAMPLES_INSTALL_BIN_DIR} )
diff --git a/samples/sample_encode/include/pipeline_encode.h b/samples/sample_encode/include/pipeline_encode.h
index de02122e..5cab6473 100644
--- a/samples/sample_encode/include/pipeline_encode.h
+++ b/samples/sample_encode/include/pipeline_encode.h
@@ -48,6 +48,11 @@ or https://software.intel.com/en-us/media-client-solutions-support.
#include "v4l2_util.h"
#endif
+#if defined (ENABLE_IMTL_SUPPORT)
+#include <mtl/st_pipeline_api.h>
+#include <arpa/inet.h>
+#endif
+
#if (MFX_VERSION >= 1024)
#include "brc_routines.h"
#endif
@@ -180,6 +185,8 @@ struct sInputParams
bool isV4L2InputEnabled;
+ bool isIMTLInputEnabled;
+
mfxU16 CodecLevel;
mfxU16 CodecProfile;
mfxU32 MaxKbps;
@@ -234,6 +241,19 @@ struct sInputParams
enum AtomISPMode MipiMode;
#endif
+#if defined (ENABLE_IMTL_SUPPORT)
+ msdk_char PortName[MSDK_MAX_FILENAME_LEN];
+ msdk_char DmaDev[MSDK_MAX_FILENAME_LEN];
+ mfxU8 IpAddr[MTL_IP_ADDR_LEN];
+ mfxU8 LocalIpAddr[MTL_IP_ADDR_LEN];
+ mfxU16 UdpPort;
+ enum st20_fmt TransportFmt;
+ enum st_frame_fmt OutputFmt;
+ enum st_fps MtlFps;
+ mfxU8 PayloadType;
+ bool has_dma;
+#endif
+
#if (MFX_VERSION >= MFX_VERSION_NEXT)
mfxI16 DeblockingAlphaTcOffset;
mfxI16 DeblockingBetaOffset;
@@ -301,6 +321,19 @@ protected:
virtual mfxU32 GetFreeTaskIndex();
};
+
+#if defined (ENABLE_IMTL_SUPPORT)
+struct MtlCtx
+{
+ mtl_handle MtlHandle;
+ st20p_rx_handle MtlRxHandle;
+ bool stop;
+ pthread_cond_t wake_cond;
+ pthread_mutex_t wake_mutex;
+};
+#endif
+
+
/* This class implements a pipeline with 2 mfx components: vpp (video preprocessing) and encode */
class CEncodingPipeline
{
@@ -321,6 +354,8 @@ public:
mfxStatus CaptureStartV4L2Pipeline();
void CaptureStopV4L2Pipeline();
+ void InitIMTLPipeline(sInputParams *pParams);
+
static void InsertIDR(mfxEncodeCtrl & ctrl, bool forceIDR);
virtual mfxStatus OpenRoundingOffsetFile(sInputParams *pInParams);
@@ -331,6 +366,10 @@ public:
pthread_t m_PollThread;
#endif
+#if defined (ENABLE_IMTL_SUPPORT)
+ struct MtlCtx mtl;
+#endif
+
protected:
std::pair<CSmplBitstreamWriter *,CSmplBitstreamWriter *> m_FileWriters;
CSmplYUVReader m_FileReader;
@@ -386,6 +425,7 @@ protected:
bool m_bTCBRCFileMode;
bool isV4L2InputEnabled;
+ bool isIMTLInputEnabled;
#if (MFX_VERSION >= 1027)
FILE* m_round_in;
#endif
@@ -454,6 +494,9 @@ protected:
void InitExtMVCBuffers(mfxExtMVCSeqDesc *mvcBuffer) const;
mfxStatus ConfigTCBRCTest(mfxFrameSurface1* pSurf);
+#if defined (ENABLE_IMTL_SUPPORT)
+ mfxStatus MtlLoadNextFrame(mfxFrameSurface1* pSurf);
+#endif
};
#endif // __PIPELINE_ENCODE_H__
diff --git a/samples/sample_encode/src/pipeline_encode.cpp b/samples/sample_encode/src/pipeline_encode.cpp
index b0cac12a..6942eca0 100644
--- a/samples/sample_encode/src/pipeline_encode.cpp
+++ b/samples/sample_encode/src/pipeline_encode.cpp
@@ -1349,6 +1349,7 @@ CEncodingPipeline::CEncodingPipeline()
MSDK_ZERO_MEMORY(m_PreEncResponse);
isV4L2InputEnabled = false;
+ isIMTLInputEnabled = false;
m_nFramesToProcess = 0;
m_bCutOutput = false;
@@ -1646,6 +1647,10 @@ mfxStatus CEncodingPipeline::Init(sInputParams *pParams)
isV4L2InputEnabled = pParams->isV4L2InputEnabled;
#endif
+#if defined ENABLE_IMTL_SUPPORT
+ isIMTLInputEnabled = pParams->isIMTLInputEnabled;
+#endif
+
m_MVCflags = pParams->MVC_flags;
// FileReader can convert yv12->nv12 without vpp
@@ -1811,7 +1816,7 @@ mfxStatus CEncodingPipeline::Init(sInputParams *pParams)
}
// Preparing readers and writers
- if (!isV4L2InputEnabled)
+ if (!isV4L2InputEnabled && !isIMTLInputEnabled)
{
// prepare input file reader
sts = m_FileReader.Init(pParams->InputFiles,
@@ -1861,6 +1866,8 @@ mfxStatus CEncodingPipeline::Init(sInputParams *pParams)
InitV4L2Pipeline(pParams);
+ InitIMTLPipeline(pParams);
+
m_nFramesToProcess = pParams->nNumFrames;
// If output isn't specified work in performance mode and do not insert idr
@@ -1875,6 +1882,76 @@ mfxStatus CEncodingPipeline::Init(sInputParams *pParams)
return MFX_ERR_NONE;
}
+#if defined (ENABLE_IMTL_SUPPORT)
+static int MtlFrameAvailable(void* priv) {
+ struct MtlCtx* s = (struct MtlCtx*)priv;
+ pthread_mutex_lock(&s->wake_mutex);
+ pthread_cond_signal(&s->wake_cond);
+ pthread_mutex_unlock(&s->wake_mutex);
+ return 0;
+}
+#endif
+
+void CEncodingPipeline::InitIMTLPipeline(sInputParams* pParams){
+#if defined (ENABLE_IMTL_SUPPORT)
+ if(isIMTLInputEnabled)
+ {
+ struct mtl_init_params param;
+ memset(¶m, 0, sizeof(param));
+ param.num_ports = 1;
+ strcpy(param.port[MTL_PORT_P], pParams->PortName);
+ if(pParams->has_dma)
+ {
+ param.num_dma_dev_port = 1;
+ strcpy(param.dma_dev_port[0], pParams->DmaDev);
+ }
+ memcpy(param.sip_addr[MTL_PORT_P], pParams->LocalIpAddr, MTL_IP_ADDR_LEN);
+ param.flags = MTL_FLAG_BIND_NUMA | MTL_FLAG_DEV_AUTO_START_STOP;
+ param.log_level = MTL_LOG_LEVEL_NOTICE;
+ param.priv = NULL;
+ param.ptp_get_time_fn = NULL;
+ param.rx_queues_cnt[MTL_PORT_P] = 1;
+ param.tx_queues_cnt[MTL_PORT_P] = 0;
+ param.lcores = NULL;
+ mtl.MtlHandle = mtl_init(¶m);
+ if (!mtl.MtlHandle)
+ {
+ msdk_printf(MSDK_STRING("IMTL device init fail\n"));
+ }
+
+ struct st20p_rx_ops ops_rx;
+ memset(&ops_rx, 0, sizeof(ops_rx));
+ ops_rx.name = "mtl_pipeline_rx";
+ ops_rx.priv = &mtl;
+ ops_rx.port.num_port = 1;
+ memcpy(ops_rx.port.sip_addr[MTL_PORT_P], pParams->IpAddr, MTL_IP_ADDR_LEN);
+ strcpy(ops_rx.port.port[MTL_PORT_P], pParams->PortName);
+ ops_rx.port.udp_port[MTL_PORT_P] = pParams->UdpPort;
+ ops_rx.port.payload_type = pParams->PayloadType;
+ ops_rx.width = pParams->nWidth;
+ ops_rx.height = pParams->nHeight;
+ ops_rx.fps = pParams->MtlFps;
+ ops_rx.transport_fmt = pParams->TransportFmt;
+ ops_rx.output_fmt = pParams->OutputFmt;
+ ops_rx.device = ST_PLUGIN_DEVICE_AUTO;
+ ops_rx.framebuff_cnt = 3;
+ ops_rx.flags |= ST20P_RX_FLAG_EXT_FRAME;
+ if(pParams->has_dma) ops_rx.flags |= ST20P_RX_FLAG_DMA_OFFLOAD;
+ ops_rx.notify_frame_available = MtlFrameAvailable;
+
+ mtl.stop = false;
+ pthread_mutex_init(&mtl.wake_mutex, NULL);
+ pthread_cond_init(&mtl.wake_cond, NULL);
+
+ mtl.MtlRxHandle = st20p_rx_create(mtl.MtlHandle, &ops_rx);
+ if (!mtl.MtlRxHandle)
+ {
+ msdk_printf(MSDK_STRING("IMTL pipeline rx create fail\n"));
+ }
+ }
+#endif
+}
+
void CEncodingPipeline::InitV4L2Pipeline(sInputParams* /*pParams*/)
{
#if defined (ENABLE_V4L2_SUPPORT)
@@ -2004,6 +2081,22 @@ void CEncodingPipeline::Close()
m_FileReader.Close();
FreeFileWriters();
+#if defined (ENABLE_IMTL_SUPPORT)
+ if (isIMTLInputEnabled)
+ {
+ if(mtl.MtlRxHandle)
+ st20p_rx_free(mtl.MtlRxHandle);
+ if(mtl.MtlHandle)
+ mtl_uninit(mtl.MtlHandle);
+ mtl.stop = true;
+ pthread_mutex_lock(&mtl.wake_mutex);
+ pthread_cond_signal(&mtl.wake_cond);
+ pthread_mutex_unlock(&mtl.wake_mutex);
+ pthread_mutex_destroy(&mtl.wake_mutex);
+ pthread_cond_destroy(&mtl.wake_cond);
+ }
+#endif
+
#if (MFX_VERSION >= 1027)
if(m_round_in)
{
@@ -2430,6 +2523,13 @@ mfxStatus CEncodingPipeline::Run()
}
#endif
+#if defined (ENABLE_IMTL_SUPPORT)
+ if (isIMTLInputEnabled)
+ {
+ msdk_printf(MSDK_STRING("Press Ctrl+C to terminate this application\n"));
+ }
+#endif
+
// main loop, preprocessing and encoding
while (MFX_ERR_NONE <= sts || MFX_ERR_MORE_DATA == sts)
{
@@ -2713,6 +2813,42 @@ mfxStatus CEncodingPipeline::Run()
return sts;
}
+#if defined (ENABLE_IMTL_SUPPORT)
+mfxStatus CEncodingPipeline::MtlLoadNextFrame(mfxFrameSurface1* pSurf)
+{
+ MSDK_CHECK_POINTER(pSurf, MFX_ERR_NULL_PTR);
+ MSDK_CHECK_POINTER(mtl.MtlRxHandle, MFX_ERR_NULL_PTR);
+
+ struct st_ext_frame ext_frame;
+
+ mfxFrameInfo& pInfo = pSurf->Info;
+ mfxFrameData& pData = pSurf->Data;
+ ext_frame.addr[0] = pData.Y;
+ ext_frame.linesize[0] = pData.Pitch;
+ ext_frame.size = pInfo.BufferSize;
+
+ struct st_frame * frame = NULL;
+ while (!frame && !mtl.stop)
+ {
+ frame = st20p_rx_get_ext_frame(mtl.MtlRxHandle, &ext_frame);
+ if(!frame)
+ { /* no frame */
+ pthread_mutex_lock(&mtl.wake_mutex);
+ if(!mtl.stop) pthread_cond_wait(&mtl.wake_cond, &mtl.wake_mutex);
+ pthread_mutex_unlock(&mtl.wake_mutex);
+ }
+ }
+
+ if (frame)
+ {
+ st20p_rx_put_frame(mtl.MtlRxHandle, frame);
+ return MFX_ERR_NONE;
+ }
+
+ return MFX_ERR_NULL_PTR;
+}
+#endif
+
mfxStatus CEncodingPipeline::LoadNextFrame(mfxFrameSurface1* pSurf)
{
mfxStatus sts = MFX_ERR_NONE;
@@ -2749,8 +2885,16 @@ mfxStatus CEncodingPipeline::LoadNextFrame(mfxFrameSurface1* pSurf)
sts = m_FileReader.SkipNframesFromBeginning(w, h, vid, m_QPFileReader.GetCurrentDisplayOrder());
MSDK_CHECK_STATUS(sts, "m_FileReader.SkipNframesFromBeginning failed");
}
-
- sts = m_FileReader.LoadNextFrame(pSurf);
+#if defined (ENABLE_IMTL_SUPPORT)
+ if (isIMTLInputEnabled)
+ {
+ sts = MtlLoadNextFrame(pSurf);
+ sts1 = m_pMFXAllocator->Unlock(m_pMFXAllocator->pthis, pSurf->Data.MemId, &(pSurf->Data));
+ MSDK_CHECK_STATUS(sts1, "m_pMFXAllocator->Unlock failed");
+ return sts;
+ } else
+#endif
+ sts = m_FileReader.LoadNextFrame(pSurf);
sts1 = m_pMFXAllocator->Unlock(m_pMFXAllocator->pthis, pSurf->Data.MemId, &(pSurf->Data));
MSDK_CHECK_STATUS(sts1, "m_pMFXAllocator->Unlock failed");
@@ -2769,7 +2913,7 @@ mfxStatus CEncodingPipeline::LoadNextFrame(mfxFrameSurface1* pSurf)
sts = m_FileReader.LoadNextFrame(pSurf);
}
- if ( (MFX_ERR_MORE_DATA == sts) && !m_bTimeOutExceed )
+ if ( (MFX_ERR_MORE_DATA == sts) && !m_bTimeOutExceed)
{
m_FileReader.Reset();
m_bFileWriterReset = m_bCutOutput;
@@ -2797,7 +2941,13 @@ void CEncodingPipeline::LoadNextControl(mfxEncodeCtrl*& pCtrl, mfxU32 encSurfIdx
void CEncodingPipeline::PrintInfo()
{
msdk_printf(MSDK_STRING("Encoding Sample Version %s\n"), GetMSDKSampleVersion().c_str());
- msdk_printf(MSDK_STRING("\nInput file format\t%s\n"), ColorFormatToStr(m_FileReader.m_ColorFormat));
+#if defined (ENABLE_IMTL_SUPPORT)
+ if (isIMTLInputEnabled)
+ msdk_printf(MSDK_STRING("\nRaw frame format\tY210 (from MTL)\n"));
+ else
+#else
+ msdk_printf(MSDK_STRING("\nInput file format\t%s\n"), ColorFormatToStr(m_FileReader.m_ColorFormat));
+#endif
msdk_printf(MSDK_STRING("Output video\t\t%s\n"), CodecIdToStr(m_mfxEncParams.mfx.CodecId).c_str());
mfxFrameInfo SrcPicInfo = m_mfxVppParams.vpp.In;
diff --git a/samples/sample_encode/src/sample_encode.cpp b/samples/sample_encode/src/sample_encode.cpp
index e4a5a7c5..92c03b86 100644
--- a/samples/sample_encode/src/sample_encode.cpp
+++ b/samples/sample_encode/src/sample_encode.cpp
@@ -214,6 +214,17 @@ void PrintHelp(msdk_char *strAppName, const msdk_char *strErrorMessage, ...)
msdk_printf(MSDK_STRING(" [-YUY2] - Input Raw format types V4L2 Encode\n"));
msdk_printf(MSDK_STRING(" [-i::v4l2] - To enable v4l2 option\n"));
msdk_printf(MSDK_STRING("Example: %s h264|mpeg2|mvc -i::v4l2 -o OutputEncodedFile -w width -h height -d /dev/video0 -UYVY -m preview -p 0\n"), strAppName);
+#endif
+#if defined (ENABLE_IMTL_SUPPORT)
+ msdk_printf(MSDK_STRING(" [-d] - NIC port BDF (eg: 0000:4b:00.0)\n"));
+ msdk_printf(MSDK_STRING(" [-dma] - DMA device BDF (eg: 0000:01:00.0)\n"));
+ msdk_printf(MSDK_STRING(" [-port] - UDP port number (eg: 20000)\n"));
+ msdk_printf(MSDK_STRING(" [-ip] - Session IP address\n"));
+ msdk_printf(MSDK_STRING(" [-lip] - Local IP address\n"));
+ msdk_printf(MSDK_STRING(" [-mtlfps] - MTL FPS\n"));
+ msdk_printf(MSDK_STRING(" [-pt] - RTP payload type\n"));
+ msdk_printf(MSDK_STRING(" [-i::imtl] - To enable IMTL option\n"));
+ msdk_printf(MSDK_STRING("Example: %s h265 -i::imtl -o OutputEncodedFile -w width -h height -mtlfps 60 -d 0000:4b:00.0 -lip 192.168.96.2 -ip 239.19.96.1 -port 20000 -pt 112 -y210 -ec::y210\n"), strAppName);
#endif
msdk_printf(MSDK_STRING(" [-viewoutput] - instruct the MVC encoder to output each view in separate bitstream buffer. Depending on the number of -o options behaves as follows:\n"));
msdk_printf(MSDK_STRING(" 1: two views are encoded in single file\n"));
@@ -440,6 +451,7 @@ mfxStatus ParseInputString(msdk_char* strInput[], mfxU8 nArgNum, sInputParams* p
// default implementation
pParams->bUseHWLib = true;
pParams->isV4L2InputEnabled = false;
+ pParams->isIMTLInputEnabled = false;
pParams->nNumFrames = 0;
pParams->FileInputFourCC = MFX_FOURCC_I420;
pParams->EncodeFourCC = 0;
@@ -455,6 +467,11 @@ mfxStatus ParseInputString(msdk_char* strInput[], mfxU8 nArgNum, sInputParams* p
pParams->MipiMode = NONE;
pParams->v4l2Format = NO_FORMAT;
#endif
+#if defined (ENABLE_IMTL_SUPPORT)
+ pParams->TransportFmt = ST20_FMT_MAX;
+ pParams->OutputFmt = ST_FRAME_FMT_MAX;
+ pParams->MtlFps = ST_FPS_MAX;
+#endif
// parse command line parameters
for (mfxU8 i = 1; i < nArgNum; i++)
@@ -572,11 +589,19 @@ mfxStatus ParseInputString(msdk_char* strInput[], mfxU8 nArgNum, sInputParams* p
else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-uyvy")))
{
pParams->FileInputFourCC = MFX_FOURCC_UYVY;
+#if defined (ENABLE_IMTL_SUPPORT)
+ pParams->OutputFmt = ST_FRAME_FMT_UYVY;
+ pParams->TransportFmt = ST20_FMT_YUV_422_8BIT;
+#endif
}
#if (MFX_VERSION >= 1027)
else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-y210")))
{
pParams->FileInputFourCC = MFX_FOURCC_Y210;
+#if defined (ENABLE_IMTL_SUPPORT)
+ pParams->OutputFmt = ST_FRAME_FMT_Y210;
+ pParams->TransportFmt = ST20_FMT_YUV_422_10BIT;
+#endif
}
else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-y410")))
{
@@ -1396,6 +1421,104 @@ mfxStatus ParseInputString(msdk_char* strInput[], mfxU8 nArgNum, sInputParams* p
{
pParams->isV4L2InputEnabled = true;
}
+#endif
+#if defined (ENABLE_IMTL_SUPPORT)
+ else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-d")))
+ {
+ VAL_CHECK(i+1 >= nArgNum, i, strInput[i]);
+ if (MFX_ERR_NONE != msdk_opt_read(strInput[++i], pParams->PortName))
+ {
+ PrintHelp(strInput[0], MSDK_STRING("Port name is invalid"));
+ return MFX_ERR_UNSUPPORTED;
+ }
+ }
+ else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-dma")))
+ {
+ VAL_CHECK(i+1 >= nArgNum, i, strInput[i]);
+ if (MFX_ERR_NONE != msdk_opt_read(strInput[++i], pParams->DmaDev))
+ {
+ PrintHelp(strInput[0], MSDK_STRING("DMA device is invalid"));
+ return MFX_ERR_UNSUPPORTED;
+ }
+ pParams->has_dma = true;
+ }
+ else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-port")))
+ {
+ VAL_CHECK(i+1 >= nArgNum, i, strInput[i]);
+ if (MFX_ERR_NONE != msdk_opt_read(strInput[++i], pParams->UdpPort))
+ {
+ PrintHelp(strInput[0], MSDK_STRING("Udp port is invalid"));
+ return MFX_ERR_UNSUPPORTED;
+ }
+ }
+ else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-ip")))
+ {
+ VAL_CHECK(i+1 >= nArgNum, i, strInput[i]);
+ if (1 != inet_pton(AF_INET, strInput[++i], pParams->IpAddr))
+ {
+ PrintHelp(strInput[0], MSDK_STRING("IP is invalid"));
+ return MFX_ERR_UNSUPPORTED;
+ }
+ }
+ else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-lip")))
+ {
+ VAL_CHECK(i+1 >= nArgNum, i, strInput[i]);
+ if (1 != inet_pton(AF_INET, strInput[++i], pParams->LocalIpAddr))
+ {
+ PrintHelp(strInput[0], MSDK_STRING("Local IP is invalid"));
+ return MFX_ERR_UNSUPPORTED;
+ }
+ }
+ else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-mtlfps")))
+ {
+ VAL_CHECK(i+1 >= nArgNum, i, strInput[i]);
+ int fps;
+ if (MFX_ERR_NONE != msdk_opt_read(strInput[++i], fps))
+ {
+ PrintHelp(strInput[0], MSDK_STRING("FPS is invalid"));
+ return MFX_ERR_UNSUPPORTED;
+ }
+ pParams->dFrameRate = fps;
+ switch (fps)
+ {
+ case 60:
+ pParams->MtlFps = ST_FPS_P60;
+ break;
+ case 30:
+ pParams->MtlFps = ST_FPS_P30;
+ break;
+ case 50:
+ pParams->MtlFps = ST_FPS_P50;
+ break;
+ case 25:
+ pParams->MtlFps = ST_FPS_P25;
+ break;
+ case 24:
+ pParams->MtlFps = ST_FPS_P24;
+ break;
+ case 120:
+ pParams->MtlFps = ST_FPS_P120;
+ break;
+ case 100:
+ pParams->MtlFps = ST_FPS_P100;
+ break;
+ default:
+ break;
+ }
+ }
+ else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-pt")))
+ {
+ VAL_CHECK(i+1 >= nArgNum, i, strInput[i]);
+ if (MFX_ERR_NONE != msdk_opt_read(strInput[++i], pParams->PayloadType))
+ {
+ PrintHelp(strInput[0], MSDK_STRING("Payload type is invalid"));
+ return MFX_ERR_UNSUPPORTED;
+ }
+ }
+ else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-i::imtl")))
+ {
+ pParams->isIMTLInputEnabled = true;
+ }
#endif
else
{
@@ -1443,8 +1566,36 @@ mfxStatus ParseInputString(msdk_char* strInput[], mfxU8 nArgNum, sInputParams* p
}
#endif
+#if defined (ENABLE_IMTL_SUPPORT)
+ if (pParams->isIMTLInputEnabled)
+ {
+ if (0 == msdk_strlen(pParams->PortName))
+ {
+ PrintHelp(strInput[0], MSDK_STRING("NIC not found"));
+ return MFX_ERR_UNSUPPORTED;
+ }
+
+ if (pParams->TransportFmt == ST20_FMT_MAX)
+ {
+ PrintHelp(strInput[0], MSDK_STRING("NO transport format\n"));
+ return MFX_ERR_UNSUPPORTED;
+ }
+ if (pParams->OutputFmt == ST_FRAME_FMT_MAX)
+ {
+ PrintHelp(strInput[0], MSDK_STRING("NO MTL output format\n"));
+ return MFX_ERR_UNSUPPORTED;
+ }
+
+ if (pParams->MtlFps == ST_FPS_MAX)
+ {
+ PrintHelp(strInput[0], MSDK_STRING("FPS not supported\n"));
+ return MFX_ERR_UNSUPPORTED;
+ }
+ }
+#endif
+
// check if all mandatory parameters were set
- if (!pParams->InputFiles.size() && !pParams->isV4L2InputEnabled)
+ if (!pParams->InputFiles.size() && !pParams->isV4L2InputEnabled && !pParams->isIMTLInputEnabled)
{
PrintHelp(strInput[0], MSDK_STRING("Source file name not found"));
return MFX_ERR_UNSUPPORTED;
--
2.34.1