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

Raw VC-1 streams without the broadcast flag receive half-duration packets since 
e930b834a928 switched libavformat to AV_CODEC_PROP_FIELDS. The parser still 
reports repeat_pict = 0 for these complete frames.

Apply Jens Duttke’s patch from #25532, preserving authorship and sign-off. 
Default repeat_pict to 1 after successful frame-header parsing, then retain the 
existing broadcast-only pulldown overrides.

Verified on master 8e362b7b51e7 with Linux AArch64/GCC 13.3:

| Sample | Before | After |
| --- | --- | --- |
| Kanu_720_576_25_interlaced.vc1 | 220 packets × 0.020000 s | 220 packets × 
0.040000 s |
| Ice_720_480_2997_interlaced.vc1 | 240 packets × 0.016683 s | 240 packets × 
0.033367 s |
| artifacts1.vc1 | 51 × 0.033367 s; 49 × 0.050050 s | Identical duration output 
|
| artifacts12-evodemux-noerrorframe.vc1 | 43 × 0.033367 s; 42 × 0.050050 s | 
Identical duration output |

All nine existing VC-1 FATE tests pass with `make fate-vc1 
SAMPLES=/opt/fate-suite`; `git diff --check` passes. No new FATE test is added; 
the supplied non-broadcast samples provide focused regression verification.

Adjacent builds of 70433abf7fb and e930b834a928 confirm the regression. Current 
release/6.1, release/7.1, release/8.0, release/8.1, and release/9.0 reproduce 
it; release/4.4 and release/5.1 give correct durations for both failing 
samples. No release backports are included.

Fixes #25532.


From 47d50b8d90a0b8f221d4b7994734b4a3066e0bde Mon Sep 17 00:00:00 2001
From: Jens Duttke <[email protected]>
Date: Tue, 27 Oct 2026 15:10:11 +0100
Subject: [PATCH] avcodec/vc1_parser: give frames without pulldown flags two
 field periods

Since e930b834a9 (lavf: use AV_CODEC_PROP_FIELDS where appropriate),
libavformat times VC-1 in field periods: a packet lasts
(1 + repeat_pict) / (2 * framerate). The parser sets repeat_pict = 1
for a frame only when the sequence header has the broadcast flag set,
and leaves it at 0 otherwise, so every frame of a stream without
pulldown flags is timed as a single field and raw elementary streams
play at twice their rate. The H.264 and MPEG-1/2 parsers were adjusted
in that commit; the VC-1 parser was not.

An interlaced 25 fps PAL stream (Kanu_720_576_25_interlaced.vc1, 220
frames) was timed at 20 ms per frame and lasted 4.4 s instead of 8.8 s;
a 29.97 fps one (Ice_720_480_2997_interlaced.vc1) at 16.7 ms per frame.
With the fix they are timed at 40 ms and 33.4 ms. Broadcast streams
with 3:2 pulldown keep their 33.4/50 ms cadence, and fate-vc1 passes
unchanged.

Signed-off-by: Jens Duttke <[email protected]>

Assisted-by: Fairy
---
 libavcodec/vc1_parser.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/libavcodec/vc1_parser.c b/libavcodec/vc1_parser.c
index 224ff3ee587..c7afdb95f14 100644
--- a/libavcodec/vc1_parser.c
+++ b/libavcodec/vc1_parser.c
@@ -94,10 +94,11 @@ static void vc1_extract_header(AVCodecParserContext *s, 
AVCodecContext *avctx,
         else
             s->pict_type = vpc->v.s.pict_type;
 
+        // A frame lasts two field periods, the unit lavf times VC-1 in
+        // since it marks the codec with AV_CODEC_PROP_FIELDS.
+        s->repeat_pict = 1;
+        // Pulldown flags are only valid when 'broadcast' has been set.
         if (vpc->v.broadcast){
-            // process pulldown flags
-            s->repeat_pict = 1;
-            // Pulldown flags are only valid when 'broadcast' has been set.
             if (vpc->v.rff){
                 // repeat field
                 s->repeat_pict = 2;
@@ -105,8 +106,6 @@ static void vc1_extract_header(AVCodecParserContext *s, 
AVCodecContext *avctx,
                 // repeat frames
                 s->repeat_pict = vpc->v.rptfrm * 2 + 1;
             }
-        }else{
-            s->repeat_pict = 0;
         }
 
         if (vpc->v.broadcast && vpc->v.interlace && !vpc->v.psf)
-- 
2.54.0

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

Reply via email to