]> granicus.if.org Git - libvpx/commitdiff
bugfix: all vpxenc arguments were not parsed under all conditions
authorJames Berry <jamesberry@google.com>
Mon, 28 Nov 2011 19:09:35 +0000 (14:09 -0500)
committerJames Berry <jamesberry@google.com>
Mon, 28 Nov 2011 20:58:50 +0000 (15:58 -0500)
dynamicly assign ARG_CTRL_CNT_MAX and
add check to make sure argument instance
doesnt already exist before creating a duplicate

Change-Id: I4f78a9c5346cda8e812cd89c077afe8996493508

vpxenc.c

index e8bd86daffec6558ebc9a3e051e87273934c1a5f..2e14f247c3e22324fc5615553638fdaa93b9045e 100644 (file)
--- a/vpxenc.c
+++ b/vpxenc.c
@@ -1442,7 +1442,8 @@ static void show_rate_histogram(struct rate_hist          *hist,
     show_histogram(hist->bucket, buckets, hist->total, scale);
 }
 
-#define ARG_CTRL_CNT_MAX 10
+#define NELEMENTS(x) (sizeof(x)/sizeof(x[0]))
+#define ARG_CTRL_CNT_MAX NELEMENTS(vp8_arg_ctrl_map)
 
 int main(int argc, const char **argv_)
 {
@@ -1721,14 +1722,26 @@ int main(int argc, const char **argv_)
         {
             if (arg_match(&arg, ctrl_args[i], argi))
             {
+                int j;
                 match = 1;
 
-                if (arg_ctrl_cnt < ARG_CTRL_CNT_MAX)
+                /* Point either to the next free element or the first
+                * instance of this control.
+                */
+                for(j=0; j<arg_ctrl_cnt; j++)
+                    if(arg_ctrls[j][0] == ctrl_args_map[i])
+                        break;
+
+                /* Update/insert */
+                assert(j < ARG_CTRL_CNT_MAX);
+                if (j < ARG_CTRL_CNT_MAX)
                 {
-                    arg_ctrls[arg_ctrl_cnt][0] = ctrl_args_map[i];
-                    arg_ctrls[arg_ctrl_cnt][1] = arg_parse_enum_or_int(&arg);
-                    arg_ctrl_cnt++;
+                    arg_ctrls[j][0] = ctrl_args_map[i];
+                    arg_ctrls[j][1] = arg_parse_enum_or_int(&arg);
+                    if(j == arg_ctrl_cnt)
+                        arg_ctrl_cnt++;
                 }
+
             }
         }