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.

1589 lines
45KB

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