📄 avcodec.h
字号:
#define FF_BUFFER_TYPE_INTERNAL 1
#define FF_BUFFER_TYPE_USER 2 ///< Direct rendering buffers (image is (de)allocated by user)
#define FF_BUFFER_TYPE_SHARED 4 ///< buffer from somewhere else, don't dealloc image (data/base), all other tables are not shared
#define FF_BUFFER_TYPE_COPY 8 ///< just a (modified) copy of some other buffer, don't dealloc anything
#define FF_I_TYPE 1 // Intra
#define FF_P_TYPE 2 // Predicted
#define FF_B_TYPE 3 // Bi-dir predicted
#define FF_S_TYPE 4 // S(GMC)-VOP MPEG4
#define FF_SI_TYPE 5
#define FF_SP_TYPE 6
#define FF_BUFFER_HINTS_VALID 0x01 // Buffer hints value is meaningful (if 0 ignore)
#define FF_BUFFER_HINTS_READABLE 0x02 // Codec will read from buffer
#define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content
#define FF_BUFFER_HINTS_REUSABLE 0x08 // Codec will reuse the buffer (update)
/**
* Audio Video Frame.
*/
typedef struct AVFrame {
FF_COMMON_FRAME
} AVFrame;
#define DEFAULT_FRAME_RATE_BASE 1001000
/**
* main external api structure.
*/
typedef struct AVCodecContext {
/**
* Info on struct for av_log
* - set by avcodec_alloc_context
*/
AVClass *av_class;
/**
* CODEC_FLAG_*.
* - encoding: set by user.
* - decoding: set by user.
*/
int flags;
/**
* some codecs needs additionnal format info. It is stored here
* - encoding: set by user.
* - decoding: set by lavc. (FIXME is this ok?)
*/
int sub_id;
/**
* some codecs need / can use extra-data like huffman tables.
* mjpeg: huffman tables
* rv10: additional flags
* mpeg4: global headers (they can be in the bitstream or here)
* the allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger
* then extradata_size to avoid prolems if its read with the bitstream reader
* the bytewise contents of extradata must not depend on the architecture or cpu endianness
* - encoding: set/allocated/freed by lavc.
* - decoding: set/allocated/freed by user.
*/
uint8_t *extradata;
int extradata_size;
/* video only */
/**
* picture width / height.
* - encoding: MUST be set by user.
* - decoding: set by lavc.
* Note, for compatibility its possible to set this instead of
* coded_width/height before decoding
*/
int width, height;
int frame_number; ///< audio or video frame number
struct AVCodec *codec;
void *priv_data;
/**
* private data of the user, can be used to carry app specific stuff.
* - encoding: set by user
* - decoding: set by user
*/
void *opaque;
char codec_name[32];
enum CodecType codec_type; /* see CODEC_TYPE_xxx */
enum CodecID codec_id; /* see CODEC_ID_xxx */
/**
* fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
* this is used to workaround some encoder bugs
* - encoding: set by user, if not then the default based on codec_id will be used
* - decoding: set by user, will be converted to upper case by lavc during init
*/
unsigned int codec_tag;
/**
* error resilience higher values will detect more errors but may missdetect
* some more or less valid parts as errors.
* - encoding: unused
* - decoding: set by user
*/
int error_resilience;
#define FF_ER_CAREFUL 1
#define FF_ER_COMPLIANT 2
#define FF_ER_AGGRESSIVE 3
#define FF_ER_VERY_AGGRESSIVE 4
/**
* called at the beginning of each frame to get a buffer for it.
* if pic.reference is set then the frame will be read later by lavc
* avcodec_align_dimensions() should be used to find the required width and
* height, as they normally need to be rounded up to the next multiple of 16
* - encoding: unused
* - decoding: set by lavc, user can override
*/
int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
/**
* called to release buffers which where allocated with get_buffer.
* a released buffer can be reused in get_buffer()
* pic.data[*] must be set to NULL
* - encoding: unused
* - decoding: set by lavc, user can override
*/
void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
/**
* if 1 the stream has a 1 frame delay during decoding.
* - encoding: set by lavc
* - decoding: set by lavc
*/
int has_b_frames;
/**
* fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
* this is used to workaround some encoder bugs
* - encoding: unused
* - decoding: set by user, will be converted to upper case by lavc during init
*/
unsigned int stream_codec_tag;
/**
* CODEC_FLAG2_*.
* - encoding: set by user.
* - decoding: set by user.
*/
int flags2;
/**
* number of macroblock rows at the top which are skipped.
* - encoding: unused
* - decoding: set by user
*/
int skip_top;
/**
* number of macroblock rows at the bottom which are skipped.
* - encoding: unused
* - decoding: set by user
*/
int skip_bottom;
/**
* profile
* - encoding: set by user
* - decoding: set by lavc
*/
int profile;
#define FF_PROFILE_UNKNOWN -99
/**
* level
* - encoding: set by user
* - decoding: set by lavc
*/
int level;
#define FF_LEVEL_UNKNOWN -99
/**
* low resolution decoding. 1-> 1/2 size, 2->1/4 size
* - encoding: unused
* - decoding: set by user
*/
int lowres;
/**
* bitsream width / height. may be different from width/height if lowres
* or other things are used
* - encoding: unused
* - decoding: set by user before init if known, codec should override / dynamically change if needed
*/
int coded_width, coded_height;
} AVCodecContext;
/**
* AVCodec.
*/
typedef struct AVCodec {
const char *name;
enum CodecType type;
enum CodecID id;
int priv_data_size;
int (*init)(AVCodecContext *);
int (*close)(AVCodecContext *);
int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
uint8_t *buf, int buf_size);
int capabilities;
struct AVCodec *next;
void (*flush)(AVCodecContext *);
} AVCodec;
/**
* four components are given, that's all.
* the last component is alpha
*/
typedef struct AVPicture {
uint8_t *data[4];
int linesize[4]; ///< number of bytes per line
} AVPicture;
extern AVCodec h264_decoder;
void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
#define FF_LOSS_RESOLUTION 0x0001 /* loss due to resolution change */
#define FF_LOSS_DEPTH 0x0002 /* loss due to color depth change */
#define FF_LOSS_COLORSPACE 0x0004 /* loss due to color space conversion */
#define FF_LOSS_ALPHA 0x0008 /* loss of alpha bits */
#define FF_LOSS_COLORQUANT 0x0010 /* loss due to color quantization */
#define FF_LOSS_CHROMA 0x0020 /* loss of chroma (e.g. rgb to gray conversion) */
/* external high level API */
extern AVCodec *first_avcodec;
void avcodec_init(void);
void register_avcodec(AVCodec *format);
void avcodec_get_context_defaults(AVCodecContext *s);
AVCodecContext *avcodec_alloc_context(void);
void avcodec_get_frame_defaults(AVFrame *pic);
AVFrame *avcodec_alloc_frame(void);
inline 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);
/**
* opens / inits the AVCodecContext.
* not thread save!
*/
int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
/**
* Decode an audio frame.
*
* @param avctx the codec context.
* @param samples output buffer, 16 byte aligned
* @param frame_size_ptr the output buffer size in bytes, zero if no frame could be compressed
* @param buf input buffer, 16 byte aligned
* @param buf_size the input buffer size
* @return 0 if successful, -1 if not.
*/
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_flush_buffers(AVCodecContext *avctx);
/**
* returns a single letter to describe the picture type
*/
char av_get_pict_type_char(int pict_type);
typedef struct AVBitStreamFilterContext {
void *priv_data;
struct AVBitStreamFilter *filter;
struct AVBitStreamFilterContext *next;
} AVBitStreamFilterContext;
typedef struct AVBitStreamFilter {
const char *name;
int priv_data_size;
int (*filter)(AVBitStreamFilterContext *bsfc,
AVCodecContext *avctx, const char *args,
uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size, int keyframe);
struct AVBitStreamFilter *next;
} AVBitStreamFilter;
extern AVBitStreamFilter *av_first_bitstream_filter;
#ifdef USE_BITSTREAM_FILTER
void av_register_bitstream_filter(AVBitStreamFilter *bsf);
AVBitStreamFilterContext *av_bitstream_filter_init(const char *name);
int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc,
AVCodecContext *avctx, const char *args,
uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size, int keyframe);
void av_bitstream_filter_close(AVBitStreamFilterContext *bsf);
extern AVBitStreamFilter dump_extradata_bsf;
extern AVBitStreamFilter remove_extradata_bsf;
extern AVBitStreamFilter noise_bsf;
#endif
/* memory */
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);
void *av_realloc_static(void *ptr, unsigned int size);
/* endian macros */
#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])
#endif
#ifdef __cplusplus
}
#endif
#endif /* AVCODEC_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -