3.2.1 - VC-1 keeps its picture size across a seek
One patch, in vc1_parser.c, and nothing else moved: same n8.1.2 FFmpeg, the same dav1d, zimg and libzvbi, the same configure flags as 3.2.0.
What it fixes
libavformat closes and reopens the parser on every reposition (ff_read_frame_flush), so a seek hands vc1_parse a zeroed VC1Context. Stock vc1_parser.c never seeds it from avctx->extradata the way vc1_decode_init does, so profile reads as simple and max_coded_width / max_coded_height are zero until an in-stream sequence header happens to pass. A track whose encoder leaves the sequence header to the container, and marks its GOPs with an entry point alone, has nothing to seed it at all.
An entry point BDU reaching the parser in that state is read at the wrong bit offset. hrd_full[] precedes coded_size_flag only when the sequence header set hrd_param_flag, which a zeroed context cannot know, so the bit taken for coded_size_flag is the top bit of hrd_full[0]: the leaky bucket fullness at that entry point.
-
below half full →
coded_size_flagreads 0, the size falls back to the zero pair, andff_set_dimensionsfails:[vc1] [IMGUTILS] Picture size 0x0 is invalid [vc1] Failed to set dimensions 0 0 -
above half full → it reads 1 and takes a 24 bit coded size out of the following payload. A wrong size, accepted without a word.
Rate control moves that fullness from GOP to GOP, which is why the same file produces it on some seek landings and not others. The same zeroed context also sends an advanced profile frame header through the simple/main reader, so pict_type and repeat_pict come out of the wrong reader, and libavformat turns those two into the packet key flag and the packet duration.
Reported on a Blu-ray sourced WVC1-in-Matroska library as AetherEngine issue 490.
Measured
On VC1_interlaced_1080i60_with_artifacts_crashes.mkv from samples.ffmpeg.org, edited by a published generator into the two shapes that occur in the wild but not in that particular file (the repeated sequence headers dropped, the top bit of hrd_full[0] cleared). Six seek points:
Picture size 0x0 is invalid |
|
|---|---|
stock n8.1.2 |
6 of 6 |
| this build | 0 of 6 |
A linear read is byte identical either way (packet=flags,pts,dts,duration matches on the reproducer, the unmodified sample, the raw elementary stream and two VC-1 FATE samples), and all nine vc1 FATE tests pass. VC1ParserExtradataTests drives the shipped libavcodec through av_parser_parse2 and pins both bucket cases plus a fixture control.
Upstream
Submitted as FFmpeg PR 24458 with the reproducer inline. The local patch goes away when it merges.