Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* Re: [FFmpeg-devel] [PATCH v3] lavc/vvc: Stop c->pix_fmt and s->pix_fmt diverging
       [not found] <20250117201839.55096-1-post@frankplowman.com>
@ 2025-01-18 15:12 ` Nuo Mi
  2025-01-26  3:15   ` Nuo Mi
  0 siblings, 1 reply; 2+ messages in thread
From: Nuo Mi @ 2025-01-18 15:12 UTC (permalink / raw)
  To: Frank Plowman; +Cc: fei.w.wang, ffmpeg-devel

On Sat, Jan 18, 2025 at 4:18 AM Frank Plowman <post@frankplowman.com> wrote:

> When the chroma format changes mid-sequence, c->pix_fmt and s->pix_fmt
> can get out-of-sync.  More specifically,
> 1. export_frame_params is called.
>    c->pix_fmt and s->pix_fmt are both set to their new values.
> 2. set_output_format is called.
>    c->pix_fmt is set back to its old value.
>
> The two getting out of sync results in a memory error.  The check in
> export_frame_params passes as it only tests the s->pix_fmt, therefore
> c->pix_fmt keeps the old value and the buffers are not allocated for the
> new pixel format.
>
> Patch fixes this by not setting c->pix_fmt in set_output_format.
>
> Signed-off-by: Frank Plowman <post@frankplowman.com>
> ---
> @Nuo Mi, Fei Wang:
> Does this look okay?  I am not really sure why c->pix_fmt was set again
> in set_output_format, was this accounting for some specific scenario?
> In terms of bitstreams where the pix_fmt changes, I only have fuzzed
> bitstreams unfortunately, so while this prevents crashing it is
> difficult to know whether the output is correct.
>
Hi Frank,
I agree with you; it's better to remove the duplicate pix_fmt in the VVC
context.
If we need it for hardware, it should be renamed to hw_fmt or something
more descriptive.
Could you share the clip?

> ---
>  libavcodec/vvc/dec.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c
> index 1cb168de7e..53e3eeec6d 100644
> --- a/libavcodec/vvc/dec.c
> +++ b/libavcodec/vvc/dec.c
> @@ -970,7 +970,6 @@ static int set_output_format(const VVCContext *s,
> const AVFrame *output)
>          if ((ret = ff_set_dimensions(c, output->width, output->height)) <
> 0)
>              return ret;
>      }
> -    c->pix_fmt = output->format;
>      return 0;
>  }
>
> --
> 2.47.0
>
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [FFmpeg-devel] [PATCH v3] lavc/vvc: Stop c->pix_fmt and s->pix_fmt diverging
  2025-01-18 15:12 ` [FFmpeg-devel] [PATCH v3] lavc/vvc: Stop c->pix_fmt and s->pix_fmt diverging Nuo Mi
@ 2025-01-26  3:15   ` Nuo Mi
  0 siblings, 0 replies; 2+ messages in thread
From: Nuo Mi @ 2025-01-26  3:15 UTC (permalink / raw)
  To: Frank Plowman; +Cc: fei.w.wang, ffmpeg-devel

On Sat, Jan 18, 2025 at 11:12 PM Nuo Mi <nuomi2021@gmail.com> wrote:

>
>
> On Sat, Jan 18, 2025 at 4:18 AM Frank Plowman <post@frankplowman.com>
> wrote:
>
>> When the chroma format changes mid-sequence, c->pix_fmt and s->pix_fmt
>> can get out-of-sync.  More specifically,
>> 1. export_frame_params is called.
>>    c->pix_fmt and s->pix_fmt are both set to their new values.
>> 2. set_output_format is called.
>>    c->pix_fmt is set back to its old value.
>>
>> The two getting out of sync results in a memory error.  The check in
>> export_frame_params passes as it only tests the s->pix_fmt, therefore
>> c->pix_fmt keeps the old value and the buffers are not allocated for the
>> new pixel format.
>>
>> Patch fixes this by not setting c->pix_fmt in set_output_format.
>>
>> Signed-off-by: Frank Plowman <post@frankplowman.com>
>> ---
>> @Nuo Mi, Fei Wang:
>> Does this look okay?  I am not really sure why c->pix_fmt was set again
>> in set_output_format, was this accounting for some specific scenario?
>> In terms of bitstreams where the pix_fmt changes, I only have fuzzed
>> bitstreams unfortunately, so while this prevents crashing it is
>> difficult to know whether the output is correct.
>>
> Hi Frank,
> I agree with you; it's better to remove the duplicate pix_fmt in the VVC
> context.
> If we need it for hardware, it should be renamed to hw_fmt or something
> more descriptive.
> Could you share the clip?
>
Hi Frank,
Thank you for the clip.
If c->pix_fmt is not needed, we might also remove ff_set_dimensions, as
setting dimensions without a format is meaningless.

Hi @Frank Plowman <post@frankplowman.com>  and @Wang, Fei W
<fei.w.wang@intel.com>,
please help review
https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=13775


---
>>  libavcodec/vvc/dec.c | 1 -
>>  1 file changed, 1 deletion(-)
>>
>> diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c
>> index 1cb168de7e..53e3eeec6d 100644
>> --- a/libavcodec/vvc/dec.c
>> +++ b/libavcodec/vvc/dec.c
>> @@ -970,7 +970,6 @@ static int set_output_format(const VVCContext *s,
>> const AVFrame *output)
>>          if ((ret = ff_set_dimensions(c, output->width, output->height))
>> < 0)
>>              return ret;
>>      }
>> -    c->pix_fmt = output->format;
>>      return 0;
>>  }
>>
>> --
>> 2.47.0
>>
>>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-01-26  3:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20250117201839.55096-1-post@frankplowman.com>
2025-01-18 15:12 ` [FFmpeg-devel] [PATCH v3] lavc/vvc: Stop c->pix_fmt and s->pix_fmt diverging Nuo Mi
2025-01-26  3:15   ` Nuo Mi

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git