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.

3152 lines
96KB

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