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.

2038 lines
59KB

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