summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
18ea2d8)
This converts the while loop into a for loop and replaces the
counted_size variable by "dest" to clarify the loop structure. We
also move the two 8-bit variables into the loop as they are only used
there and skip their pointless initializations.
static int parse_sub_atoms(struct mp4 *f, uint64_t total_size, bool meta_only)
{
int ret;
static int parse_sub_atoms(struct mp4 *f, uint64_t total_size, bool meta_only)
{
int ret;
- uint64_t size;
- uint8_t atom_type = 0;
- uint64_t counted_size = 0;
- uint8_t header_size = 0;
+ uint64_t dest, size, end = get_position(f) + total_size;
- while (counted_size < total_size) {
+ for (dest = get_position(f); dest < end; set_position(f, dest)) {
+ uint8_t header_size, atom_type;
ret = atom_read_header(f, &atom_type, &header_size, &size);
if (ret <= 0)
return ret;
if (size == 0)
return -1;
ret = atom_read_header(f, &atom_type, &header_size, &size);
if (ret <= 0)
return ret;
if (size == 0)
return -1;
+ dest = get_position(f) + size - header_size;
if (atom_type == ATOM_TRAK) {
if (f->total_tracks >= MAX_TRACKS)
return -1;
if (atom_type == ATOM_TRAK) {
if (f->total_tracks >= MAX_TRACKS)
return -1;
f->udta_offset = get_position(f) - header_size;
f->udta_size = size;
}
f->udta_offset = get_position(f) - header_size;
f->udta_size = size;
}
- if (!need_atom(atom_type, meta_only)) {
- set_position(f, get_position(f) + size - header_size);
+ if (!need_atom(atom_type, meta_only))
if (atom_type < SUBATOMIC) /* atom contains subatoms */
ret = parse_sub_atoms(f, size - header_size, meta_only);
else
if (atom_type < SUBATOMIC) /* atom contains subatoms */
ret = parse_sub_atoms(f, size - header_size, meta_only);
else