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.

1580 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 4672
  14. #define LIBAVCODEC_BUILD_STR "4672"
  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_HQ 0x0001 ///< brute force MB-type decission mode (slow)
  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: unused
  418. * - decoding: set by lavc.
  419. */
  420. enum PixelFormat pix_fmt;
  421. /**
  422. * Frame rate emulation. If not zero lower layer (i.e. format handler)
  423. * has to read frames at native frame rate.
  424. * - encoding: set by user.
  425. * - decoding: unused.
  426. */
  427. int rate_emu;
  428. /**
  429. * if non NULL, 'draw_horiz_band' is called by the libavcodec
  430. * decoder to draw an horizontal band. It improve cache usage. Not
  431. * all codecs can do that. You must check the codec capabilities
  432. * before
  433. * - encoding: unused
  434. * - decoding: set by user.
  435. * @param height the height of the slice
  436. * @param y the y position of the slice
  437. * @param type 1->top field, 2->bottom field, 3->frame
  438. * @param offset offset into the AVFrame.data from which the slice should be read
  439. */
  440. void (*draw_horiz_band)(struct AVCodecContext *s,
  441. AVFrame *src, int offset[4],
  442. int y, int type, int height);
  443. /* audio only */
  444. int sample_rate; ///< samples per sec
  445. int channels;
  446. int sample_fmt; ///< sample format, currenly unused
  447. /* the following data should not be initialized */
  448. int frame_size; ///< in samples, initialized when calling 'init'
  449. int frame_number; ///< audio or video frame number
  450. int real_pict_num; ///< returns the real picture number of previous encoded frame
  451. /**
  452. * number of frames the decoded output will be delayed relative to
  453. * the encoded input.
  454. * - encoding: set by lavc.
  455. * - decoding: unused
  456. */
  457. int delay;
  458. /* - encoding parameters */
  459. float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)
  460. float qblur; ///< amount of qscale smoothing over time (0.0-1.0)
  461. /**
  462. * minimum quantizer.
  463. * - encoding: set by user.
  464. * - decoding: unused
  465. */
  466. int qmin;
  467. /**
  468. * maximum quantizer.
  469. * - encoding: set by user.
  470. * - decoding: unused
  471. */
  472. int qmax;
  473. /**
  474. * maximum quantizer difference etween frames.
  475. * - encoding: set by user.
  476. * - decoding: unused
  477. */
  478. int max_qdiff;
  479. /**
  480. * maximum number of b frames between non b frames.
  481. * note: the output will be delayed by max_b_frames+1 relative to the input
  482. * - encoding: set by user.
  483. * - decoding: unused
  484. */
  485. int max_b_frames;
  486. /**
  487. * qscale factor between ip and b frames.
  488. * - encoding: set by user.
  489. * - decoding: unused
  490. */
  491. float b_quant_factor;
  492. /** obsolete FIXME remove */
  493. int rc_strategy;
  494. int b_frame_strategy;
  495. /**
  496. * hurry up amount.
  497. * - encoding: unused
  498. * - decoding: set by user. 1-> skip b frames, 2-> skip idct/dequant too, 5-> skip everything except header
  499. */
  500. int hurry_up;
  501. struct AVCodec *codec;
  502. void *priv_data;
  503. /* The following data is for RTP friendly coding */
  504. /* By now only H.263/H.263+/MPEG4 coder honours this */
  505. int rtp_mode; /* 1 for activate RTP friendly-mode */
  506. /* highers numbers represent more error-prone */
  507. /* enviroments, by now just "1" exist */
  508. int rtp_payload_size; /* The size of the RTP payload, the coder will */
  509. /* do it's best to deliver a chunk with size */
  510. /* below rtp_payload_size, the chunk will start */
  511. /* with a start code on some codecs like H.263 */
  512. /* This doesn't take account of any particular */
  513. /* headers inside the transmited RTP payload */
  514. /* The RTP callcack: This function is called */
  515. /* every time the encoder as a packet to send */
  516. /* Depends on the encoder if the data starts */
  517. /* with a Start Code (it should) H.263 does */
  518. void (*rtp_callback)(void *data, int size, int packet_number);
  519. /* statistics, used for 2-pass encoding */
  520. int mv_bits;
  521. int header_bits;
  522. int i_tex_bits;
  523. int p_tex_bits;
  524. int i_count;
  525. int p_count;
  526. int skip_count;
  527. int misc_bits;
  528. /**
  529. * number of bits used for the previously encoded frame.
  530. * - encoding: set by lavc
  531. * - decoding: unused
  532. */
  533. int frame_bits;
  534. /**
  535. * private data of the user, can be used to carry app specific stuff.
  536. * - encoding: set by user
  537. * - decoding: set by user
  538. */
  539. void *opaque;
  540. char codec_name[32];
  541. enum CodecType codec_type; /* see CODEC_TYPE_xxx */
  542. enum CodecID codec_id; /* see CODEC_ID_xxx */
  543. /**
  544. * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
  545. * this is used to workaround some encoder bugs
  546. * - encoding: unused
  547. * - decoding: set by user, will be converted to upper case by lavc during init
  548. */
  549. unsigned int codec_tag;
  550. /**
  551. * workaround bugs in encoders which sometimes cannot be detected automatically.
  552. * - encoding: unused
  553. * - decoding: set by user
  554. */
  555. int workaround_bugs;
  556. #define FF_BUG_AUTODETECT 1 ///< autodetection
  557. #define FF_BUG_OLD_MSMPEG4 2
  558. #define FF_BUG_XVID_ILACE 4
  559. #define FF_BUG_UMP4 8
  560. #define FF_BUG_NO_PADDING 16
  561. #define FF_BUG_AC_VLC 32
  562. #define FF_BUG_QPEL_CHROMA 64
  563. #define FF_BUG_STD_QPEL 128
  564. #define FF_BUG_QPEL_CHROMA2 256
  565. #define FF_BUG_DIRECT_BLOCKSIZE 512
  566. #define FF_BUG_EDGE 1024
  567. //#define FF_BUG_FAKE_SCALABILITY 16 //autodetection should work 100%
  568. /**
  569. * luma single coeff elimination threshold.
  570. * - encoding: set by user
  571. * - decoding: unused
  572. */
  573. int luma_elim_threshold;
  574. /**
  575. * chroma single coeff elimination threshold.
  576. * - encoding: set by user
  577. * - decoding: unused
  578. */
  579. int chroma_elim_threshold;
  580. /**
  581. * strictly follow the std (MPEG4, ...).
  582. * - encoding: set by user
  583. * - decoding: unused
  584. */
  585. int strict_std_compliance;
  586. /**
  587. * qscale offset between ip and b frames.
  588. * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
  589. * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
  590. * - encoding: set by user.
  591. * - decoding: unused
  592. */
  593. float b_quant_offset;
  594. /**
  595. * error resilience higher values will detect more errors but may missdetect
  596. * some more or less valid parts as errors.
  597. * - encoding: unused
  598. * - decoding: set by user
  599. */
  600. int error_resilience;
  601. #define FF_ER_CAREFULL 1
  602. #define FF_ER_COMPLIANT 2
  603. #define FF_ER_AGGRESSIVE 3
  604. #define FF_ER_VERY_AGGRESSIVE 4
  605. /**
  606. * called at the beginning of each frame to get a buffer for it.
  607. * if pic.reference is set then the frame will be read later by lavc
  608. * width and height should be rounded up to the next multiple of 16
  609. * - encoding: unused
  610. * - decoding: set by lavc, user can override
  611. */
  612. int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
  613. /**
  614. * called to release buffers which where allocated with get_buffer.
  615. * a released buffer can be reused in get_buffer()
  616. * pic.data[*] must be set to NULL
  617. * - encoding: unused
  618. * - decoding: set by lavc, user can override
  619. */
  620. void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
  621. /**
  622. * is 1 if the decoded stream contains b frames, 0 otherwise.
  623. * - encoding: unused
  624. * - decoding: set by lavc
  625. */
  626. int has_b_frames;
  627. int block_align; ///< used by some WAV based audio codecs
  628. int parse_only; /* - decoding only: if true, only parsing is done
  629. (function avcodec_parse_frame()). The frame
  630. data is returned. Only MPEG codecs support this now. */
  631. /**
  632. * 0-> h263 quant 1-> mpeg quant.
  633. * - encoding: set by user.
  634. * - decoding: unused
  635. */
  636. int mpeg_quant;
  637. /**
  638. * pass1 encoding statistics output buffer.
  639. * - encoding: set by lavc
  640. * - decoding: unused
  641. */
  642. char *stats_out;
  643. /**
  644. * pass2 encoding statistics input buffer.
  645. * concatenated stuff from stats_out of pass1 should be placed here
  646. * - encoding: allocated/set/freed by user
  647. * - decoding: unused
  648. */
  649. char *stats_in;
  650. /**
  651. * ratecontrol qmin qmax limiting method.
  652. * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax
  653. * - encoding: set by user.
  654. * - decoding: unused
  655. */
  656. float rc_qsquish;
  657. float rc_qmod_amp;
  658. int rc_qmod_freq;
  659. /**
  660. * ratecontrol override, see RcOverride.
  661. * - encoding: allocated/set/freed by user.
  662. * - decoding: unused
  663. */
  664. RcOverride *rc_override;
  665. int rc_override_count;
  666. /**
  667. * rate control equation.
  668. * - encoding: set by user
  669. * - decoding: unused
  670. */
  671. char *rc_eq;
  672. /**
  673. * maximum bitrate.
  674. * - encoding: set by user.
  675. * - decoding: unused
  676. */
  677. int rc_max_rate;
  678. /**
  679. * minimum bitrate.
  680. * - encoding: set by user.
  681. * - decoding: unused
  682. */
  683. int rc_min_rate;
  684. /**
  685. * decoder bitstream buffer size.
  686. * - encoding: set by user.
  687. * - decoding: unused
  688. */
  689. int rc_buffer_size;
  690. float rc_buffer_aggressivity;
  691. /**
  692. * qscale factor between p and i frames.
  693. * - encoding: set by user.
  694. * - decoding: unused
  695. */
  696. float i_quant_factor;
  697. /**
  698. * qscale offset between p and i frames.
  699. * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
  700. * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
  701. * - encoding: set by user.
  702. * - decoding: unused
  703. */
  704. float i_quant_offset;
  705. /**
  706. * initial complexity for pass1 ratecontrol.
  707. * - encoding: set by user.
  708. * - decoding: unused
  709. */
  710. float rc_initial_cplx;
  711. /**
  712. * dct algorithm, see FF_DCT_* below.
  713. * - encoding: set by user
  714. * - decoding: unused
  715. */
  716. int dct_algo;
  717. #define FF_DCT_AUTO 0
  718. #define FF_DCT_FASTINT 1
  719. #define FF_DCT_INT 2
  720. #define FF_DCT_MMX 3
  721. #define FF_DCT_MLIB 4
  722. #define FF_DCT_ALTIVEC 5
  723. /**
  724. * luminance masking (0-> disabled).
  725. * - encoding: set by user
  726. * - decoding: unused
  727. */
  728. float lumi_masking;
  729. /**
  730. * temporary complexity masking (0-> disabled).
  731. * - encoding: set by user
  732. * - decoding: unused
  733. */
  734. float temporal_cplx_masking;
  735. /**
  736. * spatial complexity masking (0-> disabled).
  737. * - encoding: set by user
  738. * - decoding: unused
  739. */
  740. float spatial_cplx_masking;
  741. /**
  742. * p block masking (0-> disabled).
  743. * - encoding: set by user
  744. * - decoding: unused
  745. */
  746. float p_masking;
  747. /**
  748. * darkness masking (0-> disabled).
  749. * - encoding: set by user
  750. * - decoding: unused
  751. */
  752. float dark_masking;
  753. /* for binary compatibility */
  754. int unused;
  755. /**
  756. * idct algorithm, see FF_IDCT_* below.
  757. * - encoding: set by user
  758. * - decoding: set by user
  759. */
  760. int idct_algo;
  761. #define FF_IDCT_AUTO 0
  762. #define FF_IDCT_INT 1
  763. #define FF_IDCT_SIMPLE 2
  764. #define FF_IDCT_SIMPLEMMX 3
  765. #define FF_IDCT_LIBMPEG2MMX 4
  766. #define FF_IDCT_PS2 5
  767. #define FF_IDCT_MLIB 6
  768. #define FF_IDCT_ARM 7
  769. #define FF_IDCT_ALTIVEC 8
  770. #define FF_IDCT_SH4 9
  771. #define FF_IDCT_SIMPLEARM 10
  772. /**
  773. * slice count.
  774. * - encoding: set by lavc
  775. * - decoding: set by user (or 0)
  776. */
  777. int slice_count;
  778. /**
  779. * slice offsets in the frame in bytes.
  780. * - encoding: set/allocated by lavc
  781. * - decoding: set/allocated by user (or NULL)
  782. */
  783. int *slice_offset;
  784. /**
  785. * error concealment flags.
  786. * - encoding: unused
  787. * - decoding: set by user
  788. */
  789. int error_concealment;
  790. #define FF_EC_GUESS_MVS 1
  791. #define FF_EC_DEBLOCK 2
  792. /**
  793. * dsp_mask could be add used to disable unwanted CPU features
  794. * CPU features (i.e. MMX, SSE. ...)
  795. *
  796. * with FORCE flag you may instead enable given CPU features
  797. * (Dangerous: usable in case of misdetection, improper usage however will
  798. * result into program crash)
  799. */
  800. unsigned dsp_mask;
  801. #define FF_MM_FORCE 0x80000000 /* force usage of selected flags (OR) */
  802. /* lower 16 bits - CPU features */
  803. #ifdef HAVE_MMX
  804. #define FF_MM_MMX 0x0001 /* standard MMX */
  805. #define FF_MM_3DNOW 0x0004 /* AMD 3DNOW */
  806. #define FF_MM_MMXEXT 0x0002 /* SSE integer functions or AMD MMX ext */
  807. #define FF_MM_SSE 0x0008 /* SSE functions */
  808. #define FF_MM_SSE2 0x0010 /* PIV SSE2 functions */
  809. #endif /* HAVE_MMX */
  810. /**
  811. * bits per sample/pixel from the demuxer (needed for huffyuv).
  812. * - encoding: set by lavc
  813. * - decoding: set by user
  814. */
  815. int bits_per_sample;
  816. /**
  817. * prediction method (needed for huffyuv).
  818. * - encoding: set by user
  819. * - decoding: unused
  820. */
  821. int prediction_method;
  822. #define FF_PRED_LEFT 0
  823. #define FF_PRED_PLANE 1
  824. #define FF_PRED_MEDIAN 2
  825. /**
  826. * aspect ratio (0 if unknown).
  827. * - encoding: set by user.
  828. * - decoding: set by lavc.
  829. */
  830. float aspect_ratio;
  831. /**
  832. * the picture in the bitstream.
  833. * - encoding: set by lavc
  834. * - decoding: set by lavc
  835. */
  836. AVFrame *coded_frame;
  837. /**
  838. * debug.
  839. * - encoding: set by user.
  840. * - decoding: set by user.
  841. */
  842. int debug;
  843. #define FF_DEBUG_PICT_INFO 1
  844. #define FF_DEBUG_RC 2
  845. #define FF_DEBUG_BITSTREAM 4
  846. #define FF_DEBUG_MB_TYPE 8
  847. #define FF_DEBUG_QP 16
  848. #define FF_DEBUG_MV 32
  849. #define FF_DEBUG_VIS_MV 0x00000040
  850. #define FF_DEBUG_SKIP 0x00000080
  851. #define FF_DEBUG_STARTCODE 0x00000100
  852. #define FF_DEBUG_PTS 0x00000200
  853. #define FF_DEBUG_ER 0x00000400
  854. #define FF_DEBUG_MMCO 0x00000800
  855. /**
  856. * error.
  857. * - encoding: set by lavc if flags&CODEC_FLAG_PSNR
  858. * - decoding: unused
  859. */
  860. uint64_t error[4];
  861. /**
  862. * minimum MB quantizer.
  863. * - encoding: set by user.
  864. * - decoding: unused
  865. */
  866. int mb_qmin;
  867. /**
  868. * maximum MB quantizer.
  869. * - encoding: set by user.
  870. * - decoding: unused
  871. */
  872. int mb_qmax;
  873. /**
  874. * motion estimation compare function.
  875. * - encoding: set by user.
  876. * - decoding: unused
  877. */
  878. int me_cmp;
  879. /**
  880. * subpixel motion estimation compare function.
  881. * - encoding: set by user.
  882. * - decoding: unused
  883. */
  884. int me_sub_cmp;
  885. /**
  886. * macroblock compare function (not supported yet).
  887. * - encoding: set by user.
  888. * - decoding: unused
  889. */
  890. int mb_cmp;
  891. #define FF_CMP_SAD 0
  892. #define FF_CMP_SSE 1
  893. #define FF_CMP_SATD 2
  894. #define FF_CMP_DCT 3
  895. #define FF_CMP_PSNR 4
  896. #define FF_CMP_BIT 5
  897. #define FF_CMP_RD 6
  898. #define FF_CMP_ZERO 7
  899. #define FF_CMP_CHROMA 256
  900. /**
  901. * ME diamond size & shape.
  902. * - encoding: set by user.
  903. * - decoding: unused
  904. */
  905. int dia_size;
  906. /**
  907. * amount of previous MV predictors (2a+1 x 2a+1 square).
  908. * - encoding: set by user.
  909. * - decoding: unused
  910. */
  911. int last_predictor_count;
  912. /**
  913. * pre pass for motion estimation.
  914. * - encoding: set by user.
  915. * - decoding: unused
  916. */
  917. int pre_me;
  918. /**
  919. * motion estimation pre pass compare function.
  920. * - encoding: set by user.
  921. * - decoding: unused
  922. */
  923. int me_pre_cmp;
  924. /**
  925. * ME pre pass diamond size & shape.
  926. * - encoding: set by user.
  927. * - decoding: unused
  928. */
  929. int pre_dia_size;
  930. /**
  931. * subpel ME quality.
  932. * - encoding: set by user.
  933. * - decoding: unused
  934. */
  935. int me_subpel_quality;
  936. /**
  937. * callback to negotiate the pixelFormat.
  938. * @param fmt is the list of formats which are supported by the codec,
  939. * its terminated by -1 as 0 is a valid format, the formats are ordered by quality
  940. * the first is allways the native one
  941. * @return the choosen format
  942. * - encoding: unused
  943. * - decoding: set by user, if not set then the native format will always be choosen
  944. */
  945. enum PixelFormat (*get_format)(struct AVCodecContext *s, enum PixelFormat * fmt);
  946. /**
  947. * DTG active format information (additionnal aspect ratio
  948. * information only used in DVB MPEG2 transport streams). 0 if
  949. * not set.
  950. *
  951. * - encoding: unused.
  952. * - decoding: set by decoder
  953. */
  954. int dtg_active_format;
  955. #define FF_DTG_AFD_SAME 8
  956. #define FF_DTG_AFD_4_3 9
  957. #define FF_DTG_AFD_16_9 10
  958. #define FF_DTG_AFD_14_9 11
  959. #define FF_DTG_AFD_4_3_SP_14_9 13
  960. #define FF_DTG_AFD_16_9_SP_14_9 14
  961. #define FF_DTG_AFD_SP_4_3 15
  962. /**
  963. * Maximum motion estimation search range in subpel units.
  964. * if 0 then no limit
  965. *
  966. * - encoding: set by user.
  967. * - decoding: unused.
  968. */
  969. int me_range;
  970. /**
  971. * frame_rate_base.
  972. * for variable fps this is 1
  973. * - encoding: set by user.
  974. * - decoding: set by lavc.
  975. * @todo move this after frame_rate
  976. */
  977. int frame_rate_base;
  978. /**
  979. * intra quantizer bias.
  980. * - encoding: set by user.
  981. * - decoding: unused
  982. */
  983. int intra_quant_bias;
  984. #define FF_DEFAULT_QUANT_BIAS 999999
  985. /**
  986. * inter quantizer bias.
  987. * - encoding: set by user.
  988. * - decoding: unused
  989. */
  990. int inter_quant_bias;
  991. /**
  992. * color table ID.
  993. * - encoding: unused.
  994. * - decoding: which clrtable should be used for 8bit RGB images
  995. * table have to be stored somewhere FIXME
  996. */
  997. int color_table_id;
  998. /**
  999. * internal_buffer count.
  1000. * Dont touch, used by lavc default_get_buffer()
  1001. */
  1002. int internal_buffer_count;
  1003. /**
  1004. * internal_buffers.
  1005. * Dont touch, used by lavc default_get_buffer()
  1006. */
  1007. void *internal_buffer;
  1008. #define FF_QUALITY_SCALE 256
  1009. /**
  1010. * global quality for codecs which cannot change it per frame.
  1011. * this should be proportional to MPEG1/2/4 qscale.
  1012. * - encoding: set by user.
  1013. * - decoding: unused
  1014. */
  1015. int global_quality;
  1016. #define FF_CODER_TYPE_VLC 0
  1017. #define FF_CODER_TYPE_AC 1
  1018. /**
  1019. * coder type
  1020. * - encoding: set by user.
  1021. * - decoding: unused
  1022. */
  1023. int coder_type;
  1024. /**
  1025. * context model
  1026. * - encoding: set by user.
  1027. * - decoding: unused
  1028. */
  1029. int context_model;
  1030. /**
  1031. * slice flags
  1032. * - encoding: unused
  1033. * - decoding: set by user.
  1034. */
  1035. int slice_flags;
  1036. #define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display
  1037. #define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics)
  1038. #define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
  1039. /**
  1040. * XVideo Motion Acceleration
  1041. * - encoding: forbidden
  1042. * - decoding: set by decoder
  1043. */
  1044. int xvmc_acceleration;
  1045. } AVCodecContext;
  1046. /**
  1047. * AVOption.
  1048. */
  1049. typedef struct AVOption {
  1050. /** options' name */
  1051. const char *name; /* if name is NULL, it indicates a link to next */
  1052. /** short English text help or const struct AVOption* subpointer */
  1053. const char *help; // const struct AVOption* sub;
  1054. /** offset to context structure where the parsed value should be stored */
  1055. int offset;
  1056. /** options' type */
  1057. int type;
  1058. #define FF_OPT_TYPE_BOOL 1 ///< boolean - true,1,on (or simply presence)
  1059. #define FF_OPT_TYPE_DOUBLE 2 ///< double
  1060. #define FF_OPT_TYPE_INT 3 ///< integer
  1061. #define FF_OPT_TYPE_STRING 4 ///< string (finished with \0)
  1062. #define FF_OPT_TYPE_MASK 0x1f ///< mask for types - upper bits are various flags
  1063. //#define FF_OPT_TYPE_EXPERT 0x20 // flag for expert option
  1064. #define FF_OPT_TYPE_FLAG (FF_OPT_TYPE_BOOL | 0x40)
  1065. #define FF_OPT_TYPE_RCOVERRIDE (FF_OPT_TYPE_STRING | 0x80)
  1066. /** min value (min == max -> no limits) */
  1067. double min;
  1068. /** maximum value for double/int */
  1069. double max;
  1070. /** default boo [0,1]l/double/int value */
  1071. double defval;
  1072. /**
  1073. * default string value (with optional semicolon delimited extra option-list
  1074. * i.e. option1;option2;option3
  1075. * defval might select other then first argument as default
  1076. */
  1077. const char *defstr;
  1078. #define FF_OPT_MAX_DEPTH 10
  1079. } AVOption;
  1080. /**
  1081. * Parse option(s) and sets fields in passed structure
  1082. * @param strct structure where the parsed results will be written
  1083. * @param list list with AVOptions
  1084. * @param opts string with options for parsing
  1085. */
  1086. int avoption_parse(void* strct, const AVOption* list, const char* opts);
  1087. /**
  1088. * AVCodec.
  1089. */
  1090. typedef struct AVCodec {
  1091. const char *name;
  1092. enum CodecType type;
  1093. int id;
  1094. int priv_data_size;
  1095. int (*init)(AVCodecContext *);
  1096. int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data);
  1097. int (*close)(AVCodecContext *);
  1098. int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
  1099. uint8_t *buf, int buf_size);
  1100. int capabilities;
  1101. const AVOption *options;
  1102. struct AVCodec *next;
  1103. void (*flush)(AVCodecContext *);
  1104. } AVCodec;
  1105. /**
  1106. * four components are given, that's all.
  1107. * the last component is alpha
  1108. */
  1109. typedef struct AVPicture {
  1110. uint8_t *data[4];
  1111. int linesize[4]; ///< number of bytes per line
  1112. } AVPicture;
  1113. extern AVCodec ac3_encoder;
  1114. extern AVCodec mp2_encoder;
  1115. extern AVCodec mp3lame_encoder;
  1116. extern AVCodec oggvorbis_encoder;
  1117. extern AVCodec mpeg1video_encoder;
  1118. extern AVCodec h263_encoder;
  1119. extern AVCodec h263p_encoder;
  1120. extern AVCodec flv_encoder;
  1121. extern AVCodec rv10_encoder;
  1122. extern AVCodec mjpeg_encoder;
  1123. extern AVCodec ljpeg_encoder;
  1124. extern AVCodec mpeg4_encoder;
  1125. extern AVCodec msmpeg4v1_encoder;
  1126. extern AVCodec msmpeg4v2_encoder;
  1127. extern AVCodec msmpeg4v3_encoder;
  1128. extern AVCodec wmv1_encoder;
  1129. extern AVCodec wmv2_encoder;
  1130. extern AVCodec huffyuv_encoder;
  1131. extern AVCodec h264_encoder;
  1132. extern AVCodec asv1_encoder;
  1133. extern AVCodec vcr1_encoder;
  1134. extern AVCodec ffv1_encoder;
  1135. extern AVCodec h263_decoder;
  1136. extern AVCodec mpeg4_decoder;
  1137. extern AVCodec msmpeg4v1_decoder;
  1138. extern AVCodec msmpeg4v2_decoder;
  1139. extern AVCodec msmpeg4v3_decoder;
  1140. extern AVCodec wmv1_decoder;
  1141. extern AVCodec wmv2_decoder;
  1142. extern AVCodec mpeg_decoder;
  1143. extern AVCodec mpeg_xvmc_decoder;
  1144. extern AVCodec h263i_decoder;
  1145. extern AVCodec flv_decoder;
  1146. extern AVCodec rv10_decoder;
  1147. extern AVCodec svq1_decoder;
  1148. extern AVCodec svq3_decoder;
  1149. extern AVCodec dvvideo_decoder;
  1150. extern AVCodec dvaudio_decoder;
  1151. extern AVCodec wmav1_decoder;
  1152. extern AVCodec wmav2_decoder;
  1153. extern AVCodec mjpeg_decoder;
  1154. extern AVCodec mjpegb_decoder;
  1155. extern AVCodec mp2_decoder;
  1156. extern AVCodec mp3_decoder;
  1157. extern AVCodec mace3_decoder;
  1158. extern AVCodec mace6_decoder;
  1159. extern AVCodec huffyuv_decoder;
  1160. extern AVCodec oggvorbis_decoder;
  1161. extern AVCodec cyuv_decoder;
  1162. extern AVCodec h264_decoder;
  1163. extern AVCodec indeo3_decoder;
  1164. extern AVCodec vp3_decoder;
  1165. extern AVCodec amr_nb_decoder;
  1166. extern AVCodec amr_nb_encoder;
  1167. extern AVCodec aac_decoder;
  1168. extern AVCodec mpeg4aac_decoder;
  1169. extern AVCodec asv1_decoder;
  1170. extern AVCodec vcr1_decoder;
  1171. extern AVCodec cljr_decoder;
  1172. extern AVCodec ffv1_decoder;
  1173. extern AVCodec fourxm_decoder;
  1174. extern AVCodec ra_144_decoder;
  1175. extern AVCodec ra_288_decoder;
  1176. /* pcm codecs */
  1177. #define PCM_CODEC(id, name) \
  1178. extern AVCodec name ## _decoder; \
  1179. extern AVCodec name ## _encoder
  1180. PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
  1181. PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
  1182. PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
  1183. PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
  1184. PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
  1185. PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
  1186. PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
  1187. PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
  1188. /* adpcm codecs */
  1189. PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
  1190. PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
  1191. PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
  1192. PCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm);
  1193. #undef PCM_CODEC
  1194. /* dummy raw video codec */
  1195. extern AVCodec rawvideo_encoder;
  1196. extern AVCodec rawvideo_decoder;
  1197. /* the following codecs use external GPL libs */
  1198. extern AVCodec ac3_decoder;
  1199. /* resample.c */
  1200. struct ReSampleContext;
  1201. typedef struct ReSampleContext ReSampleContext;
  1202. ReSampleContext *audio_resample_init(int output_channels, int input_channels,
  1203. int output_rate, int input_rate);
  1204. int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
  1205. void audio_resample_close(ReSampleContext *s);
  1206. /* YUV420 format is assumed ! */
  1207. struct ImgReSampleContext;
  1208. typedef struct ImgReSampleContext ImgReSampleContext;
  1209. ImgReSampleContext *img_resample_init(int output_width, int output_height,
  1210. int input_width, int input_height);
  1211. ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
  1212. int iwidth, int iheight,
  1213. int topBand, int bottomBand,
  1214. int leftBand, int rightBand);
  1215. void img_resample(ImgReSampleContext *s,
  1216. AVPicture *output, AVPicture *input);
  1217. void img_resample_close(ImgReSampleContext *s);
  1218. int avpicture_fill(AVPicture *picture, uint8_t *ptr,
  1219. int pix_fmt, int width, int height);
  1220. int avpicture_layout(AVPicture* src, int pix_fmt, int width, int height,
  1221. unsigned char *dest, int dest_size);
  1222. int avpicture_get_size(int pix_fmt, int width, int height);
  1223. void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift);
  1224. const char *avcodec_get_pix_fmt_name(int pix_fmt);
  1225. enum PixelFormat avcodec_get_pix_fmt(const char* name);
  1226. #define FF_LOSS_RESOLUTION 0x0001 /* loss due to resolution change */
  1227. #define FF_LOSS_DEPTH 0x0002 /* loss due to color depth change */
  1228. #define FF_LOSS_COLORSPACE 0x0004 /* loss due to color space conversion */
  1229. #define FF_LOSS_ALPHA 0x0008 /* loss of alpha bits */
  1230. #define FF_LOSS_COLORQUANT 0x0010 /* loss due to color quantization */
  1231. #define FF_LOSS_CHROMA 0x0020 /* loss of chroma (e.g. rgb to gray conversion) */
  1232. int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt,
  1233. int has_alpha);
  1234. int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt,
  1235. int has_alpha, int *loss_ptr);
  1236. #define FF_ALPHA_TRANSP 0x0001 /* image has some totally transparent pixels */
  1237. #define FF_ALPHA_SEMI_TRANSP 0x0002 /* image has some transparent pixels */
  1238. int img_get_alpha_info(AVPicture *src, int pix_fmt, int width, int height);
  1239. /* convert among pixel formats */
  1240. int img_convert(AVPicture *dst, int dst_pix_fmt,
  1241. AVPicture *src, int pix_fmt,
  1242. int width, int height);
  1243. /* deinterlace a picture */
  1244. int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
  1245. int pix_fmt, int width, int height);
  1246. /* external high level API */
  1247. extern AVCodec *first_avcodec;
  1248. /* returns LIBAVCODEC_VERSION_INT constant */
  1249. unsigned avcodec_version(void);
  1250. /* returns LIBAVCODEC_BUILD constant */
  1251. unsigned avcodec_build(void);
  1252. void avcodec_init(void);
  1253. void register_avcodec(AVCodec *format);
  1254. AVCodec *avcodec_find_encoder(enum CodecID id);
  1255. AVCodec *avcodec_find_encoder_by_name(const char *name);
  1256. AVCodec *avcodec_find_decoder(enum CodecID id);
  1257. AVCodec *avcodec_find_decoder_by_name(const char *name);
  1258. void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
  1259. void avcodec_get_context_defaults(AVCodecContext *s);
  1260. AVCodecContext *avcodec_alloc_context(void);
  1261. AVFrame *avcodec_alloc_frame(void);
  1262. int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
  1263. void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
  1264. void avcodec_default_free_buffers(AVCodecContext *s);
  1265. /**
  1266. * opens / inits the AVCodecContext.
  1267. * not thread save!
  1268. */
  1269. int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
  1270. int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
  1271. int *frame_size_ptr,
  1272. uint8_t *buf, int buf_size);
  1273. int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
  1274. int *got_picture_ptr,
  1275. uint8_t *buf, int buf_size);
  1276. int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata,
  1277. int *data_size_ptr,
  1278. uint8_t *buf, int buf_size);
  1279. int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
  1280. const short *samples);
  1281. int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
  1282. const AVFrame *pict);
  1283. int avcodec_close(AVCodecContext *avctx);
  1284. void avcodec_register_all(void);
  1285. void avcodec_flush_buffers(AVCodecContext *avctx);
  1286. /* misc usefull functions */
  1287. /**
  1288. * returns a single letter to describe the picture type
  1289. */
  1290. char av_get_pict_type_char(int pict_type);
  1291. /**
  1292. * reduce a fraction.
  1293. * this is usefull for framerate calculations
  1294. * @param max the maximum allowed for dst_nom & dst_den
  1295. * @return 1 if exact, 0 otherwise
  1296. */
  1297. int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max);
  1298. /**
  1299. * rescale a 64bit integer.
  1300. * a simple a*b/c isnt possible as it can overflow
  1301. */
  1302. int64_t av_rescale(int64_t a, int b, int c);
  1303. /**
  1304. * Interface for 0.5.0 version
  1305. *
  1306. * do not even think about it's usage for this moment
  1307. */
  1308. typedef struct {
  1309. /// compressed size used from given memory buffer
  1310. int size;
  1311. /// I/P/B frame type
  1312. int frame_type;
  1313. } avc_enc_result_t;
  1314. /**
  1315. * Commands
  1316. * order can't be changed - once it was defined
  1317. */
  1318. typedef enum {
  1319. // general commands
  1320. AVC_OPEN_BY_NAME = 0xACA000,
  1321. AVC_OPEN_BY_CODEC_ID,
  1322. AVC_OPEN_BY_FOURCC,
  1323. AVC_CLOSE,
  1324. AVC_FLUSH,
  1325. // pin - struct { uint8_t* src, uint_t src_size }
  1326. // pout - struct { AVPicture* img, consumed_bytes,
  1327. AVC_DECODE,
  1328. // pin - struct { AVPicture* img, uint8_t* dest, uint_t dest_size }
  1329. // pout - uint_t used_from_dest_size
  1330. AVC_ENCODE,
  1331. // query/get video commands
  1332. AVC_GET_VERSION = 0xACB000,
  1333. AVC_GET_WIDTH,
  1334. AVC_GET_HEIGHT,
  1335. AVC_GET_DELAY,
  1336. AVC_GET_QUANT_TABLE,
  1337. // ...
  1338. // query/get audio commands
  1339. AVC_GET_FRAME_SIZE = 0xABC000,
  1340. // maybe define some simple structure which
  1341. // might be passed to the user - but they can't
  1342. // contain any codec specific parts and these
  1343. // calls are usualy necessary only few times
  1344. // set video commands
  1345. AVC_SET_WIDTH = 0xACD000,
  1346. AVC_SET_HEIGHT,
  1347. // set video encoding commands
  1348. AVC_SET_FRAME_RATE = 0xACD800,
  1349. AVC_SET_QUALITY,
  1350. AVC_SET_HURRY_UP,
  1351. // set audio commands
  1352. AVC_SET_SAMPLE_RATE = 0xACE000,
  1353. AVC_SET_CHANNELS,
  1354. } avc_cmd_t;
  1355. /**
  1356. * \param handle allocated private structure by libavcodec
  1357. * for initialization pass NULL - will be returned pout
  1358. * user is supposed to know nothing about its structure
  1359. * \param cmd type of operation to be performed
  1360. * \param pint input parameter
  1361. * \param pout output parameter
  1362. *
  1363. * \returns command status - eventually for query command it might return
  1364. * integer resulting value
  1365. */
  1366. int avcodec(void* handle, avc_cmd_t cmd, void* pin, void* pout);
  1367. /* memory */
  1368. void *av_malloc(unsigned int size);
  1369. void *av_mallocz(unsigned int size);
  1370. void *av_realloc(void *ptr, unsigned int size);
  1371. void av_free(void *ptr);
  1372. char *av_strdup(const char *s);
  1373. void __av_freep(void **ptr);
  1374. #define av_freep(p) __av_freep((void **)(p))
  1375. void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
  1376. /* for static data only */
  1377. /* call av_free_static to release all staticaly allocated tables */
  1378. void av_free_static(void);
  1379. void *__av_mallocz_static(void** location, unsigned int size);
  1380. #define av_mallocz_static(p, s) __av_mallocz_static((void **)(p), s)
  1381. #ifdef __cplusplus
  1382. }
  1383. #endif
  1384. #endif /* AVCODEC_H */