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.

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