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.

1592 lines
45KB

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