diff --git a/crates/ec-core/src/registry.rs b/crates/ec-core/src/registry.rs index 6f7a2776..0bbd6355 100644 --- a/crates/ec-core/src/registry.rs +++ b/crates/ec-core/src/registry.rs @@ -38,6 +38,10 @@ pub enum CodecId { Ac3, /// Dolby Digital Plus (E-AC-3). EAc3, + /// Dolby TrueHD (MLP), including the Atmos substream. + TrueHd, + /// DTS and its extensions (DTS-HD, DTS:X). + Dts, /// Apple Lossless. Alac, /// Xiph FLAC. @@ -78,8 +82,8 @@ impl CodecId { use CodecId::*; match self { H264 | H265 | Vp8 | Vp9 | Av1 => MediaType::Video, - Aac | Ac3 | EAc3 | Alac | Flac | Mp3 | Opus | Vorbis | PcmU8 | PcmS16Le | PcmS16Be - | PcmS24Le | PcmS32Le | PcmF32Le => MediaType::Audio, + Aac | Ac3 | EAc3 | TrueHd | Dts | Alac | Flac | Mp3 | Opus | Vorbis | PcmU8 + | PcmS16Le | PcmS16Be | PcmS24Le | PcmS32Le | PcmF32Le => MediaType::Audio, Srt | WebVtt | Ass | Pgs | Tx3g => MediaType::Subtitle, } } @@ -96,6 +100,8 @@ impl CodecId { Aac => "aac", Ac3 => "ac3", EAc3 => "eac3", + TrueHd => "truehd", + Dts => "dts", Alac => "alac", Flac => "flac", Mp3 => "mp3", @@ -363,6 +369,8 @@ mod tests { CodecId::Aac, CodecId::Ac3, CodecId::EAc3, + CodecId::TrueHd, + CodecId::Dts, CodecId::Alac, CodecId::Flac, CodecId::Mp3, @@ -380,7 +388,7 @@ mod tests { CodecId::Pgs, CodecId::Tx3g, ]; - assert_eq!(all.len(), 24); + assert_eq!(all.len(), 26); let mut names: Vec<&str> = all.iter().map(|c| c.name()).collect(); names.sort_unstable(); names.dedup(); diff --git a/crates/ec-matroska/src/demux.rs b/crates/ec-matroska/src/demux.rs index 7b59d507..1ce082ec 100644 --- a/crates/ec-matroska/src/demux.rs +++ b/crates/ec-matroska/src/demux.rs @@ -355,6 +355,18 @@ impl MatroskaDemuxer { self.time_base } + /// The `TrackNumber` a stream index came from. + /// + /// Stream indices are this crate's own numbering; the `TrackNumber` is the + /// file's, and it is what a caller naming one language of a dual-audio + /// remux is holding. + pub fn track_number(&self, stream: u32) -> Option { + self.tracks + .iter() + .find(|t| t.stream == Some(stream)) + .map(|t| t.number) + } + /// The next cluster into [`MatroskaDemuxer::queue`]; `false` at the end of /// the segment. `at` comes back holding the offset of the cluster read. fn load_cluster(&mut self, at: &mut u64) -> Result { @@ -945,6 +957,10 @@ pub(crate) fn codec_of(id: &str, bit_depth: u32) -> Option { "A_VORBIS" => CodecId::Vorbis, "A_AC3" => CodecId::Ac3, "A_EAC3" => CodecId::EAc3, + // Named rather than dropped: nothing here decodes them, and a track a + // player lists as unsupported is a better answer than a silent one. + "A_TRUEHD" | "A_MLP" => CodecId::TrueHd, + id if id.starts_with("A_DTS") => CodecId::Dts, "A_FLAC" => CodecId::Flac, "A_ALAC" => CodecId::Alac, "S_TEXT/UTF8" => CodecId::Srt,