VP9: frames never end in a byte that reads as a superframe marker (#161)
A frame whose last byte happened to match the superframe marker pattern
(0b110xxxxx, Annex B) was taken by decoders for a superframe with an
index at its end: ffmpeg rejected it ("Invalid le value at
frame_sizes[i]"), libvpx reported a corrupt frame, and later frames lost
their reference. In the reported WebM, 3 of 60 frames (10, 22, 24) ended
in 0xc8, 0xc0 and 0xca. The render still reported success.
Such frames now get a zero byte after the last tile; the last tile's
bool-coded data may end in zero padding (9.2.3).
Test: frames_never_end_in_a_superframe_marker encodes sequences until a
frame needs the padding, checks no frame ends in a marker byte, and that
the padded frames decode exactly with FilmCraft's decoder and with
ffmpeg (clean error log). It failed before ("96x64 q40 frame 22 ends in
0xde"). The ffmpeg IVF oracle is shared with the existing inter test.
Checked with the reporter's steps: 60/60 frames, no errors from ffmpeg's
vp9 or libvpx, RGB and RGB + Alpha.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
0946660c1c
commit
e90f81850c
@@ -341,6 +341,12 @@ impl Vp9Encoder {
|
||||
}
|
||||
out.extend_from_slice(&t);
|
||||
}
|
||||
// A frame mustn't end in a byte that reads as a superframe marker (0b110xxxxx, Annex B):
|
||||
// decoders would take its last bytes for a superframe index and reject the frame. The
|
||||
// last tile's bool-coded data may end in zero padding (9.2.3), so a zero byte fixes it.
|
||||
if out.last().is_some_and(|b| b & 0xe0 == 0xc0) {
|
||||
out.push(0);
|
||||
}
|
||||
// State for the next frame.
|
||||
self.mvs = mi.iter().map(|m| if m.inter { m.mv } else { Mv::ZERO }).collect();
|
||||
self.reference = Some(planes);
|
||||
|
||||
Reference in New Issue
Block a user