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

Frank Plowman post at frankplowman.com
Mon Jan 13 14:24:52 EET 2025


On 13/01/2025 06:29, Wang, Fei W wrote:
> 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 

I see.  I think the fix will have to further investigate the
circumstances which lead to c->pix_fmt and s->pix_fmt getting
out-of-sync in the software decoder and address this there.

@Fei Wang Have you tested a hardware-accelerated decoder on a sample
where sps_chroma_format_idc varies?  I don't think there are any such
samples in the CTC and it seems the software decoder has a bug for these.

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



More information about the ffmpeg-devel mailing list