forge
Explore
Log in

Don't you dare go Hollow

S4: video_codec returns Option for the config box instead of the all-zero fourcc sentinel (a box typed 0000 is no longer taken as a configuration)

Browse files at this commit

b822bed9fc044b9cd4b0d44a606ca50e54f912baAhmet Kaan GümüşParent: 543db30
crates/ec-mp4/src/codec_table.rsmodified+16 -13
@@ -2,13 +2,16 @@ use ec_core::CodecId;
2 2
3 use crate::boxes::FourCc;3 use crate::boxes::FourCc;
4 4
5-pub(crate) fn video_codec(kind: &FourCc, video_track: bool) -> Option<(CodecId, &'static FourCc)> {5+pub(crate) fn video_codec(
6+ kind: &FourCc,
7+ video_track: bool,
8+) -> Option<(CodecId, Option<&'static FourCc>)> {
6 Some(match kind {9 Some(match kind {
7- b"avc1" | b"avc3" => (CodecId::H264, b"avcC"),10+ b"avc1" | b"avc3" => (CodecId::H264, Some(b"avcC")),
8- b"hvc1" | b"hev1" => (CodecId::H265, b"hvcC"),11+ b"hvc1" | b"hev1" => (CodecId::H265, Some(b"hvcC")),
9- b"vp08" => (CodecId::Vp8, b"vpcC"),12+ b"vp08" => (CodecId::Vp8, Some(b"vpcC")),
10- b"vp09" => (CodecId::Vp9, b"vpcC"),13+ b"vp09" => (CodecId::Vp9, Some(b"vpcC")),
11- b"av01" => (CodecId::Av1, b"av1C"),14+ b"av01" => (CodecId::Av1, Some(b"av1C")),
12 // Motion JPEG: QuickTime `jpeg` (Photo JPEG) and `mjpa` (MJPEG-A) carry whole JFIF15 // Motion JPEG: QuickTime `jpeg` (Photo JPEG) and `mjpa` (MJPEG-A) carry whole JFIF
13 // frames and no configuration box. `mjpb` (MJPEG-B) packets have a different layout16 // frames and no configuration box. `mjpb` (MJPEG-B) packets have a different layout
14 // (no SOI, marker-less blocks at header offsets); ec-mjpeg detects and rewraps them.17 // (no SOI, marker-less blocks at header offsets); ec-mjpeg detects and rewraps them.
@@ -16,25 +19,25 @@ pub(crate) fn video_codec(kind: &FourCc, video_track: bool) -> Option<(CodecId,
16 // The decoder (ec-riff `RawVideoDecoder`) reads the layout from the synthesized header.19 // The decoder (ec-riff `RawVideoDecoder`) reads the layout from the synthesized header.
17 b"raw " | b"yuvs" if !video_track => return None,20 b"raw " | b"yuvs" if !video_track => return None,
18 b"raw " | b"yuvs" | b"2vuy" | b"yuv2" | b"v210" | b"v410" | b"b16g" => {21 b"raw " | b"yuvs" | b"2vuy" | b"yuv2" | b"v210" | b"v410" | b"b16g" => {
19- (CodecId::RawVideo, b"\0\0\0\0")22+ (CodecId::RawVideo, None)
20 }23 }
21- b"jpeg" | b"mjpa" | b"mjpb" => (CodecId::Mjpeg, b"\0\0\0\0"),24+ b"jpeg" | b"mjpa" | b"mjpb" => (CodecId::Mjpeg, None),
22 // ProRes entries carry no configuration box: the frame header is self-describing.25 // ProRes entries carry no configuration box: the frame header is self-describing.
23- b"apco" | b"apcs" | b"apcn" | b"apch" | b"ap4h" | b"ap4x" => (CodecId::ProRes, b"\0\0\0\0"),26+ b"apco" | b"apcs" | b"apcn" | b"apch" | b"ap4h" | b"ap4x" => (CodecId::ProRes, None),
24 // Avid DNxHD (`AVdn`) and DNxHR (`AVdh`); the optional `DNxD` box is27 // Avid DNxHD (`AVdn`) and DNxHR (`AVdh`); the optional `DNxD` box is
25 // the only child worth keeping as extradata.28 // the only child worth keeping as extradata.
26- b"AVdn" | b"AVdh" => (CodecId::Dnxhd, b"DNxD"),29+ b"AVdn" | b"AVdh" => (CodecId::Dnxhd, Some(b"DNxD")),
27 // MPEG-4 Part 2 Visual: `mp4v` carries the VOL header in the `esds`30 // MPEG-4 Part 2 Visual: `mp4v` carries the VOL header in the `esds`
28 // DecoderSpecificInfo; the 3GPP/QuickTime H.263 entries (`s263`, `h263`)31 // DecoderSpecificInfo; the 3GPP/QuickTime H.263 entries (`s263`, `h263`)
29 // carry no configuration the baseline decoder needs (`d263` is ignored).32 // carry no configuration the baseline decoder needs (`d263` is ignored).
30- b"mp4v" => (CodecId::Mpeg4Part2, b"esds"),33+ b"mp4v" => (CodecId::Mpeg4Part2, Some(b"esds")),
31- b"s263" | b"h263" => (CodecId::Mpeg4Part2, b"\0\0\0\0"),34+ b"s263" | b"h263" => (CodecId::Mpeg4Part2, None),
32 // DV: QuickTime sample entries for DV25/DVCPRO25 (`dvc `/`dvcp`/`dvpp`), DVCPRO5035 // DV: QuickTime sample entries for DV25/DVCPRO25 (`dvc `/`dvcp`/`dvpp`), DVCPRO50
33 // (`dv5n`/`dv5p`) and DVCPRO HD (`dvhq`/`dvh3`/`dvh5`/`dvh6`/`dvhp`...). The frame is36 // (`dv5n`/`dv5p`) and DVCPRO HD (`dvhq`/`dvh3`/`dvh5`/`dvh6`/`dvhp`...). The frame is
34 // self-describing: no configuration box.37 // self-describing: no configuration box.
35 b"dvc " | b"dvcp" | b"dvpp" | b"dvcs" | b"dvis" | b"dv5n" | b"dv5p" | b"dv5q" | b"dvhq"38 b"dvc " | b"dvcp" | b"dvpp" | b"dvcs" | b"dvis" | b"dv5n" | b"dv5p" | b"dv5q" | b"dvhq"
36 | b"dvh1" | b"dvh2" | b"dvh3" | b"dvh4" | b"dvh5" | b"dvh6" | b"dvhp" | b"dvhs"39 | b"dvh1" | b"dvh2" | b"dvh3" | b"dvh4" | b"dvh5" | b"dvh6" | b"dvhp" | b"dvhs"
37- | b"dvhn" | b"dvhr" => (CodecId::DvVideo, b"\0\0\0\0"),40+ | b"dvhn" | b"dvhr" => (CodecId::DvVideo, None),
38 _ => return None,41 _ => return None,
39 })42 })
40 }43 }
crates/ec-mp4/src/demux.rsmodified+1 -1
@@ -1179,7 +1179,7 @@ fn sample_entry(kind: &FourCc, payload: &[u8], video_track: bool) -> Result<Opti
1179 Err(_) if children.ends_with(&[0; 4]) => break,1179 Err(_) if children.ends_with(&[0; 4]) => break,
1180 Err(e) => return Err(e),1180 Err(e) => return Err(e),
1181 };1181 };
1182- if &kind == config {1182+ if config == Some(&kind) {
1183 extradata = Some(Buf::copy_from_slice(body));1183 extradata = Some(Buf::copy_from_slice(body));
1184 } else if &kind == b"colr" {1184 } else if &kind == b"colr" {
1185 if let Some((info, tags)) = colr(body) {1185 if let Some((info, tags)) = colr(body) {