From b822bed9fc044b9cd4b0d44a606ca50e54f912ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 2 Dec 2026 15:11:27 +0300 Subject: [PATCH] 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) --- crates/ec-mp4/src/codec_table.rs | 29 ++++++++++++++++------------- crates/ec-mp4/src/demux.rs | 2 +- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/crates/ec-mp4/src/codec_table.rs b/crates/ec-mp4/src/codec_table.rs index b98eb08c..f7cd002c 100644 --- a/crates/ec-mp4/src/codec_table.rs +++ b/crates/ec-mp4/src/codec_table.rs @@ -2,13 +2,16 @@ use ec_core::CodecId; use crate::boxes::FourCc; -pub(crate) fn video_codec(kind: &FourCc, video_track: bool) -> Option<(CodecId, &'static FourCc)> { +pub(crate) fn video_codec( + kind: &FourCc, + video_track: bool, +) -> Option<(CodecId, Option<&'static FourCc>)> { Some(match kind { - b"avc1" | b"avc3" => (CodecId::H264, b"avcC"), - b"hvc1" | b"hev1" => (CodecId::H265, b"hvcC"), - b"vp08" => (CodecId::Vp8, b"vpcC"), - b"vp09" => (CodecId::Vp9, b"vpcC"), - b"av01" => (CodecId::Av1, b"av1C"), + b"avc1" | b"avc3" => (CodecId::H264, Some(b"avcC")), + b"hvc1" | b"hev1" => (CodecId::H265, Some(b"hvcC")), + b"vp08" => (CodecId::Vp8, Some(b"vpcC")), + b"vp09" => (CodecId::Vp9, Some(b"vpcC")), + b"av01" => (CodecId::Av1, Some(b"av1C")), // Motion JPEG: QuickTime `jpeg` (Photo JPEG) and `mjpa` (MJPEG-A) carry whole JFIF // frames and no configuration box. `mjpb` (MJPEG-B) packets have a different layout // (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, // The decoder (ec-riff `RawVideoDecoder`) reads the layout from the synthesized header. b"raw " | b"yuvs" if !video_track => return None, b"raw " | b"yuvs" | b"2vuy" | b"yuv2" | b"v210" | b"v410" | b"b16g" => { - (CodecId::RawVideo, b"\0\0\0\0") + (CodecId::RawVideo, None) } - b"jpeg" | b"mjpa" | b"mjpb" => (CodecId::Mjpeg, b"\0\0\0\0"), + b"jpeg" | b"mjpa" | b"mjpb" => (CodecId::Mjpeg, None), // ProRes entries carry no configuration box: the frame header is self-describing. - b"apco" | b"apcs" | b"apcn" | b"apch" | b"ap4h" | b"ap4x" => (CodecId::ProRes, b"\0\0\0\0"), + b"apco" | b"apcs" | b"apcn" | b"apch" | b"ap4h" | b"ap4x" => (CodecId::ProRes, None), // Avid DNxHD (`AVdn`) and DNxHR (`AVdh`); the optional `DNxD` box is // the only child worth keeping as extradata. - b"AVdn" | b"AVdh" => (CodecId::Dnxhd, b"DNxD"), + b"AVdn" | b"AVdh" => (CodecId::Dnxhd, Some(b"DNxD")), // MPEG-4 Part 2 Visual: `mp4v` carries the VOL header in the `esds` // DecoderSpecificInfo; the 3GPP/QuickTime H.263 entries (`s263`, `h263`) // carry no configuration the baseline decoder needs (`d263` is ignored). - b"mp4v" => (CodecId::Mpeg4Part2, b"esds"), - b"s263" | b"h263" => (CodecId::Mpeg4Part2, b"\0\0\0\0"), + b"mp4v" => (CodecId::Mpeg4Part2, Some(b"esds")), + b"s263" | b"h263" => (CodecId::Mpeg4Part2, None), // DV: QuickTime sample entries for DV25/DVCPRO25 (`dvc `/`dvcp`/`dvpp`), DVCPRO50 // (`dv5n`/`dv5p`) and DVCPRO HD (`dvhq`/`dvh3`/`dvh5`/`dvh6`/`dvhp`...). The frame is // self-describing: no configuration box. b"dvc " | b"dvcp" | b"dvpp" | b"dvcs" | b"dvis" | b"dv5n" | b"dv5p" | b"dv5q" | b"dvhq" | b"dvh1" | b"dvh2" | b"dvh3" | b"dvh4" | b"dvh5" | b"dvh6" | b"dvhp" | b"dvhs" - | b"dvhn" | b"dvhr" => (CodecId::DvVideo, b"\0\0\0\0"), + | b"dvhn" | b"dvhr" => (CodecId::DvVideo, None), _ => return None, }) } diff --git a/crates/ec-mp4/src/demux.rs b/crates/ec-mp4/src/demux.rs index e516373e..3e957822 100644 --- a/crates/ec-mp4/src/demux.rs +++ b/crates/ec-mp4/src/demux.rs @@ -1179,7 +1179,7 @@ fn sample_entry(kind: &FourCc, payload: &[u8], video_track: bool) -> Result break, Err(e) => return Err(e), }; - if &kind == config { + if config == Some(&kind) { extradata = Some(Buf::copy_from_slice(body)); } else if &kind == b"colr" { if let Some((info, tags)) = colr(body) {