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.

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