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.

1504 lines
42KB

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