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.

2177 lines
64KB

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