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.

1475 lines
41KB

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