FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Functions
qt-faststart.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <string.h>
#include <limits.h>

Go to the source code of this file.

Data Structures

struct  atom_t
 
struct  update_chunk_offsets_context_t
 
struct  upgrade_stco_context_t
 

Macros

#define MIN(a, b)   ((a) > (b) ? (b) : (a))
 
#define BE_32(x)
 
#define BE_64(x)
 
#define AV_WB32(p, val)
 
#define AV_WB64(p, val)
 
#define BE_FOURCC(ch0, ch1, ch2, ch3)
 
#define QT_ATOM   BE_FOURCC
 
#define FREE_ATOM   QT_ATOM('f', 'r', 'e', 'e')
 
#define JUNK_ATOM   QT_ATOM('j', 'u', 'n', 'k')
 
#define MDAT_ATOM   QT_ATOM('m', 'd', 'a', 't')
 
#define MOOV_ATOM   QT_ATOM('m', 'o', 'o', 'v')
 
#define PNOT_ATOM   QT_ATOM('p', 'n', 'o', 't')
 
#define SKIP_ATOM   QT_ATOM('s', 'k', 'i', 'p')
 
#define WIDE_ATOM   QT_ATOM('w', 'i', 'd', 'e')
 
#define PICT_ATOM   QT_ATOM('P', 'I', 'C', 'T')
 
#define FTYP_ATOM   QT_ATOM('f', 't', 'y', 'p')
 
#define UUID_ATOM   QT_ATOM('u', 'u', 'i', 'd')
 
#define CMOV_ATOM   QT_ATOM('c', 'm', 'o', 'v')
 
#define TRAK_ATOM   QT_ATOM('t', 'r', 'a', 'k')
 
#define MDIA_ATOM   QT_ATOM('m', 'd', 'i', 'a')
 
#define MINF_ATOM   QT_ATOM('m', 'i', 'n', 'f')
 
#define STBL_ATOM   QT_ATOM('s', 't', 'b', 'l')
 
#define STCO_ATOM   QT_ATOM('s', 't', 'c', 'o')
 
#define CO64_ATOM   QT_ATOM('c', 'o', '6', '4')
 
#define ATOM_PREAMBLE_SIZE   8
 
#define COPY_BUFFER_SIZE   33554432
 
#define MAX_FTYP_ATOM_SIZE   1048576
 

Typedefs

typedef int(* parse_atoms_callback_t )(void *context, atom_t *atom)
 

Functions

static int parse_atoms (unsigned char *buf, uint64_t size, parse_atoms_callback_t callback, void *context)
 
static int update_stco_offsets (update_chunk_offsets_context_t *context, atom_t *atom)
 
static int update_co64_offsets (update_chunk_offsets_context_t *context, atom_t *atom)
 
static int update_chunk_offsets_callback (void *ctx, atom_t *atom)
 
static void set_atom_size (unsigned char *header, uint32_t header_size, uint64_t size)
 
static void upgrade_stco_atom (upgrade_stco_context_t *context, atom_t *atom)
 
static int upgrade_stco_callback (void *ctx, atom_t *atom)
 
static int update_moov_atom (unsigned char **moov_atom, uint64_t *moov_atom_size)
 
int main (int argc, char *argv[])
 

Macro Definition Documentation

#define MIN (   a,
  b 
)    ((a) > (b) ? (b) : (a))

Definition at line 45 of file qt-faststart.c.

Referenced by main().

#define BE_32 (   x)
Value:
(((uint32_t)(((uint8_t*)(x))[0]) << 24) | \
(((uint8_t*)(x))[1] << 16) | \
(((uint8_t*)(x))[2] << 8) | \
((uint8_t*)(x))[3])
uint8_t

Definition at line 47 of file qt-faststart.c.

Referenced by main(), parse_atoms(), update_co64_offsets(), update_stco_offsets(), and upgrade_stco_atom().

#define BE_64 (   x)
Value:
(((uint64_t)(((uint8_t*)(x))[0]) << 56) | \
((uint64_t)(((uint8_t*)(x))[1]) << 48) | \
((uint64_t)(((uint8_t*)(x))[2]) << 40) | \
((uint64_t)(((uint8_t*)(x))[3]) << 32) | \
((uint64_t)(((uint8_t*)(x))[4]) << 24) | \
((uint64_t)(((uint8_t*)(x))[5]) << 16) | \
((uint64_t)(((uint8_t*)(x))[6]) << 8) | \
((uint64_t)( (uint8_t*)(x))[7]))
uint8_t

Definition at line 52 of file qt-faststart.c.

Referenced by main(), parse_atoms(), and update_co64_offsets().

#define AV_WB32 (   p,
  val 
)
Value:
{ \
((uint8_t*)(p))[0] = ((val) >> 24) & 0xff; \
((uint8_t*)(p))[1] = ((val) >> 16) & 0xff; \
((uint8_t*)(p))[2] = ((val) >> 8) & 0xff; \
((uint8_t*)(p))[3] = (val) & 0xff; \
}
const char const char void * val
Definition: avisynth_c.h:771
uint8_t

Definition at line 61 of file qt-faststart.c.

Referenced by set_atom_size(), update_stco_offsets(), and upgrade_stco_atom().

#define AV_WB64 (   p,
  val 
)
Value:
{ \
AV_WB32(p, (val) >> 32) \
AV_WB32(p + 4, val) \
}
const char const char void * val
Definition: avisynth_c.h:771
#define AV_WB32(p, val)
Definition: qt-faststart.c:61

Definition at line 68 of file qt-faststart.c.

Referenced by set_atom_size(), update_co64_offsets(), and upgrade_stco_atom().

