diff mbox series

[FFmpeg-devel,1/2] fftools/ffmpeg_opt: warn about overwritten parsed options

Message ID 20200229222222.28130-1-cus@passwd.hu
State Accepted
Headers show
Series [FFmpeg-devel,1/2] fftools/ffmpeg_opt: warn about overwritten parsed options | expand

Checks

Context Check Description
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Marton Balint Feb. 29, 2020, 10:22 p.m. UTC
Signed-off-by: Marton Balint <cus@passwd.hu>
---
 fftools/ffmpeg_opt.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 67 insertions(+), 3 deletions(-)

Comments

Marton Balint March 7, 2020, 7:52 p.m. UTC | #1
On Sat, 29 Feb 2020, Marton Balint wrote:

> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
> fftools/ffmpeg_opt.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++---
> 1 file changed, 67 insertions(+), 3 deletions(-)

Ping, will apply soon.

Thanks,
Marton

>
> diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
> index 12d44886ee..3d6fafe073 100644
> --- a/fftools/ffmpeg_opt.c
> +++ b/fftools/ffmpeg_opt.c
> @@ -44,16 +44,80 @@
> 
> #define DEFAULT_PASS_LOGFILENAME_PREFIX "ffmpeg2pass"
> 
> +#define SPECIFIER_OPT_FMT_str  "%s"
> +#define SPECIFIER_OPT_FMT_i    "%i"
> +#define SPECIFIER_OPT_FMT_i64  "%"PRId64"d"
> +#define SPECIFIER_OPT_FMT_ui64 "%"PRIu64"d"
> +#define SPECIFIER_OPT_FMT_f    "%f"
> +#define SPECIFIER_OPT_FMT_dbl  "%lf"
> +
> +static const char *opt_name_codec_names[]               = {"c", "codec", "acodec", "vcodec", "scodec", "dcodec", NULL};
> +static const char *opt_name_audio_channels[]            = {"ac", NULL};
> +static const char *opt_name_audio_sample_rate[]         = {"ar", NULL};
> +static const char *opt_name_frame_rates[]               = {"r", NULL};
> +static const char *opt_name_frame_sizes[]               = {"s", NULL};
> +static const char *opt_name_frame_pix_fmts[]            = {"pix_fmt", NULL};
> +static const char *opt_name_ts_scale[]                  = {"itsscale", NULL};
> +static const char *opt_name_hwaccels[]                  = {"hwaccel", NULL};
> +static const char *opt_name_hwaccel_devices[]           = {"hwaccel_device", NULL};
> +static const char *opt_name_hwaccel_output_formats[]    = {"hwaccel_output_format", NULL};
> +static const char *opt_name_autorotate[]                = {"autorotate", NULL};
> +static const char *opt_name_max_frames[]                = {"frames", "aframes", "vframes", "dframes", NULL};
> +static const char *opt_name_bitstream_filters[]         = {"bsf", "absf", "vbsf", NULL};
> +static const char *opt_name_codec_tags[]                = {"tag", "atag", "vtag", "stag", NULL};
> +static const char *opt_name_sample_fmts[]               = {"sample_fmt", NULL};
> +static const char *opt_name_qscale[]                    = {"q", "qscale", NULL};
> +static const char *opt_name_forced_key_frames[]         = {"forced_key_frames", NULL};
> +static const char *opt_name_force_fps[]                 = {"force_fps", NULL};
> +static const char *opt_name_frame_aspect_ratios[]       = {"aspect", NULL};
> +static const char *opt_name_rc_overrides[]              = {"rc_override", NULL};
> +static const char *opt_name_intra_matrices[]            = {"intra_matrix", NULL};
> +static const char *opt_name_inter_matrices[]            = {"inter_matrix", NULL};
> +static const char *opt_name_chroma_intra_matrices[]     = {"chroma_intra_matrix", NULL};
> +static const char *opt_name_top_field_first[]           = {"top", NULL};
> +static const char *opt_name_presets[]                   = {"pre", "apre", "vpre", "spre", NULL};
> +static const char *opt_name_copy_initial_nonkeyframes[] = {"copyinkfr", NULL};
> +static const char *opt_name_copy_prior_start[]          = {"copypriorss", NULL};
> +static const char *opt_name_filters[]                   = {"filter", "af", "vf", NULL};
> +static const char *opt_name_filter_scripts[]            = {"filter_script", NULL};
> +static const char *opt_name_reinit_filters[]            = {"reinit_filter", NULL};
> +static const char *opt_name_fix_sub_duration[]          = {"fix_sub_duration", NULL};
> +static const char *opt_name_canvas_sizes[]              = {"canvas_size", NULL};
> +static const char *opt_name_pass[]                      = {"pass", NULL};
> +static const char *opt_name_passlogfiles[]              = {"passlogfile", NULL};
> +static const char *opt_name_max_muxing_queue_size[]     = {"max_muxing_queue_size", NULL};
> +static const char *opt_name_guess_layout_max[]          = {"guess_layout_max", NULL};
> +static const char *opt_name_apad[]                      = {"apad", NULL};
> +static const char *opt_name_discard[]                   = {"discard", NULL};
> +static const char *opt_name_disposition[]               = {"disposition", NULL};
> +static const char *opt_name_time_bases[]                = {"time_base", NULL};
> +static const char *opt_name_enc_time_bases[]            = {"enc_time_base", NULL};
> +
> +#define WARN_MULTIPLE_OPT_USAGE(name, type, so, st)\
> +{\
> +    char namestr[128] = "";\
> +    const char *spec = so->specifier && so->specifier[0] ? so->specifier : "";\
> +    for (i = 0; opt_name_##name[i]; i++)\
> +        av_strlcatf(namestr, sizeof(namestr), "-%s%s", opt_name_##name[i], opt_name_##name[i+1] ? (opt_name_##name[i+2] ? ", " : " or ") : "");\
> +    av_log(NULL, AV_LOG_WARNING, "Multiple %s options specified for stream %d, only the last option '-%s%s%s "SPECIFIER_OPT_FMT_##type"' will be used.\n",\
> +           namestr, st->index, opt_name_##name[0], spec[0] ? ":" : "", spec, so->u.type);\
> +}
> +
> #define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)\
> {\
> -    int i, ret;\
> +    int i, ret, matches = 0;\
> +    SpecifierOpt *so;\
>     for (i = 0; i < o->nb_ ## name; i++) {\
>         char *spec = o->name[i].specifier;\
> -        if ((ret = check_stream_specifier(fmtctx, st, spec)) > 0)\
> +        if ((ret = check_stream_specifier(fmtctx, st, spec)) > 0) {\
>             outvar = o->name[i].u.type;\
> -        else if (ret < 0)\
> +            so = &o->name[i];\
> +            matches++;\
> +        } else if (ret < 0)\
>             exit_program(1);\
>     }\
> +    if (matches > 1)\
> +       WARN_MULTIPLE_OPT_USAGE(name, type, so, st);\
> }
> 
> #define MATCH_PER_TYPE_OPT(name, type, outvar, fmtctx, mediatype)\
> -- 
> 2.16.4
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Gyan Doshi March 8, 2020, 11:36 a.m. UTC | #2
On 08-03-2020 01:22 am, Marton Balint wrote:
>
>
> On Sat, 29 Feb 2020, Marton Balint wrote:
>
>> Signed-off-by: Marton Balint <cus@passwd.hu>
>> ---
>> fftools/ffmpeg_opt.c | 70 
>> +++++++++++++++++++++++++++++++++++++++++++++++++---
>> 1 file changed, 67 insertions(+), 3 deletions(-)
>
> Ping, will apply soon.

LGTM.

Gyan
Marton Balint March 8, 2020, 6:35 p.m. UTC | #3
On Sun, 8 Mar 2020, Gyan Doshi wrote:

>
>
> On 08-03-2020 01:22 am, Marton Balint wrote:
>>
>>
>> On Sat, 29 Feb 2020, Marton Balint wrote:
>>
>>> Signed-off-by: Marton Balint <cus@passwd.hu>
>>> ---
>>> fftools/ffmpeg_opt.c | 70 
>>> +++++++++++++++++++++++++++++++++++++++++++++++++---
>>> 1 file changed, 67 insertions(+), 3 deletions(-)
>>
>> Ping, will apply soon.
>
> LGTM.

Thanks, applied the series.

Regards,
Marton
Carl Eugen Hoyos March 8, 2020, 6:49 p.m. UTC | #4
Am So., 8. März 2020 um 19:35 Uhr schrieb Marton Balint <cus@passwd.hu>:
>
>
>
> On Sun, 8 Mar 2020, Gyan Doshi wrote:
>
> >
> >
> > On 08-03-2020 01:22 am, Marton Balint wrote:
> >>
> >>
> >> On Sat, 29 Feb 2020, Marton Balint wrote:
> >>
> >>> Signed-off-by: Marton Balint <cus@passwd.hu>
> >>> ---
> >>> fftools/ffmpeg_opt.c | 70
> >>> +++++++++++++++++++++++++++++++++++++++++++++++++---
> >>> 1 file changed, 67 insertions(+), 3 deletions(-)
> >>
> >> Ping, will apply soon.
> >
> > LGTM.
>
> Thanks, applied the series.

Thank you!

Carl Eugen
diff mbox series

Patch

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 12d44886ee..3d6fafe073 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -44,16 +44,80 @@ 
 
 #define DEFAULT_PASS_LOGFILENAME_PREFIX "ffmpeg2pass"
 
+#define SPECIFIER_OPT_FMT_str  "%s"
+#define SPECIFIER_OPT_FMT_i    "%i"
+#define SPECIFIER_OPT_FMT_i64  "%"PRId64"d"
+#define SPECIFIER_OPT_FMT_ui64 "%"PRIu64"d"
+#define SPECIFIER_OPT_FMT_f    "%f"
+#define SPECIFIER_OPT_FMT_dbl  "%lf"
+
+static const char *opt_name_codec_names[]               = {"c", "codec", "acodec", "vcodec", "scodec", "dcodec", NULL};
+static const char *opt_name_audio_channels[]            = {"ac", NULL};
+static const char *opt_name_audio_sample_rate[]         = {"ar", NULL};
+static const char *opt_name_frame_rates[]               = {"r", NULL};
+static const char *opt_name_frame_sizes[]               = {"s", NULL};
+static const char *opt_name_frame_pix_fmts[]            = {"pix_fmt", NULL};
+static const char *opt_name_ts_scale[]                  = {"itsscale", NULL};
+static const char *opt_name_hwaccels[]                  = {"hwaccel", NULL};
+static const char *opt_name_hwaccel_devices[]           = {"hwaccel_device", NULL};
+static const char *opt_name_hwaccel_output_formats[]    = {"hwaccel_output_format", NULL};
+static const char *opt_name_autorotate[]                = {"autorotate", NULL};
+static const char *opt_name_max_frames[]                = {"frames", "aframes", "vframes", "dframes", NULL};
+static const char *opt_name_bitstream_filters[]         = {"bsf", "absf", "vbsf", NULL};
+static const char *opt_name_codec_tags[]                = {"tag", "atag", "vtag", "stag", NULL};
+static const char *opt_name_sample_fmts[]               = {"sample_fmt", NULL};
+static const char *opt_name_qscale[]                    = {"q", "qscale", NULL};
+static const char *opt_name_forced_key_frames[]         = {"forced_key_frames", NULL};
+static const char *opt_name_force_fps[]                 = {"force_fps", NULL};
+static const char *opt_name_frame_aspect_ratios[]       = {"aspect", NULL};
+static const char *opt_name_rc_overrides[]              = {"rc_override", NULL};
+static const char *opt_name_intra_matrices[]            = {"intra_matrix", NULL};
+static const char *opt_name_inter_matrices[]            = {"inter_matrix", NULL};
+static const char *opt_name_chroma_intra_matrices[]     = {"chroma_intra_matrix", NULL};
+static const char *opt_name_top_field_first[]           = {"top", NULL};
+static const char *opt_name_presets[]                   = {"pre", "apre", "vpre", "spre", NULL};
+static const char *opt_name_copy_initial_nonkeyframes[] = {"copyinkfr", NULL};
+static const char *opt_name_copy_prior_start[]          = {"copypriorss", NULL};
+static const char *opt_name_filters[]                   = {"filter", "af", "vf", NULL};
+static const char *opt_name_filter_scripts[]            = {"filter_script", NULL};
+static const char *opt_name_reinit_filters[]            = {"reinit_filter", NULL};
+static const char *opt_name_fix_sub_duration[]          = {"fix_sub_duration", NULL};
+static const char *opt_name_canvas_sizes[]              = {"canvas_size", NULL};
+static const char *opt_name_pass[]                      = {"pass", NULL};
+static const char *opt_name_passlogfiles[]              = {"passlogfile", NULL};
+static const char *opt_name_max_muxing_queue_size[]     = {"max_muxing_queue_size", NULL};
+static const char *opt_name_guess_layout_max[]          = {"guess_layout_max", NULL};
+static const char *opt_name_apad[]                      = {"apad", NULL};
+static const char *opt_name_discard[]                   = {"discard", NULL};
+static const char *opt_name_disposition[]               = {"disposition", NULL};
+static const char *opt_name_time_bases[]                = {"time_base", NULL};
+static const char *opt_name_enc_time_bases[]            = {"enc_time_base", NULL};
+
+#define WARN_MULTIPLE_OPT_USAGE(name, type, so, st)\
+{\
+    char namestr[128] = "";\
+    const char *spec = so->specifier && so->specifier[0] ? so->specifier : "";\
+    for (i = 0; opt_name_##name[i]; i++)\
+        av_strlcatf(namestr, sizeof(namestr), "-%s%s", opt_name_##name[i], opt_name_##name[i+1] ? (opt_name_##name[i+2] ? ", " : " or ") : "");\
+    av_log(NULL, AV_LOG_WARNING, "Multiple %s options specified for stream %d, only the last option '-%s%s%s "SPECIFIER_OPT_FMT_##type"' will be used.\n",\
+           namestr, st->index, opt_name_##name[0], spec[0] ? ":" : "", spec, so->u.type);\
+}
+
 #define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)\
 {\
-    int i, ret;\
+    int i, ret, matches = 0;\
+    SpecifierOpt *so;\
     for (i = 0; i < o->nb_ ## name; i++) {\
         char *spec = o->name[i].specifier;\
-        if ((ret = check_stream_specifier(fmtctx, st, spec)) > 0)\
+        if ((ret = check_stream_specifier(fmtctx, st, spec)) > 0) {\
             outvar = o->name[i].u.type;\
-        else if (ret < 0)\
+            so = &o->name[i];\
+            matches++;\
+        } else if (ret < 0)\
             exit_program(1);\
     }\
+    if (matches > 1)\
+       WARN_MULTIPLE_OPT_USAGE(name, type, so, st);\
 }
 
 #define MATCH_PER_TYPE_OPT(name, type, outvar, fmtctx, mediatype)\