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.

2639 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)+(11<<8)+0)
  15. #define LIBAVCODEC_VERSION 51.11.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. CODEC_ID_JPEG2000,
  114. /* various pcm "codecs" */
  115. CODEC_ID_PCM_S16LE= 0x10000,
  116. CODEC_ID_PCM_S16BE,
  117. CODEC_ID_PCM_U16LE,
  118. CODEC_ID_PCM_U16BE,
  119. CODEC_ID_PCM_S8,
  120. CODEC_ID_PCM_U8,
  121. CODEC_ID_PCM_MULAW,
  122. CODEC_ID_PCM_ALAW,
  123. CODEC_ID_PCM_S32LE,
  124. CODEC_ID_PCM_S32BE,
  125. CODEC_ID_PCM_U32LE,
  126. CODEC_ID_PCM_U32BE,
  127. CODEC_ID_PCM_S24LE,
  128. CODEC_ID_PCM_S24BE,
  129. CODEC_ID_PCM_U24LE,
  130. CODEC_ID_PCM_U24BE,
  131. CODEC_ID_PCM_S24DAUD,
  132. /* various adpcm codecs */
  133. CODEC_ID_ADPCM_IMA_QT= 0x11000,
  134. CODEC_ID_ADPCM_IMA_WAV,
  135. CODEC_ID_ADPCM_IMA_DK3,
  136. CODEC_ID_ADPCM_IMA_DK4,
  137. CODEC_ID_ADPCM_IMA_WS,
  138. CODEC_ID_ADPCM_IMA_SMJPEG,
  139. CODEC_ID_ADPCM_MS,
  140. CODEC_ID_ADPCM_4XM,
  141. CODEC_ID_ADPCM_XA,
  142. CODEC_ID_ADPCM_ADX,
  143. CODEC_ID_ADPCM_EA,
  144. CODEC_ID_ADPCM_G726,
  145. CODEC_ID_ADPCM_CT,
  146. CODEC_ID_ADPCM_SWF,
  147. CODEC_ID_ADPCM_YAMAHA,
  148. CODEC_ID_ADPCM_SBPRO_4,
  149. CODEC_ID_ADPCM_SBPRO_3,
  150. CODEC_ID_ADPCM_SBPRO_2,
  151. /* AMR */
  152. CODEC_ID_AMR_NB= 0x12000,
  153. CODEC_ID_AMR_WB,
  154. /* RealAudio codecs*/
  155. CODEC_ID_RA_144= 0x13000,
  156. CODEC_ID_RA_288,
  157. /* various DPCM codecs */
  158. CODEC_ID_ROQ_DPCM= 0x14000,
  159. CODEC_ID_INTERPLAY_DPCM,
  160. CODEC_ID_XAN_DPCM,
  161. CODEC_ID_SOL_DPCM,
  162. CODEC_ID_MP2= 0x15000,
  163. CODEC_ID_MP3, /* prefered ID for MPEG Audio layer 1, 2 or3 decoding */
  164. CODEC_ID_AAC,
  165. CODEC_ID_MPEG4AAC,
  166. CODEC_ID_AC3,
  167. CODEC_ID_DTS,
  168. CODEC_ID_VORBIS,
  169. CODEC_ID_DVAUDIO,
  170. CODEC_ID_WMAV1,
  171. CODEC_ID_WMAV2,
  172. CODEC_ID_MACE3,
  173. CODEC_ID_MACE6,
  174. CODEC_ID_VMDAUDIO,
  175. CODEC_ID_SONIC,
  176. CODEC_ID_SONIC_LS,
  177. CODEC_ID_FLAC,
  178. CODEC_ID_MP3ADU,
  179. CODEC_ID_MP3ON4,
  180. CODEC_ID_SHORTEN,
  181. CODEC_ID_ALAC,
  182. CODEC_ID_WESTWOOD_SND1,
  183. CODEC_ID_GSM,
  184. CODEC_ID_QDM2,
  185. CODEC_ID_COOK,
  186. CODEC_ID_TRUESPEECH,
  187. CODEC_ID_TTA,
  188. CODEC_ID_SMACKAUDIO,
  189. CODEC_ID_QCELP,
  190. /* subtitle codecs */
  191. CODEC_ID_DVD_SUBTITLE= 0x17000,
  192. CODEC_ID_DVB_SUBTITLE,
  193. CODEC_ID_MPEG2TS= 0x20000, /* _FAKE_ codec to indicate a raw MPEG2 transport
  194. stream (only used by libavformat) */
  195. };
  196. /* CODEC_ID_MP3LAME is absolete */
  197. #define CODEC_ID_MP3LAME CODEC_ID_MP3
  198. enum CodecType {
  199. CODEC_TYPE_UNKNOWN = -1,
  200. CODEC_TYPE_VIDEO,
  201. CODEC_TYPE_AUDIO,
  202. CODEC_TYPE_DATA,
  203. CODEC_TYPE_SUBTITLE,
  204. };
  205. /* currently unused, may be used if 24/32 bits samples ever supported */
  206. /* all in native endian */
  207. enum SampleFormat {
  208. SAMPLE_FMT_NONE = -1,
  209. SAMPLE_FMT_U8, ///< unsigned 8 bits
  210. SAMPLE_FMT_S16, ///< signed 16 bits
  211. SAMPLE_FMT_S24, ///< signed 24 bits
  212. SAMPLE_FMT_S32, ///< signed 32 bits
  213. SAMPLE_FMT_FLT, ///< float
  214. };
  215. /* in bytes */
  216. #define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
  217. /**
  218. * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
  219. * this is mainly needed because some optimized bitstream readers read
  220. * 32 or 64 bit at once and could read over the end<br>
  221. * Note, if the first 23 bits of the additional bytes are not 0 then damaged
  222. * MPEG bitstreams could cause overread and segfault
  223. */
  224. #define FF_INPUT_BUFFER_PADDING_SIZE 8
  225. /**
  226. * minimum encoding buffer size.
  227. * used to avoid some checks during header writing
  228. */
  229. #define FF_MIN_BUFFER_SIZE 16384
  230. /* motion estimation type, EPZS by default */
  231. enum Motion_Est_ID {
  232. ME_ZERO = 1,
  233. ME_FULL,
  234. ME_LOG,
  235. ME_PHODS,
  236. ME_EPZS,
  237. ME_X1,
  238. ME_HEX,
  239. ME_UMH,
  240. ME_ITER,
  241. };
  242. enum AVDiscard{
  243. //we leave some space between them for extensions (drop some keyframes for intra only or drop just some bidir frames)
  244. AVDISCARD_NONE =-16, ///< discard nothing
  245. AVDISCARD_DEFAULT= 0, ///< discard useless packets like 0 size packets in avi
  246. AVDISCARD_NONREF = 8, ///< discard all non reference
  247. AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames
  248. AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes
  249. AVDISCARD_ALL = 48, ///< discard all
  250. };
  251. typedef struct RcOverride{
  252. int start_frame;
  253. int end_frame;
  254. int qscale; // if this is 0 then quality_factor will be used instead
  255. float quality_factor;
  256. } RcOverride;
  257. #define FF_MAX_B_FRAMES 16
  258. /* encoding support
  259. these flags can be passed in AVCodecContext.flags before initing
  260. Note: not everything is supported yet.
  261. */
  262. #define CODEC_FLAG_QSCALE 0x0002 ///< use fixed qscale
  263. #define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed / Advanced prediction for H263
  264. #define CODEC_FLAG_QPEL 0x0010 ///< use qpel MC
  265. #define CODEC_FLAG_GMC 0x0020 ///< use GMC
  266. #define CODEC_FLAG_MV0 0x0040 ///< always try a MB with MV=<0,0>
  267. #define CODEC_FLAG_PART 0x0080 ///< use data partitioning
  268. /* parent program gurantees that the input for b-frame containing streams is not written to
  269. for at least s->max_b_frames+1 frames, if this is not set than the input will be copied */
  270. #define CODEC_FLAG_INPUT_PRESERVED 0x0100
  271. #define CODEC_FLAG_PASS1 0x0200 ///< use internal 2pass ratecontrol in first pass mode
  272. #define CODEC_FLAG_PASS2 0x0400 ///< use internal 2pass ratecontrol in second pass mode
  273. #define CODEC_FLAG_EXTERN_HUFF 0x1000 ///< use external huffman table (for mjpeg)
  274. #define CODEC_FLAG_GRAY 0x2000 ///< only decode/encode grayscale
  275. #define CODEC_FLAG_EMU_EDGE 0x4000///< don't draw edges
  276. #define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding
  277. #define CODEC_FLAG_TRUNCATED 0x00010000 /** input bitstream might be truncated at a random location instead
  278. of only at frame boundaries */
  279. #define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< normalize adaptive quantization
  280. #define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< use interlaced dct
  281. #define CODEC_FLAG_LOW_DELAY 0x00080000 ///< force low delay
  282. #define CODEC_FLAG_ALT_SCAN 0x00100000 ///< use alternate scan
  283. #define CODEC_FLAG_TRELLIS_QUANT 0x00200000 ///< use trellis quantization
  284. #define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< place global headers in extradata instead of every keyframe
  285. #define CODEC_FLAG_BITEXACT 0x00800000 ///< use only bitexact stuff (except (i)dct)
  286. /* Fx : Flag for h263+ extra options */
  287. #define CODEC_FLAG_H263P_AIC 0x01000000 ///< H263 Advanced intra coding / MPEG4 AC prediction (remove this)
  288. #define CODEC_FLAG_AC_PRED 0x01000000 ///< H263 Advanced intra coding / MPEG4 AC prediction
  289. #define CODEC_FLAG_H263P_UMV 0x02000000 ///< Unlimited motion vector
  290. #define CODEC_FLAG_CBP_RD 0x04000000 ///< use rate distortion optimization for cbp
  291. #define CODEC_FLAG_QP_RD 0x08000000 ///< use rate distortion optimization for qp selectioon
  292. #define CODEC_FLAG_H263P_AIV 0x00000008 ///< H263 Alternative inter vlc
  293. #define CODEC_FLAG_OBMC 0x00000001 ///< OBMC
  294. #define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter
  295. #define CODEC_FLAG_H263P_SLICE_STRUCT 0x10000000
  296. #define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation
  297. #define CODEC_FLAG_SVCD_SCAN_OFFSET 0x40000000 ///< will reserve space for SVCD scan offset user data
  298. #define CODEC_FLAG_CLOSED_GOP ((int)0x80000000)
  299. #define CODEC_FLAG2_FAST 0x00000001 ///< allow non spec compliant speedup tricks
  300. #define CODEC_FLAG2_STRICT_GOP 0x00000002 ///< strictly enforce GOP size
  301. #define CODEC_FLAG2_NO_OUTPUT 0x00000004 ///< skip bitstream encoding
  302. #define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< place global headers at every keyframe instead of in extradata
  303. #define CODEC_FLAG2_BPYRAMID 0x00000010 ///< H.264 allow b-frames to be used as references
  304. #define CODEC_FLAG2_WPRED 0x00000020 ///< H.264 weighted biprediction for b-frames
  305. #define CODEC_FLAG2_MIXED_REFS 0x00000040 ///< H.264 multiple references per partition
  306. #define CODEC_FLAG2_8X8DCT 0x00000080 ///< H.264 high profile 8x8 transform
  307. #define CODEC_FLAG2_FASTPSKIP 0x00000100 ///< H.264 fast pskip
  308. #define CODEC_FLAG2_AUD 0x00000200 ///< H.264 access unit delimiters
  309. #define CODEC_FLAG2_BRDO 0x00000400 ///< b-frame rate-distortion optimization
  310. #define CODEC_FLAG2_INTRA_VLC 0x00000800 ///< use MPEG-2 intra VLC table
  311. #define CODEC_FLAG2_MEMC_ONLY 0x00001000 ///< only do ME/MC (I frames -> ref, P frame -> ME+MC)
  312. /* Unsupported options :
  313. * Syntax Arithmetic coding (SAC)
  314. * Reference Picture Selection
  315. * Independant Segment Decoding */
  316. /* /Fx */
  317. /* codec capabilities */
  318. #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< decoder can use draw_horiz_band callback
  319. /**
  320. * Codec uses get_buffer() for allocating buffers.
  321. * direct rendering method 1
  322. */
  323. #define CODEC_CAP_DR1 0x0002
  324. /* if 'parse_only' field is true, then avcodec_parse_frame() can be
  325. used */
  326. #define CODEC_CAP_PARSE_ONLY 0x0004
  327. #define CODEC_CAP_TRUNCATED 0x0008
  328. /* codec can export data for HW decoding (XvMC) */
  329. #define CODEC_CAP_HWACCEL 0x0010
  330. /**
  331. * codec has a non zero delay and needs to be feeded with NULL at the end to get the delayed data.
  332. * if this is not set, the codec is guranteed to never be feeded with NULL data
  333. */
  334. #define CODEC_CAP_DELAY 0x0020
  335. /**
  336. * Codec can be fed a final frame with a smaller size.
  337. * This can be used to prevent truncation of the last audio samples.
  338. */
  339. #define CODEC_CAP_SMALL_LAST_FRAME 0x0040
  340. //the following defines may change, don't expect compatibility if you use them
  341. #define MB_TYPE_INTRA4x4 0x0001
  342. #define MB_TYPE_INTRA16x16 0x0002 //FIXME h264 specific
  343. #define MB_TYPE_INTRA_PCM 0x0004 //FIXME h264 specific
  344. #define MB_TYPE_16x16 0x0008
  345. #define MB_TYPE_16x8 0x0010
  346. #define MB_TYPE_8x16 0x0020
  347. #define MB_TYPE_8x8 0x0040
  348. #define MB_TYPE_INTERLACED 0x0080
  349. #define MB_TYPE_DIRECT2 0x0100 //FIXME
  350. #define MB_TYPE_ACPRED 0x0200
  351. #define MB_TYPE_GMC 0x0400
  352. #define MB_TYPE_SKIP 0x0800
  353. #define MB_TYPE_P0L0 0x1000
  354. #define MB_TYPE_P1L0 0x2000
  355. #define MB_TYPE_P0L1 0x4000
  356. #define MB_TYPE_P1L1 0x8000
  357. #define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0)
  358. #define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1)
  359. #define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1)
  360. #define MB_TYPE_QUANT 0x00010000
  361. #define MB_TYPE_CBP 0x00020000
  362. //Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...)
  363. /**
  364. * Pan Scan area.
  365. * this specifies the area which should be displayed. Note there may be multiple such areas for one frame
  366. */
  367. typedef struct AVPanScan{
  368. /**
  369. * id.
  370. * - encoding: set by user.
  371. * - decoding: set by lavc
  372. */
  373. int id;
  374. /**
  375. * width and height in 1/16 pel
  376. * - encoding: set by user.
  377. * - decoding: set by lavc
  378. */
  379. int width;
  380. int height;
  381. /**
  382. * position of the top left corner in 1/16 pel for up to 3 fields/frames.
  383. * - encoding: set by user.
  384. * - decoding: set by lavc
  385. */
  386. int16_t position[3][2];
  387. }AVPanScan;
  388. #define FF_COMMON_FRAME \
  389. /**\
  390. * pointer to the picture planes.\
  391. * this might be different from the first allocated byte\
  392. * - encoding: \
  393. * - decoding: \
  394. */\
  395. uint8_t *data[4];\
  396. int linesize[4];\
  397. /**\
  398. * pointer to the first allocated byte of the picture. can be used in get_buffer/release_buffer\
  399. * this isn't used by lavc unless the default get/release_buffer() is used\
  400. * - encoding: \
  401. * - decoding: \
  402. */\
  403. uint8_t *base[4];\
  404. /**\
  405. * 1 -> keyframe, 0-> not\
  406. * - encoding: set by lavc\
  407. * - decoding: set by lavc\
  408. */\
  409. int key_frame;\
  410. \
  411. /**\
  412. * picture type of the frame, see ?_TYPE below.\
  413. * - encoding: set by lavc for coded_picture (and set by user for input)\
  414. * - decoding: set by lavc\
  415. */\
  416. int pict_type;\
  417. \
  418. /**\
  419. * presentation timestamp in time_base units (time when frame should be shown to user)\
  420. * if AV_NOPTS_VALUE then frame_rate = 1/time_base will be assumed\
  421. * - encoding: MUST be set by user\
  422. * - decoding: set by lavc\
  423. */\
  424. int64_t pts;\
  425. \
  426. /**\
  427. * picture number in bitstream order.\
  428. * - encoding: set by\
  429. * - decoding: set by lavc\
  430. */\
  431. int coded_picture_number;\
  432. /**\
  433. * picture number in display order.\
  434. * - encoding: set by\
  435. * - decoding: set by lavc\
  436. */\
  437. int display_picture_number;\
  438. \
  439. /**\
  440. * quality (between 1 (good) and FF_LAMBDA_MAX (bad)) \
  441. * - encoding: set by lavc for coded_picture (and set by user for input)\
  442. * - decoding: set by lavc\
  443. */\
  444. int quality; \
  445. \
  446. /**\
  447. * buffer age (1->was last buffer and dint change, 2->..., ...).\
  448. * set to INT_MAX if the buffer has not been used yet \
  449. * - encoding: unused\
  450. * - decoding: MUST be set by get_buffer()\
  451. */\
  452. int age;\
  453. \
  454. /**\
  455. * is this picture used as reference\
  456. * - encoding: unused\
  457. * - decoding: set by lavc (before get_buffer() call))\
  458. */\
  459. int reference;\
  460. \
  461. /**\
  462. * QP table\
  463. * - encoding: unused\
  464. * - decoding: set by lavc\
  465. */\
  466. int8_t *qscale_table;\
  467. /**\
  468. * QP store stride\
  469. * - encoding: unused\
  470. * - decoding: set by lavc\
  471. */\
  472. int qstride;\
  473. \
  474. /**\
  475. * mbskip_table[mb]>=1 if MB didnt change\
  476. * stride= mb_width = (width+15)>>4\
  477. * - encoding: unused\
  478. * - decoding: set by lavc\
  479. */\
  480. uint8_t *mbskip_table;\
  481. \
  482. /**\
  483. * Motion vector table.\
  484. * @code\
  485. * example:\
  486. * int mv_sample_log2= 4 - motion_subsample_log2;\
  487. * int mb_width= (width+15)>>4;\
  488. * int mv_stride= (mb_width << mv_sample_log2) + 1;\
  489. * motion_val[direction][x + y*mv_stride][0->mv_x, 1->mv_y];\
  490. * @endcode\
  491. * - encoding: set by user\
  492. * - decoding: set by lavc\
  493. */\
  494. int16_t (*motion_val[2])[2];\
  495. \
  496. /**\
  497. * Macroblock type table\
  498. * mb_type_base + mb_width + 2\
  499. * - encoding: set by user\
  500. * - decoding: set by lavc\
  501. */\
  502. uint32_t *mb_type;\
  503. \
  504. /**\
  505. * log2 of the size of the block which a single vector in motion_val represents: \
  506. * (4->16x16, 3->8x8, 2-> 4x4, 1-> 2x2)\
  507. * - encoding: unused\
  508. * - decoding: set by lavc\
  509. */\
  510. uint8_t motion_subsample_log2;\
  511. \
  512. /**\
  513. * for some private data of the user\
  514. * - encoding: unused\
  515. * - decoding: set by user\
  516. */\
  517. void *opaque;\
  518. \
  519. /**\
  520. * error\
  521. * - encoding: set by lavc if flags&CODEC_FLAG_PSNR\
  522. * - decoding: unused\
  523. */\
  524. uint64_t error[4];\
  525. \
  526. /**\
  527. * type of the buffer (to keep track of who has to dealloc data[*])\
  528. * - encoding: set by the one who allocs it\
  529. * - decoding: set by the one who allocs it\
  530. * Note: user allocated (direct rendering) & internal buffers can not coexist currently\
  531. */\
  532. int type;\
  533. \
  534. /**\
  535. * when decoding, this signal how much the picture must be delayed.\
  536. * extra_delay = repeat_pict / (2*fps)\
  537. * - encoding: unused\
  538. * - decoding: set by lavc\
  539. */\
  540. int repeat_pict;\
  541. \
  542. /**\
  543. * \
  544. */\
  545. int qscale_type;\
  546. \
  547. /**\
  548. * The content of the picture is interlaced.\
  549. * - encoding: set by user\
  550. * - decoding: set by lavc (default 0)\
  551. */\
  552. int interlaced_frame;\
  553. \
  554. /**\
  555. * if the content is interlaced, is top field displayed first.\
  556. * - encoding: set by user\
  557. * - decoding: set by lavc\
  558. */\
  559. int top_field_first;\
  560. \
  561. /**\
  562. * Pan scan.\
  563. * - encoding: set by user\
  564. * - decoding: set by lavc\
  565. */\
  566. AVPanScan *pan_scan;\
  567. \
  568. /**\
  569. * tell user application that palette has changed from previous frame.\
  570. * - encoding: ??? (no palette-enabled encoder yet)\
  571. * - decoding: set by lavc (default 0)\
  572. */\
  573. int palette_has_changed;\
  574. \
  575. /**\
  576. * Codec suggestion on buffer type if != 0\
  577. * - encoding: unused\
  578. * - decoding: set by lavc (before get_buffer() call))\
  579. */\
  580. int buffer_hints;\
  581. \
  582. /**\
  583. * DCT coeffitients\
  584. * - encoding: unused\
  585. * - decoding: set by lavc\
  586. */\
  587. short *dct_coeff;\
  588. \
  589. /**\
  590. * Motion referece frame index\
  591. * - encoding: set by user\
  592. * - decoding: set by lavc\
  593. */\
  594. int8_t *ref_index[2];
  595. #define FF_QSCALE_TYPE_MPEG1 0
  596. #define FF_QSCALE_TYPE_MPEG2 1
  597. #define FF_QSCALE_TYPE_H264 2
  598. #define FF_BUFFER_TYPE_INTERNAL 1
  599. #define FF_BUFFER_TYPE_USER 2 ///< Direct rendering buffers (image is (de)allocated by user)
  600. #define FF_BUFFER_TYPE_SHARED 4 ///< buffer from somewhere else, don't dealloc image (data/base), all other tables are not shared
  601. #define FF_BUFFER_TYPE_COPY 8 ///< just a (modified) copy of some other buffer, don't dealloc anything
  602. #define FF_I_TYPE 1 // Intra
  603. #define FF_P_TYPE 2 // Predicted
  604. #define FF_B_TYPE 3 // Bi-dir predicted
  605. #define FF_S_TYPE 4 // S(GMC)-VOP MPEG4
  606. #define FF_SI_TYPE 5
  607. #define FF_SP_TYPE 6
  608. #define FF_BUFFER_HINTS_VALID 0x01 // Buffer hints value is meaningful (if 0 ignore)
  609. #define FF_BUFFER_HINTS_READABLE 0x02 // Codec will read from buffer
  610. #define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content
  611. #define FF_BUFFER_HINTS_REUSABLE 0x08 // Codec will reuse the buffer (update)
  612. /**
  613. * Audio Video Frame.
  614. */
  615. typedef struct AVFrame {
  616. FF_COMMON_FRAME
  617. } AVFrame;
  618. #define DEFAULT_FRAME_RATE_BASE 1001000
  619. /**
  620. * main external api structure.
  621. */
  622. typedef struct AVCodecContext {
  623. /**
  624. * Info on struct for av_log
  625. * - set by avcodec_alloc_context
  626. */
  627. AVClass *av_class;
  628. /**
  629. * the average bitrate.
  630. * - encoding: set by user. unused for constant quantizer encoding
  631. * - decoding: set by lavc. 0 or some bitrate if this info is available in the stream
  632. */
  633. int bit_rate;
  634. /**
  635. * number of bits the bitstream is allowed to diverge from the reference.
  636. * the reference can be CBR (for CBR pass1) or VBR (for pass2)
  637. * - encoding: set by user. unused for constant quantizer encoding
  638. * - decoding: unused
  639. */
  640. int bit_rate_tolerance;
  641. /**
  642. * CODEC_FLAG_*.
  643. * - encoding: set by user.
  644. * - decoding: set by user.
  645. */
  646. int flags;
  647. /**
  648. * some codecs needs additionnal format info. It is stored here
  649. * - encoding: set by user.
  650. * - decoding: set by lavc. (FIXME is this ok?)
  651. */
  652. int sub_id;
  653. /**
  654. * motion estimation algorithm used for video coding.
  655. * 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex),
  656. * 8 (umh), 9 (iter) [7, 8 are x264 specific, 9 is snow specific]
  657. * - encoding: MUST be set by user.
  658. * - decoding: unused
  659. */
  660. int me_method;
  661. /**
  662. * some codecs need / can use extra-data like huffman tables.
  663. * mjpeg: huffman tables
  664. * rv10: additional flags
  665. * mpeg4: global headers (they can be in the bitstream or here)
  666. * the allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger
  667. * then extradata_size to avoid prolems if its read with the bitstream reader
  668. * the bytewise contents of extradata must not depend on the architecture or cpu endianness
  669. * - encoding: set/allocated/freed by lavc.
  670. * - decoding: set/allocated/freed by user.
  671. */
  672. void *extradata;
  673. int extradata_size;
  674. /**
  675. * this is the fundamental unit of time (in seconds) in terms
  676. * of which frame timestamps are represented. for fixed-fps content,
  677. * timebase should be 1/framerate and timestamp increments should be
  678. * identically 1.
  679. * - encoding: MUST be set by user
  680. * - decoding: set by lavc.
  681. */
  682. AVRational time_base;
  683. /* video only */
  684. /**
  685. * picture width / height.
  686. * - encoding: MUST be set by user.
  687. * - decoding: set by lavc.
  688. * Note, for compatibility its possible to set this instead of
  689. * coded_width/height before decoding
  690. */
  691. int width, height;
  692. #define FF_ASPECT_EXTENDED 15
  693. /**
  694. * the number of pictures in a group of pitures, or 0 for intra_only.
  695. * - encoding: set by user.
  696. * - decoding: unused
  697. */
  698. int gop_size;
  699. /**
  700. * pixel format, see PIX_FMT_xxx.
  701. * - encoding: set by user.
  702. * - decoding: set by lavc.
  703. */
  704. enum PixelFormat pix_fmt;
  705. /**
  706. * Frame rate emulation. If not zero lower layer (i.e. format handler)
  707. * has to read frames at native frame rate.
  708. * - encoding: set by user.
  709. * - decoding: unused.
  710. */
  711. int rate_emu;
  712. /**
  713. * if non NULL, 'draw_horiz_band' is called by the libavcodec
  714. * decoder to draw an horizontal band. It improve cache usage. Not
  715. * all codecs can do that. You must check the codec capabilities
  716. * before
  717. * - encoding: unused
  718. * - decoding: set by user.
  719. * @param height the height of the slice
  720. * @param y the y position of the slice
  721. * @param type 1->top field, 2->bottom field, 3->frame
  722. * @param offset offset into the AVFrame.data from which the slice should be read
  723. */
  724. void (*draw_horiz_band)(struct AVCodecContext *s,
  725. const AVFrame *src, int offset[4],
  726. int y, int type, int height);
  727. /* audio only */
  728. int sample_rate; ///< samples per sec
  729. int channels;
  730. /**
  731. * audio sample format.
  732. * - encoding: set by user.
  733. * - decoding: set by lavc.
  734. */
  735. enum SampleFormat sample_fmt; ///< sample format, currenly unused
  736. /* the following data should not be initialized */
  737. /**
  738. * samples per packet. initialized when calling 'init'
  739. */
  740. int frame_size;
  741. int frame_number; ///< audio or video frame number
  742. int real_pict_num; ///< returns the real picture number of previous encoded frame
  743. /**
  744. * number of frames the decoded output will be delayed relative to
  745. * the encoded input.
  746. * - encoding: set by lavc.
  747. * - decoding: unused
  748. */
  749. int delay;
  750. /* - encoding parameters */
  751. float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)
  752. float qblur; ///< amount of qscale smoothing over time (0.0-1.0)
  753. /**
  754. * minimum quantizer.
  755. * - encoding: set by user.
  756. * - decoding: unused
  757. */
  758. int qmin;
  759. /**
  760. * maximum quantizer.
  761. * - encoding: set by user.
  762. * - decoding: unused
  763. */
  764. int qmax;
  765. /**
  766. * maximum quantizer difference etween frames.
  767. * - encoding: set by user.
  768. * - decoding: unused
  769. */
  770. int max_qdiff;
  771. /**
  772. * maximum number of b frames between non b frames.
  773. * note: the output will be delayed by max_b_frames+1 relative to the input
  774. * - encoding: set by user.
  775. * - decoding: unused
  776. */
  777. int max_b_frames;
  778. /**
  779. * qscale factor between ip and b frames.
  780. * - encoding: set by user.
  781. * - decoding: unused
  782. */
  783. float b_quant_factor;
  784. /** obsolete FIXME remove */
  785. int rc_strategy;
  786. #define FF_RC_STRATEGY_XVID 1
  787. int b_frame_strategy;
  788. /**
  789. * hurry up amount.
  790. * deprecated in favor of skip_idct and skip_frame
  791. * - encoding: unused
  792. * - decoding: set by user. 1-> skip b frames, 2-> skip idct/dequant too, 5-> skip everything except header
  793. */
  794. int hurry_up;
  795. struct AVCodec *codec;
  796. void *priv_data;
  797. /* unused, FIXME remove*/
  798. int rtp_mode;
  799. int rtp_payload_size; /* The size of the RTP payload: the coder will */
  800. /* do it's best to deliver a chunk with size */
  801. /* below rtp_payload_size, the chunk will start */
  802. /* with a start code on some codecs like H.263 */
  803. /* This doesn't take account of any particular */
  804. /* headers inside the transmited RTP payload */
  805. /* The RTP callback: This function is called */
  806. /* every time the encoder has a packet to send */
  807. /* Depends on the encoder if the data starts */
  808. /* with a Start Code (it should) H.263 does. */
  809. /* mb_nb contains the number of macroblocks */
  810. /* encoded in the RTP payload */
  811. void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb);
  812. /* statistics, used for 2-pass encoding */
  813. int mv_bits;
  814. int header_bits;
  815. int i_tex_bits;
  816. int p_tex_bits;
  817. int i_count;
  818. int p_count;
  819. int skip_count;
  820. int misc_bits;
  821. /**
  822. * number of bits used for the previously encoded frame.
  823. * - encoding: set by lavc
  824. * - decoding: unused
  825. */
  826. int frame_bits;
  827. /**
  828. * private data of the user, can be used to carry app specific stuff.
  829. * - encoding: set by user
  830. * - decoding: set by user
  831. */
  832. void *opaque;
  833. char codec_name[32];
  834. enum CodecType codec_type; /* see CODEC_TYPE_xxx */
  835. enum CodecID codec_id; /* see CODEC_ID_xxx */
  836. /**
  837. * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
  838. * this is used to workaround some encoder bugs
  839. * - encoding: set by user, if not then the default based on codec_id will be used
  840. * - decoding: set by user, will be converted to upper case by lavc during init
  841. */
  842. unsigned int codec_tag;
  843. /**
  844. * workaround bugs in encoders which sometimes cannot be detected automatically.
  845. * - encoding: set by user
  846. * - decoding: set by user
  847. */
  848. int workaround_bugs;
  849. #define FF_BUG_AUTODETECT 1 ///< autodetection
  850. #define FF_BUG_OLD_MSMPEG4 2
  851. #define FF_BUG_XVID_ILACE 4
  852. #define FF_BUG_UMP4 8
  853. #define FF_BUG_NO_PADDING 16
  854. #define FF_BUG_AMV 32
  855. #define FF_BUG_AC_VLC 0 ///< will be removed, libavcodec can now handle these non compliant files by default
  856. #define FF_BUG_QPEL_CHROMA 64
  857. #define FF_BUG_STD_QPEL 128
  858. #define FF_BUG_QPEL_CHROMA2 256
  859. #define FF_BUG_DIRECT_BLOCKSIZE 512
  860. #define FF_BUG_EDGE 1024
  861. #define FF_BUG_HPEL_CHROMA 2048
  862. #define FF_BUG_DC_CLIP 4096
  863. #define FF_BUG_MS 8192 ///< workaround various bugs in microsofts broken decoders
  864. //#define FF_BUG_FAKE_SCALABILITY 16 //autodetection should work 100%
  865. /**
  866. * luma single coeff elimination threshold.
  867. * - encoding: set by user
  868. * - decoding: unused
  869. */
  870. int luma_elim_threshold;
  871. /**
  872. * chroma single coeff elimination threshold.
  873. * - encoding: set by user
  874. * - decoding: unused
  875. */
  876. int chroma_elim_threshold;
  877. /**
  878. * strictly follow the std (MPEG4, ...).
  879. * - encoding: set by user
  880. * - decoding: unused
  881. */
  882. int strict_std_compliance;
  883. #define FF_COMPLIANCE_VERY_STRICT 2 ///< strictly conform to a older more strict version of the spec or reference software
  884. #define FF_COMPLIANCE_STRICT 1 ///< strictly conform to all the things in the spec no matter what consequences
  885. #define FF_COMPLIANCE_NORMAL 0
  886. #define FF_COMPLIANCE_INOFFICIAL -1 ///< allow inofficial extensions
  887. #define FF_COMPLIANCE_EXPERIMENTAL -2 ///< allow non standarized experimental things
  888. /**
  889. * qscale offset between ip and b frames.
  890. * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
  891. * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
  892. * - encoding: set by user.
  893. * - decoding: unused
  894. */
  895. float b_quant_offset;
  896. /**
  897. * error resilience higher values will detect more errors but may missdetect
  898. * some more or less valid parts as errors.
  899. * - encoding: unused
  900. * - decoding: set by user
  901. */
  902. int error_resilience;
  903. #define FF_ER_CAREFUL 1
  904. #define FF_ER_COMPLIANT 2
  905. #define FF_ER_AGGRESSIVE 3
  906. #define FF_ER_VERY_AGGRESSIVE 4
  907. /**
  908. * called at the beginning of each frame to get a buffer for it.
  909. * if pic.reference is set then the frame will be read later by lavc
  910. * avcodec_align_dimensions() should be used to find the required width and
  911. * height, as they normally need to be rounded up to the next multiple of 16
  912. * - encoding: unused
  913. * - decoding: set by lavc, user can override
  914. */
  915. int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
  916. /**
  917. * called to release buffers which where allocated with get_buffer.
  918. * a released buffer can be reused in get_buffer()
  919. * pic.data[*] must be set to NULL
  920. * - encoding: unused
  921. * - decoding: set by lavc, user can override
  922. */
  923. void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
  924. /**
  925. * if 1 the stream has a 1 frame delay during decoding.
  926. * - encoding: set by lavc
  927. * - decoding: set by lavc
  928. */
  929. int has_b_frames;
  930. /**
  931. * number of bytes per packet if constant and known or 0
  932. * used by some WAV based audio codecs
  933. */
  934. int block_align;
  935. int parse_only; /* - decoding only: if true, only parsing is done
  936. (function avcodec_parse_frame()). The frame
  937. data is returned. Only MPEG codecs support this now. */
  938. /**
  939. * 0-> h263 quant 1-> mpeg quant.
  940. * - encoding: set by user.
  941. * - decoding: unused
  942. */
  943. int mpeg_quant;
  944. /**
  945. * pass1 encoding statistics output buffer.
  946. * - encoding: set by lavc
  947. * - decoding: unused
  948. */
  949. char *stats_out;
  950. /**
  951. * pass2 encoding statistics input buffer.
  952. * concatenated stuff from stats_out of pass1 should be placed here
  953. * - encoding: allocated/set/freed by user
  954. * - decoding: unused
  955. */
  956. char *stats_in;
  957. /**
  958. * ratecontrol qmin qmax limiting method.
  959. * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax
  960. * - encoding: set by user.
  961. * - decoding: unused
  962. */
  963. float rc_qsquish;
  964. float rc_qmod_amp;
  965. int rc_qmod_freq;
  966. /**
  967. * ratecontrol override, see RcOverride.
  968. * - encoding: allocated/set/freed by user.
  969. * - decoding: unused
  970. */
  971. RcOverride *rc_override;
  972. int rc_override_count;
  973. /**
  974. * rate control equation.
  975. * - encoding: set by user
  976. * - decoding: unused
  977. */
  978. char *rc_eq;
  979. /**
  980. * maximum bitrate.
  981. * - encoding: set by user.
  982. * - decoding: unused
  983. */
  984. int rc_max_rate;
  985. /**
  986. * minimum bitrate.
  987. * - encoding: set by user.
  988. * - decoding: unused
  989. */
  990. int rc_min_rate;
  991. /**
  992. * decoder bitstream buffer size.
  993. * - encoding: set by user.
  994. * - decoding: unused
  995. */
  996. int rc_buffer_size;
  997. float rc_buffer_aggressivity;
  998. /**
  999. * qscale factor between p and i frames.
  1000. * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
  1001. * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
  1002. * - encoding: set by user.
  1003. * - decoding: unused
  1004. */
  1005. float i_quant_factor;
  1006. /**
  1007. * qscale offset between p and i frames.
  1008. * - encoding: set by user.
  1009. * - decoding: unused
  1010. */
  1011. float i_quant_offset;
  1012. /**
  1013. * initial complexity for pass1 ratecontrol.
  1014. * - encoding: set by user.
  1015. * - decoding: unused
  1016. */
  1017. float rc_initial_cplx;
  1018. /**
  1019. * dct algorithm, see FF_DCT_* below.
  1020. * - encoding: set by user
  1021. * - decoding: unused
  1022. */
  1023. int dct_algo;
  1024. #define FF_DCT_AUTO 0
  1025. #define FF_DCT_FASTINT 1
  1026. #define FF_DCT_INT 2
  1027. #define FF_DCT_MMX 3
  1028. #define FF_DCT_MLIB 4
  1029. #define FF_DCT_ALTIVEC 5
  1030. #define FF_DCT_FAAN 6
  1031. /**
  1032. * luminance masking (0-> disabled).
  1033. * - encoding: set by user
  1034. * - decoding: unused
  1035. */
  1036. float lumi_masking;
  1037. /**
  1038. * temporary complexity masking (0-> disabled).
  1039. * - encoding: set by user
  1040. * - decoding: unused
  1041. */
  1042. float temporal_cplx_masking;
  1043. /**
  1044. * spatial complexity masking (0-> disabled).
  1045. * - encoding: set by user
  1046. * - decoding: unused
  1047. */
  1048. float spatial_cplx_masking;
  1049. /**
  1050. * p block masking (0-> disabled).
  1051. * - encoding: set by user
  1052. * - decoding: unused
  1053. */
  1054. float p_masking;
  1055. /**
  1056. * darkness masking (0-> disabled).
  1057. * - encoding: set by user
  1058. * - decoding: unused
  1059. */
  1060. float dark_masking;
  1061. /* for binary compatibility */
  1062. int unused;
  1063. /**
  1064. * idct algorithm, see FF_IDCT_* below.
  1065. * - encoding: set by user
  1066. * - decoding: set by user
  1067. */
  1068. int idct_algo;
  1069. #define FF_IDCT_AUTO 0
  1070. #define FF_IDCT_INT 1
  1071. #define FF_IDCT_SIMPLE 2
  1072. #define FF_IDCT_SIMPLEMMX 3
  1073. #define FF_IDCT_LIBMPEG2MMX 4
  1074. #define FF_IDCT_PS2 5
  1075. #define FF_IDCT_MLIB 6
  1076. #define FF_IDCT_ARM 7
  1077. #define FF_IDCT_ALTIVEC 8
  1078. #define FF_IDCT_SH4 9
  1079. #define FF_IDCT_SIMPLEARM 10
  1080. #define FF_IDCT_H264 11
  1081. #define FF_IDCT_VP3 12
  1082. #define FF_IDCT_IPP 13
  1083. #define FF_IDCT_XVIDMMX 14
  1084. #define FF_IDCT_CAVS 15
  1085. /**
  1086. * slice count.
  1087. * - encoding: set by lavc
  1088. * - decoding: set by user (or 0)
  1089. */
  1090. int slice_count;
  1091. /**
  1092. * slice offsets in the frame in bytes.
  1093. * - encoding: set/allocated by lavc
  1094. * - decoding: set/allocated by user (or NULL)
  1095. */
  1096. int *slice_offset;
  1097. /**
  1098. * error concealment flags.
  1099. * - encoding: unused
  1100. * - decoding: set by user
  1101. */
  1102. int error_concealment;
  1103. #define FF_EC_GUESS_MVS 1
  1104. #define FF_EC_DEBLOCK 2
  1105. /**
  1106. * dsp_mask could be add used to disable unwanted CPU features
  1107. * CPU features (i.e. MMX, SSE. ...)
  1108. *
  1109. * with FORCE flag you may instead enable given CPU features
  1110. * (Dangerous: usable in case of misdetection, improper usage however will
  1111. * result into program crash)
  1112. */
  1113. unsigned dsp_mask;
  1114. #define FF_MM_FORCE 0x80000000 /* force usage of selected flags (OR) */
  1115. /* lower 16 bits - CPU features */
  1116. #ifdef HAVE_MMX
  1117. #define FF_MM_MMX 0x0001 /* standard MMX */
  1118. #define FF_MM_3DNOW 0x0004 /* AMD 3DNOW */
  1119. #define FF_MM_MMXEXT 0x0002 /* SSE integer functions or AMD MMX ext */
  1120. #define FF_MM_SSE 0x0008 /* SSE functions */
  1121. #define FF_MM_SSE2 0x0010 /* PIV SSE2 functions */
  1122. #define FF_MM_3DNOWEXT 0x0020 /* AMD 3DNowExt */
  1123. #endif /* HAVE_MMX */
  1124. #ifdef HAVE_IWMMXT
  1125. #define FF_MM_IWMMXT 0x0100 /* XScale IWMMXT */
  1126. #endif /* HAVE_IWMMXT */
  1127. /**
  1128. * bits per sample/pixel from the demuxer (needed for huffyuv).
  1129. * - encoding: set by lavc
  1130. * - decoding: set by user
  1131. */
  1132. int bits_per_sample;
  1133. /**
  1134. * prediction method (needed for huffyuv).
  1135. * - encoding: set by user
  1136. * - decoding: unused
  1137. */
  1138. int prediction_method;
  1139. #define FF_PRED_LEFT 0
  1140. #define FF_PRED_PLANE 1
  1141. #define FF_PRED_MEDIAN 2
  1142. /**
  1143. * sample aspect ratio (0 if unknown).
  1144. * numerator and denominator must be relative prime and smaller then 256 for some video standards
  1145. * - encoding: set by user.
  1146. * - decoding: set by lavc.
  1147. */
  1148. AVRational sample_aspect_ratio;
  1149. /**
  1150. * the picture in the bitstream.
  1151. * - encoding: set by lavc
  1152. * - decoding: set by lavc
  1153. */
  1154. AVFrame *coded_frame;
  1155. /**
  1156. * debug.
  1157. * - encoding: set by user.
  1158. * - decoding: set by user.
  1159. */
  1160. int debug;
  1161. #define FF_DEBUG_PICT_INFO 1
  1162. #define FF_DEBUG_RC 2
  1163. #define FF_DEBUG_BITSTREAM 4
  1164. #define FF_DEBUG_MB_TYPE 8
  1165. #define FF_DEBUG_QP 16
  1166. #define FF_DEBUG_MV 32
  1167. #define FF_DEBUG_DCT_COEFF 0x00000040
  1168. #define FF_DEBUG_SKIP 0x00000080
  1169. #define FF_DEBUG_STARTCODE 0x00000100
  1170. #define FF_DEBUG_PTS 0x00000200
  1171. #define FF_DEBUG_ER 0x00000400
  1172. #define FF_DEBUG_MMCO 0x00000800
  1173. #define FF_DEBUG_BUGS 0x00001000
  1174. #define FF_DEBUG_VIS_QP 0x00002000
  1175. #define FF_DEBUG_VIS_MB_TYPE 0x00004000
  1176. /**
  1177. * debug.
  1178. * - encoding: set by user.
  1179. * - decoding: set by user.
  1180. */
  1181. int debug_mv;
  1182. #define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames
  1183. #define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames
  1184. #define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames
  1185. /**
  1186. * error.
  1187. * - encoding: set by lavc if flags&CODEC_FLAG_PSNR
  1188. * - decoding: unused
  1189. */
  1190. uint64_t error[4];
  1191. /**
  1192. * minimum MB quantizer.
  1193. * - encoding: unused
  1194. * - decoding: unused
  1195. */
  1196. int mb_qmin;
  1197. /**
  1198. * maximum MB quantizer.
  1199. * - encoding: unused
  1200. * - decoding: unused
  1201. */
  1202. int mb_qmax;
  1203. /**
  1204. * motion estimation compare function.
  1205. * - encoding: set by user.
  1206. * - decoding: unused
  1207. */
  1208. int me_cmp;
  1209. /**
  1210. * subpixel motion estimation compare function.
  1211. * - encoding: set by user.
  1212. * - decoding: unused
  1213. */
  1214. int me_sub_cmp;
  1215. /**
  1216. * macroblock compare function (not supported yet).
  1217. * - encoding: set by user.
  1218. * - decoding: unused
  1219. */
  1220. int mb_cmp;
  1221. /**
  1222. * interlaced dct compare function
  1223. * - encoding: set by user.
  1224. * - decoding: unused
  1225. */
  1226. int ildct_cmp;
  1227. #define FF_CMP_SAD 0
  1228. #define FF_CMP_SSE 1
  1229. #define FF_CMP_SATD 2
  1230. #define FF_CMP_DCT 3
  1231. #define FF_CMP_PSNR 4
  1232. #define FF_CMP_BIT 5
  1233. #define FF_CMP_RD 6
  1234. #define FF_CMP_ZERO 7
  1235. #define FF_CMP_VSAD 8
  1236. #define FF_CMP_VSSE 9
  1237. #define FF_CMP_NSSE 10
  1238. #define FF_CMP_W53 11
  1239. #define FF_CMP_W97 12
  1240. #define FF_CMP_DCTMAX 13
  1241. #define FF_CMP_DCT264 14
  1242. #define FF_CMP_CHROMA 256
  1243. /**
  1244. * ME diamond size & shape.
  1245. * - encoding: set by user.
  1246. * - decoding: unused
  1247. */
  1248. int dia_size;
  1249. /**
  1250. * amount of previous MV predictors (2a+1 x 2a+1 square).
  1251. * - encoding: set by user.
  1252. * - decoding: unused
  1253. */
  1254. int last_predictor_count;
  1255. /**
  1256. * pre pass for motion estimation.
  1257. * - encoding: set by user.
  1258. * - decoding: unused
  1259. */
  1260. int pre_me;
  1261. /**
  1262. * motion estimation pre pass compare function.
  1263. * - encoding: set by user.
  1264. * - decoding: unused
  1265. */
  1266. int me_pre_cmp;
  1267. /**
  1268. * ME pre pass diamond size & shape.
  1269. * - encoding: set by user.
  1270. * - decoding: unused
  1271. */
  1272. int pre_dia_size;
  1273. /**
  1274. * subpel ME quality.
  1275. * - encoding: set by user.
  1276. * - decoding: unused
  1277. */
  1278. int me_subpel_quality;
  1279. /**
  1280. * callback to negotiate the pixelFormat.
  1281. * @param fmt is the list of formats which are supported by the codec,
  1282. * its terminated by -1 as 0 is a valid format, the formats are ordered by quality
  1283. * the first is allways the native one
  1284. * @return the choosen format
  1285. * - encoding: unused
  1286. * - decoding: set by user, if not set then the native format will always be choosen
  1287. */
  1288. enum PixelFormat (*get_format)(struct AVCodecContext *s, const enum PixelFormat * fmt);
  1289. /**
  1290. * DTG active format information (additionnal aspect ratio
  1291. * information only used in DVB MPEG2 transport streams). 0 if
  1292. * not set.
  1293. *
  1294. * - encoding: unused.
  1295. * - decoding: set by decoder
  1296. */
  1297. int dtg_active_format;
  1298. #define FF_DTG_AFD_SAME 8
  1299. #define FF_DTG_AFD_4_3 9
  1300. #define FF_DTG_AFD_16_9 10
  1301. #define FF_DTG_AFD_14_9 11
  1302. #define FF_DTG_AFD_4_3_SP_14_9 13
  1303. #define FF_DTG_AFD_16_9_SP_14_9 14
  1304. #define FF_DTG_AFD_SP_4_3 15
  1305. /**
  1306. * Maximum motion estimation search range in subpel units.
  1307. * if 0 then no limit
  1308. *
  1309. * - encoding: set by user.
  1310. * - decoding: unused.
  1311. */
  1312. int me_range;
  1313. /**
  1314. * intra quantizer bias.
  1315. * - encoding: set by user.
  1316. * - decoding: unused
  1317. */
  1318. int intra_quant_bias;
  1319. #define FF_DEFAULT_QUANT_BIAS 999999
  1320. /**
  1321. * inter quantizer bias.
  1322. * - encoding: set by user.
  1323. * - decoding: unused
  1324. */
  1325. int inter_quant_bias;
  1326. /**
  1327. * color table ID.
  1328. * - encoding: unused.
  1329. * - decoding: which clrtable should be used for 8bit RGB images
  1330. * table have to be stored somewhere FIXME
  1331. */
  1332. int color_table_id;
  1333. /**
  1334. * internal_buffer count.
  1335. * Don't touch, used by lavc default_get_buffer()
  1336. */
  1337. int internal_buffer_count;
  1338. /**
  1339. * internal_buffers.
  1340. * Don't touch, used by lavc default_get_buffer()
  1341. */
  1342. void *internal_buffer;
  1343. #define FF_LAMBDA_SHIFT 7
  1344. #define FF_LAMBDA_SCALE (1<<FF_LAMBDA_SHIFT)
  1345. #define FF_QP2LAMBDA 118 ///< factor to convert from H.263 QP to lambda
  1346. #define FF_LAMBDA_MAX (256*128-1)
  1347. #define FF_QUALITY_SCALE FF_LAMBDA_SCALE //FIXME maybe remove
  1348. /**
  1349. * global quality for codecs which cannot change it per frame.
  1350. * this should be proportional to MPEG1/2/4 qscale.
  1351. * - encoding: set by user.
  1352. * - decoding: unused
  1353. */
  1354. int global_quality;
  1355. #define FF_CODER_TYPE_VLC 0
  1356. #define FF_CODER_TYPE_AC 1
  1357. /**
  1358. * coder type
  1359. * - encoding: set by user.
  1360. * - decoding: unused
  1361. */
  1362. int coder_type;
  1363. /**
  1364. * context model
  1365. * - encoding: set by user.
  1366. * - decoding: unused
  1367. */
  1368. int context_model;
  1369. #if 0
  1370. /**
  1371. *
  1372. * - encoding: unused
  1373. * - decoding: set by user.
  1374. */
  1375. uint8_t * (*realloc)(struct AVCodecContext *s, uint8_t *buf, int buf_size);
  1376. #endif
  1377. /**
  1378. * slice flags
  1379. * - encoding: unused
  1380. * - decoding: set by user.
  1381. */
  1382. int slice_flags;
  1383. #define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display
  1384. #define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics)
  1385. #define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
  1386. /**
  1387. * XVideo Motion Acceleration
  1388. * - encoding: forbidden
  1389. * - decoding: set by decoder
  1390. */
  1391. int xvmc_acceleration;
  1392. /**
  1393. * macroblock decision mode
  1394. * - encoding: set by user.
  1395. * - decoding: unused
  1396. */
  1397. int mb_decision;
  1398. #define FF_MB_DECISION_SIMPLE 0 ///< uses mb_cmp
  1399. #define FF_MB_DECISION_BITS 1 ///< chooses the one which needs the fewest bits
  1400. #define FF_MB_DECISION_RD 2 ///< rate distoration
  1401. /**
  1402. * custom intra quantization matrix
  1403. * - encoding: set by user, can be NULL
  1404. * - decoding: set by lavc
  1405. */
  1406. uint16_t *intra_matrix;
  1407. /**
  1408. * custom inter quantization matrix
  1409. * - encoding: set by user, can be NULL
  1410. * - decoding: set by lavc
  1411. */
  1412. uint16_t *inter_matrix;
  1413. /**
  1414. * fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
  1415. * this is used to workaround some encoder bugs
  1416. * - encoding: unused
  1417. * - decoding: set by user, will be converted to upper case by lavc during init
  1418. */
  1419. unsigned int stream_codec_tag;
  1420. /**
  1421. * scene change detection threshold.
  1422. * 0 is default, larger means fewer detected scene changes
  1423. * - encoding: set by user.
  1424. * - decoding: unused
  1425. */
  1426. int scenechange_threshold;
  1427. /**
  1428. * minimum lagrange multipler
  1429. * - encoding: set by user.
  1430. * - decoding: unused
  1431. */
  1432. int lmin;
  1433. /**
  1434. * maximum lagrange multipler
  1435. * - encoding: set by user.
  1436. * - decoding: unused
  1437. */
  1438. int lmax;
  1439. /**
  1440. * Palette control structure
  1441. * - encoding: ??? (no palette-enabled encoder yet)
  1442. * - decoding: set by user.
  1443. */
  1444. struct AVPaletteControl *palctrl;
  1445. /**
  1446. * noise reduction strength
  1447. * - encoding: set by user.
  1448. * - decoding: unused
  1449. */
  1450. int noise_reduction;
  1451. /**
  1452. * called at the beginning of a frame to get cr buffer for it.
  1453. * buffer type (size, hints) must be the same. lavc won't check it.
  1454. * lavc will pass previous buffer in pic, function should return
  1455. * same buffer or new buffer with old frame "painted" into it.
  1456. * if pic.data[0] == NULL must behave like get_buffer().
  1457. * - encoding: unused
  1458. * - decoding: set by lavc, user can override
  1459. */
  1460. int (*reget_buffer)(struct AVCodecContext *c, AVFrame *pic);
  1461. /**
  1462. * number of bits which should be loaded into the rc buffer before decoding starts
  1463. * - encoding: set by user.
  1464. * - decoding: unused
  1465. */
  1466. int rc_initial_buffer_occupancy;
  1467. /**
  1468. *
  1469. * - encoding: set by user.
  1470. * - decoding: unused
  1471. */
  1472. int inter_threshold;
  1473. /**
  1474. * CODEC_FLAG2_*.
  1475. * - encoding: set by user.
  1476. * - decoding: set by user.
  1477. */
  1478. int flags2;
  1479. /**
  1480. * simulates errors in the bitstream to test error concealment.
  1481. * - encoding: set by user.
  1482. * - decoding: unused.
  1483. */
  1484. int error_rate;
  1485. /**
  1486. * MP3 antialias algorithm, see FF_AA_* below.
  1487. * - encoding: unused
  1488. * - decoding: set by user
  1489. */
  1490. int antialias_algo;
  1491. #define FF_AA_AUTO 0
  1492. #define FF_AA_FASTINT 1 //not implemented yet
  1493. #define FF_AA_INT 2
  1494. #define FF_AA_FLOAT 3
  1495. /**
  1496. * Quantizer noise shaping.
  1497. * - encoding: set by user
  1498. * - decoding: unused
  1499. */
  1500. int quantizer_noise_shaping;
  1501. /**
  1502. * Thread count.
  1503. * is used to decide how many independant tasks should be passed to execute()
  1504. * - encoding: set by user
  1505. * - decoding: set by user
  1506. */
  1507. int thread_count;
  1508. /**
  1509. * the codec may call this to execute several independant things. it will return only after
  1510. * finishing all tasks, the user may replace this with some multithreaded implementation, the
  1511. * default implementation will execute the parts serially
  1512. * @param count the number of things to execute
  1513. * - encoding: set by lavc, user can override
  1514. * - decoding: set by lavc, user can override
  1515. */
  1516. int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void **arg2, int *ret, int count);
  1517. /**
  1518. * Thread opaque.
  1519. * can be used by execute() to store some per AVCodecContext stuff.
  1520. * - encoding: set by execute()
  1521. * - decoding: set by execute()
  1522. */
  1523. void *thread_opaque;
  1524. /**
  1525. * Motion estimation threshold. under which no motion estimation is
  1526. * performed, but instead the user specified motion vectors are used
  1527. *
  1528. * - encoding: set by user
  1529. * - decoding: unused
  1530. */
  1531. int me_threshold;
  1532. /**
  1533. * Macroblock threshold. under which the user specified macroblock types will be used
  1534. * - encoding: set by user
  1535. * - decoding: unused
  1536. */
  1537. int mb_threshold;
  1538. /**
  1539. * precision of the intra dc coefficient - 8.
  1540. * - encoding: set by user
  1541. * - decoding: unused
  1542. */
  1543. int intra_dc_precision;
  1544. /**
  1545. * noise vs. sse weight for the nsse comparsion function.
  1546. * - encoding: set by user
  1547. * - decoding: unused
  1548. */
  1549. int nsse_weight;
  1550. /**
  1551. * number of macroblock rows at the top which are skipped.
  1552. * - encoding: unused
  1553. * - decoding: set by user
  1554. */
  1555. int skip_top;
  1556. /**
  1557. * number of macroblock rows at the bottom which are skipped.
  1558. * - encoding: unused
  1559. * - decoding: set by user
  1560. */
  1561. int skip_bottom;
  1562. /**
  1563. * profile
  1564. * - encoding: set by user
  1565. * - decoding: set by lavc
  1566. */
  1567. int profile;
  1568. #define FF_PROFILE_UNKNOWN -99
  1569. /**
  1570. * level
  1571. * - encoding: set by user
  1572. * - decoding: set by lavc
  1573. */
  1574. int level;
  1575. #define FF_LEVEL_UNKNOWN -99
  1576. /**
  1577. * low resolution decoding. 1-> 1/2 size, 2->1/4 size
  1578. * - encoding: unused
  1579. * - decoding: set by user
  1580. */
  1581. int lowres;
  1582. /**
  1583. * bitsream width / height. may be different from width/height if lowres
  1584. * or other things are used
  1585. * - encoding: unused
  1586. * - decoding: set by user before init if known, codec should override / dynamically change if needed
  1587. */
  1588. int coded_width, coded_height;
  1589. /**
  1590. * frame skip threshold
  1591. * - encoding: set by user
  1592. * - decoding: unused
  1593. */
  1594. int frame_skip_threshold;
  1595. /**
  1596. * frame skip factor
  1597. * - encoding: set by user
  1598. * - decoding: unused
  1599. */
  1600. int frame_skip_factor;
  1601. /**
  1602. * frame skip exponent
  1603. * - encoding: set by user
  1604. * - decoding: unused
  1605. */
  1606. int frame_skip_exp;
  1607. /**
  1608. * frame skip comparission function
  1609. * - encoding: set by user.
  1610. * - decoding: unused
  1611. */
  1612. int frame_skip_cmp;
  1613. /**
  1614. * border processing masking. raises the quantizer for mbs on the borders
  1615. * of the picture.
  1616. * - encoding: set by user
  1617. * - decoding: unused
  1618. */
  1619. float border_masking;
  1620. /**
  1621. * minimum MB lagrange multipler.
  1622. * - encoding: set by user.
  1623. * - decoding: unused
  1624. */
  1625. int mb_lmin;
  1626. /**
  1627. * maximum MB lagrange multipler.
  1628. * - encoding: set by user.
  1629. * - decoding: unused
  1630. */
  1631. int mb_lmax;
  1632. /**
  1633. *
  1634. * - encoding: set by user.
  1635. * - decoding: unused
  1636. */
  1637. int me_penalty_compensation;
  1638. /**
  1639. *
  1640. * - encoding: unused
  1641. * - decoding: set by user.
  1642. */
  1643. enum AVDiscard skip_loop_filter;
  1644. /**
  1645. *
  1646. * - encoding: unused
  1647. * - decoding: set by user.
  1648. */
  1649. enum AVDiscard skip_idct;
  1650. /**
  1651. *
  1652. * - encoding: unused
  1653. * - decoding: set by user.
  1654. */
  1655. enum AVDiscard skip_frame;
  1656. /**
  1657. *
  1658. * - encoding: set by user.
  1659. * - decoding: unused
  1660. */
  1661. int bidir_refine;
  1662. /**
  1663. *
  1664. * - encoding: set by user.
  1665. * - decoding: unused
  1666. */
  1667. int brd_scale;
  1668. /**
  1669. * constant rate factor - quality-based VBR - values ~correspond to qps
  1670. * - encoding: set by user.
  1671. * - decoding: unused
  1672. */
  1673. int crf;
  1674. /**
  1675. * constant quantization parameter rate control method
  1676. * - encoding: set by user.
  1677. * - decoding: unused
  1678. */
  1679. int cqp;
  1680. /**
  1681. * minimum gop size
  1682. * - encoding: set by user.
  1683. * - decoding: unused
  1684. */
  1685. int keyint_min;
  1686. /**
  1687. * number of reference frames
  1688. * - encoding: set by user.
  1689. * - decoding: unused
  1690. */
  1691. int refs;
  1692. /**
  1693. * chroma qp offset from luma
  1694. * - encoding: set by user.
  1695. * - decoding: unused
  1696. */
  1697. int chromaoffset;
  1698. /**
  1699. * influences how often b-frames are used
  1700. * - encoding: set by user.
  1701. * - decoding: unused
  1702. */
  1703. int bframebias;
  1704. /**
  1705. * trellis RD quantization
  1706. * - encoding: set by user.
  1707. * - decoding: unused
  1708. */
  1709. int trellis;
  1710. /**
  1711. * reduce fluctuations in qp (before curve compression)
  1712. * - encoding: set by user.
  1713. * - decoding: unused
  1714. */
  1715. float complexityblur;
  1716. /**
  1717. * in-loop deblocking filter alphac0 parameter
  1718. * alpha is in the range -6...6
  1719. * - encoding: set by user.
  1720. * - decoding: unused
  1721. */
  1722. int deblockalpha;
  1723. /**
  1724. * in-loop deblocking filter beta parameter
  1725. * beta is in the range -6...6
  1726. * - encoding: set by user.
  1727. * - decoding: unused
  1728. */
  1729. int deblockbeta;
  1730. /**
  1731. * macroblock subpartition sizes to consider - p8x8, p4x4, b8x8, i8x8, i4x4
  1732. * - encoding: set by user.
  1733. * - decoding: unused
  1734. */
  1735. int partitions;
  1736. #define X264_PART_I4X4 0x001 /* Analyse i4x4 */
  1737. #define X264_PART_I8X8 0x002 /* Analyse i8x8 (requires 8x8 transform) */
  1738. #define X264_PART_P8X8 0x010 /* Analyse p16x8, p8x16 and p8x8 */
  1739. #define X264_PART_P4X4 0x020 /* Analyse p8x4, p4x8, p4x4 */
  1740. #define X264_PART_B8X8 0x100 /* Analyse b16x8, b8x16 and b8x8 */
  1741. /**
  1742. * direct mv prediction mode - 0 (none), 1 (spatial), 2 (temporal)
  1743. * - encoding: set by user.
  1744. * - decoding: unused
  1745. */
  1746. int directpred;
  1747. /**
  1748. * audio cutoff bandwidth (0 means "automatic") . Currently used only by FAAC
  1749. * - encoding: set by user.
  1750. * - decoding: unused
  1751. */
  1752. int cutoff;
  1753. /**
  1754. * multiplied by qscale for each frame and added to scene_change_score
  1755. * - encoding: set by user.
  1756. * - decoding: unused
  1757. */
  1758. int scenechange_factor;
  1759. /**
  1760. *
  1761. * note: value depends upon the compare functin used for fullpel ME
  1762. * - encoding: set by user.
  1763. * - decoding: unused
  1764. */
  1765. int mv0_threshold;
  1766. /**
  1767. * adjusts sensitivity of b_frame_strategy 1
  1768. * - encoding: set by user.
  1769. * - decoding: unused
  1770. */
  1771. int b_sensitivity;
  1772. /**
  1773. * - encoding: set by user.
  1774. * - decoding: unused
  1775. */
  1776. int compression_level;
  1777. #define FF_COMPRESSION_DEFAULT -1
  1778. /**
  1779. * sets whether to use LPC mode - used by FLAC encoder
  1780. * - encoding: set by user.
  1781. * - decoding: unused.
  1782. */
  1783. int use_lpc;
  1784. /**
  1785. * LPC coefficient precision - used by FLAC encoder
  1786. * - encoding: set by user.
  1787. * - decoding: unused.
  1788. */
  1789. int lpc_coeff_precision;
  1790. /**
  1791. * - encoding: set by user.
  1792. * - decoding: unused.
  1793. */
  1794. int min_prediction_order;
  1795. /**
  1796. * - encoding: set by user.
  1797. * - decoding: unused.
  1798. */
  1799. int max_prediction_order;
  1800. /**
  1801. * search method for selecting prediction order
  1802. * - encoding: set by user.
  1803. * - decoding: unused.
  1804. */
  1805. int prediction_order_method;
  1806. /**
  1807. * - encoding: set by user.
  1808. * - decoding: unused.
  1809. */
  1810. int min_partition_order;
  1811. /**
  1812. * - encoding: set by user.
  1813. * - decoding: unused.
  1814. */
  1815. int max_partition_order;
  1816. } AVCodecContext;
  1817. /**
  1818. * AVCodec.
  1819. */
  1820. typedef struct AVCodec {
  1821. const char *name;
  1822. enum CodecType type;
  1823. enum CodecID id;
  1824. int priv_data_size;
  1825. int (*init)(AVCodecContext *);
  1826. int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data);
  1827. int (*close)(AVCodecContext *);
  1828. int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
  1829. uint8_t *buf, int buf_size);
  1830. int capabilities;
  1831. #if LIBAVCODEC_VERSION_INT < ((50<<16)+(0<<8)+0)
  1832. void *dummy; // FIXME remove next time we break binary compatibility
  1833. #endif
  1834. struct AVCodec *next;
  1835. void (*flush)(AVCodecContext *);
  1836. const AVRational *supported_framerates; ///array of supported framerates, or NULL if any, array is terminated by {0,0}
  1837. const enum PixelFormat *pix_fmts; ///array of supported pixel formats, or NULL if unknown, array is terminanted by -1
  1838. } AVCodec;
  1839. /**
  1840. * four components are given, that's all.
  1841. * the last component is alpha
  1842. */
  1843. typedef struct AVPicture {
  1844. uint8_t *data[4];
  1845. int linesize[4]; ///< number of bytes per line
  1846. } AVPicture;
  1847. /**
  1848. * AVPaletteControl
  1849. * This structure defines a method for communicating palette changes
  1850. * between and demuxer and a decoder.
  1851. */
  1852. #define AVPALETTE_SIZE 1024
  1853. #define AVPALETTE_COUNT 256
  1854. typedef struct AVPaletteControl {
  1855. /* demuxer sets this to 1 to indicate the palette has changed;
  1856. * decoder resets to 0 */
  1857. int palette_changed;
  1858. /* 4-byte ARGB palette entries, stored in native byte order; note that
  1859. * the individual palette components should be on a 8-bit scale; if
  1860. * the palette data comes from a IBM VGA native format, the component
  1861. * data is probably 6 bits in size and needs to be scaled */
  1862. unsigned int palette[AVPALETTE_COUNT];
  1863. } AVPaletteControl;
  1864. typedef struct AVSubtitleRect {
  1865. uint16_t x;
  1866. uint16_t y;
  1867. uint16_t w;
  1868. uint16_t h;
  1869. uint16_t nb_colors;
  1870. int linesize;
  1871. uint32_t *rgba_palette;
  1872. uint8_t *bitmap;
  1873. } AVSubtitleRect;
  1874. typedef struct AVSubtitle {
  1875. uint16_t format; /* 0 = graphics */
  1876. uint32_t start_display_time; /* relative to packet pts, in ms */
  1877. uint32_t end_display_time; /* relative to packet pts, in ms */
  1878. uint32_t num_rects;
  1879. AVSubtitleRect *rects;
  1880. } AVSubtitle;
  1881. extern AVCodec ac3_encoder;
  1882. extern AVCodec mp2_encoder;
  1883. extern AVCodec mp3lame_encoder;
  1884. extern AVCodec oggvorbis_encoder;
  1885. extern AVCodec faac_encoder;
  1886. extern AVCodec flac_encoder;
  1887. extern AVCodec xvid_encoder;
  1888. extern AVCodec mpeg1video_encoder;
  1889. extern AVCodec mpeg2video_encoder;
  1890. extern AVCodec h261_encoder;
  1891. extern AVCodec h263_encoder;
  1892. extern AVCodec h263p_encoder;
  1893. extern AVCodec flv_encoder;
  1894. extern AVCodec rv10_encoder;
  1895. extern AVCodec rv20_encoder;
  1896. extern AVCodec dvvideo_encoder;
  1897. extern AVCodec mjpeg_encoder;
  1898. extern AVCodec ljpeg_encoder;
  1899. extern AVCodec jpegls_encoder;
  1900. extern AVCodec png_encoder;
  1901. extern AVCodec ppm_encoder;
  1902. extern AVCodec pgm_encoder;
  1903. extern AVCodec pgmyuv_encoder;
  1904. extern AVCodec pbm_encoder;
  1905. extern AVCodec pam_encoder;
  1906. extern AVCodec mpeg4_encoder;
  1907. extern AVCodec msmpeg4v1_encoder;
  1908. extern AVCodec msmpeg4v2_encoder;
  1909. extern AVCodec msmpeg4v3_encoder;
  1910. extern AVCodec wmv1_encoder;
  1911. extern AVCodec wmv2_encoder;
  1912. extern AVCodec huffyuv_encoder;
  1913. extern AVCodec ffvhuff_encoder;
  1914. extern AVCodec h264_encoder;
  1915. extern AVCodec asv1_encoder;
  1916. extern AVCodec asv2_encoder;
  1917. extern AVCodec vcr1_encoder;
  1918. extern AVCodec ffv1_encoder;
  1919. extern AVCodec snow_encoder;
  1920. extern AVCodec mdec_encoder;
  1921. extern AVCodec zlib_encoder;
  1922. extern AVCodec sonic_encoder;
  1923. extern AVCodec sonic_ls_encoder;
  1924. extern AVCodec svq1_encoder;
  1925. extern AVCodec x264_encoder;
  1926. extern AVCodec h263_decoder;
  1927. extern AVCodec h261_decoder;
  1928. extern AVCodec mpeg4_decoder;
  1929. extern AVCodec msmpeg4v1_decoder;
  1930. extern AVCodec msmpeg4v2_decoder;
  1931. extern AVCodec msmpeg4v3_decoder;
  1932. extern AVCodec wmv1_decoder;
  1933. extern AVCodec wmv2_decoder;
  1934. extern AVCodec vc1_decoder;
  1935. extern AVCodec wmv3_decoder;
  1936. extern AVCodec mpeg1video_decoder;
  1937. extern AVCodec mpeg2video_decoder;
  1938. extern AVCodec mpegvideo_decoder;
  1939. extern AVCodec mpeg_xvmc_decoder;
  1940. extern AVCodec h263i_decoder;
  1941. extern AVCodec flv_decoder;
  1942. extern AVCodec rv10_decoder;
  1943. extern AVCodec rv20_decoder;
  1944. extern AVCodec rv30_decoder;
  1945. extern AVCodec rv40_decoder;
  1946. extern AVCodec svq1_decoder;
  1947. extern AVCodec svq3_decoder;
  1948. extern AVCodec dvvideo_decoder;
  1949. extern AVCodec wmav1_decoder;
  1950. extern AVCodec wmav2_decoder;
  1951. extern AVCodec mjpeg_decoder;
  1952. extern AVCodec mjpegb_decoder;
  1953. extern AVCodec sp5x_decoder;
  1954. extern AVCodec png_decoder;
  1955. extern AVCodec mp2_decoder;
  1956. extern AVCodec mp3_decoder;
  1957. extern AVCodec mp3adu_decoder;
  1958. extern AVCodec mp3on4_decoder;
  1959. extern AVCodec qdm2_decoder;
  1960. extern AVCodec cook_decoder;
  1961. extern AVCodec truespeech_decoder;
  1962. extern AVCodec tta_decoder;
  1963. extern AVCodec mace3_decoder;
  1964. extern AVCodec mace6_decoder;
  1965. extern AVCodec huffyuv_decoder;
  1966. extern AVCodec ffvhuff_decoder;
  1967. extern AVCodec oggvorbis_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 */