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.

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