MP4: Rename nested_atom to find_child_atom

This commit is contained in:
Serial 2024-09-14 16:49:36 -04:00 committed by Alex
parent 3afe6d251a
commit f1fe219bed
4 changed files with 16 additions and 12 deletions

View file

@ -6,7 +6,7 @@ use crate::file::FileType;
use crate::macros::{decode_err, err, try_vec};
use crate::mp4::atom_info::{AtomIdent, AtomInfo, ATOM_HEADER_LEN, FOURCC_LEN};
use crate::mp4::ilst::r#ref::AtomRef;
use crate::mp4::read::{atom_tree, meta_is_full, nested_atom, verify_mp4, AtomReader};
use crate::mp4::read::{atom_tree, find_child_atom, meta_is_full, verify_mp4, AtomReader};
use crate::mp4::write::{AtomWriter, AtomWriterCompanion, ContextualAtom};
use crate::mp4::AtomData;
use crate::picture::{MimeType, Picture};
@ -74,10 +74,10 @@ where
let ilst = build_ilst(&mut tag.atoms)?;
let remove_tag = ilst.is_empty();
let udta = nested_atom(
let udta = find_child_atom(
&mut write_handle,
moov_len,
b"udta",
*b"udta",
ParseOptions::DEFAULT_PARSING_MODE,
)?;
@ -102,10 +102,10 @@ where
existing_udta_size = udta.len;
new_udta_size = existing_udta_size;
let meta = nested_atom(
let meta = find_child_atom(
&mut write_handle,
udta.len,
b"meta",
*b"meta",
ParseOptions::DEFAULT_PARSING_MODE,
)?;

View file

@ -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_atom, AtomReader};
use super::read::{find_child_atom, meta_is_full, skip_atom, AtomReader};
use crate::config::ParseOptions;
use crate::error::Result;
use crate::macros::decode_err;
@ -47,7 +47,7 @@ impl Moov {
b"trak" if parse_options.read_properties => {
// All we need from here is trak.mdia
if let Some(mdia) =
nested_atom(reader, atom.len, b"mdia", parse_options.parsing_mode)?
find_child_atom(reader, atom.len, *b"mdia", parse_options.parsing_mode)?
{
skip_atom(reader, mdia.extended, mdia.len)?;
traks.push(mdia);

View file

@ -1,5 +1,5 @@
use super::atom_info::{AtomIdent, AtomInfo};
use super::read::{nested_atom, skip_atom, AtomReader};
use super::read::{find_child_atom, skip_atom, AtomReader};
use crate::config::ParsingMode;
use crate::error::{LoftyError, Result};
use crate::macros::{decode_err, err, try_vec};
@ -369,7 +369,7 @@ fn read_minf<R>(
where
R: Read + Seek,
{
let Some(stbl) = nested_atom(reader, len, b"stbl", parse_mode)? else {
let Some(stbl) = find_child_atom(reader, len, *b"stbl", parse_mode)? else {
return Ok(None);
};

View file

@ -113,10 +113,14 @@ where
Ok(())
}
pub(super) fn nested_atom<R>(
/// Finds the first child atom with the given fourcc
///
/// * `len` is the length of the parent atom
/// * `expected` is the fourcc of the child atom to find
pub(super) fn find_child_atom<R>(
reader: &mut R,
mut len: u64,
expected: &[u8],
expected: [u8; 4],
parse_mode: ParsingMode,
) -> Result<Option<AtomInfo>>
where
@ -130,7 +134,7 @@ where
};
match atom.ident {
AtomIdent::Fourcc(ref fourcc) if fourcc == expected => {
AtomIdent::Fourcc(fourcc) if fourcc == expected => {
ret = Some(atom);
break;
},