libgpac
Documentation of the core library of GPAC
avilib.c File Reference
#include <gpac/setup.h>
#include <gpac/internal/avilib.h>
+ Include dependency graph for avilib.c:

Macros

#define INFO_LIST
 
#define NEW_RIFF_THRES   (1900*1024*1024)
 
#define NR_IXNN_CHUNKS   96
 
#define DEBUG_ODML
 
#define MAX_INFO_STRLEN   64
 
#define FRAME_RATE_SCALE   1000000
 
#define HEADERBYTES   2048
 
#define AVI_MAX_LEN   (UINT_MAX-(1<<20)*16-HEADERBYTES)
 
#define PAD_EVEN(x)   ( ((x)+1) & ~1 )
 
#define OUTD(n)   long2str((unsigned char*) (ix00+bl),(s32)n); bl+=4
 
#define OUTW(n)   ix00[bl] = (n)&0xff; ix00[bl+1] = (n>>8)&0xff; bl+=2
 
#define OUTC(n)   ix00[bl] = (n)&0xff; bl+=1
 
#define OUTS(s)   memcpy(ix00+bl,s,4); bl+=4
 
#define OUT4CC(s)
 
#define OUTLONG(n)
 
#define OUTSHRT(n)
 
#define OUTCHR(n)
 
#define OUTMEM(d, s)
 
#define AVIF_HASINDEX   0x00000010 /* Index at end of file */
 
#define AVIF_MUSTUSEINDEX   0x00000020
 
#define AVIF_ISINTERLEAVED   0x00000100
 
#define AVIF_TRUSTCKTYPE   0x00000800 /* Use CKType to find key frames */
 
#define AVIF_WASCAPTUREFILE   0x00010000
 
#define AVIF_COPYRIGHTED   0x00020000
 
#define S_IRWXU   00700 /* read, write, execute: owner */
 
#define S_IRUSR   00400 /* read permission: owner */
 
#define S_IWUSR   00200 /* write permission: owner */
 
#define S_IXUSR   00100 /* execute permission: owner */
 
#define S_IRWXG   00070 /* read, write, execute: group */
 
#define S_IRGRP   00040 /* read permission: group */
 
#define S_IWGRP   00020 /* write permission: group */
 
#define S_IXGRP   00010 /* execute permission: group */
 
#define S_IRWXO   00007 /* read, write, execute: other */
 
#define S_IROTH   00004 /* read permission: other */
 
#define S_IWOTH   00002 /* write permission: other */
 
#define S_IXOTH   00001 /* execute permission: other */
 
#define AVIF_HASINDEX   0x00000010 /* Index at end of file */
 
#define AVIF_MUSTUSEINDEX   0x00000020
 
#define AVIF_ISINTERLEAVED   0x00000100
 
#define AVIF_TRUSTCKTYPE   0x00000800 /* Use CKType to find key frames */
 
#define AVIF_WASCAPTUREFILE   0x00010000
 
#define AVIF_COPYRIGHTED   0x00020000
 
#define ERR_EXIT(x)
 

Functions

static u32 avi_read (FILE *fd, char *buf, u32 len)
 
static u32 avi_write (FILE *fd, char *buf, u32 len)
 
static void long2str (unsigned char *dst, s32 n)
 
static u64 str2ullong (unsigned char *str)
 
static u32 str2ulong (unsigned char *str)
 
static u32 str2ushort (unsigned char *str)
 
static u32 str2ulong_len (unsigned char *str)
 
static u32 str2ulong_key (unsigned char *str)
 
static int avi_sampsize (avi_t *AVI, int j)
 
static int avi_add_chunk (avi_t *AVI, unsigned char *tag, unsigned char *data, u32 length)
 
static int avi_ixnn_entry (avi_t *AVI, avistdindex_chunk *ch, avisuperindex_entry *en)
 
static int avi_init_super_index (avi_t *AVI, unsigned char *idxtag, avisuperindex_chunk **si)
 
static int avi_add_std_index (avi_t *AVI, unsigned char *idxtag, unsigned char *strtag, avistdindex_chunk *stdil)
 
static int avi_add_odml_index_entry_core (avi_t *AVI, int flags, u64 pos, unsigned int len, avistdindex_chunk *si)
 
static int avi_add_odml_index_entry (avi_t *AVI, unsigned char *tag, int flags, u64 pos, unsigned int len)
 
static int avi_add_index_entry (avi_t *AVI, unsigned char *tag, int flags, u64 pos, u64 len)
 
GF_EXPORT avi_tAVI_open_output_file (char *filename, u64 opendml_threshold)
 
GF_EXPORT void AVI_set_video (avi_t *AVI, int width, int height, double fps, char *compressor)
 
