Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] lavc/vvc: Set fc->ref to NULL at top of decode_nal_units
@ 2025-02-08 21:42 Frank Plowman
  2025-02-16  4:04 ` Nuo Mi
  0 siblings, 1 reply; 2+ messages in thread
From: Frank Plowman @ 2025-02-08 21:42 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Frank Plowman, nuomi2021

In the fail: block of decode_nal_units, a check as to whether fc->ref is
nonzero is used.  Before this patch, fc->ref was set to NULL in
frame_context_setup.  The issue is that, by the time frame_context_setup
is called, falliable functions (namely slices_realloc and
ff_vvc_decode_frame_ps) have already been called.  Therefore, there
could arise a situation in which the fc->ref test of decode_nal_units'
fail: block is performed while fc->ref has an invalid value.  This seems
to be particularly prevalent in situations where the FrameContexts are
being reused.  The patch resolves the issue by moving the assignment of
fc->ref to NULL to the very top of decode_nal_units, before any falliable
functions are called.

Signed-off-by: Frank Plowman <post@frankplowman.com>
---
 libavcodec/vvc/dec.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c
index 51dd60ae92..572e904301 100644
--- a/libavcodec/vvc/dec.c
+++ b/libavcodec/vvc/dec.c
@@ -671,8 +671,6 @@ static int frame_context_setup(VVCFrameContext *fc, VVCContext *s)
 {
     int ret;
 
-    fc->ref = NULL;
-
     // copy refs from the last frame
     if (s->nb_frames && s->nb_fcs > 1) {
         VVCFrameContext *prev = get_frame_context(s, fc, -1);
@@ -927,6 +925,7 @@ static int decode_nal_units(VVCContext *s, VVCFrameContext *fc, AVPacket *avpkt)
     int ret = 0;
     s->last_eos = s->eos;
     s->eos = 0;
+    fc->ref = NULL;
 
     ff_cbs_fragment_reset(frame);
     ret = ff_cbs_read_packet(s->cbc, frame, avpkt);
-- 
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] lavc/vvc: Set fc->ref to NULL at top of decode_nal_units
  2025-02-08 21:42 [FFmpeg-devel] [PATCH] lavc/vvc: Set fc->ref to NULL at top of decode_nal_units Frank Plowman
@ 2025-02-16  4:04 ` Nuo Mi
  0 siblings, 0 replies; 2+ messages in thread
From: Nuo Mi @ 2025-02-16  4:04 UTC (permalink / raw)
  To: Frank Plowman; +Cc: ffmpeg-devel

On Sun, Feb 9, 2025 at 5:43 AM Frank Plowman <post@frankplowman.com> wrote:

> In the fail: block of decode_nal_units, a check as to whether fc->ref is
> nonzero is used.  Before this patch, fc->ref was set to NULL in
> frame_context_setup.  The issue is that, by the time frame_context_setup
> is called, falliable functions (namely slices_realloc and
> ff_vvc_decode_frame_ps) have already been called.  Therefore, there
> could arise a situation in which the fc->ref test of decode_nal_units'
> fail: block is performed while fc->ref has an invalid value.  This seems
> to be particularly prevalent in situations where the FrameContexts are
> being reused.  The patch resolves the issue by moving the assignment of
> fc->ref to NULL to the very top of decode_nal_units, before any falliable
> functions are called.
>
Thank you, Frank.
Applied.

>
> Signed-off-by: Frank Plowman <post@frankplowman.com>
> ---
>  libavcodec/vvc/dec.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c
> index 51dd60ae92..572e904301 100644
> --- a/libavcodec/vvc/dec.c
> +++ b/libavcodec/vvc/dec.c
> @@ -671,8 +671,6 @@ static int frame_context_setup(VVCFrameContext *fc,
> VVCContext *s)
>  {
>      int ret;
>
> -    fc->ref = NULL;
> -
>      // copy refs from the last frame
>      if (s->nb_frames && s->nb_fcs > 1) {
>          VVCFrameContext *prev = get_frame_context(s, fc, -1);
> @@ -927,6 +925,7 @@ static int decode_nal_units(VVCContext *s,
> VVCFrameContext *fc, AVPacket *avpkt)
>      int ret = 0;
>      s->last_eos = s->eos;
>      s->eos = 0;
> +    fc->ref = NULL;
>
>      ff_cbs_fragment_reset(frame);
>      ret = ff_cbs_read_packet(s->cbc, frame, avpkt);
> --
> 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-02-16  4:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-08 21:42 [FFmpeg-devel] [PATCH] lavc/vvc: Set fc->ref to NULL at top of decode_nal_units Frank Plowman
2025-02-16  4:04 ` 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