@@ -44,6 +44,8 @@ extern "C" {
4444
4545#define MULTITHREADDECODING 1
4646
47+ bool g_dump_file = false ;
48+
4749#include < thread>
4850#include < chrono>
4951
@@ -145,7 +147,7 @@ MRDAStatus DecodeFrame(MRDAHandle mrda_handle, FILE *sink, std::shared_ptr<Frame
145147 // success
146148 if (outBuffer->pts >= 0 )
147149 {
148- WriteDecodedFrame (sink, outBuffer.get ());
150+ if (g_dump_file) WriteDecodedFrame (sink, outBuffer.get ());
149151 *cur_pts = outBuffer->pts ;
150152 // MRDA_LOG(LOG_INFO, "Receive frame at pts: %llu, buffer id %d", outBuffer->pts, outBuffer->bufferItem->buf_id);
151153 }
@@ -200,7 +202,7 @@ void ReceiveFrameThread(MRDAHandle mrda_handle, FILE *sink, uint64_t frameNum)
200202#ifdef _ENABLE_TRACE_
201203 MRDA_LOG (LOG_INFO, " MRDA trace log: complete receive frame in sample decode, pts: %llu" , outBuffer->pts );
202204#endif
203- WriteDecodedFrame (sink, outBuffer.get ());
205+ if (g_dump_file) WriteDecodedFrame (sink, outBuffer.get ());
204206 cur_pts = outBuffer->pts ;
205207 // MRDA_LOG(LOG_INFO, "Receive frame at pts: %llu, buffer id %d", outBuffer->pts, outBuffer->bufferItem->buf_id);
206208 }
@@ -235,7 +237,7 @@ MRDAStatus FlushFrame(MRDAHandle mrda_handle, FILE *sink, uint64_t cur_pts, uint
235237 // success
236238 if (outBuffer->pts >= 0 )
237239 {
238- WriteDecodedFrame (sink, outBuffer.get ());
240+ if (g_dump_file) WriteDecodedFrame (sink, outBuffer.get ());
239241 // MRDA_LOG(LOG_INFO, "In flush process: Receive frame at pts: %llu", outBuffer->pts);
240242 }
241243 cur_pts = outBuffer->pts ;
@@ -386,6 +388,7 @@ void PrintHelp()
386388 printf (" %s" , " [--height frame_height] - specifies the frame height. \n " );
387389 printf (" %s" , " [--colorFormat color_format] - specifies the color format. option: yuv420p, nv12, rgb32 \n " );
388390 printf (" %s" , " [--decodeType decode_type] - specifies the decode type. option: ffmpeg, oneVPL \n " );
391+ printf (" %s" , " [--dumpFile 1/0] - dump file(1) or not(0). default: 0: no dump file \n " );
389392 printf (" %s" , " Examples: ./MRDASampleDecodeApp.exe --hostSessionAddr 127.0.0.1:50051 -i input.h265 -o output.raw --memDevSize 1000000000 --bufferNum 100 --bufferSize 10000000 --inDevPath /dev/shm/shm1IN --outDevPath /dev/shm/shm1OUT --inDevSlotNumber 11 --outDevSlotNumber 12 --frameNum 3000 --codecId h265 --fps 30 --width 1920 --height 1080 --colorFormat rgb32 --decodeType ffmpeg \n " );
390393}
391394
@@ -403,6 +406,15 @@ TASKTYPE StringToDecodeType(const char *decode_type_str)
403406 return decode_type;
404407}
405408
409+ bool stringToBool (const std::string& str) {
410+ if (str == " 1" ) return true ;
411+ else if (str == " 0" ) return false ;
412+ else {
413+ MRDA_LOG (LOG_ERROR, " Invalid boolean string: %s" , str.c_str ());
414+ return false ;
415+ }
416+ }
417+
406418bool ParseConfig (int argc, char **argv, InputConfig *inputConfig) {
407419 // Check if the argument count is reasonable compared to InputConfig requirements
408420 if (argc < 2 ) {
@@ -447,6 +459,8 @@ bool ParseConfig(int argc, char **argv, InputConfig *inputConfig) {
447459 inputConfig->color_format = StringToColorFormat (argv[++i]);
448460 } else if (strcmp (argv[i], " --decodeType" ) == 0 && i + 1 < argc) {
449461 inputConfig->decode_type = StringToDecodeType (argv[++i]);
462+ } else if (strcmp (argv[i], " --dumpFile" ) == 0 && i + 1 < argc) {
463+ g_dump_file = stringToBool (argv[++i]);
450464 } else if (strcmp (argv[i], " --help" ) == 0 && i + 1 < argc) {
451465 PrintHelp ();
452466 return false ;
0 commit comments