Browse code

print atom info during parsing, patch by Frank Barchard, fbarchard at google dot com

Originally committed as revision 19435 to svn://svn.ffmpeg.org/ffmpeg/trunk

Frank Barchard authored on 2009/07/15 17:57:27
Showing 1 changed files
... ...
@@ -80,6 +80,7 @@ int main(int argc, char *argv[])
80 80
     unsigned char atom_bytes[ATOM_PREAMBLE_SIZE];
81 81
     uint32_t atom_type = 0;
82 82
     uint64_t atom_size = 0;
83
+    uint64_t atom_offset = 0;
83 84
     uint64_t last_offset;
84 85
     unsigned char *moov_atom;
85 86
     unsigned char *ftyp_atom = 0;
... ...
@@ -112,20 +113,6 @@ int main(int argc, char *argv[])
112 112
         atom_size = (uint32_t)BE_32(&atom_bytes[0]);
113 113
         atom_type = BE_32(&atom_bytes[4]);
114 114
 
115
-        if ((atom_type != FREE_ATOM) &&
116
-            (atom_type != JUNK_ATOM) &&
117
-            (atom_type != MDAT_ATOM) &&
118
-            (atom_type != MOOV_ATOM) &&
119
-            (atom_type != PNOT_ATOM) &&
120
-            (atom_type != SKIP_ATOM) &&
121
-            (atom_type != WIDE_ATOM) &&
122
-            (atom_type != PICT_ATOM) &&
123
-            (atom_type != UUID_ATOM) &&
124
-            (atom_type != FTYP_ATOM)) {
125
-            printf ("encountered non-QT top-level atom (is this a Quicktime file?)\n");
126
-            break;
127
-        }
128
-
129 115
         /* keep ftyp atom */
130 116
         if (atom_type == FTYP_ATOM) {
131 117
             ftyp_atom_size = atom_size;
... ...
@@ -144,8 +131,7 @@ int main(int argc, char *argv[])
144 144
                 return 1;
145 145
             }
146 146
             start_offset = ftello(infile);
147
-            continue;
148
-        }
147
+        } else {
149 148
 
150 149
         /* 64-bit special case */
151 150
         if (atom_size == 1) {
... ...
@@ -158,6 +144,28 @@ int main(int argc, char *argv[])
158 158
             fseeko(infile, atom_size - ATOM_PREAMBLE_SIZE, SEEK_CUR);
159 159
         }
160 160
     }
161
+        printf("%c%c%c%c %10"PRIu64" %"PRIu64"\n",
162
+               (atom_type >> 24) & 255,
163
+               (atom_type >> 16) & 255,
164
+               (atom_type >>  8) & 255,
165
+               (atom_type >>  0) & 255,
166
+               atom_offset,
167
+               atom_size);
168
+        if ((atom_type != FREE_ATOM) &&
169
+            (atom_type != JUNK_ATOM) &&
170
+            (atom_type != MDAT_ATOM) &&
171
+            (atom_type != MOOV_ATOM) &&
172
+            (atom_type != PNOT_ATOM) &&
173
+            (atom_type != SKIP_ATOM) &&
174
+            (atom_type != WIDE_ATOM) &&
175
+            (atom_type != PICT_ATOM) &&
176
+            (atom_type != UUID_ATOM) &&
177
+            (atom_type != FTYP_ATOM)) {
178
+            printf ("encountered non-QT top-level atom (is this a Quicktime file?)\n");
179
+            break;
180
+        }
181
+        atom_offset += atom_size;
182
+    }
161 183
 
162 184
     if (atom_type != MOOV_ATOM) {
163 185
         printf ("last atom in file was not a moov atom\n");