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.

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