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.

2224 lines
66KB

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