FFmpeg
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

◆ MIN

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

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

◆ BE_32

#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])

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

◆ BE_64

#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]))

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

◆ AV_WB32

#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; \
}

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

◆ AV_WB64

#define AV_WB64 (   p,
  val 
)
Value:
{ \
AV_WB32(p, (val) >> 32) \
AV_WB32(p + 4, val) \
}

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

◆ BE_FOURCC

#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.

◆ QT_ATOM

#define QT_ATOM   BE_FOURCC

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

◆ FREE_ATOM

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

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

◆ JUNK_ATOM

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

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

◆ MDAT_ATOM

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

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

◆ MOOV_ATOM

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

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

◆ PNOT_ATOM

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

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

◆ SKIP_ATOM

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

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

◆ WIDE_ATOM

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

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

◆ PICT_ATOM

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

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

◆ FTYP_ATOM

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

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

◆ UUID_ATOM

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

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

◆ CMOV_ATOM

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

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

◆ TRAK_ATOM

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

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

◆ MDIA_ATOM

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

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

◆ MINF_ATOM

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

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

◆ STBL_ATOM

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

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

◆ STCO_ATOM

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

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

◆ CO64_ATOM

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

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

◆ ATOM_PREAMBLE_SIZE

#define ATOM_PREAMBLE_SIZE   8

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

◆ COPY_BUFFER_SIZE

#define COPY_BUFFER_SIZE   33554432

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

◆ MAX_FTYP_ATOM_SIZE

#define MAX_FTYP_ATOM_SIZE   1048576

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

Typedef Documentation

◆ parse_atoms_callback_t

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

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

Function Documentation

◆ parse_atoms()

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

◆ update_stco_offsets()

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().

◆ update_co64_offsets()

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().

◆ 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().

◆ set_atom_size()

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().

◆ upgrade_stco_atom()

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().

◆ 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().

◆ 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().

◆ main()

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

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

val
static double val(void *priv, double ch)
Definition: aeval.c:78