mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2024-12-04 18:09:11 +00:00
MP4: Rename skip_unneeded
to skip_atom
This commit is contained in:
parent
9463c48058
commit
ef532557a7
5 changed files with 34 additions and 26 deletions
|
@ -7,7 +7,7 @@ use crate::id3::v1::constants::GENRES;
|
|||
use crate::macros::{err, try_vec};
|
||||
use crate::mp4::atom_info::{AtomInfo, ATOM_HEADER_LEN};
|
||||
use crate::mp4::ilst::atom::AtomDataStorage;
|
||||
use crate::mp4::read::{skip_unneeded, AtomReader};
|
||||
use crate::mp4::read::{skip_atom, AtomReader};
|
||||
use crate::picture::{MimeType, Picture, PictureType};
|
||||
use crate::util::text::{utf16_decode_bytes, utf8_decode};
|
||||
|
||||
|
@ -37,14 +37,14 @@ where
|
|||
if let AtomIdent::Fourcc(ref fourcc) = atom.ident {
|
||||
match fourcc {
|
||||
b"free" | b"skip" => {
|
||||
skip_unneeded(&mut ilst_reader, atom.extended, atom.len)?;
|
||||
skip_atom(&mut ilst_reader, atom.extended, atom.len)?;
|
||||
continue;
|
||||
},
|
||||
b"covr" => {
|
||||
if parse_options.read_cover_art {
|
||||
handle_covr(&mut ilst_reader, parsing_mode, &mut tag, &atom)?;
|
||||
} else {
|
||||
skip_unneeded(&mut ilst_reader, atom.extended, atom.len)?;
|
||||
skip_atom(&mut ilst_reader, atom.extended, atom.len)?;
|
||||
}
|
||||
|
||||
continue;
|
||||
|
@ -248,7 +248,7 @@ where
|
|||
);
|
||||
|
||||
pos += next_atom.len;
|
||||
skip_unneeded(reader, next_atom.extended, next_atom.len)?;
|
||||
skip_atom(reader, next_atom.extended, next_atom.len)?;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use super::atom_info::{AtomIdent, AtomInfo};
|
||||
use super::ilst::read::parse_ilst;
|
||||
use super::ilst::Ilst;
|
||||
use super::read::{meta_is_full, nested_atom, skip_unneeded, AtomReader};
|
||||
use super::read::{meta_is_full, nested_atom, skip_atom, AtomReader};
|
||||
use crate::config::ParseOptions;
|
||||
use crate::error::Result;
|
||||
use crate::macros::decode_err;
|
||||
|
@ -28,7 +28,7 @@ impl Moov {
|
|||
break;
|
||||
}
|
||||
|
||||
skip_unneeded(reader, atom.extended, atom.len)?;
|
||||
skip_atom(reader, atom.extended, atom.len)?;
|
||||
}
|
||||
|
||||
moov.ok_or_else(|| decode_err!(Mp4, "No \"moov\" atom found"))
|
||||
|
@ -49,7 +49,7 @@ impl Moov {
|
|||
if let Some(mdia) =
|
||||
nested_atom(reader, atom.len, b"mdia", parse_options.parsing_mode)?
|
||||
{
|
||||
skip_unneeded(reader, mdia.extended, mdia.len)?;
|
||||
skip_atom(reader, mdia.extended, mdia.len)?;
|
||||
traks.push(mdia);
|
||||
}
|
||||
},
|
||||
|
@ -69,13 +69,13 @@ impl Moov {
|
|||
ilst = Some(existing_ilst);
|
||||
}
|
||||
},
|
||||
_ => skip_unneeded(reader, atom.extended, atom.len)?,
|
||||
_ => skip_atom(reader, atom.extended, atom.len)?,
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
skip_unneeded(reader, atom.extended, atom.len)?
|
||||
skip_atom(reader, atom.extended, atom.len)?
|
||||
}
|
||||
|
||||
Ok(Self { traks, ilst })
|
||||
|
@ -106,7 +106,7 @@ where
|
|||
}
|
||||
|
||||
read += atom.len;
|
||||
skip_unneeded(reader, atom.extended, atom.len)?;
|
||||
skip_atom(reader, atom.extended, atom.len)?;
|
||||
}
|
||||
|
||||
if !found_meta {
|
||||
|
@ -138,7 +138,7 @@ where
|
|||
}
|
||||
|
||||
read += atom.len;
|
||||
skip_unneeded(reader, atom.extended, atom.len)?;
|
||||
skip_atom(reader, atom.extended, atom.len)?;
|
||||
}
|
||||
|
||||
if found_ilst {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use super::atom_info::{AtomIdent, AtomInfo};
|
||||
use super::read::{nested_atom, skip_unneeded, AtomReader};
|
||||
use super::read::{nested_atom, skip_atom, AtomReader};
|
||||
use crate::config::ParsingMode;
|
||||
use crate::error::{LoftyError, Result};
|
||||
use crate::macros::{decode_err, err, try_vec};
|
||||
|
@ -241,13 +241,13 @@ where
|
|||
if let AtomIdent::Fourcc(fourcc) = atom.ident {
|
||||
match &fourcc {
|
||||
b"mdhd" => {
|
||||
skip_unneeded(reader, atom.extended, atom.len)?;
|
||||
skip_atom(reader, atom.extended, atom.len)?;
|
||||
mdhd = Some(atom)
|
||||
},
|
||||
b"hdlr" => {
|
||||
if atom.len < 20 {
|
||||
log::warn!("Incomplete 'hdlr' atom, skipping");
|
||||
skip_unneeded(reader, atom.extended, atom.len)?;
|
||||
skip_atom(reader, atom.extended, atom.len)?;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -261,18 +261,18 @@ where
|
|||
audio_track = true
|
||||
}
|
||||
|
||||
skip_unneeded(reader, atom.extended, atom.len - 12)?;
|
||||
skip_atom(reader, atom.extended, atom.len - 12)?;
|
||||
},
|
||||
b"minf" => minf = Some(atom),
|
||||
_ => {
|
||||
skip_unneeded(reader, atom.extended, atom.len)?;
|
||||
skip_atom(reader, atom.extended, atom.len)?;
|
||||
},
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
skip_unneeded(reader, atom.extended, atom.len)?;
|
||||
skip_atom(reader, atom.extended, atom.len)?;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -391,7 +391,7 @@ where
|
|||
},
|
||||
b"stts" => stts = Some(read_stts(reader)?),
|
||||
_ => {
|
||||
skip_unneeded(reader, atom.extended, atom.len)?;
|
||||
skip_atom(reader, atom.extended, atom.len)?;
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -436,7 +436,7 @@ where
|
|||
// Special case to detect encrypted files
|
||||
b"drms" => {
|
||||
properties.drm_protected = true;
|
||||
skip_unneeded(reader, atom.extended, atom.len)?;
|
||||
skip_atom(reader, atom.extended, atom.len)?;
|
||||
continue;
|
||||
},
|
||||
_ => {
|
||||
|
@ -444,7 +444,7 @@ where
|
|||
"Found unsupported sample entry: {:?}",
|
||||
fourcc.escape_ascii().to_string()
|
||||
);
|
||||
skip_unneeded(reader, atom.extended, atom.len)?;
|
||||
skip_atom(reader, atom.extended, atom.len)?;
|
||||
continue;
|
||||
},
|
||||
}
|
||||
|
@ -843,7 +843,7 @@ where
|
|||
return Ok(atom.len - 8);
|
||||
}
|
||||
|
||||
skip_unneeded(reader, atom.extended, atom.len)?;
|
||||
skip_atom(reader, atom.extended, atom.len)?;
|
||||
}
|
||||
|
||||
decode_err!(@BAIL Mp4, "Failed to find \"mdat\" atom");
|
||||
|
|
|
@ -217,7 +217,15 @@ where
|
|||
})
|
||||
}
|
||||
|
||||
pub(super) fn skip_unneeded<R>(reader: &mut R, extended: bool, len: u64) -> Result<()>
|
||||
/// Seeks the reader to the end of the atom
|
||||
///
|
||||
/// This should be used immediately after [`AtomInfo::read`] to skip an unwanted atom.
|
||||
///
|
||||
/// NOTES:
|
||||
///
|
||||
/// * This makes the assumption that the reader is at the end of the atom's header.
|
||||
/// * This makes the assumption that the `len` is the *full atom length*, not just that of the content.
|
||||
pub(super) fn skip_atom<R>(reader: &mut R, extended: bool, len: u64) -> Result<()>
|
||||
where
|
||||
R: Read + Seek,
|
||||
{
|
||||
|
@ -261,7 +269,7 @@ where
|
|||
break;
|
||||
},
|
||||
_ => {
|
||||
skip_unneeded(reader, atom.extended, atom.len)?;
|
||||
skip_atom(reader, atom.extended, atom.len)?;
|
||||
len = len.saturating_sub(atom.len);
|
||||
},
|
||||
}
|
||||
|
@ -290,7 +298,7 @@ where
|
|||
break;
|
||||
};
|
||||
|
||||
skip_unneeded(reader, atom.extended, atom.len)?;
|
||||
skip_atom(reader, atom.extended, atom.len)?;
|
||||
len = len.saturating_sub(atom.len);
|
||||
|
||||
if let AtomIdent::Fourcc(ref fourcc) = atom.ident {
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::error::{LoftyError, Result};
|
|||
use crate::io::{FileLike, Length, Truncate};
|
||||
use crate::macros::err;
|
||||
use crate::mp4::atom_info::{AtomIdent, AtomInfo, IDENTIFIER_LEN};
|
||||
use crate::mp4::read::{meta_is_full, skip_unneeded};
|
||||
use crate::mp4::read::{meta_is_full, skip_atom};
|
||||
|
||||
use std::cell::{RefCell, RefMut};
|
||||
use std::io::{Cursor, Read, Seek, SeekFrom, Write};
|
||||
|
@ -53,7 +53,7 @@ impl ContextualAtom {
|
|||
*reader_len = reader_len.saturating_sub(info.len);
|
||||
|
||||
// We don't care about the atom's contents
|
||||
skip_unneeded(reader, info.extended, info.len)?;
|
||||
skip_atom(reader, info.extended, info.len)?;
|
||||
return Ok(Some(ContextualAtom {
|
||||
info,
|
||||
children: Vec::new(),
|
||||
|
|
Loading…
Reference in a new issue