forge
Explore
Log in

Don't you dare go Hollow

One ISO 639 table, the demuxer's, for both sides

Browse files at this commit

737b17126151d8b575be07aeca98712b696d4f2aAhmet Kaan GümüşParent: de38f6e
  • refactor
    • one ISO 639 table, the demuxer's, for both sides
Show full message
♻️ refactor(media): one ISO 639 table, the demuxer's, for both sides

The mux lane had carried its own copy of the demuxer's ISO 639-1 → 639-2
table because that one was private to its module. Make the demuxer's
`pub(crate)` and have the muxer read it, so the two can no longer drift;
the copies were byte-identical, all 183 entries, so nothing is dropped.
crates/engine/src/demux.rsmodified+1 -1
@@ -2370,7 +2370,7 @@ fn mkv_language(legacy: &str, bcp47: &str) -> String {
23702370 /// from `iso-codes`' own `iso_639-2.json`, so a Kannada track is as readable as
23712371 /// an English one.
23722372 #[rustfmt::skip]
2373-const ISO_639_1_TO_2: &[(&str, &str)] = &[
2373+pub(crate) const ISO_639_1_TO_2: &[(&str, &str)] = &[
23742374 ("aa", "aar"), ("ab", "abk"), ("ae", "ave"), ("af", "afr"),
23752375 ("ak", "aka"), ("am", "amh"), ("an", "arg"), ("ar", "ara"),
23762376 ("as", "asm"), ("av", "ava"), ("ay", "aym"), ("az", "aze"),
crates/engine/src/mux.rsmodified+2 -62
@@ -174,7 +174,7 @@ fn colr_nclx(colour: ColorDescription) -> [u8; 11] {
174174 /// `ptm`, silently, with a player's subtitle menu then offering a language
175175 /// nobody speaks. Matroska's `Language` is raw UTF-8 beside that and may carry
176176 /// a BCP-47 tag, so the tag is cut to its primary subtag here, mapped through
177-/// [`ISO_639_1_TO_2`] where it is two letters, and left `und` -- the code that
177+/// [`crate::demux::ISO_639_1_TO_2`] where it is two letters, and left `und` -- the code that
178178 /// says *undetermined* -- where nothing names it.
179179 ///
180180 /// Three lowercase letters are taken as they are: that is the code the field
@@ -187,7 +187,7 @@ fn mp4_language(language: &str) -> String {
187187 .unwrap_or_default()
188188 .to_ascii_lowercase();
189189 let code = match primary.len() {
190- 2 => ISO_639_1_TO_2
190+ 2 => crate::demux::ISO_639_1_TO_2
191191 .iter()
192192 .find(|(two, _)| *two == primary)
193193 .map(|(_, three)| *three),
@@ -197,66 +197,6 @@ fn mp4_language(language: &str) -> String {
197197 code.unwrap_or("und").to_owned()
198198 }
199199
200-/// Every ISO 639-1 code and the 639-2 (terminology) one it names the same
201-/// language with -- what [`mp4_language`] maps a BCP-47 primary subtag through.
202-///
203-/// corner-cut: the same standard's table `crate::demux` reads a Matroska
204-/// `TrackEntry` through, carried here as well because that one is private to
205-/// its module and this file owns no other file's visibility. The two must not
206-/// drift, so a change belongs in both; the upgrade path is one table with
207-/// `pub(crate)` on it, and a muxer that calls the demuxer's. Whole standard and
208-/// not the languages a test happened to use, generated from `iso-codes`'
209-/// `iso_639-2.json` like that one.
210-#[rustfmt::skip]
211-const ISO_639_1_TO_2: &[(&str, &str)] = &[
212- ("aa", "aar"), ("ab", "abk"), ("ae", "ave"), ("af", "afr"),
213- ("ak", "aka"), ("am", "amh"), ("an", "arg"), ("ar", "ara"),
214- ("as", "asm"), ("av", "ava"), ("ay", "aym"), ("az", "aze"),
215- ("ba", "bak"), ("be", "bel"), ("bg", "bul"), ("bi", "bis"),
216- ("bm", "bam"), ("bn", "ben"), ("bo", "bod"), ("br", "bre"),
217- ("bs", "bos"), ("ca", "cat"), ("ce", "che"), ("ch", "cha"),
218- ("co", "cos"), ("cr", "cre"), ("cs", "ces"), ("cu", "chu"),
219- ("cv", "chv"), ("cy", "cym"), ("da", "dan"), ("de", "deu"),
220- ("dv", "div"), ("dz", "dzo"), ("ee", "ewe"), ("el", "ell"),
221- ("en", "eng"), ("eo", "epo"), ("es", "spa"), ("et", "est"),
222- ("eu", "eus"), ("fa", "fas"), ("ff", "ful"), ("fi", "fin"),
223- ("fj", "fij"), ("fo", "fao"), ("fr", "fra"), ("fy", "fry"),
224- ("ga", "gle"), ("gd", "gla"), ("gl", "glg"), ("gn", "grn"),
225- ("gu", "guj"), ("gv", "glv"), ("ha", "hau"), ("he", "heb"),
226- ("hi", "hin"), ("ho", "hmo"), ("hr", "hrv"), ("ht", "hat"),
227- ("hu", "hun"), ("hy", "hye"), ("hz", "her"), ("ia", "ina"),
228- ("id", "ind"), ("ie", "ile"), ("ig", "ibo"), ("ii", "iii"),
229- ("ik", "ipk"), ("io", "ido"), ("is", "isl"), ("it", "ita"),
230- ("iu", "iku"), ("ja", "jpn"), ("jv", "jav"), ("ka", "kat"),
231- ("kg", "kon"), ("ki", "kik"), ("kj", "kua"), ("kk", "kaz"),
232- ("kl", "kal"), ("km", "khm"), ("kn", "kan"), ("ko", "kor"),
233- ("kr", "kau"), ("ks", "kas"), ("ku", "kur"), ("kv", "kom"),
234- ("kw", "cor"), ("ky", "kir"), ("la", "lat"), ("lb", "ltz"),
235- ("lg", "lug"), ("li", "lim"), ("ln", "lin"), ("lo", "lao"),
236- ("lt", "lit"), ("lu", "lub"), ("lv", "lav"), ("mg", "mlg"),
237- ("mh", "mah"), ("mi", "mri"), ("mk", "mkd"), ("ml", "mal"),
238- ("mn", "mon"), ("mr", "mar"), ("ms", "msa"), ("mt", "mlt"),
239- ("my", "mya"), ("na", "nau"), ("nb", "nob"), ("nd", "nde"),
240- ("ne", "nep"), ("ng", "ndo"), ("nl", "nld"), ("nn", "nno"),
241- ("no", "nor"), ("nr", "nbl"), ("nv", "nav"), ("ny", "nya"),
242- ("oc", "oci"), ("oj", "oji"), ("om", "orm"), ("or", "ori"),
243- ("os", "oss"), ("pa", "pan"), ("pi", "pli"), ("pl", "pol"),
244- ("ps", "pus"), ("pt", "por"), ("qu", "que"), ("rm", "roh"),
245- ("rn", "run"), ("ro", "ron"), ("ru", "rus"), ("rw", "kin"),
246- ("sa", "san"), ("sc", "srd"), ("sd", "snd"), ("se", "sme"),
247- ("sg", "sag"), ("si", "sin"), ("sk", "slk"), ("sl", "slv"),
248- ("sm", "smo"), ("sn", "sna"), ("so", "som"), ("sq", "sqi"),
249- ("sr", "srp"), ("ss", "ssw"), ("st", "sot"), ("su", "sun"),
250- ("sv", "swe"), ("sw", "swa"), ("ta", "tam"), ("te", "tel"),
251- ("tg", "tgk"), ("th", "tha"), ("ti", "tir"), ("tk", "tuk"),
252- ("tl", "tgl"), ("tn", "tsn"), ("to", "ton"), ("tr", "tur"),
253- ("ts", "tso"), ("tt", "tat"), ("tw", "twi"), ("ty", "tah"),
254- ("ug", "uig"), ("uk", "ukr"), ("ur", "urd"), ("uz", "uzb"),
255- ("ve", "ven"), ("vi", "vie"), ("vo", "vol"), ("wa", "wln"),
256- ("wo", "wol"), ("xh", "xho"), ("yi", "yid"), ("yo", "yor"),
257- ("za", "zha"), ("zh", "zho"), ("zu", "zul"),
258-];
259-
260200 const VIDEO_TRACK: u32 = 1;
261201 const AUDIO_TRACK: u32 = 2;
262202