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.

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