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.

2249 lines
67KB

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