GF_EXPORT void AVI_set_audio (avi_t *AVI, int channels, int rate, int bits, int format, int mp3rate)
 
int avi_update_header (avi_t *AVI)
 
static int avi_close_output_file (avi_t *AVI)
 
static int avi_write_data (avi_t *AVI, char *data, unsigned int length, int audio, int keyframe)
 
GF_EXPORT int AVI_write_frame (avi_t *AVI, u8 *data, int bytes, int keyframe)
 
GF_EXPORT int AVI_write_audio (avi_t *AVI, u8 *data, int bytes)
 
int AVI_set_audio_track (avi_t *AVI, u32 track)
 
int AVI_get_audio_track (avi_t *AVI)
 
GF_EXPORT int AVI_close (avi_t *AVI)
 
avi_tAVI_open_input_file (char *filename, int getIndex)
 
int avi_parse_input_file (avi_t *AVI, int getIndex)
 
int AVI_video_frames (avi_t *AVI)
 
int AVI_video_width (avi_t *AVI)
 
int AVI_video_height (avi_t *AVI)
 
double AVI_frame_rate (avi_t *AVI)
 
char * AVI_video_compressor (avi_t *AVI)
 
int AVI_audio_tracks (avi_t *AVI)
 
int AVI_audio_channels (avi_t *AVI)
 
int AVI_audio_mp3rate (avi_t *AVI)
 
int AVI_audio_bits (avi_t *AVI)
 
int AVI_audio_format (avi_t *AVI)
 
int AVI_audio_rate (avi_t *AVI)
 
int AVI_frame_size (avi_t *AVI, int frame)
 
int AVI_audio_size (avi_t *AVI, int frame)
 
u64 AVI_get_video_position (avi_t *AVI, int frame)
 
int AVI_seek_start (avi_t *AVI)
 
int AVI_set_video_position (avi_t *AVI, int frame)
 
int AVI_read_frame (avi_t *AVI, u8 *vidbuf, int *keyframe)
 
int AVI_set_audio_position (avi_t *AVI, int byte)
 
int AVI_read_audio (avi_t *AVI, u8 *audbuf, int bytes, int *continuous)
 

Variables

int AVI_errno = 0
 
static char id_str [MAX_INFO_STRLEN]
 

Macro Definition Documentation

◆ INFO_LIST

#define INFO_LIST

◆ NEW_RIFF_THRES

#define NEW_RIFF_THRES   (1900*1024*1024)

◆ NR_IXNN_CHUNKS

#define NR_IXNN_CHUNKS   96

◆ DEBUG_ODML

#define DEBUG_ODML

◆ MAX_INFO_STRLEN

#define MAX_INFO_STRLEN   64

◆ FRAME_RATE_SCALE

#define FRAME_RATE_SCALE   1000000

◆ HEADERBYTES

#define HEADERBYTES   2048

◆ AVI_MAX_LEN

#define AVI_MAX_LEN   (UINT_MAX-(1<<20)*16-HEADERBYTES)

◆ PAD_EVEN

#define PAD_EVEN (   x)    ( ((x)+1) & ~1 )

◆ OUTD

#define OUTD (   n)    long2str((unsigned char*) (ix00+bl),(s32)n); bl+=4

◆ OUTW

#define OUTW (   n)    ix00[bl] = (n)&0xff; ix00[bl+1] = (n>>8)&0xff; bl+=2

◆ OUTC

#define OUTC (   n)    ix00[bl] = (n)&0xff; bl+=1

◆ OUTS

#define OUTS (   s)    memcpy(ix00+bl,s,4); bl+=4

◆ OUT4CC

#define OUT4CC (   s)
Value:
if(nhb<=HEADERBYTES-4) memcpy(AVI_header+nhb,s,4); \
nhb += 4
#define HEADERBYTES
Definition: avilib.c:92

◆ OUTLONG

#define OUTLONG (   n)
Value:
if(nhb<=HEADERBYTES-4) long2str(AVI_header+nhb, (s32)(n)); \
nhb += 4
static void long2str(unsigned char *dst, s32 n)
Definition: avilib.c:105
int32_t s32
Definition: setup.h:328

◆ OUTSHRT

#define OUTSHRT (   n)
Value:
if(nhb<=HEADERBYTES-2) { \
AVI_header[nhb ] = (u8) ((n )&0xff); \
AVI_header[nhb+1] = (u8) ((n>>8)&0xff); \
} \
nhb += 2
uint8_t u8
Definition: setup.h:334

◆ OUTCHR

#define OUTCHR (   n)
Value:
if(nhb<=HEADERBYTES-1) { \
AVI_header[nhb ] = (n )&0xff; \
} \
nhb += 1

◆ OUTMEM

