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.

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