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.

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