shithub: libvpx

Download patch

ref: 7e934408062703549ed4248a17d32963221a8d5c
parent: 5677b25b288c516d38d1e63b713565d6efe4fb8d
parent: 9596a4cc54cfc047d37df5d1058255410d518eb8
author: John Koleszar <[email protected]>
date: Mon Jun 17 06:31:54 EDT 2013

Merge "vpxdec: add --loops option"

--- a/vpxdec.c
+++ b/vpxdec.c
@@ -67,6 +67,8 @@
 };
 
 #include "args.h"
+static const arg_def_t looparg = ARG_DEF(NULL, "loops", 1,
+                                          "Number of times to decode the file");
 static const arg_def_t codecarg = ARG_DEF(NULL, "codec", 1,
                                           "Codec to use");
 static const arg_def_t use_yv12 = ARG_DEF(NULL, "yv12", 0,
@@ -676,7 +678,7 @@
 }
 
 
-int main(int argc, const char **argv_) {
+int main_loop(int argc, const char **argv_) {
   vpx_codec_ctx_t          decoder;
   char                  *fn = NULL;
   int                    i;
@@ -737,6 +739,8 @@
       else
         die("Error: Unrecognized argument (%s) to --codec\n",
             arg.val);
+    } else if (arg_match(&arg, &looparg, argi)) {
+      // no-op
     } else if (arg_match(&arg, &outputfile, argi))
       outfile_pattern = arg.val;
     else if (arg_match(&arg, &use_yv12, argi)) {
@@ -1151,4 +1155,26 @@
   free(argv);
 
   return frames_corrupted ? EXIT_FAILURE : EXIT_SUCCESS;
+}
+
+int main(int argc, const char **argv_) {
+  unsigned int loops = 1, i;
+  char **argv, **argi, **argj;
+  struct arg arg;
+  int error = 0;
+
+  argv = argv_dup(argc - 1, argv_ + 1);
+  for (argi = argj = argv; (*argj = *argi); argi += arg.argv_step) {
+    memset(&arg, 0, sizeof(arg));
+    arg.argv_step = 1;
+
+    if (arg_match(&arg, &looparg, argi)) {
+      loops = arg_parse_uint(&arg);
+      break;
+    }
+  }
+  free(argv);
+  for (i = 0; !error && i < loops; i++)
+    error = main_loop(argc, argv_);
+  return error;
 }