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.

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