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.

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