[FFmpeg-devel] [PATCH 2/3] avcodec/cbs_av1: Clear obu.metadata on error

Michael Niedermayer michael at niedermayer.cc
Fri Jun 2 23:13:31 EEST 2023


On Thu, Jun 01, 2023 at 09:33:14PM -0300, James Almer wrote:
> On 6/1/2023 9:28 PM, Andreas Rheinhardt wrote:
> > 1. Before 97f4263, the current_obu was reset (and the packet effectively
> > discarded) upon errors from ff_cbs_read_packet(); yet this is no longer
> > true and it seems that the contents of current_obu will be processed in
> > the next call to av1_receive_frame(). This change seems to have been
> > unintentional.
> 
> I guess I assumed that ff_cbs_read_packet() failing would clear the
> CodedBitstreamFragment before returning, but if that's not the case then
> ff_cbs_fragment_reset() should be called.
> 
> Would something like
> 
> > diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
> > index 5cc5d87c64..d1a0f6eaa2 100644
> > --- a/libavcodec/av1dec.c
> > +++ b/libavcodec/av1dec.c
> > @@ -1461,6 +1461,7 @@ static int av1_receive_frame(AVCodecContext *avctx, AVFrame *frame)
> >              ret = ff_cbs_read_packet(s->cbc, &s->current_obu, s->pkt);
> >              if (ret < 0) {
> >                  av_packet_unref(s->pkt);
> > +                ff_cbs_fragment_reset(&s->current_obu);
> >                  av_log(avctx, AV_LOG_ERROR, "Failed to read packet.\n");
> >                  return ret;
> >              }
> 
> Be enough?

yes, that solves it and looks much better than my patch

thx

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

It is dangerous to be right in matters on which the established authorities
are wrong. -- Voltaire
-------------- 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/20230602/4f774f3f/attachment.sig>


More information about the ffmpeg-devel mailing list