[FFmpeg-devel] [PATCH v4] libavcodec/cbs_av1: Add size check before parse obu

Chen, Wenbin wenbin.chen at intel.com
Mon Sep 26 11:30:14 EEST 2022


> On Wed, 2022-09-21 at 17:41 +0800, Wenbin Chen wrote:
> > cbs_av1_write_obu() check pbc size after parsing obu frame, and return
> > AVERROR(ENOSPC) if pbc is small. pbc will be reallocated and this obu
> > frame will be parsed again, but this may cause error because
> > CodedBitstreamAV1Context has already been updated, for example
> > ref_order_hint is updated and will not match the same obu frame. Now
> size
> > check is added before parsing obu frame to avoid this error.
> >
> > Signed-off-by: Wenbin Chen <wenbin.chen at intel.com>
> > ---
> >  libavcodec/cbs_av1.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c
> > index 154d9156cf..9c51a8c7c8 100644
> > --- a/libavcodec/cbs_av1.c
> > +++ b/libavcodec/cbs_av1.c
> > @@ -1075,6 +1075,9 @@ static int
> cbs_av1_write_obu(CodedBitstreamContext *ctx,
> >          put_bits32(pbc, 0);
> >      }
> >
> > +    if (8 * (unit->data_size + obu->obu_size) > put_bits_left(pbc))
> > +        return AVERROR(ENOSPC);
> > +
> >      td = NULL;
> >      start_pos = put_bits_count(pbc);
> >
> 
> According to the comment in
> https://patchwork.ffmpeg.org/project/ffmpeg/patch/20220329082921.7561
> 74-1-wenbin.chen at intel.com/
> , the error might still occur. I sent out
> https://ffmpeg.org/pipermail/ffmpeg-devel/2022-September/302127.html to
> restore
> CodedBitstreamAV1Context before returning AVERROR(ENOSPC). Could you
> have a look
> ?
> 
> Thanks
> Haihao

Yes, I will. Thank you for helping me on this issue.

> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-devel mailing list