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.

1449 lines
40KB

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