diff mbox series

[FFmpeg-devel] avcodec/h264dec: Remove dead function

Message ID AS8P250MB07449F4B03A39D83D85AB4C18FB99@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM
State New
Headers show
Series [FFmpeg-devel] avcodec/h264dec: Remove dead function | 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

Andreas Rheinhardt March 13, 2023, 2:18 p.m. UTC
The H.264 decoder does not support draw_horiz_band (it does not have
the AV_CODEC_CAP_DRAW_HORIZ_BAND), making ff_h264_draw_horiz_band()
practically dead.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/dxva2_h264.c |  7 +------
 libavcodec/h264_slice.c |  2 --
 libavcodec/h264dec.c    | 35 -----------------------------------
 libavcodec/h264dec.h    |  2 --
 libavcodec/vaapi_h264.c | 11 +----------
 libavcodec/vdpau_h264.c |  2 --
 6 files changed, 2 insertions(+), 57 deletions(-)

Comments

Andreas Rheinhardt March 15, 2023, 5:18 p.m. UTC | #1
Andreas Rheinhardt:
> The H.264 decoder does not support draw_horiz_band (it does not have
> the AV_CODEC_CAP_DRAW_HORIZ_BAND), making ff_h264_draw_horiz_band()
> practically dead.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/dxva2_h264.c |  7 +------
>  libavcodec/h264_slice.c |  2 --
>  libavcodec/h264dec.c    | 35 -----------------------------------
>  libavcodec/h264dec.h    |  2 --
>  libavcodec/vaapi_h264.c | 11 +----------
>  libavcodec/vdpau_h264.c |  2 --
>  6 files changed, 2 insertions(+), 57 deletions(-)
> 
> diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c
> index 6300b1418d..26e18a71b0 100644
> --- a/libavcodec/dxva2_h264.c
> +++ b/libavcodec/dxva2_h264.c
> @@ -499,20 +499,15 @@ static int dxva2_h264_decode_slice(AVCodecContext *avctx,
>  static int dxva2_h264_end_frame(AVCodecContext *avctx)
>  {
>      H264Context *h = avctx->priv_data;
> -    H264SliceContext *sl = &h->slice_ctx[0];
>      struct dxva2_picture_context *ctx_pic =
>          h->cur_pic_ptr->hwaccel_picture_private;
> -    int ret;
>  
>      if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0)
>          return -1;
> -    ret = ff_dxva2_common_end_frame(avctx, h->cur_pic_ptr->f,
> +    return ff_dxva2_common_end_frame(avctx, h->cur_pic_ptr->f,
>                                      &ctx_pic->pp, sizeof(ctx_pic->pp),
>                                      &ctx_pic->qm, sizeof(ctx_pic->qm),
>                                      commit_bitstream_and_slice_buffer);
> -    if (!ret)
> -        ff_h264_draw_horiz_band(h, sl, 0, h->avctx->height);
> -    return ret;
>  }
>  
>  #if CONFIG_H264_DXVA2_HWACCEL
> diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
> index 7767e16cf1..912f1ea9c7 100644
> --- a/libavcodec/h264_slice.c
> +++ b/libavcodec/h264_slice.c
> @@ -2490,8 +2490,6 @@ static void decode_finish_row(const H264Context *h, H264SliceContext *sl)
>          top    = 0;
>      }
>  
> -    ff_h264_draw_horiz_band(h, sl, top, height);
> -
>      if (h->droppable || h->er.error_occurred)
>          return;
>  
> diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
> index 2d691731c5..023716645f 100644
> --- a/libavcodec/h264dec.c
> +++ b/libavcodec/h264dec.c
> @@ -96,41 +96,6 @@ static void h264_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type,
>      ff_h264_hl_decode_mb(h, &h->slice_ctx[0]);
>  }
>  
> -void ff_h264_draw_horiz_band(const H264Context *h, H264SliceContext *sl,
> -                             int y, int height)
> -{
> -    AVCodecContext *avctx = h->avctx;
> -    const AVFrame   *src  = h->cur_pic.f;
> -    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
> -    int vshift = desc->log2_chroma_h;
> -    const int field_pic = h->picture_structure != PICT_FRAME;
> -    if (field_pic) {
> -        height <<= 1;
> -        y      <<= 1;
> -    }
> -
> -    height = FFMIN(height, avctx->height - y);
> -
> -    if (field_pic && h->first_field && !(avctx->slice_flags & SLICE_FLAG_ALLOW_FIELD))
> -        return;
> -
> -    if (avctx->draw_horiz_band) {
> -        int offset[AV_NUM_DATA_POINTERS];
> -        int i;
> -
> -        offset[0] = y * src->linesize[0];
> -        offset[1] =
> -        offset[2] = (y >> vshift) * src->linesize[1];
> -        for (i = 3; i < AV_NUM_DATA_POINTERS; i++)
> -            offset[i] = 0;
> -
> -        emms_c();
> -
> -        avctx->draw_horiz_band(avctx, src, offset,
> -                               y, h->picture_structure, height);
> -    }
> -}
> -
>  void ff_h264_free_tables(H264Context *h)
>  {
>      int i;
> diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h
> index 9a1ec1bace..28f62dbbba 100644
> --- a/libavcodec/h264dec.h
> +++ b/libavcodec/h264dec.h
> @@ -787,8 +787,6 @@ void ff_h264_unref_picture(H264Context *h, H264Picture *pic);
>  
>  void ff_h264_slice_context_init(H264Context *h, H264SliceContext *sl);
>  
> -void ff_h264_draw_horiz_band(const H264Context *h, H264SliceContext *sl, int y, int height);
> -
>  /**
>   * Submit a slice for decoding.
>   *
> diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
> index 9332aa6f31..386adae346 100644
> --- a/libavcodec/vaapi_h264.c
> +++ b/libavcodec/vaapi_h264.c
> @@ -311,17 +311,8 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
>  {
>      const H264Context *h = avctx->priv_data;
>      VAAPIDecodePicture *pic = h->cur_pic_ptr->hwaccel_picture_private;
> -    H264SliceContext *sl = &h->slice_ctx[0];
> -    int ret;
>  
> -    ret = ff_vaapi_decode_issue(avctx, pic);
> -    if (ret < 0)
> -        goto finish;
> -
> -    ff_h264_draw_horiz_band(h, sl, 0, h->avctx->height);
> -
> -finish:
> -    return ret;
> +    return ff_vaapi_decode_issue(avctx, pic);
>  }
>  
>  /** Decode the given H.264 slice with VA API. */
> diff --git a/libavcodec/vdpau_h264.c b/libavcodec/vdpau_h264.c
> index 525e208495..d39dbdd042 100644
> --- a/libavcodec/vdpau_h264.c
> +++ b/libavcodec/vdpau_h264.c
> @@ -201,7 +201,6 @@ static int vdpau_h264_decode_slice(AVCodecContext *avctx,
>  static int vdpau_h264_end_frame(AVCodecContext *avctx)
>  {
>      H264Context *h = avctx->priv_data;
> -    H264SliceContext *sl = &h->slice_ctx[0];
>      H264Picture *pic = h->cur_pic_ptr;
>      struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
>      int val;
> @@ -210,7 +209,6 @@ static int vdpau_h264_end_frame(AVCodecContext *avctx)
>      if (val < 0)
>          return val;
>  
> -    ff_h264_draw_horiz_band(h, sl, 0, h->avctx->height);
>      return 0;
>  }
>  

Will apply this patch tomorrow unless there are objections.

- Andreas
Kieran Kunhya March 15, 2023, 5:54 p.m. UTC | #2
On Wed, 15 Mar 2023 at 17:17, Andreas Rheinhardt <
andreas.rheinhardt@outlook.com> wrote:

> Andreas Rheinhardt:
> > The H.264 decoder does not support draw_horiz_band (it does not have
> > the AV_CODEC_CAP_DRAW_HORIZ_BAND), making ff_h264_draw_horiz_band()
> > practically dead.
> >
> > Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> > ---
> >  libavcodec/dxva2_h264.c |  7 +------
> >  libavcodec/h264_slice.c |  2 --
> >  libavcodec/h264dec.c    | 35 -----------------------------------
> >  libavcodec/h264dec.h    |  2 --
> >  libavcodec/vaapi_h264.c | 11 +----------
> >  libavcodec/vdpau_h264.c |  2 --
> >  6 files changed, 2 insertions(+), 57 deletions(-)
> >
> > diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c
> > index 6300b1418d..26e18a71b0 100644
> > --- a/libavcodec/dxva2_h264.c
> > +++ b/libavcodec/dxva2_h264.c
> > @@ -499,20 +499,15 @@ static int dxva2_h264_decode_slice(AVCodecContext
> *avctx,
> >  static int dxva2_h264_end_frame(AVCodecContext *avctx)
> >  {
> >      H264Context *h = avctx->priv_data;
> > -    H264SliceContext *sl = &h->slice_ctx[0];
> >      struct dxva2_picture_context *ctx_pic =
> >          h->cur_pic_ptr->hwaccel_picture_private;
> > -    int ret;
> >
> >      if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0)
> >          return -1;
> > -    ret = ff_dxva2_common_end_frame(avctx, h->cur_pic_ptr->f,
> > +    return ff_dxva2_common_end_frame(avctx, h->cur_pic_ptr->f,
> >                                      &ctx_pic->pp, sizeof(ctx_pic->pp),
> >                                      &ctx_pic->qm, sizeof(ctx_pic->qm),
> >                                      commit_bitstream_and_slice_buffer);
> > -    if (!ret)
> > -        ff_h264_draw_horiz_band(h, sl, 0, h->avctx->height);
> > -    return ret;
> >  }
> >
> >  #if CONFIG_H264_DXVA2_HWACCEL
> > diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
> > index 7767e16cf1..912f1ea9c7 100644
> > --- a/libavcodec/h264_slice.c
> > +++ b/libavcodec/h264_slice.c
> > @@ -2490,8 +2490,6 @@ static void decode_finish_row(const H264Context
> *h, H264SliceContext *sl)
> >          top    = 0;
> >      }
> >
> > -    ff_h264_draw_horiz_band(h, sl, top, height);
> > -
> >      if (h->droppable || h->er.error_occurred)
> >          return;
> >
> > diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
> > index 2d691731c5..023716645f 100644
> > --- a/libavcodec/h264dec.c
> > +++ b/libavcodec/h264dec.c
> > @@ -96,41 +96,6 @@ static void h264_er_decode_mb(void *opaque, int ref,
> int mv_dir, int mv_type,
> >      ff_h264_hl_decode_mb(h, &h->slice_ctx[0]);
> >  }
> >
> > -void ff_h264_draw_horiz_band(const H264Context *h, H264SliceContext *sl,
> > -                             int y, int height)
> > -{
> > -    AVCodecContext *avctx = h->avctx;
> > -    const AVFrame   *src  = h->cur_pic.f;
> > -    const AVPixFmtDescriptor *desc =
> av_pix_fmt_desc_get(avctx->pix_fmt);
> > -    int vshift = desc->log2_chroma_h;
> > -    const int field_pic = h->picture_structure != PICT_FRAME;
> > -    if (field_pic) {
> > -        height <<= 1;
> > -        y      <<= 1;
> > -    }
> > -
> > -    height = FFMIN(height, avctx->height - y);
> > -
> > -    if (field_pic && h->first_field && !(avctx->slice_flags &
> SLICE_FLAG_ALLOW_FIELD))
> > -        return;
> > -
> > -    if (avctx->draw_horiz_band) {
> > -        int offset[AV_NUM_DATA_POINTERS];
> > -        int i;
> > -
> > -        offset[0] = y * src->linesize[0];
> > -        offset[1] =
> > -        offset[2] = (y >> vshift) * src->linesize[1];
> > -        for (i = 3; i < AV_NUM_DATA_POINTERS; i++)
> > -            offset[i] = 0;
> > -
> > -        emms_c();
> > -
> > -        avctx->draw_horiz_band(avctx, src, offset,
> > -                               y, h->picture_structure, height);
> > -    }
> > -}
> > -
> >  void ff_h264_free_tables(H264Context *h)
> >  {
> >      int i;
> > diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h
> > index 9a1ec1bace..28f62dbbba 100644
> > --- a/libavcodec/h264dec.h
> > +++ b/libavcodec/h264dec.h
> > @@ -787,8 +787,6 @@ void ff_h264_unref_picture(H264Context *h,
> H264Picture *pic);
> >
> >  void ff_h264_slice_context_init(H264Context *h, H264SliceContext *sl);
> >
> > -void ff_h264_draw_horiz_band(const H264Context *h, H264SliceContext
> *sl, int y, int height);
> > -
> >  /**
> >   * Submit a slice for decoding.
> >   *
> > diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
> > index 9332aa6f31..386adae346 100644
> > --- a/libavcodec/vaapi_h264.c
> > +++ b/libavcodec/vaapi_h264.c
> > @@ -311,17 +311,8 @@ static int vaapi_h264_end_frame(AVCodecContext
> *avctx)
> >  {
> >      const H264Context *h = avctx->priv_data;
> >      VAAPIDecodePicture *pic = h->cur_pic_ptr->hwaccel_picture_private;
> > -    H264SliceContext *sl = &h->slice_ctx[0];
> > -    int ret;
> >
> > -    ret = ff_vaapi_decode_issue(avctx, pic);
> > -    if (ret < 0)
> > -        goto finish;
> > -
> > -    ff_h264_draw_horiz_band(h, sl, 0, h->avctx->height);
> > -
> > -finish:
> > -    return ret;
> > +    return ff_vaapi_decode_issue(avctx, pic);
> >  }
> >
> >  /** Decode the given H.264 slice with VA API. */
> > diff --git a/libavcodec/vdpau_h264.c b/libavcodec/vdpau_h264.c
> > index 525e208495..d39dbdd042 100644
> > --- a/libavcodec/vdpau_h264.c
> > +++ b/libavcodec/vdpau_h264.c
> > @@ -201,7 +201,6 @@ static int vdpau_h264_decode_slice(AVCodecContext
> *avctx,
> >  static int vdpau_h264_end_frame(AVCodecContext *avctx)
> >  {
> >      H264Context *h = avctx->priv_data;
> > -    H264SliceContext *sl = &h->slice_ctx[0];
> >      H264Picture *pic = h->cur_pic_ptr;
> >      struct vdpau_picture_context *pic_ctx =
> pic->hwaccel_picture_private;
> >      int val;
> > @@ -210,7 +209,6 @@ static int vdpau_h264_end_frame(AVCodecContext
> *avctx)
> >      if (val < 0)
> >          return val;
> >
> > -    ff_h264_draw_horiz_band(h, sl, 0, h->avctx->height);
> >      return 0;
> >  }
> >
>
> Will apply this patch tomorrow unless there are objections.
>
> - Andreas
>

Err...this used to work, what changed?

Kieran
Andreas Rheinhardt March 15, 2023, 6:02 p.m. UTC | #3
Kieran Kunhya:
> On Wed, 15 Mar 2023 at 17:17, Andreas Rheinhardt <
> andreas.rheinhardt@outlook.com> wrote:
> 
>> Andreas Rheinhardt:
>>> The H.264 decoder does not support draw_horiz_band (it does not have
>>> the AV_CODEC_CAP_DRAW_HORIZ_BAND), making ff_h264_draw_horiz_band()
>>> practically dead.
>>>
>>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
>>> ---
>>>  libavcodec/dxva2_h264.c |  7 +------
>>>  libavcodec/h264_slice.c |  2 --
>>>  libavcodec/h264dec.c    | 35 -----------------------------------
>>>  libavcodec/h264dec.h    |  2 --
>>>  libavcodec/vaapi_h264.c | 11 +----------
>>>  libavcodec/vdpau_h264.c |  2 --
>>>  6 files changed, 2 insertions(+), 57 deletions(-)
>>>
>>> diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c
>>> index 6300b1418d..26e18a71b0 100644
>>> --- a/libavcodec/dxva2_h264.c
>>> +++ b/libavcodec/dxva2_h264.c
>>> @@ -499,20 +499,15 @@ static int dxva2_h264_decode_slice(AVCodecContext
>> *avctx,
>>>  static int dxva2_h264_end_frame(AVCodecContext *avctx)
>>>  {
>>>      H264Context *h = avctx->priv_data;
>>> -    H264SliceContext *sl = &h->slice_ctx[0];
>>>      struct dxva2_picture_context *ctx_pic =
>>>          h->cur_pic_ptr->hwaccel_picture_private;
>>> -    int ret;
>>>
>>>      if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0)
>>>          return -1;
>>> -    ret = ff_dxva2_common_end_frame(avctx, h->cur_pic_ptr->f,
>>> +    return ff_dxva2_common_end_frame(avctx, h->cur_pic_ptr->f,
>>>                                      &ctx_pic->pp, sizeof(ctx_pic->pp),
>>>                                      &ctx_pic->qm, sizeof(ctx_pic->qm),
>>>                                      commit_bitstream_and_slice_buffer);
>>> -    if (!ret)
>>> -        ff_h264_draw_horiz_band(h, sl, 0, h->avctx->height);
>>> -    return ret;
>>>  }
>>>
>>>  #if CONFIG_H264_DXVA2_HWACCEL
>>> diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
>>> index 7767e16cf1..912f1ea9c7 100644
>>> --- a/libavcodec/h264_slice.c
>>> +++ b/libavcodec/h264_slice.c
>>> @@ -2490,8 +2490,6 @@ static void decode_finish_row(const H264Context
>> *h, H264SliceContext *sl)
>>>          top    = 0;
>>>      }
>>>
>>> -    ff_h264_draw_horiz_band(h, sl, top, height);
>>> -
>>>      if (h->droppable || h->er.error_occurred)
>>>          return;
>>>
>>> diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
>>> index 2d691731c5..023716645f 100644
>>> --- a/libavcodec/h264dec.c
>>> +++ b/libavcodec/h264dec.c
>>> @@ -96,41 +96,6 @@ static void h264_er_decode_mb(void *opaque, int ref,
>> int mv_dir, int mv_type,
>>>      ff_h264_hl_decode_mb(h, &h->slice_ctx[0]);
>>>  }
>>>
>>> -void ff_h264_draw_horiz_band(const H264Context *h, H264SliceContext *sl,
>>> -                             int y, int height)
>>> -{
>>> -    AVCodecContext *avctx = h->avctx;
>>> -    const AVFrame   *src  = h->cur_pic.f;
>>> -    const AVPixFmtDescriptor *desc =
>> av_pix_fmt_desc_get(avctx->pix_fmt);
>>> -    int vshift = desc->log2_chroma_h;
>>> -    const int field_pic = h->picture_structure != PICT_FRAME;
>>> -    if (field_pic) {
>>> -        height <<= 1;
>>> -        y      <<= 1;
>>> -    }
>>> -
>>> -    height = FFMIN(height, avctx->height - y);
>>> -
>>> -    if (field_pic && h->first_field && !(avctx->slice_flags &
>> SLICE_FLAG_ALLOW_FIELD))
>>> -        return;
>>> -
>>> -    if (avctx->draw_horiz_band) {
>>> -        int offset[AV_NUM_DATA_POINTERS];
>>> -        int i;
>>> -
>>> -        offset[0] = y * src->linesize[0];
>>> -        offset[1] =
>>> -        offset[2] = (y >> vshift) * src->linesize[1];
>>> -        for (i = 3; i < AV_NUM_DATA_POINTERS; i++)
>>> -            offset[i] = 0;
>>> -
>>> -        emms_c();
>>> -
>>> -        avctx->draw_horiz_band(avctx, src, offset,
>>> -                               y, h->picture_structure, height);
>>> -    }
>>> -}
>>> -
>>>  void ff_h264_free_tables(H264Context *h)
>>>  {
>>>      int i;
>>> diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h
>>> index 9a1ec1bace..28f62dbbba 100644
>>> --- a/libavcodec/h264dec.h
>>> +++ b/libavcodec/h264dec.h
>>> @@ -787,8 +787,6 @@ void ff_h264_unref_picture(H264Context *h,
>> H264Picture *pic);
>>>
>>>  void ff_h264_slice_context_init(H264Context *h, H264SliceContext *sl);
>>>
>>> -void ff_h264_draw_horiz_band(const H264Context *h, H264SliceContext
>> *sl, int y, int height);
>>> -
>>>  /**
>>>   * Submit a slice for decoding.
>>>   *
>>> diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
>>> index 9332aa6f31..386adae346 100644
>>> --- a/libavcodec/vaapi_h264.c
>>> +++ b/libavcodec/vaapi_h264.c
>>> @@ -311,17 +311,8 @@ static int vaapi_h264_end_frame(AVCodecContext
>> *avctx)
>>>  {
>>>      const H264Context *h = avctx->priv_data;
>>>      VAAPIDecodePicture *pic = h->cur_pic_ptr->hwaccel_picture_private;
>>> -    H264SliceContext *sl = &h->slice_ctx[0];
>>> -    int ret;
>>>
>>> -    ret = ff_vaapi_decode_issue(avctx, pic);
>>> -    if (ret < 0)
>>> -        goto finish;
>>> -
>>> -    ff_h264_draw_horiz_band(h, sl, 0, h->avctx->height);
>>> -
>>> -finish:
>>> -    return ret;
>>> +    return ff_vaapi_decode_issue(avctx, pic);
>>>  }
>>>
>>>  /** Decode the given H.264 slice with VA API. */
>>> diff --git a/libavcodec/vdpau_h264.c b/libavcodec/vdpau_h264.c
>>> index 525e208495..d39dbdd042 100644
>>> --- a/libavcodec/vdpau_h264.c
>>> +++ b/libavcodec/vdpau_h264.c
>>> @@ -201,7 +201,6 @@ static int vdpau_h264_decode_slice(AVCodecContext
>> *avctx,
>>>  static int vdpau_h264_end_frame(AVCodecContext *avctx)
>>>  {
>>>      H264Context *h = avctx->priv_data;
>>> -    H264SliceContext *sl = &h->slice_ctx[0];
>>>      H264Picture *pic = h->cur_pic_ptr;
>>>      struct vdpau_picture_context *pic_ctx =
>> pic->hwaccel_picture_private;
>>>      int val;
>>> @@ -210,7 +209,6 @@ static int vdpau_h264_end_frame(AVCodecContext
>> *avctx)
>>>      if (val < 0)
>>>          return val;
>>>
>>> -    ff_h264_draw_horiz_band(h, sl, 0, h->avctx->height);
>>>      return 0;
>>>  }
>>>
>>
>> Will apply this patch tomorrow unless there are objections.
>>
>> - Andreas
>>
> 
> Err...this used to work, what changed?
> 

As far as I know, this codec never had the AV_CODEC_CAP_DRAW_HORIZ_BAND
flag set (the commented out flag was removed in
e0c01a62adf59d1866ec53dcd76e4d4c815c5d58). Are you sure it ever worked?
Do you know someone who uses draw_horiz_band?
(Given the lack of the flag, ut would have been either illegal for the
caller to set draw_horiz_band or for the decoder to call it.)

- Andreas
Kieran Kunhya March 15, 2023, 6:03 p.m. UTC | #4
>
> As far as I know, this codec never had the AV_CODEC_CAP_DRAW_HORIZ_BAND
> flag set (the commented out flag was removed in
> e0c01a62adf59d1866ec53dcd76e4d4c815c5d58). Are you sure it ever worked?
> Do you know someone who uses draw_horiz_band?
> (Given the lack of the flag, ut would have been either illegal for the
> caller to set draw_horiz_band or for the decoder to call it.)
>
> - Andreas
>

I use draw_horiz_band and it did work. I have no idea why the flag was
commented out.
There is a FATE test for draw_horiz_band but not for h264 it seems.

Kieran
Kieran Kunhya March 15, 2023, 6:07 p.m. UTC | #5
>
> (Given the lack of the flag, ut would have been either illegal for the
> caller to set draw_horiz_band or for the decoder to call it.)
>

This is not a documented restriction:
https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/avcodec.h#L637

Kieran
Kieran Kunhya March 15, 2023, 6:16 p.m. UTC | #6
On Wed, 15 Mar 2023 at 18:07, Kieran Kunhya <kierank@obe.tv> wrote:

> (Given the lack of the flag, ut would have been either illegal for the
>> caller to set draw_horiz_band or for the decoder to call it.)
>>
>
> This is not a documented restriction:
> https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/avcodec.h#L637
>

Ignore that, the test is what doesn't follow this.

Kieran
diff mbox series

Patch

diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c
index 6300b1418d..26e18a71b0 100644
--- a/libavcodec/dxva2_h264.c
+++ b/libavcodec/dxva2_h264.c
@@ -499,20 +499,15 @@  static int dxva2_h264_decode_slice(AVCodecContext *avctx,
 static int dxva2_h264_end_frame(AVCodecContext *avctx)
 {
     H264Context *h = avctx->priv_data;
-    H264SliceContext *sl = &h->slice_ctx[0];
     struct dxva2_picture_context *ctx_pic =
         h->cur_pic_ptr->hwaccel_picture_private;
-    int ret;
 
     if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0)
         return -1;
-    ret = ff_dxva2_common_end_frame(avctx, h->cur_pic_ptr->f,
+    return ff_dxva2_common_end_frame(avctx, h->cur_pic_ptr->f,
                                     &ctx_pic->pp, sizeof(ctx_pic->pp),
                                     &ctx_pic->qm, sizeof(ctx_pic->qm),
                                     commit_bitstream_and_slice_buffer);
-    if (!ret)
-        ff_h264_draw_horiz_band(h, sl, 0, h->avctx->height);
-    return ret;
 }
 
 #if CONFIG_H264_DXVA2_HWACCEL
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 7767e16cf1..912f1ea9c7 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -2490,8 +2490,6 @@  static void decode_finish_row(const H264Context *h, H264SliceContext *sl)
         top    = 0;
     }
 
-    ff_h264_draw_horiz_band(h, sl, top, height);
-
     if (h->droppable || h->er.error_occurred)
         return;
 
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index 2d691731c5..023716645f 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -96,41 +96,6 @@  static void h264_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type,
     ff_h264_hl_decode_mb(h, &h->slice_ctx[0]);
 }
 
-void ff_h264_draw_horiz_band(const H264Context *h, H264SliceContext *sl,
-                             int y, int height)
-{
-    AVCodecContext *avctx = h->avctx;
-    const AVFrame   *src  = h->cur_pic.f;
-    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
-    int vshift = desc->log2_chroma_h;
-    const int field_pic = h->picture_structure != PICT_FRAME;
-    if (field_pic) {
-        height <<= 1;
-        y      <<= 1;
-    }
-
-    height = FFMIN(height, avctx->height - y);
-
-    if (field_pic && h->first_field && !(avctx->slice_flags & SLICE_FLAG_ALLOW_FIELD))
-        return;
-
-    if (avctx->draw_horiz_band) {
-        int offset[AV_NUM_DATA_POINTERS];
-        int i;
-
-        offset[0] = y * src->linesize[0];
-        offset[1] =
-        offset[2] = (y >> vshift) * src->linesize[1];
-        for (i = 3; i < AV_NUM_DATA_POINTERS; i++)
-            offset[i] = 0;
-
-        emms_c();
-
-        avctx->draw_horiz_band(avctx, src, offset,
-                               y, h->picture_structure, height);
-    }
-}
-
 void ff_h264_free_tables(H264Context *h)
 {
     int i;
diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h
index 9a1ec1bace..28f62dbbba 100644
--- a/libavcodec/h264dec.h
+++ b/libavcodec/h264dec.h
@@ -787,8 +787,6 @@  void ff_h264_unref_picture(H264Context *h, H264Picture *pic);
 
 void ff_h264_slice_context_init(H264Context *h, H264SliceContext *sl);
 
-void ff_h264_draw_horiz_band(const H264Context *h, H264SliceContext *sl, int y, int height);
-
 /**
  * Submit a slice for decoding.
  *
diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
index 9332aa6f31..386adae346 100644
--- a/libavcodec/vaapi_h264.c
+++ b/libavcodec/vaapi_h264.c
@@ -311,17 +311,8 @@  static int vaapi_h264_end_frame(AVCodecContext *avctx)
 {
     const H264Context *h = avctx->priv_data;
     VAAPIDecodePicture *pic = h->cur_pic_ptr->hwaccel_picture_private;
-    H264SliceContext *sl = &h->slice_ctx[0];
-    int ret;
 
-    ret = ff_vaapi_decode_issue(avctx, pic);
-    if (ret < 0)
-        goto finish;
-
-    ff_h264_draw_horiz_band(h, sl, 0, h->avctx->height);
-
-finish:
-    return ret;
+    return ff_vaapi_decode_issue(avctx, pic);
 }
 
 /** Decode the given H.264 slice with VA API. */
diff --git a/libavcodec/vdpau_h264.c b/libavcodec/vdpau_h264.c
index 525e208495..d39dbdd042 100644
--- a/libavcodec/vdpau_h264.c
+++ b/libavcodec/vdpau_h264.c
@@ -201,7 +201,6 @@  static int vdpau_h264_decode_slice(AVCodecContext *avctx,
 static int vdpau_h264_end_frame(AVCodecContext *avctx)
 {
     H264Context *h = avctx->priv_data;
-    H264SliceContext *sl = &h->slice_ctx[0];
     H264Picture *pic = h->cur_pic_ptr;
     struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
     int val;
@@ -210,7 +209,6 @@  static int vdpau_h264_end_frame(AVCodecContext *avctx)
     if (val < 0)
         return val;
 
-    ff_h264_draw_horiz_band(h, sl, 0, h->avctx->height);
     return 0;
 }