You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2640 lines
76KB

  1. #ifndef AVCODEC_H
  2. #define AVCODEC_H
  3. /**
  4. * @file avcodec.h
  5. * external api header.
  6. */
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. #include "avutil.h"
  11. #include <sys/types.h> /* size_t */
  12. #define AV_STRINGIFY(s) AV_TOSTRING(s)
  13. #define AV_TOSTRING(s) #s
  14. #define LIBAVCODEC_VERSION_INT ((51<<16)+(10<<8)+0)
  15. #define LIBAVCODEC_VERSION 51.10.0
  16. #define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT
  17. #define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION)
  18. #define AV_NOPTS_VALUE int64_t_C(0x8000000000000000)
  19. #define AV_TIME_BASE 1000000
  20. #define AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE}
  21. enum CodecID {
  22. CODEC_ID_NONE,
  23. CODEC_ID_MPEG1VIDEO,
  24. CODEC_ID_MPEG2VIDEO, /* prefered ID for MPEG Video 1 or 2 decoding */
  25. CODEC_ID_MPEG2VIDEO_XVMC,
  26. CODEC_ID_H261,
  27. CODEC_ID_H263,
  28. CODEC_ID_RV10,
  29. CODEC_ID_RV20,
  30. CODEC_ID_MJPEG,
  31. CODEC_ID_MJPEGB,
  32. CODEC_ID_LJPEG,
  33. CODEC_ID_SP5X,
  34. CODEC_ID_JPEGLS,
  35. CODEC_ID_MPEG4,
  36. CODEC_ID_RAWVIDEO,
  37. CODEC_ID_MSMPEG4V1,
  38. CODEC_ID_MSMPEG4V2,
  39. CODEC_ID_MSMPEG4V3,
  40. CODEC_ID_WMV1,
  41. CODEC_ID_WMV2,
  42. CODEC_ID_H263P,
  43. CODEC_ID_H263I,
  44. CODEC_ID_FLV1,
  45. CODEC_ID_SVQ1,
  46. CODEC_ID_SVQ3,
  47. CODEC_ID_DVVIDEO,
  48. CODEC_ID_HUFFYUV,
  49. CODEC_ID_CYUV,
  50. CODEC_ID_H264,
  51. CODEC_ID_INDEO3,
  52. CODEC_ID_VP3,
  53. CODEC_ID_THEORA,
  54. CODEC_ID_ASV1,
  55. CODEC_ID_ASV2,
  56. CODEC_ID_FFV1,
  57. CODEC_ID_4XM,
  58. CODEC_ID_VCR1,
  59. CODEC_ID_CLJR,
  60. CODEC_ID_MDEC,
  61. CODEC_ID_ROQ,
  62. CODEC_ID_INTERPLAY_VIDEO,
  63. CODEC_ID_XAN_WC3,
  64. CODEC_ID_XAN_WC4,
  65. CODEC_ID_RPZA,
  66. CODEC_ID_CINEPAK,
  67. CODEC_ID_WS_VQA,
  68. CODEC_ID_MSRLE,
  69. CODEC_ID_MSVIDEO1,
  70. CODEC_ID_IDCIN,
  71. CODEC_ID_8BPS,
  72. CODEC_ID_SMC,
  73. CODEC_ID_FLIC,
  74. CODEC_ID_TRUEMOTION1,
  75. CODEC_ID_VMDVIDEO,
  76. CODEC_ID_MSZH,
  77. CODEC_ID_ZLIB,
  78. CODEC_ID_QTRLE,
  79. CODEC_ID_SNOW,
  80. CODEC_ID_TSCC,
  81. CODEC_ID_ULTI,
  82. CODEC_ID_QDRAW,
  83. CODEC_ID_VIXL,
  84. CODEC_ID_QPEG,
  85. CODEC_ID_XVID,
  86. CODEC_ID_PNG,
  87. CODEC_ID_PPM,
  88. CODEC_ID_PBM,
  89. CODEC_ID_PGM,
  90. CODEC_ID_PGMYUV,
  91. CODEC_ID_PAM,
  92. CODEC_ID_FFVHUFF,
  93. CODEC_ID_RV30,
  94. CODEC_ID_RV40,
  95. CODEC_ID_VC1,
  96. CODEC_ID_WMV3,
  97. CODEC_ID_LOCO,
  98. CODEC_ID_WNV1,
  99. CODEC_ID_AASC,
  100. CODEC_ID_INDEO2,
  101. CODEC_ID_FRAPS,
  102. CODEC_ID_TRUEMOTION2,
  103. CODEC_ID_BMP,
  104. CODEC_ID_CSCD,
  105. CODEC_ID_MMVIDEO,
  106. CODEC_ID_ZMBV,
  107. CODEC_ID_AVS,
  108. CODEC_ID_SMACKVIDEO,
  109. CODEC_ID_NUV,
  110. CODEC_ID_KMVC,
  111. CODEC_ID_FLASHSV,
  112. CODEC_ID_CAVS,
  113. /* various pcm "codecs" */
  114. CODEC_ID_PCM_S16LE= 0x10000,
  115. CODEC_ID_PCM_S16BE,
  116. CODEC_ID_PCM_U16LE,
  117. CODEC_ID_PCM_U16BE,
  118. CODEC_ID_PCM_S8,
  119. CODEC_ID_PCM_U8,
  120. CODEC_ID_PCM_MULAW,
  121. CODEC_ID_PCM_ALAW,
  122. CODEC_ID_PCM_S32LE,
  123. CODEC_ID_PCM_S32BE,
  124. CODEC_ID_PCM_U32LE,
  125. CODEC_ID_PCM_U32BE,
  126. CODEC_ID_PCM_S24LE,
  127. CODEC_ID_PCM_S24BE,
  128. CODEC_ID_PCM_U24LE,
  129. CODEC_ID_PCM_U24BE,
  130. CODEC_ID_PCM_S24DAUD,
  131. /* various adpcm codecs */
  132. CODEC_ID_ADPCM_IMA_QT= 0x11000,
  133. CODEC_ID_ADPCM_IMA_WAV,
  134. CODEC_ID_ADPCM_IMA_DK3,
  135. CODEC_ID_ADPCM_IMA_DK4,
  136. CODEC_ID_ADPCM_IMA_WS,
  137. CODEC_ID_ADPCM_IMA_SMJPEG,
  138. CODEC_ID_ADPCM_MS,
  139. CODEC_ID_ADPCM_4XM,
  140. CODEC_ID_ADPCM_XA,
  141. CODEC_ID_ADPCM_ADX,
  142. CODEC_ID_ADPCM_EA,
  143. CODEC_ID_ADPCM_G726,
  144. CODEC_ID_ADPCM_CT,
  145. CODEC_ID_ADPCM_SWF,
  146. CODEC_ID_ADPCM_YAMAHA,
  147. CODEC_ID_ADPCM_SBPRO_4,
  148. CODEC_ID_ADPCM_SBPRO_3,
  149. CODEC_ID_ADPCM_SBPRO_2,
  150. /* AMR */
  151. CODEC_ID_AMR_NB= 0x12000,
  152. CODEC_ID_AMR_WB,
  153. /* RealAudio codecs*/
  154. CODEC_ID_RA_144= 0x13000,
  155. CODEC_ID_RA_288,
  156. /* various DPCM codecs */
  157. CODEC_ID_ROQ_DPCM= 0x14000,
  158. CODEC_ID_INTERPLAY_DPCM,
  159. CODEC_ID_XAN_DPCM,
  160. CODEC_ID_SOL_DPCM,
  161. CODEC_ID_MP2= 0x15000,
  162. CODEC_ID_MP3, /* prefered ID for MPEG Audio layer 1, 2 or3 decoding */
  163. CODEC_ID_AAC,
  164. CODEC_ID_MPEG4AAC,
  165. CODEC_ID_AC3,
  166. CODEC_ID_DTS,
  167. CODEC_ID_VORBIS,
  168. CODEC_ID_DVAUDIO,
  169. CODEC_ID_WMAV1,
  170. CODEC_ID_WMAV2,
  171. CODEC_ID_MACE3,
  172. CODEC_ID_MACE6,
  173. CODEC_ID_VMDAUDIO,
  174. CODEC_ID_SONIC,
  175. CODEC_ID_SONIC_LS,
  176. CODEC_ID_FLAC,
  177. CODEC_ID_MP3ADU,
  178. CODEC_ID_MP3ON4,
  179. CODEC_ID_SHORTEN,
  180. CODEC_ID_ALAC,
  181. CODEC_ID_WESTWOOD_SND1,
  182. CODEC_ID_GSM,
  183. CODEC_ID_QDM2,
  184. CODEC_ID_COOK,
  185. CODEC_ID_TRUESPEECH,
  186. CODEC_ID_TTA,
  187. CODEC_ID_SMACKAUDIO,
  188. CODEC_ID_OGGTHEORA= 0x16000,
  189. /* subtitle codecs */
  190. CODEC_ID_DVD_SUBTITLE= 0x17000,
  191. CODEC_ID_DVB_SUBTITLE,
  192. CODEC_ID_MPEG2TS= 0x20000, /* _FAKE_ codec to indicate a raw MPEG2 transport
  193. stream (only used by libavformat) */
  194. };
  195. /* CODEC_ID_MP3LAME is absolete */
  196. #define CODEC_ID_MP3LAME CODEC_ID_MP3
  197. enum CodecType {
  198. CODEC_TYPE_UNKNOWN = -1,
  199. CODEC_TYPE_VIDEO,
  200. CODEC_TYPE_AUDIO,
  201. CODEC_TYPE_DATA,
  202. CODEC_TYPE_SUBTITLE,
  203. };
  204. /* currently unused, may be used if 24/32 bits samples ever supported */
  205. /* all in native endian */
  206. enum SampleFormat {
  207. SAMPLE_FMT_NONE = -1,
  208. SAMPLE_FMT_U8, ///< unsigned 8 bits
  209. SAMPLE_FMT_S16, ///< signed 16 bits
  210. SAMPLE_FMT_S24, ///< signed 24 bits
  211. SAMPLE_FMT_S32, ///< signed 32 bits
  212. SAMPLE_FMT_FLT, ///< float
  213. };
  214. /* in bytes */
  215. #define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
  216. /**
  217. * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
  218. * this is mainly needed because some optimized bitstream readers read
  219. * 32 or 64 bit at once and could read over the end<br>
  220. * Note, if the first 23 bits of the additional bytes are not 0 then damaged
  221. * MPEG bitstreams could cause overread and segfault
  222. */
  223. #define FF_INPUT_BUFFER_PADDING_SIZE 8
  224. /**
  225. * minimum encoding buffer size.
  226. * used to avoid some checks during header writing
  227. */
  228. #define FF_MIN_BUFFER_SIZE 16384
  229. /* motion estimation type, EPZS by default */
  230. enum Motion_Est_ID {
  231. ME_ZERO = 1,
  232. ME_FULL,
  233. ME_LOG,
  234. ME_PHODS,
  235. ME_EPZS,
  236. ME_X1,
  237. ME_HEX,
  238. ME_UMH,
  239. ME_ITER,
  240. };
  241. enum AVDiscard{
  242. //we leave some space between them for extensions (drop some keyframes for intra only or drop just some bidir frames)
  243. AVDISCARD_NONE =-16, ///< discard nothing
  244. AVDISCARD_DEFAULT= 0, ///< discard useless packets like 0 size packets in avi
  245. AVDISCARD_NONREF = 8, ///< discard all non reference
  246. AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames
  247. AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes
  248. AVDISCARD_ALL = 48, ///< discard all
  249. };
  250. typedef struct RcOverride{
  251. int start_frame;
  252. int end_frame;
  253. int qscale; // if this is 0 then quality_factor will be used instead
  254. float quality_factor;
  255. } RcOverride;
  256. #define FF_MAX_B_FRAMES 16
  257. /* encoding support
  258. these flags can be passed in AVCodecContext.flags before initing
  259. Note: not everything is supported yet.
  260. */
  261. #define CODEC_FLAG_QSCALE 0x0002 ///< use fixed qscale
  262. #define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed / Advanced prediction for H263
  263. #define CODEC_FLAG_QPEL 0x0010 ///< use qpel MC
  264. #define CODEC_FLAG_GMC 0x0020 ///< use GMC
  265. #define CODEC_FLAG_MV0 0x0040 ///< always try a MB with MV=<0,0>
  266. #define CODEC_FLAG_PART 0x0080 ///< use data partitioning
  267. /* parent program gurantees that the input for b-frame containing streams is not written to
  268. for at least s->max_b_frames+1 frames, if this is not set than the input will be copied */
  269. #define CODEC_FLAG_INPUT_PRESERVED 0x0100
  270. #define CODEC_FLAG_PASS1 0x0200 ///< use internal 2pass ratecontrol in first pass mode
  271. #define CODEC_FLAG_PASS2 0x0400 ///< use internal 2pass ratecontrol in second pass mode
  272. #define CODEC_FLAG_EXTERN_HUFF 0x1000 ///< use external huffman table (for mjpeg)
  273. #define CODEC_FLAG_GRAY 0x2000 ///< only decode/encode grayscale
  274. #define CODEC_FLAG_EMU_EDGE 0x4000///< don't draw edges
  275. #define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding
  276. #define CODEC_FLAG_TRUNCATED 0x00010000 /** input bitstream might be truncated at a random location instead
  277. of only at frame boundaries */
  278. #define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< normalize adaptive quantization
  279. #define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< use interlaced dct
  280. #define CODEC_FLAG_LOW_DELAY 0x00080000 ///< force low delay
  281. #define CODEC_FLAG_ALT_SCAN 0x00100000 ///< use alternate scan
  282. #define CODEC_FLAG_TRELLIS_QUANT 0x00200000 ///< use trellis quantization
  283. #define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< place global headers in extradata instead of every keyframe
  284. #define CODEC_FLAG_BITEXACT 0x00800000 ///< use only bitexact stuff (except (i)dct)
  285. /* Fx : Flag for h263+ extra options */
  286. #define CODEC_FLAG_H263P_AIC 0x01000000 ///< H263 Advanced intra coding / MPEG4 AC prediction (remove this)
  287. #define CODEC_FLAG_AC_PRED 0x01000000 ///< H263 Advanced intra coding / MPEG4 AC prediction
  288. #define CODEC_FLAG_H263P_UMV 0x02000000 ///< Unlimited motion vector
  289. #define CODEC_FLAG_CBP_RD 0x04000000 ///< use rate distortion optimization for cbp
  290. #define CODEC_FLAG_QP_RD 0x08000000 ///< use rate distortion optimization for qp selectioon
  291. #define CODEC_FLAG_H263P_AIV 0x00000008 ///< H263 Alternative inter vlc
  292. #define CODEC_FLAG_OBMC 0x00000001 ///< OBMC
  293. #define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter
  294. #define CODEC_FLAG_H263P_SLICE_STRUCT 0x10000000
  295. #define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation
  296. #define CODEC_FLAG_SVCD_SCAN_OFFSET 0x40000000 ///< will reserve space for SVCD scan offset user data
  297. #define CODEC_FLAG_CLOSED_GOP ((int)0x80000000)
  298. #define CODEC_FLAG2_FAST 0x00000001 ///< allow non spec compliant speedup tricks
  299. #define CODEC_FLAG2_STRICT_GOP 0x00000002 ///< strictly enforce GOP size
  300. #define CODEC_FLAG2_NO_OUTPUT 0x00000004 ///< skip bitstream encoding
  301. #define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< place global headers at every keyframe instead of in extradata
  302. #define CODEC_FLAG2_BPYRAMID 0x00000010 ///< H.264 allow b-frames to be used as references
  303. #define CODEC_FLAG2_WPRED 0x00000020 ///< H.264 weighted biprediction for b-frames
  304. #define CODEC_FLAG2_MIXED_REFS 0x00000040 ///< H.264 multiple references per partition
  305. #define CODEC_FLAG2_8X8DCT 0x00000080 ///< H.264 high profile 8x8 transform
  306. #define CODEC_FLAG2_FASTPSKIP 0x00000100 ///< H.264 fast pskip
  307. #define CODEC_FLAG2_AUD 0x00000200 ///< H.264 access unit delimiters
  308. #define CODEC_FLAG2_BRDO 0x00000400 ///< b-frame rate-distortion optimization
  309. #define CODEC_FLAG2_INTRA_VLC 0x00000800 ///< use MPEG-2 intra VLC table
  310. #define CODEC_FLAG2_MEMC_ONLY 0x00001000 ///< only do ME/MC (I frames -> ref, P frame -> ME+MC)
  311. /* Unsupported options :
  312. * Syntax Arithmetic coding (SAC)
  313. * Reference Picture Selection
  314. * Independant Segment Decoding */
  315. /* /Fx */
  316. /* codec capabilities */
  317. #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< decoder can use draw_horiz_band callback
  318. /**
  319. * Codec uses get_buffer() for allocating buffers.
  320. * direct rendering method 1
  321. */
  322. #define CODEC_CAP_DR1 0x0002
  323. /* if 'parse_only' field is true, then avcodec_parse_frame() can be
  324. used */
  325. #define CODEC_CAP_PARSE_ONLY 0x0004
  326. #define CODEC_CAP_TRUNCATED 0x0008
  327. /* codec can export data for HW decoding (XvMC) */
  328. #define CODEC_CAP_HWACCEL 0x0010
  329. /**
  330. * codec has a non zero delay and needs to be feeded with NULL at the end to get the delayed data.
  331. * if this is not set, the codec is guranteed to never be feeded with NULL data
  332. */
  333. #define CODEC_CAP_DELAY 0x0020
  334. /**
  335. * Codec can be fed a final frame with a smaller size.
  336. * This can be used to prevent truncation of the last audio samples.
  337. */
  338. #define CODEC_CAP_SMALL_LAST_FRAME 0x0040
  339. //the following defines may change, don't expect compatibility if you use them
  340. #define MB_TYPE_INTRA4x4 0x0001
  341. #define MB_TYPE_INTRA16x16 0x0002 //FIXME h264 specific
  342. #define MB_TYPE_INTRA_PCM 0x0004 //FIXME h264 specific
  343. #define MB_TYPE_16x16 0x0008
  344. #define MB_TYPE_16x8 0x0010
  345. #define MB_TYPE_8x16 0x0020
  346. #define MB_TYPE_8x8 0x0040
  347. #define MB_TYPE_INTERLACED 0x0080
  348. #define MB_TYPE_DIRECT2 0x0100 //FIXME
  349. #define MB_TYPE_ACPRED 0x0200
  350. #define MB_TYPE_GMC 0x0400
  351. #define MB_TYPE_SKIP 0x0800
  352. #define MB_TYPE_P0L0 0x1000
  353. #define MB_TYPE_P1L0 0x2000
  354. #define MB_TYPE_P0L1 0x4000
  355. #define MB_TYPE_P1L1 0x8000
  356. #define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0)
  357. #define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1)
  358. #define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1)
  359. #define MB_TYPE_QUANT 0x00010000
  360. #define MB_TYPE_CBP 0x00020000
  361. //Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...)
  362. /**
  363. * Pan Scan area.
  364. * this specifies the area which should be displayed. Note there may be multiple such areas for one frame
  365. */
  366. typedef struct AVPanScan{
  367. /**
  368. * id.
  369. * - encoding: set by user.
  370. * - decoding: set by lavc
  371. */
  372. int id;
  373. /**
  374. * width and height in 1/16 pel
  375. * - encoding: set by user.
  376. * - decoding: set by lavc
  377. */
  378. int width;
  379. int height;
  380. /**
  381. * position of the top left corner in 1/16 pel for up to 3 fields/frames.
  382. * - encoding: set by user.
  383. * - decoding: set by lavc
  384. */
  385. int16_t position[3][2];
  386. }AVPanScan;
  387. #define FF_COMMON_FRAME \
  388. /**\
  389. * pointer to the picture planes.\
  390. * this might be different from the first allocated byte\
  391. * - encoding: \
  392. * - decoding: \
  393. */\
  394. uint8_t *data[4];\
  395. int linesize[4];\
  396. /**\
  397. * pointer to the first allocated byte of the picture. can be used in get_buffer/release_buffer\
  398. * this isn't used by lavc unless the default get/release_buffer() is used\
  399. * - encoding: \
  400. * - decoding: \
  401. */\
  402. uint8_t *base[4];\
  403. /**\
  404. * 1 -> keyframe, 0-> not\
  405. * - encoding: set by lavc\
  406. * - decoding: set by lavc\
  407. */\
  408. int key_frame;\
  409. \
  410. /**\
  411. * picture type of the frame, see ?_TYPE below.\
  412. * - encoding: set by lavc for coded_picture (and set by user for input)\
  413. * - decoding: set by lavc\
  414. */\
  415. int pict_type;\
  416. \
  417. /**\
  418. * presentation timestamp in time_base units (time when frame should be shown to user)\
  419. * if AV_NOPTS_VALUE then frame_rate = 1/time_base will be assumed\
  420. * - encoding: MUST be set by user\
  421. * - decoding: set by lavc\
  422. */\
  423. int64_t pts;\
  424. \
  425. /**\
  426. * picture number in bitstream order.\
  427. * - encoding: set by\
  428. * - decoding: set by lavc\
  429. */\
  430. int coded_picture_number;\
  431. /**\
  432. * picture number in display order.\
  433. * - encoding: set by\
  434. * - decoding: set by lavc\
  435. */\
  436. int display_picture_number;\
  437. \
  438. /**\
  439. * quality (between 1 (good) and FF_LAMBDA_MAX (bad)) \
  440. * - encoding: set by lavc for coded_picture (and set by user for input)\
  441. * - decoding: set by lavc\
  442. */\
  443. int quality; \
  444. \
  445. /**\
  446. * buffer age (1->was last buffer and dint change, 2->..., ...).\
  447. * set to INT_MAX if the buffer has not been used yet \
  448. * - encoding: unused\
  449. * - decoding: MUST be set by get_buffer()\
  450. */\
  451. int age;\
  452. \
  453. /**\
  454. * is this picture used as reference\
  455. * - encoding: unused\
  456. * - decoding: set by lavc (before get_buffer() call))\
  457. */\
  458. int reference;\
  459. \
  460. /**\
  461. * QP table\
  462. * - encoding: unused\
  463. * - decoding: set by lavc\
  464. */\
  465. int8_t *qscale_table;\
  466. /**\
  467. * QP store stride\
  468. * - encoding: unused\
  469. * - decoding: set by lavc\
  470. */\
  471. int qstride;\
  472. \
  473. /**\
  474. * mbskip_table[mb]>=1 if MB didnt change\
  475. * stride= mb_width = (width+15)>>4\
  476. * - encoding: unused\
  477. * - decoding: set by lavc\
  478. */\
  479. uint8_t *mbskip_table;\
  480. \
  481. /**\
  482. * Motion vector table.\
  483. * @code\
  484. * example:\
  485. * int mv_sample_log2= 4 - motion_subsample_log2;\
  486. * int mb_width= (width+15)>>4;\
  487. * int mv_stride= (mb_width << mv_sample_log2) + 1;\
  488. * motion_val[direction][x + y*mv_stride][0->mv_x, 1->mv_y];\
  489. * @endcode\
  490. * - encoding: set by user\
  491. * - decoding: set by lavc\
  492. */\
  493. int16_t (*motion_val[2])[2];\
  494. \
  495. /**\
  496. * Macroblock type table\
  497. * mb_type_base + mb_width + 2\
  498. * - encoding: set by user\
  499. * - decoding: set by lavc\
  500. */\
  501. uint32_t *mb_type;\
  502. \
  503. /**\
  504. * log2 of the size of the block which a single vector in motion_val represents: \
  505. * (4->16x16, 3->8x8, 2-> 4x4, 1-> 2x2)\
  506. * - encoding: unused\
  507. * - decoding: set by lavc\
  508. */\
  509. uint8_t motion_subsample_log2;\
  510. \
  511. /**\
  512. * for some private data of the user\
  513. * - encoding: unused\
  514. * - decoding: set by user\
  515. */\
  516. void *opaque;\
  517. \
  518. /**\
  519. * error\
  520. * - encoding: set by lavc if flags&CODEC_FLAG_PSNR\
  521. * - decoding: unused\
  522. */\
  523. uint64_t error[4];\
  524. \
  525. /**\
  526. * type of the buffer (to keep track of who has to dealloc data[*])\
  527. * - encoding: set by the one who allocs it\
  528. * - decoding: set by the one who allocs it\
  529. * Note: user allocated (direct rendering) & internal buffers can not coexist currently\
  530. */\
  531. int type;\
  532. \
  533. /**\
  534. * when decoding, this signal how much the picture must be delayed.\
  535. * extra_delay = repeat_pict / (2*fps)\
  536. * - encoding: unused\
  537. * - decoding: set by lavc\
  538. */\
  539. int repeat_pict;\
  540. \
  541. /**\
  542. * \
  543. */\
  544. int qscale_type;\
  545. \
  546. /**\
  547. * The content of the picture is interlaced.\
  548. * - encoding: set by user\
  549. * - decoding: set by lavc (default 0)\
  550. */\
  551. int interlaced_frame;\
  552. \
  553. /**\
  554. * if the content is interlaced, is top field displayed first.\
  555. * - encoding: set by user\
  556. * - decoding: set by lavc\
  557. */\
  558. int top_field_first;\
  559. \
  560. /**\
  561. * Pan scan.\
  562. * - encoding: set by user\
  563. * - decoding: set by lavc\
  564. */\
  565. AVPanScan *pan_scan;\
  566. \
  567. /**\
  568. * tell user application that palette has changed from previous frame.\
  569. * - encoding: ??? (no palette-enabled encoder yet)\
  570. * - decoding: set by lavc (default 0)\
  571. */\
  572. int palette_has_changed;\
  573. \
  574. /**\
  575. * Codec suggestion on buffer type if != 0\
  576. * - encoding: unused\
  577. * - decoding: set by lavc (before get_buffer() call))\
  578. */\
  579. int buffer_hints;\
  580. \
  581. /**\
  582. * DCT coeffitients\
  583. * - encoding: unused\
  584. * - decoding: set by lavc\
  585. */\
  586. short *dct_coeff;\
  587. \
  588. /**\
  589. * Motion referece frame index\
  590. * - encoding: set by user\
  591. * - decoding: set by lavc\
  592. */\
  593. int8_t *ref_index[2];
  594. #define FF_QSCALE_TYPE_MPEG1 0
  595. #define FF_QSCALE_TYPE_MPEG2 1
  596. #define FF_QSCALE_TYPE_H264 2
  597. #define FF_BUFFER_TYPE_INTERNAL 1
  598. #define FF_BUFFER_TYPE_USER 2 ///< Direct rendering buffers (image is (de)allocated by user)
  599. #define FF_BUFFER_TYPE_SHARED 4 ///< buffer from somewhere else, don't dealloc image (data/base), all other tables are not shared
  600. #define FF_BUFFER_TYPE_COPY 8 ///< just a (modified) copy of some other buffer, don't dealloc anything
  601. #define FF_I_TYPE 1 // Intra
  602. #define FF_P_TYPE 2 // Predicted
  603. #define FF_B_TYPE 3 // Bi-dir predicted
  604. #define FF_S_TYPE 4 // S(GMC)-VOP MPEG4
  605. #define FF_SI_TYPE 5
  606. #define FF_SP_TYPE 6
  607. #define FF_BUFFER_HINTS_VALID 0x01 // Buffer hints value is meaningful (if 0 ignore)
  608. #define FF_BUFFER_HINTS_READABLE 0x02 // Codec will read from buffer
  609. #define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content
  610. #define FF_BUFFER_HINTS_REUSABLE 0x08 // Codec will reuse the buffer (update)
  611. /**
  612. * Audio Video Frame.
  613. */
  614. typedef struct AVFrame {
  615. FF_COMMON_FRAME
  616. } AVFrame;
  617. #define DEFAULT_FRAME_RATE_BASE 1001000
  618. /**
  619. * main external api structure.
  620. */
  621. typedef struct AVCodecContext {
  622. /**
  623. * Info on struct for av_log
  624. * - set by avcodec_alloc_context
  625. */
  626. AVClass *av_class;
  627. /**
  628. * the average bitrate.
  629. * - encoding: set by user. unused for constant quantizer encoding
  630. * - decoding: set by lavc. 0 or some bitrate if this info is available in the stream
  631. */
  632. int bit_rate;
  633. /**
  634. * number of bits the bitstream is allowed to diverge from the reference.
  635. * the reference can be CBR (for CBR pass1) or VBR (for pass2)
  636. * - encoding: set by user. unused for constant quantizer encoding
  637. * - decoding: unused
  638. */
  639. int bit_rate_tolerance;
  640. /**
  641. * CODEC_FLAG_*.
  642. * - encoding: set by user.
  643. * - decoding: set by user.
  644. */
  645. int flags;
  646. /**
  647. * some codecs needs additionnal format info. It is stored here
  648. * - encoding: set by user.
  649. * - decoding: set by lavc. (FIXME is this ok?)
  650. */
  651. int sub_id;
  652. /**
  653. * motion estimation algorithm used for video coding.
  654. * 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex),
  655. * 8 (umh), 9 (iter) [7, 8 are x264 specific, 9 is snow specific]
  656. * - encoding: MUST be set by user.
  657. * - decoding: unused
  658. */
  659. int me_method;
  660. /**
  661. * some codecs need / can use extra-data like huffman tables.
  662. * mjpeg: huffman tables
  663. * rv10: additional flags
  664. * mpeg4: global headers (they can be in the bitstream or here)
  665. * the allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger
  666. * then extradata_size to avoid prolems if its read with the bitstream reader
  667. * the bytewise contents of extradata must not depend on the architecture or cpu endianness
  668. * - encoding: set/allocated/freed by lavc.
  669. * - decoding: set/allocated/freed by user.
  670. */
  671. void *extradata;
  672. int extradata_size;
  673. /**
  674. * this is the fundamental unit of time (in seconds) in terms
  675. * of which frame timestamps are represented. for fixed-fps content,
  676. * timebase should be 1/framerate and timestamp increments should be
  677. * identically 1.
  678. * - encoding: MUST be set by user
  679. * - decoding: set by lavc.
  680. */
  681. AVRational time_base;
  682. /* video only */
  683. /**
  684. * picture width / height.
  685. * - encoding: MUST be set by user.
  686. * - decoding: set by lavc.
  687. * Note, for compatibility its possible to set this instead of
  688. * coded_width/height before decoding
  689. */
  690. int width, height;
  691. #define FF_ASPECT_EXTENDED 15
  692. /**
  693. * the number of pictures in a group of pitures, or 0 for intra_only.
  694. * - encoding: set by user.
  695. * - decoding: unused
  696. */
  697. int gop_size;
  698. /**
  699. * pixel format, see PIX_FMT_xxx.
  700. * - encoding: set by user.
  701. * - decoding: set by lavc.
  702. */
  703. enum PixelFormat pix_fmt;
  704. /**
  705. * Frame rate emulation. If not zero lower layer (i.e. format handler)
  706. * has to read frames at native frame rate.
  707. * - encoding: set by user.
  708. * - decoding: unused.
  709. */
  710. int rate_emu;
  711. /**
  712. * if non NULL, 'draw_horiz_band' is called by the libavcodec
  713. * decoder to draw an horizontal band. It improve cache usage. Not
  714. * all codecs can do that. You must check the codec capabilities
  715. * before
  716. * - encoding: unused
  717. * - decoding: set by user.
  718. * @param height the height of the slice
  719. * @param y the y position of the slice
  720. * @param type 1->top field, 2->bottom field, 3->frame
  721. * @param offset offset into the AVFrame.data from which the slice should be read
  722. */
  723. void (*draw_horiz_band)(struct AVCodecContext *s,
  724. const AVFrame *src, int offset[4],
  725. int y, int type, int height);
  726. /* audio only */
  727. int sample_rate; ///< samples per sec
  728. int channels;
  729. /**
  730. * audio sample format.
  731. * - encoding: set by user.
  732. * - decoding: set by lavc.
  733. */
  734. enum SampleFormat sample_fmt; ///< sample format, currenly unused
  735. /* the following data should not be initialized */
  736. /**
  737. * samples per packet. initialized when calling 'init'
  738. */
  739. int frame_size;
  740. int frame_number; ///< audio or video frame number
  741. int real_pict_num; ///< returns the real picture number of previous encoded frame
  742. /**
  743. * number of frames the decoded output will be delayed relative to
  744. * the encoded input.
  745. * - encoding: set by lavc.
  746. * - decoding: unused
  747. */
  748. int delay;
  749. /* - encoding parameters */
  750. float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)
  751. float qblur; ///< amount of qscale smoothing over time (0.0-1.0)
  752. /**
  753. * minimum quantizer.
  754. * - encoding: set by user.
  755. * - decoding: unused
  756. */
  757. int qmin;
  758. /**
  759. * maximum quantizer.
  760. * - encoding: set by user.
  761. * - decoding: unused
  762. */
  763. int qmax;
  764. /**
  765. * maximum quantizer difference etween frames.
  766. * - encoding: set by user.
  767. * - decoding: unused
  768. */
  769. int max_qdiff;
  770. /**
  771. * maximum number of b frames between non b frames.
  772. * note: the output will be delayed by max_b_frames+1 relative to the input
  773. * - encoding: set by user.
  774. * - decoding: unused
  775. */
  776. int max_b_frames;
  777. /**
  778. * qscale factor between ip and b frames.
  779. * - encoding: set by user.
  780. * - decoding: unused
  781. */
  782. float b_quant_factor;
  783. /** obsolete FIXME remove */
  784. int rc_strategy;
  785. #define FF_RC_STRATEGY_XVID 1
  786. int b_frame_strategy;
  787. /**
  788. * hurry up amount.
  789. * deprecated in favor of skip_idct and skip_frame
  790. * - encoding: unused
  791. * - decoding: set by user. 1-> skip b frames, 2-> skip idct/dequant too, 5-> skip everything except header
  792. */
  793. int hurry_up;
  794. struct AVCodec *codec;
  795. void *priv_data;
  796. /* unused, FIXME remove*/
  797. int rtp_mode;
  798. int rtp_payload_size; /* The size of the RTP payload: the coder will */
  799. /* do it's best to deliver a chunk with size */
  800. /* below rtp_payload_size, the chunk will start */
  801. /* with a start code on some codecs like H.263 */
  802. /* This doesn't take account of any particular */
  803. /* headers inside the transmited RTP payload */
  804. /* The RTP callback: This function is called */
  805. /* every time the encoder has a packet to send */
  806. /* Depends on the encoder if the data starts */
  807. /* with a Start Code (it should) H.263 does. */
  808. /* mb_nb contains the number of macroblocks */
  809. /* encoded in the RTP payload */
  810. void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb);
  811. /* statistics, used for 2-pass encoding */
  812. int mv_bits;
  813. int header_bits;
  814. int i_tex_bits;
  815. int p_tex_bits;
  816. int i_count;
  817. int p_count;
  818. int skip_count;
  819. int misc_bits;
  820. /**
  821. * number of bits used for the previously encoded frame.
  822. * - encoding: set by lavc
  823. * - decoding: unused
  824. */
  825. int frame_bits;
  826. /**
  827. * private data of the user, can be used to carry app specific stuff.
  828. * - encoding: set by user
  829. * - decoding: set by user
  830. */
  831. void *opaque;
  832. char codec_name[32];
  833. enum CodecType codec_type; /* see CODEC_TYPE_xxx */
  834. enum CodecID codec_id; /* see CODEC_ID_xxx */
  835. /**
  836. * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
  837. * this is used to workaround some encoder bugs
  838. * - encoding: set by user, if not then the default based on codec_id will be used
  839. * - decoding: set by user, will be converted to upper case by lavc during init
  840. */
  841. unsigned int codec_tag;
  842. /**
  843. * workaround bugs in encoders which sometimes cannot be detected automatically.
  844. * - encoding: set by user
  845. * - decoding: set by user
  846. */
  847. int workaround_bugs;
  848. #define FF_BUG_AUTODETECT 1 ///< autodetection
  849. #define FF_BUG_OLD_MSMPEG4 2
  850. #define FF_BUG_XVID_ILACE 4
  851. #define FF_BUG_UMP4 8
  852. #define FF_BUG_NO_PADDING 16
  853. #define FF_BUG_AMV 32
  854. #define FF_BUG_AC_VLC 0 ///< will be removed, libavcodec can now handle these non compliant files by default
  855. #define FF_BUG_QPEL_CHROMA 64
  856. #define FF_BUG_STD_QPEL 128
  857. #define FF_BUG_QPEL_CHROMA2 256
  858. #define FF_BUG_DIRECT_BLOCKSIZE 512
  859. #define FF_BUG_EDGE 1024
  860. #define FF_BUG_HPEL_CHROMA 2048
  861. #define FF_BUG_DC_CLIP 4096
  862. #define FF_BUG_MS 8192 ///< workaround various bugs in microsofts broken decoders
  863. //#define FF_BUG_FAKE_SCALABILITY 16 //autodetection should work 100%
  864. /**
  865. * luma single coeff elimination threshold.
  866. * - encoding: set by user
  867. * - decoding: unused
  868. */
  869. int luma_elim_threshold;
  870. /**
  871. * chroma single coeff elimination threshold.
  872. * - encoding: set by user
  873. * - decoding: unused
  874. */
  875. int chroma_elim_threshold;
  876. /**
  877. * strictly follow the std (MPEG4, ...).
  878. * - encoding: set by user
  879. * - decoding: unused
  880. */
  881. int strict_std_compliance;
  882. #define FF_COMPLIANCE_VERY_STRICT 2 ///< strictly conform to a older more strict version of the spec or reference software
  883. #define FF_COMPLIANCE_STRICT 1 ///< strictly conform to all the things in the spec no matter what consequences
  884. #define FF_COMPLIANCE_NORMAL 0
  885. #define FF_COMPLIANCE_INOFFICIAL -1 ///< allow inofficial extensions
  886. #define FF_COMPLIANCE_EXPERIMENTAL -2 ///< allow non standarized experimental things
  887. /**
  888. * qscale offset between ip and b frames.
  889. * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
  890. * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
  891. * - encoding: set by user.
  892. * - decoding: unused
  893. */
  894. float b_quant_offset;
  895. /**
  896. * error resilience higher values will detect more errors but may missdetect
  897. * some more or less valid parts as errors.
  898. * - encoding: unused
  899. * - decoding: set by user
  900. */
  901. int error_resilience;
  902. #define FF_ER_CAREFUL 1
  903. #define FF_ER_COMPLIANT 2
  904. #define FF_ER_AGGRESSIVE 3
  905. #define FF_ER_VERY_AGGRESSIVE 4
  906. /**
  907. * called at the beginning of each frame to get a buffer for it.
  908. * if pic.reference is set then the frame will be read later by lavc
  909. * avcodec_align_dimensions() should be used to find the required width and
  910. * height, as they normally need to be rounded up to the next multiple of 16
  911. * - encoding: unused
  912. * - decoding: set by lavc, user can override
  913. */
  914. int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
  915. /**
  916. * called to release buffers which where allocated with get_buffer.
  917. * a released buffer can be reused in get_buffer()
  918. * pic.data[*] must be set to NULL
  919. * - encoding: unused
  920. * - decoding: set by lavc, user can override
  921. */
  922. void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
  923. /**
  924. * if 1 the stream has a 1 frame delay during decoding.
  925. * - encoding: set by lavc
  926. * - decoding: set by lavc
  927. */
  928. int has_b_frames;
  929. /**
  930. * number of bytes per packet if constant and known or 0
  931. * used by some WAV based audio codecs
  932. */
  933. int block_align;
  934. int parse_only; /* - decoding only: if true, only parsing is done
  935. (function avcodec_parse_frame()). The frame
  936. data is returned. Only MPEG codecs support this now. */
  937. /**
  938. * 0-> h263 quant 1-> mpeg quant.
  939. * - encoding: set by user.
  940. * - decoding: unused
  941. */
  942. int mpeg_quant;
  943. /**
  944. * pass1 encoding statistics output buffer.
  945. * - encoding: set by lavc
  946. * - decoding: unused
  947. */
  948. char *stats_out;
  949. /**
  950. * pass2 encoding statistics input buffer.
  951. * concatenated stuff from stats_out of pass1 should be placed here
  952. * - encoding: allocated/set/freed by user
  953. * - decoding: unused
  954. */
  955. char *stats_in;
  956. /**
  957. * ratecontrol qmin qmax limiting method.
  958. * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax
  959. * - encoding: set by user.
  960. * - decoding: unused
  961. */
  962. float rc_qsquish;
  963. float rc_qmod_amp;
  964. int rc_qmod_freq;
  965. /**
  966. * ratecontrol override, see RcOverride.
  967. * - encoding: allocated/set/freed by user.
  968. * - decoding: unused
  969. */
  970. RcOverride *rc_override;
  971. int rc_override_count;
  972. /**
  973. * rate control equation.
  974. * - encoding: set by user
  975. * - decoding: unused
  976. */
  977. char *rc_eq;
  978. /**
  979. * maximum bitrate.
  980. * - encoding: set by user.
  981. * - decoding: unused
  982. */
  983. int rc_max_rate;
  984. /**
  985. * minimum bitrate.
  986. * - encoding: set by user.
  987. * - decoding: unused
  988. */
  989. int rc_min_rate;
  990. /**
  991. * decoder bitstream buffer size.
  992. * - encoding: set by user.
  993. * - decoding: unused
  994. */
  995. int rc_buffer_size;
  996. float rc_buffer_aggressivity;
  997. /**
  998. * qscale factor between p and i frames.
  999. * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
  1000. * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
  1001. * - encoding: set by user.
  1002. * - decoding: unused
  1003. */
  1004. float i_quant_factor;
  1005. /**
  1006. * qscale offset between p and i frames.
  1007. * - encoding: set by user.
  1008. * - decoding: unused
  1009. */
  1010. float i_quant_offset;
  1011. /**
  1012. * initial complexity for pass1 ratecontrol.
  1013. * - encoding: set by user.
  1014. * - decoding: unused
  1015. */
  1016. float rc_initial_cplx;
  1017. /**
  1018. * dct algorithm, see FF_DCT_* below.
  1019. * - encoding: set by user
  1020. * - decoding: unused
  1021. */
  1022. int dct_algo;
  1023. #define FF_DCT_AUTO 0
  1024. #define FF_DCT_FASTINT 1
  1025. #define FF_DCT_INT 2
  1026. #define FF_DCT_MMX 3
  1027. #define FF_DCT_MLIB 4
  1028. #define FF_DCT_ALTIVEC 5
  1029. #define FF_DCT_FAAN 6
  1030. /**
  1031. * luminance masking (0-> disabled).
  1032. * - encoding: set by user
  1033. * - decoding: unused
  1034. */
  1035. float lumi_masking;
  1036. /**
  1037. * temporary complexity masking (0-> disabled).
  1038. * - encoding: set by user
  1039. * - decoding: unused
  1040. */
  1041. float temporal_cplx_masking;
  1042. /**
  1043. * spatial complexity masking (0-> disabled).
  1044. * - encoding: set by user
  1045. * - decoding: unused
  1046. */
  1047. float spatial_cplx_masking;
  1048. /**
  1049. * p block masking (0-> disabled).
  1050. * - encoding: set by user
  1051. * - decoding: unused
  1052. */
  1053. float p_masking;
  1054. /**
  1055. * darkness masking (0-> disabled).
  1056. * - encoding: set by user
  1057. * - decoding: unused
  1058. */
  1059. float dark_masking;
  1060. /* for binary compatibility */
  1061. int unused;
  1062. /**
  1063. * idct algorithm, see FF_IDCT_* below.
  1064. * - encoding: set by user
  1065. * - decoding: set by user
  1066. */
  1067. int idct_algo;
  1068. #define FF_IDCT_AUTO 0
  1069. #define FF_IDCT_INT 1
  1070. #define FF_IDCT_SIMPLE 2
  1071. #define FF_IDCT_SIMPLEMMX 3
  1072. #define FF_IDCT_LIBMPEG2MMX 4
  1073. #define FF_IDCT_PS2 5
  1074. #define FF_IDCT_MLIB 6
  1075. #define FF_IDCT_ARM 7
  1076. #define FF_IDCT_ALTIVEC 8
  1077. #define FF_IDCT_SH4 9
  1078. #define FF_IDCT_SIMPLEARM 10
  1079. #define FF_IDCT_H264 11
  1080. #define FF_IDCT_VP3 12
  1081. #define FF_IDCT_IPP 13
  1082. #define FF_IDCT_XVIDMMX 14
  1083. /**
  1084. * slice count.
  1085. * - encoding: set by lavc
  1086. * - decoding: set by user (or 0)
  1087. */
  1088. int slice_count;
  1089. /**
  1090. * slice offsets in the frame in bytes.
  1091. * - encoding: set/allocated by lavc
  1092. * - decoding: set/allocated by user (or NULL)
  1093. */
  1094. int *slice_offset;
  1095. /**
  1096. * error concealment flags.
  1097. * - encoding: unused
  1098. * - decoding: set by user
  1099. */
  1100. int error_concealment;
  1101. #define FF_EC_GUESS_MVS 1
  1102. #define FF_EC_DEBLOCK 2
  1103. /**
  1104. * dsp_mask could be add used to disable unwanted CPU features
  1105. * CPU features (i.e. MMX, SSE. ...)
  1106. *
  1107. * with FORCE flag you may instead enable given CPU features
  1108. * (Dangerous: usable in case of misdetection, improper usage however will
  1109. * result into program crash)
  1110. */
  1111. unsigned dsp_mask;
  1112. #define FF_MM_FORCE 0x80000000 /* force usage of selected flags (OR) */
  1113. /* lower 16 bits - CPU features */
  1114. #ifdef HAVE_MMX
  1115. #define FF_MM_MMX 0x0001 /* standard MMX */
  1116. #define FF_MM_3DNOW 0x0004 /* AMD 3DNOW */
  1117. #define FF_MM_MMXEXT 0x0002 /* SSE integer functions or AMD MMX ext */
  1118. #define FF_MM_SSE 0x0008 /* SSE functions */
  1119. #define FF_MM_SSE2 0x0010 /* PIV SSE2 functions */
  1120. #define FF_MM_3DNOWEXT 0x0020 /* AMD 3DNowExt */
  1121. #endif /* HAVE_MMX */
  1122. #ifdef HAVE_IWMMXT
  1123. #define FF_MM_IWMMXT 0x0100 /* XScale IWMMXT */
  1124. #endif /* HAVE_IWMMXT */
  1125. /**
  1126. * bits per sample/pixel from the demuxer (needed for huffyuv).
  1127. * - encoding: set by lavc
  1128. * - decoding: set by user
  1129. */
  1130. int bits_per_sample;
  1131. /**
  1132. * prediction method (needed for huffyuv).
  1133. * - encoding: set by user
  1134. * - decoding: unused
  1135. */
  1136. int prediction_method;
  1137. #define FF_PRED_LEFT 0
  1138. #define FF_PRED_PLANE 1
  1139. #define FF_PRED_MEDIAN 2
  1140. /**
  1141. * sample aspect ratio (0 if unknown).
  1142. * numerator and denominator must be relative prime and smaller then 256 for some video standards
  1143. * - encoding: set by user.
  1144. * - decoding: set by lavc.
  1145. */
  1146. AVRational sample_aspect_ratio;
  1147. /**
  1148. * the picture in the bitstream.
  1149. * - encoding: set by lavc
  1150. * - decoding: set by lavc
  1151. */
  1152. AVFrame *coded_frame;
  1153. /**
  1154. * debug.
  1155. * - encoding: set by user.
  1156. * - decoding: set by user.
  1157. */
  1158. int debug;
  1159. #define FF_DEBUG_PICT_INFO 1
  1160. #define FF_DEBUG_RC 2
  1161. #define FF_DEBUG_BITSTREAM 4
  1162. #define FF_DEBUG_MB_TYPE 8
  1163. #define FF_DEBUG_QP 16
  1164. #define FF_DEBUG_MV 32
  1165. #define FF_DEBUG_DCT_COEFF 0x00000040
  1166. #define FF_DEBUG_SKIP 0x00000080
  1167. #define FF_DEBUG_STARTCODE 0x00000100
  1168. #define FF_DEBUG_PTS 0x00000200
  1169. #define FF_DEBUG_ER 0x00000400
  1170. #define FF_DEBUG_MMCO 0x00000800
  1171. #define FF_DEBUG_BUGS 0x00001000
  1172. #define FF_DEBUG_VIS_QP 0x00002000
  1173. #define FF_DEBUG_VIS_MB_TYPE 0x00004000
  1174. /**
  1175. * debug.
  1176. * - encoding: set by user.
  1177. * - decoding: set by user.
  1178. */
  1179. int debug_mv;
  1180. #define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames
  1181. #define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames
  1182. #define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames
  1183. /**
  1184. * error.
  1185. * - encoding: set by lavc if flags&CODEC_FLAG_PSNR
  1186. * - decoding: unused
  1187. */
  1188. uint64_t error[4];
  1189. /**
  1190. * minimum MB quantizer.
  1191. * - encoding: unused
  1192. * - decoding: unused
  1193. */
  1194. int mb_qmin;
  1195. /**
  1196. * maximum MB quantizer.
  1197. * - encoding: unused
  1198. * - decoding: unused
  1199. */
  1200. int mb_qmax;
  1201. /**
  1202. * motion estimation compare function.
  1203. * - encoding: set by user.
  1204. * - decoding: unused
  1205. */
  1206. int me_cmp;
  1207. /**
  1208. * subpixel motion estimation compare function.
  1209. * - encoding: set by user.
  1210. * - decoding: unused
  1211. */
  1212. int me_sub_cmp;
  1213. /**
  1214. * macroblock compare function (not supported yet).
  1215. * - encoding: set by user.
  1216. * - decoding: unused
  1217. */
  1218. int mb_cmp;
  1219. /**
  1220. * interlaced dct compare function
  1221. * - encoding: set by user.
  1222. * - decoding: unused
  1223. */
  1224. int ildct_cmp;
  1225. #define FF_CMP_SAD 0
  1226. #define FF_CMP_SSE 1
  1227. #define FF_CMP_SATD 2
  1228. #define FF_CMP_DCT 3
  1229. #define FF_CMP_PSNR 4
  1230. #define FF_CMP_BIT 5
  1231. #define FF_CMP_RD 6
  1232. #define FF_CMP_ZERO 7
  1233. #define FF_CMP_VSAD 8
  1234. #define FF_CMP_VSSE 9
  1235. #define FF_CMP_NSSE 10
  1236. #define FF_CMP_W53 11
  1237. #define FF_CMP_W97 12
  1238. #define FF_CMP_DCTMAX 13
  1239. #define FF_CMP_DCT264 14
  1240. #define FF_CMP_CHROMA 256
  1241. /**
  1242. * ME diamond size & shape.
  1243. * - encoding: set by user.
  1244. * - decoding: unused
  1245. */
  1246. int dia_size;
  1247. /**
  1248. * amount of previous MV predictors (2a+1 x 2a+1 square).
  1249. * - encoding: set by user.
  1250. * - decoding: unused
  1251. */
  1252. int last_predictor_count;
  1253. /**
  1254. * pre pass for motion estimation.
  1255. * - encoding: set by user.
  1256. * - decoding: unused
  1257. */
  1258. int pre_me;
  1259. /**
  1260. * motion estimation pre pass compare function.
  1261. * - encoding: set by user.
  1262. * - decoding: unused
  1263. */
  1264. int me_pre_cmp;
  1265. /**
  1266. * ME pre pass diamond size & shape.
  1267. * - encoding: set by user.
  1268. * - decoding: unused
  1269. */
  1270. int pre_dia_size;
  1271. /**
  1272. * subpel ME quality.
  1273. * - encoding: set by user.
  1274. * - decoding: unused
  1275. */
  1276. int me_subpel_quality;
  1277. /**
  1278. * callback to negotiate the pixelFormat.
  1279. * @param fmt is the list of formats which are supported by the codec,
  1280. * its terminated by -1 as 0 is a valid format, the formats are ordered by quality
  1281. * the first is allways the native one
  1282. * @return the choosen format
  1283. * - encoding: unused
  1284. * - decoding: set by user, if not set then the native format will always be choosen
  1285. */
  1286. enum PixelFormat (*get_format)(struct AVCodecContext *s, const enum PixelFormat * fmt);
  1287. /**
  1288. * DTG active format information (additionnal aspect ratio
  1289. * information only used in DVB MPEG2 transport streams). 0 if
  1290. * not set.
  1291. *
  1292. * - encoding: unused.
  1293. * - decoding: set by decoder
  1294. */
  1295. int dtg_active_format;
  1296. #define FF_DTG_AFD_SAME 8
  1297. #define FF_DTG_AFD_4_3 9
  1298. #define FF_DTG_AFD_16_9 10
  1299. #define FF_DTG_AFD_14_9 11
  1300. #define FF_DTG_AFD_4_3_SP_14_9 13
  1301. #define FF_DTG_AFD_16_9_SP_14_9 14
  1302. #define FF_DTG_AFD_SP_4_3 15
  1303. /**
  1304. * Maximum motion estimation search range in subpel units.
  1305. * if 0 then no limit
  1306. *
  1307. * - encoding: set by user.
  1308. * - decoding: unused.
  1309. */
  1310. int me_range;
  1311. /**
  1312. * intra quantizer bias.
  1313. * - encoding: set by user.
  1314. * - decoding: unused
  1315. */
  1316. int intra_quant_bias;
  1317. #define FF_DEFAULT_QUANT_BIAS 999999
  1318. /**
  1319. * inter quantizer bias.
  1320. * - encoding: set by user.
  1321. * - decoding: unused
  1322. */
  1323. int inter_quant_bias;
  1324. /**
  1325. * color table ID.
  1326. * - encoding: unused.
  1327. * - decoding: which clrtable should be used for 8bit RGB images
  1328. * table have to be stored somewhere FIXME
  1329. */
  1330. int color_table_id;
  1331. /**
  1332. * internal_buffer count.
  1333. * Don't touch, used by lavc default_get_buffer()
  1334. */
  1335. int internal_buffer_count;
  1336. /**
  1337. * internal_buffers.
  1338. * Don't touch, used by lavc default_get_buffer()
  1339. */
  1340. void *internal_buffer;
  1341. #define FF_LAMBDA_SHIFT 7
  1342. #define FF_LAMBDA_SCALE (1<<FF_LAMBDA_SHIFT)
  1343. #define FF_QP2LAMBDA 118 ///< factor to convert from H.263 QP to lambda
  1344. #define FF_LAMBDA_MAX (256*128-1)
  1345. #define FF_QUALITY_SCALE FF_LAMBDA_SCALE //FIXME maybe remove
  1346. /**
  1347. * global quality for codecs which cannot change it per frame.
  1348. * this should be proportional to MPEG1/2/4 qscale.
  1349. * - encoding: set by user.
  1350. * - decoding: unused
  1351. */
  1352. int global_quality;
  1353. #define FF_CODER_TYPE_VLC 0
  1354. #define FF_CODER_TYPE_AC 1
  1355. /**
  1356. * coder type
  1357. * - encoding: set by user.
  1358. * - decoding: unused
  1359. */
  1360. int coder_type;
  1361. /**
  1362. * context model
  1363. * - encoding: set by user.
  1364. * - decoding: unused
  1365. */
  1366. int context_model;
  1367. #if 0
  1368. /**
  1369. *
  1370. * - encoding: unused
  1371. * - decoding: set by user.
  1372. */
  1373. uint8_t * (*realloc)(struct AVCodecContext *s, uint8_t *buf, int buf_size);
  1374. #endif
  1375. /**
  1376. * slice flags
  1377. * - encoding: unused
  1378. * - decoding: set by user.
  1379. */
  1380. int slice_flags;
  1381. #define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display
  1382. #define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics)
  1383. #define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
  1384. /**
  1385. * XVideo Motion Acceleration
  1386. * - encoding: forbidden
  1387. * - decoding: set by decoder
  1388. */
  1389. int xvmc_acceleration;
  1390. /**
  1391. * macroblock decision mode
  1392. * - encoding: set by user.
  1393. * - decoding: unused
  1394. */
  1395. int mb_decision;
  1396. #define FF_MB_DECISION_SIMPLE 0 ///< uses mb_cmp
  1397. #define FF_MB_DECISION_BITS 1 ///< chooses the one which needs the fewest bits
  1398. #define FF_MB_DECISION_RD 2 ///< rate distoration
  1399. /**
  1400. * custom intra quantization matrix
  1401. * - encoding: set by user, can be NULL
  1402. * - decoding: set by lavc
  1403. */
  1404. uint16_t *intra_matrix;
  1405. /**
  1406. * custom inter quantization matrix
  1407. * - encoding: set by user, can be NULL
  1408. * - decoding: set by lavc
  1409. */
  1410. uint16_t *inter_matrix;
  1411. /**
  1412. * fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
  1413. * this is used to workaround some encoder bugs
  1414. * - encoding: unused
  1415. * - decoding: set by user, will be converted to upper case by lavc during init
  1416. */
  1417. unsigned int stream_codec_tag;
  1418. /**
  1419. * scene change detection threshold.
  1420. * 0 is default, larger means fewer detected scene changes
  1421. * - encoding: set by user.
  1422. * - decoding: unused
  1423. */
  1424. int scenechange_threshold;
  1425. /**
  1426. * minimum lagrange multipler
  1427. * - encoding: set by user.
  1428. * - decoding: unused
  1429. */
  1430. int lmin;
  1431. /**
  1432. * maximum lagrange multipler
  1433. * - encoding: set by user.
  1434. * - decoding: unused
  1435. */
  1436. int lmax;
  1437. /**
  1438. * Palette control structure
  1439. * - encoding: ??? (no palette-enabled encoder yet)
  1440. * - decoding: set by user.
  1441. */
  1442. struct AVPaletteControl *palctrl;
  1443. /**
  1444. * noise reduction strength
  1445. * - encoding: set by user.
  1446. * - decoding: unused
  1447. */
  1448. int noise_reduction;
  1449. /**
  1450. * called at the beginning of a frame to get cr buffer for it.
  1451. * buffer type (size, hints) must be the same. lavc won't check it.
  1452. * lavc will pass previous buffer in pic, function should return
  1453. * same buffer or new buffer with old frame "painted" into it.
  1454. * if pic.data[0] == NULL must behave like get_buffer().
  1455. * - encoding: unused
  1456. * - decoding: set by lavc, user can override
  1457. */
  1458. int (*reget_buffer)(struct AVCodecContext *c, AVFrame *pic);
  1459. /**
  1460. * number of bits which should be loaded into the rc buffer before decoding starts
  1461. * - encoding: set by user.
  1462. * - decoding: unused
  1463. */
  1464. int rc_initial_buffer_occupancy;
  1465. /**
  1466. *
  1467. * - encoding: set by user.
  1468. * - decoding: unused
  1469. */
  1470. int inter_threshold;
  1471. /**
  1472. * CODEC_FLAG2_*.
  1473. * - encoding: set by user.
  1474. * - decoding: set by user.
  1475. */
  1476. int flags2;
  1477. /**
  1478. * simulates errors in the bitstream to test error concealment.
  1479. * - encoding: set by user.
  1480. * - decoding: unused.
  1481. */
  1482. int error_rate;
  1483. /**
  1484. * MP3 antialias algorithm, see FF_AA_* below.
  1485. * - encoding: unused
  1486. * - decoding: set by user
  1487. */
  1488. int antialias_algo;
  1489. #define FF_AA_AUTO 0
  1490. #define FF_AA_FASTINT 1 //not implemented yet
  1491. #define FF_AA_INT 2
  1492. #define FF_AA_FLOAT 3
  1493. /**
  1494. * Quantizer noise shaping.
  1495. * - encoding: set by user
  1496. * - decoding: unused
  1497. */
  1498. int quantizer_noise_shaping;
  1499. /**
  1500. * Thread count.
  1501. * is used to decide how many independant tasks should be passed to execute()
  1502. * - encoding: set by user
  1503. * - decoding: set by user
  1504. */
  1505. int thread_count;
  1506. /**
  1507. * the codec may call this to execute several independant things. it will return only after
  1508. * finishing all tasks, the user may replace this with some multithreaded implementation, the
  1509. * default implementation will execute the parts serially
  1510. * @param count the number of things to execute
  1511. * - encoding: set by lavc, user can override
  1512. * - decoding: set by lavc, user can override
  1513. */
  1514. int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void **arg2, int *ret, int count);
  1515. /**
  1516. * Thread opaque.
  1517. * can be used by execute() to store some per AVCodecContext stuff.
  1518. * - encoding: set by execute()
  1519. * - decoding: set by execute()
  1520. */
  1521. void *thread_opaque;
  1522. /**
  1523. * Motion estimation threshold. under which no motion estimation is
  1524. * performed, but instead the user specified motion vectors are used
  1525. *
  1526. * - encoding: set by user
  1527. * - decoding: unused
  1528. */
  1529. int me_threshold;
  1530. /**
  1531. * Macroblock threshold. under which the user specified macroblock types will be used
  1532. * - encoding: set by user
  1533. * - decoding: unused
  1534. */
  1535. int mb_threshold;
  1536. /**
  1537. * precision of the intra dc coefficient - 8.
  1538. * - encoding: set by user
  1539. * - decoding: unused
  1540. */
  1541. int intra_dc_precision;
  1542. /**
  1543. * noise vs. sse weight for the nsse comparsion function.
  1544. * - encoding: set by user
  1545. * - decoding: unused
  1546. */
  1547. int nsse_weight;
  1548. /**
  1549. * number of macroblock rows at the top which are skipped.
  1550. * - encoding: unused
  1551. * - decoding: set by user
  1552. */
  1553. int skip_top;
  1554. /**
  1555. * number of macroblock rows at the bottom which are skipped.
  1556. * - encoding: unused
  1557. * - decoding: set by user
  1558. */
  1559. int skip_bottom;
  1560. /**
  1561. * profile
  1562. * - encoding: set by user
  1563. * - decoding: set by lavc
  1564. */
  1565. int profile;
  1566. #define FF_PROFILE_UNKNOWN -99
  1567. /**
  1568. * level
  1569. * - encoding: set by user
  1570. * - decoding: set by lavc
  1571. */
  1572. int level;
  1573. #define FF_LEVEL_UNKNOWN -99
  1574. /**
  1575. * low resolution decoding. 1-> 1/2 size, 2->1/4 size
  1576. * - encoding: unused
  1577. * - decoding: set by user
  1578. */
  1579. int lowres;
  1580. /**
  1581. * bitsream width / height. may be different from width/height if lowres
  1582. * or other things are used
  1583. * - encoding: unused
  1584. * - decoding: set by user before init if known, codec should override / dynamically change if needed
  1585. */
  1586. int coded_width, coded_height;
  1587. /**
  1588. * frame skip threshold
  1589. * - encoding: set by user
  1590. * - decoding: unused
  1591. */
  1592. int frame_skip_threshold;
  1593. /**
  1594. * frame skip factor
  1595. * - encoding: set by user
  1596. * - decoding: unused
  1597. */
  1598. int frame_skip_factor;
  1599. /**
  1600. * frame skip exponent
  1601. * - encoding: set by user
  1602. * - decoding: unused
  1603. */
  1604. int frame_skip_exp;
  1605. /**
  1606. * frame skip comparission function
  1607. * - encoding: set by user.
  1608. * - decoding: unused
  1609. */
  1610. int frame_skip_cmp;
  1611. /**
  1612. * border processing masking. raises the quantizer for mbs on the borders
  1613. * of the picture.
  1614. * - encoding: set by user
  1615. * - decoding: unused
  1616. */
  1617. float border_masking;
  1618. /**
  1619. * minimum MB lagrange multipler.
  1620. * - encoding: set by user.
  1621. * - decoding: unused
  1622. */
  1623. int mb_lmin;
  1624. /**
  1625. * maximum MB lagrange multipler.
  1626. * - encoding: set by user.
  1627. * - decoding: unused
  1628. */
  1629. int mb_lmax;
  1630. /**
  1631. *
  1632. * - encoding: set by user.
  1633. * - decoding: unused
  1634. */
  1635. int me_penalty_compensation;
  1636. /**
  1637. *
  1638. * - encoding: unused
  1639. * - decoding: set by user.
  1640. */
  1641. enum AVDiscard skip_loop_filter;
  1642. /**
  1643. *
  1644. * - encoding: unused
  1645. * - decoding: set by user.
  1646. */
  1647. enum AVDiscard skip_idct;
  1648. /**
  1649. *
  1650. * - encoding: unused
  1651. * - decoding: set by user.
  1652. */
  1653. enum AVDiscard skip_frame;
  1654. /**
  1655. *
  1656. * - encoding: set by user.
  1657. * - decoding: unused
  1658. */
  1659. int bidir_refine;
  1660. /**
  1661. *
  1662. * - encoding: set by user.
  1663. * - decoding: unused
  1664. */
  1665. int brd_scale;
  1666. /**
  1667. * constant rate factor - quality-based VBR - values ~correspond to qps
  1668. * - encoding: set by user.
  1669. * - decoding: unused
  1670. */
  1671. int crf;
  1672. /**
  1673. * constant quantization parameter rate control method
  1674. * - encoding: set by user.
  1675. * - decoding: unused
  1676. */
  1677. int cqp;
  1678. /**
  1679. * minimum gop size
  1680. * - encoding: set by user.
  1681. * - decoding: unused
  1682. */
  1683. int keyint_min;
  1684. /**
  1685. * number of reference frames
  1686. * - encoding: set by user.
  1687. * - decoding: unused
  1688. */
  1689. int refs;
  1690. /**
  1691. * chroma qp offset from luma
  1692. * - encoding: set by user.
  1693. * - decoding: unused
  1694. */
  1695. int chromaoffset;
  1696. /**
  1697. * influences how often b-frames are used
  1698. * - encoding: set by user.
  1699. * - decoding: unused
  1700. */
  1701. int bframebias;
  1702. /**
  1703. * trellis RD quantization
  1704. * - encoding: set by user.
  1705. * - decoding: unused
  1706. */
  1707. int trellis;
  1708. /**
  1709. * reduce fluctuations in qp (before curve compression)
  1710. * - encoding: set by user.
  1711. * - decoding: unused
  1712. */
  1713. float complexityblur;
  1714. /**
  1715. * in-loop deblocking filter alphac0 parameter
  1716. * alpha is in the range -6...6
  1717. * - encoding: set by user.
  1718. * - decoding: unused
  1719. */
  1720. int deblockalpha;
  1721. /**
  1722. * in-loop deblocking filter beta parameter
  1723. * beta is in the range -6...6
  1724. * - encoding: set by user.
  1725. * - decoding: unused
  1726. */
  1727. int deblockbeta;
  1728. /**
  1729. * macroblock subpartition sizes to consider - p8x8, p4x4, b8x8, i8x8, i4x4
  1730. * - encoding: set by user.
  1731. * - decoding: unused
  1732. */
  1733. int partitions;
  1734. #define X264_PART_I4X4 0x001 /* Analyse i4x4 */
  1735. #define X264_PART_I8X8 0x002 /* Analyse i8x8 (requires 8x8 transform) */
  1736. #define X264_PART_P8X8 0x010 /* Analyse p16x8, p8x16 and p8x8 */
  1737. #define X264_PART_P4X4 0x020 /* Analyse p8x4, p4x8, p4x4 */
  1738. #define X264_PART_B8X8 0x100 /* Analyse b16x8, b8x16 and b8x8 */
  1739. /**
  1740. * direct mv prediction mode - 0 (none), 1 (spatial), 2 (temporal)
  1741. * - encoding: set by user.
  1742. * - decoding: unused
  1743. */
  1744. int directpred;
  1745. /**
  1746. * audio cutoff bandwidth (0 means "automatic") . Currently used only by FAAC
  1747. * - encoding: set by user.
  1748. * - decoding: unused
  1749. */
  1750. int cutoff;
  1751. /**
  1752. * multiplied by qscale for each frame and added to scene_change_score
  1753. * - encoding: set by user.
  1754. * - decoding: unused
  1755. */
  1756. int scenechange_factor;
  1757. /**
  1758. *
  1759. * note: value depends upon the compare functin used for fullpel ME
  1760. * - encoding: set by user.
  1761. * - decoding: unused
  1762. */
  1763. int mv0_threshold;
  1764. /**
  1765. * adjusts sensitivity of b_frame_strategy 1
  1766. * - encoding: set by user.
  1767. * - decoding: unused
  1768. */
  1769. int b_sensitivity;
  1770. /**
  1771. * - encoding: set by user.
  1772. * - decoding: unused
  1773. */
  1774. int compression_level;
  1775. #define FF_COMPRESSION_DEFAULT -1
  1776. /**
  1777. * sets whether to use LPC mode - used by FLAC encoder
  1778. * - encoding: set by user.
  1779. * - decoding: unused.
  1780. */
  1781. int use_lpc;
  1782. /**
  1783. * LPC coefficient precision - used by FLAC encoder
  1784. * - encoding: set by user.
  1785. * - decoding: unused.
  1786. */
  1787. int lpc_coeff_precision;
  1788. /**
  1789. * - encoding: set by user.
  1790. * - decoding: unused.
  1791. */
  1792. int min_prediction_order;
  1793. /**
  1794. * - encoding: set by user.
  1795. * - decoding: unused.
  1796. */
  1797. int max_prediction_order;
  1798. /**
  1799. * search method for selecting prediction order
  1800. * - encoding: set by user.
  1801. * - decoding: unused.
  1802. */
  1803. int prediction_order_method;
  1804. /**
  1805. * - encoding: set by user.
  1806. * - decoding: unused.
  1807. */
  1808. int min_partition_order;
  1809. /**
  1810. * - encoding: set by user.
  1811. * - decoding: unused.
  1812. */
  1813. int max_partition_order;
  1814. } AVCodecContext;
  1815. /**
  1816. * AVCodec.
  1817. */
  1818. typedef struct AVCodec {
  1819. const char *name;
  1820. enum CodecType type;
  1821. enum CodecID id;
  1822. int priv_data_size;
  1823. int (*init)(AVCodecContext *);
  1824. int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data);
  1825. int (*close)(AVCodecContext *);
  1826. int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
  1827. uint8_t *buf, int buf_size);
  1828. int capabilities;
  1829. #if LIBAVCODEC_VERSION_INT < ((50<<16)+(0<<8)+0)
  1830. void *dummy; // FIXME remove next time we break binary compatibility
  1831. #endif
  1832. struct AVCodec *next;
  1833. void (*flush)(AVCodecContext *);
  1834. const AVRational *supported_framerates; ///array of supported framerates, or NULL if any, array is terminated by {0,0}
  1835. const enum PixelFormat *pix_fmts; ///array of supported pixel formats, or NULL if unknown, array is terminanted by -1
  1836. } AVCodec;
  1837. /**
  1838. * four components are given, that's all.
  1839. * the last component is alpha
  1840. */
  1841. typedef struct AVPicture {
  1842. uint8_t *data[4];
  1843. int linesize[4]; ///< number of bytes per line
  1844. } AVPicture;
  1845. /**
  1846. * AVPaletteControl
  1847. * This structure defines a method for communicating palette changes
  1848. * between and demuxer and a decoder.
  1849. */
  1850. #define AVPALETTE_SIZE 1024
  1851. #define AVPALETTE_COUNT 256
  1852. typedef struct AVPaletteControl {
  1853. /* demuxer sets this to 1 to indicate the palette has changed;
  1854. * decoder resets to 0 */
  1855. int palette_changed;
  1856. /* 4-byte ARGB palette entries, stored in native byte order; note that
  1857. * the individual palette components should be on a 8-bit scale; if
  1858. * the palette data comes from a IBM VGA native format, the component
  1859. * data is probably 6 bits in size and needs to be scaled */
  1860. unsigned int palette[AVPALETTE_COUNT];
  1861. } AVPaletteControl;
  1862. typedef struct AVSubtitleRect {
  1863. uint16_t x;
  1864. uint16_t y;
  1865. uint16_t w;
  1866. uint16_t h;
  1867. uint16_t nb_colors;
  1868. int linesize;
  1869. uint32_t *rgba_palette;
  1870. uint8_t *bitmap;
  1871. } AVSubtitleRect;
  1872. typedef struct AVSubtitle {
  1873. uint16_t format; /* 0 = graphics */
  1874. uint32_t start_display_time; /* relative to packet pts, in ms */
  1875. uint32_t end_display_time; /* relative to packet pts, in ms */
  1876. uint32_t num_rects;
  1877. AVSubtitleRect *rects;
  1878. } AVSubtitle;
  1879. extern AVCodec ac3_encoder;
  1880. extern AVCodec mp2_encoder;
  1881. extern AVCodec mp3lame_encoder;
  1882. extern AVCodec oggvorbis_encoder;
  1883. extern AVCodec oggtheora_encoder;
  1884. extern AVCodec faac_encoder;
  1885. extern AVCodec flac_encoder;
  1886. extern AVCodec xvid_encoder;
  1887. extern AVCodec mpeg1video_encoder;
  1888. extern AVCodec mpeg2video_encoder;
  1889. extern AVCodec h261_encoder;
  1890. extern AVCodec h263_encoder;
  1891. extern AVCodec h263p_encoder;
  1892. extern AVCodec flv_encoder;
  1893. extern AVCodec rv10_encoder;
  1894. extern AVCodec rv20_encoder;
  1895. extern AVCodec dvvideo_encoder;
  1896. extern AVCodec mjpeg_encoder;
  1897. extern AVCodec ljpeg_encoder;
  1898. extern AVCodec jpegls_encoder;
  1899. extern AVCodec png_encoder;
  1900. extern AVCodec ppm_encoder;
  1901. extern AVCodec pgm_encoder;
  1902. extern AVCodec pgmyuv_encoder;
  1903. extern AVCodec pbm_encoder;
  1904. extern AVCodec pam_encoder;
  1905. extern AVCodec mpeg4_encoder;
  1906. extern AVCodec msmpeg4v1_encoder;
  1907. extern AVCodec msmpeg4v2_encoder;
  1908. extern AVCodec msmpeg4v3_encoder;
  1909. extern AVCodec wmv1_encoder;
  1910. extern AVCodec wmv2_encoder;
  1911. extern AVCodec huffyuv_encoder;
  1912. extern AVCodec ffvhuff_encoder;
  1913. extern AVCodec h264_encoder;
  1914. extern AVCodec asv1_encoder;
  1915. extern AVCodec asv2_encoder;
  1916. extern AVCodec vcr1_encoder;
  1917. extern AVCodec ffv1_encoder;
  1918. extern AVCodec snow_encoder;
  1919. extern AVCodec mdec_encoder;
  1920. extern AVCodec zlib_encoder;
  1921. extern AVCodec sonic_encoder;
  1922. extern AVCodec sonic_ls_encoder;
  1923. extern AVCodec svq1_encoder;
  1924. extern AVCodec x264_encoder;
  1925. extern AVCodec h263_decoder;
  1926. extern AVCodec h261_decoder;
  1927. extern AVCodec mpeg4_decoder;
  1928. extern AVCodec msmpeg4v1_decoder;
  1929. extern AVCodec msmpeg4v2_decoder;
  1930. extern AVCodec msmpeg4v3_decoder;
  1931. extern AVCodec wmv1_decoder;
  1932. extern AVCodec wmv2_decoder;
  1933. extern AVCodec vc1_decoder;
  1934. extern AVCodec wmv3_decoder;
  1935. extern AVCodec mpeg1video_decoder;
  1936. extern AVCodec mpeg2video_decoder;
  1937. extern AVCodec mpegvideo_decoder;
  1938. extern AVCodec mpeg_xvmc_decoder;
  1939. extern AVCodec h263i_decoder;
  1940. extern AVCodec flv_decoder;
  1941. extern AVCodec rv10_decoder;
  1942. extern AVCodec rv20_decoder;
  1943. extern AVCodec rv30_decoder;
  1944. extern AVCodec rv40_decoder;
  1945. extern AVCodec svq1_decoder;
  1946. extern AVCodec svq3_decoder;
  1947. extern AVCodec dvvideo_decoder;
  1948. extern AVCodec wmav1_decoder;
  1949. extern AVCodec wmav2_decoder;
  1950. extern AVCodec mjpeg_decoder;
  1951. extern AVCodec mjpegb_decoder;
  1952. extern AVCodec sp5x_decoder;
  1953. extern AVCodec png_decoder;
  1954. extern AVCodec mp2_decoder;
  1955. extern AVCodec mp3_decoder;
  1956. extern AVCodec mp3adu_decoder;
  1957. extern AVCodec mp3on4_decoder;
  1958. extern AVCodec qdm2_decoder;
  1959. extern AVCodec cook_decoder;
  1960. extern AVCodec truespeech_decoder;
  1961. extern AVCodec tta_decoder;
  1962. extern AVCodec mace3_decoder;
  1963. extern AVCodec mace6_decoder;
  1964. extern AVCodec huffyuv_decoder;
  1965. extern AVCodec ffvhuff_decoder;
  1966. extern AVCodec oggvorbis_decoder;
  1967. extern AVCodec oggtheora_decoder;
  1968. extern AVCodec cyuv_decoder;
  1969. extern AVCodec h264_decoder;
  1970. extern AVCodec indeo3_decoder;
  1971. extern AVCodec vp3_decoder;
  1972. extern AVCodec theora_decoder;
  1973. extern AVCodec amr_nb_decoder;
  1974. extern AVCodec amr_nb_encoder;
  1975. extern AVCodec amr_wb_encoder;
  1976. extern AVCodec amr_wb_decoder;
  1977. extern AVCodec aac_decoder;
  1978. extern AVCodec mpeg4aac_decoder;
  1979. extern AVCodec asv1_decoder;
  1980. extern AVCodec asv2_decoder;
  1981. extern AVCodec vcr1_decoder;
  1982. extern AVCodec cljr_decoder;
  1983. extern AVCodec ffv1_decoder;
  1984. extern AVCodec snow_decoder;
  1985. extern AVCodec fourxm_decoder;
  1986. extern AVCodec mdec_decoder;
  1987. extern AVCodec roq_decoder;
  1988. extern AVCodec interplay_video_decoder;
  1989. extern AVCodec xan_wc3_decoder;
  1990. extern AVCodec rpza_decoder;
  1991. extern AVCodec cinepak_decoder;
  1992. extern AVCodec msrle_decoder;
  1993. extern AVCodec msvideo1_decoder;
  1994. extern AVCodec vqa_decoder;
  1995. extern AVCodec idcin_decoder;
  1996. extern AVCodec eightbps_decoder;
  1997. extern AVCodec smc_decoder;
  1998. extern AVCodec flic_decoder;
  1999. extern AVCodec vmdvideo_decoder;
  2000. extern AVCodec vmdaudio_decoder;
  2001. extern AVCodec truemotion1_decoder;
  2002. extern AVCodec truemotion2_decoder;
  2003. extern AVCodec mszh_decoder;
  2004. extern AVCodec zlib_decoder;
  2005. extern AVCodec ra_144_decoder;
  2006. extern AVCodec ra_288_decoder;
  2007. extern AVCodec roq_dpcm_decoder;
  2008. extern AVCodec interplay_dpcm_decoder;
  2009. extern AVCodec xan_dpcm_decoder;
  2010. extern AVCodec sol_dpcm_decoder;
  2011. extern AVCodec sonic_decoder;
  2012. extern AVCodec qtrle_decoder;
  2013. extern AVCodec flac_decoder;
  2014. extern AVCodec tscc_decoder;
  2015. extern AVCodec cscd_decoder;
  2016. extern AVCodec nuv_decoder;
  2017. extern AVCodec ulti_decoder;
  2018. extern AVCodec qdraw_decoder;
  2019. extern AVCodec xl_decoder;
  2020. extern AVCodec qpeg_decoder;
  2021. extern AVCodec shorten_decoder;
  2022. extern AVCodec loco_decoder;
  2023. extern AVCodec wnv1_decoder;
  2024. extern AVCodec aasc_decoder;
  2025. extern AVCodec alac_decoder;
  2026. extern AVCodec ws_snd1_decoder;
  2027. extern AVCodec indeo2_decoder;
  2028. extern AVCodec vorbis_decoder;
  2029. extern AVCodec fraps_decoder;
  2030. extern AVCodec libgsm_encoder;
  2031. extern AVCodec libgsm_decoder;
  2032. extern AVCodec bmp_decoder;
  2033. extern AVCodec mmvideo_decoder;
  2034. extern AVCodec zmbv_decoder;
  2035. extern AVCodec avs_decoder;
  2036. extern AVCodec smacker_decoder;
  2037. extern AVCodec smackaud_decoder;
  2038. extern AVCodec kmvc_decoder;
  2039. extern AVCodec flashsv_decoder;
  2040. extern AVCodec cavs_decoder;
  2041. /* pcm codecs */
  2042. #define PCM_CODEC(id, name) \
  2043. extern AVCodec name ## _decoder; \
  2044. extern AVCodec name ## _encoder
  2045. PCM_CODEC(CODEC_ID_PCM_S32LE, pcm_s32le);
  2046. PCM_CODEC(CODEC_ID_PCM_S32BE, pcm_s32be);
  2047. PCM_CODEC(CODEC_ID_PCM_U32LE, pcm_u32le);
  2048. PCM_CODEC(CODEC_ID_PCM_U32BE, pcm_u32be);
  2049. PCM_CODEC(CODEC_ID_PCM_S24LE, pcm_s24le);
  2050. PCM_CODEC(CODEC_ID_PCM_S24BE, pcm_s24be);
  2051. PCM_CODEC(CODEC_ID_PCM_U24LE, pcm_u24le);
  2052. PCM_CODEC(CODEC_ID_PCM_U24BE, pcm_u24be);
  2053. PCM_CODEC(CODEC_ID_PCM_S24DAUD, pcm_s24daud);
  2054. PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
  2055. PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
  2056. PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
  2057. PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
  2058. PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
  2059. PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
  2060. PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
  2061. PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
  2062. /* adpcm codecs */
  2063. PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
  2064. PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
  2065. PCM_CODEC(CODEC_ID_ADPCM_IMA_DK3, adpcm_ima_dk3);
  2066. PCM_CODEC(CODEC_ID_ADPCM_IMA_DK4, adpcm_ima_dk4);
  2067. PCM_CODEC(CODEC_ID_ADPCM_IMA_WS, adpcm_ima_ws);
  2068. PCM_CODEC(CODEC_ID_ADPCM_SMJPEG, adpcm_ima_smjpeg);
  2069. PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
  2070. PCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm);
  2071. PCM_CODEC(CODEC_ID_ADPCM_XA, adpcm_xa);
  2072. PCM_CODEC(CODEC_ID_ADPCM_ADX, adpcm_adx);
  2073. PCM_CODEC(CODEC_ID_ADPCM_EA, adpcm_ea);
  2074. PCM_CODEC(CODEC_ID_ADPCM_G726, adpcm_g726);
  2075. PCM_CODEC(CODEC_ID_ADPCM_CT, adpcm_ct);
  2076. PCM_CODEC(CODEC_ID_ADPCM_SWF, adpcm_swf);
  2077. PCM_CODEC(CODEC_ID_ADPCM_YAMAHA, adpcm_yamaha);
  2078. PCM_CODEC(CODEC_ID_ADPCM_SBPRO_4, adpcm_sbpro_4);
  2079. PCM_CODEC(CODEC_ID_ADPCM_SBPRO_3, adpcm_sbpro_3);
  2080. PCM_CODEC(CODEC_ID_ADPCM_SBPRO_2, adpcm_sbpro_2);
  2081. #undef PCM_CODEC
  2082. /* dummy raw video codec */
  2083. extern AVCodec rawvideo_encoder;
  2084. extern AVCodec rawvideo_decoder;
  2085. /* the following codecs use external GPL libs */
  2086. extern AVCodec ac3_decoder;
  2087. extern AVCodec dts_decoder;
  2088. /* subtitles */
  2089. extern AVCodec dvdsub_encoder;
  2090. extern AVCodec dvdsub_decoder;
  2091. extern AVCodec dvbsub_encoder;
  2092. extern AVCodec dvbsub_decoder;
  2093. /* resample.c */
  2094. struct ReSampleContext;
  2095. struct AVResampleContext;
  2096. typedef struct ReSampleContext ReSampleContext;
  2097. ReSampleContext *audio_resample_init(int output_channels, int input_channels,
  2098. int output_rate, int input_rate);
  2099. int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
  2100. void audio_resample_close(ReSampleContext *s);
  2101. struct AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_length, int log2_phase_count, int linear, double cutoff);
  2102. int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx);
  2103. void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance);
  2104. void av_resample_close(struct AVResampleContext *c);
  2105. /* YUV420 format is assumed ! */
  2106. struct ImgReSampleContext;
  2107. typedef struct ImgReSampleContext ImgReSampleContext;
  2108. ImgReSampleContext *img_resample_init(int output_width, int output_height,
  2109. int input_width, int input_height);
  2110. ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
  2111. int iwidth, int iheight,
  2112. int topBand, int bottomBand,
  2113. int leftBand, int rightBand,
  2114. int padtop, int padbottom,
  2115. int padleft, int padright);
  2116. void img_resample(ImgReSampleContext *s,
  2117. AVPicture *output, const AVPicture *input);
  2118. void img_resample_close(ImgReSampleContext *s);
  2119. /**
  2120. * Allocate memory for a picture. Call avpicture_free to free it.
  2121. *
  2122. * @param picture the picture to be filled in.
  2123. * @param pix_fmt the format of the picture.
  2124. * @param width the width of the picture.
  2125. * @param height the height of the picture.
  2126. * @return 0 if successful, -1 if not.
  2127. */
  2128. int avpicture_alloc(AVPicture *picture, int pix_fmt, int width, int height);
  2129. /* Free a picture previously allocated by avpicture_alloc. */
  2130. void avpicture_free(AVPicture *picture);
  2131. int avpicture_fill(AVPicture *picture, uint8_t *ptr,
  2132. int pix_fmt, int width, int height);
  2133. int avpicture_layout(const AVPicture* src, int pix_fmt, int width, int height,
  2134. unsigned char *dest, int dest_size);
  2135. int avpicture_get_size(int pix_fmt, int width, int height);
  2136. void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift);
  2137. const char *avcodec_get_pix_fmt_name(int pix_fmt);
  2138. void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
  2139. enum PixelFormat avcodec_get_pix_fmt(const char* name);
  2140. unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat p);
  2141. #define FF_LOSS_RESOLUTION 0x0001 /* loss due to resolution change */
  2142. #define FF_LOSS_DEPTH 0x0002 /* loss due to color depth change */
  2143. #define FF_LOSS_COLORSPACE 0x0004 /* loss due to color space conversion */
  2144. #define FF_LOSS_ALPHA 0x0008 /* loss of alpha bits */
  2145. #define FF_LOSS_COLORQUANT 0x0010 /* loss due to color quantization */
  2146. #define FF_LOSS_CHROMA 0x0020 /* loss of chroma (e.g. rgb to gray conversion) */
  2147. int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt,
  2148. int has_alpha);
  2149. int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt,
  2150. int has_alpha, int *loss_ptr);
  2151. #define FF_ALPHA_TRANSP 0x0001 /* image has some totally transparent pixels */
  2152. #define FF_ALPHA_SEMI_TRANSP 0x0002 /* image has some transparent pixels */
  2153. int img_get_alpha_info(const AVPicture *src,
  2154. int pix_fmt, int width, int height);
  2155. /* convert among pixel formats */
  2156. int img_convert(AVPicture *dst, int dst_pix_fmt,
  2157. const AVPicture *src, int pix_fmt,
  2158. int width, int height);
  2159. /* deinterlace a picture */
  2160. int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
  2161. int pix_fmt, int width, int height);
  2162. /* external high level API */
  2163. extern AVCodec *first_avcodec;
  2164. /* returns LIBAVCODEC_VERSION_INT constant */
  2165. unsigned avcodec_version(void);
  2166. /* returns LIBAVCODEC_BUILD constant */
  2167. unsigned avcodec_build(void);
  2168. void avcodec_init(void);
  2169. void register_avcodec(AVCodec *format);
  2170. AVCodec *avcodec_find_encoder(enum CodecID id);
  2171. AVCodec *avcodec_find_encoder_by_name(const char *name);
  2172. AVCodec *avcodec_find_decoder(enum CodecID id);
  2173. AVCodec *avcodec_find_decoder_by_name(const char *name);
  2174. void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
  2175. void avcodec_get_context_defaults(AVCodecContext *s);
  2176. AVCodecContext *avcodec_alloc_context(void);
  2177. void avcodec_get_frame_defaults(AVFrame *pic);
  2178. AVFrame *avcodec_alloc_frame(void);
  2179. int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
  2180. void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
  2181. int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic);
  2182. void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);
  2183. int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h);
  2184. enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt);
  2185. int avcodec_thread_init(AVCodecContext *s, int thread_count);
  2186. void avcodec_thread_free(AVCodecContext *s);
  2187. int avcodec_thread_execute(AVCodecContext *s, int (*func)(AVCodecContext *c2, void *arg2),void **arg, int *ret, int count);
  2188. int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void **arg, int *ret, int count);
  2189. //FIXME func typedef
  2190. /**
  2191. * opens / inits the AVCodecContext.
  2192. * not thread save!
  2193. */
  2194. int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
  2195. int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
  2196. int *frame_size_ptr,
  2197. uint8_t *buf, int buf_size);
  2198. int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
  2199. int *got_picture_ptr,
  2200. uint8_t *buf, int buf_size);
  2201. int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub,
  2202. int *got_sub_ptr,
  2203. const uint8_t *buf, int buf_size);
  2204. int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata,
  2205. int *data_size_ptr,
  2206. uint8_t *buf, int buf_size);
  2207. int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
  2208. const short *samples);
  2209. int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
  2210. const AVFrame *pict);
  2211. int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
  2212. const AVSubtitle *sub);
  2213. int avcodec_close(AVCodecContext *avctx);
  2214. void avcodec_register_all(void);
  2215. void avcodec_flush_buffers(AVCodecContext *avctx);
  2216. void avcodec_default_free_buffers(AVCodecContext *s);
  2217. /* misc usefull functions */
  2218. /**
  2219. * returns a single letter to describe the picture type
  2220. */
  2221. char av_get_pict_type_char(int pict_type);
  2222. /**
  2223. * returns codec bits per sample
  2224. */
  2225. int av_get_bits_per_sample(enum CodecID codec_id);
  2226. /* frame parsing */
  2227. typedef struct AVCodecParserContext {
  2228. void *priv_data;
  2229. struct AVCodecParser *parser;
  2230. int64_t frame_offset; /* offset of the current frame */
  2231. int64_t cur_offset; /* current offset
  2232. (incremented by each av_parser_parse()) */
  2233. int64_t last_frame_offset; /* offset of the last frame */
  2234. /* video info */
  2235. int pict_type; /* XXX: put it back in AVCodecContext */
  2236. int repeat_pict; /* XXX: put it back in AVCodecContext */
  2237. int64_t pts; /* pts of the current frame */
  2238. int64_t dts; /* dts of the current frame */
  2239. /* private data */
  2240. int64_t last_pts;
  2241. int64_t last_dts;
  2242. int fetch_timestamp;
  2243. #define AV_PARSER_PTS_NB 4
  2244. int cur_frame_start_index;
  2245. int64_t cur_frame_offset[AV_PARSER_PTS_NB];
  2246. int64_t cur_frame_pts[AV_PARSER_PTS_NB];
  2247. int64_t cur_frame_dts[AV_PARSER_PTS_NB];
  2248. int flags;
  2249. #define PARSER_FLAG_COMPLETE_FRAMES 0x0001
  2250. } AVCodecParserContext;
  2251. typedef struct AVCodecParser {
  2252. int codec_ids[5]; /* several codec IDs are permitted */
  2253. int priv_data_size;
  2254. int (*parser_init)(AVCodecParserContext *s);
  2255. int (*parser_parse)(AVCodecParserContext *s,
  2256. AVCodecContext *avctx,
  2257. uint8_t **poutbuf, int *poutbuf_size,
  2258. const uint8_t *buf, int buf_size);
  2259. void (*parser_close)(AVCodecParserContext *s);
  2260. int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size);
  2261. struct AVCodecParser *next;
  2262. } AVCodecParser;
  2263. extern AVCodecParser *av_first_parser;
  2264. void av_register_codec_parser(AVCodecParser *parser);
  2265. AVCodecParserContext *av_parser_init(int codec_id);
  2266. int av_parser_parse(AVCodecParserContext *s,
  2267. AVCodecContext *avctx,
  2268. uint8_t **poutbuf, int *poutbuf_size,
  2269. const uint8_t *buf, int buf_size,
  2270. int64_t pts, int64_t dts);
  2271. int av_parser_change(AVCodecParserContext *s,
  2272. AVCodecContext *avctx,
  2273. uint8_t **poutbuf, int *poutbuf_size,
  2274. const uint8_t *buf, int buf_size, int keyframe);
  2275. void av_parser_close(AVCodecParserContext *s);
  2276. extern AVCodecParser mpegvideo_parser;
  2277. extern AVCodecParser mpeg4video_parser;
  2278. extern AVCodecParser cavsvideo_parser;
  2279. extern AVCodecParser h261_parser;
  2280. extern AVCodecParser h263_parser;
  2281. extern AVCodecParser h264_parser;
  2282. extern AVCodecParser mjpeg_parser;
  2283. extern AVCodecParser pnm_parser;
  2284. extern AVCodecParser mpegaudio_parser;
  2285. extern AVCodecParser ac3_parser;
  2286. extern AVCodecParser dvdsub_parser;
  2287. extern AVCodecParser dvbsub_parser;
  2288. extern AVCodecParser aac_parser;
  2289. typedef struct AVBitStreamFilterContext {
  2290. void *priv_data;
  2291. struct AVBitStreamFilter *filter;
  2292. AVCodecParserContext *parser;
  2293. struct AVBitStreamFilterContext *next;
  2294. } AVBitStreamFilterContext;
  2295. typedef struct AVBitStreamFilter {
  2296. const char *name;
  2297. int priv_data_size;
  2298. int (*filter)(AVBitStreamFilterContext *bsfc,
  2299. AVCodecContext *avctx, const char *args,
  2300. uint8_t **poutbuf, int *poutbuf_size,
  2301. const uint8_t *buf, int buf_size, int keyframe);
  2302. struct AVBitStreamFilter *next;
  2303. } AVBitStreamFilter;
  2304. extern AVBitStreamFilter *av_first_bitstream_filter;
  2305. void av_register_bitstream_filter(AVBitStreamFilter *bsf);
  2306. AVBitStreamFilterContext *av_bitstream_filter_init(const char *name);
  2307. int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc,
  2308. AVCodecContext *avctx, const char *args,
  2309. uint8_t **poutbuf, int *poutbuf_size,
  2310. const uint8_t *buf, int buf_size, int keyframe);
  2311. void av_bitstream_filter_close(AVBitStreamFilterContext *bsf);
  2312. extern AVBitStreamFilter dump_extradata_bsf;
  2313. extern AVBitStreamFilter remove_extradata_bsf;
  2314. extern AVBitStreamFilter noise_bsf;
  2315. /* memory */
  2316. void *av_mallocz(unsigned int size);
  2317. char *av_strdup(const char *s);
  2318. void av_freep(void *ptr);
  2319. void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
  2320. /* for static data only */
  2321. /* call av_free_static to release all staticaly allocated tables */
  2322. void av_free_static(void);
  2323. void *av_mallocz_static(unsigned int size);
  2324. void *av_realloc_static(void *ptr, unsigned int size);
  2325. void img_copy(AVPicture *dst, const AVPicture *src,
  2326. int pix_fmt, int width, int height);
  2327. int img_crop(AVPicture *dst, const AVPicture *src,
  2328. int pix_fmt, int top_band, int left_band);
  2329. int img_pad(AVPicture *dst, const AVPicture *src, int height, int width, int pix_fmt,
  2330. int padtop, int padbottom, int padleft, int padright, int *color);
  2331. /* endian macros */
  2332. #if !defined(BE_16) || !defined(BE_32) || !defined(LE_16) || !defined(LE_32)
  2333. #define BE_16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1])
  2334. #define BE_32(x) ((((uint8_t*)(x))[0] << 24) | \
  2335. (((uint8_t*)(x))[1] << 16) | \
  2336. (((uint8_t*)(x))[2] << 8) | \
  2337. ((uint8_t*)(x))[3])
  2338. #define LE_16(x) ((((uint8_t*)(x))[1] << 8) | ((uint8_t*)(x))[0])
  2339. #define LE_32(x) ((((uint8_t*)(x))[3] << 24) | \
  2340. (((uint8_t*)(x))[2] << 16) | \
  2341. (((uint8_t*)(x))[1] << 8) | \
  2342. ((uint8_t*)(x))[0])
  2343. #endif
  2344. extern unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
  2345. #ifdef __cplusplus
  2346. }
  2347. #endif
  2348. #endif /* AVCODEC_H */