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.

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