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.

2068 lines
60KB

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