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.

3106 lines
94KB

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