[FFmpeg-devel] [PATCH] lavc/vvc: Fix pix_fmt change detection

Wang, Fei W fei.w.wang at intel.com
Mon Jan 13 08:29:06 EET 2025


On Sun, 2025-01-12 at 11:45 +0800, Nuo Mi wrote:
> 
> 
> On Sat, Jan 11, 2025 at 9:18 PM Frank Plowman <post at frankplowman.com>
> wrote:
> > In some scenarios, the VVCContext.pix_fmt and the
> > AVCodecContext.pix_fmt can get out-of-sync.  It is more robust here
> > to check the AVCodecContext.pix_fmt, as we already do for the width
> > and
> > height, seeing as the AVCodecContext.pix_fmt is the value which
> > actually ends up being used to determine the number of channels in
> > the
> > allocated frame.
> > 
> > Fixes null dereferences if the chroma format changes mid-sequence.
> > 
> > Signed-off-by: Frank Plowman <post at frankplowman.com>
> > ---
> >  libavcodec/vvc/dec.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c
> > index 1cb168de7e..12a33ac798 100644
> > --- a/libavcodec/vvc/dec.c
> > +++ b/libavcodec/vvc/dec.c
> > @@ -802,7 +802,7 @@ static int export_frame_params(VVCContext *s,
> > const VVCFrameContext *fc)
> >      int ret;
> > 
> >      // Reset HW config if pix_fmt/w/h change.
> > -    if (s->pix_fmt != sps->pix_fmt || c->coded_width != pps->width
> > || c->coded_height != pps->height) {
> > +    if (c->pix_fmt != sps->pix_fmt || c->coded_width != pps->width
> > || c->coded_height != pps->height) {
> > 
> 
> 
> It's related to hardware codec. @Wang, Fei W, please help review the
> patch.
> Do we still need s->format if this patch is applied?

c.pix_fmt is set to a hw pix fmt if hwaccel enabled. It should always
not equals to a software pix fmt.

Thanks
Fei 

> 
> >          c->coded_width  = pps->width;
> >          c->coded_height = pps->height;
> >          ret = get_format(c, sps);



More information about the ffmpeg-devel mailing list