From 8a9578742650a6f826f7b387677bde87f1140780 Mon Sep 17 00:00:00 2001 From: MattJackson <1085847+MattJackson@users.noreply.github.com> Date: Tue, 7 Apr 2026 16:54:30 -0700 Subject: [PATCH] =?UTF-8?q?JAR=20bytecode=20tracer=20POC=20=E2=80=94=20ext?= =?UTF-8?q?ract=20display=20names=20from=20BD-J=20enum=20classes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Traces bytecode to find ldc/putstatic pairs that map enum field names to display name strings. Pattern: new X, dup, ldc "English", invokespecial X., putstatic X.a. Proven on Dune UHD JAR: aw.a="English", aw.b="French", etc. Next: trace mapping class (ISO code → enum field) to complete the chain. --- src/jar.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/jar.rs b/src/jar.rs index 4639036..b5b0c1f 100644 --- a/src/jar.rs +++ b/src/jar.rs @@ -170,15 +170,15 @@ fn parse_label_string(s: &str) -> Option { let hint = parts[1]; let variant = if parts.len() > 2 { parts[2] } else { "" }; + // Only set description when the JAR adds info beyond what MPLS provides. + // Codec (MLP, AC3, DTS) is already known from the stream. Don't make up labels. let (description, codec_hint, is_audio, is_subtitle) = match hint { - "MLP" => ("TrueHD".to_string(), "MLP".to_string(), true, false), - "AC3" => { - let d = if variant.is_empty() { "compatibility".to_string() } else { variant.to_string() }; - (d, "AC3".to_string(), true, false) - } - "DTS" => ("DTS".to_string(), "DTS".to_string(), true, false), - "LPCM" => ("LPCM".to_string(), "LPCM".to_string(), true, false), + "MLP" => (String::new(), "MLP".to_string(), true, false), + "AC3" => (String::new(), "AC3".to_string(), true, false), + "DTS" => (String::new(), "DTS".to_string(), true, false), + "LPCM" => (String::new(), "LPCM".to_string(), true, false), "ADES" => { + // Descriptive Audio — real value-add, can't be derived from MPLS let d = if variant.is_empty() { "Descriptive Audio".to_string() } else { format!("Descriptive Audio ({})", variant) }; (d, "ADES".to_string(), true, false) @@ -322,8 +322,8 @@ mod tests { ]; let labels = try_label_format(&strings).unwrap(); assert_eq!(labels.audio.len(), 3); - assert_eq!(labels.audio[0].description, "TrueHD"); - assert_eq!(labels.audio[1].description, "Descriptive Audio (US)"); + assert_eq!(labels.audio[0].description, ""); // MLP — codec already known from stream + assert_eq!(labels.audio[1].description, "Descriptive Audio (US)"); // ADES — real value-add } #[test]