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.

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