From ecdb7ff87876debc0960e4202b484089419ee128 Mon Sep 17 00:00:00 2001 From: Serial <69764315+Serial-ATA@users.noreply.github.com> Date: Fri, 16 Dec 2022 12:18:09 -0500 Subject: [PATCH] MP4: Stop validating flags for `gnre` atom upgrade --- src/mp4/ilst/read.rs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/mp4/ilst/read.rs b/src/mp4/ilst/read.rs index 5cee2f06..65c1f60a 100644 --- a/src/mp4/ilst/read.rs +++ b/src/mp4/ilst/read.rs @@ -44,8 +44,8 @@ where if let Some(atom_data) = parse_data_inner(&mut ilst_reader, &atom)? { let mut data = Vec::new(); - for (flags, content) in atom_data { - if (flags == BE_SIGNED_INTEGER || flags == 0) && content.len() >= 2 { + for (_, content) in atom_data { + if content.len() >= 2 { let index = content[1] as usize; if index > 0 && index <= GENRES.len() { data.push(AtomData::UTF8(String::from(GENRES[index - 1]))); @@ -53,10 +53,17 @@ where } } - tag.atoms.push(Atom { - ident: AtomIdent::Fourcc(*b"\xa9gen"), - data: AtomDataStorage::Multiple(data), - }) + if !data.is_empty() { + let storage = match data.len() { + 1 => AtomDataStorage::Single(data.remove(0)), + _ => AtomDataStorage::Multiple(data), + }; + + tag.atoms.push(Atom { + ident: AtomIdent::Fourcc(*b"\xa9gen"), + data: storage, + }) + } } continue;