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.

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