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.

1650 lines
47KB

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