shithub: openh264

Download patch

ref: 9254d722d397569a1e4d2bbce99bde6c5374830c
parent: d1f8b10b2451304780c7a17cc7eccb28d8dbd905
parent: e69983d6de4290b3d322d6d3410cb861ccdb4863
author: Ethan Hugg <ethanhugg@gmail.com>
date: Thu Dec 26 12:52:49 EST 2013

Merge pull request #62 from varunbpatil/cleanup

minor cleanup and bug fixes

--- a/codec/console/dec/src/h264dec.cpp
+++ b/codec/console/dec/src/h264dec.cpp
@@ -344,7 +344,6 @@
         printf ("Specified file: %s not exist, maybe invalid path or parameter settting.\n", cReadCfg.GetFileName().c_str());
         return 1;
       }
-      memset (&sDecParam, 0, sizeof (sDecParam));
 
       while (!cReadCfg.EndOfFile()) {
         long nRd = cReadCfg.ReadLine (&strTag[0]);
@@ -382,7 +381,6 @@
     } else if (strstr (pArgV[1],
                        ".264")) { // no output dump yuv file, just try to render the decoded pictures //confirmed_safe_unsafe_usage
       strInputFile	= pArgV[1];
-      memset (&sDecParam, 0, sizeof (sDecParam));
       sDecParam.iOutputColorFormat          = videoFormatI420;
       sDecParam.uiTargetDqLayer	          = (uint8_t) - 1;
       sDecParam.uiEcActiveFlag	          = 1;
@@ -391,26 +389,28 @@
   } else { //iArgC > 2
     strInputFile	= pArgV[1];
     strOutputFile	= pArgV[2];
-    memset (&sDecParam, 0, sizeof (sDecParam));
     sDecParam.iOutputColorFormat	= videoFormatI420;
     sDecParam.uiTargetDqLayer	= (uint8_t) - 1;
     sDecParam.uiEcActiveFlag	= 1;
     sDecParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT;
     if (iArgC > 3) {
-      // Basic option parser. Note that this is not safe about the
-      // number of remaining arguments.
-      // TODO: rewrite
       for (int i = 3; i < iArgC; i++) {
         char* cmd = pArgV[i];
 
         if (!strcmp (cmd, "-options")) {
-          strOutputFile = pArgV[i + 1];
-          i += 2;
+          if (i + 1 < iArgC)
+            strOptionFile = pArgV[i++];
+          else {
+            printf ("options file not specified.\n");
+            return 1;
+          }
         } else if (!strcmp (cmd, "-trace")) {
-          WelsStderrSetTraceLevel (atoi (pArgV[i + 1]));
-          i += 2;
-        } else {
-          i++;
+          if (i + 1 < iArgC)
+            WelsStderrSetTraceLevel (atoi (pArgV[i++]));
+          else {
+            printf ("trace level not specified.\n");
+            return 1;
+          }
         }
       }
     }
@@ -494,4 +494,3 @@
 
   return 0;
 }
-
--- a/codec/console/enc/src/welsenc.cpp
+++ b/codec/console/enc/src/welsenc.cpp
@@ -1416,10 +1416,7 @@
   if (argc < 2) {
     goto exit;
   } else {
-    string	strCfgFileName = argv[1];
-    basic_string <char>::size_type index;
-    index = strCfgFileName.rfind (".cfg");	// check configuration type (like .cfg?)
-    if (index == std::string::npos) {
+    if (!strstr(argv[1], ".cfg")) { // check configuration type (like .cfg?)
       if (argc > 2) {
         iRet = ProcessEncodingSvcWithParam (pSVCEncoder, argc, argv);
         if (iRet != 0)