mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2025-01-18 23:23:53 +00:00
ID3v2: Simply parse_popularimeter
This commit is contained in:
parent
cffc8182e1
commit
f25ed9b6c7
1 changed files with 4 additions and 8 deletions
|
@ -171,15 +171,11 @@ fn parse_popularimeter(content: &mut &[u8]) -> Result<FrameValue> {
|
|||
if remaining_size > 8 {
|
||||
counter = u64::MAX;
|
||||
} else {
|
||||
let mut c = Vec::with_capacity(8);
|
||||
content.read_to_end(&mut c)?;
|
||||
let mut counter_bytes = [0; 8];
|
||||
let counter_start_pos = 8 - remaining_size;
|
||||
|
||||
let needed_zeros = 8 - remaining_size;
|
||||
for _ in 0..needed_zeros {
|
||||
c.insert(0, 0);
|
||||
}
|
||||
|
||||
counter = u64::from_be_bytes(c.try_into().unwrap());
|
||||
counter_bytes[counter_start_pos..].copy_from_slice(content);
|
||||
counter = u64::from_be_bytes(counter_bytes);
|
||||
}
|
||||
|
||||
Ok(FrameValue::Popularimeter(Popularimeter {
|
||||
|
|
Loading…
Reference in a new issue