#define BE_FOURCC (   ch0,
  ch1,
  ch2,
  ch3 
)
Value:
( (uint32_t)(unsigned char)(ch3) | \
((uint32_t)(unsigned char)(ch2) << 8) | \
((uint32_t)(unsigned char)(ch1) << 16) | \
((uint32_t)(unsigned char)(ch0) << 24) )

Definition at line 73 of file qt-faststart.c.

#define QT_ATOM   BE_FOURCC

Definition at line 79 of file qt-faststart.c.

#define FREE_ATOM   QT_ATOM('f', 'r', 'e', 'e')

Definition at line 81 of file qt-faststart.c.

Referenced by main().

#define JUNK_ATOM   QT_ATOM('j', 'u', 'n', 'k')

Definition at line 82 of file qt-faststart.c.

Referenced by main().

#define MDAT_ATOM   QT_ATOM('m', 'd', 'a', 't')

Definition at line 83 of file qt-faststart.c.

Referenced by main().

#define MOOV_ATOM   QT_ATOM('m', 'o', 'o', 'v')

Definition at line 84 of file qt-faststart.c.

Referenced by main(), update_chunk_offsets_callback(), and upgrade_stco_callback().

#define PNOT_ATOM   QT_ATOM('p', 'n', 'o', 't')

Definition at line 85 of file qt-faststart.c.

Referenced by main().

#define SKIP_ATOM   QT_ATOM('s', 'k', 'i', 'p')

Definition at line 86 of file qt-faststart.c.

Referenced by main().

#define WIDE_ATOM   QT_ATOM('w', 'i', 'd', 'e')

Definition at line 87 of file qt-faststart.c.

Referenced by main().

#define PICT_ATOM   QT_ATOM('P', 'I', 'C', 'T')

Definition at line 88 of file qt-faststart.c.

Referenced by main().

#define FTYP_ATOM   QT_ATOM('f', 't', 'y', 'p')

Definition at line 89 of file qt-faststart.c.

Referenced by main().

#define UUID_ATOM   QT_ATOM('u', 'u', 'i', 'd')

Definition at line 90 of file qt-faststart.c.

Referenced by main().

#define CMOV_ATOM   QT_ATOM('c', 'm', 'o', 'v')

Definition at line 92 of file qt-faststart.c.

Referenced by main().

#define TRAK_ATOM   QT_ATOM('t', 'r', 'a', 'k')

Definition at line 93 of file qt-faststart.c.

Referenced by update_chunk_offsets_callback(), and upgrade_stco_callback().

#define MDIA_ATOM   QT_ATOM('m', 'd', 'i', 'a')

Definition at line 94 of file qt-faststart.c.

Referenced by update_chunk_offsets_callback(), and upgrade_stco_callback().

#define MINF_ATOM   QT_ATOM('m', 'i', 'n', 'f')

Definition at line 95 of file qt-faststart.c.

Referenced by update_chunk_offsets_callback(), and upgrade_stco_callback().

#define STBL_ATOM   QT_ATOM('s', 't', 'b', 'l')

Definition at line 96 of file qt-faststart.c.

Referenced by update_chunk_offsets_callback(), and upgrade_stco_callback().

#define STCO_ATOM   QT_ATOM('s', 't', 'c', 'o')

Definition at line 97 of file qt-faststart.c.

Referenced by update_chunk_offsets_callback(), and upgrade_stco_callback().

#define CO64_ATOM   QT_ATOM('c', 'o', '6', '4')

Definition at line 98 of file qt-faststart.c.

Referenced by update_chunk_offsets_callback(), and upgrade_stco_atom().

#define ATOM_PREAMBLE_SIZE   8

Definition at line 100 of file qt-faststart.c.

Referenced by main(), and parse_atoms().

#define COPY_BUFFER_SIZE   33554432

Definition at line 101 of file qt-faststart.c.

Referenced by main().

#define MAX_FTYP_ATOM_SIZE   1048576

Definition at line 102 of file qt-faststart.c.

Referenced by main().

Typedef Documentation

typedef int(* parse_atoms_callback_t)(void *context, atom_t *atom)

Definition at line 125 of file qt-faststart.c.

Function Documentation

static int parse_atoms ( unsigned char *  buf,
uint64_t  size,
parse_atoms_callback_t  callback,
void context 
)
static
static int update_stco_offsets ( update_chunk_offsets_context_t context,
atom_t atom 
)
static

Definition at line 185 of file qt-faststart.c.

Referenced by update_chunk_offsets_callback().

static int update_co64_offsets ( update_chunk_offsets_context_t context,
atom_t atom 
)
static

Definition at line 221 of file qt-faststart.c.

Referenced by update_chunk_offsets_callback().

static int update_chunk_offsets_callback ( void ctx,
atom_t atom 
)
static

Definition at line 251 of file qt-faststart.c.

Referenced by update_moov_atom().

static void set_atom_size ( unsigned char *  header,
uint32_t  header_size,
uint64_t  size 
)
static

Definition at line 286 of file qt-faststart.c.

Referenced by upgrade_stco_atom(), and upgrade_stco_callback().

static void upgrade_stco_atom ( upgrade_stco_context_t context,
atom_t atom 
)
static

Definition at line 299 of file qt-faststart.c.

Referenced by upgrade_stco_callback().

static int upgrade_stco_callback ( void ctx,
atom_t atom 
)
static

Definition at line 328 of file qt-faststart.c.

Referenced by update_moov_atom().

static int update_moov_atom ( unsigned char **  moov_atom,
uint64_t *  moov_atom_size 
)
static

Definition at line 372 of file qt-faststart.c.

Referenced by main().

int main ( int  argc,
char *  argv[] 
)

Definition at line 430 of file qt-faststart.c.