2001-07-22 16:18:56 +02:00
|
|
|
|
2002-04-15 04:28:05 +02:00
|
|
|
#define LIBAV_VERSION_INT 0x000406
|
|
|
|
#define LIBAV_VERSION "0.4.6"
|
|
|
|
#define LIBAV_BUILD 4600
|
|
|
|
|
2001-07-22 16:18:56 +02:00
|
|
|
#include "avcodec.h"
|
|
|
|
|
|
|
|
#include "avio.h"
|
|
|
|
|
|
|
|
/* packet functions */
|
|
|
|
|
|
|
|
typedef struct AVPacket {
|
|
|
|
INT64 pts;
|
|
|
|
UINT8 *data;
|
|
|
|
int size;
|
|
|
|
int stream_index;
|
|
|
|
int flags;
|
|
|
|
#define PKT_FLAG_KEY 0x0001
|
2002-04-08 22:58:56 +02:00
|
|
|
#define PKT_FLAG_DROPPED_FRAME 0x0002
|
2001-07-22 16:18:56 +02:00
|
|
|
} AVPacket;
|
|
|
|
|
|
|
|
int av_new_packet(AVPacket *pkt, int size);
|
|
|
|
void av_free_packet(AVPacket *pkt);
|
|
|
|
|
|
|
|
/*************************************************/
|
|
|
|
/* output formats */
|
|
|
|
|
|
|
|
struct AVFormatContext;
|
|
|
|
struct AVFormatInputContext;
|
|
|
|
|
|
|
|
typedef struct AVFormatParameters {
|
|
|
|
int frame_rate;
|
|
|
|
int sample_rate;
|
|
|
|
int channels;
|
|
|
|
int width;
|
|
|
|
int height;
|
2002-04-08 22:58:56 +02:00
|
|
|
enum PixelFormat pix_fmt;
|
2001-07-22 16:18:56 +02:00
|
|
|
} AVFormatParameters;
|
|
|
|
|
|
|
|
typedef struct AVFormat {
|
|
|
|
const char *name;
|
|
|
|
const char *long_name;
|
|
|
|
const char *mime_type;
|
|
|
|
const char *extensions; /* comma separated extensions */
|
|
|
|
|
|
|
|
/* output support */
|
|
|
|
enum CodecID audio_codec; /* default audio codec */
|
|
|
|
enum CodecID video_codec; /* default video codec */
|
|
|
|
int (*write_header)(struct AVFormatContext *);
|
|
|
|
int (*write_packet)(struct AVFormatContext *,
|
|
|
|
int stream_index,
|
2002-04-07 23:44:29 +02:00
|
|
|
unsigned char *buf, int size, int force_pts);
|
2001-07-22 16:18:56 +02:00
|
|
|
int (*write_trailer)(struct AVFormatContext *);
|
|
|
|
|
|
|
|
/* optional input support */
|
|
|
|
/* read the format header and initialize the AVFormatInputContext
|
|
|
|
structure. Return 0 if OK. 'ap' if non NULL contains
|
|
|
|
additionnal paramters. Only used in raw format right now */
|
|
|
|
int (*read_header)(struct AVFormatContext *,
|
|
|
|
AVFormatParameters *ap);
|
|
|
|
/* read one packet and put it in 'pkt'. pts and flags are also set */
|
|
|
|
int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
|
|
|
|
/* close the stream. The AVFormatContext and AVStreams are not
|
|
|
|
freed by this function */
|
|
|
|
int (*read_close)(struct AVFormatContext *);
|
|
|
|
/* seek at or before a given pts (given in microsecond). The pts
|
|
|
|
origin is defined by the stream */
|
|
|
|
int (*read_seek)(struct AVFormatContext *, INT64 pts);
|
|
|
|
int flags;
|
2001-09-16 23:48:59 +02:00
|
|
|
#define AVFMT_NOFILE 0x0001 /* no file should be opened */
|
|
|
|
#define AVFMT_NEEDNUMBER 0x0002 /* needs '%d' in filename */
|
2001-07-22 16:18:56 +02:00
|
|
|
struct AVFormat *next;
|
|
|
|
} AVFormat;
|
|
|
|
|
|
|
|
typedef struct AVStream {
|
|
|
|
int id; /* internal stream id */
|
|
|
|
AVCodecContext codec; /* codec context */
|
|
|
|
void *priv_data;
|
|
|
|
} AVStream;
|
|
|
|
|
|
|
|
#define MAX_STREAMS 20
|
|
|
|
|
|
|
|
/* format I/O context */
|
|
|
|
typedef struct AVFormatContext {
|
|
|
|
struct AVFormat *format;
|
|
|
|
void *priv_data;
|
|
|
|
ByteIOContext pb;
|
|
|
|
int nb_streams;
|
|
|
|
AVStream *streams[MAX_STREAMS];
|
|
|
|
char filename[1024]; /* input or output filename */
|
|
|
|
/* stream info */
|
|
|
|
char title[512];
|
|
|
|
char author[512];
|
|
|
|
char copyright[512];
|
|
|
|
char comment[512];
|
|
|
|
/* This buffer is only needed when packets were already buffered but
|
|
|
|
not decoded, for example to get the codec parameters in mpeg
|
|
|
|
streams */
|
|
|
|
struct AVPacketList *packet_buffer;
|
|
|
|
} AVFormatContext;
|
|
|
|
|
|
|
|
typedef struct AVPacketList {
|
|
|
|
AVPacket pkt;
|
|
|
|
struct AVPacketList *next;
|
|
|
|
} AVPacketList;
|
|
|
|
|
|
|
|
extern AVFormat *first_format;
|
|
|
|
|
|
|
|
/* rv10enc.c */
|
|
|
|
extern AVFormat rm_format;
|
|
|
|
|
|
|
|
/* mpegmux.c */
|
|
|
|
extern AVFormat mpeg_mux_format;
|
|
|
|
|
|
|
|
/* asfenc.c */
|
|
|
|
extern AVFormat asf_format;
|
|
|
|
|
|
|
|
/* avienc.c */
|
|
|
|
extern AVFormat avi_format;
|
|
|
|
|
2002-04-08 14:32:01 +02:00
|
|
|
/* mov.c */
|
|
|
|
extern AVFormat mov_format;
|
|
|
|
extern AVFormat mp4_format;
|
|
|
|
|
2001-07-22 16:18:56 +02:00
|
|
|
/* jpegenc.c */
|
|
|
|
extern AVFormat mpjpeg_format;
|
|
|
|
extern AVFormat jpeg_format;
|
2001-08-15 15:04:53 +02:00
|
|
|
extern AVFormat single_jpeg_format;
|
2001-07-22 16:18:56 +02:00
|
|
|
|
|
|
|
/* swfenc.c */
|
|
|
|
extern AVFormat swf_format;
|
|
|
|
|
2002-04-08 14:32:01 +02:00
|
|
|
/* gif.c */
|
|
|
|
extern AVFormat gif_format;
|
|
|
|
/* au.c */
|
|
|
|
extern AVFormat au_format;
|
|
|
|
|
2001-07-22 16:18:56 +02:00
|
|
|
/* wav.c */
|
|
|
|
extern AVFormat wav_format;
|
|
|
|
|
|
|
|
/* img.c */
|
|
|
|
extern AVFormat pgm_format;
|
2001-08-11 20:59:34 +02:00
|
|
|
extern AVFormat ppm_format;
|
2001-07-22 16:18:56 +02:00
|
|
|
extern AVFormat pgmyuv_format;
|
|
|
|
extern AVFormat imgyuv_format;
|
2001-08-11 20:59:34 +02:00
|
|
|
|
2001-07-22 16:18:56 +02:00
|
|
|
extern AVFormat pgmpipe_format;
|
2001-08-11 20:59:34 +02:00
|
|
|
extern AVFormat pgmyuvpipe_format;
|
|
|
|
extern AVFormat ppmpipe_format;
|
2001-07-22 16:18:56 +02:00
|
|
|
|
|
|
|
/* raw.c */
|
|
|
|
extern AVFormat mp2_format;
|
|
|
|
extern AVFormat ac3_format;
|
|
|
|
extern AVFormat h263_format;
|
|
|
|
extern AVFormat mpeg1video_format;
|
2001-08-15 15:04:53 +02:00
|
|
|
extern AVFormat mjpeg_format;
|
2001-09-23 19:19:49 +02:00
|
|
|
extern AVFormat pcm_s16le_format;
|
|
|
|
extern AVFormat pcm_s16be_format;
|
|
|
|
extern AVFormat pcm_u16le_format;
|
|
|
|
extern AVFormat pcm_u16be_format;
|
|
|
|
extern AVFormat pcm_s8_format;
|
|
|
|
extern AVFormat pcm_u8_format;
|
|
|
|
extern AVFormat pcm_mulaw_format;
|
|
|
|
extern AVFormat pcm_alaw_format;
|
2001-07-22 16:18:56 +02:00
|
|
|
extern AVFormat rawvideo_format;
|
|
|
|
|
|
|
|
/* ffm.c */
|
|
|
|
extern AVFormat ffm_format;
|
|
|
|
|
|
|
|
/* formats.c */
|
|
|
|
|
|
|
|
#define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24))
|
|
|
|
#define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24))
|
|
|
|
|
|
|
|
void register_avformat(AVFormat *format);
|
|
|
|
AVFormat *guess_format(const char *short_name, const char *filename, const char *mime_type);
|
|
|
|
|
|
|
|
int strstart(const char *str, const char *val, const char **ptr);
|
|
|
|
void nstrcpy(char *buf, int buf_size, const char *str);
|
|
|
|
int match_ext(const char *filename, const char *extensions);
|
|
|
|
|
|
|
|
void register_all(void);
|
|
|
|
|
|
|
|
INT64 gettime(void);
|
|
|
|
|
|
|
|
typedef struct FifoBuffer {
|
|
|
|
UINT8 *buffer;
|
|
|
|
UINT8 *rptr, *wptr, *end;
|
|
|
|
} FifoBuffer;
|
|
|
|
|
|
|
|
int fifo_init(FifoBuffer *f, int size);
|
|
|
|
void fifo_free(FifoBuffer *f);
|
|
|
|
int fifo_size(FifoBuffer *f, UINT8 *rptr);
|
|
|
|
int fifo_read(FifoBuffer *f, UINT8 *buf, int buf_size, UINT8 **rptr_ptr);
|
|
|
|
void fifo_write(FifoBuffer *f, UINT8 *buf, int size, UINT8 **wptr_ptr);
|
|
|
|
|
2001-09-25 01:25:28 +02:00
|
|
|
AVFormatContext *av_open_input_file(const char *filename,
|
|
|
|
const char *format_name,
|
|
|
|
int buf_size,
|
|
|
|
AVFormatParameters *ap);
|
2001-07-22 16:18:56 +02:00
|
|
|
int av_read_packet(AVFormatContext *s, AVPacket *pkt);
|
|
|
|
void av_close_input_file(AVFormatContext *s);
|
|
|
|
|
2002-04-07 23:44:29 +02:00
|
|
|
int av_write_packet(AVFormatContext *s, AVPacket *pkt, int force_pts);
|
2001-07-22 16:18:56 +02:00
|
|
|
|
|
|
|
void dump_format(AVFormatContext *ic,
|
|
|
|
int index,
|
|
|
|
const char *url,
|
|
|
|
int is_output);
|
|
|
|
int parse_image_size(int *width_ptr, int *height_ptr, const char *str);
|
|
|
|
INT64 gettime(void);
|
|
|
|
INT64 parse_date(const char *datestr, int duration);
|
|
|
|
|
|
|
|
/* ffm specific for ffserver */
|
|
|
|
#define FFM_PACKET_SIZE 4096
|
|
|
|
offset_t ffm_read_write_index(int fd);
|
|
|
|
void ffm_write_write_index(int fd, offset_t pos);
|
|
|
|
void ffm_set_write_index(AVFormatContext *s, offset_t pos, offset_t file_size);
|
|
|
|
|
|
|
|
int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
|
|
|
|
|
2001-09-16 23:48:59 +02:00
|
|
|
int get_frame_filename(char *buf, int buf_size,
|
|
|
|
const char *path, int number);
|
2001-09-25 01:25:28 +02:00
|
|
|
|
|
|
|
/* grab/output specific */
|
|
|
|
extern AVFormat video_grab_device_format;
|
|
|
|
extern AVFormat audio_device_format;
|
|
|
|
|
|
|
|
extern const char *v4l_device;
|
|
|
|
extern const char *audio_device;
|