[FFmpeg-devel] [PATCH 1/4] avcodec/vp8: Fix wrong #endif comment

Peter Ross pross at xvid.org
Sat Mar 8 22:19:55 EET 2025


On Sat, Mar 08, 2025 at 04:29:06AM +0100, Andreas Rheinhardt wrote:
> Patches attached
> 
> - Andreas

> From 54e27b588e18fdfe277a77b0f385cb02731022b9 Mon Sep 17 00:00:00 2001
> From: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> Date: Thu, 6 Mar 2025 17:56:08 +0100
> Subject: [PATCH 1/4] avcodec/vp8: Fix wrong #endif comment
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> ---
>  libavcodec/vp8.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
> index 3651688c10..6337fa173b 100644
> --- a/libavcodec/vp8.c
> +++ b/libavcodec/vp8.c
> @@ -2984,4 +2984,4 @@ const FFCodec ff_vp8_decoder = {
>                                 NULL
>                             },
>  };
> -#endif /* CONFIG_VP7_DECODER */
> +#endif /* CONFIG_VP8_DECODER */
> -- 
> 2.45.2
> 

> From 2360e180fabb2dc8577018283c8b3f5f46425a51 Mon Sep 17 00:00:00 2001
> From: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> Date: Thu, 6 Mar 2025 18:00:28 +0100
> Subject: [PATCH 2/4] avcodec/vp8: Move codec-specific init code out of common
>  init
> 
> While just at it, also move the init functions inside
> the #if CONFIG_VP?_DECODER (to avoid linking failures).
> While just at it, also declare these init functions
> as av_cold and uninline the remaining common init function.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> ---
>  libavcodec/vp8.c | 48 ++++++++++++++++++++++++------------------------
>  1 file changed, 24 insertions(+), 24 deletions(-)
> 
> diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
> index 6337fa173b..be8dbde91e 100644
> --- a/libavcodec/vp8.c
> +++ b/libavcodec/vp8.c
> @@ -2858,8 +2858,7 @@ av_cold int ff_vp8_decode_free(AVCodecContext *avctx)
>      return 0;
>  }
>  
> -static av_always_inline
> -int vp78_decode_init(AVCodecContext *avctx, int is_vp7)
> +static av_cold void vp78_decode_init(AVCodecContext *avctx)
>  {
>      VP8Context *s = avctx->priv_data;
>  
> @@ -2870,37 +2869,25 @@ int vp78_decode_init(AVCodecContext *avctx, int is_vp7)
>      ff_videodsp_init(&s->vdsp, 8);
>  
>      ff_vp78dsp_init(&s->vp8dsp);
> -    if (CONFIG_VP7_DECODER && is_vp7) {
> -        ff_h264_pred_init(&s->hpc, AV_CODEC_ID_VP7, 8, 1);
> -        ff_vp7dsp_init(&s->vp8dsp);
> -        s->decode_mb_row_no_filter = vp7_decode_mb_row_no_filter;
> -        s->filter_mb_row           = vp7_filter_mb_row;
> -    } else if (CONFIG_VP8_DECODER && !is_vp7) {
> -        ff_h264_pred_init(&s->hpc, AV_CODEC_ID_VP8, 8, 1);
> -        ff_vp8dsp_init(&s->vp8dsp);
> -        s->decode_mb_row_no_filter = vp8_decode_mb_row_no_filter;
> -        s->filter_mb_row           = vp8_filter_mb_row;
> -    }
>  
>      /* does not change for VP8 */
>      memcpy(s->prob[0].scan, ff_zigzag_scan, sizeof(s->prob[0].scan));
> -
> -    return 0;
>  }
>  
> -#if CONFIG_VP7_DECODER
> -static int vp7_decode_init(AVCodecContext *avctx)
> -{
> -    return vp78_decode_init(avctx, IS_VP7);
> -}
> -#endif /* CONFIG_VP7_DECODER */
> -
> +#if CONFIG_VP8_DECODER
>  av_cold int ff_vp8_decode_init(AVCodecContext *avctx)
>  {
> -    return vp78_decode_init(avctx, IS_VP8);
> +    VP8Context *s = avctx->priv_data;
> +
> +    vp78_decode_init(avctx);
> +    ff_h264_pred_init(&s->hpc, AV_CODEC_ID_VP8, 8, 1);
> +    ff_vp8dsp_init(&s->vp8dsp);
> +    s->decode_mb_row_no_filter = vp8_decode_mb_row_no_filter;
> +    s->filter_mb_row           = vp8_filter_mb_row;
> +
> +    return 0;
>  }
>  
> -#if CONFIG_VP8_DECODER
>  #if HAVE_THREADS
>  static void vp8_replace_frame(VP8Frame *dst, const VP8Frame *src)
>  {
> @@ -2944,6 +2931,19 @@ static int vp8_decode_update_thread_context(AVCodecContext *dst,
>  #endif /* CONFIG_VP8_DECODER */
>  
>  #if CONFIG_VP7_DECODER
> +av_cold static int vp7_decode_init(AVCodecContext *avctx)
> +{
> +    VP8Context *s = avctx->priv_data;
> +
> +    vp78_decode_init(avctx);
> +    ff_h264_pred_init(&s->hpc, AV_CODEC_ID_VP7, 8, 1);
> +    ff_vp7dsp_init(&s->vp8dsp);
> +    s->decode_mb_row_no_filter = vp7_decode_mb_row_no_filter;
> +    s->filter_mb_row           = vp7_filter_mb_row;
> +
> +    return 0;
> +}
> +
>  const FFCodec ff_vp7_decoder = {
>      .p.name                = "vp7",
>      CODEC_LONG_NAME("On2 VP7"),
> -- 
> 2.45.2
> 

> From 538cb0a9226066d4fe13ef07aad70e6f14273939 Mon Sep 17 00:00:00 2001
> From: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> Date: Thu, 6 Mar 2025 18:16:50 +0100
> Subject: [PATCH 3/4] avcodec/vp8: Move VPx specific functions inside #if
>  CONFIG_VPx block
> 
> where appropriate. Avoids including ff_vp8_decode_frame()
> when the VP8 decoder is disabled.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> ---
>  libavcodec/vp8.c | 74 +++++++++++++++++++++++-------------------------
>  1 file changed, 36 insertions(+), 38 deletions(-)
> 
> diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
> index be8dbde91e..77f7b4d4df 100644
> --- a/libavcodec/vp8.c
> +++ b/libavcodec/vp8.c
> @@ -2512,18 +2512,6 @@ static av_always_inline int decode_mb_row_no_filter(AVCodecContext *avctx, void
>      return 0;
>  }
>  
> -static int vp7_decode_mb_row_no_filter(AVCodecContext *avctx, void *tdata,
> -                                        int jobnr, int threadnr)
> -{
> -    return decode_mb_row_no_filter(avctx, tdata, jobnr, threadnr, 1);
> -}
> -
> -static int vp8_decode_mb_row_no_filter(AVCodecContext *avctx, void *tdata,
> -                                        int jobnr, int threadnr)
> -{
> -    return decode_mb_row_no_filter(avctx, tdata, jobnr, threadnr, 0);
> -}
> -
>  static av_always_inline void filter_mb_row(AVCodecContext *avctx, void *tdata,
>                                int jobnr, int threadnr, int is_vp7)
>  {
> @@ -2583,18 +2571,6 @@ static av_always_inline void filter_mb_row(AVCodecContext *avctx, void *tdata,
>      }
>  }
>  
> -static void vp7_filter_mb_row(AVCodecContext *avctx, void *tdata,
> -                              int jobnr, int threadnr)
> -{
> -    filter_mb_row(avctx, tdata, jobnr, threadnr, 1);
> -}
> -
> -static void vp8_filter_mb_row(AVCodecContext *avctx, void *tdata,
> -                              int jobnr, int threadnr)
> -{
> -    filter_mb_row(avctx, tdata, jobnr, threadnr, 0);
> -}
> -
>  static av_always_inline
>  int vp78_decode_mb_row_sliced(AVCodecContext *avctx, void *tdata, int jobnr,
>                                int threadnr, int is_vp7)
> @@ -2837,20 +2813,6 @@ err:
>      return ret;
>  }
>  
> -int ff_vp8_decode_frame(AVCodecContext *avctx, AVFrame *frame,
> -                        int *got_frame, AVPacket *avpkt)
> -{
> -    return vp78_decode_frame(avctx, frame, got_frame, avpkt, IS_VP8);
> -}
> -
> -#if CONFIG_VP7_DECODER
> -static int vp7_decode_frame(AVCodecContext *avctx, AVFrame *frame,
> -                            int *got_frame, AVPacket *avpkt)
> -{
> -    return vp78_decode_frame(avctx, frame, got_frame, avpkt, IS_VP7);
> -}
> -#endif /* CONFIG_VP7_DECODER */
> -
>  av_cold int ff_vp8_decode_free(AVCodecContext *avctx)
>  {
>      vp8_decode_flush_impl(avctx, 1);
> @@ -2875,6 +2837,24 @@ static av_cold void vp78_decode_init(AVCodecContext *avctx)
>  }
>  
>  #if CONFIG_VP8_DECODER
> +static int vp8_decode_mb_row_no_filter(AVCodecContext *avctx, void *tdata,
> +                                        int jobnr, int threadnr)
> +{
> +    return decode_mb_row_no_filter(avctx, tdata, jobnr, threadnr, 0);
> +}
> +
> +static void vp8_filter_mb_row(AVCodecContext *avctx, void *tdata,
> +                              int jobnr, int threadnr)
> +{
> +    filter_mb_row(avctx, tdata, jobnr, threadnr, 0);
> +}
> +
> +int ff_vp8_decode_frame(AVCodecContext *avctx, AVFrame *frame,
> +                        int *got_frame, AVPacket *avpkt)
> +{
> +    return vp78_decode_frame(avctx, frame, got_frame, avpkt, IS_VP8);
> +}
> +
>  av_cold int ff_vp8_decode_init(AVCodecContext *avctx)
>  {
>      VP8Context *s = avctx->priv_data;
> @@ -2931,6 +2911,24 @@ static int vp8_decode_update_thread_context(AVCodecContext *dst,
>  #endif /* CONFIG_VP8_DECODER */
>  
>  #if CONFIG_VP7_DECODER
> +static int vp7_decode_mb_row_no_filter(AVCodecContext *avctx, void *tdata,
> +                                        int jobnr, int threadnr)
> +{
> +    return decode_mb_row_no_filter(avctx, tdata, jobnr, threadnr, 1);
> +}
> +
> +static void vp7_filter_mb_row(AVCodecContext *avctx, void *tdata,
> +                              int jobnr, int threadnr)
> +{
> +    filter_mb_row(avctx, tdata, jobnr, threadnr, 1);
> +}
> +
> +static int vp7_decode_frame(AVCodecContext *avctx, AVFrame *frame,
> +                            int *got_frame, AVPacket *avpkt)
> +{
> +    return vp78_decode_frame(avctx, frame, got_frame, avpkt, IS_VP7);
> +}
> +
>  av_cold static int vp7_decode_init(AVCodecContext *avctx)
>  {
>      VP8Context *s = avctx->priv_data;
> -- 
> 2.45.2
> 

> From 105f5edaa24b5ad0b4b1431cb04f22f3f5a106a6 Mon Sep 17 00:00:00 2001
> From: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> Date: Thu, 6 Mar 2025 18:20:32 +0100
> Subject: [PATCH 4/4] avcodec/vp8: Remove always-false hwaccel checks for VP7
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> ---
>  libavcodec/vp8.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
> index 77f7b4d4df..348744efd6 100644
> --- a/libavcodec/vp8.c
> +++ b/libavcodec/vp8.c
> @@ -2727,7 +2727,7 @@ int vp78_decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame,
>      if (!is_vp7 && !s->actually_webp)
>          ff_thread_finish_setup(avctx);
>  
> -    if (avctx->hwaccel) {
> +    if (!is_vp7 && avctx->hwaccel) {
>          const FFHWAccel *hwaccel = ffhwaccel(avctx->hwaccel);
>          ret = hwaccel->start_frame(avctx, avpkt->data, avpkt->size);
>          if (ret < 0)
> -- 

no objections, lgtm

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20250309/de27ecb8/attachment.sig>


More information about the ffmpeg-devel mailing list