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.

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