]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - mp4.c
mp4: Merge parse_leaf_atom() into parse_sub_atoms().
[paraslash.git] / mp4.c
diff --git a/mp4.c b/mp4.c
index d030d62d3e759c81ddfa440a6b47613e87f4d14e..10ff3bfe3b3033785e4bdc397e3cee302ff5271b 100644 (file)
--- a/mp4.c
+++ b/mp4.c
@@ -158,8 +158,6 @@ enum atoms {
        ATOM_DATE,
        ATOM_COMMENT,
 
-       SUBATOMIC = 128,
-
        /* atoms without subatoms */
        ATOM_MDHD, /* track header */
        ATOM_STSD, /* sample description box */
@@ -657,29 +655,6 @@ static int32_t read_meta(struct mp4 *f, uint64_t size)
        return 1;
 }
 
-static int parse_leaf_atom(struct mp4 *f, uint64_t size, uint8_t header_size,
-               uint8_t atom_type)
-{
-       uint64_t dest_position = get_position(f) + size - 8;
-       int ret = 1; /* return success for atoms we don't care about */
-
-       switch (atom_type) {
-       case ATOM_STSZ: ret = read_stsz(f); break;
-       case ATOM_STTS: ret = read_stts(f); break;
-       case ATOM_STSC: ret = read_stsc(f); break;
-       case ATOM_STCO: ret = read_stco(f); break;
-       case ATOM_STSD: ret = read_stsd(f); break;
-       case ATOM_MDHD: ret = read_mdhd(f); break;
-       case ATOM_META:
-               f->meta_offset = get_position(f) - header_size;
-               f->meta_size = size;
-               ret = read_meta(f, size);
-               break;
-       }
-       set_position(f, dest_position);
-       return ret;
-}
-
 static bool need_atom(uint8_t atom_type, bool meta_only)
 {
        /* these are needed in any case */
@@ -734,10 +709,21 @@ static int parse_sub_atoms(struct mp4 *f, uint64_t total_size, bool meta_only)
                }
                if (!need_atom(atom_type, meta_only))
                        continue;
-               if (atom_type < SUBATOMIC) /* atom contains subatoms */
+               switch (atom_type) {
+               case ATOM_STSZ: ret = read_stsz(f); break;
+               case ATOM_STTS: ret = read_stts(f); break;
+               case ATOM_STSC: ret = read_stsc(f); break;
+               case ATOM_STCO: ret = read_stco(f); break;
+               case ATOM_STSD: ret = read_stsd(f); break;
+               case ATOM_MDHD: ret = read_mdhd(f); break;
+               case ATOM_META:
+                       f->meta_offset = get_position(f) - header_size;
+                       f->meta_size = size;
+                       ret = read_meta(f, size);
+                       break;
+               default:
                        ret = parse_sub_atoms(f, size - header_size, meta_only);
-               else
-                       ret = parse_leaf_atom(f, size, header_size, atom_type);
+               }
                if (ret <= 0)
                        return ret;
        }