|
|
|
|
#ifndef AVCODEC_H
|
|
|
|
|
#define AVCODEC_H
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>õĺꡢ<EFBFBD><EFBFBD><EFBFBD>ݽṹ<EFBFBD>ͺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Щ<EFBFBD>ꡢ<EFBFBD><EFBFBD><EFBFBD>ݽṹ<EFBFBD>ͺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч
|
|
|
|
|
*/
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C"
|
|
|
|
|
{
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "../libavutil/avutil.h"
|
|
|
|
|
|
|
|
|
|
#define FFMPEG_VERSION_INT 0x000409
|
|
|
|
|
#define FFMPEG_VERSION "CVS"
|
|
|
|
|
|
|
|
|
|
#define AV_STRINGIFY(s) AV_TOSTRING(s)
|
|
|
|
|
#define AV_TOSTRING(s) #s
|
|
|
|
|
|
|
|
|
|
#define LIBAVCODEC_VERSION_INT ((51<<16)+(8<<8)+0)
|
|
|
|
|
#define LIBAVCODEC_VERSION 51.8.0
|
|
|
|
|
#define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT
|
|
|
|
|
|
|
|
|
|
#define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION)
|
|
|
|
|
|
|
|
|
|
#define AV_NOPTS_VALUE int64_t_C(0x8000000000000000)
|
|
|
|
|
#define AV_TIME_BASE 1000000
|
|
|
|
|
|
|
|
|
|
/* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ID <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ֧<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><EFBFBD>뷽ʽ<EFBFBD><EFBFBD>truespeech<EFBFBD><EFBFBD>msrle<EFBFBD><EFBFBD>*/
|
|
|
|
|
enum CodecID
|
|
|
|
|
{
|
|
|
|
|
CODEC_ID_TRUESPEECH,
|
|
|
|
|
CODEC_ID_MSRLE,
|
|
|
|
|
CODEC_ID_NONE
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
enum CodecType
|
|
|
|
|
{
|
|
|
|
|
CODEC_TYPE_UNKNOWN = - 1,
|
|
|
|
|
// <EFBFBD><EFBFBD>Ƶ
|
|
|
|
|
CODEC_TYPE_VIDEO,
|
|
|
|
|
// <EFBFBD><EFBFBD>Ƶ
|
|
|
|
|
CODEC_TYPE_AUDIO,
|
|
|
|
|
CODEC_TYPE_DATA
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
|
|
|
|
|
|
|
|
|
|
#define FF_INPUT_BUFFER_PADDING_SIZE 8
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
AVPicture <EFBFBD><EFBFBD> AVFrame <EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ʹ<EFBFBD>û<EFBFBD><EFBFBD>棬ͨ<EFBFBD><EFBFBD>֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> YUV <EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD> YUV
|
|
|
|
|
Ҳ<EFBFBD><EFBFBD> RGB <EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 4 <EFBFBD><EFBFBD> data ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* ͼ<EFBFBD><EFBFBD> */
|
|
|
|
|
typedef struct AVPicture
|
|
|
|
|
{
|
|
|
|
|
uint8_t *data[4];
|
|
|
|
|
int linesize[4];
|
|
|
|
|
} AVPicture;
|
|
|
|
|
|
|
|
|
|
/* ֡ */
|
|
|
|
|
typedef struct AVFrame
|
|
|
|
|
{
|
|
|
|
|
uint8_t *data[4];
|
|
|
|
|
int linesize[4];
|
|
|
|
|
uint8_t *base[4];
|
|
|
|
|
} AVFrame;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ǰ Codec ʹ<EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Codec <EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
ֵ)<EFBFBD><EFBFBD>codec <EFBFBD><EFBFBD> priv_data <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ṹ<EFBFBD><EFBFBD><EFBFBD>ֶΣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽṹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>еĵ<EFBFBD>ǰ Codec ʹ<EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
typedef struct AVCodecContext
|
|
|
|
|
{
|
|
|
|
|
int bit_rate;
|
|
|
|
|
int frame_number; // audio or video frame number
|
|
|
|
|
|
|
|
|
|
unsigned char *extradata; // Codec<EFBFBD><EFBFBD>˽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><EFBFBD><EFBFBD>Audio<EFBFBD><EFBFBD>WAVEFORMATEX<EFBFBD>ṹ<EFBFBD><EFBFBD>չ<EFBFBD>ֽڡ<EFBFBD>
|
|
|
|
|
int extradata_size; // <EFBFBD><EFBFBD>Video<EFBFBD><EFBFBD>BITMAPINFOHEADER<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>չ<EFBFBD>ֽ<EFBFBD>
|
|
|
|
|
|
|
|
|
|
int width, height;
|
|
|
|
|
|
|
|
|
|
enum PixelFormat pix_fmt;
|
|
|
|
|
|
|
|
|
|
int sample_rate; // samples per sec // audio only
|
|
|
|
|
int channels;
|
|
|
|
|
int bits_per_sample;
|
|
|
|
|
int block_align;
|
|
|
|
|
|
|
|
|
|
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
struct AVCodec *codec;
|
|
|
|
|
void *priv_data;
|
|
|
|
|
|
|
|
|
|
enum CodecType codec_type; // see CODEC_TYPE_xxx
|
|
|
|
|
enum CodecID codec_id; // see CODEC_ID_xxx
|
|
|
|
|
|
|
|
|
|
int(*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
|
|
|
|
|
void(*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
|
|
|
|
|
int(*reget_buffer)(struct AVCodecContext *c, AVFrame *pic);
|
|
|
|
|
|
|
|
|
|
int internal_buffer_count;
|
|
|
|
|
void *internal_buffer;
|
|
|
|
|
|
|
|
|
|
// <EFBFBD><EFBFBD>ɫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
struct AVPaletteControl *palctrl;
|
|
|
|
|
}AVCodecContext;
|
|
|
|
|
|
|
|
|
|
/* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϳ<EFBFBD><EFBFBD>Ա<EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|
|
|
|
/* <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڹ<EFBFBD><EFBFBD>ܺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> һ<EFBFBD><EFBFBD>ý<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD>Ӧһ<EFBFBD><EFBFBD> AVCodec
|
|
|
|
|
<EFBFBD>ṹ<EFBFBD><EFBFBD><EFBFBD>ڳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD>*/
|
|
|
|
|
typedef struct AVCodec
|
|
|
|
|
{
|
|
|
|
|
const char *name; // <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
enum CodecType type; // <EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><EFBFBD><EFBFBD> Video<EFBFBD><EFBFBD>Audio<EFBFBD><EFBFBD>Data <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
enum CodecID id; // id
|
|
|
|
|
int priv_data_size; // <EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵĴ<EFBFBD>С
|
|
|
|
|
int(*init)(AVCodecContext*); // <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|
|
|
|
int(*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data); // <EFBFBD><EFBFBD><EFBFBD>뺯<EFBFBD><EFBFBD>
|
|
|
|
|
int(*close)(AVCodecContext*); // <EFBFBD>ر<EFBFBD>
|
|
|
|
|
int(*decode)(AVCodecContext *, void *outdata, int *outdata_size, uint8_t *buf, int buf_size); // <EFBFBD><EFBFBD><EFBFBD>뺯<EFBFBD><EFBFBD>
|
|
|
|
|
int capabilities; // <EFBFBD><EFBFBD>ʾCodec <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
struct AVCodec *next; // <EFBFBD><EFBFBD><EFBFBD>ڰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Codec <EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}AVCodec;
|
|
|
|
|
|
|
|
|
|
#define AVPALETTE_SIZE 1024
|
|
|
|
|
#define AVPALETTE_COUNT 256
|
|
|
|
|
|
|
|
|
|
/* <EFBFBD><EFBFBD>ɫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>ʹ<EFBFBD>С<EFBFBD>궨<EFBFBD>壬ÿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>(R,G,B,<EFBFBD><EFBFBD>)<EFBFBD><EFBFBD><EFBFBD>кܶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶͼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƚ<EFBFBD><EFBFBD>٣<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>ӱ<EFBFBD>ʾÿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD>ɫֵ<EFBFBD><EFBFBD><EFBFBD>Ϳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>ɫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵʵ<EFBFBD>ּĴ<EFBFBD>Լ<EFBFBD><EFBFBD> 4:1 ѹ<EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD> */
|
|
|
|
|
/* <EFBFBD><EFBFBD>ɫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD>ɫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽṹ<EFBFBD><EFBFBD><EFBFBD>壬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD> */
|
|
|
|
|
typedef struct AVPaletteControl
|
|
|
|
|
{
|
|
|
|
|
// demuxer sets this to 1 to indicate the palette has changed; decoder resets to 0
|
|
|
|
|
int palette_changed;
|
|
|
|
|
|
|
|
|
|
/* 4-byte ARGB palette entries, stored in native byte order; note that
|
|
|
|
|
* the individual palette components should be on a 8-bit scale; if
|
|
|
|
|
* the palette data comes from a IBM VGA native format, the component
|
|
|
|
|
* data is probably 6 bits in size and needs to be scaled */
|
|
|
|
|
unsigned int palette[AVPALETTE_COUNT];
|
|
|
|
|
|
|
|
|
|
} AVPaletteControl;
|
|
|
|
|
|
|
|
|
|
int avpicture_alloc(AVPicture *picture, int pix_fmt, int width, int height);
|
|
|
|
|
|
|
|
|
|
void avpicture_free(AVPicture *picture);
|
|
|
|
|
|
|
|
|
|
int avpicture_fill(AVPicture *picture, uint8_t *ptr, int pix_fmt, int width, int height);
|
|
|
|
|
int avpicture_get_size(int pix_fmt, int width, int height);
|
|
|
|
|
void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift);
|
|
|
|
|
|
|
|
|
|
int img_convert(AVPicture *dst, int dst_pix_fmt, const AVPicture *src, int pix_fmt,
|
|
|
|
|
int width, int height);
|
|
|
|
|
|
|
|
|
|
void avcodec_init(void);
|
|
|
|
|
|
|
|
|
|
void register_avcodec(AVCodec *format);
|
|
|
|
|
AVCodec *avcodec_find_decoder(enum CodecID id);
|
|
|
|
|
|
|
|
|
|
AVCodecContext *avcodec_alloc_context(void);
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h);
|
|
|
|
|
|
|
|
|
|
int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
|
|
|
|
|
|
|
|
|
|
int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples, int *frame_size_ptr,
|
|
|
|
|
uint8_t *buf, int buf_size);
|
|
|
|
|
int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr,
|
|
|
|
|
uint8_t *buf, int buf_size);
|
|
|
|
|
|
|
|
|
|
int avcodec_close(AVCodecContext *avctx);
|
|
|
|
|
|
|
|
|
|
void avcodec_register_all(void);
|
|
|
|
|
|
|
|
|
|
void avcodec_default_free_buffers(AVCodecContext *s);
|
|
|
|
|
|
|
|
|
|
void *av_malloc(unsigned int size);
|
|
|
|
|
void *av_mallocz(unsigned int size);
|
|
|
|
|
void *av_realloc(void *ptr, unsigned int size);
|
|
|
|
|
void av_free(void *ptr);
|
|
|
|
|
void av_freep(void *ptr);
|
|
|
|
|
void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
|
|
|
|
|
|
|
|
|
|
void img_copy(AVPicture *dst, const AVPicture *src, int pix_fmt, int width, int height);
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif
|