Lines Matching defs:atom

7  * This utility rearranges a Quicktime file such that the moov atom
20 * atoms. This utility stipulates that the very last atom in the file needs
21 * to be a moov atom. When given such a file, this utility will rearrange
22 * the top-level atoms by shifting the moov atom from the back of the file
125 typedef int (*parse_atoms_callback_t)(void *context, atom_t *atom);
135 atom_t atom;
139 atom.size = BE_32(pos);
140 atom.type = BE_32(pos + 4);
142 atom.header_size = ATOM_PREAMBLE_SIZE;
144 switch (atom.size) {
147 fprintf(stderr, "not enough room for 64 bit atom size\n");
151 atom.size = BE_64(pos);
153 atom.header_size = ATOM_PREAMBLE_SIZE + 8;
157 atom.size = ATOM_PREAMBLE_SIZE + end - pos;
161 if (atom.size < atom.header_size) {
162 fprintf(stderr, "atom size %"PRIu64" too small\n", atom.size);
166 atom.size -= atom.header_size;
168 if (atom.size > end - pos) {
169 fprintf(stderr, "atom size %"PRIu64" too big\n", atom.size);
173 atom.data = pos;
174 ret = callback(context, &atom);
179 pos += atom.size;
185 static int update_stco_offsets(update_chunk_offsets_context_t *context, atom_t *atom)
192 printf(" patching stco atom...\n");
193 if (atom->size < 8) {
194 fprintf(stderr, "stco atom size %"PRIu64" too small\n", atom->size);
198 offset_count = BE_32(atom->data + 4);
199 if (offset_count > (atom->size - 8) / 4) {
205 context->stco_data_size += atom->size - 8;
207 for (pos = atom->data + 8, end = pos + offset_count * 4;
221 static int update_co64_offsets(update_chunk_offsets_context_t *context, atom_t *atom)
228 printf(" patching co64 atom...\n");
229 if (atom->size < 8) {
230 fprintf(stderr, "co64 atom size %"PRIu64" too small\n", atom->size);
234 offset_count = BE_32(atom->data + 4);
235 if (offset_count > (atom->size - 8) / 8) {
240 for (pos = atom->data + 8, end = pos + offset_count * 8;
251 static int update_chunk_offsets_callback(void *ctx, atom_t *atom)
256 switch (atom->type) {
258 return update_stco_offsets(context, atom);
261 return update_co64_offsets(context, atom);
275 atom->data,
276 atom->size,
299 static void upgrade_stco_atom(upgrade_stco_context_t *context, atom_t *atom)
309 offset_count = BE_32(atom->data + 4);
312 memcpy(context->dest, atom->data - atom->header_size, atom->header_size + 8);
314 set_atom_size(context->dest, atom->header_size, atom->header_size + 8 + offset_count * 8);
315 context->dest += atom->header_size + 8;
318 for (pos = atom->data + 8, end = pos + offset_count * 4;
328 static int upgrade_stco_callback(void *ctx, atom_t *atom)
334 switch (atom->type) {
336 upgrade_stco_atom(context, atom);
344 /* write the atom header */
345 memcpy(context->dest, atom->data - atom->header_size, atom->header_size);
347 context->dest += atom->header_size;
351 atom->data,
352 atom->size,
358 /* update the atom size */
359 set_atom_size(start_pos, atom->header_size, context->dest - start_pos);
363 copy_size = atom->header_size + atom->size;
364 memcpy(context->dest, atom->data - atom->header_size, copy_size);
401 fprintf(stderr, "could not allocate %"PRIu64" bytes for updated moov atom\n",
475 /* keep ftyp atom */
478 fprintf(stderr, "ftyp atom size %"PRIu64" too big\n",
486 fprintf(stderr, "could not allocate %"PRIu64" bytes for ftyp atom\n",
530 fprintf(stderr, "encountered non-QT top-level atom (is this a QuickTime file?)\n");
535 /* The atom header is 8 (or 16 bytes), if the atom size (which
537 * able to continue scanning sensibly after this atom, so break. */
552 printf("last atom in file was not a moov atom\n");
559 fprintf(stderr, "bad moov atom size\n");
563 /* moov atom was, in fact, the last atom in the chunk; load the whole
564 * moov atom */
577 fprintf(stderr, "could not allocate %"PRIu64" bytes for moov atom\n", atom_size);
607 if (start_offset > 0) { /* seek after ftyp atom */
622 /* dump the same ftyp atom */
624 printf(" writing ftyp atom...\n");
631 /* dump the new moov atom */
632 printf(" writing moov atom...\n");