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.

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