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.

2221 lines
66KB

  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 "common.h"
  11. #include "rational.h"
  12. #include <sys/types.h> /* size_t */
  13. #define FFMPEG_VERSION_INT 0x000409
  14. #define FFMPEG_VERSION "0.4.9-pre1"
  15. #define LIBAVCODEC_BUILD 4725
  16. #define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT
  17. #define LIBAVCODEC_VERSION FFMPEG_VERSION
  18. #define AV_STRINGIFY(s) AV_TOSTRING(s)
  19. #define AV_TOSTRING(s) #s
  20. #define LIBAVCODEC_IDENT "FFmpeg" LIBAVCODEC_VERSION "b" AV_STRINGIFY(LIBAVCODEC_BUILD)
  21. #define AV_NOPTS_VALUE int64_t_C(0x8000000000000000)
  22. #define AV_TIME_BASE 1000000
  23. enum CodecID {
  24. CODEC_ID_NONE,
  25. CODEC_ID_MPEG1VIDEO,
  26. CODEC_ID_MPEG2VIDEO, /* prefered ID for MPEG Video 1 or 2 decoding */
  27. CODEC_ID_MPEG2VIDEO_XVMC,
  28. CODEC_ID_H261,
  29. CODEC_ID_H263,
  30. CODEC_ID_RV10,
  31. CODEC_ID_RV20,
  32. CODEC_ID_MP2,
  33. CODEC_ID_MP3, /* prefered ID for MPEG Audio layer 1, 2 or3 decoding */
  34. CODEC_ID_VORBIS,
  35. CODEC_ID_AC3,
  36. CODEC_ID_MJPEG,
  37. CODEC_ID_MJPEGB,
  38. CODEC_ID_LJPEG,
  39. CODEC_ID_SP5X,
  40. CODEC_ID_MPEG4,
  41. CODEC_ID_RAWVIDEO,
  42. CODEC_ID_MSMPEG4V1,
  43. CODEC_ID_MSMPEG4V2,
  44. CODEC_ID_MSMPEG4V3,
  45. CODEC_ID_WMV1,
  46. CODEC_ID_WMV2,
  47. CODEC_ID_H263P,
  48. CODEC_ID_H263I,
  49. CODEC_ID_FLV1,
  50. CODEC_ID_SVQ1,
  51. CODEC_ID_SVQ3,
  52. CODEC_ID_DVVIDEO,
  53. CODEC_ID_DVAUDIO,
  54. CODEC_ID_WMAV1,
  55. CODEC_ID_WMAV2,
  56. CODEC_ID_MACE3,
  57. CODEC_ID_MACE6,
  58. CODEC_ID_HUFFYUV,
  59. CODEC_ID_CYUV,
  60. CODEC_ID_H264,
  61. CODEC_ID_INDEO3,
  62. CODEC_ID_VP3,
  63. CODEC_ID_THEORA,
  64. CODEC_ID_AAC,
  65. CODEC_ID_MPEG4AAC,
  66. CODEC_ID_ASV1,
  67. CODEC_ID_ASV2,
  68. CODEC_ID_FFV1,
  69. CODEC_ID_4XM,
  70. CODEC_ID_VCR1,
  71. CODEC_ID_CLJR,
  72. CODEC_ID_MDEC,
  73. CODEC_ID_ROQ,
  74. CODEC_ID_INTERPLAY_VIDEO,
  75. CODEC_ID_XAN_WC3,
  76. CODEC_ID_XAN_WC4,
  77. CODEC_ID_RPZA,
  78. CODEC_ID_CINEPAK,
  79. CODEC_ID_WS_VQA,
  80. CODEC_ID_MSRLE,
  81. CODEC_ID_MSVIDEO1,
  82. CODEC_ID_IDCIN,
  83. CODEC_ID_8BPS,
  84. CODEC_ID_SMC,
  85. CODEC_ID_FLIC,
  86. CODEC_ID_TRUEMOTION1,
  87. CODEC_ID_VMDVIDEO,
  88. CODEC_ID_VMDAUDIO,
  89. CODEC_ID_MSZH,
  90. CODEC_ID_ZLIB,
  91. CODEC_ID_SONIC,
  92. CODEC_ID_SONIC_LS,
  93. CODEC_ID_QTRLE,
  94. CODEC_ID_SNOW,
  95. CODEC_ID_TSCC,
  96. CODEC_ID_ULTI,
  97. CODEC_ID_QDRAW,
  98. /* various pcm "codecs" */
  99. CODEC_ID_PCM_S16LE,
  100. CODEC_ID_PCM_S16BE,
  101. CODEC_ID_PCM_U16LE,
  102. CODEC_ID_PCM_U16BE,
  103. CODEC_ID_PCM_S8,
  104. CODEC_ID_PCM_U8,
  105. CODEC_ID_PCM_MULAW,
  106. CODEC_ID_PCM_ALAW,
  107. /* various adpcm codecs */
  108. CODEC_ID_ADPCM_IMA_QT,
  109. CODEC_ID_ADPCM_IMA_WAV,
  110. CODEC_ID_ADPCM_IMA_DK3,
  111. CODEC_ID_ADPCM_IMA_DK4,
  112. CODEC_ID_ADPCM_IMA_WS,
  113. CODEC_ID_ADPCM_IMA_SMJPEG,
  114. CODEC_ID_ADPCM_MS,
  115. CODEC_ID_ADPCM_4XM,
  116. CODEC_ID_ADPCM_XA,
  117. CODEC_ID_ADPCM_ADX,
  118. CODEC_ID_ADPCM_EA,
  119. CODEC_ID_ADPCM_G726,
  120. /* AMR */
  121. CODEC_ID_AMR_NB,
  122. CODEC_ID_AMR_WB,
  123. /* RealAudio codecs*/
  124. CODEC_ID_RA_144,
  125. CODEC_ID_RA_288,
  126. /* various DPCM codecs */
  127. CODEC_ID_ROQ_DPCM,
  128. CODEC_ID_INTERPLAY_DPCM,
  129. CODEC_ID_XAN_DPCM,
  130. CODEC_ID_SOL_DPCM,
  131. CODEC_ID_FLAC,
  132. CODEC_ID_MPEG2TS, /* _FAKE_ codec to indicate a raw MPEG2 transport
  133. stream (only used by libavformat) */
  134. CODEC_ID_DTS,
  135. CODEC_ID_XVID,
  136. };
  137. /* CODEC_ID_MP3LAME is absolete */
  138. #define CODEC_ID_MP3LAME CODEC_ID_MP3
  139. enum CodecType {
  140. CODEC_TYPE_UNKNOWN = -1,
  141. CODEC_TYPE_VIDEO,
  142. CODEC_TYPE_AUDIO,
  143. CODEC_TYPE_DATA,
  144. };
  145. /**
  146. * Pixel format. Notes:
  147. *
  148. * PIX_FMT_RGBA32 is handled in an endian-specific manner. A RGBA
  149. * color is put together as:
  150. * (A << 24) | (R << 16) | (G << 8) | B
  151. * This is stored as BGRA on little endian CPU architectures and ARGB on
  152. * big endian CPUs.
  153. *
  154. * When the pixel format is palettized RGB (PIX_FMT_PAL8), the palettized
  155. * image data is stored in AVFrame.data[0]. The palette is transported in
  156. * AVFrame.data[1] and, is 1024 bytes long (256 4-byte entries) and is
  157. * formatted the same as in PIX_FMT_RGBA32 described above (i.e., it is
  158. * also endian-specific). Note also that the individual RGB palette
  159. * components stored in AVFrame.data[1] should be in the range 0..255.
  160. * This is important as many custom PAL8 video codecs that were designed
  161. * to run on the IBM VGA graphics adapter use 6-bit palette components.
  162. */
  163. enum PixelFormat {
  164. PIX_FMT_YUV420P, ///< Planar YUV 4:2:0 (1 Cr & Cb sample per 2x2 Y samples)
  165. PIX_FMT_YUV422, ///< Packed pixel, Y0 Cb Y1 Cr
  166. PIX_FMT_RGB24, ///< Packed pixel, 3 bytes per pixel, RGBRGB...
  167. PIX_FMT_BGR24, ///< Packed pixel, 3 bytes per pixel, BGRBGR...
  168. PIX_FMT_YUV422P, ///< Planar YUV 4:2:2 (1 Cr & Cb sample per 2x1 Y samples)
  169. PIX_FMT_YUV444P, ///< Planar YUV 4:4:4 (1 Cr & Cb sample per 1x1 Y samples)
  170. PIX_FMT_RGBA32, ///< Packed pixel, 4 bytes per pixel, BGRABGRA..., stored in cpu endianness
  171. PIX_FMT_YUV410P, ///< Planar YUV 4:1:0 (1 Cr & Cb sample per 4x4 Y samples)
  172. PIX_FMT_YUV411P, ///< Planar YUV 4:1:1 (1 Cr & Cb sample per 4x1 Y samples)
  173. PIX_FMT_RGB565, ///< always stored in cpu endianness
  174. PIX_FMT_RGB555, ///< always stored in cpu endianness, most significant bit to 1
  175. PIX_FMT_GRAY8,
  176. PIX_FMT_MONOWHITE, ///< 0 is white
  177. PIX_FMT_MONOBLACK, ///< 0 is black
  178. PIX_FMT_PAL8, ///< 8 bit with RGBA palette
  179. PIX_FMT_YUVJ420P, ///< Planar YUV 4:2:0 full scale (jpeg)
  180. PIX_FMT_YUVJ422P, ///< Planar YUV 4:2:2 full scale (jpeg)
  181. PIX_FMT_YUVJ444P, ///< Planar YUV 4:4:4 full scale (jpeg)
  182. PIX_FMT_XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing(xvmc_render.h)
  183. PIX_FMT_XVMC_MPEG2_IDCT,
  184. PIX_FMT_UYVY422, ///< Packed pixel, Cb Y0 Cr Y1
  185. PIX_FMT_NB,
  186. };
  187. /* currently unused, may be used if 24/32 bits samples ever supported */
  188. enum SampleFormat {
  189. SAMPLE_FMT_S16 = 0, ///< signed 16 bits
  190. };
  191. /* in bytes */
  192. #define AVCODEC_MAX_AUDIO_FRAME_SIZE 131072
  193. /**
  194. * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
  195. * this is mainly needed because some optimized bitstream readers read
  196. * 32 or 64 bit at once and could read over the end<br>
  197. * Note, if the first 23 bits of the additional bytes are not 0 then damaged
  198. * MPEG bitstreams could cause overread and segfault
  199. */
  200. #define FF_INPUT_BUFFER_PADDING_SIZE 8
  201. /* motion estimation type, EPZS by default */
  202. enum Motion_Est_ID {
  203. ME_ZERO = 1,
  204. ME_FULL,
  205. ME_LOG,
  206. ME_PHODS,
  207. ME_EPZS,
  208. ME_X1
  209. };
  210. enum AVRounding {
  211. AV_ROUND_ZERO = 0, ///< round toward zero
  212. AV_ROUND_INF = 1, ///< round away from zero
  213. AV_ROUND_DOWN = 2, ///< round toward -infinity
  214. AV_ROUND_UP = 3, ///< round toward +infinity
  215. AV_ROUND_NEAR_INF = 5, ///< round to nearest and halfway cases away from zero
  216. };
  217. typedef struct RcOverride{
  218. int start_frame;
  219. int end_frame;
  220. int qscale; // if this is 0 then quality_factor will be used instead
  221. float quality_factor;
  222. } RcOverride;
  223. /* only for ME compatiblity with old apps */
  224. extern int motion_estimation_method;
  225. #define FF_MAX_B_FRAMES 8
  226. /* encoding support
  227. these flags can be passed in AVCodecContext.flags before initing
  228. Note: note not everything is supported yet
  229. */
  230. #define CODEC_FLAG_QSCALE 0x0002 ///< use fixed qscale
  231. #define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed / Advanced prediction for H263
  232. #define CODEC_FLAG_QPEL 0x0010 ///< use qpel MC
  233. #define CODEC_FLAG_GMC 0x0020 ///< use GMC
  234. #define CODEC_FLAG_MV0 0x0040 ///< always try a MB with MV=<0,0>
  235. #define CODEC_FLAG_PART 0x0080 ///< use data partitioning
  236. /* parent program gurantees that the input for b-frame containing streams is not written to
  237. for at least s->max_b_frames+1 frames, if this is not set than the input will be copied */
  238. #define CODEC_FLAG_INPUT_PRESERVED 0x0100
  239. #define CODEC_FLAG_PASS1 0x0200 ///< use internal 2pass ratecontrol in first pass mode
  240. #define CODEC_FLAG_PASS2 0x0400 ///< use internal 2pass ratecontrol in second pass mode
  241. #define CODEC_FLAG_EXTERN_HUFF 0x1000 ///< use external huffman table (for mjpeg)
  242. #define CODEC_FLAG_GRAY 0x2000 ///< only decode/encode grayscale
  243. #define CODEC_FLAG_EMU_EDGE 0x4000///< dont draw edges
  244. #define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding
  245. #define CODEC_FLAG_TRUNCATED 0x00010000 /** input bitstream might be truncated at a random location instead
  246. of only at frame boundaries */
  247. #define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< normalize adaptive quantization
  248. #define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< use interlaced dct
  249. #define CODEC_FLAG_LOW_DELAY 0x00080000 ///< force low delay
  250. #define CODEC_FLAG_ALT_SCAN 0x00100000 ///< use alternate scan
  251. #define CODEC_FLAG_TRELLIS_QUANT 0x00200000 ///< use trellis quantization
  252. #define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< place global headers in extradata instead of every keyframe
  253. #define CODEC_FLAG_BITEXACT 0x00800000 ///< use only bitexact stuff (except (i)dct)
  254. /* Fx : Flag for h263+ extra options */
  255. #define CODEC_FLAG_H263P_AIC 0x01000000 ///< H263 Advanced intra coding / MPEG4 AC prediction (remove this)
  256. #define CODEC_FLAG_AC_PRED 0x01000000 ///< H263 Advanced intra coding / MPEG4 AC prediction
  257. #define CODEC_FLAG_H263P_UMV 0x02000000 ///< Unlimited motion vector
  258. #define CODEC_FLAG_CBP_RD 0x04000000 ///< use rate distortion optimization for cbp
  259. #define CODEC_FLAG_QP_RD 0x08000000 ///< use rate distortion optimization for qp selectioon
  260. #define CODEC_FLAG_H263P_AIV 0x00000008 ///< H263 Alternative inter vlc
  261. #define CODEC_FLAG_OBMC 0x00000001 ///< OBMC
  262. #define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter
  263. #define CODEC_FLAG_H263P_SLICE_STRUCT 0x10000000
  264. #define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation
  265. #define CODEC_FLAG_SVCD_SCAN_OFFSET 0x40000000 ///< will reserve space for SVCD scan offset user data
  266. #define CODEC_FLAG_CLOSED_GOP 0x80000000
  267. #define CODEC_FLAG2_FAST 0x00000001 ///< allow non spec compliant speedup tricks
  268. /* Unsupported options :
  269. * Syntax Arithmetic coding (SAC)
  270. * Reference Picture Selection
  271. * Independant Segment Decoding */
  272. /* /Fx */
  273. /* codec capabilities */
  274. #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< decoder can use draw_horiz_band callback
  275. /**
  276. * Codec uses get_buffer() for allocating buffers.
  277. * direct rendering method 1
  278. */
  279. #define CODEC_CAP_DR1 0x0002
  280. /* if 'parse_only' field is true, then avcodec_parse_frame() can be
  281. used */
  282. #define CODEC_CAP_PARSE_ONLY 0x0004
  283. #define CODEC_CAP_TRUNCATED 0x0008
  284. /* codec can export data for HW decoding (XvMC) */
  285. #define CODEC_CAP_HWACCEL 0x0010
  286. /** codec has a non zero delay and needs to be feeded with NULL at the end to get the delayed data */
  287. #define CODEC_CAP_DELAY 0x0020
  288. //the following defines might change, so dont expect compatibility if u use them
  289. #define MB_TYPE_INTRA4x4 0x0001
  290. #define MB_TYPE_INTRA16x16 0x0002 //FIXME h264 specific
  291. #define MB_TYPE_INTRA_PCM 0x0004 //FIXME h264 specific
  292. #define MB_TYPE_16x16 0x0008
  293. #define MB_TYPE_16x8 0x0010
  294. #define MB_TYPE_8x16 0x0020
  295. #define MB_TYPE_8x8 0x0040
  296. #define MB_TYPE_INTERLACED 0x0080
  297. #define MB_TYPE_DIRECT2 0x0100 //FIXME
  298. #define MB_TYPE_ACPRED 0x0200
  299. #define MB_TYPE_GMC 0x0400
  300. #define MB_TYPE_SKIP 0x0800
  301. #define MB_TYPE_P0L0 0x1000
  302. #define MB_TYPE_P1L0 0x2000
  303. #define MB_TYPE_P0L1 0x4000
  304. #define MB_TYPE_P1L1 0x8000
  305. #define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0)
  306. #define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1)
  307. #define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1)
  308. #define MB_TYPE_QUANT 0x00010000
  309. #define MB_TYPE_CBP 0x00020000
  310. //Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...)
  311. /**
  312. * Pan Scan area.
  313. * this specifies the area which should be displayed. Note there may be multiple such areas for one frame
  314. */
  315. typedef struct AVPanScan{
  316. /**
  317. * id.
  318. * - encoding: set by user.
  319. * - decoding: set by lavc
  320. */
  321. int id;
  322. /**
  323. * width and height in 1/16 pel
  324. * - encoding: set by user.
  325. * - decoding: set by lavc
  326. */
  327. int width;
  328. int height;
  329. /**
  330. * position of the top left corner in 1/16 pel for up to 3 fields/frames.
  331. * - encoding: set by user.
  332. * - decoding: set by lavc
  333. */
  334. int16_t position[3][2];
  335. }AVPanScan;
  336. #define FF_COMMON_FRAME \
  337. /**\
  338. * pointer to the picture planes.\
  339. * this might be different from the first allocated byte\
  340. * - encoding: \
  341. * - decoding: \
  342. */\
  343. uint8_t *data[4];\
  344. int linesize[4];\
  345. /**\
  346. * pointer to the first allocated byte of the picture. can be used in get_buffer/release_buffer\
  347. * this isnt used by lavc unless the default get/release_buffer() is used\
  348. * - encoding: \
  349. * - decoding: \
  350. */\
  351. uint8_t *base[4];\
  352. /**\
  353. * 1 -> keyframe, 0-> not\
  354. * - encoding: set by lavc\
  355. * - decoding: set by lavc\
  356. */\
  357. int key_frame;\
  358. \
  359. /**\
  360. * picture type of the frame, see ?_TYPE below.\
  361. * - encoding: set by lavc for coded_picture (and set by user for input)\
  362. * - decoding: set by lavc\
  363. */\
  364. int pict_type;\
  365. \
  366. /**\
  367. * presentation timestamp in AV_TIME_BASE (=micro seconds currently) (time when frame should be shown to user)\
  368. * if AV_NOPTS_VALUE then the frame_rate will be used as reference\
  369. * - encoding: MUST be set by user\
  370. * - decoding: set by lavc\
  371. */\
  372. int64_t pts;\
  373. \
  374. /**\
  375. * picture number in bitstream order.\
  376. * - encoding: set by\
  377. * - decoding: set by lavc\
  378. */\
  379. int coded_picture_number;\
  380. /**\
  381. * picture number in display order.\
  382. * - encoding: set by\
  383. * - decoding: set by lavc\
  384. */\
  385. int display_picture_number;\
  386. \
  387. /**\
  388. * quality (between 1 (good) and FF_LAMBDA_MAX (bad)) \
  389. * - encoding: set by lavc for coded_picture (and set by user for input)\
  390. * - decoding: set by lavc\
  391. */\
  392. int quality; \
  393. \
  394. /**\
  395. * buffer age (1->was last buffer and dint change, 2->..., ...).\
  396. * set to INT_MAX if the buffer has not been used yet \
  397. * - encoding: unused\
  398. * - decoding: MUST be set by get_buffer()\
  399. */\
  400. int age;\
  401. \
  402. /**\
  403. * is this picture used as reference\
  404. * - encoding: unused\
  405. * - decoding: set by lavc (before get_buffer() call))\
  406. */\
  407. int reference;\
  408. \
  409. /**\
  410. * QP table\
  411. * - encoding: unused\
  412. * - decoding: set by lavc\
  413. */\
  414. int8_t *qscale_table;\
  415. /**\
  416. * QP store stride\
  417. * - encoding: unused\
  418. * - decoding: set by lavc\
  419. */\
  420. int qstride;\
  421. \
  422. /**\
  423. * mbskip_table[mb]>=1 if MB didnt change\
  424. * stride= mb_width = (width+15)>>4\
  425. * - encoding: unused\
  426. * - decoding: set by lavc\
  427. */\
  428. uint8_t *mbskip_table;\
  429. \
  430. /**\
  431. * Motion vector table\
  432. * - encoding: set by user\
  433. * - decoding: set by lavc\
  434. */\
  435. int16_t (*motion_val[2])[2];\
  436. \
  437. /**\
  438. * Macroblock type table\
  439. * mb_type_base + mb_width + 2\
  440. * - encoding: set by user\
  441. * - decoding: set by lavc\
  442. */\
  443. uint32_t *mb_type;\
  444. \
  445. /**\
  446. * Macroblock size: (0->16x16, 1->8x8, 2-> 4x4, 3-> 2x2)\
  447. * - encoding: unused\
  448. * - decoding: set by lavc\
  449. */\
  450. uint8_t motion_subsample_log2;\
  451. \
  452. /**\
  453. * for some private data of the user\
  454. * - encoding: unused\
  455. * - decoding: set by user\
  456. */\
  457. void *opaque;\
  458. \
  459. /**\
  460. * error\
  461. * - encoding: set by lavc if flags&CODEC_FLAG_PSNR\
  462. * - decoding: unused\
  463. */\
  464. uint64_t error[4];\
  465. \
  466. /**\
  467. * type of the buffer (to keep track of who has to dealloc data[*])\
  468. * - encoding: set by the one who allocs it\
  469. * - decoding: set by the one who allocs it\
  470. * Note: user allocated (direct rendering) & internal buffers can not coexist currently\
  471. */\
  472. int type;\
  473. \
  474. /**\
  475. * when decoding, this signal how much the picture must be delayed.\
  476. * extra_delay = repeat_pict / (2*fps)\
  477. * - encoding: unused\
  478. * - decoding: set by lavc\
  479. */\
  480. int repeat_pict;\
  481. \
  482. /**\
  483. * \
  484. */\
  485. int qscale_type;\
  486. \
  487. /**\
  488. * The content of the picture is interlaced.\
  489. * - encoding: set by user\
  490. * - decoding: set by lavc (default 0)\
  491. */\
  492. int interlaced_frame;\
  493. \
  494. /**\
  495. * if the content is interlaced, is top field displayed first.\
  496. * - encoding: set by user\
  497. * - decoding: set by lavc\
  498. */\
  499. int top_field_first;\
  500. \
  501. /**\
  502. * Pan scan.\
  503. * - encoding: set by user\
  504. * - decoding: set by lavc\
  505. */\
  506. AVPanScan *pan_scan;\
  507. \
  508. /**\
  509. * tell user application that palette has changed from previous frame.\
  510. * - encoding: ??? (no palette-enabled encoder yet)\
  511. * - decoding: set by lavc (default 0)\
  512. */\
  513. int palette_has_changed;\
  514. \
  515. /**\
  516. * Codec suggestion on buffer type if != 0\
  517. * - encoding: unused\
  518. * - decoding: set by lavc (before get_buffer() call))\
  519. */\
  520. int buffer_hints;\
  521. \
  522. /**\
  523. * DCT coeffitients\
  524. * - encoding: unused\
  525. * - decoding: set by lavc\
  526. */\
  527. short *dct_coeff;\
  528. \
  529. /**\
  530. * Motion referece frame index\
  531. * - encoding: set by user\
  532. * - decoding: set by lavc\
  533. */\
  534. int8_t *ref_index[2];
  535. #define FF_QSCALE_TYPE_MPEG1 0
  536. #define FF_QSCALE_TYPE_MPEG2 1
  537. #define FF_BUFFER_TYPE_INTERNAL 1
  538. #define FF_BUFFER_TYPE_USER 2 ///< Direct rendering buffers (image is (de)allocated by user)
  539. #define FF_BUFFER_TYPE_SHARED 4 ///< buffer from somewher else, dont dealloc image (data/base), all other tables are not shared
  540. #define FF_BUFFER_TYPE_COPY 8 ///< just a (modified) copy of some other buffer, dont dealloc anything
  541. #define FF_I_TYPE 1 // Intra
  542. #define FF_P_TYPE 2 // Predicted
  543. #define FF_B_TYPE 3 // Bi-dir predicted
  544. #define FF_S_TYPE 4 // S(GMC)-VOP MPEG4
  545. #define FF_SI_TYPE 5
  546. #define FF_SP_TYPE 6
  547. #define FF_BUFFER_HINTS_VALID 0x01 // Buffer hints value is meaningful (if 0 ignore)
  548. #define FF_BUFFER_HINTS_READABLE 0x02 // Codec will read from buffer
  549. #define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content
  550. #define FF_BUFFER_HINTS_REUSABLE 0x08 // Codec will reuse the buffer (update)
  551. /**
  552. * Audio Video Frame.
  553. */
  554. typedef struct AVFrame {
  555. FF_COMMON_FRAME
  556. } AVFrame;
  557. #define DEFAULT_FRAME_RATE_BASE 1001000
  558. /**
  559. * Used by av_log
  560. */
  561. typedef struct AVCLASS AVClass;
  562. struct AVCLASS {
  563. const char* class_name;
  564. const char* (*item_name)(void*); /* actually passing a pointer to an AVCodecContext
  565. or AVFormatContext, which begin with an AVClass.
  566. Needed because av_log is in libavcodec and has no visibility
  567. of AVIn/OutputFormat */
  568. };
  569. /**
  570. * main external api structure.
  571. */
  572. typedef struct AVCodecContext {
  573. /**
  574. * Info on struct for av_log
  575. * - set by avcodec_alloc_context
  576. */
  577. AVClass *av_class;
  578. /**
  579. * the average bitrate.
  580. * - encoding: set by user. unused for constant quantizer encoding
  581. * - decoding: set by lavc. 0 or some bitrate if this info is available in the stream
  582. */
  583. int bit_rate;
  584. /**
  585. * number of bits the bitstream is allowed to diverge from the reference.
  586. * the reference can be CBR (for CBR pass1) or VBR (for pass2)
  587. * - encoding: set by user. unused for constant quantizer encoding
  588. * - decoding: unused
  589. */
  590. int bit_rate_tolerance;
  591. /**
  592. * CODEC_FLAG_*.
  593. * - encoding: set by user.
  594. * - decoding: set by user.
  595. */
  596. int flags;
  597. /**
  598. * some codecs needs additionnal format info. It is stored here
  599. * - encoding: set by user.
  600. * - decoding: set by lavc. (FIXME is this ok?)
  601. */
  602. int sub_id;
  603. /**
  604. * motion estimation algorithm used for video coding.
  605. * - encoding: MUST be set by user.
  606. * - decoding: unused
  607. */
  608. int me_method;
  609. /**
  610. * some codecs need / can use extra-data like huffman tables.
  611. * mjpeg: huffman tables
  612. * rv10: additional flags
  613. * mpeg4: global headers (they can be in the bitstream or here)
  614. * - encoding: set/allocated/freed by lavc.
  615. * - decoding: set/allocated/freed by user.
  616. */
  617. void *extradata;
  618. int extradata_size;
  619. /* video only */
  620. /**
  621. * frames per sec multiplied by frame_rate_base.
  622. * for variable fps this is the precission, so if the timestamps
  623. * can be specified in msec precssion then this is 1000*frame_rate_base
  624. * - encoding: MUST be set by user
  625. * - decoding: set by lavc. 0 or the frame_rate if available
  626. */
  627. int frame_rate;
  628. /**
  629. * picture width / height.
  630. * - encoding: MUST be set by user.
  631. * - decoding: set by lavc.
  632. * Note, for compatibility its possible to set this instead of
  633. * coded_width/height before decoding
  634. */
  635. int width, height;
  636. #define FF_ASPECT_EXTENDED 15
  637. /**
  638. * the number of pictures in a group of pitures, or 0 for intra_only.
  639. * - encoding: set by user.
  640. * - decoding: unused
  641. */
  642. int gop_size;
  643. /**
  644. * pixel format, see PIX_FMT_xxx.
  645. * - encoding: FIXME: used by ffmpeg to decide whether an pix_fmt
  646. * conversion is in order. This only works for
  647. * codecs with one supported pix_fmt, we should
  648. * do something for a generic case as well.
  649. * - decoding: set by lavc.
  650. */
  651. enum PixelFormat pix_fmt;
  652. /**
  653. * Frame rate emulation. If not zero lower layer (i.e. format handler)
  654. * has to read frames at native frame rate.
  655. * - encoding: set by user.
  656. * - decoding: unused.
  657. */
  658. int rate_emu;
  659. /**
  660. * if non NULL, 'draw_horiz_band' is called by the libavcodec
  661. * decoder to draw an horizontal band. It improve cache usage. Not
  662. * all codecs can do that. You must check the codec capabilities
  663. * before
  664. * - encoding: unused
  665. * - decoding: set by user.
  666. * @param height the height of the slice
  667. * @param y the y position of the slice
  668. * @param type 1->top field, 2->bottom field, 3->frame
  669. * @param offset offset into the AVFrame.data from which the slice should be read
  670. */
  671. void (*draw_horiz_band)(struct AVCodecContext *s,
  672. const AVFrame *src, int offset[4],
  673. int y, int type, int height);
  674. /* audio only */
  675. int sample_rate; ///< samples per sec
  676. int channels;
  677. int sample_fmt; ///< sample format, currenly unused
  678. /* the following data should not be initialized */
  679. int frame_size; ///< in samples, initialized when calling 'init'
  680. int frame_number; ///< audio or video frame number
  681. int real_pict_num; ///< returns the real picture number of previous encoded frame
  682. /**
  683. * number of frames the decoded output will be delayed relative to
  684. * the encoded input.
  685. * - encoding: set by lavc.
  686. * - decoding: unused
  687. */
  688. int delay;
  689. /* - encoding parameters */
  690. float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)
  691. float qblur; ///< amount of qscale smoothing over time (0.0-1.0)
  692. /**
  693. * minimum quantizer.
  694. * - encoding: set by user.
  695. * - decoding: unused
  696. */
  697. int qmin;
  698. /**
  699. * maximum quantizer.
  700. * - encoding: set by user.
  701. * - decoding: unused
  702. */
  703. int qmax;
  704. /**
  705. * maximum quantizer difference etween frames.
  706. * - encoding: set by user.
  707. * - decoding: unused
  708. */
  709. int max_qdiff;
  710. /**
  711. * maximum number of b frames between non b frames.
  712. * note: the output will be delayed by max_b_frames+1 relative to the input
  713. * - encoding: set by user.
  714. * - decoding: unused
  715. */
  716. int max_b_frames;
  717. /**
  718. * qscale factor between ip and b frames.
  719. * - encoding: set by user.
  720. * - decoding: unused
  721. */
  722. float b_quant_factor;
  723. /** obsolete FIXME remove */
  724. int rc_strategy;
  725. int b_frame_strategy;
  726. /**
  727. * hurry up amount.
  728. * - encoding: unused
  729. * - decoding: set by user. 1-> skip b frames, 2-> skip idct/dequant too, 5-> skip everything except header
  730. */
  731. int hurry_up;
  732. struct AVCodec *codec;
  733. void *priv_data;
  734. /* unused, FIXME remove*/
  735. int rtp_mode;
  736. int rtp_payload_size; /* The size of the RTP payload, the coder will */
  737. /* do it's best to deliver a chunk with size */
  738. /* below rtp_payload_size, the chunk will start */
  739. /* with a start code on some codecs like H.263 */
  740. /* This doesn't take account of any particular */
  741. /* headers inside the transmited RTP payload */
  742. /* The RTP callcack: This function is called */
  743. /* every time the encoder as a packet to send */
  744. /* Depends on the encoder if the data starts */
  745. /* with a Start Code (it should) H.263 does */
  746. void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int packet_number);
  747. /* statistics, used for 2-pass encoding */
  748. int mv_bits;
  749. int header_bits;
  750. int i_tex_bits;
  751. int p_tex_bits;
  752. int i_count;
  753. int p_count;
  754. int skip_count;
  755. int misc_bits;
  756. /**
  757. * number of bits used for the previously encoded frame.
  758. * - encoding: set by lavc
  759. * - decoding: unused
  760. */
  761. int frame_bits;
  762. /**
  763. * private data of the user, can be used to carry app specific stuff.
  764. * - encoding: set by user
  765. * - decoding: set by user
  766. */
  767. void *opaque;
  768. char codec_name[32];
  769. enum CodecType codec_type; /* see CODEC_TYPE_xxx */
  770. enum CodecID codec_id; /* see CODEC_ID_xxx */
  771. /**
  772. * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
  773. * this is used to workaround some encoder bugs
  774. * - encoding: set by user, if not then the default based on codec_id will be used
  775. * - decoding: set by user, will be converted to upper case by lavc during init
  776. */
  777. unsigned int codec_tag;
  778. /**
  779. * workaround bugs in encoders which sometimes cannot be detected automatically.
  780. * - encoding: unused
  781. * - decoding: set by user
  782. */
  783. int workaround_bugs;
  784. #define FF_BUG_AUTODETECT 1 ///< autodetection
  785. #define FF_BUG_OLD_MSMPEG4 2
  786. #define FF_BUG_XVID_ILACE 4
  787. #define FF_BUG_UMP4 8
  788. #define FF_BUG_NO_PADDING 16
  789. #define FF_BUG_AMV 32
  790. #define FF_BUG_AC_VLC 0 ///< will be removed, libavcodec can now handle these non compliant files by default
  791. #define FF_BUG_QPEL_CHROMA 64
  792. #define FF_BUG_STD_QPEL 128
  793. #define FF_BUG_QPEL_CHROMA2 256
  794. #define FF_BUG_DIRECT_BLOCKSIZE 512
  795. #define FF_BUG_EDGE 1024
  796. #define FF_BUG_HPEL_CHROMA 2048
  797. #define FF_BUG_DC_CLIP 4096
  798. //#define FF_BUG_FAKE_SCALABILITY 16 //autodetection should work 100%
  799. /**
  800. * luma single coeff elimination threshold.
  801. * - encoding: set by user
  802. * - decoding: unused
  803. */
  804. int luma_elim_threshold;
  805. /**
  806. * chroma single coeff elimination threshold.
  807. * - encoding: set by user
  808. * - decoding: unused
  809. */
  810. int chroma_elim_threshold;
  811. /**
  812. * strictly follow the std (MPEG4, ...).
  813. * - encoding: set by user
  814. * - decoding: unused
  815. */
  816. int strict_std_compliance;
  817. /**
  818. * qscale offset between ip and b frames.
  819. * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
  820. * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
  821. * - encoding: set by user.
  822. * - decoding: unused
  823. */
  824. float b_quant_offset;
  825. /**
  826. * error resilience higher values will detect more errors but may missdetect
  827. * some more or less valid parts as errors.
  828. * - encoding: unused
  829. * - decoding: set by user
  830. */
  831. int error_resilience;
  832. #define FF_ER_CAREFULL 1
  833. #define FF_ER_COMPLIANT 2
  834. #define FF_ER_AGGRESSIVE 3
  835. #define FF_ER_VERY_AGGRESSIVE 4
  836. /**
  837. * called at the beginning of each frame to get a buffer for it.
  838. * if pic.reference is set then the frame will be read later by lavc
  839. * avcodec_align_dimensions() should be used to find the required width and
  840. * height, as they normally need to be rounded up to the next multiple of 16
  841. * - encoding: unused
  842. * - decoding: set by lavc, user can override
  843. */
  844. int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
  845. /**
  846. * called to release buffers which where allocated with get_buffer.
  847. * a released buffer can be reused in get_buffer()
  848. * pic.data[*] must be set to NULL
  849. * - encoding: unused
  850. * - decoding: set by lavc, user can override
  851. */
  852. void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
  853. /**
  854. * if 1 the stream has a 1 frame delay during decoding.
  855. * - encoding: set by lavc
  856. * - decoding: set by lavc
  857. */
  858. int has_b_frames;
  859. int block_align; ///< used by some WAV based audio codecs
  860. int parse_only; /* - decoding only: if true, only parsing is done
  861. (function avcodec_parse_frame()). The frame
  862. data is returned. Only MPEG codecs support this now. */
  863. /**
  864. * 0-> h263 quant 1-> mpeg quant.
  865. * - encoding: set by user.
  866. * - decoding: unused
  867. */
  868. int mpeg_quant;
  869. /**
  870. * pass1 encoding statistics output buffer.
  871. * - encoding: set by lavc
  872. * - decoding: unused
  873. */
  874. char *stats_out;
  875. /**
  876. * pass2 encoding statistics input buffer.
  877. * concatenated stuff from stats_out of pass1 should be placed here
  878. * - encoding: allocated/set/freed by user
  879. * - decoding: unused
  880. */
  881. char *stats_in;
  882. /**
  883. * ratecontrol qmin qmax limiting method.
  884. * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax
  885. * - encoding: set by user.
  886. * - decoding: unused
  887. */
  888. float rc_qsquish;
  889. float rc_qmod_amp;
  890. int rc_qmod_freq;
  891. /**
  892. * ratecontrol override, see RcOverride.
  893. * - encoding: allocated/set/freed by user.
  894. * - decoding: unused
  895. */
  896. RcOverride *rc_override;
  897. int rc_override_count;
  898. /**
  899. * rate control equation.
  900. * - encoding: set by user
  901. * - decoding: unused
  902. */
  903. char *rc_eq;
  904. /**
  905. * maximum bitrate.
  906. * - encoding: set by user.
  907. * - decoding: unused
  908. */
  909. int rc_max_rate;
  910. /**
  911. * minimum bitrate.
  912. * - encoding: set by user.
  913. * - decoding: unused
  914. */
  915. int rc_min_rate;
  916. /**
  917. * decoder bitstream buffer size.
  918. * - encoding: set by user.
  919. * - decoding: unused
  920. */
  921. int rc_buffer_size;
  922. float rc_buffer_aggressivity;
  923. /**
  924. * qscale factor between p and i frames.
  925. * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
  926. * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
  927. * - encoding: set by user.
  928. * - decoding: unused
  929. */
  930. float i_quant_factor;
  931. /**
  932. * qscale offset between p and i frames.
  933. * - encoding: set by user.
  934. * - decoding: unused
  935. */
  936. float i_quant_offset;
  937. /**
  938. * initial complexity for pass1 ratecontrol.
  939. * - encoding: set by user.
  940. * - decoding: unused
  941. */
  942. float rc_initial_cplx;
  943. /**
  944. * dct algorithm, see FF_DCT_* below.
  945. * - encoding: set by user
  946. * - decoding: unused
  947. */
  948. int dct_algo;
  949. #define FF_DCT_AUTO 0
  950. #define FF_DCT_FASTINT 1
  951. #define FF_DCT_INT 2
  952. #define FF_DCT_MMX 3
  953. #define FF_DCT_MLIB 4
  954. #define FF_DCT_ALTIVEC 5
  955. #define FF_DCT_FAAN 6
  956. /**
  957. * luminance masking (0-> disabled).
  958. * - encoding: set by user
  959. * - decoding: unused
  960. */
  961. float lumi_masking;
  962. /**
  963. * temporary complexity masking (0-> disabled).
  964. * - encoding: set by user
  965. * - decoding: unused
  966. */
  967. float temporal_cplx_masking;
  968. /**
  969. * spatial complexity masking (0-> disabled).
  970. * - encoding: set by user
  971. * - decoding: unused
  972. */
  973. float spatial_cplx_masking;
  974. /**
  975. * p block masking (0-> disabled).
  976. * - encoding: set by user
  977. * - decoding: unused
  978. */
  979. float p_masking;
  980. /**
  981. * darkness masking (0-> disabled).
  982. * - encoding: set by user
  983. * - decoding: unused
  984. */
  985. float dark_masking;
  986. /* for binary compatibility */
  987. int unused;
  988. /**
  989. * idct algorithm, see FF_IDCT_* below.
  990. * - encoding: set by user
  991. * - decoding: set by user
  992. */
  993. int idct_algo;
  994. #define FF_IDCT_AUTO 0
  995. #define FF_IDCT_INT 1
  996. #define FF_IDCT_SIMPLE 2
  997. #define FF_IDCT_SIMPLEMMX 3
  998. #define FF_IDCT_LIBMPEG2MMX 4
  999. #define FF_IDCT_PS2 5
  1000. #define FF_IDCT_MLIB 6
  1001. #define FF_IDCT_ARM 7
  1002. #define FF_IDCT_ALTIVEC 8
  1003. #define FF_IDCT_SH4 9
  1004. #define FF_IDCT_SIMPLEARM 10
  1005. #define FF_IDCT_H264 11
  1006. /**
  1007. * slice count.
  1008. * - encoding: set by lavc
  1009. * - decoding: set by user (or 0)
  1010. */
  1011. int slice_count;
  1012. /**
  1013. * slice offsets in the frame in bytes.
  1014. * - encoding: set/allocated by lavc
  1015. * - decoding: set/allocated by user (or NULL)
  1016. */
  1017. int *slice_offset;
  1018. /**
  1019. * error concealment flags.
  1020. * - encoding: unused
  1021. * - decoding: set by user
  1022. */
  1023. int error_concealment;
  1024. #define FF_EC_GUESS_MVS 1
  1025. #define FF_EC_DEBLOCK 2
  1026. /**
  1027. * dsp_mask could be add used to disable unwanted CPU features
  1028. * CPU features (i.e. MMX, SSE. ...)
  1029. *
  1030. * with FORCE flag you may instead enable given CPU features
  1031. * (Dangerous: usable in case of misdetection, improper usage however will
  1032. * result into program crash)
  1033. */
  1034. unsigned dsp_mask;
  1035. #define FF_MM_FORCE 0x80000000 /* force usage of selected flags (OR) */
  1036. /* lower 16 bits - CPU features */
  1037. #ifdef HAVE_MMX
  1038. #define FF_MM_MMX 0x0001 /* standard MMX */
  1039. #define FF_MM_3DNOW 0x0004 /* AMD 3DNOW */
  1040. #define FF_MM_MMXEXT 0x0002 /* SSE integer functions or AMD MMX ext */
  1041. #define FF_MM_SSE 0x0008 /* SSE functions */
  1042. #define FF_MM_SSE2 0x0010 /* PIV SSE2 functions */
  1043. #endif /* HAVE_MMX */
  1044. /**
  1045. * bits per sample/pixel from the demuxer (needed for huffyuv).
  1046. * - encoding: set by lavc
  1047. * - decoding: set by user
  1048. */
  1049. int bits_per_sample;
  1050. /**
  1051. * prediction method (needed for huffyuv).
  1052. * - encoding: set by user
  1053. * - decoding: unused
  1054. */
  1055. int prediction_method;
  1056. #define FF_PRED_LEFT 0
  1057. #define FF_PRED_PLANE 1
  1058. #define FF_PRED_MEDIAN 2
  1059. /**
  1060. * sample aspect ratio (0 if unknown).
  1061. * numerator and denominator must be relative prime and smaller then 256 for some video standards
  1062. * - encoding: set by user.
  1063. * - decoding: set by lavc.
  1064. */
  1065. AVRational sample_aspect_ratio;
  1066. /**
  1067. * the picture in the bitstream.
  1068. * - encoding: set by lavc
  1069. * - decoding: set by lavc
  1070. */
  1071. AVFrame *coded_frame;
  1072. /**
  1073. * debug.
  1074. * - encoding: set by user.
  1075. * - decoding: set by user.
  1076. */
  1077. int debug;
  1078. #define FF_DEBUG_PICT_INFO 1
  1079. #define FF_DEBUG_RC 2
  1080. #define FF_DEBUG_BITSTREAM 4
  1081. #define FF_DEBUG_MB_TYPE 8
  1082. #define FF_DEBUG_QP 16
  1083. #define FF_DEBUG_MV 32
  1084. #define FF_DEBUG_DCT_COEFF 0x00000040
  1085. #define FF_DEBUG_SKIP 0x00000080
  1086. #define FF_DEBUG_STARTCODE 0x00000100
  1087. #define FF_DEBUG_PTS 0x00000200
  1088. #define FF_DEBUG_ER 0x00000400
  1089. #define FF_DEBUG_MMCO 0x00000800
  1090. #define FF_DEBUG_BUGS 0x00001000
  1091. #define FF_DEBUG_VIS_QP 0x00002000
  1092. #define FF_DEBUG_VIS_MB_TYPE 0x00004000
  1093. /**
  1094. * debug.
  1095. * - encoding: set by user.
  1096. * - decoding: set by user.
  1097. */
  1098. int debug_mv;
  1099. #define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames
  1100. #define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames
  1101. #define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames
  1102. /**
  1103. * error.
  1104. * - encoding: set by lavc if flags&CODEC_FLAG_PSNR
  1105. * - decoding: unused
  1106. */
  1107. uint64_t error[4];
  1108. /**
  1109. * minimum MB quantizer.
  1110. * - encoding: set by user.
  1111. * - decoding: unused
  1112. */
  1113. int mb_qmin;
  1114. /**
  1115. * maximum MB quantizer.
  1116. * - encoding: set by user.
  1117. * - decoding: unused
  1118. */
  1119. int mb_qmax;
  1120. /**
  1121. * motion estimation compare function.
  1122. * - encoding: set by user.
  1123. * - decoding: unused
  1124. */
  1125. int me_cmp;
  1126. /**
  1127. * subpixel motion estimation compare function.
  1128. * - encoding: set by user.
  1129. * - decoding: unused
  1130. */
  1131. int me_sub_cmp;
  1132. /**
  1133. * macroblock compare function (not supported yet).
  1134. * - encoding: set by user.
  1135. * - decoding: unused
  1136. */
  1137. int mb_cmp;
  1138. /**
  1139. * interlaced dct compare function
  1140. * - encoding: set by user.
  1141. * - decoding: unused
  1142. */
  1143. int ildct_cmp;
  1144. #define FF_CMP_SAD 0
  1145. #define FF_CMP_SSE 1
  1146. #define FF_CMP_SATD 2
  1147. #define FF_CMP_DCT 3
  1148. #define FF_CMP_PSNR 4
  1149. #define FF_CMP_BIT 5
  1150. #define FF_CMP_RD 6
  1151. #define FF_CMP_ZERO 7
  1152. #define FF_CMP_VSAD 8
  1153. #define FF_CMP_VSSE 9
  1154. #define FF_CMP_NSSE 10
  1155. #define FF_CMP_W53 11
  1156. #define FF_CMP_W97 12
  1157. #define FF_CMP_CHROMA 256
  1158. /**
  1159. * ME diamond size & shape.
  1160. * - encoding: set by user.
  1161. * - decoding: unused
  1162. */
  1163. int dia_size;
  1164. /**
  1165. * amount of previous MV predictors (2a+1 x 2a+1 square).
  1166. * - encoding: set by user.
  1167. * - decoding: unused
  1168. */
  1169. int last_predictor_count;
  1170. /**
  1171. * pre pass for motion estimation.
  1172. * - encoding: set by user.
  1173. * - decoding: unused
  1174. */
  1175. int pre_me;
  1176. /**
  1177. * motion estimation pre pass compare function.
  1178. * - encoding: set by user.
  1179. * - decoding: unused
  1180. */
  1181. int me_pre_cmp;
  1182. /**
  1183. * ME pre pass diamond size & shape.
  1184. * - encoding: set by user.
  1185. * - decoding: unused
  1186. */
  1187. int pre_dia_size;
  1188. /**
  1189. * subpel ME quality.
  1190. * - encoding: set by user.
  1191. * - decoding: unused
  1192. */
  1193. int me_subpel_quality;
  1194. /**
  1195. * callback to negotiate the pixelFormat.
  1196. * @param fmt is the list of formats which are supported by the codec,
  1197. * its terminated by -1 as 0 is a valid format, the formats are ordered by quality
  1198. * the first is allways the native one
  1199. * @return the choosen format
  1200. * - encoding: unused
  1201. * - decoding: set by user, if not set then the native format will always be choosen
  1202. */
  1203. enum PixelFormat (*get_format)(struct AVCodecContext *s, const enum PixelFormat * fmt);
  1204. /**
  1205. * DTG active format information (additionnal aspect ratio
  1206. * information only used in DVB MPEG2 transport streams). 0 if
  1207. * not set.
  1208. *
  1209. * - encoding: unused.
  1210. * - decoding: set by decoder
  1211. */
  1212. int dtg_active_format;
  1213. #define FF_DTG_AFD_SAME 8
  1214. #define FF_DTG_AFD_4_3 9
  1215. #define FF_DTG_AFD_16_9 10
  1216. #define FF_DTG_AFD_14_9 11
  1217. #define FF_DTG_AFD_4_3_SP_14_9 13
  1218. #define FF_DTG_AFD_16_9_SP_14_9 14
  1219. #define FF_DTG_AFD_SP_4_3 15
  1220. /**
  1221. * Maximum motion estimation search range in subpel units.
  1222. * if 0 then no limit
  1223. *
  1224. * - encoding: set by user.
  1225. * - decoding: unused.
  1226. */
  1227. int me_range;
  1228. /**
  1229. * frame_rate_base.
  1230. * for variable fps this is 1
  1231. * - encoding: set by user.
  1232. * - decoding: set by lavc.
  1233. * @todo move this after frame_rate
  1234. */
  1235. int frame_rate_base;
  1236. /**
  1237. * intra quantizer bias.
  1238. * - encoding: set by user.
  1239. * - decoding: unused
  1240. */
  1241. int intra_quant_bias;
  1242. #define FF_DEFAULT_QUANT_BIAS 999999
  1243. /**
  1244. * inter quantizer bias.
  1245. * - encoding: set by user.
  1246. * - decoding: unused
  1247. */
  1248. int inter_quant_bias;
  1249. /**
  1250. * color table ID.
  1251. * - encoding: unused.
  1252. * - decoding: which clrtable should be used for 8bit RGB images
  1253. * table have to be stored somewhere FIXME
  1254. */
  1255. int color_table_id;
  1256. /**
  1257. * internal_buffer count.
  1258. * Dont touch, used by lavc default_get_buffer()
  1259. */
  1260. int internal_buffer_count;
  1261. /**
  1262. * internal_buffers.
  1263. * Dont touch, used by lavc default_get_buffer()
  1264. */
  1265. void *internal_buffer;
  1266. #define FF_LAMBDA_SHIFT 7
  1267. #define FF_LAMBDA_SCALE (1<<FF_LAMBDA_SHIFT)
  1268. #define FF_QP2LAMBDA 118 ///< factor to convert from H.263 QP to lambda
  1269. #define FF_LAMBDA_MAX (256*128-1)
  1270. #define FF_QUALITY_SCALE FF_LAMBDA_SCALE //FIXME maybe remove
  1271. /**
  1272. * global quality for codecs which cannot change it per frame.
  1273. * this should be proportional to MPEG1/2/4 qscale.
  1274. * - encoding: set by user.
  1275. * - decoding: unused
  1276. */
  1277. int global_quality;
  1278. #define FF_CODER_TYPE_VLC 0
  1279. #define FF_CODER_TYPE_AC 1
  1280. /**
  1281. * coder type
  1282. * - encoding: set by user.
  1283. * - decoding: unused
  1284. */
  1285. int coder_type;
  1286. /**
  1287. * context model
  1288. * - encoding: set by user.
  1289. * - decoding: unused
  1290. */
  1291. int context_model;
  1292. /**
  1293. * slice flags
  1294. * - encoding: unused
  1295. * - decoding: set by user.
  1296. */
  1297. int slice_flags;
  1298. #define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display
  1299. #define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics)
  1300. #define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
  1301. /**
  1302. * XVideo Motion Acceleration
  1303. * - encoding: forbidden
  1304. * - decoding: set by decoder
  1305. */
  1306. int xvmc_acceleration;
  1307. /**
  1308. * macroblock decision mode
  1309. * - encoding: set by user.
  1310. * - decoding: unused
  1311. */
  1312. int mb_decision;
  1313. #define FF_MB_DECISION_SIMPLE 0 ///< uses mb_cmp
  1314. #define FF_MB_DECISION_BITS 1 ///< chooses the one which needs the fewest bits
  1315. #define FF_MB_DECISION_RD 2 ///< rate distoration
  1316. /**
  1317. * custom intra quantization matrix
  1318. * - encoding: set by user, can be NULL
  1319. * - decoding: set by lavc
  1320. */
  1321. uint16_t *intra_matrix;
  1322. /**
  1323. * custom inter quantization matrix
  1324. * - encoding: set by user, can be NULL
  1325. * - decoding: set by lavc
  1326. */
  1327. uint16_t *inter_matrix;
  1328. /**
  1329. * fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
  1330. * this is used to workaround some encoder bugs
  1331. * - encoding: unused
  1332. * - decoding: set by user, will be converted to upper case by lavc during init
  1333. */
  1334. unsigned int stream_codec_tag;
  1335. /**
  1336. * scene change detection threshold.
  1337. * 0 is default, larger means fewer detected scene changes
  1338. * - encoding: set by user.
  1339. * - decoding: unused
  1340. */
  1341. int scenechange_threshold;
  1342. /**
  1343. * minimum lagrange multipler
  1344. * - encoding: set by user.
  1345. * - decoding: unused
  1346. */
  1347. int lmin;
  1348. /**
  1349. * maximum lagrange multipler
  1350. * - encoding: set by user.
  1351. * - decoding: unused
  1352. */
  1353. int lmax;
  1354. /**
  1355. * Palette control structure
  1356. * - encoding: ??? (no palette-enabled encoder yet)
  1357. * - decoding: set by user.
  1358. */
  1359. struct AVPaletteControl *palctrl;
  1360. /**
  1361. * noise reduction strength
  1362. * - encoding: set by user.
  1363. * - decoding: unused
  1364. */
  1365. int noise_reduction;
  1366. /**
  1367. * called at the beginning of a frame to get cr buffer for it.
  1368. * buffer type (size, hints) must be the same. lavc won't check it.
  1369. * lavc will pass previous buffer in pic, function should return
  1370. * same buffer or new buffer with old frame "painted" into it.
  1371. * if pic.data[0] == NULL must behave like get_buffer().
  1372. * - encoding: unused
  1373. * - decoding: set by lavc, user can override
  1374. */
  1375. int (*reget_buffer)(struct AVCodecContext *c, AVFrame *pic);
  1376. /**
  1377. * number of bits which should be loaded into the rc buffer before decoding starts
  1378. * - encoding: set by user.
  1379. * - decoding: unused
  1380. */
  1381. int rc_initial_buffer_occupancy;
  1382. /**
  1383. *
  1384. * - encoding: set by user.
  1385. * - decoding: unused
  1386. */
  1387. int inter_threshold;
  1388. /**
  1389. * CODEC_FLAG2_*.
  1390. * - encoding: set by user.
  1391. * - decoding: set by user.
  1392. */
  1393. int flags2;
  1394. /**
  1395. * simulates errors in the bitstream to test error concealment.
  1396. * - encoding: set by user.
  1397. * - decoding: unused.
  1398. */
  1399. int error_rate;
  1400. /**
  1401. * MP3 antialias algorithm, see FF_AA_* below.
  1402. * - encoding: unused
  1403. * - decoding: set by user
  1404. */
  1405. int antialias_algo;
  1406. #define FF_AA_AUTO 0
  1407. #define FF_AA_FASTINT 1 //not implemented yet
  1408. #define FF_AA_INT 2
  1409. #define FF_AA_FLOAT 3
  1410. /**
  1411. * Quantizer noise shaping.
  1412. * - encoding: set by user
  1413. * - decoding: unused
  1414. */
  1415. int quantizer_noise_shaping;
  1416. /**
  1417. * Thread count.
  1418. * is used to decide how many independant tasks should be passed to execute()
  1419. * - encoding: set by user
  1420. * - decoding: set by user
  1421. */
  1422. int thread_count;
  1423. /**
  1424. * the codec may call this to execute several independant things. it will return only after
  1425. * finishing all tasks, the user may replace this with some multithreaded implementation, the
  1426. * default implementation will execute the parts serially
  1427. * @param count the number of things to execute
  1428. * - encoding: set by lavc, user can override
  1429. * - decoding: set by lavc, user can override
  1430. */
  1431. int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void **arg2, int *ret, int count);
  1432. /**
  1433. * Thread opaque.
  1434. * can be used by execute() to store some per AVCodecContext stuff.
  1435. * - encoding: set by execute()
  1436. * - decoding: set by execute()
  1437. */
  1438. void *thread_opaque;
  1439. /**
  1440. * Motion estimation threshold. under which no motion estimation is
  1441. * performed, but instead the user specified motion vectors are used
  1442. *
  1443. * - encoding: set by user
  1444. * - decoding: unused
  1445. */
  1446. int me_threshold;
  1447. /**
  1448. * Macroblock threshold. under which the user specified macroblock types will be used
  1449. * - encoding: set by user
  1450. * - decoding: unused
  1451. */
  1452. int mb_threshold;
  1453. /**
  1454. * precision of the intra dc coefficient - 8.
  1455. * - encoding: set by user
  1456. * - decoding: unused
  1457. */
  1458. int intra_dc_precision;
  1459. /**
  1460. * noise vs. sse weight for the nsse comparsion function.
  1461. * - encoding: set by user
  1462. * - decoding: unused
  1463. */
  1464. int nsse_weight;
  1465. /**
  1466. * number of macroblock rows at the top which are skiped.
  1467. * - encoding: unused
  1468. * - decoding: set by user
  1469. */
  1470. int skip_top;
  1471. /**
  1472. * number of macroblock rows at the bottom which are skiped.
  1473. * - encoding: unused
  1474. * - decoding: set by user
  1475. */
  1476. int skip_bottom;
  1477. /**
  1478. * profile
  1479. * - encoding: set by user
  1480. * - decoding: set by lavc
  1481. */
  1482. int profile;
  1483. #define FF_PROFILE_UNKNOWN -99
  1484. /**
  1485. * level
  1486. * - encoding: set by user
  1487. * - decoding: set by lavc
  1488. */
  1489. int level;
  1490. #define FF_LEVEL_UNKNOWN -99
  1491. /**
  1492. * low resolution decoding. 1-> 1/2 size, 2->1/4 size
  1493. * - encoding: unused
  1494. * - decoding: set by user
  1495. */
  1496. int lowres;
  1497. /**
  1498. * bistream width / height. may be different from width/height if lowres
  1499. * or other things are used
  1500. * - encoding: unused
  1501. * - decoding: set by user before init if known, codec should override / dynamically change if needed
  1502. */
  1503. int coded_width, coded_height;
  1504. } AVCodecContext;
  1505. /**
  1506. * AVOption.
  1507. */
  1508. typedef struct AVOption {
  1509. /** options' name */
  1510. const char *name; /* if name is NULL, it indicates a link to next */
  1511. /** short English text help or const struct AVOption* subpointer */
  1512. const char *help; // const struct AVOption* sub;
  1513. /** offset to context structure where the parsed value should be stored */
  1514. int offset;
  1515. /** options' type */
  1516. int type;
  1517. #define FF_OPT_TYPE_BOOL 1 ///< boolean - true,1,on (or simply presence)
  1518. #define FF_OPT_TYPE_DOUBLE 2 ///< double
  1519. #define FF_OPT_TYPE_INT 3 ///< integer
  1520. #define FF_OPT_TYPE_STRING 4 ///< string (finished with \0)
  1521. #define FF_OPT_TYPE_MASK 0x1f ///< mask for types - upper bits are various flags
  1522. //#define FF_OPT_TYPE_EXPERT 0x20 // flag for expert option
  1523. #define FF_OPT_TYPE_FLAG (FF_OPT_TYPE_BOOL | 0x40)
  1524. #define FF_OPT_TYPE_RCOVERRIDE (FF_OPT_TYPE_STRING | 0x80)
  1525. /** min value (min == max -> no limits) */
  1526. double min;
  1527. /** maximum value for double/int */
  1528. double max;
  1529. /** default boo [0,1]l/double/int value */
  1530. double defval;
  1531. /**
  1532. * default string value (with optional semicolon delimited extra option-list
  1533. * i.e. option1;option2;option3
  1534. * defval might select other then first argument as default
  1535. */
  1536. const char *defstr;
  1537. #define FF_OPT_MAX_DEPTH 10
  1538. } AVOption;
  1539. /**
  1540. * Parse option(s) and sets fields in passed structure
  1541. * @param strct structure where the parsed results will be written
  1542. * @param list list with AVOptions
  1543. * @param opts string with options for parsing
  1544. */
  1545. int avoption_parse(void* strct, const AVOption* list, const char* opts);
  1546. /**
  1547. * AVCodec.
  1548. */
  1549. typedef struct AVCodec {
  1550. const char *name;
  1551. enum CodecType type;
  1552. int id;
  1553. int priv_data_size;
  1554. int (*init)(AVCodecContext *);
  1555. int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data);
  1556. int (*close)(AVCodecContext *);
  1557. int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
  1558. uint8_t *buf, int buf_size);
  1559. int capabilities;
  1560. const AVOption *options;
  1561. struct AVCodec *next;
  1562. void (*flush)(AVCodecContext *);
  1563. const AVRational *supported_framerates; ///array of supported framerates, or NULL if any, array is terminated by {0,0}
  1564. const enum PixelFormat *pix_fmts; ///array of supported pixel formats, or NULL if unknown, array is terminanted by -1
  1565. } AVCodec;
  1566. /**
  1567. * four components are given, that's all.
  1568. * the last component is alpha
  1569. */
  1570. typedef struct AVPicture {
  1571. uint8_t *data[4];
  1572. int linesize[4]; ///< number of bytes per line
  1573. } AVPicture;
  1574. /**
  1575. * AVPaletteControl
  1576. * This structure defines a method for communicating palette changes
  1577. * between and demuxer and a decoder.
  1578. */
  1579. #define AVPALETTE_SIZE 1024
  1580. #define AVPALETTE_COUNT 256
  1581. typedef struct AVPaletteControl {
  1582. /* demuxer sets this to 1 to indicate the palette has changed;
  1583. * decoder resets to 0 */
  1584. int palette_changed;
  1585. /* 4-byte ARGB palette entries, stored in native byte order; note that
  1586. * the individual palette components should be on a 8-bit scale; if
  1587. * the palette data comes from a IBM VGA native format, the component
  1588. * data is probably 6 bits in size and needs to be scaled */
  1589. unsigned int palette[AVPALETTE_COUNT];
  1590. } AVPaletteControl;
  1591. extern AVCodec ac3_encoder;
  1592. extern AVCodec mp2_encoder;
  1593. extern AVCodec mp3lame_encoder;
  1594. extern AVCodec oggvorbis_encoder;
  1595. extern AVCodec faac_encoder;
  1596. extern AVCodec xvid_encoder;
  1597. extern AVCodec mpeg1video_encoder;
  1598. extern AVCodec mpeg2video_encoder;
  1599. extern AVCodec h263_encoder;
  1600. extern AVCodec h263p_encoder;
  1601. extern AVCodec flv_encoder;
  1602. extern AVCodec rv10_encoder;
  1603. extern AVCodec rv20_encoder;
  1604. extern AVCodec dvvideo_encoder;
  1605. extern AVCodec mjpeg_encoder;
  1606. extern AVCodec ljpeg_encoder;
  1607. extern AVCodec mpeg4_encoder;
  1608. extern AVCodec msmpeg4v1_encoder;
  1609. extern AVCodec msmpeg4v2_encoder;
  1610. extern AVCodec msmpeg4v3_encoder;
  1611. extern AVCodec wmv1_encoder;
  1612. extern AVCodec wmv2_encoder;
  1613. extern AVCodec huffyuv_encoder;
  1614. extern AVCodec h264_encoder;
  1615. extern AVCodec asv1_encoder;
  1616. extern AVCodec asv2_encoder;
  1617. extern AVCodec vcr1_encoder;
  1618. extern AVCodec ffv1_encoder;
  1619. extern AVCodec snow_encoder;
  1620. extern AVCodec mdec_encoder;
  1621. extern AVCodec zlib_encoder;
  1622. extern AVCodec sonic_encoder;
  1623. extern AVCodec sonic_ls_encoder;
  1624. extern AVCodec svq1_encoder;
  1625. extern AVCodec h263_decoder;
  1626. extern AVCodec h261_decoder;
  1627. extern AVCodec mpeg4_decoder;
  1628. extern AVCodec msmpeg4v1_decoder;
  1629. extern AVCodec msmpeg4v2_decoder;
  1630. extern AVCodec msmpeg4v3_decoder;
  1631. extern AVCodec wmv1_decoder;
  1632. extern AVCodec wmv2_decoder;
  1633. extern AVCodec mpeg1video_decoder;
  1634. extern AVCodec mpeg2video_decoder;
  1635. extern AVCodec mpegvideo_decoder;
  1636. extern AVCodec mpeg_xvmc_decoder;
  1637. extern AVCodec h263i_decoder;
  1638. extern AVCodec flv_decoder;
  1639. extern AVCodec rv10_decoder;
  1640. extern AVCodec rv20_decoder;
  1641. extern AVCodec svq1_decoder;
  1642. extern AVCodec svq3_decoder;
  1643. extern AVCodec dvvideo_decoder;
  1644. extern AVCodec wmav1_decoder;
  1645. extern AVCodec wmav2_decoder;
  1646. extern AVCodec mjpeg_decoder;
  1647. extern AVCodec mjpegb_decoder;
  1648. extern AVCodec sp5x_decoder;
  1649. extern AVCodec mp2_decoder;
  1650. extern AVCodec mp3_decoder;
  1651. extern AVCodec mace3_decoder;
  1652. extern AVCodec mace6_decoder;
  1653. extern AVCodec huffyuv_decoder;
  1654. extern AVCodec oggvorbis_decoder;
  1655. extern AVCodec cyuv_decoder;
  1656. extern AVCodec h264_decoder;
  1657. extern AVCodec indeo3_decoder;
  1658. extern AVCodec vp3_decoder;
  1659. extern AVCodec theora_decoder;
  1660. extern AVCodec amr_nb_decoder;
  1661. extern AVCodec amr_nb_encoder;
  1662. extern AVCodec amr_wb_encoder;
  1663. extern AVCodec amr_wb_decoder;
  1664. extern AVCodec aac_decoder;
  1665. extern AVCodec mpeg4aac_decoder;
  1666. extern AVCodec asv1_decoder;
  1667. extern AVCodec asv2_decoder;
  1668. extern AVCodec vcr1_decoder;
  1669. extern AVCodec cljr_decoder;
  1670. extern AVCodec ffv1_decoder;
  1671. extern AVCodec snow_decoder;
  1672. extern AVCodec fourxm_decoder;
  1673. extern AVCodec mdec_decoder;
  1674. extern AVCodec roq_decoder;
  1675. extern AVCodec interplay_video_decoder;
  1676. extern AVCodec xan_wc3_decoder;
  1677. extern AVCodec rpza_decoder;
  1678. extern AVCodec cinepak_decoder;
  1679. extern AVCodec msrle_decoder;
  1680. extern AVCodec msvideo1_decoder;
  1681. extern AVCodec vqa_decoder;
  1682. extern AVCodec idcin_decoder;
  1683. extern AVCodec eightbps_decoder;
  1684. extern AVCodec smc_decoder;
  1685. extern AVCodec flic_decoder;
  1686. extern AVCodec vmdvideo_decoder;
  1687. extern AVCodec vmdaudio_decoder;
  1688. extern AVCodec truemotion1_decoder;
  1689. extern AVCodec mszh_decoder;
  1690. extern AVCodec zlib_decoder;
  1691. extern AVCodec ra_144_decoder;
  1692. extern AVCodec ra_288_decoder;
  1693. extern AVCodec roq_dpcm_decoder;
  1694. extern AVCodec interplay_dpcm_decoder;
  1695. extern AVCodec xan_dpcm_decoder;
  1696. extern AVCodec sol_dpcm_decoder;
  1697. extern AVCodec sonic_decoder;
  1698. extern AVCodec qtrle_decoder;
  1699. extern AVCodec flac_decoder;
  1700. extern AVCodec tscc_decoder;
  1701. extern AVCodec ulti_decoder;
  1702. extern AVCodec qdraw_decoder;
  1703. /* pcm codecs */
  1704. #define PCM_CODEC(id, name) \
  1705. extern AVCodec name ## _decoder; \
  1706. extern AVCodec name ## _encoder
  1707. PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
  1708. PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
  1709. PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
  1710. PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
  1711. PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
  1712. PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
  1713. PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
  1714. PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
  1715. /* adpcm codecs */
  1716. PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
  1717. PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
  1718. PCM_CODEC(CODEC_ID_ADPCM_IMA_DK3, adpcm_ima_dk3);
  1719. PCM_CODEC(CODEC_ID_ADPCM_IMA_DK4, adpcm_ima_dk4);
  1720. PCM_CODEC(CODEC_ID_ADPCM_IMA_WS, adpcm_ima_ws);
  1721. PCM_CODEC(CODEC_ID_ADPCM_SMJPEG, adpcm_ima_smjpeg);
  1722. PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
  1723. PCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm);
  1724. PCM_CODEC(CODEC_ID_ADPCM_XA, adpcm_xa);
  1725. PCM_CODEC(CODEC_ID_ADPCM_ADX, adpcm_adx);
  1726. PCM_CODEC(CODEC_ID_ADPCM_EA, adpcm_ea);
  1727. PCM_CODEC(CODEC_ID_ADPCM_G726, adpcm_g726);
  1728. #undef PCM_CODEC
  1729. /* dummy raw video codec */
  1730. extern AVCodec rawvideo_encoder;
  1731. extern AVCodec rawvideo_decoder;
  1732. /* the following codecs use external GPL libs */
  1733. extern AVCodec ac3_decoder;
  1734. extern AVCodec dts_decoder;
  1735. /* resample.c */
  1736. struct ReSampleContext;
  1737. struct AVResampleContext;
  1738. typedef struct ReSampleContext ReSampleContext;
  1739. ReSampleContext *audio_resample_init(int output_channels, int input_channels,
  1740. int output_rate, int input_rate);
  1741. int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
  1742. void audio_resample_close(ReSampleContext *s);
  1743. struct AVResampleContext *av_resample_init(int out_rate, int in_rate);
  1744. int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx);
  1745. void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance);
  1746. void av_resample_close(struct AVResampleContext *c);
  1747. /* YUV420 format is assumed ! */
  1748. struct ImgReSampleContext;
  1749. typedef struct ImgReSampleContext ImgReSampleContext;
  1750. ImgReSampleContext *img_resample_init(int output_width, int output_height,
  1751. int input_width, int input_height);
  1752. ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
  1753. int iwidth, int iheight,
  1754. int topBand, int bottomBand,
  1755. int leftBand, int rightBand,
  1756. int padtop, int padbottom,
  1757. int padleft, int padright);
  1758. void img_resample(ImgReSampleContext *s,
  1759. AVPicture *output, const AVPicture *input);
  1760. void img_resample_close(ImgReSampleContext *s);
  1761. /**
  1762. * Allocate memory for a picture. Call avpicture_free to free it.
  1763. *
  1764. * @param picture the picture to be filled in.
  1765. * @param pix_fmt the format of the picture.
  1766. * @param width the width of the picture.
  1767. * @param height the height of the picture.
  1768. * @return 0 if successful, -1 if not.
  1769. */
  1770. int avpicture_alloc(AVPicture *picture, int pix_fmt, int width, int height);
  1771. /* Free a picture previously allocated by avpicture_alloc. */
  1772. void avpicture_free(AVPicture *picture);
  1773. int avpicture_fill(AVPicture *picture, uint8_t *ptr,
  1774. int pix_fmt, int width, int height);
  1775. int avpicture_layout(const AVPicture* src, int pix_fmt, int width, int height,
  1776. unsigned char *dest, int dest_size);
  1777. int avpicture_get_size(int pix_fmt, int width, int height);
  1778. void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift);
  1779. const char *avcodec_get_pix_fmt_name(int pix_fmt);
  1780. void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
  1781. enum PixelFormat avcodec_get_pix_fmt(const char* name);
  1782. #define FF_LOSS_RESOLUTION 0x0001 /* loss due to resolution change */
  1783. #define FF_LOSS_DEPTH 0x0002 /* loss due to color depth change */
  1784. #define FF_LOSS_COLORSPACE 0x0004 /* loss due to color space conversion */
  1785. #define FF_LOSS_ALPHA 0x0008 /* loss of alpha bits */
  1786. #define FF_LOSS_COLORQUANT 0x0010 /* loss due to color quantization */
  1787. #define FF_LOSS_CHROMA 0x0020 /* loss of chroma (e.g. rgb to gray conversion) */
  1788. int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt,
  1789. int has_alpha);
  1790. int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt,
  1791. int has_alpha, int *loss_ptr);
  1792. #define FF_ALPHA_TRANSP 0x0001 /* image has some totally transparent pixels */
  1793. #define FF_ALPHA_SEMI_TRANSP 0x0002 /* image has some transparent pixels */
  1794. int img_get_alpha_info(const AVPicture *src,
  1795. int pix_fmt, int width, int height);
  1796. /* convert among pixel formats */
  1797. int img_convert(AVPicture *dst, int dst_pix_fmt,
  1798. const AVPicture *src, int pix_fmt,
  1799. int width, int height);
  1800. /* deinterlace a picture */
  1801. int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
  1802. int pix_fmt, int width, int height);
  1803. /* external high level API */
  1804. extern AVCodec *first_avcodec;
  1805. /* returns LIBAVCODEC_VERSION_INT constant */
  1806. unsigned avcodec_version(void);
  1807. /* returns LIBAVCODEC_BUILD constant */
  1808. unsigned avcodec_build(void);
  1809. void avcodec_init(void);
  1810. void register_avcodec(AVCodec *format);
  1811. AVCodec *avcodec_find_encoder(enum CodecID id);
  1812. AVCodec *avcodec_find_encoder_by_name(const char *name);
  1813. AVCodec *avcodec_find_decoder(enum CodecID id);
  1814. AVCodec *avcodec_find_decoder_by_name(const char *name);
  1815. void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
  1816. void avcodec_get_context_defaults(AVCodecContext *s);
  1817. AVCodecContext *avcodec_alloc_context(void);
  1818. void avcodec_get_frame_defaults(AVFrame *pic);
  1819. AVFrame *avcodec_alloc_frame(void);
  1820. int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
  1821. void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
  1822. int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic);
  1823. void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);
  1824. enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt);
  1825. int avcodec_thread_init(AVCodecContext *s, int thread_count);
  1826. void avcodec_thread_free(AVCodecContext *s);
  1827. int avcodec_thread_execute(AVCodecContext *s, int (*func)(AVCodecContext *c2, void *arg2),void **arg, int *ret, int count);
  1828. int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void **arg, int *ret, int count);
  1829. //FIXME func typedef
  1830. /**
  1831. * opens / inits the AVCodecContext.
  1832. * not thread save!
  1833. */
  1834. int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
  1835. int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
  1836. int *frame_size_ptr,
  1837. uint8_t *buf, int buf_size);
  1838. int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
  1839. int *got_picture_ptr,
  1840. uint8_t *buf, int buf_size);
  1841. int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata,
  1842. int *data_size_ptr,
  1843. uint8_t *buf, int buf_size);
  1844. int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
  1845. const short *samples);
  1846. int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
  1847. const AVFrame *pict);
  1848. int avcodec_close(AVCodecContext *avctx);
  1849. void avcodec_register_all(void);
  1850. void avcodec_flush_buffers(AVCodecContext *avctx);
  1851. /* misc usefull functions */
  1852. /**
  1853. * returns a single letter to describe the picture type
  1854. */
  1855. char av_get_pict_type_char(int pict_type);
  1856. /**
  1857. * reduce a fraction.
  1858. * this is usefull for framerate calculations
  1859. * @param max the maximum allowed for dst_nom & dst_den
  1860. * @return 1 if exact, 0 otherwise
  1861. */
  1862. int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max);
  1863. /**
  1864. * rescale a 64bit integer with rounding to nearest.
  1865. * a simple a*b/c isnt possible as it can overflow
  1866. */
  1867. int64_t av_rescale(int64_t a, int64_t b, int64_t c);
  1868. /**
  1869. * rescale a 64bit integer with specified rounding.
  1870. * a simple a*b/c isnt possible as it can overflow
  1871. */
  1872. int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding);
  1873. /* frame parsing */
  1874. typedef struct AVCodecParserContext {
  1875. void *priv_data;
  1876. struct AVCodecParser *parser;
  1877. int64_t frame_offset; /* offset of the current frame */
  1878. int64_t cur_offset; /* current offset
  1879. (incremented by each av_parser_parse()) */
  1880. int64_t last_frame_offset; /* offset of the last frame */
  1881. /* video info */
  1882. int pict_type; /* XXX: put it back in AVCodecContext */
  1883. int repeat_pict; /* XXX: put it back in AVCodecContext */
  1884. int64_t pts; /* pts of the current frame */
  1885. int64_t dts; /* dts of the current frame */
  1886. /* private data */
  1887. int64_t last_pts;
  1888. int64_t last_dts;
  1889. int fetch_timestamp;
  1890. #define AV_PARSER_PTS_NB 4
  1891. int cur_frame_start_index;
  1892. int64_t cur_frame_offset[AV_PARSER_PTS_NB];
  1893. int64_t cur_frame_pts[AV_PARSER_PTS_NB];
  1894. int64_t cur_frame_dts[AV_PARSER_PTS_NB];
  1895. } AVCodecParserContext;
  1896. typedef struct AVCodecParser {
  1897. int codec_ids[3]; /* several codec IDs are permitted */
  1898. int priv_data_size;
  1899. int (*parser_init)(AVCodecParserContext *s);
  1900. int (*parser_parse)(AVCodecParserContext *s,
  1901. AVCodecContext *avctx,
  1902. uint8_t **poutbuf, int *poutbuf_size,
  1903. const uint8_t *buf, int buf_size);
  1904. void (*parser_close)(AVCodecParserContext *s);
  1905. struct AVCodecParser *next;
  1906. } AVCodecParser;
  1907. extern AVCodecParser *av_first_parser;
  1908. void av_register_codec_parser(AVCodecParser *parser);
  1909. AVCodecParserContext *av_parser_init(int codec_id);
  1910. int av_parser_parse(AVCodecParserContext *s,
  1911. AVCodecContext *avctx,
  1912. uint8_t **poutbuf, int *poutbuf_size,
  1913. const uint8_t *buf, int buf_size,
  1914. int64_t pts, int64_t dts);
  1915. void av_parser_close(AVCodecParserContext *s);
  1916. extern AVCodecParser mpegvideo_parser;
  1917. extern AVCodecParser mpeg4video_parser;
  1918. extern AVCodecParser h261_parser;
  1919. extern AVCodecParser h263_parser;
  1920. extern AVCodecParser h264_parser;
  1921. extern AVCodecParser mpegaudio_parser;
  1922. extern AVCodecParser ac3_parser;
  1923. /* memory */
  1924. void *av_malloc(unsigned int size);
  1925. void *av_mallocz(unsigned int size);
  1926. void *av_realloc(void *ptr, unsigned int size);
  1927. void av_free(void *ptr);
  1928. char *av_strdup(const char *s);
  1929. void av_freep(void *ptr);
  1930. void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
  1931. /* for static data only */
  1932. /* call av_free_static to release all staticaly allocated tables */
  1933. void av_free_static(void);
  1934. void *av_mallocz_static(unsigned int size);
  1935. /* add by bero : in adx.c */
  1936. int is_adx(const unsigned char *buf,size_t bufsize);
  1937. void img_copy(AVPicture *dst, const AVPicture *src,
  1938. int pix_fmt, int width, int height);
  1939. /* av_log API */
  1940. #include <stdarg.h>
  1941. #define AV_LOG_QUIET -1
  1942. #define AV_LOG_ERROR 0
  1943. #define AV_LOG_INFO 1
  1944. #define AV_LOG_DEBUG 2
  1945. #ifdef __GNUC__
  1946. extern void av_log(void*, int level, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4)));
  1947. #else
  1948. extern void av_log(void*, int level, const char *fmt, ...);
  1949. #endif
  1950. extern void av_vlog(void*, int level, const char *fmt, va_list);
  1951. extern int av_log_get_level(void);
  1952. extern void av_log_set_level(int);
  1953. extern void av_log_set_callback(void (*)(void*, int, const char*, va_list));
  1954. /* endian macros */
  1955. #if !defined(BE_16) || !defined(BE_32) || !defined(LE_16) || !defined(LE_32)
  1956. #define BE_16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1])
  1957. #define BE_32(x) ((((uint8_t*)(x))[0] << 24) | \
  1958. (((uint8_t*)(x))[1] << 16) | \
  1959. (((uint8_t*)(x))[2] << 8) | \
  1960. ((uint8_t*)(x))[3])
  1961. #define LE_16(x) ((((uint8_t*)(x))[1] << 8) | ((uint8_t*)(x))[0])
  1962. #define LE_32(x) ((((uint8_t*)(x))[3] << 24) | \
  1963. (((uint8_t*)(x))[2] << 16) | \
  1964. (((uint8_t*)(x))[1] << 8) | \
  1965. ((uint8_t*)(x))[0])
  1966. #endif
  1967. #ifdef __cplusplus
  1968. }
  1969. #endif
  1970. #endif /* AVCODEC_H */