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.

1731 lines
50KB

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