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.

1816 lines
52KB

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