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.

1860 lines
53KB

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