Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: frankplow via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: frankplow <code@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH] lavc/vvc: Ensure seq_decode is always updated with SPS (PR #20717)
Date: Sun, 19 Oct 2025 11:41:38 -0000
Message-ID: <176087409922.62.3850657758959997196@bf907ddaa564> (raw)

PR #20717 opened by frankplow
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20717
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20717.patch

seq_decode is used to ensure that a picture and all of its reference pictures use the same SPS. Any time the SPS changes, seq_decode should be incremented. Prior to this patch, seq_decode was incremented in frame_context_setup, which is called after the SPS is potentially changed in decode_sps. Should the decoder encounter an error between changing the SPS and incrementing seq_decode, the SPS could be modified while seq_decode was not incremented, which could lead to invalid reference pictures and various downstream issues. By instead updating seq_decode within the picture set manager, we ensure seq_decode and the SPS are always updated in tandem.


>From e611aeff64a15d12cede6da420e0173c665117a7 Mon Sep 17 00:00:00 2001
From: Frank Plowman <post@frankplowman.com>
Date: Sun, 19 Oct 2025 12:28:00 +0100
Subject: [PATCH] lavc/vvc: Ensure seq_decode is always updated with SPS

seq_decode is used to ensure that a picture and all of its reference
pictures use the same SPS. Any time the SPS changes, seq_decode should
be incremented. Prior to this patch, seq_decode was incremented in
frame_context_setup, which is called after the SPS is potentially
changed in decode_sps. Should the decoder encounter an error between
changing the SPS and incrementing seq_decode, the SPS could be modified
while seq_decode was not incremented, which could lead to invalid
reference pictures and various downstream issues. By instead updating
seq_decode within the picture set manager, we ensure seq_decode and the
SPS are always updated in tandem.
---
 libavcodec/vvc/dec.c | 1 -
 libavcodec/vvc/ps.c  | 2 ++
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c
index bfe330e028..028f34b491 100644
--- a/libavcodec/vvc/dec.c
+++ b/libavcodec/vvc/dec.c
@@ -726,7 +726,6 @@ static int frame_context_setup(VVCFrameContext *fc, VVCContext *s)
     }
 
     if (IS_IDR(s)) {
-        s->seq_decode = (s->seq_decode + 1) & 0xff;
         ff_vvc_clear_refs(fc);
     }
 
diff --git a/libavcodec/vvc/ps.c b/libavcodec/vvc/ps.c
index 8faee1d826..a591851238 100644
--- a/libavcodec/vvc/ps.c
+++ b/libavcodec/vvc/ps.c
@@ -279,12 +279,14 @@ fail:
 
 static int decode_sps(VVCParamSets *ps, AVCodecContext *c, const H266RawSPS *rsps, int is_clvss)
 {
+    VVCContext *s           = c->priv_data;
     const int sps_id        = rsps->sps_seq_parameter_set_id;
     const VVCSPS *old_sps   = ps->sps_list[sps_id];
     const VVCSPS *sps;
 
     if (is_clvss) {
         ps->sps_id_used = 0;
+        s->seq_decode = (s->seq_decode + 1) & 0xff;
     }
 
     if (old_sps) {
-- 
2.49.1

_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org

                 reply	other threads:[~2025-10-19 11:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=176087409922.62.3850657758959997196@bf907ddaa564 \
    --to=ffmpeg-devel@ffmpeg.org \
    --cc=code@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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