4444#if defined (ANDROID_NDK)
4545#include < android/log.h>
4646#endif
47+ #ifdef __EMSCRIPTEN__
48+ #include < emscripten.h>
49+ #endif
50+
4751#include " codec_def.h"
4852#include " codec_app_def.h"
4953#include " codec_api.h"
@@ -60,6 +64,13 @@ float g_fDecFPS = 0.0;
6064int g_iDecodedFrameNum = 0 ;
6165#endif
6266
67+ #if defined(NODEFS)
68+ #define CWD " /workload/"
69+ #endif
70+ #if defined(MEMFS)
71+ #define CWD " testbin/workload/"
72+ #endif
73+
6374#if defined(ANDROID_NDK)
6475#define LOG_TAG " welsdec"
6576#define LOGI (...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
@@ -256,7 +267,7 @@ void H264DecodeInstance (ISVCDecoder* pDecoder, const char* kpH264FileName, cons
256267 if (kpH264FileName) {
257268 pH264File = fopen (kpH264FileName, " rb" );
258269 if (pH264File == NULL ) {
259- fprintf (stderr, " Can not open h264 source file, check its legal path related please..\n " );
270+ fprintf (stderr, " Can not open h264 source file: %s , check its legal path related please..\n " , kpH264FileName );
260271 return ;
261272 }
262273 fprintf (stderr, " H264 source file name: %s..\n " , kpH264FileName);
@@ -505,14 +516,27 @@ int32_t main (int32_t iArgC, char* pArgV[]) {
505516 sDecParam .sVideoProperty .size = sizeof (sDecParam .sVideoProperty );
506517 sDecParam .eEcActiveIdc = ERROR_CON_SLICE_MV_COPY_CROSS_IDR_FREEZE_RES_CHANGE;
507518
519+ #if defined(NODEFS)
520+ EM_ASM (
521+ FS.mkdir (' /workload' );
522+ FS.mount (NODEFS, { root: ' .' }, ' /workload' );
523+ );
524+ #endif
525+
508526 if (iArgC < 2 ) {
509527 printf (" usage 1: h264dec.exe welsdec.cfg\n " );
510528 printf (" usage 2: h264dec.exe welsdec.264 out.yuv\n " );
511529 printf (" usage 3: h264dec.exe welsdec.264\n " );
512530 return 1 ;
513531 } else if (iArgC == 2 ) {
514532 if (strstr (pArgV[1 ], " .cfg" )) { // read config file //confirmed_safe_unsafe_usage
515- CReadConfig cReadCfg (pArgV[1 ]);
533+ string cfgFilePath;
534+ #if defined(NODEFS) || defined(MEMFS)
535+ cfgFilePath = string (CWD) + string (pArgV[1 ]);
536+ #else
537+ cfgFilePath = string (pArgV[1 ]);
538+ #endif
539+ CReadConfig cReadCfg (cfgFilePath.c_str ());
516540 string strTag[4 ];
517541 string strReconFile (" " );
518542
@@ -554,14 +578,23 @@ int32_t main (int32_t iArgC, char* pArgV[]) {
554578 }
555579 } else if (strstr (pArgV[1 ],
556580 " .264" )) { // no output dump yuv file, just try to render the decoded pictures //confirmed_safe_unsafe_usage
581+ #if defined(NODEFS) || defined(MEMFS)
582+ strInputFile = string (CWD) + string (pArgV[1 ]);
583+ #else
557584 strInputFile = pArgV[1 ];
585+ #endif
558586 sDecParam .uiTargetDqLayer = (uint8_t ) - 1 ;
559587 sDecParam .eEcActiveIdc = ERROR_CON_SLICE_COPY;
560588 sDecParam .sVideoProperty .eVideoBsType = VIDEO_BITSTREAM_DEFAULT;
561589 }
562590 } else { // iArgC > 2
591+ #if defined(NODEFS) || defined(MEMFS)
592+ strInputFile = string (CWD) + string (pArgV[1 ]);
593+ strOutputFile = string (CWD) + string (pArgV[2 ]);
594+ #else
563595 strInputFile = pArgV[1 ];
564596 strOutputFile = pArgV[2 ];
597+ #endif
565598 sDecParam .uiTargetDqLayer = (uint8_t ) - 1 ;
566599 sDecParam .eEcActiveIdc = ERROR_CON_SLICE_COPY;
567600 sDecParam .sVideoProperty .eVideoBsType = VIDEO_BITSTREAM_DEFAULT;
@@ -571,7 +604,11 @@ int32_t main (int32_t iArgC, char* pArgV[]) {
571604
572605 if (!strcmp (cmd, " -options" )) {
573606 if (i + 1 < iArgC)
607+ #if defined(NODEFS) || defined(MEMFS)
608+ strOptionFile = string (CWD) + string (pArgV[++i]);
609+ #else
574610 strOptionFile = pArgV[++i];
611+ #endif
575612 else {
576613 printf (" options file not specified.\n " );
577614 return 1 ;
@@ -585,7 +622,11 @@ int32_t main (int32_t iArgC, char* pArgV[]) {
585622 }
586623 } else if (!strcmp (cmd, " -length" )) {
587624 if (i + 1 < iArgC)
625+ #if defined(NODEFS) || defined(MEMFS)
626+ strLengthFile = string (CWD) + string (pArgV[++i]);
627+ #else
588628 strLengthFile = pArgV[++i];
629+ #endif
589630 else {
590631 printf (" lenght file not specified.\n " );
591632 return 1 ;
@@ -655,4 +696,4 @@ int32_t main (int32_t iArgC, char* pArgV[]) {
655696 }
656697
657698 return 0 ;
658- }
699+ }
0 commit comments