226
263
#define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< place global headers in extradata instead of every keyframe
227
264
#define CODEC_FLAG_BITEXACT 0x00800000 ///< use only bitexact stuff (except (i)dct)
228
265
/* Fx : Flag for h263+ extra options */
229
#define CODEC_FLAG_H263P_AIC 0x01000000 ///< Advanced intra coding
266
#define CODEC_FLAG_H263P_AIC 0x01000000 ///< H263 Advanced intra coding / MPEG4 AC prediction (remove this)
267
#define CODEC_FLAG_AC_PRED 0x01000000 ///< H263 Advanced intra coding / MPEG4 AC prediction
230
268
#define CODEC_FLAG_H263P_UMV 0x02000000 ///< Unlimited motion vector
231
/* For advanced prediction mode, we reuse the 4MV flag */
269
#define CODEC_FLAG_CBP_RD 0x04000000 ///< use rate distortion optimization for cbp
270
#define CODEC_FLAG_QP_RD 0x08000000 ///< use rate distortion optimization for qp selectioon
271
#define CODEC_FLAG_H263P_AIV 0x00000008 ///< H263 Alternative inter vlc
272
#define CODEC_FLAG_OBMC 0x00000001 ///< OBMC
273
#define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter
274
#define CODEC_FLAG_H263P_SLICE_STRUCT 0x10000000
275
#define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation
276
#define CODEC_FLAG_SVCD_SCAN_OFFSET 0x40000000 ///< will reserve space for SVCD scan offset user data
277
#define CODEC_FLAG_CLOSED_GOP 0x80000000
232
278
/* Unsupported options :
233
279
* Syntax Arithmetic coding (SAC)
234
* Deblocking filter internal loop
236
280
* Reference Picture Selection
237
* Independant Segment Decoding
238
* Alternative Inter * VLC
239
* Modified Quantization */
281
* Independant Segment Decoding */
241
283
/* codec capabilities */
251
293
#define CODEC_CAP_PARSE_ONLY 0x0004
252
294
#define CODEC_CAP_TRUNCATED 0x0008
295
/* codec can export data for HW decoding (XvMC) */
296
#define CODEC_CAP_HWACCEL 0x0010
297
/** codec has a non zero delay and needs to be feeded with NULL at the end to get the delayed data */
298
#define CODEC_CAP_DELAY 0x0020
300
//the following defines might change, so dont expect compatibility if u use them
301
#define MB_TYPE_INTRA4x4 0x0001
302
#define MB_TYPE_INTRA16x16 0x0002 //FIXME h264 specific
303
#define MB_TYPE_INTRA_PCM 0x0004 //FIXME h264 specific
304
#define MB_TYPE_16x16 0x0008
305
#define MB_TYPE_16x8 0x0010
306
#define MB_TYPE_8x16 0x0020
307
#define MB_TYPE_8x8 0x0040
308
#define MB_TYPE_INTERLACED 0x0080
309
#define MB_TYPE_DIRECT2 0x0100 //FIXME
310
#define MB_TYPE_ACPRED 0x0200
311
#define MB_TYPE_GMC 0x0400
312
#define MB_TYPE_SKIP 0x0800
313
#define MB_TYPE_P0L0 0x1000
314
#define MB_TYPE_P1L0 0x2000
315
#define MB_TYPE_P0L1 0x4000
316
#define MB_TYPE_P1L1 0x8000
317
#define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0)
318
#define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1)
319
#define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1)
320
#define MB_TYPE_QUANT 0x00010000
321
#define MB_TYPE_CBP 0x00020000
322
//Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...)
326
* this specifies the area which should be displayed. Note there may be multiple such areas for one frame
328
typedef struct AVPanScan{
331
* - encoding: set by user.
332
* - decoding: set by lavc
337
* width and height in 1/16 pel
338
* - encoding: set by user.
339
* - decoding: set by lavc
345
* position of the top left corner in 1/16 pel for up to 3 fields/frames.
346
* - encoding: set by user.
347
* - decoding: set by lavc
349
int16_t position[3][2];
254
352
#define FF_COMMON_FRAME \
381
501
int qscale_type;\
504
* The content of the picture is interlaced.\
505
* - encoding: set by user\
506
* - decoding: set by lavc (default 0)\
508
int interlaced_frame;\
511
* if the content is interlaced, is top field displayed first.\
512
* - encoding: set by user\
513
* - decoding: set by lavc\
515
int top_field_first;\
519
* - encoding: set by user\
520
* - decoding: set by lavc\
522
AVPanScan *pan_scan;\
525
* tell user application that palette has changed from previous frame.\
526
* - encoding: ??? (no palette-enabled encoder yet)\
527
* - decoding: set by lavc (default 0)\
529
int palette_has_changed;\
532
* Codec suggestion on buffer type if != 0\
533
* - encoding: unused\
534
* - decoding: set by lavc (before get_buffer() call))\
540
* - encoding: unused\
541
* - decoding: set by lavc\
546
* Motion referece frame index\
547
* - encoding: set by user\
548
* - decoding: set by lavc\
550
int8_t *ref_index[2];
383
552
#define FF_QSCALE_TYPE_MPEG1 0
384
553
#define FF_QSCALE_TYPE_MPEG2 1
386
555
#define FF_BUFFER_TYPE_INTERNAL 1
387
556
#define FF_BUFFER_TYPE_USER 2 ///< Direct rendering buffers (image is (de)allocated by user)
388
#define FF_BUFFER_TYPE_SHARED 4 ///< buffer from somewher else, dont dealloc image (data/base)
557
#define FF_BUFFER_TYPE_SHARED 4 ///< buffer from somewher else, dont dealloc image (data/base), all other tables are not shared
389
558
#define FF_BUFFER_TYPE_COPY 8 ///< just a (modified) copy of some other buffer, dont dealloc anything
989
1178
#define FF_DEBUG_MB_TYPE 8
990
1179
#define FF_DEBUG_QP 16
991
1180
#define FF_DEBUG_MV 32
992
#define FF_DEBUG_VIS_MV 0x00000040
1181
#define FF_DEBUG_DCT_COEFF 0x00000040
993
1182
#define FF_DEBUG_SKIP 0x00000080
994
1183
#define FF_DEBUG_STARTCODE 0x00000100
995
1184
#define FF_DEBUG_PTS 0x00000200
996
1185
#define FF_DEBUG_ER 0x00000400
997
1186
#define FF_DEBUG_MMCO 0x00000800
998
1187
#define FF_DEBUG_BUGS 0x00001000
1188
#define FF_DEBUG_VIS_QP 0x00002000
1189
#define FF_DEBUG_VIS_MB_TYPE 0x00004000
1193
* - encoding: set by user.
1194
* - decoding: set by user.
1197
#define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames
1198
#define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames
1199
#define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames
1002
1203
* - encoding: set by lavc if flags&CODEC_FLAG_PSNR
1003
1204
* - decoding: unused
1250
1465
* - decoding: unused
1252
1467
int scenechange_threshold;
1470
* minimum lagrange multipler
1471
* - encoding: set by user.
1472
* - decoding: unused
1477
* maximum lagrange multipler
1478
* - encoding: set by user.
1479
* - decoding: unused
1484
* Palette control structure
1485
* - encoding: ??? (no palette-enabled encoder yet)
1486
* - decoding: set by user.
1488
struct AVPaletteControl *palctrl;
1491
* noise reduction strength
1492
* - encoding: set by user.
1493
* - decoding: unused
1495
int noise_reduction;
1498
* called at the beginning of a frame to get cr buffer for it.
1499
* buffer type (size, hints) must be the same. lavc won't check it.
1500
* lavc will pass previous buffer in pic, function should return
1501
* same buffer or new buffer with old frame "painted" into it.
1502
* if pic.data[0] == NULL must behave like get_buffer().
1503
* - encoding: unused
1504
* - decoding: set by lavc, user can override
1506
int (*reget_buffer)(struct AVCodecContext *c, AVFrame *pic);
1509
* number of bits which should be loaded into the rc buffer before decoding starts
1510
* - encoding: set by user.
1511
* - decoding: unused
1513
int rc_initial_buffer_occupancy;
1517
* - encoding: set by user.
1518
* - decoding: unused
1520
int inter_threshold;
1524
* - encoding: set by user.
1525
* - decoding: set by user.
1530
* simulates errors in the bitstream to test error concealment.
1531
* - encoding: set by user.
1532
* - decoding: unused.
1537
* MP3 antialias algorithm, see FF_AA_* below.
1538
* - encoding: unused
1539
* - decoding: set by user
1542
#define FF_AA_AUTO 0
1543
#define FF_AA_FASTINT 1 //not implemented yet
1545
#define FF_AA_FLOAT 3
1547
* Quantizer noise shaping.
1548
* - encoding: set by user
1549
* - decoding: unused
1551
int quantizer_noise_shaping;
1555
* is used to decide how many independant tasks should be passed to execute()
1556
* - encoding: set by user
1557
* - decoding: set by user
1562
* the codec may call this to execute several independant things. it will return only after
1563
* finishing all tasks, the user may replace this with some multithreaded implementation, the
1564
* default implementation will execute the parts serially
1565
* @param count the number of things to execute
1566
* - encoding: set by lavc, user can override
1567
* - decoding: set by lavc, user can override
1569
int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void **arg2, int *ret, int count);
1573
* can be used by execute() to store some per AVCodecContext stuff.
1574
* - encoding: set by execute()
1575
* - decoding: set by execute()
1577
void *thread_opaque;
1580
* Motion estimation threshold. under which no motion estimation is
1581
* performed, but instead the user specified motion vectors are used
1583
* - encoding: set by user
1584
* - decoding: unused
1589
* Macroblock threshold. under which the user specified macroblock types will be used
1590
* - encoding: set by user
1591
* - decoding: unused
1596
* precision of the intra dc coefficient - 8.
1597
* - encoding: set by user
1598
* - decoding: unused
1600
int intra_dc_precision;
1603
* noise vs. sse weight for the nsse comparsion function.
1604
* - encoding: set by user
1605
* - decoding: unused
1610
* number of macroblock rows at the top which are skiped.
1611
* - encoding: unused
1612
* - decoding: set by user
1617
* number of macroblock rows at the bottom which are skiped.
1618
* - encoding: unused
1619
* - decoding: set by user
1253
1622
} AVCodecContext;
1330
1701
* This structure defines a method for communicating palette changes
1331
1702
* between and demuxer and a decoder.
1704
#define AVPALETTE_SIZE 1024
1705
#define AVPALETTE_COUNT 256
1333
1706
typedef struct AVPaletteControl {
1335
1708
/* demuxer sets this to 1 to indicate the palette has changed;
1336
1709
* decoder resets to 0 */
1337
1710
int palette_changed;
1339
/* 256 3-byte RGB palette entries; the components should be
1340
* formatted in the buffer as "RGBRGB..." and should be scaled to
1341
* 8 bits if they originally represented 6-bit VGA palette
1343
unsigned char palette[256 * 3];
1712
/* 4-byte ARGB palette entries, stored in native byte order; note that
1713
* the individual palette components should be on a 8-bit scale; if
1714
* the palette data comes from a IBM VGA native format, the component
1715
* data is probably 6 bits in size and needs to be scaled */
1716
unsigned int palette[AVPALETTE_COUNT];
1345
1718
} AVPaletteControl;
1379
1758
extern AVCodec wmv2_decoder;
1380
1759
extern AVCodec mpeg1video_decoder;
1381
1760
extern AVCodec mpeg2video_decoder;
1761
extern AVCodec mpegvideo_decoder;
1382
1762
extern AVCodec mpeg_xvmc_decoder;
1383
1763
extern AVCodec h263i_decoder;
1384
1764
extern AVCodec flv_decoder;
1385
1765
extern AVCodec rv10_decoder;
1766
extern AVCodec rv20_decoder;
1386
1767
extern AVCodec svq1_decoder;
1387
1768
extern AVCodec svq3_decoder;
1388
1769
extern AVCodec dvvideo_decoder;
1389
extern AVCodec dvaudio_decoder;
1390
1770
extern AVCodec wmav1_decoder;
1391
1771
extern AVCodec wmav2_decoder;
1392
1772
extern AVCodec mjpeg_decoder;
1393
1773
extern AVCodec mjpegb_decoder;
1774
extern AVCodec sp5x_decoder;
1394
1775
extern AVCodec mp2_decoder;
1395
1776
extern AVCodec mp3_decoder;
1396
1777
extern AVCodec mace3_decoder;
1415
1799
extern AVCodec roq_decoder;
1416
1800
extern AVCodec interplay_video_decoder;
1417
1801
extern AVCodec xan_wc3_decoder;
1802
extern AVCodec rpza_decoder;
1803
extern AVCodec cinepak_decoder;
1804
extern AVCodec msrle_decoder;
1805
extern AVCodec msvideo1_decoder;
1806
extern AVCodec vqa_decoder;
1807
extern AVCodec idcin_decoder;
1808
extern AVCodec eightbps_decoder;
1809
extern AVCodec smc_decoder;
1810
extern AVCodec flic_decoder;
1811
extern AVCodec vmdvideo_decoder;
1812
extern AVCodec vmdaudio_decoder;
1813
extern AVCodec truemotion1_decoder;
1814
extern AVCodec mszh_decoder;
1815
extern AVCodec zlib_decoder;
1418
1816
extern AVCodec ra_144_decoder;
1419
1817
extern AVCodec ra_288_decoder;
1420
1818
extern AVCodec roq_dpcm_decoder;
1421
1819
extern AVCodec interplay_dpcm_decoder;
1422
1820
extern AVCodec xan_dpcm_decoder;
1821
extern AVCodec qtrle_decoder;
1822
extern AVCodec flac_decoder;
1424
1824
/* pcm codecs */
1425
1825
#define PCM_CODEC(id, name) \
1441
1841
PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
1442
1842
PCM_CODEC(CODEC_ID_ADPCM_IMA_DK3, adpcm_ima_dk3);
1443
1843
PCM_CODEC(CODEC_ID_ADPCM_IMA_DK4, adpcm_ima_dk4);
1844
PCM_CODEC(CODEC_ID_ADPCM_IMA_WS, adpcm_ima_ws);
1845
PCM_CODEC(CODEC_ID_ADPCM_SMJPEG, adpcm_ima_smjpeg);
1444
1846
PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
1445
1847
PCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm);
1848
PCM_CODEC(CODEC_ID_ADPCM_XA, adpcm_xa);
1849
PCM_CODEC(CODEC_ID_ADPCM_ADX, adpcm_adx);
1850
PCM_CODEC(CODEC_ID_ADPCM_EA, adpcm_ea);
1851
PCM_CODEC(CODEC_ID_ADPCM_G726, adpcm_g726);
1447
1853
#undef PCM_CODEC
1476
1888
ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
1477
1889
int iwidth, int iheight,
1478
1890
int topBand, int bottomBand,
1479
int leftBand, int rightBand);
1891
int leftBand, int rightBand,
1892
int padtop, int padbottom,
1893
int padleft, int padright);
1481
1896
void img_resample(ImgReSampleContext *s,
1482
AVPicture *output, AVPicture *input);
1897
AVPicture *output, const AVPicture *input);
1484
1899
void img_resample_close(ImgReSampleContext *s);
1902
* Allocate memory for a picture. Call avpicture_free to free it.
1904
* @param picture the picture to be filled in.
1905
* @param pix_fmt the format of the picture.
1906
* @param width the width of the picture.
1907
* @param height the height of the picture.
1908
* @return 0 if successful, -1 if not.
1910
int avpicture_alloc(AVPicture *picture, int pix_fmt, int width, int height);
1912
/* Free a picture previously allocated by avpicture_alloc. */
1913
void avpicture_free(AVPicture *picture);
1486
1915
int avpicture_fill(AVPicture *picture, uint8_t *ptr,
1487
1916
int pix_fmt, int width, int height);
1488
int avpicture_layout(AVPicture* src, int pix_fmt, int width, int height,
1917
int avpicture_layout(const AVPicture* src, int pix_fmt, int width, int height,
1489
1918
unsigned char *dest, int dest_size);
1490
1919
int avpicture_get_size(int pix_fmt, int width, int height);
1491
1920
void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift);
1507
1936
#define FF_ALPHA_TRANSP 0x0001 /* image has some totally transparent pixels */
1508
1937
#define FF_ALPHA_SEMI_TRANSP 0x0002 /* image has some transparent pixels */
1509
int img_get_alpha_info(AVPicture *src, int pix_fmt, int width, int height);
1938
int img_get_alpha_info(const AVPicture *src,
1939
int pix_fmt, int width, int height);
1511
1941
/* convert among pixel formats */
1512
1942
int img_convert(AVPicture *dst, int dst_pix_fmt,
1513
AVPicture *src, int pix_fmt,
1943
const AVPicture *src, int pix_fmt,
1514
1944
int width, int height);
1516
1946
/* deinterlace a picture */
1517
int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
1947
int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
1518
1948
int pix_fmt, int width, int height);
1520
1950
/* external high level API */
1537
1967
void avcodec_get_context_defaults(AVCodecContext *s);
1538
1968
AVCodecContext *avcodec_alloc_context(void);
1969
void avcodec_get_frame_defaults(AVFrame *pic);
1539
1970
AVFrame *avcodec_alloc_frame(void);
1541
1972
int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
1542
1973
void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
1543
void avcodec_default_free_buffers(AVCodecContext *s);
1974
int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic);
1975
void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);
1976
enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt);
1978
int avcodec_thread_init(AVCodecContext *s, int thread_count);
1979
void avcodec_thread_free(AVCodecContext *s);
1980
int avcodec_thread_execute(AVCodecContext *s, int (*func)(AVCodecContext *c2, void *arg2),void **arg, int *ret, int count);
1981
int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void **arg, int *ret, int count);
1982
//FIXME func typedef
1546
1985
* opens / inits the AVCodecContext.
1667
2106
int avcodec(void* handle, avc_cmd_t cmd, void* pin, void* pout);
2109
typedef struct AVCodecParserContext {
2111
struct AVCodecParser *parser;
2112
int64_t frame_offset; /* offset of the current frame */
2113
int64_t cur_offset; /* current offset
2114
(incremented by each av_parser_parse()) */
2115
int64_t last_frame_offset; /* offset of the last frame */
2117
int pict_type; /* XXX: put it back in AVCodecContext */
2118
int repeat_pict; /* XXX: put it back in AVCodecContext */
2119
int64_t pts; /* pts of the current frame */
2120
int64_t dts; /* dts of the current frame */
2125
int fetch_timestamp;
2127
#define AV_PARSER_PTS_NB 4
2128
int cur_frame_start_index;
2129
int64_t cur_frame_offset[AV_PARSER_PTS_NB];
2130
int64_t cur_frame_pts[AV_PARSER_PTS_NB];
2131
int64_t cur_frame_dts[AV_PARSER_PTS_NB];
2132
} AVCodecParserContext;
2134
typedef struct AVCodecParser {
2135
int codec_ids[3]; /* several codec IDs are permitted */
2137
int (*parser_init)(AVCodecParserContext *s);
2138
int (*parser_parse)(AVCodecParserContext *s,
2139
AVCodecContext *avctx,
2140
uint8_t **poutbuf, int *poutbuf_size,
2141
const uint8_t *buf, int buf_size);
2142
void (*parser_close)(AVCodecParserContext *s);
2143
struct AVCodecParser *next;
2146
extern AVCodecParser *av_first_parser;
2148
void av_register_codec_parser(AVCodecParser *parser);
2149
AVCodecParserContext *av_parser_init(int codec_id);
2150
int av_parser_parse(AVCodecParserContext *s,
2151
AVCodecContext *avctx,
2152
uint8_t **poutbuf, int *poutbuf_size,
2153
const uint8_t *buf, int buf_size,
2154
int64_t pts, int64_t dts);
2155
void av_parser_close(AVCodecParserContext *s);
2157
extern AVCodecParser mpegvideo_parser;
2158
extern AVCodecParser mpeg4video_parser;
2159
extern AVCodecParser h261_parser;
2160
extern AVCodecParser h263_parser;
2161
extern AVCodecParser h264_parser;
2162
extern AVCodecParser mpegaudio_parser;
2163
extern AVCodecParser ac3_parser;
1670
2166
void *av_malloc(unsigned int size);
1671
2167
void *av_mallocz(unsigned int size);
1672
2168
void *av_realloc(void *ptr, unsigned int size);
1673
2169
void av_free(void *ptr);
1674
2170
char *av_strdup(const char *s);
1675
void __av_freep(void **ptr);
1676
#define av_freep(p) __av_freep((void **)(p))
2171
void av_freep(void *ptr);
1677
2172
void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
1678
2173
/* for static data only */
1679
2174
/* call av_free_static to release all staticaly allocated tables */
1680
2175
void av_free_static(void);
1681
void *__av_mallocz_static(void** location, unsigned int size);
1682
#define av_mallocz_static(p, s) __av_mallocz_static((void **)(p), s)
2176
void *av_mallocz_static(unsigned int size);
2178
/* add by bero : in adx.c */
2179
int is_adx(const unsigned char *buf,size_t bufsize);
2181
void img_copy(AVPicture *dst, const AVPicture *src,
2182
int pix_fmt, int width, int height);
2188
#define AV_LOG_QUIET -1
2189
#define AV_LOG_ERROR 0
2190
#define AV_LOG_INFO 1
2191
#define AV_LOG_DEBUG 2
2194
extern void av_log(void*, int level, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4)));
2196
extern void av_log(void*, int level, const char *fmt, ...);
2199
extern void av_vlog(void*, int level, const char *fmt, va_list);
2200
extern int av_log_get_level(void);
2201
extern void av_log_set_level(int);
2202
extern void av_log_set_callback(void (*)(void*, int, const char*, va_list));
2205
#if !defined(BE_16) || !defined(BE_32) || !defined(LE_16) || !defined(LE_32)
2206
#define BE_16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1])
2207
#define BE_32(x) ((((uint8_t*)(x))[0] << 24) | \
2208
(((uint8_t*)(x))[1] << 16) | \
2209
(((uint8_t*)(x))[2] << 8) | \
2211
#define LE_16(x) ((((uint8_t*)(x))[1] << 8) | ((uint8_t*)(x))[0])
2212
#define LE_32(x) ((((uint8_t*)(x))[3] << 24) | \
2213
(((uint8_t*)(x))[2] << 16) | \
2214
(((uint8_t*)(x))[1] << 8) | \
1684
2218
#ifdef __cplusplus