#define OUTMEM (   d,
 
)
Value:
{ \
u32 s_ = (u32) (s); \
if(nhb + s_ <= HEADERBYTES) \
memcpy(AVI_header+nhb, (d), s_); \
nhb += s_; \
}
uint32_t u32
Definition: setup.h:326

◆ AVIF_HASINDEX [1/2]

#define AVIF_HASINDEX   0x00000010 /* Index at end of file */

◆ AVIF_MUSTUSEINDEX [1/2]

#define AVIF_MUSTUSEINDEX   0x00000020

◆ AVIF_ISINTERLEAVED [1/2]

#define AVIF_ISINTERLEAVED   0x00000100

◆ AVIF_TRUSTCKTYPE [1/2]

#define AVIF_TRUSTCKTYPE   0x00000800 /* Use CKType to find key frames */

◆ AVIF_WASCAPTUREFILE [1/2]

#define AVIF_WASCAPTUREFILE   0x00010000

◆ AVIF_COPYRIGHTED [1/2]

#define AVIF_COPYRIGHTED   0x00020000

◆ S_IRWXU

#define S_IRWXU   00700 /* read, write, execute: owner */

◆ S_IRUSR

#define S_IRUSR   00400 /* read permission: owner */

◆ S_IWUSR

#define S_IWUSR   00200 /* write permission: owner */

◆ S_IXUSR

#define S_IXUSR   00100 /* execute permission: owner */

◆ S_IRWXG

#define S_IRWXG   00070 /* read, write, execute: group */

◆ S_IRGRP

#define S_IRGRP   00040 /* read permission: group */

◆ S_IWGRP

#define S_IWGRP   00020 /* write permission: group */

◆ S_IXGRP

#define S_IXGRP   00010 /* execute permission: group */

◆ S_IRWXO

#define S_IRWXO   00007 /* read, write, execute: other */

◆ S_IROTH

#define S_IROTH   00004 /* read permission: other */

◆ S_IWOTH

#define S_IWOTH   00002 /* write permission: other */

◆ S_IXOTH

#define S_IXOTH   00001 /* execute permission: other */

◆ AVIF_HASINDEX [2/2]

#define AVIF_HASINDEX   0x00000010 /* Index at end of file */

◆ AVIF_MUSTUSEINDEX [2/2]

#define AVIF_MUSTUSEINDEX   0x00000020

◆ AVIF_ISINTERLEAVED [2/2]

#define AVIF_ISINTERLEAVED   0x00000100

◆ AVIF_TRUSTCKTYPE [2/2]

#define AVIF_TRUSTCKTYPE   0x00000800 /* Use CKType to find key frames */

◆ AVIF_WASCAPTUREFILE [2/2]

#define AVIF_WASCAPTUREFILE   0x00010000

◆ AVIF_COPYRIGHTED [2/2]

#define AVIF_COPYRIGHTED   0x00020000

◆ ERR_EXIT

#define ERR_EXIT (   x)
Value:
{ \
if (hdrl_data) { gf_free(hdrl_data); hdrl_data=NULL; }\
AVI_close(AVI); \
AVI_errno = x; \
return 0; \
}
void gf_free(void *ptr)
Definition: alloc.c:163

Function Documentation

◆ avi_read()

