diff mbox series

[FFmpeg-devel,v2,13/17] fftools/ffmpeg_filter: set strict_std_compliance

Message ID 20240408125950.53472-14-ffmpeg@haasn.xyz
State New
Headers show
Series Add avcodec_get_supported_config() | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Niklas Haas April 8, 2024, 12:57 p.m. UTC
From: Niklas Haas <git@haasn.dev>

For avcodec_get_supported_config(), which requires this value be set on
the actual ost->enc_ctx being queried.
---
 fftools/ffmpeg_filter.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

Comments

Niklas Haas April 9, 2024, 1:01 p.m. UTC | #1
On Mon, 08 Apr 2024 14:57:17 +0200 Niklas Haas <ffmpeg@haasn.xyz> wrote:
> From: Niklas Haas <git@haasn.dev>
> 
> For avcodec_get_supported_config(), which requires this value be set on
> the actual ost->enc_ctx being queried.
> ---
>  fftools/ffmpeg_filter.c | 16 ++++++----------
>  1 file changed, 6 insertions(+), 10 deletions(-)
> 
> diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
> index ac04841a16c..9ff064f5f68 100644
> --- a/fftools/ffmpeg_filter.c
> +++ b/fftools/ffmpeg_filter.c
> @@ -770,6 +770,7 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost,
>      FilterGraph  *fg = ofilter->graph;
>      FilterGraphPriv *fgp = fgp_from_fg(fg);
>      const AVCodec *c = ost->enc_ctx->codec;
> +    const AVDictionaryEntry *strict = av_dict_get(ost->encoder_opts, "strict", NULL, 0);
>      int ret;
>  
>      av_assert0(!ofilter->ost);
> @@ -780,6 +781,10 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost,
>      ofp->ts_offset     = of->start_time == AV_NOPTS_VALUE ? 0 : of->start_time;
>      ofp->enc_timebase = ost->enc_timebase;
>  
> +    /* Ensure this is up-to-date for avcodefc_get_supported_config() */
> +    if (strict)
> +        av_opt_set(ost->enc_ctx, strict->key, strict->value, 0);
> +
>      switch (ost->enc_ctx->codec_type) {
>      case AVMEDIA_TYPE_VIDEO:
>          ofp->width      = ost->enc_ctx->width;
> @@ -800,16 +805,7 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost,
>                      { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P,
>                        AV_PIX_FMT_NONE };
>  
> -                const AVDictionaryEntry *strict = av_dict_get(ost->encoder_opts, "strict", NULL, 0);
> -                int strict_val = ost->enc_ctx->strict_std_compliance;
> -
> -                if (strict) {
> -                    const AVOption *o = av_opt_find(ost->enc_ctx, strict->key, NULL, 0, 0);
> -                    av_assert0(o);
> -                    av_opt_eval_int(ost->enc_ctx, o, strict->value, &strict_val);
> -                }
> -
> -                if (strict_val > FF_COMPLIANCE_UNOFFICIAL)
> +                if (ost->enc_ctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL)
>                      ofp->formats = mjpeg_formats;
>              }
>          }
> -- 
> 2.44.0
> 

Note: Will be no longer needed if elenril's encoder_opts series is
merged first, so that would be preferred as this is sort of a hack.
diff mbox series

Patch

diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index ac04841a16c..9ff064f5f68 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -770,6 +770,7 @@  int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost,
     FilterGraph  *fg = ofilter->graph;
     FilterGraphPriv *fgp = fgp_from_fg(fg);
     const AVCodec *c = ost->enc_ctx->codec;
+    const AVDictionaryEntry *strict = av_dict_get(ost->encoder_opts, "strict", NULL, 0);
     int ret;
 
     av_assert0(!ofilter->ost);
@@ -780,6 +781,10 @@  int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost,
     ofp->ts_offset     = of->start_time == AV_NOPTS_VALUE ? 0 : of->start_time;
     ofp->enc_timebase = ost->enc_timebase;
 
+    /* Ensure this is up-to-date for avcodefc_get_supported_config() */
+    if (strict)
+        av_opt_set(ost->enc_ctx, strict->key, strict->value, 0);
+
     switch (ost->enc_ctx->codec_type) {
     case AVMEDIA_TYPE_VIDEO:
         ofp->width      = ost->enc_ctx->width;
@@ -800,16 +805,7 @@  int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost,
                     { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P,
                       AV_PIX_FMT_NONE };
 
-                const AVDictionaryEntry *strict = av_dict_get(ost->encoder_opts, "strict", NULL, 0);
-                int strict_val = ost->enc_ctx->strict_std_compliance;
-
-                if (strict) {
-                    const AVOption *o = av_opt_find(ost->enc_ctx, strict->key, NULL, 0, 0);
-                    av_assert0(o);
-                    av_opt_eval_int(ost->enc_ctx, o, strict->value, &strict_val);
-                }
-
-                if (strict_val > FF_COMPLIANCE_UNOFFICIAL)
+                if (ost->enc_ctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL)
                     ofp->formats = mjpeg_formats;
             }
         }