]> git.sesse.net Git - ffmpeg/blobdiff - cmdutils.c
rmdec: set bit rate for ra4
[ffmpeg] / cmdutils.c
index dc32807b55eaa60294f37c0370f07978ae308df1..666b0394e482299259cae476b8dc1f257f47381b 100644 (file)
@@ -480,6 +480,9 @@ int opt_default(void *optctx, const char *opt, const char *arg)
     const AVClass *cc = avcodec_get_class(), *fc = avformat_get_class();
     const AVClass *sc, *swr_class;
 
+    if (!strcmp(opt, "debug") || !strcmp(opt, "fdebug"))
+        av_log_set_level(AV_LOG_DEBUG);
+
     if (!(p = strchr(opt, ':')))
         p = opt + strlen(opt);
     av_strlcpy(opt_stripped, opt, FFMIN(sizeof(opt_stripped), p - opt + 1));
@@ -534,14 +537,15 @@ int opt_default(void *optctx, const char *opt, const char *arg)
  *
  * @return index of the group definition that matched or -1 if none
  */
-static int match_group_separator(const OptionGroupDef *groups, const char *opt)
+static int match_group_separator(const OptionGroupDef *groups, int nb_groups,
+                                 const char *opt)
 {
-    const OptionGroupDef *p = groups;
+    int i;
 
-    while (p->name) {
+    for (i = 0; i < nb_groups; i++) {
+        const OptionGroupDef *p = &groups[i];
         if (p->sep && !strcmp(p->sep, opt))
-            return p - groups;
-        p++;
+            return i;
     }
 
     return -1;
@@ -568,6 +572,7 @@ static void finish_group(OptionParseContext *octx, int group_idx,
 #if CONFIG_SWSCALE
     g->sws_opts    = sws_opts;
 #endif
+    g->swr_opts    = swr_opts;
     g->codec_opts  = codec_opts;
     g->format_opts = format_opts;
 
@@ -576,6 +581,7 @@ static void finish_group(OptionParseContext *octx, int group_idx,
 #if CONFIG_SWSCALE
     sws_opts    = NULL;
 #endif
+    swr_opts    = NULL;
     init_opts();
 
     memset(&octx->cur_group, 0, sizeof(octx->cur_group));
@@ -597,17 +603,14 @@ static void add_opt(OptionParseContext *octx, const OptionDef *opt,
 }
 
 static void init_parse_context(OptionParseContext *octx,
-                               const OptionGroupDef *groups)
+                               const OptionGroupDef *groups, int nb_groups)
 {
     static const OptionGroupDef global_group = { "global" };
-    const OptionGroupDef *g = groups;
     int i;
 
     memset(octx, 0, sizeof(*octx));
 
-    while (g->name)
-        g++;
-    octx->nb_groups = g - groups;
+    octx->nb_groups = nb_groups;
     octx->groups    = av_mallocz(sizeof(*octx->groups) * octx->nb_groups);
     if (!octx->groups)
         exit(1);
@@ -635,6 +638,8 @@ void uninit_parse_context(OptionParseContext *octx)
 #if CONFIG_SWSCALE
             sws_freeContext(l->groups[j].sws_opts);
 #endif
+            if(CONFIG_SWRESAMPLE)
+                swr_free(&l->groups[j].swr_opts);
         }
         av_freep(&l->groups);
     }
@@ -648,14 +653,14 @@ void uninit_parse_context(OptionParseContext *octx)
 
 int split_commandline(OptionParseContext *octx, int argc, char *argv[],
                       const OptionDef *options,
-                      const OptionGroupDef *groups)
+                      const OptionGroupDef *groups, int nb_groups)
 {
     int optindex = 1;
 
     /* perform system-dependent conversions for arguments list */
     prepare_app_arguments(&argc, &argv);
 
-    init_parse_context(octx, groups);
+    init_parse_context(octx, groups, nb_groups);
     av_log(NULL, AV_LOG_DEBUG, "Splitting the commandline.\n");
 
     while (optindex < argc) {
@@ -683,7 +688,7 @@ do {                                                                           \
 } while (0)
 
         /* named group separators, e.g. -i */
-        if ((ret = match_group_separator(groups, opt)) >= 0) {
+        if ((ret = match_group_separator(groups, nb_groups, opt)) >= 0) {
             GET_ARG(arg);
             finish_group(octx, ret, arg);
             av_log(NULL, AV_LOG_DEBUG, " matched as %s with argument '%s'.\n",
@@ -905,12 +910,6 @@ int opt_cpuflags(void *optctx, const char *opt, const char *arg)
     return 0;
 }
 
-int opt_codec_debug(void *optctx, const char *opt, const char *arg)
-{
-    av_log_set_level(AV_LOG_DEBUG);
-    return opt_default(NULL, opt, arg);
-}
-
 int opt_timelimit(void *optctx, const char *opt, const char *arg)
 {
 #if HAVE_SETRLIMIT