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.

1694 lines
49KB

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