Newer
Older
int pix_fmt, int width, int height);
/* external high level API */
extern AVCodec *first_avcodec;
unsigned avcodec_version(void);
unsigned avcodec_build(void);
void avcodec_init(void);
void register_avcodec(AVCodec *format);
AVCodec *avcodec_find_encoder(enum CodecID id);
AVCodec *avcodec_find_encoder_by_name(const char *name);
AVCodec *avcodec_find_decoder(enum CodecID id);
AVCodec *avcodec_find_decoder_by_name(const char *name);
void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic);
void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);
enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt);
int avcodec_thread_init(AVCodecContext *s, int thread_count);
void avcodec_thread_free(AVCodecContext *s);
int avcodec_thread_execute(AVCodecContext *s, int (*func)(AVCodecContext *c2, void *arg2),void **arg, int *ret, int count);
int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void **arg, int *ret, int count);
/**
* opens / inits the AVCodecContext.
* not thread save!
*/
int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
uint8_t *buf, int buf_size);
int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata,
Fabrice Bellard
committed
int *data_size_ptr,
uint8_t *buf, int buf_size);
int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
int avcodec_close(AVCodecContext *avctx);
void avcodec_register_all(void);
void avcodec_flush_buffers(AVCodecContext *avctx);
Michael Niedermayer
committed
/* misc usefull functions */
/**
* returns a single letter to describe the picture type
*/
char av_get_pict_type_char(int pict_type);
Michael Niedermayer
committed
/**
* reduce a fraction.
* this is usefull for framerate calculations
* @param max the maximum allowed for dst_nom & dst_den
* @return 1 if exact, 0 otherwise
*/
int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max);
/**
* rescale a 64bit integer with rounding to nearest.
Michael Niedermayer
committed
* a simple a*b/c isnt possible as it can overflow
*/
Michael Niedermayer
committed
int64_t av_rescale(int64_t a, int64_t b, int64_t c);
/**
* rescale a 64bit integer with specified rounding.
* a simple a*b/c isnt possible as it can overflow
*/
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding);
/**
* Interface for 0.5.0 version
*
* do not even think about it's usage for this moment
*/
typedef struct {
/// compressed size used from given memory buffer
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
int size;
/// I/P/B frame type
int frame_type;
} avc_enc_result_t;
/**
* Commands
* order can't be changed - once it was defined
*/
typedef enum {
// general commands
AVC_OPEN_BY_NAME = 0xACA000,
AVC_OPEN_BY_CODEC_ID,
AVC_OPEN_BY_FOURCC,
AVC_CLOSE,
AVC_FLUSH,
// pin - struct { uint8_t* src, uint_t src_size }
// pout - struct { AVPicture* img, consumed_bytes,
AVC_DECODE,
// pin - struct { AVPicture* img, uint8_t* dest, uint_t dest_size }
// pout - uint_t used_from_dest_size
AVC_ENCODE,
// query/get video commands
AVC_GET_VERSION = 0xACB000,
AVC_GET_WIDTH,
AVC_GET_HEIGHT,
AVC_GET_DELAY,
AVC_GET_QUANT_TABLE,
// ...
// query/get audio commands
AVC_GET_FRAME_SIZE = 0xABC000,
// maybe define some simple structure which
// might be passed to the user - but they can't
// contain any codec specific parts and these
// calls are usualy necessary only few times
// set video commands
AVC_SET_WIDTH = 0xACD000,
AVC_SET_HEIGHT,
// set video encoding commands
AVC_SET_FRAME_RATE = 0xACD800,
AVC_SET_QUALITY,
AVC_SET_HURRY_UP,
// set audio commands
AVC_SET_SAMPLE_RATE = 0xACE000,
AVC_SET_CHANNELS,
} avc_cmd_t;
/**
* \param handle allocated private structure by libavcodec
* for initialization pass NULL - will be returned pout
* user is supposed to know nothing about its structure
* \param cmd type of operation to be performed
* \param pint input parameter
* \param pout output parameter
*
* \returns command status - eventually for query command it might return
* integer resulting value
*/
int avcodec(void* handle, avc_cmd_t cmd, void* pin, void* pout);
/* frame parsing */
typedef struct AVCodecParserContext {
void *priv_data;
struct AVCodecParser *parser;
int64_t frame_offset; /* offset of the current frame */
int64_t cur_offset; /* current offset
(incremented by each av_parser_parse()) */
int64_t last_frame_offset; /* offset of the last frame */
/* video info */
int pict_type; /* XXX: put it back in AVCodecContext */
int repeat_pict; /* XXX: put it back in AVCodecContext */
int64_t pts; /* pts of the current frame */
int64_t dts; /* dts of the current frame */
/* private data */
int64_t last_pts;
int64_t last_dts;
#define AV_PARSER_PTS_NB 4
int cur_frame_start_index;
int64_t cur_frame_offset[AV_PARSER_PTS_NB];
int64_t cur_frame_pts[AV_PARSER_PTS_NB];
int64_t cur_frame_dts[AV_PARSER_PTS_NB];
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
} AVCodecParserContext;
typedef struct AVCodecParser {
int codec_ids[3]; /* several codec IDs are permitted */
int priv_data_size;
int (*parser_init)(AVCodecParserContext *s);
int (*parser_parse)(AVCodecParserContext *s,
AVCodecContext *avctx,
uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size);
void (*parser_close)(AVCodecParserContext *s);
struct AVCodecParser *next;
} AVCodecParser;
extern AVCodecParser *av_first_parser;
void av_register_codec_parser(AVCodecParser *parser);
AVCodecParserContext *av_parser_init(int codec_id);
int av_parser_parse(AVCodecParserContext *s,
AVCodecContext *avctx,
uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size,
int64_t pts, int64_t dts);
void av_parser_close(AVCodecParserContext *s);
extern AVCodecParser mpegvideo_parser;
extern AVCodecParser mpeg4video_parser;
Michael Niedermayer
committed
extern AVCodecParser h261_parser;
extern AVCodecParser h263_parser;
extern AVCodecParser h264_parser;
extern AVCodecParser mpegaudio_parser;
extern AVCodecParser ac3_parser;
Michael Niedermayer
committed
void *av_malloc(unsigned int size);
void *av_mallocz(unsigned int size);
void *av_realloc(void *ptr, unsigned int size);
char *av_strdup(const char *s);
void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
/* for static data only */
/* call av_free_static to release all staticaly allocated tables */
void av_free_static(void);
void *av_mallocz_static(unsigned int size);
/* add by bero : in adx.c */
int is_adx(const unsigned char *buf,size_t bufsize);
void img_copy(AVPicture *dst, const AVPicture *src,
int pix_fmt, int width, int height);
/* av_log API */
#include <stdarg.h>
#define AV_LOG_QUIET -1
#define AV_LOG_ERROR 0
#define AV_LOG_INFO 1
#define AV_LOG_DEBUG 2
Michael Niedermayer
committed
#ifdef __GNUC__
extern void av_log(void*, int level, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4)));
Michael Niedermayer
committed
#else
extern void av_log(void*, int level, const char *fmt, ...);
#endif
extern void av_vlog(void*, int level, const char *fmt, va_list);
extern int av_log_get_level(void);
extern void av_log_set_level(int);
extern void av_log_set_callback(void (*)(void*, int, const char*, va_list));
/* endian macros */
Michael Niedermayer
committed
#if !defined(BE_16) || !defined(BE_32) || !defined(LE_16) || !defined(LE_32)
#define BE_16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1])
#define BE_32(x) ((((uint8_t*)(x))[0] << 24) | \
(((uint8_t*)(x))[1] << 16) | \
(((uint8_t*)(x))[2] << 8) | \
((uint8_t*)(x))[3])
#define LE_16(x) ((((uint8_t*)(x))[1] << 8) | ((uint8_t*)(x))[0])
#define LE_32(x) ((((uint8_t*)(x))[3] << 24) | \
(((uint8_t*)(x))[2] << 16) | \
(((uint8_t*)(x))[1] << 8) | \
((uint8_t*)(x))[0])
Michael Niedermayer
committed
#endif
#ifdef __cplusplus
}
#endif