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.

1536 lines
43KB

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