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.

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