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.

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