PR #20787 opened by James Almer (jamrial)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20787
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20787.patch

Supersedes #20781


>From fd3d41c721b50962cb29c9c409904981c82bd2cd Mon Sep 17 00:00:00 2001
From: James Almer <[email protected]>
Date: Wed, 29 Oct 2025 12:17:56 -0300
Subject: [PATCH 1/2] avcodec/vc1dec: look for ENDOFSEQ markers at the end of a
 packet's payload

This is in preparation for the parser no longer splitting them into their own
packets.

Signed-off-by: James Almer <[email protected]>
---
 libavcodec/vc1dec.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 55225baec9..536fdcb147 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -834,9 +834,11 @@ static int vc1_decode_frame(AVCodecContext *avctx, AVFrame 
*pict,
 
     if(s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY)
         s->low_delay = 1;
+    if (buf_size >= 4 && AV_RB32(&buf[buf_size-4]) == VC1_CODE_ENDOFSEQ)
+        buf_size -= 4;
 
     /* no supplementary picture */
-    if (buf_size == 0 || (buf_size == 4 && AV_RB32(buf) == VC1_CODE_ENDOFSEQ)) 
{
+    if (buf_size == 0) {
         /* special case for last picture */
         if (s->low_delay == 0 && s->next_pic.ptr) {
             if ((ret = av_frame_ref(pict, s->next_pic.ptr->f)) < 0)
-- 
2.49.1


>From 7929ba5d1fd21ecdc9e3829c40f21b9d41b7c8d9 Mon Sep 17 00:00:00 2001
From: James Almer <[email protected]>
Date: Wed, 29 Oct 2025 12:47:11 -0300
Subject: [PATCH 2/2] avcodec/vc1_parser: stop splitting ENDOFSEQ markers into
 separate packets

The decode API can handle outputting delayed frames without relying on the
parser splitting off the ENDOFSEQ marker.

Signed-off-by: James Almer <[email protected]>
---
 libavcodec/vc1_parser.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vc1_parser.c b/libavcodec/vc1_parser.c
index 124a7a771f..05094d782f 100644
--- a/libavcodec/vc1_parser.c
+++ b/libavcodec/vc1_parser.c
@@ -216,7 +216,8 @@ static int vc1_parse(AVCodecParserContext *s,
                 if (!pic_found && (b == (VC1_CODE_FRAME & 0xFF) || b == 
(VC1_CODE_FIELD & 0xFF))) {
                     pic_found = 1;
                 }
-                else if (pic_found && b != (VC1_CODE_FIELD & 0xFF) && b != 
(VC1_CODE_SLICE & 0xFF)) {
+                else if (pic_found && b != (VC1_CODE_FIELD & 0xFF) && b != 
(VC1_CODE_SLICE & 0xFF)
+                                   && b != (VC1_CODE_ENDOFSEQ & 0xFF)) {
                     next = i - 4;
                     pic_found = b == (VC1_CODE_FRAME & 0xFF);
                     break;
-- 
2.49.1

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to