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.

1616 lines
46KB

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