Serial-ATA / lofty-rs

Audio metadata library
Apache License 2.0
186 stars 34 forks source link

Possible issue reading cpil field from m4a tags. #457

Closed milesegan closed 1 week ago

milesegan commented 1 week ago

Reproducer

Repo for reproduction is here:

https://github.com/milesegan/lofty-aac-compilation-bug

Summary

There seems to be an error reading the cpil compilation flag field from m4a tags. In the sample file the value is 1 but the tag reads as 0.

Expected behavior

No response

Assets

No response

milesegan commented 1 week ago

It seems like maybe the issue is here?

https://github.com/Serial-ATA/lofty-rs/blob/79336cd3048985cc7bb6c99600311e5c6bb837eb/lofty/src/mp4/ilst/read.rs#L123-L126

When I read the tag the content is [0, 0, 0, 1] which gets parsed as false. Maybe an endian issue?

Serial-ATA commented 1 week ago

Yep, that's exactly where the issue is :)

These flag atoms seem to be pretty inconsistently implemented. Quite a few projects write a 1 byte flag (which is what I thought was correct). It seems like other tools (including iTunes) write an i32, though. Guess I'll have to account for both encodings during parsing.

milesegan commented 1 week ago

It sounds tricky! Please let me know if I can help out.