static u32 avi_read ( FILE *  fd,
char *  buf,
u32  len 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ avi_write()

static u32 avi_write ( FILE *  fd,
char *  buf,
u32  len 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ long2str()

static void long2str ( unsigned char *  dst,
s32  n 
)
static
+ Here is the caller graph for this function:

◆ str2ullong()

static u64 str2ullong ( unsigned char *  str)
static
+ Here is the caller graph for this function:

◆ str2ulong()

static u32 str2ulong ( unsigned char *  str)
static
+ Here is the caller graph for this function:

◆ str2ushort()

static u32 str2ushort ( unsigned char *  str)
static
+ Here is the caller graph for this function:

◆ str2ulong_len()

static u32 str2ulong_len ( unsigned char *  str)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ str2ulong_key()

static u32 str2ulong_key ( unsigned char *  str)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ avi_sampsize()

static int avi_sampsize ( avi_t AVI,
int  j 
)
static
+ Here is the caller graph for this function:

◆ avi_add_chunk()

static int avi_add_chunk ( avi_t AVI,
unsigned char *  tag,
unsigned char *  data,
u32  length 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ avi_ixnn_entry()

static int avi_ixnn_entry ( avi_t AVI,
avistdindex_chunk ch,
avisuperindex_entry en 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ avi_init_super_index()

static int avi_init_super_index ( avi_t AVI,
unsigned char *  idxtag,
avisuperindex_chunk **  si 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ avi_add_std_index()

static int avi_add_std_index ( avi_t AVI,
unsigned char *  idxtag,
unsigned char *  strtag,
avistdindex_chunk stdil 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ avi_add_odml_index_entry_core()

static int avi_add_odml_index_entry_core ( avi_t AVI,
int  flags,
u64  pos,
unsigned int  len,
avistdindex_chunk si 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ avi_add_odml_index_entry()

static int avi_add_odml_index_entry ( avi_t AVI,
unsigned char *  tag,
int  flags,
u64  pos,
unsigned int  len 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ avi_add_index_entry()

static int avi_add_index_entry ( avi_t AVI,
unsigned char *  tag,
int  flags,
u64  pos,
u64  len 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AVI_open_output_file()

GF_EXPORT avi_t* AVI_open_output_file ( char *  filename,
u64  opendml_threshold 
)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AVI_set_video()

GF_EXPORT void AVI_set_video ( avi_t AVI,
int  width,
int  height,
double  fps,
char *  compressor 
)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AVI_set_audio()

GF_EXPORT void AVI_set_audio ( avi_t AVI,
int  channels,
int  rate,
int  bits,
int  format,
int  mp3rate 
)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ avi_update_header()

int avi_update_header ( avi_t AVI)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ avi_close_output_file()

static int avi_close_output_file ( avi_t AVI)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ avi_write_data()

static int avi_write_data ( avi_t AVI,
char *  data,
unsigned int  length,
int  audio,
int  keyframe 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AVI_write_frame()

GF_EXPORT int AVI_write_frame ( avi_t AVI,
u8 data,
int  bytes,
int  keyframe 
)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AVI_write_audio()

GF_EXPORT int AVI_write_audio ( avi_t AVI,
u8 data,
int  bytes 
)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AVI_set_audio_track()

int AVI_set_audio_track ( avi_t AVI,
u32  track 
)
+ Here is the caller graph for this function:

◆ AVI_get_audio_track()

int AVI_get_audio_track ( avi_t AVI)
+ Here is the caller graph for this function:

◆ AVI_close()

GF_EXPORT int AVI_close ( avi_t AVI)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AVI_open_input_file()

avi_t* AVI_open_input_file ( char *  filename,
int  getIndex 
)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ avi_parse_input_file()

int avi_parse_input_file ( avi_t AVI,
int  getIndex 
)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AVI_video_frames()

int AVI_video_frames ( avi_t AVI)
+ Here is the caller graph for this function:

◆ AVI_video_width()

int AVI_video_width ( avi_t AVI)
+ Here is the caller graph for this function:

◆ AVI_video_height()

int AVI_video_height ( avi_t AVI)
+ Here is the caller graph for this function:

◆ AVI_frame_rate()

double AVI_frame_rate ( avi_t AVI)
+ Here is the caller graph for this function:

◆ AVI_video_compressor()

char* AVI_video_compressor ( avi_t AVI)
+ Here is the caller graph for this function:

◆ AVI_audio_tracks()

int AVI_audio_tracks ( avi_t AVI)
+ Here is the caller graph for this function:

◆ AVI_audio_channels()

int AVI_audio_channels ( avi_t AVI)
+ Here is the caller graph for this function:

◆ AVI_audio_mp3rate()

int AVI_audio_mp3rate ( avi_t AVI)
+ Here is the caller graph for this function:

◆ AVI_audio_bits()

int AVI_audio_bits ( avi_t AVI)
+ Here is the caller graph for this function:

◆ AVI_audio_format()

int AVI_audio_format ( avi_t AVI)
+ Here is the caller graph for this function:

◆ AVI_audio_rate()

int AVI_audio_rate ( avi_t AVI)
+ Here is the caller graph for this function:

◆ AVI_frame_size()

int AVI_frame_size ( avi_t AVI,
int  frame 
)
+ Here is the caller graph for this function:

◆ AVI_audio_size()

int AVI_audio_size ( avi_t AVI,
int  frame 
)
+ Here is the caller graph for this function:

◆ AVI_get_video_position()

u64 AVI_get_video_position ( avi_t AVI,
int  frame 
)
+ Here is the caller graph for this function:

◆ AVI_seek_start()

int AVI_seek_start ( avi_t AVI)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AVI_set_video_position()

int AVI_set_video_position ( avi_t AVI,
int  frame 
)
+ Here is the caller graph for this function:

◆ AVI_read_frame()

int AVI_read_frame ( avi_t AVI,
u8 vidbuf,
int *  keyframe 
)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AVI_set_audio_position()

int AVI_set_audio_position ( avi_t AVI,
int  byte 
)
+ Here is the caller graph for this function:

◆ AVI_read_audio()

int AVI_read_audio ( avi_t AVI,
u8 audbuf,
int  bytes,
int *  continuous 
)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ AVI_errno

int AVI_errno = 0

◆ id_str

char id_str[MAX_INFO_STRLEN]
static