forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust381.2 MiBe18142dTahinli5 hours ago4543 commits

codec_table.rs43 lines, 2.4 KiBHistoryRawDownload
1use ec_core::CodecId;
2
3use crate::boxes::FourCc;
4
5pub(crate) fn video_codec(
6 kind: &FourCc,
7 video_track: bool,
8) -> Option<(CodecId, Option<&'static FourCc>)> {
9 Some(match kind {
10 b"avc1" | b"avc3" => (CodecId::H264, Some(b"avcC")),
11 b"hvc1" | b"hev1" => (CodecId::H265, Some(b"hvcC")),
12 b"vp08" => (CodecId::Vp8, Some(b"vpcC")),
13 b"vp09" => (CodecId::Vp9, Some(b"vpcC")),
14 b"av01" => (CodecId::Av1, Some(b"av1C")),
15 // Motion JPEG: QuickTime `jpeg` (Photo JPEG) and `mjpa` (MJPEG-A) carry whole JFIF
16 // frames and no configuration box. `mjpb` (MJPEG-B) packets have a different layout
17 // (no SOI, marker-less blocks at header offsets); ec-mjpeg detects and rewraps them.
18 // Uncompressed video; `raw ` is also the 8-bit PCM audio entry, so it needs a `vide` track.
19 // The decoder (ec-riff `RawVideoDecoder`) reads the layout from the synthesized header.
20 b"raw " | b"yuvs" if !video_track => return None,
21 b"raw " | b"yuvs" | b"2vuy" | b"yuv2" | b"v210" | b"v410" | b"b16g" => {
22 (CodecId::RawVideo, None)
23 }
24 b"jpeg" | b"mjpa" | b"mjpb" => (CodecId::Mjpeg, None),
25 // ProRes entries carry no configuration box: the frame header is self-describing.
26 b"apco" | b"apcs" | b"apcn" | b"apch" | b"ap4h" | b"ap4x" => (CodecId::ProRes, None),
27 // Avid DNxHD (`AVdn`) and DNxHR (`AVdh`); the optional `DNxD` box is
28 // the only child worth keeping as extradata.
29 b"AVdn" | b"AVdh" => (CodecId::Dnxhd, Some(b"DNxD")),
30 // MPEG-4 Part 2 Visual: `mp4v` carries the VOL header in the `esds`
31 // DecoderSpecificInfo; the 3GPP/QuickTime H.263 entries (`s263`, `h263`)
32 // carry no configuration the baseline decoder needs (`d263` is ignored).
33 b"mp4v" => (CodecId::Mpeg4Part2, Some(b"esds")),
34 b"s263" | b"h263" => (CodecId::Mpeg4Part2, None),
35 // DV: QuickTime sample entries for DV25/DVCPRO25 (`dvc `/`dvcp`/`dvpp`), DVCPRO50
36 // (`dv5n`/`dv5p`) and DVCPRO HD (`dvhq`/`dvh3`/`dvh5`/`dvh6`/`dvhp`...). The frame is
37 // self-describing: no configuration box.
38 b"dvc " | b"dvcp" | b"dvpp" | b"dvcs" | b"dvis" | b"dv5n" | b"dv5p" | b"dv5q" | b"dvhq"
39 | b"dvh1" | b"dvh2" | b"dvh3" | b"dvh4" | b"dvh5" | b"dvh6" | b"dvhp" | b"dvhs"
40 | b"dvhn" | b"dvhr" => (CodecId::DvVideo, None),
41 _ => return None,
42 })
43}