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.

2939 lines
90KB

  1. /*
  2. * copyright (c) 2001 Fabrice Bellard
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #ifndef AVCODEC_H
  21. #define AVCODEC_H
  22. /**
  23. * @file avcodec.h
  24. * external API header
  25. */
  26. #include "avutil.h"
  27. #include <sys/types.h> /* size_t */
  28. #define AV_STRINGIFY(s) AV_TOSTRING(s)
  29. #define AV_TOSTRING(s) #s
  30. #define LIBAVCODEC_VERSION_INT ((51<<16)+(40<<8)+4)
  31. #define LIBAVCODEC_VERSION 51.40.4
  32. #define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT
  33. #define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION)
  34. #define AV_NOPTS_VALUE INT64_C(0x8000000000000000)
  35. #define AV_TIME_BASE 1000000
  36. #define AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE}
  37. /**
  38. * Identifies the syntax and semantics of the bitstream.
  39. * The principle is roughly:
  40. * Two decoders with the same ID can decode the same streams.
  41. * Two encoders with the same ID can encode compatible streams.
  42. * There may be slight deviations from the principle due to implementation
  43. * details.
  44. *
  45. * If you add a codec ID to this list, add it so that
  46. * 1. no value of a existing codec ID changes (that would break ABI),
  47. * 2. it is as close as possible to similar codecs.
  48. */
  49. enum CodecID {
  50. CODEC_ID_NONE,
  51. CODEC_ID_MPEG1VIDEO,
  52. CODEC_ID_MPEG2VIDEO, /* preferred ID for MPEG-1/2 video decoding */
  53. CODEC_ID_MPEG2VIDEO_XVMC,
  54. CODEC_ID_H261,
  55. CODEC_ID_H263,
  56. CODEC_ID_RV10,
  57. CODEC_ID_RV20,
  58. CODEC_ID_MJPEG,
  59. CODEC_ID_MJPEGB,
  60. CODEC_ID_LJPEG,
  61. CODEC_ID_SP5X,
  62. CODEC_ID_JPEGLS,
  63. CODEC_ID_MPEG4,
  64. CODEC_ID_RAWVIDEO,
  65. CODEC_ID_MSMPEG4V1,
  66. CODEC_ID_MSMPEG4V2,
  67. CODEC_ID_MSMPEG4V3,
  68. CODEC_ID_WMV1,
  69. CODEC_ID_WMV2,
  70. CODEC_ID_H263P,
  71. CODEC_ID_H263I,
  72. CODEC_ID_FLV1,
  73. CODEC_ID_SVQ1,
  74. CODEC_ID_SVQ3,
  75. CODEC_ID_DVVIDEO,
  76. CODEC_ID_HUFFYUV,
  77. CODEC_ID_CYUV,
  78. CODEC_ID_H264,
  79. CODEC_ID_INDEO3,
  80. CODEC_ID_VP3,
  81. CODEC_ID_THEORA,
  82. CODEC_ID_ASV1,
  83. CODEC_ID_ASV2,
  84. CODEC_ID_FFV1,
  85. CODEC_ID_4XM,
  86. CODEC_ID_VCR1,
  87. CODEC_ID_CLJR,
  88. CODEC_ID_MDEC,
  89. CODEC_ID_ROQ,
  90. CODEC_ID_INTERPLAY_VIDEO,
  91. CODEC_ID_XAN_WC3,
  92. CODEC_ID_XAN_WC4,
  93. CODEC_ID_RPZA,
  94. CODEC_ID_CINEPAK,
  95. CODEC_ID_WS_VQA,
  96. CODEC_ID_MSRLE,
  97. CODEC_ID_MSVIDEO1,
  98. CODEC_ID_IDCIN,
  99. CODEC_ID_8BPS,
  100. CODEC_ID_SMC,
  101. CODEC_ID_FLIC,
  102. CODEC_ID_TRUEMOTION1,
  103. CODEC_ID_VMDVIDEO,
  104. CODEC_ID_MSZH,
  105. CODEC_ID_ZLIB,
  106. CODEC_ID_QTRLE,
  107. CODEC_ID_SNOW,
  108. CODEC_ID_TSCC,
  109. CODEC_ID_ULTI,
  110. CODEC_ID_QDRAW,
  111. CODEC_ID_VIXL,
  112. CODEC_ID_QPEG,
  113. CODEC_ID_XVID,
  114. CODEC_ID_PNG,
  115. CODEC_ID_PPM,
  116. CODEC_ID_PBM,
  117. CODEC_ID_PGM,
  118. CODEC_ID_PGMYUV,
  119. CODEC_ID_PAM,
  120. CODEC_ID_FFVHUFF,
  121. CODEC_ID_RV30,
  122. CODEC_ID_RV40,
  123. CODEC_ID_VC1,
  124. CODEC_ID_WMV3,
  125. CODEC_ID_LOCO,
  126. CODEC_ID_WNV1,
  127. CODEC_ID_AASC,
  128. CODEC_ID_INDEO2,
  129. CODEC_ID_FRAPS,
  130. CODEC_ID_TRUEMOTION2,
  131. CODEC_ID_BMP,
  132. CODEC_ID_CSCD,
  133. CODEC_ID_MMVIDEO,
  134. CODEC_ID_ZMBV,
  135. CODEC_ID_AVS,
  136. CODEC_ID_SMACKVIDEO,
  137. CODEC_ID_NUV,
  138. CODEC_ID_KMVC,
  139. CODEC_ID_FLASHSV,
  140. CODEC_ID_CAVS,
  141. CODEC_ID_JPEG2000,
  142. CODEC_ID_VMNC,
  143. CODEC_ID_VP5,
  144. CODEC_ID_VP6,
  145. CODEC_ID_VP6F,
  146. CODEC_ID_TARGA,
  147. CODEC_ID_DSICINVIDEO,
  148. CODEC_ID_TIERTEXSEQVIDEO,
  149. CODEC_ID_TIFF,
  150. CODEC_ID_GIF,
  151. CODEC_ID_FFH264,
  152. CODEC_ID_DXA,
  153. CODEC_ID_DNXHD,
  154. CODEC_ID_THP,
  155. CODEC_ID_SGI,
  156. CODEC_ID_C93,
  157. CODEC_ID_BETHSOFTVID,
  158. CODEC_ID_PTX,
  159. CODEC_ID_TXD,
  160. /* various PCM "codecs" */
  161. CODEC_ID_PCM_S16LE= 0x10000,
  162. CODEC_ID_PCM_S16BE,
  163. CODEC_ID_PCM_U16LE,
  164. CODEC_ID_PCM_U16BE,
  165. CODEC_ID_PCM_S8,
  166. CODEC_ID_PCM_U8,
  167. CODEC_ID_PCM_MULAW,
  168. CODEC_ID_PCM_ALAW,
  169. CODEC_ID_PCM_S32LE,
  170. CODEC_ID_PCM_S32BE,
  171. CODEC_ID_PCM_U32LE,
  172. CODEC_ID_PCM_U32BE,
  173. CODEC_ID_PCM_S24LE,
  174. CODEC_ID_PCM_S24BE,
  175. CODEC_ID_PCM_U24LE,
  176. CODEC_ID_PCM_U24BE,
  177. CODEC_ID_PCM_S24DAUD,
  178. CODEC_ID_PCM_ZORK,
  179. /* various ADPCM codecs */
  180. CODEC_ID_ADPCM_IMA_QT= 0x11000,
  181. CODEC_ID_ADPCM_IMA_WAV,
  182. CODEC_ID_ADPCM_IMA_DK3,
  183. CODEC_ID_ADPCM_IMA_DK4,
  184. CODEC_ID_ADPCM_IMA_WS,
  185. CODEC_ID_ADPCM_IMA_SMJPEG,
  186. CODEC_ID_ADPCM_MS,
  187. CODEC_ID_ADPCM_4XM,
  188. CODEC_ID_ADPCM_XA,
  189. CODEC_ID_ADPCM_ADX,
  190. CODEC_ID_ADPCM_EA,
  191. CODEC_ID_ADPCM_G726,
  192. CODEC_ID_ADPCM_CT,
  193. CODEC_ID_ADPCM_SWF,
  194. CODEC_ID_ADPCM_YAMAHA,
  195. CODEC_ID_ADPCM_SBPRO_4,
  196. CODEC_ID_ADPCM_SBPRO_3,
  197. CODEC_ID_ADPCM_SBPRO_2,
  198. CODEC_ID_ADPCM_THP,
  199. /* AMR */
  200. CODEC_ID_AMR_NB= 0x12000,
  201. CODEC_ID_AMR_WB,
  202. /* RealAudio codecs*/
  203. CODEC_ID_RA_144= 0x13000,
  204. CODEC_ID_RA_288,
  205. /* various DPCM codecs */
  206. CODEC_ID_ROQ_DPCM= 0x14000,
  207. CODEC_ID_INTERPLAY_DPCM,
  208. CODEC_ID_XAN_DPCM,
  209. CODEC_ID_SOL_DPCM,
  210. CODEC_ID_MP2= 0x15000,
  211. CODEC_ID_MP3, /* preferred ID for decoding MPEG audio layer 1, 2 or 3 */
  212. CODEC_ID_AAC,
  213. #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
  214. CODEC_ID_MPEG4AAC,
  215. #endif
  216. CODEC_ID_AC3,
  217. CODEC_ID_DTS,
  218. CODEC_ID_VORBIS,
  219. CODEC_ID_DVAUDIO,
  220. CODEC_ID_WMAV1,
  221. CODEC_ID_WMAV2,
  222. CODEC_ID_MACE3,
  223. CODEC_ID_MACE6,
  224. CODEC_ID_VMDAUDIO,
  225. CODEC_ID_SONIC,
  226. CODEC_ID_SONIC_LS,
  227. CODEC_ID_FLAC,
  228. CODEC_ID_MP3ADU,
  229. CODEC_ID_MP3ON4,
  230. CODEC_ID_SHORTEN,
  231. CODEC_ID_ALAC,
  232. CODEC_ID_WESTWOOD_SND1,
  233. CODEC_ID_GSM, /* as in Berlin toast format */
  234. CODEC_ID_QDM2,
  235. CODEC_ID_COOK,
  236. CODEC_ID_TRUESPEECH,
  237. CODEC_ID_TTA,
  238. CODEC_ID_SMACKAUDIO,
  239. CODEC_ID_QCELP,
  240. CODEC_ID_WAVPACK,
  241. CODEC_ID_DSICINAUDIO,
  242. CODEC_ID_IMC,
  243. CODEC_ID_MUSEPACK7,
  244. CODEC_ID_MLP,
  245. CODEC_ID_GSM_MS, /* as found in WAV */
  246. CODEC_ID_ATRAC3,
  247. CODEC_ID_VOXWARE,
  248. /* subtitle codecs */
  249. CODEC_ID_DVD_SUBTITLE= 0x17000,
  250. CODEC_ID_DVB_SUBTITLE,
  251. CODEC_ID_TEXT, /* raw UTF-8 text */
  252. CODEC_ID_MPEG2TS= 0x20000, /* _FAKE_ codec to indicate a raw MPEG-2 TS
  253. * stream (only used by libavformat) */
  254. };
  255. #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
  256. /* CODEC_ID_MP3LAME is obsolete */
  257. #define CODEC_ID_MP3LAME CODEC_ID_MP3
  258. #define CODEC_ID_MPEG4AAC CODEC_ID_AAC
  259. #endif
  260. enum CodecType {
  261. CODEC_TYPE_UNKNOWN = -1,
  262. CODEC_TYPE_VIDEO,
  263. CODEC_TYPE_AUDIO,
  264. CODEC_TYPE_DATA,
  265. CODEC_TYPE_SUBTITLE,
  266. CODEC_TYPE_NB
  267. };
  268. /* Currently unused, may be used if 24/32 bits samples are ever supported. */
  269. /* all in native-endian format */
  270. enum SampleFormat {
  271. SAMPLE_FMT_NONE = -1,
  272. SAMPLE_FMT_U8, ///< unsigned 8 bits
  273. SAMPLE_FMT_S16, ///< signed 16 bits
  274. SAMPLE_FMT_S24, ///< signed 24 bits
  275. SAMPLE_FMT_S32, ///< signed 32 bits
  276. SAMPLE_FMT_FLT, ///< float
  277. };
  278. /* in bytes */
  279. #define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
  280. /**
  281. * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
  282. * This is mainly needed because some optimized bitstream readers read
  283. * 32 or 64 bit at once and could read over the end.<br>
  284. * Note: If the first 23 bits of the additional bytes are not 0, then damaged
  285. * MPEG bitstreams could cause overread and segfault.
  286. */
  287. #define FF_INPUT_BUFFER_PADDING_SIZE 8
  288. /**
  289. * minimum encoding buffer size
  290. * Used to avoid some checks during header writing.
  291. */
  292. #define FF_MIN_BUFFER_SIZE 16384
  293. /* motion estimation type, EPZS by default */
  294. enum Motion_Est_ID {
  295. ME_ZERO = 1,
  296. ME_FULL,
  297. ME_LOG,
  298. ME_PHODS,
  299. ME_EPZS,
  300. ME_X1,
  301. ME_HEX,
  302. ME_UMH,
  303. ME_ITER,
  304. };
  305. enum AVDiscard{
  306. /* We leave some space between them for extensions (drop some
  307. * keyframes for intra-only or drop just some bidir frames). */
  308. AVDISCARD_NONE =-16, ///< discard nothing
  309. AVDISCARD_DEFAULT= 0, ///< discard useless packets like 0 size packets in avi
  310. AVDISCARD_NONREF = 8, ///< discard all non reference
  311. AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames
  312. AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes
  313. AVDISCARD_ALL = 48, ///< discard all
  314. };
  315. typedef struct RcOverride{
  316. int start_frame;
  317. int end_frame;
  318. int qscale; // If this is 0 then quality_factor will be used instead.
  319. float quality_factor;
  320. } RcOverride;
  321. #define FF_MAX_B_FRAMES 16
  322. /* encoding support
  323. These flags can be passed in AVCodecContext.flags before initialization.
  324. Note: Not everything is supported yet.
  325. */
  326. #define CODEC_FLAG_QSCALE 0x0002 ///< Use fixed qscale.
  327. #define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed / advanced prediction for H.263.
  328. #define CODEC_FLAG_QPEL 0x0010 ///< Use qpel MC.
  329. #define CODEC_FLAG_GMC 0x0020 ///< Use GMC.
  330. #define CODEC_FLAG_MV0 0x0040 ///< Always try a MB with MV=<0,0>.
  331. #define CODEC_FLAG_PART 0x0080 ///< Use data partitioning.
  332. /* The parent program guarantees that the input for B-frames containing
  333. * streams is not written to for at least s->max_b_frames+1 frames, if
  334. * this is not set the input will be copied. */
  335. #define CODEC_FLAG_INPUT_PRESERVED 0x0100
  336. #define CODEC_FLAG_PASS1 0x0200 ///< Use internal 2pass ratecontrol in first pass mode.
  337. #define CODEC_FLAG_PASS2 0x0400 ///< Use internal 2pass ratecontrol in second pass mode.
  338. #define CODEC_FLAG_EXTERN_HUFF 0x1000 ///< Use external Huffman table (for MJPEG).
  339. #define CODEC_FLAG_GRAY 0x2000 ///< Only decode/encode grayscale.
  340. #define CODEC_FLAG_EMU_EDGE 0x4000///< Don't draw edges.
  341. #define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding.
  342. #define CODEC_FLAG_TRUNCATED 0x00010000 /** Input bitstream might be truncated at a random location instead
  343. of only at frame boundaries. */
  344. #define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< Normalize adaptive quantization.
  345. #define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< Use interlaced DCT.
  346. #define CODEC_FLAG_LOW_DELAY 0x00080000 ///< Force low delay.
  347. #define CODEC_FLAG_ALT_SCAN 0x00100000 ///< Use alternate scan.
  348. #define CODEC_FLAG_TRELLIS_QUANT 0x00200000 ///< Use trellis quantization.
  349. #define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< Place global headers in extradata instead of every keyframe.
  350. #define CODEC_FLAG_BITEXACT 0x00800000 ///< Use only bitexact stuff (except (I)DCT).
  351. /* Fx : Flag for h263+ extra options */
  352. #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
  353. #define CODEC_FLAG_H263P_AIC 0x01000000 ///< H.263 advanced intra coding / MPEG-4 AC prediction (remove this)
  354. #endif
  355. #define CODEC_FLAG_AC_PRED 0x01000000 ///< H.263 advanced intra coding / MPEG-4 AC prediction
  356. #define CODEC_FLAG_H263P_UMV 0x02000000 ///< unlimited motion vector
  357. #define CODEC_FLAG_CBP_RD 0x04000000 ///< Use rate distortion optimization for cbp.
  358. #define CODEC_FLAG_QP_RD 0x08000000 ///< Use rate distortion optimization for qp selectioon.
  359. #define CODEC_FLAG_H263P_AIV 0x00000008 ///< H.263 alternative inter VLC
  360. #define CODEC_FLAG_OBMC 0x00000001 ///< OBMC
  361. #define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter
  362. #define CODEC_FLAG_H263P_SLICE_STRUCT 0x10000000
  363. #define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation
  364. #define CODEC_FLAG_SVCD_SCAN_OFFSET 0x40000000 ///< Will reserve space for SVCD scan offset user data.
  365. #define CODEC_FLAG_CLOSED_GOP ((int)0x80000000)
  366. #define CODEC_FLAG2_FAST 0x00000001 ///< Allow non spec compliant speedup tricks.
  367. #define CODEC_FLAG2_STRICT_GOP 0x00000002 ///< Strictly enforce GOP size.
  368. #define CODEC_FLAG2_NO_OUTPUT 0x00000004 ///< Skip bitstream encoding.
  369. #define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< Place global headers at every keyframe instead of in extradata.
  370. #define CODEC_FLAG2_BPYRAMID 0x00000010 ///< H.264 allow B-frames to be used as references.
  371. #define CODEC_FLAG2_WPRED 0x00000020 ///< H.264 weighted biprediction for B-frames
  372. #define CODEC_FLAG2_MIXED_REFS 0x00000040 ///< H.264 one reference per partition, as opposed to one reference per macroblock
  373. #define CODEC_FLAG2_8X8DCT 0x00000080 ///< H.264 high profile 8x8 transform
  374. #define CODEC_FLAG2_FASTPSKIP 0x00000100 ///< H.264 fast pskip
  375. #define CODEC_FLAG2_AUD 0x00000200 ///< H.264 access unit delimiters
  376. #define CODEC_FLAG2_BRDO 0x00000400 ///< B-frame rate-distortion optimization
  377. #define CODEC_FLAG2_INTRA_VLC 0x00000800 ///< Use MPEG-2 intra VLC table.
  378. #define CODEC_FLAG2_MEMC_ONLY 0x00001000 ///< Only do ME/MC (I frames -> ref, P frame -> ME+MC).
  379. #define CODEC_FLAG2_DROP_FRAME_TIMECODE 0x00002000 ///< timecode is in drop frame format.
  380. #define CODEC_FLAG2_SKIP_RD 0x00004000 ///< RD optimal MB level residual skipping
  381. #define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries.
  382. #define CODEC_FLAG2_NON_LINEAR_QUANT 0x00010000 ///< Use MPEG-2 nonlinear quantizer.
  383. /* Unsupported options :
  384. * Syntax Arithmetic coding (SAC)
  385. * Reference Picture Selection
  386. * Independent Segment Decoding */
  387. /* /Fx */
  388. /* codec capabilities */
  389. #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< Decoder can use draw_horiz_band callback.
  390. /**
  391. * Codec uses get_buffer() for allocating buffers.
  392. * direct rendering method 1
  393. */
  394. #define CODEC_CAP_DR1 0x0002
  395. /* If 'parse_only' field is true, then avcodec_parse_frame() can be used. */
  396. #define CODEC_CAP_PARSE_ONLY 0x0004
  397. #define CODEC_CAP_TRUNCATED 0x0008
  398. /* Codec can export data for HW decoding (XvMC). */
  399. #define CODEC_CAP_HWACCEL 0x0010
  400. /**
  401. * Codec has a nonzero delay and needs to be fed with NULL at the end to get the delayed data.
  402. * If this is not set, the codec is guaranteed to never be fed with NULL data.
  403. */
  404. #define CODEC_CAP_DELAY 0x0020
  405. /**
  406. * Codec can be fed a final frame with a smaller size.
  407. * This can be used to prevent truncation of the last audio samples.
  408. */
  409. #define CODEC_CAP_SMALL_LAST_FRAME 0x0040
  410. //The following defines may change, don't expect compatibility if you use them.
  411. #define MB_TYPE_INTRA4x4 0x0001
  412. #define MB_TYPE_INTRA16x16 0x0002 //FIXME H.264-specific
  413. #define MB_TYPE_INTRA_PCM 0x0004 //FIXME H.264-specific
  414. #define MB_TYPE_16x16 0x0008
  415. #define MB_TYPE_16x8 0x0010
  416. #define MB_TYPE_8x16 0x0020
  417. #define MB_TYPE_8x8 0x0040
  418. #define MB_TYPE_INTERLACED 0x0080
  419. #define MB_TYPE_DIRECT2 0x0100 //FIXME
  420. #define MB_TYPE_ACPRED 0x0200
  421. #define MB_TYPE_GMC 0x0400
  422. #define MB_TYPE_SKIP 0x0800
  423. #define MB_TYPE_P0L0 0x1000
  424. #define MB_TYPE_P1L0 0x2000
  425. #define MB_TYPE_P0L1 0x4000
  426. #define MB_TYPE_P1L1 0x8000
  427. #define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0)
  428. #define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1)
  429. #define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1)
  430. #define MB_TYPE_QUANT 0x00010000
  431. #define MB_TYPE_CBP 0x00020000
  432. //Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...)
  433. /**
  434. * Pan Scan area.
  435. * This specifies the area which should be displayed.
  436. * Note there may be multiple such areas for one frame.
  437. */
  438. typedef struct AVPanScan{
  439. /**
  440. * id
  441. * - encoding: Set by user.
  442. * - decoding: Set by libavcodec.
  443. */
  444. int id;
  445. /**
  446. * width and height in 1/16 pel
  447. * - encoding: Set by user.
  448. * - decoding: Set by libavcodec.
  449. */
  450. int width;
  451. int height;
  452. /**
  453. * position of the top left corner in 1/16 pel for up to 3 fields/frames
  454. * - encoding: Set by user.
  455. * - decoding: Set by libavcodec.
  456. */
  457. int16_t position[3][2];
  458. }AVPanScan;
  459. #define FF_COMMON_FRAME \
  460. /**\
  461. * pointer to the picture planes.\
  462. * This might be different from the first allocated byte\
  463. * - encoding: \
  464. * - decoding: \
  465. */\
  466. uint8_t *data[4];\
  467. int linesize[4];\
  468. /**\
  469. * pointer to the first allocated byte of the picture. Can be used in get_buffer/release_buffer.\
  470. * This isn't used by libavcodec unless the default get/release_buffer() is used.\
  471. * - encoding: \
  472. * - decoding: \
  473. */\
  474. uint8_t *base[4];\
  475. /**\
  476. * 1 -> keyframe, 0-> not\
  477. * - encoding: Set by libavcodec.\
  478. * - decoding: Set by libavcodec.\
  479. */\
  480. int key_frame;\
  481. \
  482. /**\
  483. * Picture type of the frame, see ?_TYPE below.\
  484. * - encoding: Set by libavcodec. for coded_picture (and set by user for input).\
  485. * - decoding: Set by libavcodec.\
  486. */\
  487. int pict_type;\
  488. \
  489. /**\
  490. * presentation timestamp in time_base units (time when frame should be shown to user)\
  491. * If AV_NOPTS_VALUE then frame_rate = 1/time_base will be assumed.\
  492. * - encoding: MUST be set by user.\
  493. * - decoding: Set by libavcodec.\
  494. */\
  495. int64_t pts;\
  496. \
  497. /**\
  498. * picture number in bitstream order\
  499. * - encoding: set by\
  500. * - decoding: Set by libavcodec.\
  501. */\
  502. int coded_picture_number;\
  503. /**\
  504. * picture number in display order\
  505. * - encoding: set by\
  506. * - decoding: Set by libavcodec.\
  507. */\
  508. int display_picture_number;\
  509. \
  510. /**\
  511. * quality (between 1 (good) and FF_LAMBDA_MAX (bad)) \
  512. * - encoding: Set by libavcodec. for coded_picture (and set by user for input).\
  513. * - decoding: Set by libavcodec.\
  514. */\
  515. int quality; \
  516. \
  517. /**\
  518. * buffer age (1->was last buffer and dint change, 2->..., ...).\
  519. * Set to INT_MAX if the buffer has not been used yet.\
  520. * - encoding: unused\
  521. * - decoding: MUST be set by get_buffer().\
  522. */\
  523. int age;\
  524. \
  525. /**\
  526. * is this picture used as reference\
  527. * - encoding: unused\
  528. * - decoding: Set by libavcodec. (before get_buffer() call)).\
  529. */\
  530. int reference;\
  531. \
  532. /**\
  533. * QP table\
  534. * - encoding: unused\
  535. * - decoding: Set by libavcodec.\
  536. */\
  537. int8_t *qscale_table;\
  538. /**\
  539. * QP store stride\
  540. * - encoding: unused\
  541. * - decoding: Set by libavcodec.\
  542. */\
  543. int qstride;\
  544. \
  545. /**\
  546. * mbskip_table[mb]>=1 if MB didn't change\
  547. * stride= mb_width = (width+15)>>4\
  548. * - encoding: unused\
  549. * - decoding: Set by libavcodec.\
  550. */\
  551. uint8_t *mbskip_table;\
  552. \
  553. /**\
  554. * motion vector table\
  555. * @code\
  556. * example:\
  557. * int mv_sample_log2= 4 - motion_subsample_log2;\
  558. * int mb_width= (width+15)>>4;\
  559. * int mv_stride= (mb_width << mv_sample_log2) + 1;\
  560. * motion_val[direction][x + y*mv_stride][0->mv_x, 1->mv_y];\
  561. * @endcode\
  562. * - encoding: Set by user.\
  563. * - decoding: Set by libavcodec.\
  564. */\
  565. int16_t (*motion_val[2])[2];\
  566. \
  567. /**\
  568. * macroblock type table\
  569. * mb_type_base + mb_width + 2\
  570. * - encoding: Set by user.\
  571. * - decoding: Set by libavcodec.\
  572. */\
  573. uint32_t *mb_type;\
  574. \
  575. /**\
  576. * log2 of the size of the block which a single vector in motion_val represents: \
  577. * (4->16x16, 3->8x8, 2-> 4x4, 1-> 2x2)\
  578. * - encoding: unused\
  579. * - decoding: Set by libavcodec.\
  580. */\
  581. uint8_t motion_subsample_log2;\
  582. \
  583. /**\
  584. * for some private data of the user\
  585. * - encoding: unused\
  586. * - decoding: Set by user.\
  587. */\
  588. void *opaque;\
  589. \
  590. /**\
  591. * error\
  592. * - encoding: Set by libavcodec. if flags&CODEC_FLAG_PSNR.\
  593. * - decoding: unused\
  594. */\
  595. uint64_t error[4];\
  596. \
  597. /**\
  598. * type of the buffer (to keep track of who has to deallocate data[*])\
  599. * - encoding: Set by the one who allocates it.\
  600. * - decoding: Set by the one who allocates it.\
  601. * Note: User allocated (direct rendering) & internal buffers cannot coexist currently.\
  602. */\
  603. int type;\
  604. \
  605. /**\
  606. * When decoding, this signals how much the picture must be delayed.\
  607. * extra_delay = repeat_pict / (2*fps)\
  608. * - encoding: unused\
  609. * - decoding: Set by libavcodec.\
  610. */\
  611. int repeat_pict;\
  612. \
  613. /**\
  614. * \
  615. */\
  616. int qscale_type;\
  617. \
  618. /**\
  619. * The content of the picture is interlaced.\
  620. * - encoding: Set by user.\
  621. * - decoding: Set by libavcodec. (default 0)\
  622. */\
  623. int interlaced_frame;\
  624. \
  625. /**\
  626. * If the content is interlaced, is top field displayed first.\
  627. * - encoding: Set by user.\
  628. * - decoding: Set by libavcodec.\
  629. */\
  630. int top_field_first;\
  631. \
  632. /**\
  633. * Pan scan.\
  634. * - encoding: Set by user.\
  635. * - decoding: Set by libavcodec.\
  636. */\
  637. AVPanScan *pan_scan;\
  638. \
  639. /**\
  640. * Tell user application that palette has changed from previous frame.\
  641. * - encoding: ??? (no palette-enabled encoder yet)\
  642. * - decoding: Set by libavcodec. (default 0).\
  643. */\
  644. int palette_has_changed;\
  645. \
  646. /**\
  647. * codec suggestion on buffer type if != 0\
  648. * - encoding: unused\
  649. * - decoding: Set by libavcodec. (before get_buffer() call)).\
  650. */\
  651. int buffer_hints;\
  652. \
  653. /**\
  654. * DCT coefficients\
  655. * - encoding: unused\
  656. * - decoding: Set by libavcodec.\
  657. */\
  658. short *dct_coeff;\
  659. \
  660. /**\
  661. * motion referece frame index\
  662. * - encoding: Set by user.\
  663. * - decoding: Set by libavcodec.\
  664. */\
  665. int8_t *ref_index[2];
  666. #define FF_QSCALE_TYPE_MPEG1 0
  667. #define FF_QSCALE_TYPE_MPEG2 1
  668. #define FF_QSCALE_TYPE_H264 2
  669. #define FF_BUFFER_TYPE_INTERNAL 1
  670. #define FF_BUFFER_TYPE_USER 2 ///< direct rendering buffers (image is (de)allocated by user)
  671. #define FF_BUFFER_TYPE_SHARED 4 ///< Buffer from somewhere else; don't deallocate image (data/base), all other tables are not shared.
  672. #define FF_BUFFER_TYPE_COPY 8 ///< Just a (modified) copy of some other buffer, don't deallocate anything.
  673. #define FF_I_TYPE 1 // Intra
  674. #define FF_P_TYPE 2 // Predicted
  675. #define FF_B_TYPE 3 // Bi-dir predicted
  676. #define FF_S_TYPE 4 // S(GMC)-VOP MPEG4
  677. #define FF_SI_TYPE 5
  678. #define FF_SP_TYPE 6
  679. #define FF_BUFFER_HINTS_VALID 0x01 // Buffer hints value is meaningful (if 0 ignore).
  680. #define FF_BUFFER_HINTS_READABLE 0x02 // Codec will read from buffer.
  681. #define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content.
  682. #define FF_BUFFER_HINTS_REUSABLE 0x08 // Codec will reuse the buffer (update).
  683. /**
  684. * Audio Video Frame.
  685. */
  686. typedef struct AVFrame {
  687. FF_COMMON_FRAME
  688. } AVFrame;
  689. #define DEFAULT_FRAME_RATE_BASE 1001000
  690. /**
  691. * main external API structure
  692. */
  693. typedef struct AVCodecContext {
  694. /**
  695. * information on struct for av_log
  696. * - set by avcodec_alloc_context
  697. */
  698. AVClass *av_class;
  699. /**
  700. * the average bitrate
  701. * - encoding: Set by user; unused for constant quantizer encoding.
  702. * - decoding: Set by libavcodec. 0 or some bitrate if this info is available in the stream.
  703. */
  704. int bit_rate;
  705. /**
  706. * number of bits the bitstream is allowed to diverge from the reference.
  707. * the reference can be CBR (for CBR pass1) or VBR (for pass2)
  708. * - encoding: Set by user; unused for constant quantizer encoding.
  709. * - decoding: unused
  710. */
  711. int bit_rate_tolerance;
  712. /**
  713. * CODEC_FLAG_*.
  714. * - encoding: Set by user.
  715. * - decoding: Set by user.
  716. */
  717. int flags;
  718. /**
  719. * Some codecs need additional format info. It is stored here.
  720. * If any muxer uses this then ALL demuxers/parsers AND encoders for the
  721. * specific codec MUST set it correctly otherwise stream copy breaks.
  722. * In general use of this field by muxers is not recommanded.
  723. * - encoding: Set by libavcodec.
  724. * - decoding: Set by libavcodec. (FIXME: Is this OK?)
  725. */
  726. int sub_id;
  727. /**
  728. * Motion estimation algorithm used for video coding.
  729. * 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex),
  730. * 8 (umh), 9 (iter) [7, 8 are x264 specific, 9 is snow specific]
  731. * - encoding: MUST be set by user.
  732. * - decoding: unused
  733. */
  734. int me_method;
  735. /**
  736. * some codecs need / can use extradata like Huffman tables.
  737. * mjpeg: Huffman tables
  738. * rv10: additional flags
  739. * mpeg4: global headers (they can be in the bitstream or here)
  740. * The allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger
  741. * than extradata_size to avoid prolems if it is read with the bitstream reader.
  742. * The bytewise contents of extradata must not depend on the architecture or CPU endianness.
  743. * - encoding: Set/allocated/freed by libavcodec.
  744. * - decoding: Set/allocated/freed by user.
  745. */
  746. uint8_t *extradata;
  747. int extradata_size;
  748. /**
  749. * This is the fundamental unit of time (in seconds) in terms
  750. * of which frame timestamps are represented. For fixed-fps content,
  751. * timebase should be 1/framerate and timestamp increments should be
  752. * identically 1.
  753. * - encoding: MUST be set by user.
  754. * - decoding: Set by libavcodec.
  755. */
  756. AVRational time_base;
  757. /* video only */
  758. /**
  759. * picture width / height.
  760. * - encoding: MUST be set by user.
  761. * - decoding: Set by libavcodec.
  762. * Note: For compatibility it is possible to set this instead of
  763. * coded_width/height before decoding.
  764. */
  765. int width, height;
  766. #define FF_ASPECT_EXTENDED 15
  767. /**
  768. * the number of pictures in a group of pictures, or 0 for intra_only
  769. * - encoding: Set by user.
  770. * - decoding: unused
  771. */
  772. int gop_size;
  773. /**
  774. * Pixel format, see PIX_FMT_xxx.
  775. * - encoding: Set by user.
  776. * - decoding: Set by libavcodec.
  777. */
  778. enum PixelFormat pix_fmt;
  779. /**
  780. * Frame rate emulation. If not zero, the lower layer (i.e. format handler)
  781. * has to read frames at native frame rate.
  782. * - encoding: Set by user.
  783. * - decoding: unused
  784. */
  785. int rate_emu;
  786. /**
  787. * If non NULL, 'draw_horiz_band' is called by the libavcodec
  788. * decoder to draw a horizontal band. It improves cache usage. Not
  789. * all codecs can do that. You must check the codec capabilities
  790. * beforehand.
  791. * - encoding: unused
  792. * - decoding: Set by user.
  793. * @param height the height of the slice
  794. * @param y the y position of the slice
  795. * @param type 1->top field, 2->bottom field, 3->frame
  796. * @param offset offset into the AVFrame.data from which the slice should be read
  797. */
  798. void (*draw_horiz_band)(struct AVCodecContext *s,
  799. const AVFrame *src, int offset[4],
  800. int y, int type, int height);
  801. /* audio only */
  802. int sample_rate; ///< samples per second
  803. int channels;
  804. /**
  805. * audio sample format
  806. * - encoding: Set by user.
  807. * - decoding: Set by libavcodec.
  808. */
  809. enum SampleFormat sample_fmt; ///< sample format, currently unused
  810. /* The following data should not be initialized. */
  811. /**
  812. * Samples per packet, initialized when calling 'init'.
  813. */
  814. int frame_size;
  815. int frame_number; ///< audio or video frame number
  816. int real_pict_num; ///< Returns the real picture number of previous encoded frame.
  817. /**
  818. * Number of frames the decoded output will be delayed relative to
  819. * the encoded input.
  820. * - encoding: Set by libavcodec.
  821. * - decoding: unused
  822. */
  823. int delay;
  824. /* - encoding parameters */
  825. float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)
  826. float qblur; ///< amount of qscale smoothing over time (0.0-1.0)
  827. /**
  828. * minimum quantizer
  829. * - encoding: Set by user.
  830. * - decoding: unused
  831. */
  832. int qmin;
  833. /**
  834. * maximum quantizer
  835. * - encoding: Set by user.
  836. * - decoding: unused
  837. */
  838. int qmax;
  839. /**
  840. * maximum quantizer difference between frames
  841. * - encoding: Set by user.
  842. * - decoding: unused
  843. */
  844. int max_qdiff;
  845. /**
  846. * maximum number of B-frames between non-B-frames
  847. * Note: The output will be delayed by max_b_frames+1 relative to the input.
  848. * - encoding: Set by user.
  849. * - decoding: unused
  850. */
  851. int max_b_frames;
  852. /**
  853. * qscale factor between IP and B-frames
  854. * - encoding: Set by user.
  855. * - decoding: unused
  856. */
  857. float b_quant_factor;
  858. /** obsolete FIXME remove */
  859. int rc_strategy;
  860. #define FF_RC_STRATEGY_XVID 1
  861. int b_frame_strategy;
  862. /**
  863. * hurry up amount
  864. * - encoding: unused
  865. * - decoding: Set by user. 1-> Skip B-frames, 2-> Skip IDCT/dequant too, 5-> Skip everything except header
  866. * @deprecated Deprecated in favor of skip_idct and skip_frame.
  867. */
  868. int hurry_up;
  869. struct AVCodec *codec;
  870. void *priv_data;
  871. #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
  872. /* unused, FIXME remove*/
  873. int rtp_mode;
  874. #endif
  875. int rtp_payload_size; /* The size of the RTP payload: the coder will */
  876. /* do its best to deliver a chunk with size */
  877. /* below rtp_payload_size, the chunk will start */
  878. /* with a start code on some codecs like H.263. */
  879. /* This doesn't take account of any particular */
  880. /* headers inside the transmitted RTP payload. */
  881. /* The RTP callback: This function is called */
  882. /* every time the encoder has a packet to send. */
  883. /* It depends on the encoder if the data starts */
  884. /* with a Start Code (it should). H.263 does. */
  885. /* mb_nb contains the number of macroblocks */
  886. /* encoded in the RTP payload. */
  887. void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb);
  888. /* statistics, used for 2-pass encoding */
  889. int mv_bits;
  890. int header_bits;
  891. int i_tex_bits;
  892. int p_tex_bits;
  893. int i_count;
  894. int p_count;
  895. int skip_count;
  896. int misc_bits;
  897. /**
  898. * number of bits used for the previously encoded frame
  899. * - encoding: Set by libavcodec.
  900. * - decoding: unused
  901. */
  902. int frame_bits;
  903. /**
  904. * Private data of the user, can be used to carry app specific stuff.
  905. * - encoding: Set by user.
  906. * - decoding: Set by user.
  907. */
  908. void *opaque;
  909. char codec_name[32];
  910. enum CodecType codec_type; /* see CODEC_TYPE_xxx */
  911. enum CodecID codec_id; /* see CODEC_ID_xxx */
  912. /**
  913. * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
  914. * This is used to work around some encoder bugs.
  915. * A demuxer should set this to what is stored in the field used to identify the codec.
  916. * If there are multiple such fields in a container then the demuxer should choose the one
  917. * which maximizes the information about the used codec.
  918. * If the codec tag field in a container is larger then 32 bits then the demuxer should
  919. * remap the longer ID to 32 bits with a table or other structure. Alternatively a new
  920. * extra_codec_tag + size could be added but for this a clear advantage must be demonstrated
  921. * first.
  922. * - encoding: Set by user, if not then the default based on codec_id will be used.
  923. * - decoding: Set by user, will be converted to uppercase by libavcodec during init.
  924. */
  925. unsigned int codec_tag;
  926. /**
  927. * Work around bugs in encoders which sometimes cannot be detected automatically.
  928. * - encoding: Set by user
  929. * - decoding: Set by user
  930. */
  931. int workaround_bugs;
  932. #define FF_BUG_AUTODETECT 1 ///< autodetection
  933. #define FF_BUG_OLD_MSMPEG4 2
  934. #define FF_BUG_XVID_ILACE 4
  935. #define FF_BUG_UMP4 8
  936. #define FF_BUG_NO_PADDING 16
  937. #define FF_BUG_AMV 32
  938. #define FF_BUG_AC_VLC 0 ///< Will be removed, libavcodec can now handle these non-compliant files by default.
  939. #define FF_BUG_QPEL_CHROMA 64
  940. #define FF_BUG_STD_QPEL 128
  941. #define FF_BUG_QPEL_CHROMA2 256
  942. #define FF_BUG_DIRECT_BLOCKSIZE 512
  943. #define FF_BUG_EDGE 1024
  944. #define FF_BUG_HPEL_CHROMA 2048
  945. #define FF_BUG_DC_CLIP 4096
  946. #define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders.
  947. //#define FF_BUG_FAKE_SCALABILITY 16 //Autodetection should work 100%.
  948. /**
  949. * luma single coefficient elimination threshold
  950. * - encoding: Set by user.
  951. * - decoding: unused
  952. */
  953. int luma_elim_threshold;
  954. /**
  955. * chroma single coeff elimination threshold
  956. * - encoding: Set by user.
  957. * - decoding: unused
  958. */
  959. int chroma_elim_threshold;
  960. /**
  961. * strictly follow the standard (MPEG4, ...).
  962. * - encoding: Set by user.
  963. * - decoding: unused
  964. */
  965. int strict_std_compliance;
  966. #define FF_COMPLIANCE_VERY_STRICT 2 ///< Strictly conform to a older more strict version of the spec or reference software.
  967. #define FF_COMPLIANCE_STRICT 1 ///< Strictly conform to all the things in the spec no matter what consequences.
  968. #define FF_COMPLIANCE_NORMAL 0
  969. #define FF_COMPLIANCE_INOFFICIAL -1 ///< Allow inofficial extensions.
  970. #define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things.
  971. /**
  972. * qscale offset between IP and B-frames
  973. * If > 0 then the last P-frame quantizer will be used (q= lastp_q*factor+offset).
  974. * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
  975. * - encoding: Set by user.
  976. * - decoding: unused
  977. */
  978. float b_quant_offset;
  979. /**
  980. * Error resilience; higher values will detect more errors but may
  981. * misdetect some more or less valid parts as errors.
  982. * - encoding: unused
  983. * - decoding: Set by user.
  984. */
  985. int error_resilience;
  986. #define FF_ER_CAREFUL 1
  987. #define FF_ER_COMPLIANT 2
  988. #define FF_ER_AGGRESSIVE 3
  989. #define FF_ER_VERY_AGGRESSIVE 4
  990. /**
  991. * Called at the beginning of each frame to get a buffer for it.
  992. * If pic.reference is set then the frame will be read later by libavcodec.
  993. * avcodec_align_dimensions() should be used to find the required width and
  994. * height, as they normally need to be rounded up to the next multiple of 16.
  995. * - encoding: unused
  996. * - decoding: Set by libavcodec., user can override.
  997. */
  998. int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
  999. /**
  1000. * Called to release buffers which where allocated with get_buffer.
  1001. * A released buffer can be reused in get_buffer().
  1002. * pic.data[*] must be set to NULL.
  1003. * - encoding: unused
  1004. * - decoding: Set by libavcodec., user can override.
  1005. */
  1006. void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
  1007. /**
  1008. * If 1 the stream has a 1 frame delay during decoding.
  1009. * - encoding: Set by libavcodec.
  1010. * - decoding: Set by libavcodec.
  1011. */
  1012. int has_b_frames;
  1013. /**
  1014. * number of bytes per packet if constant and known or 0
  1015. * Used by some WAV based audio codecs.
  1016. */
  1017. int block_align;
  1018. int parse_only; /* - decoding only: If true, only parsing is done
  1019. (function avcodec_parse_frame()). The frame
  1020. data is returned. Only MPEG codecs support this now. */
  1021. /**
  1022. * 0-> h263 quant 1-> mpeg quant
  1023. * - encoding: Set by user.
  1024. * - decoding: unused
  1025. */
  1026. int mpeg_quant;
  1027. /**
  1028. * pass1 encoding statistics output buffer
  1029. * - encoding: Set by libavcodec.
  1030. * - decoding: unused
  1031. */
  1032. char *stats_out;
  1033. /**
  1034. * pass2 encoding statistics input buffer
  1035. * Concatenated stuff from stats_out of pass1 should be placed here.
  1036. * - encoding: Allocated/set/freed by user.
  1037. * - decoding: unused
  1038. */
  1039. char *stats_in;
  1040. /**
  1041. * ratecontrol qmin qmax limiting method
  1042. * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax.
  1043. * - encoding: Set by user.
  1044. * - decoding: unused
  1045. */
  1046. float rc_qsquish;
  1047. float rc_qmod_amp;
  1048. int rc_qmod_freq;
  1049. /**
  1050. * ratecontrol override, see RcOverride
  1051. * - encoding: Allocated/set/freed by user.
  1052. * - decoding: unused
  1053. */
  1054. RcOverride *rc_override;
  1055. int rc_override_count;
  1056. /**
  1057. * rate control equation
  1058. * - encoding: Set by user
  1059. * - decoding: unused
  1060. */
  1061. char *rc_eq;
  1062. /**
  1063. * maximum bitrate
  1064. * - encoding: Set by user.
  1065. * - decoding: unused
  1066. */
  1067. int rc_max_rate;
  1068. /**
  1069. * minimum bitrate
  1070. * - encoding: Set by user.
  1071. * - decoding: unused
  1072. */
  1073. int rc_min_rate;
  1074. /**
  1075. * decoder bitstream buffer size
  1076. * - encoding: Set by user.
  1077. * - decoding: unused
  1078. */
  1079. int rc_buffer_size;
  1080. float rc_buffer_aggressivity;
  1081. /**
  1082. * qscale factor between P and I-frames
  1083. * If > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset).
  1084. * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
  1085. * - encoding: Set by user.
  1086. * - decoding: unused
  1087. */
  1088. float i_quant_factor;
  1089. /**
  1090. * qscale offset between P and I-frames
  1091. * - encoding: Set by user.
  1092. * - decoding: unused
  1093. */
  1094. float i_quant_offset;
  1095. /**
  1096. * initial complexity for pass1 ratecontrol
  1097. * - encoding: Set by user.
  1098. * - decoding: unused
  1099. */
  1100. float rc_initial_cplx;
  1101. /**
  1102. * DCT algorithm, see FF_DCT_* below
  1103. * - encoding: Set by user.
  1104. * - decoding: unused
  1105. */
  1106. int dct_algo;
  1107. #define FF_DCT_AUTO 0
  1108. #define FF_DCT_FASTINT 1
  1109. #define FF_DCT_INT 2
  1110. #define FF_DCT_MMX 3
  1111. #define FF_DCT_MLIB 4
  1112. #define FF_DCT_ALTIVEC 5
  1113. #define FF_DCT_FAAN 6
  1114. /**
  1115. * luminance masking (0-> disabled)
  1116. * - encoding: Set by user.
  1117. * - decoding: unused
  1118. */
  1119. float lumi_masking;
  1120. /**
  1121. * temporary complexity masking (0-> disabled)
  1122. * - encoding: Set by user.
  1123. * - decoding: unused
  1124. */
  1125. float temporal_cplx_masking;
  1126. /**
  1127. * spatial complexity masking (0-> disabled)
  1128. * - encoding: Set by user.
  1129. * - decoding: unused
  1130. */
  1131. float spatial_cplx_masking;
  1132. /**
  1133. * p block masking (0-> disabled)
  1134. * - encoding: Set by user.
  1135. * - decoding: unused
  1136. */
  1137. float p_masking;
  1138. /**
  1139. * darkness masking (0-> disabled)
  1140. * - encoding: Set by user.
  1141. * - decoding: unused
  1142. */
  1143. float dark_masking;
  1144. /* for binary compatibility */
  1145. int unused;
  1146. /**
  1147. * IDCT algorithm, see FF_IDCT_* below.
  1148. * - encoding: Set by user.
  1149. * - decoding: Set by user.
  1150. */
  1151. int idct_algo;
  1152. #define FF_IDCT_AUTO 0
  1153. #define FF_IDCT_INT 1
  1154. #define FF_IDCT_SIMPLE 2
  1155. #define FF_IDCT_SIMPLEMMX 3
  1156. #define FF_IDCT_LIBMPEG2MMX 4
  1157. #define FF_IDCT_PS2 5
  1158. #define FF_IDCT_MLIB 6
  1159. #define FF_IDCT_ARM 7
  1160. #define FF_IDCT_ALTIVEC 8
  1161. #define FF_IDCT_SH4 9
  1162. #define FF_IDCT_SIMPLEARM 10
  1163. #define FF_IDCT_H264 11
  1164. #define FF_IDCT_VP3 12
  1165. #define FF_IDCT_IPP 13
  1166. #define FF_IDCT_XVIDMMX 14
  1167. #define FF_IDCT_CAVS 15
  1168. #define FF_IDCT_SIMPLEARMV5TE 16
  1169. #define FF_IDCT_SIMPLEARMV6 17
  1170. /**
  1171. * slice count
  1172. * - encoding: Set by libavcodec.
  1173. * - decoding: Set by user (or 0).
  1174. */
  1175. int slice_count;
  1176. /**
  1177. * slice offsets in the frame in bytes
  1178. * - encoding: Set/allocated by libavcodec.
  1179. * - decoding: Set/allocated by user (or NULL).
  1180. */
  1181. int *slice_offset;
  1182. /**
  1183. * error concealment flags
  1184. * - encoding: unused
  1185. * - decoding: Set by user.
  1186. */
  1187. int error_concealment;
  1188. #define FF_EC_GUESS_MVS 1
  1189. #define FF_EC_DEBLOCK 2
  1190. /**
  1191. * dsp_mask could be add used to disable unwanted CPU features
  1192. * CPU features (i.e. MMX, SSE. ...)
  1193. *
  1194. * With the FORCE flag you may instead enable given CPU features.
  1195. * (Dangerous: Usable in case of misdetection, improper usage however will
  1196. * result into program crash.)
  1197. */
  1198. unsigned dsp_mask;
  1199. #define FF_MM_FORCE 0x80000000 /* Force usage of selected flags (OR) */
  1200. /* lower 16 bits - CPU features */
  1201. #define FF_MM_MMX 0x0001 /* standard MMX */
  1202. #define FF_MM_3DNOW 0x0004 /* AMD 3DNOW */
  1203. #define FF_MM_MMXEXT 0x0002 /* SSE integer functions or AMD MMX ext */
  1204. #define FF_MM_SSE 0x0008 /* SSE functions */
  1205. #define FF_MM_SSE2 0x0010 /* PIV SSE2 functions */
  1206. #define FF_MM_3DNOWEXT 0x0020 /* AMD 3DNowExt */
  1207. #define FF_MM_SSE3 0x0040 /* Prescott SSE3 functions */
  1208. #define FF_MM_SSSE3 0x0080 /* Conroe SSSE3 functions */
  1209. #define FF_MM_IWMMXT 0x0100 /* XScale IWMMXT */
  1210. /**
  1211. * bits per sample/pixel from the demuxer (needed for huffyuv).
  1212. * - encoding: Set by libavcodec.
  1213. * - decoding: Set by user.
  1214. */
  1215. int bits_per_sample;
  1216. /**
  1217. * prediction method (needed for huffyuv)
  1218. * - encoding: Set by user.
  1219. * - decoding: unused
  1220. */
  1221. int prediction_method;
  1222. #define FF_PRED_LEFT 0
  1223. #define FF_PRED_PLANE 1
  1224. #define FF_PRED_MEDIAN 2
  1225. /**
  1226. * sample aspect ratio (0 if unknown)
  1227. * Numerator and denominator must be relatively prime and smaller than 256 for some video standards.
  1228. * - encoding: Set by user.
  1229. * - decoding: Set by libavcodec.
  1230. */
  1231. AVRational sample_aspect_ratio;
  1232. /**
  1233. * the picture in the bitstream
  1234. * - encoding: Set by libavcodec.
  1235. * - decoding: Set by libavcodec.
  1236. */
  1237. AVFrame *coded_frame;
  1238. /**
  1239. * debug
  1240. * - encoding: Set by user.
  1241. * - decoding: Set by user.
  1242. */
  1243. int debug;
  1244. #define FF_DEBUG_PICT_INFO 1
  1245. #define FF_DEBUG_RC 2
  1246. #define FF_DEBUG_BITSTREAM 4
  1247. #define FF_DEBUG_MB_TYPE 8
  1248. #define FF_DEBUG_QP 16
  1249. #define FF_DEBUG_MV 32
  1250. #define FF_DEBUG_DCT_COEFF 0x00000040
  1251. #define FF_DEBUG_SKIP 0x00000080
  1252. #define FF_DEBUG_STARTCODE 0x00000100
  1253. #define FF_DEBUG_PTS 0x00000200
  1254. #define FF_DEBUG_ER 0x00000400
  1255. #define FF_DEBUG_MMCO 0x00000800
  1256. #define FF_DEBUG_BUGS 0x00001000
  1257. #define FF_DEBUG_VIS_QP 0x00002000
  1258. #define FF_DEBUG_VIS_MB_TYPE 0x00004000
  1259. /**
  1260. * debug
  1261. * - encoding: Set by user.
  1262. * - decoding: Set by user.
  1263. */
  1264. int debug_mv;
  1265. #define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames
  1266. #define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames
  1267. #define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames
  1268. /**
  1269. * error
  1270. * - encoding: Set by libavcodec if flags&CODEC_FLAG_PSNR.
  1271. * - decoding: unused
  1272. */
  1273. uint64_t error[4];
  1274. /**
  1275. * minimum MB quantizer
  1276. * - encoding: unused
  1277. * - decoding: unused
  1278. */
  1279. int mb_qmin;
  1280. /**
  1281. * maximum MB quantizer
  1282. * - encoding: unused
  1283. * - decoding: unused
  1284. */
  1285. int mb_qmax;
  1286. /**
  1287. * motion estimation comparison function
  1288. * - encoding: Set by user.
  1289. * - decoding: unused
  1290. */
  1291. int me_cmp;
  1292. /**
  1293. * subpixel motion estimation comparison function
  1294. * - encoding: Set by user.
  1295. * - decoding: unused
  1296. */
  1297. int me_sub_cmp;
  1298. /**
  1299. * macroblock comparison function (not supported yet)
  1300. * - encoding: Set by user.
  1301. * - decoding: unused
  1302. */
  1303. int mb_cmp;
  1304. /**
  1305. * interlaced DCT comparison function
  1306. * - encoding: Set by user.
  1307. * - decoding: unused
  1308. */
  1309. int ildct_cmp;
  1310. #define FF_CMP_SAD 0
  1311. #define FF_CMP_SSE 1
  1312. #define FF_CMP_SATD 2
  1313. #define FF_CMP_DCT 3
  1314. #define FF_CMP_PSNR 4
  1315. #define FF_CMP_BIT 5
  1316. #define FF_CMP_RD 6
  1317. #define FF_CMP_ZERO 7
  1318. #define FF_CMP_VSAD 8
  1319. #define FF_CMP_VSSE 9
  1320. #define FF_CMP_NSSE 10
  1321. #define FF_CMP_W53 11
  1322. #define FF_CMP_W97 12
  1323. #define FF_CMP_DCTMAX 13
  1324. #define FF_CMP_DCT264 14
  1325. #define FF_CMP_CHROMA 256
  1326. /**
  1327. * ME diamond size & shape
  1328. * - encoding: Set by user.
  1329. * - decoding: unused
  1330. */
  1331. int dia_size;
  1332. /**
  1333. * amount of previous MV predictors (2a+1 x 2a+1 square)
  1334. * - encoding: Set by user.
  1335. * - decoding: unused
  1336. */
  1337. int last_predictor_count;
  1338. /**
  1339. * prepass for motion estimation
  1340. * - encoding: Set by user.
  1341. * - decoding: unused
  1342. */
  1343. int pre_me;
  1344. /**
  1345. * motion estimation prepass comparison function
  1346. * - encoding: Set by user.
  1347. * - decoding: unused
  1348. */
  1349. int me_pre_cmp;
  1350. /**
  1351. * ME prepass diamond size & shape
  1352. * - encoding: Set by user.
  1353. * - decoding: unused
  1354. */
  1355. int pre_dia_size;
  1356. /**
  1357. * subpel ME quality
  1358. * - encoding: Set by user.
  1359. * - decoding: unused
  1360. */
  1361. int me_subpel_quality;
  1362. /**
  1363. * callback to negotiate the pixelFormat
  1364. * @param fmt is the list of formats which are supported by the codec,
  1365. * it is terminated by -1 as 0 is a valid format, the formats are ordered by quality.
  1366. * The first is always the native one.
  1367. * @return the chosen format
  1368. * - encoding: unused
  1369. * - decoding: Set by user, if not set the native format will be chosen.
  1370. */
  1371. enum PixelFormat (*get_format)(struct AVCodecContext *s, const enum PixelFormat * fmt);
  1372. /**
  1373. * DTG active format information (additional aspect ratio
  1374. * information only used in DVB MPEG-2 transport streams)
  1375. * 0 if not set.
  1376. *
  1377. * - encoding: unused
  1378. * - decoding: Set by decoder.
  1379. */
  1380. int dtg_active_format;
  1381. #define FF_DTG_AFD_SAME 8
  1382. #define FF_DTG_AFD_4_3 9
  1383. #define FF_DTG_AFD_16_9 10
  1384. #define FF_DTG_AFD_14_9 11
  1385. #define FF_DTG_AFD_4_3_SP_14_9 13
  1386. #define FF_DTG_AFD_16_9_SP_14_9 14
  1387. #define FF_DTG_AFD_SP_4_3 15
  1388. /**
  1389. * maximum motion estimation search range in subpel units
  1390. * If 0 then no limit.
  1391. *
  1392. * - encoding: Set by user.
  1393. * - decoding: unused
  1394. */
  1395. int me_range;
  1396. /**
  1397. * intra quantizer bias
  1398. * - encoding: Set by user.
  1399. * - decoding: unused
  1400. */
  1401. int intra_quant_bias;
  1402. #define FF_DEFAULT_QUANT_BIAS 999999
  1403. /**
  1404. * inter quantizer bias
  1405. * - encoding: Set by user.
  1406. * - decoding: unused
  1407. */
  1408. int inter_quant_bias;
  1409. /**
  1410. * color table ID
  1411. * - encoding: unused
  1412. * - decoding: Which clrtable should be used for 8bit RGB images.
  1413. * Tables have to be stored somewhere. FIXME
  1414. */
  1415. int color_table_id;
  1416. /**
  1417. * internal_buffer count
  1418. * Don't touch, used by libavcodec default_get_buffer().
  1419. */
  1420. int internal_buffer_count;
  1421. /**
  1422. * internal_buffers
  1423. * Don't touch, used by libavcodec default_get_buffer().
  1424. */
  1425. void *internal_buffer;
  1426. #define FF_LAMBDA_SHIFT 7
  1427. #define FF_LAMBDA_SCALE (1<<FF_LAMBDA_SHIFT)
  1428. #define FF_QP2LAMBDA 118 ///< factor to convert from H.263 QP to lambda
  1429. #define FF_LAMBDA_MAX (256*128-1)
  1430. #define FF_QUALITY_SCALE FF_LAMBDA_SCALE //FIXME maybe remove
  1431. /**
  1432. * Global quality for codecs which cannot change it per frame.
  1433. * This should be proportional to MPEG-1/2/4 qscale.
  1434. * - encoding: Set by user.
  1435. * - decoding: unused
  1436. */
  1437. int global_quality;
  1438. #define FF_CODER_TYPE_VLC 0
  1439. #define FF_CODER_TYPE_AC 1
  1440. #define FF_CODER_TYPE_RAW 2
  1441. #define FF_CODER_TYPE_RLE 3
  1442. #define FF_CODER_TYPE_DEFLATE 4
  1443. /**
  1444. * coder type
  1445. * - encoding: Set by user.
  1446. * - decoding: unused
  1447. */
  1448. int coder_type;
  1449. /**
  1450. * context model
  1451. * - encoding: Set by user.
  1452. * - decoding: unused
  1453. */
  1454. int context_model;
  1455. #if 0
  1456. /**
  1457. *
  1458. * - encoding: unused
  1459. * - decoding: Set by user.
  1460. */
  1461. uint8_t * (*realloc)(struct AVCodecContext *s, uint8_t *buf, int buf_size);
  1462. #endif
  1463. /**
  1464. * slice flags
  1465. * - encoding: unused
  1466. * - decoding: Set by user.
  1467. */
  1468. int slice_flags;
  1469. #define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display
  1470. #define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics)
  1471. #define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
  1472. /**
  1473. * XVideo Motion Acceleration
  1474. * - encoding: forbidden
  1475. * - decoding: set by decoder
  1476. */
  1477. int xvmc_acceleration;
  1478. /**
  1479. * macroblock decision mode
  1480. * - encoding: Set by user.
  1481. * - decoding: unused
  1482. */
  1483. int mb_decision;
  1484. #define FF_MB_DECISION_SIMPLE 0 ///< uses mb_cmp
  1485. #define FF_MB_DECISION_BITS 1 ///< chooses the one which needs the fewest bits
  1486. #define FF_MB_DECISION_RD 2 ///< rate distoration
  1487. /**
  1488. * custom intra quantization matrix
  1489. * - encoding: Set by user, can be NULL.
  1490. * - decoding: Set by libavcodec.
  1491. */
  1492. uint16_t *intra_matrix;
  1493. /**
  1494. * custom inter quantization matrix
  1495. * - encoding: Set by user, can be NULL.
  1496. * - decoding: Set by libavcodec.
  1497. */
  1498. uint16_t *inter_matrix;
  1499. /**
  1500. * fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
  1501. * This is used to work around some encoder bugs.
  1502. * - encoding: unused
  1503. * - decoding: Set by user, will be converted to uppercase by libavcodec during init.
  1504. */
  1505. unsigned int stream_codec_tag;
  1506. /**
  1507. * scene change detection threshold
  1508. * 0 is default, larger means fewer detected scene changes.
  1509. * - encoding: Set by user.
  1510. * - decoding: unused
  1511. */
  1512. int scenechange_threshold;
  1513. /**
  1514. * minimum Lagrange multipler
  1515. * - encoding: Set by user.
  1516. * - decoding: unused
  1517. */
  1518. int lmin;
  1519. /**
  1520. * maximum Lagrange multipler
  1521. * - encoding: Set by user.
  1522. * - decoding: unused
  1523. */
  1524. int lmax;
  1525. /**
  1526. * palette control structure
  1527. * - encoding: ??? (no palette-enabled encoder yet)
  1528. * - decoding: Set by user.
  1529. */
  1530. struct AVPaletteControl *palctrl;
  1531. /**
  1532. * noise reduction strength
  1533. * - encoding: Set by user.
  1534. * - decoding: unused
  1535. */
  1536. int noise_reduction;
  1537. /**
  1538. * Called at the beginning of a frame to get cr buffer for it.
  1539. * Buffer type (size, hints) must be the same. libavcodec won't check it.
  1540. * libavcodec will pass previous buffer in pic, function should return
  1541. * same buffer or new buffer with old frame "painted" into it.
  1542. * If pic.data[0] == NULL must behave like get_buffer().
  1543. * - encoding: unused
  1544. * - decoding: Set by libavcodec., user can override
  1545. */
  1546. int (*reget_buffer)(struct AVCodecContext *c, AVFrame *pic);
  1547. /**
  1548. * Number of bits which should be loaded into the rc buffer before decoding starts.
  1549. * - encoding: Set by user.
  1550. * - decoding: unused
  1551. */
  1552. int rc_initial_buffer_occupancy;
  1553. /**
  1554. *
  1555. * - encoding: Set by user.
  1556. * - decoding: unused
  1557. */
  1558. int inter_threshold;
  1559. /**
  1560. * CODEC_FLAG2_*
  1561. * - encoding: Set by user.
  1562. * - decoding: Set by user.
  1563. */
  1564. int flags2;
  1565. /**
  1566. * Simulates errors in the bitstream to test error concealment.
  1567. * - encoding: Set by user.
  1568. * - decoding: unused
  1569. */
  1570. int error_rate;
  1571. /**
  1572. * MP3 antialias algorithm, see FF_AA_* below.
  1573. * - encoding: unused
  1574. * - decoding: Set by user.
  1575. */
  1576. int antialias_algo;
  1577. #define FF_AA_AUTO 0
  1578. #define FF_AA_FASTINT 1 //not implemented yet
  1579. #define FF_AA_INT 2
  1580. #define FF_AA_FLOAT 3
  1581. /**
  1582. * quantizer noise shaping
  1583. * - encoding: Set by user.
  1584. * - decoding: unused
  1585. */
  1586. int quantizer_noise_shaping;
  1587. /**
  1588. * thread count
  1589. * is used to decide how many independent tasks should be passed to execute()
  1590. * - encoding: Set by user.
  1591. * - decoding: Set by user.
  1592. */
  1593. int thread_count;
  1594. /**
  1595. * The codec may call this to execute several independent things.
  1596. * It will return only after finishing all tasks.
  1597. * The user may replace this with some multithreaded implementation,
  1598. * the default implementation will execute the parts serially.
  1599. * @param count the number of things to execute
  1600. * - encoding: Set by libavcodec, user can override.
  1601. * - decoding: Set by libavcodec, user can override.
  1602. */
  1603. int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void **arg2, int *ret, int count);
  1604. /**
  1605. * thread opaque
  1606. * Can be used by execute() to store some per AVCodecContext stuff.
  1607. * - encoding: set by execute()
  1608. * - decoding: set by execute()
  1609. */
  1610. void *thread_opaque;
  1611. /**
  1612. * Motion estimation threshold below which no motion estimation is
  1613. * performed, but instead the user specified motion vectors are used.
  1614. *
  1615. * - encoding: Set by user.
  1616. * - decoding: unused
  1617. */
  1618. int me_threshold;
  1619. /**
  1620. * Macroblock threshold below which the user specified macroblock types will be used.
  1621. * - encoding: Set by user.
  1622. * - decoding: unused
  1623. */
  1624. int mb_threshold;
  1625. /**
  1626. * precision of the intra DC coefficient - 8
  1627. * - encoding: Set by user.
  1628. * - decoding: unused
  1629. */
  1630. int intra_dc_precision;
  1631. /**
  1632. * noise vs. sse weight for the nsse comparsion function
  1633. * - encoding: Set by user.
  1634. * - decoding: unused
  1635. */
  1636. int nsse_weight;
  1637. /**
  1638. * Number of macroblock rows at the top which are skipped.
  1639. * - encoding: unused
  1640. * - decoding: Set by user.
  1641. */
  1642. int skip_top;
  1643. /**
  1644. * Number of macroblock rows at the bottom which are skipped.
  1645. * - encoding: unused
  1646. * - decoding: Set by user.
  1647. */
  1648. int skip_bottom;
  1649. /**
  1650. * profile
  1651. * - encoding: Set by user.
  1652. * - decoding: Set by libavcodec.
  1653. */
  1654. int profile;
  1655. #define FF_PROFILE_UNKNOWN -99
  1656. #define FF_PROFILE_AAC_MAIN 0
  1657. #define FF_PROFILE_AAC_LOW 1
  1658. #define FF_PROFILE_AAC_SSR 2
  1659. #define FF_PROFILE_AAC_LTP 3
  1660. /**
  1661. * level
  1662. * - encoding: Set by user.
  1663. * - decoding: Set by libavcodec.
  1664. */
  1665. int level;
  1666. #define FF_LEVEL_UNKNOWN -99
  1667. /**
  1668. * low resolution decoding, 1-> 1/2 size, 2->1/4 size
  1669. * - encoding: unused
  1670. * - decoding: Set by user.
  1671. */
  1672. int lowres;
  1673. /**
  1674. * Bitstream width / height, may be different from width/height if lowres
  1675. * or other things are used.
  1676. * - encoding: unused
  1677. * - decoding: Set by user before init if known. Codec should override / dynamically change if needed.
  1678. */
  1679. int coded_width, coded_height;
  1680. /**
  1681. * frame skip threshold
  1682. * - encoding: Set by user.
  1683. * - decoding: unused
  1684. */
  1685. int frame_skip_threshold;
  1686. /**
  1687. * frame skip factor
  1688. * - encoding: Set by user.
  1689. * - decoding: unused
  1690. */
  1691. int frame_skip_factor;
  1692. /**
  1693. * frame skip exponent
  1694. * - encoding: Set by user.
  1695. * - decoding: unused
  1696. */
  1697. int frame_skip_exp;
  1698. /**
  1699. * frame skip comparison function
  1700. * - encoding: Set by user.
  1701. * - decoding: unused
  1702. */
  1703. int frame_skip_cmp;
  1704. /**
  1705. * Border processing masking, raises the quantizer for mbs on the borders
  1706. * of the picture.
  1707. * - encoding: Set by user.
  1708. * - decoding: unused
  1709. */
  1710. float border_masking;
  1711. /**
  1712. * minimum MB lagrange multipler
  1713. * - encoding: Set by user.
  1714. * - decoding: unused
  1715. */
  1716. int mb_lmin;
  1717. /**
  1718. * maximum MB lagrange multipler
  1719. * - encoding: Set by user.
  1720. * - decoding: unused
  1721. */
  1722. int mb_lmax;
  1723. /**
  1724. *
  1725. * - encoding: Set by user.
  1726. * - decoding: unused
  1727. */
  1728. int me_penalty_compensation;
  1729. /**
  1730. *
  1731. * - encoding: unused
  1732. * - decoding: Set by user.
  1733. */
  1734. enum AVDiscard skip_loop_filter;
  1735. /**
  1736. *
  1737. * - encoding: unused
  1738. * - decoding: Set by user.
  1739. */
  1740. enum AVDiscard skip_idct;
  1741. /**
  1742. *
  1743. * - encoding: unused
  1744. * - decoding: Set by user.
  1745. */
  1746. enum AVDiscard skip_frame;
  1747. /**
  1748. *
  1749. * - encoding: Set by user.
  1750. * - decoding: unused
  1751. */
  1752. int bidir_refine;
  1753. /**
  1754. *
  1755. * - encoding: Set by user.
  1756. * - decoding: unused
  1757. */
  1758. int brd_scale;
  1759. /**
  1760. * constant rate factor - quality-based VBR - values ~correspond to qps
  1761. * - encoding: Set by user.
  1762. * - decoding: unused
  1763. */
  1764. float crf;
  1765. /**
  1766. * constant quantization parameter rate control method
  1767. * - encoding: Set by user.
  1768. * - decoding: unused
  1769. */
  1770. int cqp;
  1771. /**
  1772. * minimum GOP size
  1773. * - encoding: Set by user.
  1774. * - decoding: unused
  1775. */
  1776. int keyint_min;
  1777. /**
  1778. * number of reference frames
  1779. * - encoding: Set by user.
  1780. * - decoding: unused
  1781. */
  1782. int refs;
  1783. /**
  1784. * chroma qp offset from luma
  1785. * - encoding: Set by user.
  1786. * - decoding: unused
  1787. */
  1788. int chromaoffset;
  1789. /**
  1790. * Influences how often B-frames are used.
  1791. * - encoding: Set by user.
  1792. * - decoding: unused
  1793. */
  1794. int bframebias;
  1795. /**
  1796. * trellis RD quantization
  1797. * - encoding: Set by user.
  1798. * - decoding: unused
  1799. */
  1800. int trellis;
  1801. /**
  1802. * Reduce fluctuations in qp (before curve compression).
  1803. * - encoding: Set by user.
  1804. * - decoding: unused
  1805. */
  1806. float complexityblur;
  1807. /**
  1808. * in-loop deblocking filter alphac0 parameter
  1809. * alpha is in the range -6...6
  1810. * - encoding: Set by user.
  1811. * - decoding: unused
  1812. */
  1813. int deblockalpha;
  1814. /**
  1815. * in-loop deblocking filter beta parameter
  1816. * beta is in the range -6...6
  1817. * - encoding: Set by user.
  1818. * - decoding: unused
  1819. */
  1820. int deblockbeta;
  1821. /**
  1822. * macroblock subpartition sizes to consider - p8x8, p4x4, b8x8, i8x8, i4x4
  1823. * - encoding: Set by user.
  1824. * - decoding: unused
  1825. */
  1826. int partitions;
  1827. #define X264_PART_I4X4 0x001 /* Analyse i4x4 */
  1828. #define X264_PART_I8X8 0x002 /* Analyse i8x8 (requires 8x8 transform) */
  1829. #define X264_PART_P8X8 0x010 /* Analyse p16x8, p8x16 and p8x8 */
  1830. #define X264_PART_P4X4 0x020 /* Analyse p8x4, p4x8, p4x4 */
  1831. #define X264_PART_B8X8 0x100 /* Analyse b16x8, b8x16 and b8x8 */
  1832. /**
  1833. * direct MV prediction mode - 0 (none), 1 (spatial), 2 (temporal)
  1834. * - encoding: Set by user.
  1835. * - decoding: unused
  1836. */
  1837. int directpred;
  1838. /**
  1839. * Audio cutoff bandwidth (0 means "automatic"), currently used only by FAAC.
  1840. * - encoding: Set by user.
  1841. * - decoding: unused
  1842. */
  1843. int cutoff;
  1844. /**
  1845. * Multiplied by qscale for each frame and added to scene_change_score.
  1846. * - encoding: Set by user.
  1847. * - decoding: unused
  1848. */
  1849. int scenechange_factor;
  1850. /**
  1851. *
  1852. * Note: Value depends upon the compare function used for fullpel ME.
  1853. * - encoding: Set by user.
  1854. * - decoding: unused
  1855. */
  1856. int mv0_threshold;
  1857. /**
  1858. * Adjusts sensitivity of b_frame_strategy 1.
  1859. * - encoding: Set by user.
  1860. * - decoding: unused
  1861. */
  1862. int b_sensitivity;
  1863. /**
  1864. * - encoding: Set by user.
  1865. * - decoding: unused
  1866. */
  1867. int compression_level;
  1868. #define FF_COMPRESSION_DEFAULT -1
  1869. /**
  1870. * Sets whether to use LPC mode - used by FLAC encoder.
  1871. * - encoding: Set by user.
  1872. * - decoding: unused
  1873. */
  1874. int use_lpc;
  1875. /**
  1876. * LPC coefficient precision - used by FLAC encoder
  1877. * - encoding: Set by user.
  1878. * - decoding: unused
  1879. */
  1880. int lpc_coeff_precision;
  1881. /**
  1882. * - encoding: Set by user.
  1883. * - decoding: unused
  1884. */
  1885. int min_prediction_order;
  1886. /**
  1887. * - encoding: Set by user.
  1888. * - decoding: unused
  1889. */
  1890. int max_prediction_order;
  1891. /**
  1892. * search method for selecting prediction order
  1893. * - encoding: Set by user.
  1894. * - decoding: unused
  1895. */
  1896. int prediction_order_method;
  1897. /**
  1898. * - encoding: Set by user.
  1899. * - decoding: unused
  1900. */
  1901. int min_partition_order;
  1902. /**
  1903. * - encoding: Set by user.
  1904. * - decoding: unused
  1905. */
  1906. int max_partition_order;
  1907. /**
  1908. * GOP timecode frame start number, in non drop frame format
  1909. * - encoding: Set by user.
  1910. * - decoding: unused
  1911. */
  1912. int64_t timecode_frame_start;
  1913. } AVCodecContext;
  1914. /**
  1915. * AVCodec.
  1916. */
  1917. typedef struct AVCodec {
  1918. /**
  1919. * Name of the codec implementation.
  1920. * The name is globally unique among encoders and among decoders (but an
  1921. * encoder and a decoder can share the same name).
  1922. * This is the primary way to find a codec from the user perspective.
  1923. */
  1924. const char *name;
  1925. enum CodecType type;
  1926. enum CodecID id;
  1927. int priv_data_size;
  1928. int (*init)(AVCodecContext *);
  1929. int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data);
  1930. int (*close)(AVCodecContext *);
  1931. int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
  1932. uint8_t *buf, int buf_size);
  1933. int capabilities;
  1934. struct AVCodec *next;
  1935. void (*flush)(AVCodecContext *);
  1936. const AVRational *supported_framerates; ///array of supported framerates, or NULL if any, array is terminated by {0,0}
  1937. const enum PixelFormat *pix_fmts; ///array of supported pixel formats, or NULL if unknown, array is terminanted by -1
  1938. } AVCodec;
  1939. /**
  1940. * four components are given, that's all.
  1941. * the last component is alpha
  1942. */
  1943. typedef struct AVPicture {
  1944. uint8_t *data[4];
  1945. int linesize[4]; ///< number of bytes per line
  1946. } AVPicture;
  1947. /**
  1948. * AVPaletteControl
  1949. * This structure defines a method for communicating palette changes
  1950. * between and demuxer and a decoder.
  1951. *
  1952. * @deprecated Use AVPacket to send palette changes instead.
  1953. * This is totally broken.
  1954. */
  1955. #define AVPALETTE_SIZE 1024
  1956. #define AVPALETTE_COUNT 256
  1957. typedef struct AVPaletteControl {
  1958. /* Demuxer sets this to 1 to indicate the palette has changed;
  1959. * decoder resets to 0. */
  1960. int palette_changed;
  1961. /* 4-byte ARGB palette entries, stored in native byte order; note that
  1962. * the individual palette components should be on a 8-bit scale; if
  1963. * the palette data comes from an IBM VGA native format, the component
  1964. * data is probably 6 bits in size and needs to be scaled. */
  1965. unsigned int palette[AVPALETTE_COUNT];
  1966. } AVPaletteControl attribute_deprecated;
  1967. typedef struct AVSubtitleRect {
  1968. uint16_t x;
  1969. uint16_t y;
  1970. uint16_t w;
  1971. uint16_t h;
  1972. uint16_t nb_colors;
  1973. int linesize;
  1974. uint32_t *rgba_palette;
  1975. uint8_t *bitmap;
  1976. } AVSubtitleRect;
  1977. typedef struct AVSubtitle {
  1978. uint16_t format; /* 0 = graphics */
  1979. uint32_t start_display_time; /* relative to packet pts, in ms */
  1980. uint32_t end_display_time; /* relative to packet pts, in ms */
  1981. uint32_t num_rects;
  1982. AVSubtitleRect *rects;
  1983. } AVSubtitle;
  1984. /* resample.c */
  1985. struct ReSampleContext;
  1986. struct AVResampleContext;
  1987. typedef struct ReSampleContext ReSampleContext;
  1988. ReSampleContext *audio_resample_init(int output_channels, int input_channels,
  1989. int output_rate, int input_rate);
  1990. int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
  1991. void audio_resample_close(ReSampleContext *s);
  1992. struct AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_length, int log2_phase_count, int linear, double cutoff);
  1993. int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx);
  1994. void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance);
  1995. void av_resample_close(struct AVResampleContext *c);
  1996. #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
  1997. /* YUV420 format is assumed ! */
  1998. /**
  1999. * @deprecated Use the software scaler (swscale) instead.
  2000. */
  2001. typedef struct ImgReSampleContext ImgReSampleContext attribute_deprecated;
  2002. /**
  2003. * @deprecated Use the software scaler (swscale) instead.
  2004. */
  2005. attribute_deprecated ImgReSampleContext *img_resample_init(int output_width, int output_height,
  2006. int input_width, int input_height);
  2007. /**
  2008. * @deprecated Use the software scaler (swscale) instead.
  2009. */
  2010. attribute_deprecated ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
  2011. int iwidth, int iheight,
  2012. int topBand, int bottomBand,
  2013. int leftBand, int rightBand,
  2014. int padtop, int padbottom,
  2015. int padleft, int padright);
  2016. /**
  2017. * @deprecated Use the software scaler (swscale) instead.
  2018. */
  2019. attribute_deprecated void img_resample(struct ImgReSampleContext *s,
  2020. AVPicture *output, const AVPicture *input);
  2021. /**
  2022. * @deprecated Use the software scaler (swscale) instead.
  2023. */
  2024. attribute_deprecated void img_resample_close(struct ImgReSampleContext *s);
  2025. #endif
  2026. /**
  2027. * Allocate memory for a picture. Call avpicture_free to free it.
  2028. *
  2029. * @param picture the picture to be filled in
  2030. * @param pix_fmt the format of the picture
  2031. * @param width the width of the picture
  2032. * @param height the height of the picture
  2033. * @return zero if successful, a negative value if not
  2034. */
  2035. int avpicture_alloc(AVPicture *picture, int pix_fmt, int width, int height);
  2036. /**
  2037. * Free a picture previously allocated by avpicture_alloc().
  2038. *
  2039. * @param picture the AVPicture to be freed
  2040. */
  2041. void avpicture_free(AVPicture *picture);
  2042. /**
  2043. * Fill in the AVPicture fields.
  2044. * The fields of the given AVPicture are filled in by using the 'ptr' address
  2045. * which points to the image data buffer. Depending on the specified picture
  2046. * format, one or multiple image data pointers and line sizes will be set.
  2047. * If a planar format is specified, several pointers will be set pointing to
  2048. * the different picture planes and the line sizes of the different planes
  2049. * will be stored in the lines_sizes array.
  2050. *
  2051. * @param picture AVPicture whose fields are to be filled in
  2052. * @param ptr Buffer which will contain or contains the actual image data
  2053. * @param pix_fmt The format in which the picture data is stored.
  2054. * @param width the width of the image in pixels
  2055. * @param height the height of the image in pixels
  2056. * @return size of the image data in bytes
  2057. */
  2058. int avpicture_fill(AVPicture *picture, uint8_t *ptr,
  2059. int pix_fmt, int width, int height);
  2060. int avpicture_layout(const AVPicture* src, int pix_fmt, int width, int height,
  2061. unsigned char *dest, int dest_size);
  2062. /**
  2063. * Calculate the size in bytes that a picture of the given width and height
  2064. * would occupy if stored in the given picture format.
  2065. *
  2066. * @param pix_fmt the given picture format
  2067. * @param width the width of the image
  2068. * @param height the height of the image
  2069. * @return Image data size in bytes
  2070. */
  2071. int avpicture_get_size(int pix_fmt, int width, int height);
  2072. void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift);
  2073. const char *avcodec_get_pix_fmt_name(int pix_fmt);
  2074. void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
  2075. enum PixelFormat avcodec_get_pix_fmt(const char* name);
  2076. unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat p);
  2077. #define FF_LOSS_RESOLUTION 0x0001 /**< loss due to resolution change */
  2078. #define FF_LOSS_DEPTH 0x0002 /**< loss due to color depth change */
  2079. #define FF_LOSS_COLORSPACE 0x0004 /**< loss due to color space conversion */
  2080. #define FF_LOSS_ALPHA 0x0008 /**< loss of alpha bits */
  2081. #define FF_LOSS_COLORQUANT 0x0010 /**< loss due to color quantization */
  2082. #define FF_LOSS_CHROMA 0x0020 /**< loss of chroma (e.g. RGB to gray conversion) */
  2083. /**
  2084. * Computes what kind of losses will occur when converting from one specific
  2085. * pixel format to another.
  2086. * When converting from one pixel format to another, information loss may occur.
  2087. * For example, when converting from RGB24 to GRAY, the color information will
  2088. * be lost. Similarly, other losses occur when converting from some formats to
  2089. * other formats. These losses can involve loss of chroma, but also loss of
  2090. * resolution, loss of color depth, loss due to the color space conversion, loss
  2091. * of the alpha bits or loss due to color quantization.
  2092. * avcodec_get_fix_fmt_loss() informs you about the various types of losses
  2093. * which will occur when converting from one pixel format to another.
  2094. *
  2095. * @param[in] dst_pix_fmt destination pixel format
  2096. * @param[in] src_pix_fmt source pixel format
  2097. * @param[in] has_alpha Whether the source pixel format alpha channel is used.
  2098. * @return Combination of flags informing you what kind of losses will occur.
  2099. */
  2100. int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt,
  2101. int has_alpha);
  2102. /**
  2103. * Finds the best pixel format to convert to given a certain source pixel
  2104. * format. When converting from one pixel format to another, information loss
  2105. * may occur. For example, when converting from RGB24 to GRAY, the color
  2106. * information will be lost. Similarly, other losses occur when converting from
  2107. * some formats to other formats. avcodec_find_best_pix_fmt() searches which of
  2108. * the given pixel formats should be used to suffer the least amount of loss.
  2109. * The pixel formats from which it chooses one, are determined by the
  2110. * \p pix_fmt_mask parameter.
  2111. *
  2112. * @code
  2113. * src_pix_fmt = PIX_FMT_YUV420P;
  2114. * pix_fmt_mask = (1 << PIX_FMT_YUV422P) || (1 << PIX_FMT_RGB24);
  2115. * dst_pix_fmt = avcodec_find_best_pix_fmt(pix_fmt_mask, src_pix_fmt, alpha, &loss);
  2116. * @endcode
  2117. *
  2118. * @param[in] pix_fmt_mask bitmask determining which pixel format to choose from
  2119. * @param[in] src_pix_fmt source pixel format
  2120. * @param[in] has_alpha Whether the source pixel format alpha channel is used.
  2121. * @param[out] loss_ptr Combination of flags informing you what kind of losses will occur.
  2122. * @return The best pixel format to convert to or -1 if none was found.
  2123. */
  2124. int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt,
  2125. int has_alpha, int *loss_ptr);
  2126. /**
  2127. * Print in buf the string corresponding to the pixel format with
  2128. * number pix_fmt, or an header if pix_fmt is negative.
  2129. *
  2130. * @param buf[in] the buffer where to write the string
  2131. * @param buf_size[in] the size of buf
  2132. * @param pix_fmt[in] the number of the pixel format to print the corresponding info string, or
  2133. * a negative value to print the corresponding header.
  2134. * Meaningful values for obtaining a pixel format info vary from 0 to PIX_FMT_NB -1.
  2135. */
  2136. void avcodec_pix_fmt_string (char *buf, int buf_size, int pix_fmt);
  2137. #define FF_ALPHA_TRANSP 0x0001 /* image has some totally transparent pixels */
  2138. #define FF_ALPHA_SEMI_TRANSP 0x0002 /* image has some transparent pixels */
  2139. /**
  2140. * Tell if an image really has transparent alpha values.
  2141. * @return ored mask of FF_ALPHA_xxx constants
  2142. */
  2143. int img_get_alpha_info(const AVPicture *src,
  2144. int pix_fmt, int width, int height);
  2145. #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
  2146. /**
  2147. * convert among pixel formats
  2148. * @deprecated Use the software scaler (swscale) instead.
  2149. */
  2150. attribute_deprecated int img_convert(AVPicture *dst, int dst_pix_fmt,
  2151. const AVPicture *src, int pix_fmt,
  2152. int width, int height);
  2153. #endif
  2154. /* deinterlace a picture */
  2155. /* deinterlace - if not supported return -1 */
  2156. int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
  2157. int pix_fmt, int width, int height);
  2158. /* external high level API */
  2159. extern AVCodec *first_avcodec;
  2160. /* returns LIBAVCODEC_VERSION_INT constant */
  2161. unsigned avcodec_version(void);
  2162. /* returns LIBAVCODEC_BUILD constant */
  2163. unsigned avcodec_build(void);
  2164. /**
  2165. * Initializes libavcodec.
  2166. *
  2167. * @warning This function \e must be called before any other libavcodec
  2168. * function.
  2169. */
  2170. void avcodec_init(void);
  2171. void register_avcodec(AVCodec *format);
  2172. /**
  2173. * Finds an encoder with a matching codec ID.
  2174. *
  2175. * @param id CodecID of the requested encoder
  2176. * @return An encoder if one was found, NULL otherwise.
  2177. */
  2178. AVCodec *avcodec_find_encoder(enum CodecID id);
  2179. /**
  2180. * Finds an encoder with the specified name.
  2181. *
  2182. * @param name name of the requested encoder
  2183. * @return An encoder if one was found, NULL otherwise.
  2184. */
  2185. AVCodec *avcodec_find_encoder_by_name(const char *name);
  2186. /**
  2187. * Finds a decoder with a matching codec ID.
  2188. *
  2189. * @param id CodecID of the requested decoder
  2190. * @return A decoder if one was found, NULL otherwise.
  2191. */
  2192. AVCodec *avcodec_find_decoder(enum CodecID id);
  2193. /**
  2194. * Finds an decoder with the specified name.
  2195. *
  2196. * @param name name of the requested decoder
  2197. * @return A decoder if one was found, NULL otherwise.
  2198. */
  2199. AVCodec *avcodec_find_decoder_by_name(const char *name);
  2200. void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
  2201. /**
  2202. * Sets the fields of the given AVCodecContext to default values.
  2203. *
  2204. * @param s The AVCodecContext of which the fields should be set to default values.
  2205. */
  2206. void avcodec_get_context_defaults(AVCodecContext *s);
  2207. /** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
  2208. * we WILL change its arguments and name a few times! */
  2209. void avcodec_get_context_defaults2(AVCodecContext *s, enum CodecType);
  2210. /**
  2211. * Allocates an AVCodecContext and sets its fields to default values. The
  2212. * resulting struct can be deallocated by simply calling av_free().
  2213. *
  2214. * @return An AVCodecContext filled with default values or NULL on failure.
  2215. * @see avcodec_get_context_defaults
  2216. */
  2217. AVCodecContext *avcodec_alloc_context(void);
  2218. /** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
  2219. * we WILL change its arguments and name a few times! */
  2220. AVCodecContext *avcodec_alloc_context2(enum CodecType);
  2221. /**
  2222. * Sets the fields of the given AVFrame to default values.
  2223. *
  2224. * @param pic The AVFrame of which the fields should be set to default values.
  2225. */
  2226. void avcodec_get_frame_defaults(AVFrame *pic);
  2227. /**
  2228. * Allocates an AVFrame and sets its fields to default values. The resulting
  2229. * struct can be deallocated by simply calling av_free().
  2230. *
  2231. * @return An AVFrame filled with default values or NULL on failure.
  2232. * @see avcodec_get_frame_defaults
  2233. */
  2234. AVFrame *avcodec_alloc_frame(void);
  2235. int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
  2236. void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
  2237. int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic);
  2238. void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);
  2239. /**
  2240. * Checks if the given dimension of a picture is valid, meaning that all
  2241. * bytes of the picture can be addressed with a signed int.
  2242. *
  2243. * @param[in] w Width of the picture.
  2244. * @param[in] h Height of the picture.
  2245. * @return Zero if valid, a negative value if invalid.
  2246. */
  2247. int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h);
  2248. enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt);
  2249. int avcodec_thread_init(AVCodecContext *s, int thread_count);
  2250. void avcodec_thread_free(AVCodecContext *s);
  2251. int avcodec_thread_execute(AVCodecContext *s, int (*func)(AVCodecContext *c2, void *arg2),void **arg, int *ret, int count);
  2252. int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void **arg, int *ret, int count);
  2253. //FIXME func typedef
  2254. /**
  2255. * Initializes the AVCodecContext to use the given AVCodec. Prior to using this
  2256. * function the context has to be allocated.
  2257. *
  2258. * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),
  2259. * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for
  2260. * retrieving a codec.
  2261. *
  2262. * @warning This function is not thread safe!
  2263. *
  2264. * @code
  2265. * avcodec_register_all();
  2266. * codec = avcodec_find_decoder(CODEC_ID_H264);
  2267. * if (!codec)
  2268. * exit(1);
  2269. *
  2270. * context = avcodec_alloc_context();
  2271. *
  2272. * if (avcodec_open(context, codec) < 0)
  2273. * exit(1);
  2274. * @endcode
  2275. *
  2276. * @param avctx The context which will be set up to use the given codec.
  2277. * @param codec The codec to use within the context.
  2278. * @return zero on success, a negative value on error
  2279. * @see avcodec_alloc_context, avcodec_find_decoder, avcodec_find_encoder
  2280. */
  2281. int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
  2282. /**
  2283. * @deprecated Use avcodec_decode_audio2() instead.
  2284. */
  2285. attribute_deprecated int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
  2286. int *frame_size_ptr,
  2287. uint8_t *buf, int buf_size);
  2288. /**
  2289. * Decodes an audio frame from \p buf into \p samples.
  2290. * The avcodec_decode_audio2() function decodes an audio frame from the input
  2291. * buffer \p buf of size \p buf_size. To decode it, it makes use of the
  2292. * audio codec which was coupled with \p avctx using avcodec_open(). The
  2293. * resulting decoded frame is stored in output buffer \p samples. If no frame
  2294. * could be decompressed, \p frame_size_ptr is zero. Otherwise, it is the
  2295. * decompressed frame size in \e bytes.
  2296. *
  2297. * @warning You \e must set \p frame_size_ptr to the allocated size of the
  2298. * output buffer before calling avcodec_decode_audio2().
  2299. *
  2300. * @warning The input buffer must be \c FF_INPUT_BUFFER_PADDING_SIZE larger than
  2301. * the actual read bytes because some optimized bitstream readers read 32 or 64
  2302. * bits at once and could read over the end.
  2303. *
  2304. * @warning The end of the input buffer \p buf should be set to 0 to ensure that
  2305. * no overreading happens for damaged MPEG streams.
  2306. *
  2307. * @note You might have to align the input buffer \p buf and output buffer \p
  2308. * samples. The alignment requirements depend on the CPU: On some CPUs it isn't
  2309. * necessary at all, on others it won't work at all if not aligned and on others
  2310. * it will work but it will have an impact on performance. In practice, the
  2311. * bitstream should have 4 byte alignment at minimum and all sample data should
  2312. * be 16 byte aligned unless the CPU doesn't need it (AltiVec and SSE do). If
  2313. * the linesize is not a multiple of 16 then there's no sense in aligning the
  2314. * start of the buffer to 16.
  2315. *
  2316. * @param avctx the codec context
  2317. * @param[out] samples the output buffer
  2318. * @param[in,out] frame_size_ptr the output buffer size in bytes
  2319. * @param[in] buf the input buffer
  2320. * @param[in] buf_size the input buffer size in bytes
  2321. * @return On error a negative value is returned, otherwise the number of bytes
  2322. * used or zero if no frame could be decompressed.
  2323. */
  2324. int avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples,
  2325. int *frame_size_ptr,
  2326. uint8_t *buf, int buf_size);
  2327. /**
  2328. * Decodes a video frame from \p buf into \p picture.
  2329. * The avcodec_decode_video() function decodes a video frame from the input
  2330. * buffer \p buf of size \p buf_size. To decode it, it makes use of the
  2331. * video codec which was coupled with \p avctx using avcodec_open(). The
  2332. * resulting decoded frame is stored in \p picture.
  2333. *
  2334. * @warning The input buffer must be \c FF_INPUT_BUFFER_PADDING_SIZE larger than
  2335. * the actual read bytes because some optimized bitstream readers read 32 or 64
  2336. * bits at once and could read over the end.
  2337. *
  2338. * @warning The end of the input buffer \p buf should be set to 0 to ensure that
  2339. * no overreading happens for damaged MPEG streams.
  2340. *
  2341. * @note You might have to align the input buffer \p buf and output buffer \p
  2342. * samples. The alignment requirements depend on the CPU: on some CPUs it isn't
  2343. * necessary at all, on others it won't work at all if not aligned and on others
  2344. * it will work but it will have an impact on performance. In practice, the
  2345. * bitstream should have 4 byte alignment at minimum and all sample data should
  2346. * be 16 byte aligned unless the CPU doesn't need it (AltiVec and SSE do). If
  2347. * the linesize is not a multiple of 16 then there's no sense in aligning the
  2348. * start of the buffer to 16.
  2349. *
  2350. * @param avctx the codec context
  2351. * @param[out] picture The AVFrame in which the decoded video frame will be stored.
  2352. * @param[in] buf the input buffer
  2353. * @param[in] buf_size the size of the input buffer in bytes
  2354. * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero.
  2355. * @return On error a negative value is returned, otherwise the number of bytes
  2356. * used or zero if no frame could be decompressed.
  2357. */
  2358. int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
  2359. int *got_picture_ptr,
  2360. uint8_t *buf, int buf_size);
  2361. /* Decode a subtitle message. Return -1 if error, otherwise return the
  2362. * number of bytes used. If no subtitle could be decompressed,
  2363. * got_sub_ptr is zero. Otherwise, the subtitle is stored in *sub. */
  2364. int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub,
  2365. int *got_sub_ptr,
  2366. const uint8_t *buf, int buf_size);
  2367. int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata,
  2368. int *data_size_ptr,
  2369. uint8_t *buf, int buf_size);
  2370. /**
  2371. * Encodes an audio frame from \p samples into \p buf.
  2372. * The avcodec_encode_audio() function encodes an audio frame from the input
  2373. * buffer \p samples. To encode it, it makes use of the audio codec which was
  2374. * coupled with \p avctx using avcodec_open(). The resulting encoded frame is
  2375. * stored in output buffer \p buf.
  2376. *
  2377. * @note The output buffer should be at least \c FF_MIN_BUFFER_SIZE bytes large.
  2378. *
  2379. * @param avctx the codec context
  2380. * @param[out] buf the output buffer
  2381. * @param[in] buf_size the output buffer size
  2382. * @param[in] samples the input buffer containing the samples
  2383. * @return On error a negative value is returned, on succes zero or the number
  2384. * of bytes used from the input buffer.
  2385. */
  2386. int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
  2387. const short *samples);
  2388. /**
  2389. * Encodes a video frame from \p pict into \p buf.
  2390. * The avcodec_encode_video() function encodes a video frame from the input
  2391. * \p pict. To encode it, it makes use of the video codec which was coupled with
  2392. * \p avctx using avcodec_open(). The resulting encoded bytes representing the
  2393. * frame are stored in the output buffer \p buf. The input picture should be
  2394. * stored using a specific format, namely \c avctx.pix_fmt.
  2395. *
  2396. * @param avctx the codec context
  2397. * @param[out] buf the output buffer for the bitstream of encoded frame
  2398. * @param[in] buf_size the size of the output buffer in bytes
  2399. * @param[in] pict the input picture to encode
  2400. * @return On error a negative value is returned, on success zero or the number
  2401. * of bytes used from the input buffer.
  2402. */
  2403. int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
  2404. const AVFrame *pict);
  2405. int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
  2406. const AVSubtitle *sub);
  2407. int avcodec_close(AVCodecContext *avctx);
  2408. void avcodec_register_all(void);
  2409. /**
  2410. * Flush buffers, should be called when seeking or when switching to a different stream.
  2411. */
  2412. void avcodec_flush_buffers(AVCodecContext *avctx);
  2413. void avcodec_default_free_buffers(AVCodecContext *s);
  2414. /* misc useful functions */
  2415. /**
  2416. * Returns a single letter to describe the given picture type \p pict_type.
  2417. *
  2418. * @param[in] pict_type the picture type
  2419. * @return A single character representing the picture type.
  2420. */
  2421. char av_get_pict_type_char(int pict_type);
  2422. /**
  2423. * Returns codec bits per sample.
  2424. *
  2425. * @param[in] codec_id the codec
  2426. * @return Number of bits per sample or zero if unknown for the given codec.
  2427. */
  2428. int av_get_bits_per_sample(enum CodecID codec_id);
  2429. /* frame parsing */
  2430. typedef struct AVCodecParserContext {
  2431. void *priv_data;
  2432. struct AVCodecParser *parser;
  2433. int64_t frame_offset; /* offset of the current frame */
  2434. int64_t cur_offset; /* current offset
  2435. (incremented by each av_parser_parse()) */
  2436. int64_t last_frame_offset; /* offset of the last frame */
  2437. /* video info */
  2438. int pict_type; /* XXX: Put it back in AVCodecContext. */
  2439. int repeat_pict; /* XXX: Put it back in AVCodecContext. */
  2440. int64_t pts; /* pts of the current frame */
  2441. int64_t dts; /* dts of the current frame */
  2442. /* private data */
  2443. int64_t last_pts;
  2444. int64_t last_dts;
  2445. int fetch_timestamp;
  2446. #define AV_PARSER_PTS_NB 4
  2447. int cur_frame_start_index;
  2448. int64_t cur_frame_offset[AV_PARSER_PTS_NB];
  2449. int64_t cur_frame_pts[AV_PARSER_PTS_NB];
  2450. int64_t cur_frame_dts[AV_PARSER_PTS_NB];
  2451. int flags;
  2452. #define PARSER_FLAG_COMPLETE_FRAMES 0x0001
  2453. int64_t offset; ///< byte offset from starting packet start
  2454. int64_t last_offset;
  2455. } AVCodecParserContext;
  2456. typedef struct AVCodecParser {
  2457. int codec_ids[5]; /* several codec IDs are permitted */
  2458. int priv_data_size;
  2459. int (*parser_init)(AVCodecParserContext *s);
  2460. int (*parser_parse)(AVCodecParserContext *s,
  2461. AVCodecContext *avctx,
  2462. const uint8_t **poutbuf, int *poutbuf_size,
  2463. const uint8_t *buf, int buf_size);
  2464. void (*parser_close)(AVCodecParserContext *s);
  2465. int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size);
  2466. struct AVCodecParser *next;
  2467. } AVCodecParser;
  2468. extern AVCodecParser *av_first_parser;
  2469. void av_register_codec_parser(AVCodecParser *parser);
  2470. AVCodecParserContext *av_parser_init(int codec_id);
  2471. int av_parser_parse(AVCodecParserContext *s,
  2472. AVCodecContext *avctx,
  2473. uint8_t **poutbuf, int *poutbuf_size,
  2474. const uint8_t *buf, int buf_size,
  2475. int64_t pts, int64_t dts);
  2476. int av_parser_change(AVCodecParserContext *s,
  2477. AVCodecContext *avctx,
  2478. uint8_t **poutbuf, int *poutbuf_size,
  2479. const uint8_t *buf, int buf_size, int keyframe);
  2480. void av_parser_close(AVCodecParserContext *s);
  2481. extern AVCodecParser aac_parser;
  2482. extern AVCodecParser ac3_parser;
  2483. extern AVCodecParser cavsvideo_parser;
  2484. extern AVCodecParser dca_parser;
  2485. extern AVCodecParser dvbsub_parser;
  2486. extern AVCodecParser dvdsub_parser;
  2487. extern AVCodecParser h261_parser;
  2488. extern AVCodecParser h263_parser;
  2489. extern AVCodecParser h264_parser;
  2490. extern AVCodecParser mjpeg_parser;
  2491. extern AVCodecParser mpeg4video_parser;
  2492. extern AVCodecParser mpegaudio_parser;
  2493. extern AVCodecParser mpegvideo_parser;
  2494. extern AVCodecParser pnm_parser;
  2495. extern AVCodecParser vc1_parser;
  2496. typedef struct AVBitStreamFilterContext {
  2497. void *priv_data;
  2498. struct AVBitStreamFilter *filter;
  2499. AVCodecParserContext *parser;
  2500. struct AVBitStreamFilterContext *next;
  2501. } AVBitStreamFilterContext;
  2502. typedef struct AVBitStreamFilter {
  2503. const char *name;
  2504. int priv_data_size;
  2505. int (*filter)(AVBitStreamFilterContext *bsfc,
  2506. AVCodecContext *avctx, const char *args,
  2507. uint8_t **poutbuf, int *poutbuf_size,
  2508. const uint8_t *buf, int buf_size, int keyframe);
  2509. struct AVBitStreamFilter *next;
  2510. } AVBitStreamFilter;
  2511. extern AVBitStreamFilter *av_first_bitstream_filter;
  2512. void av_register_bitstream_filter(AVBitStreamFilter *bsf);
  2513. AVBitStreamFilterContext *av_bitstream_filter_init(const char *name);
  2514. int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc,
  2515. AVCodecContext *avctx, const char *args,
  2516. uint8_t **poutbuf, int *poutbuf_size,
  2517. const uint8_t *buf, int buf_size, int keyframe);
  2518. void av_bitstream_filter_close(AVBitStreamFilterContext *bsf);
  2519. extern AVBitStreamFilter dump_extradata_bsf;
  2520. extern AVBitStreamFilter remove_extradata_bsf;
  2521. extern AVBitStreamFilter noise_bsf;
  2522. extern AVBitStreamFilter mp3_header_compress_bsf;
  2523. extern AVBitStreamFilter mp3_header_decompress_bsf;
  2524. extern AVBitStreamFilter mjpega_dump_header_bsf;
  2525. extern AVBitStreamFilter imx_dump_header_bsf;
  2526. /* memory */
  2527. /**
  2528. * Reallocates the given block if it is not large enough, otherwise it
  2529. * does nothing.
  2530. *
  2531. * @see av_realloc
  2532. */
  2533. void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
  2534. /* for static data only */
  2535. /**
  2536. * Frees all static arrays and resets their pointers to 0.
  2537. * Call this function to release all statically allocated tables.
  2538. *
  2539. * @deprecated. Code which uses av_free_static is broken/misdesigned
  2540. * and should correctly use static arrays
  2541. *
  2542. */
  2543. attribute_deprecated void av_free_static(void);
  2544. /**
  2545. * Allocation of static arrays.
  2546. *
  2547. * @warning Do not use for normal allocation.
  2548. *
  2549. * @param[in] size The amount of memory you need in bytes.
  2550. * @return block of memory of the requested size
  2551. * @deprecated. Code which uses av_mallocz_static is broken/misdesigned
  2552. * and should correctly use static arrays
  2553. */
  2554. attribute_deprecated void *av_mallocz_static(unsigned int size);
  2555. /**
  2556. * Copy image 'src' to 'dst'.
  2557. */
  2558. void av_picture_copy(AVPicture *dst, const AVPicture *src,
  2559. int pix_fmt, int width, int height);
  2560. /**
  2561. * Crop image top and left side.
  2562. */
  2563. int av_picture_crop(AVPicture *dst, const AVPicture *src,
  2564. int pix_fmt, int top_band, int left_band);
  2565. /**
  2566. * Pad image.
  2567. */
  2568. int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, int pix_fmt,
  2569. int padtop, int padbottom, int padleft, int padright, int *color);
  2570. #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
  2571. /**
  2572. * @deprecated Use the software scaler (swscale) instead.
  2573. */
  2574. attribute_deprecated void img_copy(AVPicture *dst, const AVPicture *src,
  2575. int pix_fmt, int width, int height);
  2576. /**
  2577. * @deprecated Use the software scaler (swscale) instead.
  2578. */
  2579. attribute_deprecated int img_crop(AVPicture *dst, const AVPicture *src,
  2580. int pix_fmt, int top_band, int left_band);
  2581. /**
  2582. * @deprecated Use the software scaler (swscale) instead.
  2583. */
  2584. attribute_deprecated int img_pad(AVPicture *dst, const AVPicture *src, int height, int width, int pix_fmt,
  2585. int padtop, int padbottom, int padleft, int padright, int *color);
  2586. #endif
  2587. extern unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
  2588. /**
  2589. * Parses \p str and put in \p width_ptr and \p height_ptr the detected values.
  2590. *
  2591. * @return 0 in case of a successful parsing, a negative value otherwise
  2592. * @param[in] str the string to parse: it has to be a string in the format
  2593. * <width>x<height> or a valid video frame size abbreviation.
  2594. * @param[in,out] width_ptr pointer to the variable which will contain the detected
  2595. * frame width value
  2596. * @param[in,out] height_ptr pointer to the variable which will contain the detected
  2597. * frame height value
  2598. */
  2599. int av_parse_video_frame_size(int *width_ptr, int *height_ptr, const char *str);
  2600. /**
  2601. * Parses \p str and put in \p frame_rate the detected values.
  2602. *
  2603. * @return 0 in case of a successful parsing, a negative value otherwise
  2604. * @param[in] str the string to parse: it has to be a string in the format
  2605. * <frame_rate_nom>/<frame_rate_den>, a float number or a valid video rate abbreviation
  2606. * @param[in,out] frame_rate pointer to the AVRational which will contain the detected
  2607. * frame rate
  2608. */
  2609. int av_parse_video_frame_rate(AVRational *frame_rate, const char *str);
  2610. /* error handling */
  2611. #if EINVAL > 0
  2612. #define AVERROR(e) (-(e)) /**< Returns a negative error code from a POSIX error code, to return from library functions. */
  2613. #define AVUNERROR(e) (-(e)) /**< Returns a POSIX error code from a library function error return value. */
  2614. #else
  2615. /* Some platforms have E* and errno already negated. */
  2616. #define AVERROR(e) (e)
  2617. #define AVUNERROR(e) (e)
  2618. #endif
  2619. #define AVERROR_UNKNOWN AVERROR(EINVAL) /**< unknown error */
  2620. #define AVERROR_IO AVERROR(EIO) /**< I/O error */
  2621. #define AVERROR_NUMEXPECTED AVERROR(EDOM) /**< Number syntax expected in filename. */
  2622. #define AVERROR_INVALIDDATA AVERROR(EINVAL) /**< invalid data found */
  2623. #define AVERROR_NOMEM AVERROR(ENOMEM) /**< not enough memory */
  2624. #define AVERROR_NOFMT AVERROR(EILSEQ) /**< unknown format */
  2625. #define AVERROR_NOTSUPP AVERROR(ENOSYS) /**< Operation not supported. */
  2626. #define AVERROR_NOENT AVERROR(ENOENT) /**< No such file or directory. */
  2627. #endif /* AVCODEC_H */