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.

1564 lines
44KB

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