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.

4071 lines
131KB

  1. /*
  2. * copyright (c) 2001 Fabrice Bellard
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #ifndef AVCODEC_AVCODEC_H
  21. #define AVCODEC_AVCODEC_H
  22. /**
  23. * @file
  24. * external API header
  25. */
  26. #include <errno.h>
  27. #include "libavutil/avutil.h"
  28. #include "libavutil/cpu.h"
  29. #define LIBAVCODEC_VERSION_MAJOR 52
  30. #define LIBAVCODEC_VERSION_MINOR 89
  31. #define LIBAVCODEC_VERSION_MICRO 0
  32. #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
  33. LIBAVCODEC_VERSION_MINOR, \
  34. LIBAVCODEC_VERSION_MICRO)
  35. #define LIBAVCODEC_VERSION AV_VERSION(LIBAVCODEC_VERSION_MAJOR, \
  36. LIBAVCODEC_VERSION_MINOR, \
  37. LIBAVCODEC_VERSION_MICRO)
  38. #define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT
  39. #define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION)
  40. /**
  41. * Those FF_API_* defines are not part of public API.
  42. * They may change, break or disappear at any time.
  43. */
  44. #ifndef FF_API_PALETTE_CONTROL
  45. #define FF_API_PALETTE_CONTROL (LIBAVCODEC_VERSION_MAJOR < 54)
  46. #endif
  47. #ifndef FF_API_MM_FLAGS
  48. #define FF_API_MM_FLAGS (LIBAVCODEC_VERSION_MAJOR < 53)
  49. #endif
  50. #define AV_NOPTS_VALUE INT64_C(0x8000000000000000)
  51. #define AV_TIME_BASE 1000000
  52. #define AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE}
  53. /**
  54. * Identify the syntax and semantics of the bitstream.
  55. * The principle is roughly:
  56. * Two decoders with the same ID can decode the same streams.
  57. * Two encoders with the same ID can encode compatible streams.
  58. * There may be slight deviations from the principle due to implementation
  59. * details.
  60. *
  61. * If you add a codec ID to this list, add it so that
  62. * 1. no value of a existing codec ID changes (that would break ABI),
  63. * 2. it is as close as possible to similar codecs.
  64. */
  65. enum CodecID {
  66. CODEC_ID_NONE,
  67. /* video codecs */
  68. CODEC_ID_MPEG1VIDEO,
  69. CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding
  70. CODEC_ID_MPEG2VIDEO_XVMC,
  71. CODEC_ID_H261,
  72. CODEC_ID_H263,
  73. CODEC_ID_RV10,
  74. CODEC_ID_RV20,
  75. CODEC_ID_MJPEG,
  76. CODEC_ID_MJPEGB,
  77. CODEC_ID_LJPEG,
  78. CODEC_ID_SP5X,
  79. CODEC_ID_JPEGLS,
  80. CODEC_ID_MPEG4,
  81. CODEC_ID_RAWVIDEO,
  82. CODEC_ID_MSMPEG4V1,
  83. CODEC_ID_MSMPEG4V2,
  84. CODEC_ID_MSMPEG4V3,
  85. CODEC_ID_WMV1,
  86. CODEC_ID_WMV2,
  87. CODEC_ID_H263P,
  88. CODEC_ID_H263I,
  89. CODEC_ID_FLV1,
  90. CODEC_ID_SVQ1,
  91. CODEC_ID_SVQ3,
  92. CODEC_ID_DVVIDEO,
  93. CODEC_ID_HUFFYUV,
  94. CODEC_ID_CYUV,
  95. CODEC_ID_H264,
  96. CODEC_ID_INDEO3,
  97. CODEC_ID_VP3,
  98. CODEC_ID_THEORA,
  99. CODEC_ID_ASV1,
  100. CODEC_ID_ASV2,
  101. CODEC_ID_FFV1,
  102. CODEC_ID_4XM,
  103. CODEC_ID_VCR1,
  104. CODEC_ID_CLJR,
  105. CODEC_ID_MDEC,
  106. CODEC_ID_ROQ,
  107. CODEC_ID_INTERPLAY_VIDEO,
  108. CODEC_ID_XAN_WC3,
  109. CODEC_ID_XAN_WC4,
  110. CODEC_ID_RPZA,
  111. CODEC_ID_CINEPAK,
  112. CODEC_ID_WS_VQA,
  113. CODEC_ID_MSRLE,
  114. CODEC_ID_MSVIDEO1,
  115. CODEC_ID_IDCIN,
  116. CODEC_ID_8BPS,
  117. CODEC_ID_SMC,
  118. CODEC_ID_FLIC,
  119. CODEC_ID_TRUEMOTION1,
  120. CODEC_ID_VMDVIDEO,
  121. CODEC_ID_MSZH,
  122. CODEC_ID_ZLIB,
  123. CODEC_ID_QTRLE,
  124. CODEC_ID_SNOW,
  125. CODEC_ID_TSCC,
  126. CODEC_ID_ULTI,
  127. CODEC_ID_QDRAW,
  128. CODEC_ID_VIXL,
  129. CODEC_ID_QPEG,
  130. #if LIBAVCODEC_VERSION_MAJOR < 53
  131. CODEC_ID_XVID,
  132. #endif
  133. CODEC_ID_PNG,
  134. CODEC_ID_PPM,
  135. CODEC_ID_PBM,
  136. CODEC_ID_PGM,
  137. CODEC_ID_PGMYUV,
  138. CODEC_ID_PAM,
  139. CODEC_ID_FFVHUFF,
  140. CODEC_ID_RV30,
  141. CODEC_ID_RV40,
  142. CODEC_ID_VC1,
  143. CODEC_ID_WMV3,
  144. CODEC_ID_LOCO,
  145. CODEC_ID_WNV1,
  146. CODEC_ID_AASC,
  147. CODEC_ID_INDEO2,
  148. CODEC_ID_FRAPS,
  149. CODEC_ID_TRUEMOTION2,
  150. CODEC_ID_BMP,
  151. CODEC_ID_CSCD,
  152. CODEC_ID_MMVIDEO,
  153. CODEC_ID_ZMBV,
  154. CODEC_ID_AVS,
  155. CODEC_ID_SMACKVIDEO,
  156. CODEC_ID_NUV,
  157. CODEC_ID_KMVC,
  158. CODEC_ID_FLASHSV,
  159. CODEC_ID_CAVS,
  160. CODEC_ID_JPEG2000,
  161. CODEC_ID_VMNC,
  162. CODEC_ID_VP5,
  163. CODEC_ID_VP6,
  164. CODEC_ID_VP6F,
  165. CODEC_ID_TARGA,
  166. CODEC_ID_DSICINVIDEO,
  167. CODEC_ID_TIERTEXSEQVIDEO,
  168. CODEC_ID_TIFF,
  169. CODEC_ID_GIF,
  170. CODEC_ID_FFH264,
  171. CODEC_ID_DXA,
  172. CODEC_ID_DNXHD,
  173. CODEC_ID_THP,
  174. CODEC_ID_SGI,
  175. CODEC_ID_C93,
  176. CODEC_ID_BETHSOFTVID,
  177. CODEC_ID_PTX,
  178. CODEC_ID_TXD,
  179. CODEC_ID_VP6A,
  180. CODEC_ID_AMV,
  181. CODEC_ID_VB,
  182. CODEC_ID_PCX,
  183. CODEC_ID_SUNRAST,
  184. CODEC_ID_INDEO4,
  185. CODEC_ID_INDEO5,
  186. CODEC_ID_MIMIC,
  187. CODEC_ID_RL2,
  188. CODEC_ID_8SVX_EXP,
  189. CODEC_ID_8SVX_FIB,
  190. CODEC_ID_ESCAPE124,
  191. CODEC_ID_DIRAC,
  192. CODEC_ID_BFI,
  193. CODEC_ID_CMV,
  194. CODEC_ID_MOTIONPIXELS,
  195. CODEC_ID_TGV,
  196. CODEC_ID_TGQ,
  197. CODEC_ID_TQI,
  198. CODEC_ID_AURA,
  199. CODEC_ID_AURA2,
  200. CODEC_ID_V210X,
  201. CODEC_ID_TMV,
  202. CODEC_ID_V210,
  203. CODEC_ID_DPX,
  204. CODEC_ID_MAD,
  205. CODEC_ID_FRWU,
  206. CODEC_ID_FLASHSV2,
  207. CODEC_ID_CDGRAPHICS,
  208. CODEC_ID_R210,
  209. CODEC_ID_ANM,
  210. CODEC_ID_BINKVIDEO,
  211. CODEC_ID_IFF_ILBM,
  212. CODEC_ID_IFF_BYTERUN1,
  213. CODEC_ID_KGV1,
  214. CODEC_ID_YOP,
  215. CODEC_ID_VP8,
  216. CODEC_ID_PICTOR,
  217. CODEC_ID_ANSI,
  218. CODEC_ID_A64_MULTI,
  219. CODEC_ID_A64_MULTI5,
  220. CODEC_ID_R10K,
  221. /* various PCM "codecs" */
  222. CODEC_ID_PCM_S16LE= 0x10000,
  223. CODEC_ID_PCM_S16BE,
  224. CODEC_ID_PCM_U16LE,
  225. CODEC_ID_PCM_U16BE,
  226. CODEC_ID_PCM_S8,
  227. CODEC_ID_PCM_U8,
  228. CODEC_ID_PCM_MULAW,
  229. CODEC_ID_PCM_ALAW,
  230. CODEC_ID_PCM_S32LE,
  231. CODEC_ID_PCM_S32BE,
  232. CODEC_ID_PCM_U32LE,
  233. CODEC_ID_PCM_U32BE,
  234. CODEC_ID_PCM_S24LE,
  235. CODEC_ID_PCM_S24BE,
  236. CODEC_ID_PCM_U24LE,
  237. CODEC_ID_PCM_U24BE,
  238. CODEC_ID_PCM_S24DAUD,
  239. CODEC_ID_PCM_ZORK,
  240. CODEC_ID_PCM_S16LE_PLANAR,
  241. CODEC_ID_PCM_DVD,
  242. CODEC_ID_PCM_F32BE,
  243. CODEC_ID_PCM_F32LE,
  244. CODEC_ID_PCM_F64BE,
  245. CODEC_ID_PCM_F64LE,
  246. CODEC_ID_PCM_BLURAY,
  247. /* various ADPCM codecs */
  248. CODEC_ID_ADPCM_IMA_QT= 0x11000,
  249. CODEC_ID_ADPCM_IMA_WAV,
  250. CODEC_ID_ADPCM_IMA_DK3,
  251. CODEC_ID_ADPCM_IMA_DK4,
  252. CODEC_ID_ADPCM_IMA_WS,
  253. CODEC_ID_ADPCM_IMA_SMJPEG,
  254. CODEC_ID_ADPCM_MS,
  255. CODEC_ID_ADPCM_4XM,
  256. CODEC_ID_ADPCM_XA,
  257. CODEC_ID_ADPCM_ADX,
  258. CODEC_ID_ADPCM_EA,
  259. CODEC_ID_ADPCM_G726,
  260. CODEC_ID_ADPCM_CT,
  261. CODEC_ID_ADPCM_SWF,
  262. CODEC_ID_ADPCM_YAMAHA,
  263. CODEC_ID_ADPCM_SBPRO_4,
  264. CODEC_ID_ADPCM_SBPRO_3,
  265. CODEC_ID_ADPCM_SBPRO_2,
  266. CODEC_ID_ADPCM_THP,
  267. CODEC_ID_ADPCM_IMA_AMV,
  268. CODEC_ID_ADPCM_EA_R1,
  269. CODEC_ID_ADPCM_EA_R3,
  270. CODEC_ID_ADPCM_EA_R2,
  271. CODEC_ID_ADPCM_IMA_EA_SEAD,
  272. CODEC_ID_ADPCM_IMA_EA_EACS,
  273. CODEC_ID_ADPCM_EA_XAS,
  274. CODEC_ID_ADPCM_EA_MAXIS_XA,
  275. CODEC_ID_ADPCM_IMA_ISS,
  276. CODEC_ID_ADPCM_G722,
  277. /* AMR */
  278. CODEC_ID_AMR_NB= 0x12000,
  279. CODEC_ID_AMR_WB,
  280. /* RealAudio codecs*/
  281. CODEC_ID_RA_144= 0x13000,
  282. CODEC_ID_RA_288,
  283. /* various DPCM codecs */
  284. CODEC_ID_ROQ_DPCM= 0x14000,
  285. CODEC_ID_INTERPLAY_DPCM,
  286. CODEC_ID_XAN_DPCM,
  287. CODEC_ID_SOL_DPCM,
  288. /* audio codecs */
  289. CODEC_ID_MP2= 0x15000,
  290. CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3
  291. CODEC_ID_AAC,
  292. CODEC_ID_AC3,
  293. CODEC_ID_DTS,
  294. CODEC_ID_VORBIS,
  295. CODEC_ID_DVAUDIO,
  296. CODEC_ID_WMAV1,
  297. CODEC_ID_WMAV2,
  298. CODEC_ID_MACE3,
  299. CODEC_ID_MACE6,
  300. CODEC_ID_VMDAUDIO,
  301. CODEC_ID_SONIC,
  302. CODEC_ID_SONIC_LS,
  303. CODEC_ID_FLAC,
  304. CODEC_ID_MP3ADU,
  305. CODEC_ID_MP3ON4,
  306. CODEC_ID_SHORTEN,
  307. CODEC_ID_ALAC,
  308. CODEC_ID_WESTWOOD_SND1,
  309. CODEC_ID_GSM, ///< as in Berlin toast format
  310. CODEC_ID_QDM2,
  311. CODEC_ID_COOK,
  312. CODEC_ID_TRUESPEECH,
  313. CODEC_ID_TTA,
  314. CODEC_ID_SMACKAUDIO,
  315. CODEC_ID_QCELP,
  316. CODEC_ID_WAVPACK,
  317. CODEC_ID_DSICINAUDIO,
  318. CODEC_ID_IMC,
  319. CODEC_ID_MUSEPACK7,
  320. CODEC_ID_MLP,
  321. CODEC_ID_GSM_MS, /* as found in WAV */
  322. CODEC_ID_ATRAC3,
  323. CODEC_ID_VOXWARE,
  324. CODEC_ID_APE,
  325. CODEC_ID_NELLYMOSER,
  326. CODEC_ID_MUSEPACK8,
  327. CODEC_ID_SPEEX,
  328. CODEC_ID_WMAVOICE,
  329. CODEC_ID_WMAPRO,
  330. CODEC_ID_WMALOSSLESS,
  331. CODEC_ID_ATRAC3P,
  332. CODEC_ID_EAC3,
  333. CODEC_ID_SIPR,
  334. CODEC_ID_MP1,
  335. CODEC_ID_TWINVQ,
  336. CODEC_ID_TRUEHD,
  337. CODEC_ID_MP4ALS,
  338. CODEC_ID_ATRAC1,
  339. CODEC_ID_BINKAUDIO_RDFT,
  340. CODEC_ID_BINKAUDIO_DCT,
  341. /* subtitle codecs */
  342. CODEC_ID_DVD_SUBTITLE= 0x17000,
  343. CODEC_ID_DVB_SUBTITLE,
  344. CODEC_ID_TEXT, ///< raw UTF-8 text
  345. CODEC_ID_XSUB,
  346. CODEC_ID_SSA,
  347. CODEC_ID_MOV_TEXT,
  348. CODEC_ID_HDMV_PGS_SUBTITLE,
  349. CODEC_ID_DVB_TELETEXT,
  350. CODEC_ID_SRT,
  351. /* other specific kind of codecs (generally used for attachments) */
  352. CODEC_ID_TTF= 0x18000,
  353. CODEC_ID_PROBE= 0x19000, ///< codec_id is not known (like CODEC_ID_NONE) but lavf should attempt to identify it
  354. CODEC_ID_MPEG2TS= 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS
  355. * stream (only used by libavformat) */
  356. };
  357. #if LIBAVCODEC_VERSION_MAJOR < 53
  358. #define CodecType AVMediaType
  359. #define CODEC_TYPE_UNKNOWN AVMEDIA_TYPE_UNKNOWN
  360. #define CODEC_TYPE_VIDEO AVMEDIA_TYPE_VIDEO
  361. #define CODEC_TYPE_AUDIO AVMEDIA_TYPE_AUDIO
  362. #define CODEC_TYPE_DATA AVMEDIA_TYPE_DATA
  363. #define CODEC_TYPE_SUBTITLE AVMEDIA_TYPE_SUBTITLE
  364. #define CODEC_TYPE_ATTACHMENT AVMEDIA_TYPE_ATTACHMENT
  365. #define CODEC_TYPE_NB AVMEDIA_TYPE_NB
  366. #endif
  367. /**
  368. * all in native-endian format
  369. */
  370. enum SampleFormat {
  371. SAMPLE_FMT_NONE = -1,
  372. SAMPLE_FMT_U8, ///< unsigned 8 bits
  373. SAMPLE_FMT_S16, ///< signed 16 bits
  374. SAMPLE_FMT_S32, ///< signed 32 bits
  375. SAMPLE_FMT_FLT, ///< float
  376. SAMPLE_FMT_DBL, ///< double
  377. SAMPLE_FMT_NB ///< Number of sample formats. DO NOT USE if dynamically linking to libavcodec
  378. };
  379. /* Audio channel masks */
  380. #define CH_FRONT_LEFT 0x00000001
  381. #define CH_FRONT_RIGHT 0x00000002
  382. #define CH_FRONT_CENTER 0x00000004
  383. #define CH_LOW_FREQUENCY 0x00000008
  384. #define CH_BACK_LEFT 0x00000010
  385. #define CH_BACK_RIGHT 0x00000020
  386. #define CH_FRONT_LEFT_OF_CENTER 0x00000040
  387. #define CH_FRONT_RIGHT_OF_CENTER 0x00000080
  388. #define CH_BACK_CENTER 0x00000100
  389. #define CH_SIDE_LEFT 0x00000200
  390. #define CH_SIDE_RIGHT 0x00000400
  391. #define CH_TOP_CENTER 0x00000800
  392. #define CH_TOP_FRONT_LEFT 0x00001000
  393. #define CH_TOP_FRONT_CENTER 0x00002000
  394. #define CH_TOP_FRONT_RIGHT 0x00004000
  395. #define CH_TOP_BACK_LEFT 0x00008000
  396. #define CH_TOP_BACK_CENTER 0x00010000
  397. #define CH_TOP_BACK_RIGHT 0x00020000
  398. #define CH_STEREO_LEFT 0x20000000 ///< Stereo downmix.
  399. #define CH_STEREO_RIGHT 0x40000000 ///< See CH_STEREO_LEFT.
  400. /** Channel mask value used for AVCodecContext.request_channel_layout
  401. to indicate that the user requests the channel order of the decoder output
  402. to be the native codec channel order. */
  403. #define CH_LAYOUT_NATIVE 0x8000000000000000LL
  404. /* Audio channel convenience macros */
  405. #define CH_LAYOUT_MONO (CH_FRONT_CENTER)
  406. #define CH_LAYOUT_STEREO (CH_FRONT_LEFT|CH_FRONT_RIGHT)
  407. #define CH_LAYOUT_2_1 (CH_LAYOUT_STEREO|CH_BACK_CENTER)
  408. #define CH_LAYOUT_SURROUND (CH_LAYOUT_STEREO|CH_FRONT_CENTER)
  409. #define CH_LAYOUT_4POINT0 (CH_LAYOUT_SURROUND|CH_BACK_CENTER)
  410. #define CH_LAYOUT_2_2 (CH_LAYOUT_STEREO|CH_SIDE_LEFT|CH_SIDE_RIGHT)
  411. #define CH_LAYOUT_QUAD (CH_LAYOUT_STEREO|CH_BACK_LEFT|CH_BACK_RIGHT)
  412. #define CH_LAYOUT_5POINT0 (CH_LAYOUT_SURROUND|CH_SIDE_LEFT|CH_SIDE_RIGHT)
  413. #define CH_LAYOUT_5POINT1 (CH_LAYOUT_5POINT0|CH_LOW_FREQUENCY)
  414. #define CH_LAYOUT_5POINT0_BACK (CH_LAYOUT_SURROUND|CH_BACK_LEFT|CH_BACK_RIGHT)
  415. #define CH_LAYOUT_5POINT1_BACK (CH_LAYOUT_5POINT0_BACK|CH_LOW_FREQUENCY)
  416. #define CH_LAYOUT_7POINT0 (CH_LAYOUT_5POINT0|CH_BACK_LEFT|CH_BACK_RIGHT)
  417. #define CH_LAYOUT_7POINT1 (CH_LAYOUT_5POINT1|CH_BACK_LEFT|CH_BACK_RIGHT)
  418. #define CH_LAYOUT_7POINT1_WIDE (CH_LAYOUT_5POINT1_BACK|\
  419. CH_FRONT_LEFT_OF_CENTER|CH_FRONT_RIGHT_OF_CENTER)
  420. #define CH_LAYOUT_STEREO_DOWNMIX (CH_STEREO_LEFT|CH_STEREO_RIGHT)
  421. /* in bytes */
  422. #define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
  423. /**
  424. * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
  425. * This is mainly needed because some optimized bitstream readers read
  426. * 32 or 64 bit at once and could read over the end.<br>
  427. * Note: If the first 23 bits of the additional bytes are not 0, then damaged
  428. * MPEG bitstreams could cause overread and segfault.
  429. */
  430. #define FF_INPUT_BUFFER_PADDING_SIZE 8
  431. /**
  432. * minimum encoding buffer size
  433. * Used to avoid some checks during header writing.
  434. */
  435. #define FF_MIN_BUFFER_SIZE 16384
  436. /**
  437. * motion estimation type.
  438. */
  439. enum Motion_Est_ID {
  440. ME_ZERO = 1, ///< no search, that is use 0,0 vector whenever one is needed
  441. ME_FULL,
  442. ME_LOG,
  443. ME_PHODS,
  444. ME_EPZS, ///< enhanced predictive zonal search
  445. ME_X1, ///< reserved for experiments
  446. ME_HEX, ///< hexagon based search
  447. ME_UMH, ///< uneven multi-hexagon search
  448. ME_ITER, ///< iterative search
  449. ME_TESA, ///< transformed exhaustive search algorithm
  450. };
  451. enum AVDiscard{
  452. /* We leave some space between them for extensions (drop some
  453. * keyframes for intra-only or drop just some bidir frames). */
  454. AVDISCARD_NONE =-16, ///< discard nothing
  455. AVDISCARD_DEFAULT= 0, ///< discard useless packets like 0 size packets in avi
  456. AVDISCARD_NONREF = 8, ///< discard all non reference
  457. AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames
  458. AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes
  459. AVDISCARD_ALL = 48, ///< discard all
  460. };
  461. enum AVColorPrimaries{
  462. AVCOL_PRI_BT709 =1, ///< also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B
  463. AVCOL_PRI_UNSPECIFIED=2,
  464. AVCOL_PRI_BT470M =4,
  465. AVCOL_PRI_BT470BG =5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
  466. AVCOL_PRI_SMPTE170M =6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
  467. AVCOL_PRI_SMPTE240M =7, ///< functionally identical to above
  468. AVCOL_PRI_FILM =8,
  469. AVCOL_PRI_NB , ///< Not part of ABI
  470. };
  471. enum AVColorTransferCharacteristic{
  472. AVCOL_TRC_BT709 =1, ///< also ITU-R BT1361
  473. AVCOL_TRC_UNSPECIFIED=2,
  474. AVCOL_TRC_GAMMA22 =4, ///< also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
  475. AVCOL_TRC_GAMMA28 =5, ///< also ITU-R BT470BG
  476. AVCOL_TRC_NB , ///< Not part of ABI
  477. };
  478. enum AVColorSpace{
  479. AVCOL_SPC_RGB =0,
  480. AVCOL_SPC_BT709 =1, ///< also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
  481. AVCOL_SPC_UNSPECIFIED=2,
  482. AVCOL_SPC_FCC =4,
  483. AVCOL_SPC_BT470BG =5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
  484. AVCOL_SPC_SMPTE170M =6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
  485. AVCOL_SPC_SMPTE240M =7,
  486. AVCOL_SPC_NB , ///< Not part of ABI
  487. };
  488. enum AVColorRange{
  489. AVCOL_RANGE_UNSPECIFIED=0,
  490. AVCOL_RANGE_MPEG =1, ///< the normal 219*2^(n-8) "MPEG" YUV ranges
  491. AVCOL_RANGE_JPEG =2, ///< the normal 2^n-1 "JPEG" YUV ranges
  492. AVCOL_RANGE_NB , ///< Not part of ABI
  493. };
  494. /**
  495. * X X 3 4 X X are luma samples,
  496. * 1 2 1-6 are possible chroma positions
  497. * X X 5 6 X 0 is undefined/unknown position
  498. */
  499. enum AVChromaLocation{
  500. AVCHROMA_LOC_UNSPECIFIED=0,
  501. AVCHROMA_LOC_LEFT =1, ///< mpeg2/4, h264 default
  502. AVCHROMA_LOC_CENTER =2, ///< mpeg1, jpeg, h263
  503. AVCHROMA_LOC_TOPLEFT =3, ///< DV
  504. AVCHROMA_LOC_TOP =4,
  505. AVCHROMA_LOC_BOTTOMLEFT =5,
  506. AVCHROMA_LOC_BOTTOM =6,
  507. AVCHROMA_LOC_NB , ///< Not part of ABI
  508. };
  509. /**
  510. * LPC analysis type
  511. */
  512. enum AVLPCType {
  513. AV_LPC_TYPE_DEFAULT = -1, ///< use the codec default LPC type
  514. AV_LPC_TYPE_NONE = 0, ///< do not use LPC prediction or use all zero coefficients
  515. AV_LPC_TYPE_FIXED = 1, ///< fixed LPC coefficients
  516. AV_LPC_TYPE_LEVINSON = 2, ///< Levinson-Durbin recursion
  517. AV_LPC_TYPE_CHOLESKY = 3, ///< Cholesky factorization
  518. AV_LPC_TYPE_NB , ///< Not part of ABI
  519. };
  520. typedef struct RcOverride{
  521. int start_frame;
  522. int end_frame;
  523. int qscale; // If this is 0 then quality_factor will be used instead.
  524. float quality_factor;
  525. } RcOverride;
  526. #define FF_MAX_B_FRAMES 16
  527. /* encoding support
  528. These flags can be passed in AVCodecContext.flags before initialization.
  529. Note: Not everything is supported yet.
  530. */
  531. #define CODEC_FLAG_QSCALE 0x0002 ///< Use fixed qscale.
  532. #define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed / advanced prediction for H.263.
  533. #define CODEC_FLAG_QPEL 0x0010 ///< Use qpel MC.
  534. #define CODEC_FLAG_GMC 0x0020 ///< Use GMC.
  535. #define CODEC_FLAG_MV0 0x0040 ///< Always try a MB with MV=<0,0>.
  536. #define CODEC_FLAG_PART 0x0080 ///< Use data partitioning.
  537. /**
  538. * The parent program guarantees that the input for B-frames containing
  539. * streams is not written to for at least s->max_b_frames+1 frames, if
  540. * this is not set the input will be copied.
  541. */
  542. #define CODEC_FLAG_INPUT_PRESERVED 0x0100
  543. #define CODEC_FLAG_PASS1 0x0200 ///< Use internal 2pass ratecontrol in first pass mode.
  544. #define CODEC_FLAG_PASS2 0x0400 ///< Use internal 2pass ratecontrol in second pass mode.
  545. #define CODEC_FLAG_EXTERN_HUFF 0x1000 ///< Use external Huffman table (for MJPEG).
  546. #define CODEC_FLAG_GRAY 0x2000 ///< Only decode/encode grayscale.
  547. #define CODEC_FLAG_EMU_EDGE 0x4000 ///< Don't draw edges.
  548. #define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding.
  549. #define CODEC_FLAG_TRUNCATED 0x00010000 /** Input bitstream might be truncated at a random
  550. location instead of only at frame boundaries. */
  551. #define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< Normalize adaptive quantization.
  552. #define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< Use interlaced DCT.
  553. #define CODEC_FLAG_LOW_DELAY 0x00080000 ///< Force low delay.
  554. #define CODEC_FLAG_ALT_SCAN 0x00100000 ///< Use alternate scan.
  555. #define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< Place global headers in extradata instead of every keyframe.
  556. #define CODEC_FLAG_BITEXACT 0x00800000 ///< Use only bitexact stuff (except (I)DCT).
  557. /* Fx : Flag for h263+ extra options */
  558. #define CODEC_FLAG_AC_PRED 0x01000000 ///< H.263 advanced intra coding / MPEG-4 AC prediction
  559. #define CODEC_FLAG_H263P_UMV 0x02000000 ///< unlimited motion vector
  560. #define CODEC_FLAG_CBP_RD 0x04000000 ///< Use rate distortion optimization for cbp.
  561. #define CODEC_FLAG_QP_RD 0x08000000 ///< Use rate distortion optimization for qp selectioon.
  562. #define CODEC_FLAG_H263P_AIV 0x00000008 ///< H.263 alternative inter VLC
  563. #define CODEC_FLAG_OBMC 0x00000001 ///< OBMC
  564. #define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter
  565. #define CODEC_FLAG_H263P_SLICE_STRUCT 0x10000000
  566. #define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation
  567. #define CODEC_FLAG_SVCD_SCAN_OFFSET 0x40000000 ///< Will reserve space for SVCD scan offset user data.
  568. #define CODEC_FLAG_CLOSED_GOP 0x80000000
  569. #define CODEC_FLAG2_FAST 0x00000001 ///< Allow non spec compliant speedup tricks.
  570. #define CODEC_FLAG2_STRICT_GOP 0x00000002 ///< Strictly enforce GOP size.
  571. #define CODEC_FLAG2_NO_OUTPUT 0x00000004 ///< Skip bitstream encoding.
  572. #define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< Place global headers at every keyframe instead of in extradata.
  573. #define CODEC_FLAG2_BPYRAMID 0x00000010 ///< H.264 allow B-frames to be used as references.
  574. #define CODEC_FLAG2_WPRED 0x00000020 ///< H.264 weighted biprediction for B-frames
  575. #define CODEC_FLAG2_MIXED_REFS 0x00000040 ///< H.264 one reference per partition, as opposed to one reference per macroblock
  576. #define CODEC_FLAG2_8X8DCT 0x00000080 ///< H.264 high profile 8x8 transform
  577. #define CODEC_FLAG2_FASTPSKIP 0x00000100 ///< H.264 fast pskip
  578. #define CODEC_FLAG2_AUD 0x00000200 ///< H.264 access unit delimiters
  579. #define CODEC_FLAG2_BRDO 0x00000400 ///< B-frame rate-distortion optimization
  580. #define CODEC_FLAG2_INTRA_VLC 0x00000800 ///< Use MPEG-2 intra VLC table.
  581. #define CODEC_FLAG2_MEMC_ONLY 0x00001000 ///< Only do ME/MC (I frames -> ref, P frame -> ME+MC).
  582. #define CODEC_FLAG2_DROP_FRAME_TIMECODE 0x00002000 ///< timecode is in drop frame format.
  583. #define CODEC_FLAG2_SKIP_RD 0x00004000 ///< RD optimal MB level residual skipping
  584. #define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries.
  585. #define CODEC_FLAG2_NON_LINEAR_QUANT 0x00010000 ///< Use MPEG-2 nonlinear quantizer.
  586. #define CODEC_FLAG2_BIT_RESERVOIR 0x00020000 ///< Use a bit reservoir when encoding if possible
  587. #define CODEC_FLAG2_MBTREE 0x00040000 ///< Use macroblock tree ratecontrol (x264 only)
  588. #define CODEC_FLAG2_PSY 0x00080000 ///< Use psycho visual optimizations.
  589. #define CODEC_FLAG2_SSIM 0x00100000 ///< Compute SSIM during encoding, error[] values are undefined.
  590. #define CODEC_FLAG2_INTRA_REFRESH 0x00200000 ///< Use periodic insertion of intra blocks instead of keyframes.
  591. /* Unsupported options :
  592. * Syntax Arithmetic coding (SAC)
  593. * Reference Picture Selection
  594. * Independent Segment Decoding */
  595. /* /Fx */
  596. /* codec capabilities */
  597. #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< Decoder can use draw_horiz_band callback.
  598. /**
  599. * Codec uses get_buffer() for allocating buffers and supports custom allocators.
  600. * If not set, it might not use get_buffer() at all or use operations that
  601. * assume the buffer was allocated by avcodec_default_get_buffer.
  602. */
  603. #define CODEC_CAP_DR1 0x0002
  604. /* If 'parse_only' field is true, then avcodec_parse_frame() can be used. */
  605. #define CODEC_CAP_PARSE_ONLY 0x0004
  606. #define CODEC_CAP_TRUNCATED 0x0008
  607. /* Codec can export data for HW decoding (XvMC). */
  608. #define CODEC_CAP_HWACCEL 0x0010
  609. /**
  610. * Codec has a nonzero delay and needs to be fed with NULL at the end to get the delayed data.
  611. * If this is not set, the codec is guaranteed to never be fed with NULL data.
  612. */
  613. #define CODEC_CAP_DELAY 0x0020
  614. /**
  615. * Codec can be fed a final frame with a smaller size.
  616. * This can be used to prevent truncation of the last audio samples.
  617. */
  618. #define CODEC_CAP_SMALL_LAST_FRAME 0x0040
  619. /**
  620. * Codec can export data for HW decoding (VDPAU).
  621. */
  622. #define CODEC_CAP_HWACCEL_VDPAU 0x0080
  623. /**
  624. * Codec can output multiple frames per AVPacket
  625. * Normally demuxers return one frame at a time, demuxers which do not do
  626. * are connected to a parser to split what they return into proper frames.
  627. * This flag is reserved to the very rare category of codecs which have a
  628. * bitstream that cannot be split into frames without timeconsuming
  629. * operations like full decoding. Demuxers carring such bitstreams thus
  630. * may return multiple frames in a packet. This has many disadvantages like
  631. * prohibiting stream copy in many cases thus it should only be considered
  632. * as a last resort.
  633. */
  634. #define CODEC_CAP_SUBFRAMES 0x0100
  635. /**
  636. * Codec is experimental and is thus avoided in favor of non experimental
  637. * encoders
  638. */
  639. #define CODEC_CAP_EXPERIMENTAL 0x0200
  640. //The following defines may change, don't expect compatibility if you use them.
  641. #define MB_TYPE_INTRA4x4 0x0001
  642. #define MB_TYPE_INTRA16x16 0x0002 //FIXME H.264-specific
  643. #define MB_TYPE_INTRA_PCM 0x0004 //FIXME H.264-specific
  644. #define MB_TYPE_16x16 0x0008
  645. #define MB_TYPE_16x8 0x0010
  646. #define MB_TYPE_8x16 0x0020
  647. #define MB_TYPE_8x8 0x0040
  648. #define MB_TYPE_INTERLACED 0x0080
  649. #define MB_TYPE_DIRECT2 0x0100 //FIXME
  650. #define MB_TYPE_ACPRED 0x0200
  651. #define MB_TYPE_GMC 0x0400
  652. #define MB_TYPE_SKIP 0x0800
  653. #define MB_TYPE_P0L0 0x1000
  654. #define MB_TYPE_P1L0 0x2000
  655. #define MB_TYPE_P0L1 0x4000
  656. #define MB_TYPE_P1L1 0x8000
  657. #define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0)
  658. #define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1)
  659. #define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1)
  660. #define MB_TYPE_QUANT 0x00010000
  661. #define MB_TYPE_CBP 0x00020000
  662. //Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...)
  663. /**
  664. * Pan Scan area.
  665. * This specifies the area which should be displayed.
  666. * Note there may be multiple such areas for one frame.
  667. */
  668. typedef struct AVPanScan{
  669. /**
  670. * id
  671. * - encoding: Set by user.
  672. * - decoding: Set by libavcodec.
  673. */
  674. int id;
  675. /**
  676. * width and height in 1/16 pel
  677. * - encoding: Set by user.
  678. * - decoding: Set by libavcodec.
  679. */
  680. int width;
  681. int height;
  682. /**
  683. * position of the top left corner in 1/16 pel for up to 3 fields/frames
  684. * - encoding: Set by user.
  685. * - decoding: Set by libavcodec.
  686. */
  687. int16_t position[3][2];
  688. }AVPanScan;
  689. #define FF_COMMON_FRAME \
  690. /**\
  691. * pointer to the picture planes.\
  692. * This might be different from the first allocated byte\
  693. * - encoding: \
  694. * - decoding: \
  695. */\
  696. uint8_t *data[4];\
  697. int linesize[4];\
  698. /**\
  699. * pointer to the first allocated byte of the picture. Can be used in get_buffer/release_buffer.\
  700. * This isn't used by libavcodec unless the default get/release_buffer() is used.\
  701. * - encoding: \
  702. * - decoding: \
  703. */\
  704. uint8_t *base[4];\
  705. /**\
  706. * 1 -> keyframe, 0-> not\
  707. * - encoding: Set by libavcodec.\
  708. * - decoding: Set by libavcodec.\
  709. */\
  710. int key_frame;\
  711. \
  712. /**\
  713. * Picture type of the frame, see ?_TYPE below.\
  714. * - encoding: Set by libavcodec. for coded_picture (and set by user for input).\
  715. * - decoding: Set by libavcodec.\
  716. */\
  717. int pict_type;\
  718. \
  719. /**\
  720. * presentation timestamp in time_base units (time when frame should be shown to user)\
  721. * If AV_NOPTS_VALUE then frame_rate = 1/time_base will be assumed.\
  722. * - encoding: MUST be set by user.\
  723. * - decoding: Set by libavcodec.\
  724. */\
  725. int64_t pts;\
  726. \
  727. /**\
  728. * picture number in bitstream order\
  729. * - encoding: set by\
  730. * - decoding: Set by libavcodec.\
  731. */\
  732. int coded_picture_number;\
  733. /**\
  734. * picture number in display order\
  735. * - encoding: set by\
  736. * - decoding: Set by libavcodec.\
  737. */\
  738. int display_picture_number;\
  739. \
  740. /**\
  741. * quality (between 1 (good) and FF_LAMBDA_MAX (bad)) \
  742. * - encoding: Set by libavcodec. for coded_picture (and set by user for input).\
  743. * - decoding: Set by libavcodec.\
  744. */\
  745. int quality; \
  746. \
  747. /**\
  748. * buffer age (1->was last buffer and dint change, 2->..., ...).\
  749. * Set to INT_MAX if the buffer has not been used yet.\
  750. * - encoding: unused\
  751. * - decoding: MUST be set by get_buffer().\
  752. */\
  753. int age;\
  754. \
  755. /**\
  756. * is this picture used as reference\
  757. * The values for this are the same as the MpegEncContext.picture_structure\
  758. * variable, that is 1->top field, 2->bottom field, 3->frame/both fields.\
  759. * Set to 4 for delayed, non-reference frames.\
  760. * - encoding: unused\
  761. * - decoding: Set by libavcodec. (before get_buffer() call)).\
  762. */\
  763. int reference;\
  764. \
  765. /**\
  766. * QP table\
  767. * - encoding: unused\
  768. * - decoding: Set by libavcodec.\
  769. */\
  770. int8_t *qscale_table;\
  771. /**\
  772. * QP store stride\
  773. * - encoding: unused\
  774. * - decoding: Set by libavcodec.\
  775. */\
  776. int qstride;\
  777. \
  778. /**\
  779. * mbskip_table[mb]>=1 if MB didn't change\
  780. * stride= mb_width = (width+15)>>4\
  781. * - encoding: unused\
  782. * - decoding: Set by libavcodec.\
  783. */\
  784. uint8_t *mbskip_table;\
  785. \
  786. /**\
  787. * motion vector table\
  788. * @code\
  789. * example:\
  790. * int mv_sample_log2= 4 - motion_subsample_log2;\
  791. * int mb_width= (width+15)>>4;\
  792. * int mv_stride= (mb_width << mv_sample_log2) + 1;\
  793. * motion_val[direction][x + y*mv_stride][0->mv_x, 1->mv_y];\
  794. * @endcode\
  795. * - encoding: Set by user.\
  796. * - decoding: Set by libavcodec.\
  797. */\
  798. int16_t (*motion_val[2])[2];\
  799. \
  800. /**\
  801. * macroblock type table\
  802. * mb_type_base + mb_width + 2\
  803. * - encoding: Set by user.\
  804. * - decoding: Set by libavcodec.\
  805. */\
  806. uint32_t *mb_type;\
  807. \
  808. /**\
  809. * log2 of the size of the block which a single vector in motion_val represents: \
  810. * (4->16x16, 3->8x8, 2-> 4x4, 1-> 2x2)\
  811. * - encoding: unused\
  812. * - decoding: Set by libavcodec.\
  813. */\
  814. uint8_t motion_subsample_log2;\
  815. \
  816. /**\
  817. * for some private data of the user\
  818. * - encoding: unused\
  819. * - decoding: Set by user.\
  820. */\
  821. void *opaque;\
  822. \
  823. /**\
  824. * error\
  825. * - encoding: Set by libavcodec. if flags&CODEC_FLAG_PSNR.\
  826. * - decoding: unused\
  827. */\
  828. uint64_t error[4];\
  829. \
  830. /**\
  831. * type of the buffer (to keep track of who has to deallocate data[*])\
  832. * - encoding: Set by the one who allocates it.\
  833. * - decoding: Set by the one who allocates it.\
  834. * Note: User allocated (direct rendering) & internal buffers cannot coexist currently.\
  835. */\
  836. int type;\
  837. \
  838. /**\
  839. * When decoding, this signals how much the picture must be delayed.\
  840. * extra_delay = repeat_pict / (2*fps)\
  841. * - encoding: unused\
  842. * - decoding: Set by libavcodec.\
  843. */\
  844. int repeat_pict;\
  845. \
  846. /**\
  847. * \
  848. */\
  849. int qscale_type;\
  850. \
  851. /**\
  852. * The content of the picture is interlaced.\
  853. * - encoding: Set by user.\
  854. * - decoding: Set by libavcodec. (default 0)\
  855. */\
  856. int interlaced_frame;\
  857. \
  858. /**\
  859. * If the content is interlaced, is top field displayed first.\
  860. * - encoding: Set by user.\
  861. * - decoding: Set by libavcodec.\
  862. */\
  863. int top_field_first;\
  864. \
  865. /**\
  866. * Pan scan.\
  867. * - encoding: Set by user.\
  868. * - decoding: Set by libavcodec.\
  869. */\
  870. AVPanScan *pan_scan;\
  871. \
  872. /**\
  873. * Tell user application that palette has changed from previous frame.\
  874. * - encoding: ??? (no palette-enabled encoder yet)\
  875. * - decoding: Set by libavcodec. (default 0).\
  876. */\
  877. int palette_has_changed;\
  878. \
  879. /**\
  880. * codec suggestion on buffer type if != 0\
  881. * - encoding: unused\
  882. * - decoding: Set by libavcodec. (before get_buffer() call)).\
  883. */\
  884. int buffer_hints;\
  885. \
  886. /**\
  887. * DCT coefficients\
  888. * - encoding: unused\
  889. * - decoding: Set by libavcodec.\
  890. */\
  891. short *dct_coeff;\
  892. \
  893. /**\
  894. * motion reference frame index\
  895. * the order in which these are stored can depend on the codec.\
  896. * - encoding: Set by user.\
  897. * - decoding: Set by libavcodec.\
  898. */\
  899. int8_t *ref_index[2];\
  900. \
  901. /**\
  902. * reordered opaque 64bit number (generally a PTS) from AVCodecContext.reordered_opaque\
  903. * output in AVFrame.reordered_opaque\
  904. * - encoding: unused\
  905. * - decoding: Read by user.\
  906. */\
  907. int64_t reordered_opaque;\
  908. \
  909. /**\
  910. * hardware accelerator private data (FFmpeg allocated)\
  911. * - encoding: unused\
  912. * - decoding: Set by libavcodec\
  913. */\
  914. void *hwaccel_picture_private;\
  915. #define FF_QSCALE_TYPE_MPEG1 0
  916. #define FF_QSCALE_TYPE_MPEG2 1
  917. #define FF_QSCALE_TYPE_H264 2
  918. #define FF_QSCALE_TYPE_VP56 3
  919. #define FF_BUFFER_TYPE_INTERNAL 1
  920. #define FF_BUFFER_TYPE_USER 2 ///< direct rendering buffers (image is (de)allocated by user)
  921. #define FF_BUFFER_TYPE_SHARED 4 ///< Buffer from somewhere else; don't deallocate image (data/base), all other tables are not shared.
  922. #define FF_BUFFER_TYPE_COPY 8 ///< Just a (modified) copy of some other buffer, don't deallocate anything.
  923. #define FF_I_TYPE 1 ///< Intra
  924. #define FF_P_TYPE 2 ///< Predicted
  925. #define FF_B_TYPE 3 ///< Bi-dir predicted
  926. #define FF_S_TYPE 4 ///< S(GMC)-VOP MPEG4
  927. #define FF_SI_TYPE 5 ///< Switching Intra
  928. #define FF_SP_TYPE 6 ///< Switching Predicted
  929. #define FF_BI_TYPE 7
  930. #define FF_BUFFER_HINTS_VALID 0x01 // Buffer hints value is meaningful (if 0 ignore).
  931. #define FF_BUFFER_HINTS_READABLE 0x02 // Codec will read from buffer.
  932. #define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content.
  933. #define FF_BUFFER_HINTS_REUSABLE 0x08 // Codec will reuse the buffer (update).
  934. typedef struct AVPacket {
  935. /**
  936. * Presentation timestamp in AVStream->time_base units; the time at which
  937. * the decompressed packet will be presented to the user.
  938. * Can be AV_NOPTS_VALUE if it is not stored in the file.
  939. * pts MUST be larger or equal to dts as presentation cannot happen before
  940. * decompression, unless one wants to view hex dumps. Some formats misuse
  941. * the terms dts and pts/cts to mean something different. Such timestamps
  942. * must be converted to true pts/dts before they are stored in AVPacket.
  943. */
  944. int64_t pts;
  945. /**
  946. * Decompression timestamp in AVStream->time_base units; the time at which
  947. * the packet is decompressed.
  948. * Can be AV_NOPTS_VALUE if it is not stored in the file.
  949. */
  950. int64_t dts;
  951. uint8_t *data;
  952. int size;
  953. int stream_index;
  954. int flags;
  955. /**
  956. * Duration of this packet in AVStream->time_base units, 0 if unknown.
  957. * Equals next_pts - this_pts in presentation order.
  958. */
  959. int duration;
  960. void (*destruct)(struct AVPacket *);
  961. void *priv;
  962. int64_t pos; ///< byte position in stream, -1 if unknown
  963. /**
  964. * Time difference in AVStream->time_base units from the pts of this
  965. * packet to the point at which the output from the decoder has converged
  966. * independent from the availability of previous frames. That is, the
  967. * frames are virtually identical no matter if decoding started from
  968. * the very first frame or from this keyframe.
  969. * Is AV_NOPTS_VALUE if unknown.
  970. * This field is not the display duration of the current packet.
  971. * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY
  972. * set.
  973. *
  974. * The purpose of this field is to allow seeking in streams that have no
  975. * keyframes in the conventional sense. It corresponds to the
  976. * recovery point SEI in H.264 and match_time_delta in NUT. It is also
  977. * essential for some types of subtitle streams to ensure that all
  978. * subtitles are correctly displayed after seeking.
  979. */
  980. int64_t convergence_duration;
  981. } AVPacket;
  982. #define AV_PKT_FLAG_KEY 0x0001
  983. #if LIBAVCODEC_VERSION_MAJOR < 53
  984. #define PKT_FLAG_KEY AV_PKT_FLAG_KEY
  985. #endif
  986. /**
  987. * Audio Video Frame.
  988. * New fields can be added to the end of FF_COMMON_FRAME with minor version
  989. * bumps.
  990. * Removal, reordering and changes to existing fields require a major
  991. * version bump. No fields should be added into AVFrame before or after
  992. * FF_COMMON_FRAME!
  993. * sizeof(AVFrame) must not be used outside libav*.
  994. */
  995. typedef struct AVFrame {
  996. FF_COMMON_FRAME
  997. } AVFrame;
  998. /**
  999. * main external API structure.
  1000. * New fields can be added to the end with minor version bumps.
  1001. * Removal, reordering and changes to existing fields require a major
  1002. * version bump.
  1003. * sizeof(AVCodecContext) must not be used outside libav*.
  1004. */
  1005. typedef struct AVCodecContext {
  1006. /**
  1007. * information on struct for av_log
  1008. * - set by avcodec_alloc_context
  1009. */
  1010. const AVClass *av_class;
  1011. /**
  1012. * the average bitrate
  1013. * - encoding: Set by user; unused for constant quantizer encoding.
  1014. * - decoding: Set by libavcodec. 0 or some bitrate if this info is available in the stream.
  1015. */
  1016. int bit_rate;
  1017. /**
  1018. * number of bits the bitstream is allowed to diverge from the reference.
  1019. * the reference can be CBR (for CBR pass1) or VBR (for pass2)
  1020. * - encoding: Set by user; unused for constant quantizer encoding.
  1021. * - decoding: unused
  1022. */
  1023. int bit_rate_tolerance;
  1024. /**
  1025. * CODEC_FLAG_*.
  1026. * - encoding: Set by user.
  1027. * - decoding: Set by user.
  1028. */
  1029. int flags;
  1030. /**
  1031. * Some codecs need additional format info. It is stored here.
  1032. * If any muxer uses this then ALL demuxers/parsers AND encoders for the
  1033. * specific codec MUST set it correctly otherwise stream copy breaks.
  1034. * In general use of this field by muxers is not recommanded.
  1035. * - encoding: Set by libavcodec.
  1036. * - decoding: Set by libavcodec. (FIXME: Is this OK?)
  1037. */
  1038. int sub_id;
  1039. /**
  1040. * Motion estimation algorithm used for video coding.
  1041. * 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex),
  1042. * 8 (umh), 9 (iter), 10 (tesa) [7, 8, 10 are x264 specific, 9 is snow specific]
  1043. * - encoding: MUST be set by user.
  1044. * - decoding: unused
  1045. */
  1046. int me_method;
  1047. /**
  1048. * some codecs need / can use extradata like Huffman tables.
  1049. * mjpeg: Huffman tables
  1050. * rv10: additional flags
  1051. * mpeg4: global headers (they can be in the bitstream or here)
  1052. * The allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger
  1053. * than extradata_size to avoid prolems if it is read with the bitstream reader.
  1054. * The bytewise contents of extradata must not depend on the architecture or CPU endianness.
  1055. * - encoding: Set/allocated/freed by libavcodec.
  1056. * - decoding: Set/allocated/freed by user.
  1057. */
  1058. uint8_t *extradata;
  1059. int extradata_size;
  1060. /**
  1061. * This is the fundamental unit of time (in seconds) in terms
  1062. * of which frame timestamps are represented. For fixed-fps content,
  1063. * timebase should be 1/framerate and timestamp increments should be
  1064. * identically 1.
  1065. * - encoding: MUST be set by user.
  1066. * - decoding: Set by libavcodec.
  1067. */
  1068. AVRational time_base;
  1069. /* video only */
  1070. /**
  1071. * picture width / height.
  1072. * - encoding: MUST be set by user.
  1073. * - decoding: Set by libavcodec.
  1074. * Note: For compatibility it is possible to set this instead of
  1075. * coded_width/height before decoding.
  1076. */
  1077. int width, height;
  1078. #define FF_ASPECT_EXTENDED 15
  1079. /**
  1080. * the number of pictures in a group of pictures, or 0 for intra_only
  1081. * - encoding: Set by user.
  1082. * - decoding: unused
  1083. */
  1084. int gop_size;
  1085. /**
  1086. * Pixel format, see PIX_FMT_xxx.
  1087. * May be set by the demuxer if known from headers.
  1088. * May be overriden by the decoder if it knows better.
  1089. * - encoding: Set by user.
  1090. * - decoding: Set by user if known, overridden by libavcodec if known
  1091. */
  1092. enum PixelFormat pix_fmt;
  1093. /**
  1094. * Frame rate emulation. If not zero, the lower layer (i.e. format handler)
  1095. * has to read frames at native frame rate.
  1096. * - encoding: Set by user.
  1097. * - decoding: unused
  1098. */
  1099. int rate_emu;
  1100. /**
  1101. * If non NULL, 'draw_horiz_band' is called by the libavcodec
  1102. * decoder to draw a horizontal band. It improves cache usage. Not
  1103. * all codecs can do that. You must check the codec capabilities
  1104. * beforehand.
  1105. * The function is also used by hardware acceleration APIs.
  1106. * It is called at least once during frame decoding to pass
  1107. * the data needed for hardware render.
  1108. * In that mode instead of pixel data, AVFrame points to
  1109. * a structure specific to the acceleration API. The application
  1110. * reads the structure and can change some fields to indicate progress
  1111. * or mark state.
  1112. * - encoding: unused
  1113. * - decoding: Set by user.
  1114. * @param height the height of the slice
  1115. * @param y the y position of the slice
  1116. * @param type 1->top field, 2->bottom field, 3->frame
  1117. * @param offset offset into the AVFrame.data from which the slice should be read
  1118. */
  1119. void (*draw_horiz_band)(struct AVCodecContext *s,
  1120. const AVFrame *src, int offset[4],
  1121. int y, int type, int height);
  1122. /* audio only */
  1123. int sample_rate; ///< samples per second
  1124. int channels; ///< number of audio channels
  1125. /**
  1126. * audio sample format
  1127. * - encoding: Set by user.
  1128. * - decoding: Set by libavcodec.
  1129. */
  1130. enum SampleFormat sample_fmt; ///< sample format
  1131. /* The following data should not be initialized. */
  1132. /**
  1133. * Samples per packet, initialized when calling 'init'.
  1134. */
  1135. int frame_size;
  1136. int frame_number; ///< audio or video frame number
  1137. #if LIBAVCODEC_VERSION_MAJOR < 53
  1138. int real_pict_num; ///< Returns the real picture number of previous encoded frame.
  1139. #endif
  1140. /**
  1141. * Number of frames the decoded output will be delayed relative to
  1142. * the encoded input.
  1143. * - encoding: Set by libavcodec.
  1144. * - decoding: unused
  1145. */
  1146. int delay;
  1147. /* - encoding parameters */
  1148. float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)
  1149. float qblur; ///< amount of qscale smoothing over time (0.0-1.0)
  1150. /**
  1151. * minimum quantizer
  1152. * - encoding: Set by user.
  1153. * - decoding: unused
  1154. */
  1155. int qmin;
  1156. /**
  1157. * maximum quantizer
  1158. * - encoding: Set by user.
  1159. * - decoding: unused
  1160. */
  1161. int qmax;
  1162. /**
  1163. * maximum quantizer difference between frames
  1164. * - encoding: Set by user.
  1165. * - decoding: unused
  1166. */
  1167. int max_qdiff;
  1168. /**
  1169. * maximum number of B-frames between non-B-frames
  1170. * Note: The output will be delayed by max_b_frames+1 relative to the input.
  1171. * - encoding: Set by user.
  1172. * - decoding: unused
  1173. */
  1174. int max_b_frames;
  1175. /**
  1176. * qscale factor between IP and B-frames
  1177. * If > 0 then the last P-frame quantizer will be used (q= lastp_q*factor+offset).
  1178. * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
  1179. * - encoding: Set by user.
  1180. * - decoding: unused
  1181. */
  1182. float b_quant_factor;
  1183. /** obsolete FIXME remove */
  1184. int rc_strategy;
  1185. #define FF_RC_STRATEGY_XVID 1
  1186. int b_frame_strategy;
  1187. /**
  1188. * hurry up amount
  1189. * - encoding: unused
  1190. * - decoding: Set by user. 1-> Skip B-frames, 2-> Skip IDCT/dequant too, 5-> Skip everything except header
  1191. * @deprecated Deprecated in favor of skip_idct and skip_frame.
  1192. */
  1193. int hurry_up;
  1194. struct AVCodec *codec;
  1195. void *priv_data;
  1196. int rtp_payload_size; /* The size of the RTP payload: the coder will */
  1197. /* do its best to deliver a chunk with size */
  1198. /* below rtp_payload_size, the chunk will start */
  1199. /* with a start code on some codecs like H.263. */
  1200. /* This doesn't take account of any particular */
  1201. /* headers inside the transmitted RTP payload. */
  1202. /* The RTP callback: This function is called */
  1203. /* every time the encoder has a packet to send. */
  1204. /* It depends on the encoder if the data starts */
  1205. /* with a Start Code (it should). H.263 does. */
  1206. /* mb_nb contains the number of macroblocks */
  1207. /* encoded in the RTP payload. */
  1208. void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb);
  1209. /* statistics, used for 2-pass encoding */
  1210. int mv_bits;
  1211. int header_bits;
  1212. int i_tex_bits;
  1213. int p_tex_bits;
  1214. int i_count;
  1215. int p_count;
  1216. int skip_count;
  1217. int misc_bits;
  1218. /**
  1219. * number of bits used for the previously encoded frame
  1220. * - encoding: Set by libavcodec.
  1221. * - decoding: unused
  1222. */
  1223. int frame_bits;
  1224. /**
  1225. * Private data of the user, can be used to carry app specific stuff.
  1226. * - encoding: Set by user.
  1227. * - decoding: Set by user.
  1228. */
  1229. void *opaque;
  1230. char codec_name[32];
  1231. enum AVMediaType codec_type; /* see AVMEDIA_TYPE_xxx */
  1232. enum CodecID codec_id; /* see CODEC_ID_xxx */
  1233. /**
  1234. * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
  1235. * This is used to work around some encoder bugs.
  1236. * A demuxer should set this to what is stored in the field used to identify the codec.
  1237. * If there are multiple such fields in a container then the demuxer should choose the one
  1238. * which maximizes the information about the used codec.
  1239. * If the codec tag field in a container is larger then 32 bits then the demuxer should
  1240. * remap the longer ID to 32 bits with a table or other structure. Alternatively a new
  1241. * extra_codec_tag + size could be added but for this a clear advantage must be demonstrated
  1242. * first.
  1243. * - encoding: Set by user, if not then the default based on codec_id will be used.
  1244. * - decoding: Set by user, will be converted to uppercase by libavcodec during init.
  1245. */
  1246. unsigned int codec_tag;
  1247. /**
  1248. * Work around bugs in encoders which sometimes cannot be detected automatically.
  1249. * - encoding: Set by user
  1250. * - decoding: Set by user
  1251. */
  1252. int workaround_bugs;
  1253. #define FF_BUG_AUTODETECT 1 ///< autodetection
  1254. #define FF_BUG_OLD_MSMPEG4 2
  1255. #define FF_BUG_XVID_ILACE 4
  1256. #define FF_BUG_UMP4 8
  1257. #define FF_BUG_NO_PADDING 16
  1258. #define FF_BUG_AMV 32
  1259. #define FF_BUG_AC_VLC 0 ///< Will be removed, libavcodec can now handle these non-compliant files by default.
  1260. #define FF_BUG_QPEL_CHROMA 64
  1261. #define FF_BUG_STD_QPEL 128
  1262. #define FF_BUG_QPEL_CHROMA2 256
  1263. #define FF_BUG_DIRECT_BLOCKSIZE 512
  1264. #define FF_BUG_EDGE 1024
  1265. #define FF_BUG_HPEL_CHROMA 2048
  1266. #define FF_BUG_DC_CLIP 4096
  1267. #define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders.
  1268. #define FF_BUG_TRUNCATED 16384
  1269. //#define FF_BUG_FAKE_SCALABILITY 16 //Autodetection should work 100%.
  1270. /**
  1271. * luma single coefficient elimination threshold
  1272. * - encoding: Set by user.
  1273. * - decoding: unused
  1274. */
  1275. int luma_elim_threshold;
  1276. /**
  1277. * chroma single coeff elimination threshold
  1278. * - encoding: Set by user.
  1279. * - decoding: unused
  1280. */
  1281. int chroma_elim_threshold;
  1282. /**
  1283. * strictly follow the standard (MPEG4, ...).
  1284. * - encoding: Set by user.
  1285. * - decoding: Set by user.
  1286. * Setting this to STRICT or higher means the encoder and decoder will
  1287. * generally do stupid things, whereas setting it to unofficial or lower
  1288. * will mean the encoder might produce output that is not supported by all
  1289. * spec-compliant decoders. Decoders don't differentiate between normal,
  1290. * unofficial and experimental (that is, they always try to decode things
  1291. * when they can) unless they are explicitly asked to behave stupidly
  1292. * (=strictly conform to the specs)
  1293. */
  1294. int strict_std_compliance;
  1295. #define FF_COMPLIANCE_VERY_STRICT 2 ///< Strictly conform to an older more strict version of the spec or reference software.
  1296. #define FF_COMPLIANCE_STRICT 1 ///< Strictly conform to all the things in the spec no matter what consequences.
  1297. #define FF_COMPLIANCE_NORMAL 0
  1298. #if LIBAVCODEC_VERSION_MAJOR < 53
  1299. #define FF_COMPLIANCE_INOFFICIAL -1 ///< Allow inofficial extensions (deprecated - use FF_COMPLIANCE_UNOFFICIAL instead).
  1300. #endif
  1301. #define FF_COMPLIANCE_UNOFFICIAL -1 ///< Allow unofficial extensions
  1302. #define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things.
  1303. /**
  1304. * qscale offset between IP and B-frames
  1305. * - encoding: Set by user.
  1306. * - decoding: unused
  1307. */
  1308. float b_quant_offset;
  1309. /**
  1310. * Error recognization; higher values will detect more errors but may
  1311. * misdetect some more or less valid parts as errors.
  1312. * - encoding: unused
  1313. * - decoding: Set by user.
  1314. */
  1315. int error_recognition;
  1316. #define FF_ER_CAREFUL 1
  1317. #define FF_ER_COMPLIANT 2
  1318. #define FF_ER_AGGRESSIVE 3
  1319. #define FF_ER_VERY_AGGRESSIVE 4
  1320. /**
  1321. * Called at the beginning of each frame to get a buffer for it.
  1322. * If pic.reference is set then the frame will be read later by libavcodec.
  1323. * avcodec_align_dimensions2() should be used to find the required width and
  1324. * height, as they normally need to be rounded up to the next multiple of 16.
  1325. * if CODEC_CAP_DR1 is not set then get_buffer() must call
  1326. * avcodec_default_get_buffer() instead of providing buffers allocated by
  1327. * some other means.
  1328. * - encoding: unused
  1329. * - decoding: Set by libavcodec, user can override.
  1330. */
  1331. int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
  1332. /**
  1333. * Called to release buffers which were allocated with get_buffer.
  1334. * A released buffer can be reused in get_buffer().
  1335. * pic.data[*] must be set to NULL.
  1336. * - encoding: unused
  1337. * - decoding: Set by libavcodec, user can override.
  1338. */
  1339. void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
  1340. /**
  1341. * Size of the frame reordering buffer in the decoder.
  1342. * For MPEG-2 it is 1 IPB or 0 low delay IP.
  1343. * - encoding: Set by libavcodec.
  1344. * - decoding: Set by libavcodec.
  1345. */
  1346. int has_b_frames;
  1347. /**
  1348. * number of bytes per packet if constant and known or 0
  1349. * Used by some WAV based audio codecs.
  1350. */
  1351. int block_align;
  1352. int parse_only; /* - decoding only: If true, only parsing is done
  1353. (function avcodec_parse_frame()). The frame
  1354. data is returned. Only MPEG codecs support this now. */
  1355. /**
  1356. * 0-> h263 quant 1-> mpeg quant
  1357. * - encoding: Set by user.
  1358. * - decoding: unused
  1359. */
  1360. int mpeg_quant;
  1361. /**
  1362. * pass1 encoding statistics output buffer
  1363. * - encoding: Set by libavcodec.
  1364. * - decoding: unused
  1365. */
  1366. char *stats_out;
  1367. /**
  1368. * pass2 encoding statistics input buffer
  1369. * Concatenated stuff from stats_out of pass1 should be placed here.
  1370. * - encoding: Allocated/set/freed by user.
  1371. * - decoding: unused
  1372. */
  1373. char *stats_in;
  1374. /**
  1375. * ratecontrol qmin qmax limiting method
  1376. * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax.
  1377. * - encoding: Set by user.
  1378. * - decoding: unused
  1379. */
  1380. float rc_qsquish;
  1381. float rc_qmod_amp;
  1382. int rc_qmod_freq;
  1383. /**
  1384. * ratecontrol override, see RcOverride
  1385. * - encoding: Allocated/set/freed by user.
  1386. * - decoding: unused
  1387. */
  1388. RcOverride *rc_override;
  1389. int rc_override_count;
  1390. /**
  1391. * rate control equation
  1392. * - encoding: Set by user
  1393. * - decoding: unused
  1394. */
  1395. const char *rc_eq;
  1396. /**
  1397. * maximum bitrate
  1398. * - encoding: Set by user.
  1399. * - decoding: unused
  1400. */
  1401. int rc_max_rate;
  1402. /**
  1403. * minimum bitrate
  1404. * - encoding: Set by user.
  1405. * - decoding: unused
  1406. */
  1407. int rc_min_rate;
  1408. /**
  1409. * decoder bitstream buffer size
  1410. * - encoding: Set by user.
  1411. * - decoding: unused
  1412. */
  1413. int rc_buffer_size;
  1414. float rc_buffer_aggressivity;
  1415. /**
  1416. * qscale factor between P and I-frames
  1417. * If > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset).
  1418. * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
  1419. * - encoding: Set by user.
  1420. * - decoding: unused
  1421. */
  1422. float i_quant_factor;
  1423. /**
  1424. * qscale offset between P and I-frames
  1425. * - encoding: Set by user.
  1426. * - decoding: unused
  1427. */
  1428. float i_quant_offset;
  1429. /**
  1430. * initial complexity for pass1 ratecontrol
  1431. * - encoding: Set by user.
  1432. * - decoding: unused
  1433. */
  1434. float rc_initial_cplx;
  1435. /**
  1436. * DCT algorithm, see FF_DCT_* below
  1437. * - encoding: Set by user.
  1438. * - decoding: unused
  1439. */
  1440. int dct_algo;
  1441. #define FF_DCT_AUTO 0
  1442. #define FF_DCT_FASTINT 1
  1443. #define FF_DCT_INT 2
  1444. #define FF_DCT_MMX 3
  1445. #define FF_DCT_MLIB 4
  1446. #define FF_DCT_ALTIVEC 5
  1447. #define FF_DCT_FAAN 6
  1448. /**
  1449. * luminance masking (0-> disabled)
  1450. * - encoding: Set by user.
  1451. * - decoding: unused
  1452. */
  1453. float lumi_masking;
  1454. /**
  1455. * temporary complexity masking (0-> disabled)
  1456. * - encoding: Set by user.
  1457. * - decoding: unused
  1458. */
  1459. float temporal_cplx_masking;
  1460. /**
  1461. * spatial complexity masking (0-> disabled)
  1462. * - encoding: Set by user.
  1463. * - decoding: unused
  1464. */
  1465. float spatial_cplx_masking;
  1466. /**
  1467. * p block masking (0-> disabled)
  1468. * - encoding: Set by user.
  1469. * - decoding: unused
  1470. */
  1471. float p_masking;
  1472. /**
  1473. * darkness masking (0-> disabled)
  1474. * - encoding: Set by user.
  1475. * - decoding: unused
  1476. */
  1477. float dark_masking;
  1478. /**
  1479. * IDCT algorithm, see FF_IDCT_* below.
  1480. * - encoding: Set by user.
  1481. * - decoding: Set by user.
  1482. */
  1483. int idct_algo;
  1484. #define FF_IDCT_AUTO 0
  1485. #define FF_IDCT_INT 1
  1486. #define FF_IDCT_SIMPLE 2
  1487. #define FF_IDCT_SIMPLEMMX 3
  1488. #define FF_IDCT_LIBMPEG2MMX 4
  1489. #define FF_IDCT_PS2 5
  1490. #define FF_IDCT_MLIB 6
  1491. #define FF_IDCT_ARM 7
  1492. #define FF_IDCT_ALTIVEC 8
  1493. #define FF_IDCT_SH4 9
  1494. #define FF_IDCT_SIMPLEARM 10
  1495. #define FF_IDCT_H264 11
  1496. #define FF_IDCT_VP3 12
  1497. #define FF_IDCT_IPP 13
  1498. #define FF_IDCT_XVIDMMX 14
  1499. #define FF_IDCT_CAVS 15
  1500. #define FF_IDCT_SIMPLEARMV5TE 16
  1501. #define FF_IDCT_SIMPLEARMV6 17
  1502. #define FF_IDCT_SIMPLEVIS 18
  1503. #define FF_IDCT_WMV2 19
  1504. #define FF_IDCT_FAAN 20
  1505. #define FF_IDCT_EA 21
  1506. #define FF_IDCT_SIMPLENEON 22
  1507. #define FF_IDCT_SIMPLEALPHA 23
  1508. #define FF_IDCT_BINK 24
  1509. /**
  1510. * slice count
  1511. * - encoding: Set by libavcodec.
  1512. * - decoding: Set by user (or 0).
  1513. */
  1514. int slice_count;
  1515. /**
  1516. * slice offsets in the frame in bytes
  1517. * - encoding: Set/allocated by libavcodec.
  1518. * - decoding: Set/allocated by user (or NULL).
  1519. */
  1520. int *slice_offset;
  1521. /**
  1522. * error concealment flags
  1523. * - encoding: unused
  1524. * - decoding: Set by user.
  1525. */
  1526. int error_concealment;
  1527. #define FF_EC_GUESS_MVS 1
  1528. #define FF_EC_DEBLOCK 2
  1529. /**
  1530. * dsp_mask could be add used to disable unwanted CPU features
  1531. * CPU features (i.e. MMX, SSE. ...)
  1532. *
  1533. * With the FORCE flag you may instead enable given CPU features.
  1534. * (Dangerous: Usable in case of misdetection, improper usage however will
  1535. * result into program crash.)
  1536. */
  1537. unsigned dsp_mask;
  1538. #if FF_API_MM_FLAGS
  1539. #define FF_MM_FORCE AV_CPU_FLAG_FORCE
  1540. #define FF_MM_MMX AV_CPU_FLAG_MMX
  1541. #define FF_MM_3DNOW AV_CPU_FLAG_3DNOW
  1542. #define FF_MM_MMXEXT AV_CPU_FLAG_MMX2
  1543. #define FF_MM_MMX2 AV_CPU_FLAG_MMX2
  1544. #define FF_MM_SSE AV_CPU_FLAG_SSE
  1545. #define FF_MM_SSE2 AV_CPU_FLAG_SSE2
  1546. #define FF_MM_SSE2SLOW AV_CPU_FLAG_SSE2SLOW
  1547. #define FF_MM_3DNOWEXT AV_CPU_FLAG_3DNOWEXT
  1548. #define FF_MM_SSE3 AV_CPU_FLAG_SSE3
  1549. #define FF_MM_SSE3SLOW AV_CPU_FLAG_SSE3SLOW
  1550. #define FF_MM_SSSE3 AV_CPU_FLAG_SSSE3
  1551. #define FF_MM_SSE4 AV_CPU_FLAG_SSE4
  1552. #define FF_MM_SSE42 AV_CPU_FLAG_SSE42
  1553. #define FF_MM_IWMMXT AV_CPU_FLAG_IWMMXT
  1554. #define FF_MM_ALTIVEC AV_CPU_FLAG_ALTIVEC
  1555. #endif
  1556. /**
  1557. * bits per sample/pixel from the demuxer (needed for huffyuv).
  1558. * - encoding: Set by libavcodec.
  1559. * - decoding: Set by user.
  1560. */
  1561. int bits_per_coded_sample;
  1562. /**
  1563. * prediction method (needed for huffyuv)
  1564. * - encoding: Set by user.
  1565. * - decoding: unused
  1566. */
  1567. int prediction_method;
  1568. #define FF_PRED_LEFT 0
  1569. #define FF_PRED_PLANE 1
  1570. #define FF_PRED_MEDIAN 2
  1571. /**
  1572. * sample aspect ratio (0 if unknown)
  1573. * That is the width of a pixel divided by the height of the pixel.
  1574. * Numerator and denominator must be relatively prime and smaller than 256 for some video standards.
  1575. * - encoding: Set by user.
  1576. * - decoding: Set by libavcodec.
  1577. */
  1578. AVRational sample_aspect_ratio;
  1579. /**
  1580. * the picture in the bitstream
  1581. * - encoding: Set by libavcodec.
  1582. * - decoding: Set by libavcodec.
  1583. */
  1584. AVFrame *coded_frame;
  1585. /**
  1586. * debug
  1587. * - encoding: Set by user.
  1588. * - decoding: Set by user.
  1589. */
  1590. int debug;
  1591. #define FF_DEBUG_PICT_INFO 1
  1592. #define FF_DEBUG_RC 2
  1593. #define FF_DEBUG_BITSTREAM 4
  1594. #define FF_DEBUG_MB_TYPE 8
  1595. #define FF_DEBUG_QP 16
  1596. #define FF_DEBUG_MV 32
  1597. #define FF_DEBUG_DCT_COEFF 0x00000040
  1598. #define FF_DEBUG_SKIP 0x00000080
  1599. #define FF_DEBUG_STARTCODE 0x00000100
  1600. #define FF_DEBUG_PTS 0x00000200
  1601. #define FF_DEBUG_ER 0x00000400
  1602. #define FF_DEBUG_MMCO 0x00000800
  1603. #define FF_DEBUG_BUGS 0x00001000
  1604. #define FF_DEBUG_VIS_QP 0x00002000
  1605. #define FF_DEBUG_VIS_MB_TYPE 0x00004000
  1606. #define FF_DEBUG_BUFFERS 0x00008000
  1607. /**
  1608. * debug
  1609. * - encoding: Set by user.
  1610. * - decoding: Set by user.
  1611. */
  1612. int debug_mv;
  1613. #define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames
  1614. #define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames
  1615. #define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames
  1616. /**
  1617. * error
  1618. * - encoding: Set by libavcodec if flags&CODEC_FLAG_PSNR.
  1619. * - decoding: unused
  1620. */
  1621. uint64_t error[4];
  1622. /**
  1623. * minimum MB quantizer
  1624. * - encoding: unused
  1625. * - decoding: unused
  1626. */
  1627. int mb_qmin;
  1628. /**
  1629. * maximum MB quantizer
  1630. * - encoding: unused
  1631. * - decoding: unused
  1632. */
  1633. int mb_qmax;
  1634. /**
  1635. * motion estimation comparison function
  1636. * - encoding: Set by user.
  1637. * - decoding: unused
  1638. */
  1639. int me_cmp;
  1640. /**
  1641. * subpixel motion estimation comparison function
  1642. * - encoding: Set by user.
  1643. * - decoding: unused
  1644. */
  1645. int me_sub_cmp;
  1646. /**
  1647. * macroblock comparison function (not supported yet)
  1648. * - encoding: Set by user.
  1649. * - decoding: unused
  1650. */
  1651. int mb_cmp;
  1652. /**
  1653. * interlaced DCT comparison function
  1654. * - encoding: Set by user.
  1655. * - decoding: unused
  1656. */
  1657. int ildct_cmp;
  1658. #define FF_CMP_SAD 0
  1659. #define FF_CMP_SSE 1
  1660. #define FF_CMP_SATD 2
  1661. #define FF_CMP_DCT 3
  1662. #define FF_CMP_PSNR 4
  1663. #define FF_CMP_BIT 5
  1664. #define FF_CMP_RD 6
  1665. #define FF_CMP_ZERO 7
  1666. #define FF_CMP_VSAD 8
  1667. #define FF_CMP_VSSE 9
  1668. #define FF_CMP_NSSE 10
  1669. #define FF_CMP_W53 11
  1670. #define FF_CMP_W97 12
  1671. #define FF_CMP_DCTMAX 13
  1672. #define FF_CMP_DCT264 14
  1673. #define FF_CMP_CHROMA 256
  1674. /**
  1675. * ME diamond size & shape
  1676. * - encoding: Set by user.
  1677. * - decoding: unused
  1678. */
  1679. int dia_size;
  1680. /**
  1681. * amount of previous MV predictors (2a+1 x 2a+1 square)
  1682. * - encoding: Set by user.
  1683. * - decoding: unused
  1684. */
  1685. int last_predictor_count;
  1686. /**
  1687. * prepass for motion estimation
  1688. * - encoding: Set by user.
  1689. * - decoding: unused
  1690. */
  1691. int pre_me;
  1692. /**
  1693. * motion estimation prepass comparison function
  1694. * - encoding: Set by user.
  1695. * - decoding: unused
  1696. */
  1697. int me_pre_cmp;
  1698. /**
  1699. * ME prepass diamond size & shape
  1700. * - encoding: Set by user.
  1701. * - decoding: unused
  1702. */
  1703. int pre_dia_size;
  1704. /**
  1705. * subpel ME quality
  1706. * - encoding: Set by user.
  1707. * - decoding: unused
  1708. */
  1709. int me_subpel_quality;
  1710. /**
  1711. * callback to negotiate the pixelFormat
  1712. * @param fmt is the list of formats which are supported by the codec,
  1713. * it is terminated by -1 as 0 is a valid format, the formats are ordered by quality.
  1714. * The first is always the native one.
  1715. * @return the chosen format
  1716. * - encoding: unused
  1717. * - decoding: Set by user, if not set the native format will be chosen.
  1718. */
  1719. enum PixelFormat (*get_format)(struct AVCodecContext *s, const enum PixelFormat * fmt);
  1720. /**
  1721. * DTG active format information (additional aspect ratio
  1722. * information only used in DVB MPEG-2 transport streams)
  1723. * 0 if not set.
  1724. *
  1725. * - encoding: unused
  1726. * - decoding: Set by decoder.
  1727. */
  1728. int dtg_active_format;
  1729. #define FF_DTG_AFD_SAME 8
  1730. #define FF_DTG_AFD_4_3 9
  1731. #define FF_DTG_AFD_16_9 10
  1732. #define FF_DTG_AFD_14_9 11
  1733. #define FF_DTG_AFD_4_3_SP_14_9 13
  1734. #define FF_DTG_AFD_16_9_SP_14_9 14
  1735. #define FF_DTG_AFD_SP_4_3 15
  1736. /**
  1737. * maximum motion estimation search range in subpel units
  1738. * If 0 then no limit.
  1739. *
  1740. * - encoding: Set by user.
  1741. * - decoding: unused
  1742. */
  1743. int me_range;
  1744. /**
  1745. * intra quantizer bias
  1746. * - encoding: Set by user.
  1747. * - decoding: unused
  1748. */
  1749. int intra_quant_bias;
  1750. #define FF_DEFAULT_QUANT_BIAS 999999
  1751. /**
  1752. * inter quantizer bias
  1753. * - encoding: Set by user.
  1754. * - decoding: unused
  1755. */
  1756. int inter_quant_bias;
  1757. /**
  1758. * color table ID
  1759. * - encoding: unused
  1760. * - decoding: Which clrtable should be used for 8bit RGB images.
  1761. * Tables have to be stored somewhere. FIXME
  1762. */
  1763. int color_table_id;
  1764. /**
  1765. * internal_buffer count
  1766. * Don't touch, used by libavcodec default_get_buffer().
  1767. */
  1768. int internal_buffer_count;
  1769. /**
  1770. * internal_buffers
  1771. * Don't touch, used by libavcodec default_get_buffer().
  1772. */
  1773. void *internal_buffer;
  1774. #define FF_LAMBDA_SHIFT 7
  1775. #define FF_LAMBDA_SCALE (1<<FF_LAMBDA_SHIFT)
  1776. #define FF_QP2LAMBDA 118 ///< factor to convert from H.263 QP to lambda
  1777. #define FF_LAMBDA_MAX (256*128-1)
  1778. #define FF_QUALITY_SCALE FF_LAMBDA_SCALE //FIXME maybe remove
  1779. /**
  1780. * Global quality for codecs which cannot change it per frame.
  1781. * This should be proportional to MPEG-1/2/4 qscale.
  1782. * - encoding: Set by user.
  1783. * - decoding: unused
  1784. */
  1785. int global_quality;
  1786. #define FF_CODER_TYPE_VLC 0
  1787. #define FF_CODER_TYPE_AC 1
  1788. #define FF_CODER_TYPE_RAW 2
  1789. #define FF_CODER_TYPE_RLE 3
  1790. #define FF_CODER_TYPE_DEFLATE 4
  1791. /**
  1792. * coder type
  1793. * - encoding: Set by user.
  1794. * - decoding: unused
  1795. */
  1796. int coder_type;
  1797. /**
  1798. * context model
  1799. * - encoding: Set by user.
  1800. * - decoding: unused
  1801. */
  1802. int context_model;
  1803. #if 0
  1804. /**
  1805. *
  1806. * - encoding: unused
  1807. * - decoding: Set by user.
  1808. */
  1809. uint8_t * (*realloc)(struct AVCodecContext *s, uint8_t *buf, int buf_size);
  1810. #endif
  1811. /**
  1812. * slice flags
  1813. * - encoding: unused
  1814. * - decoding: Set by user.
  1815. */
  1816. int slice_flags;
  1817. #define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display
  1818. #define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics)
  1819. #define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
  1820. /**
  1821. * XVideo Motion Acceleration
  1822. * - encoding: forbidden
  1823. * - decoding: set by decoder
  1824. */
  1825. int xvmc_acceleration;
  1826. /**
  1827. * macroblock decision mode
  1828. * - encoding: Set by user.
  1829. * - decoding: unused
  1830. */
  1831. int mb_decision;
  1832. #define FF_MB_DECISION_SIMPLE 0 ///< uses mb_cmp
  1833. #define FF_MB_DECISION_BITS 1 ///< chooses the one which needs the fewest bits
  1834. #define FF_MB_DECISION_RD 2 ///< rate distortion
  1835. /**
  1836. * custom intra quantization matrix
  1837. * - encoding: Set by user, can be NULL.
  1838. * - decoding: Set by libavcodec.
  1839. */
  1840. uint16_t *intra_matrix;
  1841. /**
  1842. * custom inter quantization matrix
  1843. * - encoding: Set by user, can be NULL.
  1844. * - decoding: Set by libavcodec.
  1845. */
  1846. uint16_t *inter_matrix;
  1847. /**
  1848. * fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
  1849. * This is used to work around some encoder bugs.
  1850. * - encoding: unused
  1851. * - decoding: Set by user, will be converted to uppercase by libavcodec during init.
  1852. */
  1853. unsigned int stream_codec_tag;
  1854. /**
  1855. * scene change detection threshold
  1856. * 0 is default, larger means fewer detected scene changes.
  1857. * - encoding: Set by user.
  1858. * - decoding: unused
  1859. */
  1860. int scenechange_threshold;
  1861. /**
  1862. * minimum Lagrange multipler
  1863. * - encoding: Set by user.
  1864. * - decoding: unused
  1865. */
  1866. int lmin;
  1867. /**
  1868. * maximum Lagrange multipler
  1869. * - encoding: Set by user.
  1870. * - decoding: unused
  1871. */
  1872. int lmax;
  1873. #if FF_API_PALETTE_CONTROL
  1874. /**
  1875. * palette control structure
  1876. * - encoding: ??? (no palette-enabled encoder yet)
  1877. * - decoding: Set by user.
  1878. */
  1879. struct AVPaletteControl *palctrl;
  1880. #endif
  1881. /**
  1882. * noise reduction strength
  1883. * - encoding: Set by user.
  1884. * - decoding: unused
  1885. */
  1886. int noise_reduction;
  1887. /**
  1888. * Called at the beginning of a frame to get cr buffer for it.
  1889. * Buffer type (size, hints) must be the same. libavcodec won't check it.
  1890. * libavcodec will pass previous buffer in pic, function should return
  1891. * same buffer or new buffer with old frame "painted" into it.
  1892. * If pic.data[0] == NULL must behave like get_buffer().
  1893. * if CODEC_CAP_DR1 is not set then reget_buffer() must call
  1894. * avcodec_default_reget_buffer() instead of providing buffers allocated by
  1895. * some other means.
  1896. * - encoding: unused
  1897. * - decoding: Set by libavcodec, user can override.
  1898. */
  1899. int (*reget_buffer)(struct AVCodecContext *c, AVFrame *pic);
  1900. /**
  1901. * Number of bits which should be loaded into the rc buffer before decoding starts.
  1902. * - encoding: Set by user.
  1903. * - decoding: unused
  1904. */
  1905. int rc_initial_buffer_occupancy;
  1906. /**
  1907. *
  1908. * - encoding: Set by user.
  1909. * - decoding: unused
  1910. */
  1911. int inter_threshold;
  1912. /**
  1913. * CODEC_FLAG2_*
  1914. * - encoding: Set by user.
  1915. * - decoding: Set by user.
  1916. */
  1917. int flags2;
  1918. /**
  1919. * Simulates errors in the bitstream to test error concealment.
  1920. * - encoding: Set by user.
  1921. * - decoding: unused
  1922. */
  1923. int error_rate;
  1924. /**
  1925. * MP3 antialias algorithm, see FF_AA_* below.
  1926. * - encoding: unused
  1927. * - decoding: Set by user.
  1928. */
  1929. int antialias_algo;
  1930. #define FF_AA_AUTO 0
  1931. #define FF_AA_FASTINT 1 //not implemented yet
  1932. #define FF_AA_INT 2
  1933. #define FF_AA_FLOAT 3
  1934. /**
  1935. * quantizer noise shaping
  1936. * - encoding: Set by user.
  1937. * - decoding: unused
  1938. */
  1939. int quantizer_noise_shaping;
  1940. /**
  1941. * thread count
  1942. * is used to decide how many independent tasks should be passed to execute()
  1943. * - encoding: Set by user.
  1944. * - decoding: Set by user.
  1945. */
  1946. int thread_count;
  1947. /**
  1948. * The codec may call this to execute several independent things.
  1949. * It will return only after finishing all tasks.
  1950. * The user may replace this with some multithreaded implementation,
  1951. * the default implementation will execute the parts serially.
  1952. * @param count the number of things to execute
  1953. * - encoding: Set by libavcodec, user can override.
  1954. * - decoding: Set by libavcodec, user can override.
  1955. */
  1956. int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size);
  1957. /**
  1958. * thread opaque
  1959. * Can be used by execute() to store some per AVCodecContext stuff.
  1960. * - encoding: set by execute()
  1961. * - decoding: set by execute()
  1962. */
  1963. void *thread_opaque;
  1964. /**
  1965. * Motion estimation threshold below which no motion estimation is
  1966. * performed, but instead the user specified motion vectors are used.
  1967. *
  1968. * - encoding: Set by user.
  1969. * - decoding: unused
  1970. */
  1971. int me_threshold;
  1972. /**
  1973. * Macroblock threshold below which the user specified macroblock types will be used.
  1974. * - encoding: Set by user.
  1975. * - decoding: unused
  1976. */
  1977. int mb_threshold;
  1978. /**
  1979. * precision of the intra DC coefficient - 8
  1980. * - encoding: Set by user.
  1981. * - decoding: unused
  1982. */
  1983. int intra_dc_precision;
  1984. /**
  1985. * noise vs. sse weight for the nsse comparsion function
  1986. * - encoding: Set by user.
  1987. * - decoding: unused
  1988. */
  1989. int nsse_weight;
  1990. /**
  1991. * Number of macroblock rows at the top which are skipped.
  1992. * - encoding: unused
  1993. * - decoding: Set by user.
  1994. */
  1995. int skip_top;
  1996. /**
  1997. * Number of macroblock rows at the bottom which are skipped.
  1998. * - encoding: unused
  1999. * - decoding: Set by user.
  2000. */
  2001. int skip_bottom;
  2002. /**
  2003. * profile
  2004. * - encoding: Set by user.
  2005. * - decoding: Set by libavcodec.
  2006. */
  2007. int profile;
  2008. #define FF_PROFILE_UNKNOWN -99
  2009. #define FF_PROFILE_AAC_MAIN 0
  2010. #define FF_PROFILE_AAC_LOW 1
  2011. #define FF_PROFILE_AAC_SSR 2
  2012. #define FF_PROFILE_AAC_LTP 3
  2013. #define FF_PROFILE_H264_BASELINE 66
  2014. #define FF_PROFILE_H264_MAIN 77
  2015. #define FF_PROFILE_H264_EXTENDED 88
  2016. #define FF_PROFILE_H264_HIGH 100
  2017. #define FF_PROFILE_H264_HIGH_10 110
  2018. #define FF_PROFILE_H264_HIGH_422 122
  2019. #define FF_PROFILE_H264_HIGH_444 244
  2020. #define FF_PROFILE_H264_CAVLC_444 44
  2021. /**
  2022. * level
  2023. * - encoding: Set by user.
  2024. * - decoding: Set by libavcodec.
  2025. */
  2026. int level;
  2027. #define FF_LEVEL_UNKNOWN -99
  2028. /**
  2029. * low resolution decoding, 1-> 1/2 size, 2->1/4 size
  2030. * - encoding: unused
  2031. * - decoding: Set by user.
  2032. */
  2033. int lowres;
  2034. /**
  2035. * Bitstream width / height, may be different from width/height if lowres
  2036. * or other things are used.
  2037. * - encoding: unused
  2038. * - decoding: Set by user before init if known. Codec should override / dynamically change if needed.
  2039. */
  2040. int coded_width, coded_height;
  2041. /**
  2042. * frame skip threshold
  2043. * - encoding: Set by user.
  2044. * - decoding: unused
  2045. */
  2046. int frame_skip_threshold;
  2047. /**
  2048. * frame skip factor
  2049. * - encoding: Set by user.
  2050. * - decoding: unused
  2051. */
  2052. int frame_skip_factor;
  2053. /**
  2054. * frame skip exponent
  2055. * - encoding: Set by user.
  2056. * - decoding: unused
  2057. */
  2058. int frame_skip_exp;
  2059. /**
  2060. * frame skip comparison function
  2061. * - encoding: Set by user.
  2062. * - decoding: unused
  2063. */
  2064. int frame_skip_cmp;
  2065. /**
  2066. * Border processing masking, raises the quantizer for mbs on the borders
  2067. * of the picture.
  2068. * - encoding: Set by user.
  2069. * - decoding: unused
  2070. */
  2071. float border_masking;
  2072. /**
  2073. * minimum MB lagrange multipler
  2074. * - encoding: Set by user.
  2075. * - decoding: unused
  2076. */
  2077. int mb_lmin;
  2078. /**
  2079. * maximum MB lagrange multipler
  2080. * - encoding: Set by user.
  2081. * - decoding: unused
  2082. */
  2083. int mb_lmax;
  2084. /**
  2085. *
  2086. * - encoding: Set by user.
  2087. * - decoding: unused
  2088. */
  2089. int me_penalty_compensation;
  2090. /**
  2091. *
  2092. * - encoding: unused
  2093. * - decoding: Set by user.
  2094. */
  2095. enum AVDiscard skip_loop_filter;
  2096. /**
  2097. *
  2098. * - encoding: unused
  2099. * - decoding: Set by user.
  2100. */
  2101. enum AVDiscard skip_idct;
  2102. /**
  2103. *
  2104. * - encoding: unused
  2105. * - decoding: Set by user.
  2106. */
  2107. enum AVDiscard skip_frame;
  2108. /**
  2109. *
  2110. * - encoding: Set by user.
  2111. * - decoding: unused
  2112. */
  2113. int bidir_refine;
  2114. /**
  2115. *
  2116. * - encoding: Set by user.
  2117. * - decoding: unused
  2118. */
  2119. int brd_scale;
  2120. /**
  2121. * constant rate factor - quality-based VBR - values ~correspond to qps
  2122. * - encoding: Set by user.
  2123. * - decoding: unused
  2124. */
  2125. float crf;
  2126. /**
  2127. * constant quantization parameter rate control method
  2128. * - encoding: Set by user.
  2129. * - decoding: unused
  2130. */
  2131. int cqp;
  2132. /**
  2133. * minimum GOP size
  2134. * - encoding: Set by user.
  2135. * - decoding: unused
  2136. */
  2137. int keyint_min;
  2138. /**
  2139. * number of reference frames
  2140. * - encoding: Set by user.
  2141. * - decoding: Set by lavc.
  2142. */
  2143. int refs;
  2144. /**
  2145. * chroma qp offset from luma
  2146. * - encoding: Set by user.
  2147. * - decoding: unused
  2148. */
  2149. int chromaoffset;
  2150. /**
  2151. * Influences how often B-frames are used.
  2152. * - encoding: Set by user.
  2153. * - decoding: unused
  2154. */
  2155. int bframebias;
  2156. /**
  2157. * trellis RD quantization
  2158. * - encoding: Set by user.
  2159. * - decoding: unused
  2160. */
  2161. int trellis;
  2162. /**
  2163. * Reduce fluctuations in qp (before curve compression).
  2164. * - encoding: Set by user.
  2165. * - decoding: unused
  2166. */
  2167. float complexityblur;
  2168. /**
  2169. * in-loop deblocking filter alphac0 parameter
  2170. * alpha is in the range -6...6
  2171. * - encoding: Set by user.
  2172. * - decoding: unused
  2173. */
  2174. int deblockalpha;
  2175. /**
  2176. * in-loop deblocking filter beta parameter
  2177. * beta is in the range -6...6
  2178. * - encoding: Set by user.
  2179. * - decoding: unused
  2180. */
  2181. int deblockbeta;
  2182. /**
  2183. * macroblock subpartition sizes to consider - p8x8, p4x4, b8x8, i8x8, i4x4
  2184. * - encoding: Set by user.
  2185. * - decoding: unused
  2186. */
  2187. int partitions;
  2188. #define X264_PART_I4X4 0x001 /* Analyze i4x4 */
  2189. #define X264_PART_I8X8 0x002 /* Analyze i8x8 (requires 8x8 transform) */
  2190. #define X264_PART_P8X8 0x010 /* Analyze p16x8, p8x16 and p8x8 */
  2191. #define X264_PART_P4X4 0x020 /* Analyze p8x4, p4x8, p4x4 */
  2192. #define X264_PART_B8X8 0x100 /* Analyze b16x8, b8x16 and b8x8 */
  2193. /**
  2194. * direct MV prediction mode - 0 (none), 1 (spatial), 2 (temporal), 3 (auto)
  2195. * - encoding: Set by user.
  2196. * - decoding: unused
  2197. */
  2198. int directpred;
  2199. /**
  2200. * Audio cutoff bandwidth (0 means "automatic")
  2201. * - encoding: Set by user.
  2202. * - decoding: unused
  2203. */
  2204. int cutoff;
  2205. /**
  2206. * Multiplied by qscale for each frame and added to scene_change_score.
  2207. * - encoding: Set by user.
  2208. * - decoding: unused
  2209. */
  2210. int scenechange_factor;
  2211. /**
  2212. *
  2213. * Note: Value depends upon the compare function used for fullpel ME.
  2214. * - encoding: Set by user.
  2215. * - decoding: unused
  2216. */
  2217. int mv0_threshold;
  2218. /**
  2219. * Adjusts sensitivity of b_frame_strategy 1.
  2220. * - encoding: Set by user.
  2221. * - decoding: unused
  2222. */
  2223. int b_sensitivity;
  2224. /**
  2225. * - encoding: Set by user.
  2226. * - decoding: unused
  2227. */
  2228. int compression_level;
  2229. #define FF_COMPRESSION_DEFAULT -1
  2230. #if LIBAVCODEC_VERSION_MAJOR < 53
  2231. /**
  2232. * Sets whether to use LPC mode - used by FLAC encoder.
  2233. * - encoding: Set by user.
  2234. * - decoding: unused
  2235. * @deprecated Deprecated in favor of lpc_type and lpc_passes.
  2236. */
  2237. int use_lpc;
  2238. #endif
  2239. /**
  2240. * LPC coefficient precision - used by FLAC encoder
  2241. * - encoding: Set by user.
  2242. * - decoding: unused
  2243. */
  2244. int lpc_coeff_precision;
  2245. /**
  2246. * - encoding: Set by user.
  2247. * - decoding: unused
  2248. */
  2249. int min_prediction_order;
  2250. /**
  2251. * - encoding: Set by user.
  2252. * - decoding: unused
  2253. */
  2254. int max_prediction_order;
  2255. /**
  2256. * search method for selecting prediction order
  2257. * - encoding: Set by user.
  2258. * - decoding: unused
  2259. */
  2260. int prediction_order_method;
  2261. /**
  2262. * - encoding: Set by user.
  2263. * - decoding: unused
  2264. */
  2265. int min_partition_order;
  2266. /**
  2267. * - encoding: Set by user.
  2268. * - decoding: unused
  2269. */
  2270. int max_partition_order;
  2271. /**
  2272. * GOP timecode frame start number, in non drop frame format
  2273. * - encoding: Set by user.
  2274. * - decoding: unused
  2275. */
  2276. int64_t timecode_frame_start;
  2277. #if LIBAVCODEC_VERSION_MAJOR < 53
  2278. /**
  2279. * Decoder should decode to this many channels if it can (0 for default)
  2280. * - encoding: unused
  2281. * - decoding: Set by user.
  2282. * @deprecated Deprecated in favor of request_channel_layout.
  2283. */
  2284. int request_channels;
  2285. #endif
  2286. /**
  2287. * Percentage of dynamic range compression to be applied by the decoder.
  2288. * The default value is 1.0, corresponding to full compression.
  2289. * - encoding: unused
  2290. * - decoding: Set by user.
  2291. */
  2292. float drc_scale;
  2293. /**
  2294. * opaque 64bit number (generally a PTS) that will be reordered and
  2295. * output in AVFrame.reordered_opaque
  2296. * - encoding: unused
  2297. * - decoding: Set by user.
  2298. */
  2299. int64_t reordered_opaque;
  2300. /**
  2301. * Bits per sample/pixel of internal libavcodec pixel/sample format.
  2302. * This field is applicable only when sample_fmt is SAMPLE_FMT_S32.
  2303. * - encoding: set by user.
  2304. * - decoding: set by libavcodec.
  2305. */
  2306. int bits_per_raw_sample;
  2307. /**
  2308. * Audio channel layout.
  2309. * - encoding: set by user.
  2310. * - decoding: set by libavcodec.
  2311. */
  2312. int64_t channel_layout;
  2313. /**
  2314. * Request decoder to use this channel layout if it can (0 for default)
  2315. * - encoding: unused
  2316. * - decoding: Set by user.
  2317. */
  2318. int64_t request_channel_layout;
  2319. /**
  2320. * Ratecontrol attempt to use, at maximum, <value> of what can be used without an underflow.
  2321. * - encoding: Set by user.
  2322. * - decoding: unused.
  2323. */
  2324. float rc_max_available_vbv_use;
  2325. /**
  2326. * Ratecontrol attempt to use, at least, <value> times the amount needed to prevent a vbv overflow.
  2327. * - encoding: Set by user.
  2328. * - decoding: unused.
  2329. */
  2330. float rc_min_vbv_overflow_use;
  2331. /**
  2332. * Hardware accelerator in use
  2333. * - encoding: unused.
  2334. * - decoding: Set by libavcodec
  2335. */
  2336. struct AVHWAccel *hwaccel;
  2337. /**
  2338. * For some codecs, the time base is closer to the field rate than the frame rate.
  2339. * Most notably, H.264 and MPEG-2 specify time_base as half of frame duration
  2340. * if no telecine is used ...
  2341. *
  2342. * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2.
  2343. */
  2344. int ticks_per_frame;
  2345. /**
  2346. * Hardware accelerator context.
  2347. * For some hardware accelerators, a global context needs to be
  2348. * provided by the user. In that case, this holds display-dependent
  2349. * data FFmpeg cannot instantiate itself. Please refer to the
  2350. * FFmpeg HW accelerator documentation to know how to fill this
  2351. * is. e.g. for VA API, this is a struct vaapi_context.
  2352. * - encoding: unused
  2353. * - decoding: Set by user
  2354. */
  2355. void *hwaccel_context;
  2356. /**
  2357. * Chromaticity coordinates of the source primaries.
  2358. * - encoding: Set by user
  2359. * - decoding: Set by libavcodec
  2360. */
  2361. enum AVColorPrimaries color_primaries;
  2362. /**
  2363. * Color Transfer Characteristic.
  2364. * - encoding: Set by user
  2365. * - decoding: Set by libavcodec
  2366. */
  2367. enum AVColorTransferCharacteristic color_trc;
  2368. /**
  2369. * YUV colorspace type.
  2370. * - encoding: Set by user
  2371. * - decoding: Set by libavcodec
  2372. */
  2373. enum AVColorSpace colorspace;
  2374. /**
  2375. * MPEG vs JPEG YUV range.
  2376. * - encoding: Set by user
  2377. * - decoding: Set by libavcodec
  2378. */
  2379. enum AVColorRange color_range;
  2380. /**
  2381. * This defines the location of chroma samples.
  2382. * - encoding: Set by user
  2383. * - decoding: Set by libavcodec
  2384. */
  2385. enum AVChromaLocation chroma_sample_location;
  2386. /**
  2387. * The codec may call this to execute several independent things.
  2388. * It will return only after finishing all tasks.
  2389. * The user may replace this with some multithreaded implementation,
  2390. * the default implementation will execute the parts serially.
  2391. * Also see avcodec_thread_init and e.g. the --enable-pthread configure option.
  2392. * @param c context passed also to func
  2393. * @param count the number of things to execute
  2394. * @param arg2 argument passed unchanged to func
  2395. * @param ret return values of executed functions, must have space for "count" values. May be NULL.
  2396. * @param func function that will be called count times, with jobnr from 0 to count-1.
  2397. * threadnr will be in the range 0 to c->thread_count-1 < MAX_THREADS and so that no
  2398. * two instances of func executing at the same time will have the same threadnr.
  2399. * @return always 0 currently, but code should handle a future improvement where when any call to func
  2400. * returns < 0 no further calls to func may be done and < 0 is returned.
  2401. * - encoding: Set by libavcodec, user can override.
  2402. * - decoding: Set by libavcodec, user can override.
  2403. */
  2404. int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count);
  2405. /**
  2406. * explicit P-frame weighted prediction analysis method
  2407. * 0: off
  2408. * 1: fast blind weighting (one reference duplicate with -1 offset)
  2409. * 2: smart weighting (full fade detection analysis)
  2410. * - encoding: Set by user.
  2411. * - decoding: unused
  2412. */
  2413. int weighted_p_pred;
  2414. /**
  2415. * AQ mode
  2416. * 0: Disabled
  2417. * 1: Variance AQ (complexity mask)
  2418. * 2: Auto-variance AQ (experimental)
  2419. * - encoding: Set by user
  2420. * - decoding: unused
  2421. */
  2422. int aq_mode;
  2423. /**
  2424. * AQ strength
  2425. * Reduces blocking and blurring in flat and textured areas.
  2426. * - encoding: Set by user
  2427. * - decoding: unused
  2428. */
  2429. float aq_strength;
  2430. /**
  2431. * PSY RD
  2432. * Strength of psychovisual optimization
  2433. * - encoding: Set by user
  2434. * - decoding: unused
  2435. */
  2436. float psy_rd;
  2437. /**
  2438. * PSY trellis
  2439. * Strength of psychovisual optimization
  2440. * - encoding: Set by user
  2441. * - decoding: unused
  2442. */
  2443. float psy_trellis;
  2444. /**
  2445. * RC lookahead
  2446. * Number of frames for frametype and ratecontrol lookahead
  2447. * - encoding: Set by user
  2448. * - decoding: unused
  2449. */
  2450. int rc_lookahead;
  2451. /**
  2452. * Constant rate factor maximum
  2453. * With CRF encoding mode and VBV restrictions enabled, prevents quality from being worse
  2454. * than crf_max, even if doing so would violate VBV restrictions.
  2455. * - encoding: Set by user.
  2456. * - decoding: unused
  2457. */
  2458. float crf_max;
  2459. int log_level_offset;
  2460. /**
  2461. * Determines which LPC analysis algorithm to use.
  2462. * - encoding: Set by user
  2463. * - decoding: unused
  2464. */
  2465. enum AVLPCType lpc_type;
  2466. /**
  2467. * Number of passes to use for Cholesky factorization during LPC analysis
  2468. * - encoding: Set by user
  2469. * - decoding: unused
  2470. */
  2471. int lpc_passes;
  2472. } AVCodecContext;
  2473. /**
  2474. * AVCodec.
  2475. */
  2476. typedef struct AVCodec {
  2477. /**
  2478. * Name of the codec implementation.
  2479. * The name is globally unique among encoders and among decoders (but an
  2480. * encoder and a decoder can share the same name).
  2481. * This is the primary way to find a codec from the user perspective.
  2482. */
  2483. const char *name;
  2484. enum AVMediaType type;
  2485. enum CodecID id;
  2486. int priv_data_size;
  2487. int (*init)(AVCodecContext *);
  2488. int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data);
  2489. int (*close)(AVCodecContext *);
  2490. int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt);
  2491. /**
  2492. * Codec capabilities.
  2493. * see CODEC_CAP_*
  2494. */
  2495. int capabilities;
  2496. struct AVCodec *next;
  2497. /**
  2498. * Flush buffers.
  2499. * Will be called when seeking
  2500. */
  2501. void (*flush)(AVCodecContext *);
  2502. const AVRational *supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0}
  2503. const enum PixelFormat *pix_fmts; ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1
  2504. /**
  2505. * Descriptive name for the codec, meant to be more human readable than name.
  2506. * You should use the NULL_IF_CONFIG_SMALL() macro to define it.
  2507. */
  2508. const char *long_name;
  2509. const int *supported_samplerates; ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0
  2510. const enum SampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1
  2511. const int64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0
  2512. uint8_t max_lowres; ///< maximum value for lowres supported by the decoder
  2513. } AVCodec;
  2514. /**
  2515. * AVHWAccel.
  2516. */
  2517. typedef struct AVHWAccel {
  2518. /**
  2519. * Name of the hardware accelerated codec.
  2520. * The name is globally unique among encoders and among decoders (but an
  2521. * encoder and a decoder can share the same name).
  2522. */
  2523. const char *name;
  2524. /**
  2525. * Type of codec implemented by the hardware accelerator.
  2526. *
  2527. * See AVMEDIA_TYPE_xxx
  2528. */
  2529. enum AVMediaType type;
  2530. /**
  2531. * Codec implemented by the hardware accelerator.
  2532. *
  2533. * See CODEC_ID_xxx
  2534. */
  2535. enum CodecID id;
  2536. /**
  2537. * Supported pixel format.
  2538. *
  2539. * Only hardware accelerated formats are supported here.
  2540. */
  2541. enum PixelFormat pix_fmt;
  2542. /**
  2543. * Hardware accelerated codec capabilities.
  2544. * see FF_HWACCEL_CODEC_CAP_*
  2545. */
  2546. int capabilities;
  2547. struct AVHWAccel *next;
  2548. /**
  2549. * Called at the beginning of each frame or field picture.
  2550. *
  2551. * Meaningful frame information (codec specific) is guaranteed to
  2552. * be parsed at this point. This function is mandatory.
  2553. *
  2554. * Note that buf can be NULL along with buf_size set to 0.
  2555. * Otherwise, this means the whole frame is available at this point.
  2556. *
  2557. * @param avctx the codec context
  2558. * @param buf the frame data buffer base
  2559. * @param buf_size the size of the frame in bytes
  2560. * @return zero if successful, a negative value otherwise
  2561. */
  2562. int (*start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
  2563. /**
  2564. * Callback for each slice.
  2565. *
  2566. * Meaningful slice information (codec specific) is guaranteed to
  2567. * be parsed at this point. This function is mandatory.
  2568. *
  2569. * @param avctx the codec context
  2570. * @param buf the slice data buffer base
  2571. * @param buf_size the size of the slice in bytes
  2572. * @return zero if successful, a negative value otherwise
  2573. */
  2574. int (*decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
  2575. /**
  2576. * Called at the end of each frame or field picture.
  2577. *
  2578. * The whole picture is parsed at this point and can now be sent
  2579. * to the hardware accelerator. This function is mandatory.
  2580. *
  2581. * @param avctx the codec context
  2582. * @return zero if successful, a negative value otherwise
  2583. */
  2584. int (*end_frame)(AVCodecContext *avctx);
  2585. /**
  2586. * Size of HW accelerator private data.
  2587. *
  2588. * Private data is allocated with av_mallocz() before
  2589. * AVCodecContext.get_buffer() and deallocated after
  2590. * AVCodecContext.release_buffer().
  2591. */
  2592. int priv_data_size;
  2593. } AVHWAccel;
  2594. /**
  2595. * four components are given, that's all.
  2596. * the last component is alpha
  2597. */
  2598. typedef struct AVPicture {
  2599. uint8_t *data[4];
  2600. int linesize[4]; ///< number of bytes per line
  2601. } AVPicture;
  2602. #if FF_API_PALETTE_CONTROL
  2603. /**
  2604. * AVPaletteControl
  2605. * This structure defines a method for communicating palette changes
  2606. * between and demuxer and a decoder.
  2607. *
  2608. * @deprecated Use AVPacket to send palette changes instead.
  2609. * This is totally broken.
  2610. */
  2611. #define AVPALETTE_SIZE 1024
  2612. #define AVPALETTE_COUNT 256
  2613. typedef struct AVPaletteControl {
  2614. /* Demuxer sets this to 1 to indicate the palette has changed;
  2615. * decoder resets to 0. */
  2616. int palette_changed;
  2617. /* 4-byte ARGB palette entries, stored in native byte order; note that
  2618. * the individual palette components should be on a 8-bit scale; if
  2619. * the palette data comes from an IBM VGA native format, the component
  2620. * data is probably 6 bits in size and needs to be scaled. */
  2621. unsigned int palette[AVPALETTE_COUNT];
  2622. } AVPaletteControl attribute_deprecated;
  2623. #endif
  2624. enum AVSubtitleType {
  2625. SUBTITLE_NONE,
  2626. SUBTITLE_BITMAP, ///< A bitmap, pict will be set
  2627. /**
  2628. * Plain text, the text field must be set by the decoder and is
  2629. * authoritative. ass and pict fields may contain approximations.
  2630. */
  2631. SUBTITLE_TEXT,
  2632. /**
  2633. * Formatted text, the ass field must be set by the decoder and is
  2634. * authoritative. pict and text fields may contain approximations.
  2635. */
  2636. SUBTITLE_ASS,
  2637. };
  2638. typedef struct AVSubtitleRect {
  2639. int x; ///< top left corner of pict, undefined when pict is not set
  2640. int y; ///< top left corner of pict, undefined when pict is not set
  2641. int w; ///< width of pict, undefined when pict is not set
  2642. int h; ///< height of pict, undefined when pict is not set
  2643. int nb_colors; ///< number of colors in pict, undefined when pict is not set
  2644. /**
  2645. * data+linesize for the bitmap of this subtitle.
  2646. * can be set for text/ass as well once they where rendered
  2647. */
  2648. AVPicture pict;
  2649. enum AVSubtitleType type;
  2650. char *text; ///< 0 terminated plain UTF-8 text
  2651. /**
  2652. * 0 terminated ASS/SSA compatible event line.
  2653. * The pressentation of this is unaffected by the other values in this
  2654. * struct.
  2655. */
  2656. char *ass;
  2657. } AVSubtitleRect;
  2658. typedef struct AVSubtitle {
  2659. uint16_t format; /* 0 = graphics */
  2660. uint32_t start_display_time; /* relative to packet pts, in ms */
  2661. uint32_t end_display_time; /* relative to packet pts, in ms */
  2662. unsigned num_rects;
  2663. AVSubtitleRect **rects;
  2664. int64_t pts; ///< Same as packet pts, in AV_TIME_BASE
  2665. } AVSubtitle;
  2666. /* packet functions */
  2667. /**
  2668. * @deprecated use NULL instead
  2669. */
  2670. attribute_deprecated void av_destruct_packet_nofree(AVPacket *pkt);
  2671. /**
  2672. * Default packet destructor.
  2673. */
  2674. void av_destruct_packet(AVPacket *pkt);
  2675. /**
  2676. * Initialize optional fields of a packet with default values.
  2677. *
  2678. * @param pkt packet
  2679. */
  2680. void av_init_packet(AVPacket *pkt);
  2681. /**
  2682. * Allocate the payload of a packet and initialize its fields with
  2683. * default values.
  2684. *
  2685. * @param pkt packet
  2686. * @param size wanted payload size
  2687. * @return 0 if OK, AVERROR_xxx otherwise
  2688. */
  2689. int av_new_packet(AVPacket *pkt, int size);
  2690. /**
  2691. * Reduce packet size, correctly zeroing padding
  2692. *
  2693. * @param pkt packet
  2694. * @param size new size
  2695. */
  2696. void av_shrink_packet(AVPacket *pkt, int size);
  2697. /**
  2698. * @warning This is a hack - the packet memory allocation stuff is broken. The
  2699. * packet is allocated if it was not really allocated.
  2700. */
  2701. int av_dup_packet(AVPacket *pkt);
  2702. /**
  2703. * Free a packet.
  2704. *
  2705. * @param pkt packet to free
  2706. */
  2707. void av_free_packet(AVPacket *pkt);
  2708. /* resample.c */
  2709. struct ReSampleContext;
  2710. struct AVResampleContext;
  2711. typedef struct ReSampleContext ReSampleContext;
  2712. #if LIBAVCODEC_VERSION_MAJOR < 53
  2713. /**
  2714. * @deprecated Use av_audio_resample_init() instead.
  2715. */
  2716. attribute_deprecated ReSampleContext *audio_resample_init(int output_channels, int input_channels,
  2717. int output_rate, int input_rate);
  2718. #endif
  2719. /**
  2720. * Initialize audio resampling context
  2721. *
  2722. * @param output_channels number of output channels
  2723. * @param input_channels number of input channels
  2724. * @param output_rate output sample rate
  2725. * @param input_rate input sample rate
  2726. * @param sample_fmt_out requested output sample format
  2727. * @param sample_fmt_in input sample format
  2728. * @param filter_length length of each FIR filter in the filterbank relative to the cutoff freq
  2729. * @param log2_phase_count log2 of the number of entries in the polyphase filterbank
  2730. * @param linear If 1 then the used FIR filter will be linearly interpolated
  2731. between the 2 closest, if 0 the closest will be used
  2732. * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate
  2733. * @return allocated ReSampleContext, NULL if error occured
  2734. */
  2735. ReSampleContext *av_audio_resample_init(int output_channels, int input_channels,
  2736. int output_rate, int input_rate,
  2737. enum SampleFormat sample_fmt_out,
  2738. enum SampleFormat sample_fmt_in,
  2739. int filter_length, int log2_phase_count,
  2740. int linear, double cutoff);
  2741. int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
  2742. void audio_resample_close(ReSampleContext *s);
  2743. /**
  2744. * Initialize an audio resampler.
  2745. * Note, if either rate is not an integer then simply scale both rates up so they are.
  2746. * @param filter_length length of each FIR filter in the filterbank relative to the cutoff freq
  2747. * @param log2_phase_count log2 of the number of entries in the polyphase filterbank
  2748. * @param linear If 1 then the used FIR filter will be linearly interpolated
  2749. between the 2 closest, if 0 the closest will be used
  2750. * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate
  2751. */
  2752. struct AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_length, int log2_phase_count, int linear, double cutoff);
  2753. /**
  2754. * Resample an array of samples using a previously configured context.
  2755. * @param src an array of unconsumed samples
  2756. * @param consumed the number of samples of src which have been consumed are returned here
  2757. * @param src_size the number of unconsumed samples available
  2758. * @param dst_size the amount of space in samples available in dst
  2759. * @param update_ctx If this is 0 then the context will not be modified, that way several channels can be resampled with the same context.
  2760. * @return the number of samples written in dst or -1 if an error occurred
  2761. */
  2762. int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx);
  2763. /**
  2764. * Compensate samplerate/timestamp drift. The compensation is done by changing
  2765. * the resampler parameters, so no audible clicks or similar distortions occur
  2766. * @param compensation_distance distance in output samples over which the compensation should be performed
  2767. * @param sample_delta number of output samples which should be output less
  2768. *
  2769. * example: av_resample_compensate(c, 10, 500)
  2770. * here instead of 510 samples only 500 samples would be output
  2771. *
  2772. * note, due to rounding the actual compensation might be slightly different,
  2773. * especially if the compensation_distance is large and the in_rate used during init is small
  2774. */
  2775. void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance);
  2776. void av_resample_close(struct AVResampleContext *c);
  2777. /**
  2778. * Allocate memory for a picture. Call avpicture_free to free it.
  2779. *
  2780. * @param picture the picture to be filled in
  2781. * @param pix_fmt the format of the picture
  2782. * @param width the width of the picture
  2783. * @param height the height of the picture
  2784. * @return zero if successful, a negative value if not
  2785. */
  2786. int avpicture_alloc(AVPicture *picture, enum PixelFormat pix_fmt, int width, int height);
  2787. /**
  2788. * Free a picture previously allocated by avpicture_alloc().
  2789. *
  2790. * @param picture the AVPicture to be freed
  2791. */
  2792. void avpicture_free(AVPicture *picture);
  2793. /**
  2794. * Fill in the AVPicture fields.
  2795. * The fields of the given AVPicture are filled in by using the 'ptr' address
  2796. * which points to the image data buffer. Depending on the specified picture
  2797. * format, one or multiple image data pointers and line sizes will be set.
  2798. * If a planar format is specified, several pointers will be set pointing to
  2799. * the different picture planes and the line sizes of the different planes
  2800. * will be stored in the lines_sizes array.
  2801. * Call with ptr == NULL to get the required size for the ptr buffer.
  2802. *
  2803. * @param picture AVPicture whose fields are to be filled in
  2804. * @param ptr Buffer which will contain or contains the actual image data
  2805. * @param pix_fmt The format in which the picture data is stored.
  2806. * @param width the width of the image in pixels
  2807. * @param height the height of the image in pixels
  2808. * @return size of the image data in bytes
  2809. */
  2810. int avpicture_fill(AVPicture *picture, uint8_t *ptr,
  2811. enum PixelFormat pix_fmt, int width, int height);
  2812. int avpicture_layout(const AVPicture* src, enum PixelFormat pix_fmt, int width, int height,
  2813. unsigned char *dest, int dest_size);
  2814. /**
  2815. * Calculate the size in bytes that a picture of the given width and height
  2816. * would occupy if stored in the given picture format.
  2817. * Note that this returns the size of a compact representation as generated
  2818. * by avpicture_layout, which can be smaller than the size required for e.g.
  2819. * avpicture_fill.
  2820. *
  2821. * @param pix_fmt the given picture format
  2822. * @param width the width of the image
  2823. * @param height the height of the image
  2824. * @return Image data size in bytes or -1 on error (e.g. too large dimensions).
  2825. */
  2826. int avpicture_get_size(enum PixelFormat pix_fmt, int width, int height);
  2827. void avcodec_get_chroma_sub_sample(enum PixelFormat pix_fmt, int *h_shift, int *v_shift);
  2828. const char *avcodec_get_pix_fmt_name(enum PixelFormat pix_fmt);
  2829. void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
  2830. #if LIBAVCODEC_VERSION_MAJOR < 53
  2831. /**
  2832. * Return the pixel format corresponding to the name name.
  2833. *
  2834. * If there is no pixel format with name name, then look for a
  2835. * pixel format with the name corresponding to the native endian
  2836. * format of name.
  2837. * For example in a little-endian system, first look for "gray16",
  2838. * then for "gray16le".
  2839. *
  2840. * Finally if no pixel format has been found, return PIX_FMT_NONE.
  2841. *
  2842. * @deprecated Deprecated in favor of av_get_pix_fmt().
  2843. */
  2844. attribute_deprecated enum PixelFormat avcodec_get_pix_fmt(const char* name);
  2845. #endif
  2846. /**
  2847. * Return a value representing the fourCC code associated to the
  2848. * pixel format pix_fmt, or 0 if no associated fourCC code can be
  2849. * found.
  2850. */
  2851. unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat pix_fmt);
  2852. /**
  2853. * Put a string representing the codec tag codec_tag in buf.
  2854. *
  2855. * @param buf_size size in bytes of buf
  2856. * @return the length of the string that would have been generated if
  2857. * enough space had been available, excluding the trailing null
  2858. */
  2859. size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag);
  2860. #define FF_LOSS_RESOLUTION 0x0001 /**< loss due to resolution change */
  2861. #define FF_LOSS_DEPTH 0x0002 /**< loss due to color depth change */
  2862. #define FF_LOSS_COLORSPACE 0x0004 /**< loss due to color space conversion */
  2863. #define FF_LOSS_ALPHA 0x0008 /**< loss of alpha bits */
  2864. #define FF_LOSS_COLORQUANT 0x0010 /**< loss due to color quantization */
  2865. #define FF_LOSS_CHROMA 0x0020 /**< loss of chroma (e.g. RGB to gray conversion) */
  2866. /**
  2867. * Compute what kind of losses will occur when converting from one specific
  2868. * pixel format to another.
  2869. * When converting from one pixel format to another, information loss may occur.
  2870. * For example, when converting from RGB24 to GRAY, the color information will
  2871. * be lost. Similarly, other losses occur when converting from some formats to
  2872. * other formats. These losses can involve loss of chroma, but also loss of
  2873. * resolution, loss of color depth, loss due to the color space conversion, loss
  2874. * of the alpha bits or loss due to color quantization.
  2875. * avcodec_get_fix_fmt_loss() informs you about the various types of losses
  2876. * which will occur when converting from one pixel format to another.
  2877. *
  2878. * @param[in] dst_pix_fmt destination pixel format
  2879. * @param[in] src_pix_fmt source pixel format
  2880. * @param[in] has_alpha Whether the source pixel format alpha channel is used.
  2881. * @return Combination of flags informing you what kind of losses will occur.
  2882. */
  2883. int avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_pix_fmt,
  2884. int has_alpha);
  2885. /**
  2886. * Find the best pixel format to convert to given a certain source pixel
  2887. * format. When converting from one pixel format to another, information loss
  2888. * may occur. For example, when converting from RGB24 to GRAY, the color
  2889. * information will be lost. Similarly, other losses occur when converting from
  2890. * some formats to other formats. avcodec_find_best_pix_fmt() searches which of
  2891. * the given pixel formats should be used to suffer the least amount of loss.
  2892. * The pixel formats from which it chooses one, are determined by the
  2893. * pix_fmt_mask parameter.
  2894. *
  2895. * @code
  2896. * src_pix_fmt = PIX_FMT_YUV420P;
  2897. * pix_fmt_mask = (1 << PIX_FMT_YUV422P) || (1 << PIX_FMT_RGB24);
  2898. * dst_pix_fmt = avcodec_find_best_pix_fmt(pix_fmt_mask, src_pix_fmt, alpha, &loss);
  2899. * @endcode
  2900. *
  2901. * @param[in] pix_fmt_mask bitmask determining which pixel format to choose from
  2902. * @param[in] src_pix_fmt source pixel format
  2903. * @param[in] has_alpha Whether the source pixel format alpha channel is used.
  2904. * @param[out] loss_ptr Combination of flags informing you what kind of losses will occur.
  2905. * @return The best pixel format to convert to or -1 if none was found.
  2906. */
  2907. enum PixelFormat avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, enum PixelFormat src_pix_fmt,
  2908. int has_alpha, int *loss_ptr);
  2909. /**
  2910. * Print in buf the string corresponding to the pixel format with
  2911. * number pix_fmt, or an header if pix_fmt is negative.
  2912. *
  2913. * @param[in] buf the buffer where to write the string
  2914. * @param[in] buf_size the size of buf
  2915. * @param[in] pix_fmt the number of the pixel format to print the corresponding info string, or
  2916. * a negative value to print the corresponding header.
  2917. * Meaningful values for obtaining a pixel format info vary from 0 to PIX_FMT_NB -1.
  2918. */
  2919. void avcodec_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt);
  2920. #define FF_ALPHA_TRANSP 0x0001 /* image has some totally transparent pixels */
  2921. #define FF_ALPHA_SEMI_TRANSP 0x0002 /* image has some transparent pixels */
  2922. /**
  2923. * Tell if an image really has transparent alpha values.
  2924. * @return ored mask of FF_ALPHA_xxx constants
  2925. */
  2926. int img_get_alpha_info(const AVPicture *src,
  2927. enum PixelFormat pix_fmt, int width, int height);
  2928. /* deinterlace a picture */
  2929. /* deinterlace - if not supported return -1 */
  2930. int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
  2931. enum PixelFormat pix_fmt, int width, int height);
  2932. /* external high level API */
  2933. /**
  2934. * If c is NULL, returns the first registered codec,
  2935. * if c is non-NULL, returns the next registered codec after c,
  2936. * or NULL if c is the last one.
  2937. */
  2938. AVCodec *av_codec_next(AVCodec *c);
  2939. /**
  2940. * Return the LIBAVCODEC_VERSION_INT constant.
  2941. */
  2942. unsigned avcodec_version(void);
  2943. /**
  2944. * Return the libavcodec build-time configuration.
  2945. */
  2946. const char *avcodec_configuration(void);
  2947. /**
  2948. * Return the libavcodec license.
  2949. */
  2950. const char *avcodec_license(void);
  2951. /**
  2952. * Initialize libavcodec.
  2953. *
  2954. * @warning This function must be called before any other libavcodec
  2955. * function.
  2956. */
  2957. void avcodec_init(void);
  2958. #if LIBAVCODEC_VERSION_MAJOR < 53
  2959. /**
  2960. * @deprecated Deprecated in favor of avcodec_register().
  2961. */
  2962. attribute_deprecated void register_avcodec(AVCodec *codec);
  2963. #endif
  2964. /**
  2965. * Register the codec codec and initialize libavcodec.
  2966. *
  2967. * @see avcodec_init()
  2968. */
  2969. void avcodec_register(AVCodec *codec);
  2970. /**
  2971. * Find a registered encoder with a matching codec ID.
  2972. *
  2973. * @param id CodecID of the requested encoder
  2974. * @return An encoder if one was found, NULL otherwise.
  2975. */
  2976. AVCodec *avcodec_find_encoder(enum CodecID id);
  2977. /**
  2978. * Find a registered encoder with the specified name.
  2979. *
  2980. * @param name name of the requested encoder
  2981. * @return An encoder if one was found, NULL otherwise.
  2982. */
  2983. AVCodec *avcodec_find_encoder_by_name(const char *name);
  2984. /**
  2985. * Find a registered decoder with a matching codec ID.
  2986. *
  2987. * @param id CodecID of the requested decoder
  2988. * @return A decoder if one was found, NULL otherwise.
  2989. */
  2990. AVCodec *avcodec_find_decoder(enum CodecID id);
  2991. /**
  2992. * Find a registered decoder with the specified name.
  2993. *
  2994. * @param name name of the requested decoder
  2995. * @return A decoder if one was found, NULL otherwise.
  2996. */
  2997. AVCodec *avcodec_find_decoder_by_name(const char *name);
  2998. void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
  2999. /**
  3000. * Set the fields of the given AVCodecContext to default values.
  3001. *
  3002. * @param s The AVCodecContext of which the fields should be set to default values.
  3003. */
  3004. void avcodec_get_context_defaults(AVCodecContext *s);
  3005. /** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
  3006. * we WILL change its arguments and name a few times! */
  3007. void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType);
  3008. /**
  3009. * Allocate an AVCodecContext and set its fields to default values. The
  3010. * resulting struct can be deallocated by simply calling av_free().
  3011. *
  3012. * @return An AVCodecContext filled with default values or NULL on failure.
  3013. * @see avcodec_get_context_defaults
  3014. */
  3015. AVCodecContext *avcodec_alloc_context(void);
  3016. /** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
  3017. * we WILL change its arguments and name a few times! */
  3018. AVCodecContext *avcodec_alloc_context2(enum AVMediaType);
  3019. /**
  3020. * Copy the settings of the source AVCodecContext into the destination
  3021. * AVCodecContext. The resulting destination codec context will be
  3022. * unopened, i.e. you are required to call avcodec_open() before you
  3023. * can use this AVCodecContext to decode/encode video/audio data.
  3024. *
  3025. * @param dest target codec context, should be initialized with
  3026. * avcodec_alloc_context(), but otherwise uninitialized
  3027. * @param src source codec context
  3028. * @return AVERROR() on error (e.g. memory allocation error), 0 on success
  3029. */
  3030. int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src);
  3031. /**
  3032. * Set the fields of the given AVFrame to default values.
  3033. *
  3034. * @param pic The AVFrame of which the fields should be set to default values.
  3035. */
  3036. void avcodec_get_frame_defaults(AVFrame *pic);
  3037. /**
  3038. * Allocate an AVFrame and set its fields to default values. The resulting
  3039. * struct can be deallocated by simply calling av_free().
  3040. *
  3041. * @return An AVFrame filled with default values or NULL on failure.
  3042. * @see avcodec_get_frame_defaults
  3043. */
  3044. AVFrame *avcodec_alloc_frame(void);
  3045. int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
  3046. void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
  3047. int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic);
  3048. /**
  3049. * Return the amount of padding in pixels which the get_buffer callback must
  3050. * provide around the edge of the image for codecs which do not have the
  3051. * CODEC_FLAG_EMU_EDGE flag.
  3052. *
  3053. * @return Required padding in pixels.
  3054. */
  3055. unsigned avcodec_get_edge_width(void);
  3056. /**
  3057. * Modify width and height values so that they will result in a memory
  3058. * buffer that is acceptable for the codec if you do not use any horizontal
  3059. * padding.
  3060. *
  3061. * May only be used if a codec with CODEC_CAP_DR1 has been opened.
  3062. * If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased
  3063. * according to avcodec_get_edge_width() before.
  3064. */
  3065. void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);
  3066. /**
  3067. * Modify width and height values so that they will result in a memory
  3068. * buffer that is acceptable for the codec if you also ensure that all
  3069. * line sizes are a multiple of the respective linesize_align[i].
  3070. *
  3071. * May only be used if a codec with CODEC_CAP_DR1 has been opened.
  3072. * If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased
  3073. * according to avcodec_get_edge_width() before.
  3074. */
  3075. void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
  3076. int linesize_align[4]);
  3077. #if LIBAVCODEC_VERSION_MAJOR < 53
  3078. /**
  3079. * @deprecated Deprecated in favor of av_check_image_size().
  3080. */
  3081. attribute_deprecated
  3082. int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h);
  3083. #endif
  3084. enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt);
  3085. int avcodec_thread_init(AVCodecContext *s, int thread_count);
  3086. void avcodec_thread_free(AVCodecContext *s);
  3087. int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size);
  3088. int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count);
  3089. //FIXME func typedef
  3090. /**
  3091. * Initialize the AVCodecContext to use the given AVCodec. Prior to using this
  3092. * function the context has to be allocated.
  3093. *
  3094. * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),
  3095. * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for
  3096. * retrieving a codec.
  3097. *
  3098. * @warning This function is not thread safe!
  3099. *
  3100. * @code
  3101. * avcodec_register_all();
  3102. * codec = avcodec_find_decoder(CODEC_ID_H264);
  3103. * if (!codec)
  3104. * exit(1);
  3105. *
  3106. * context = avcodec_alloc_context();
  3107. *
  3108. * if (avcodec_open(context, codec) < 0)
  3109. * exit(1);
  3110. * @endcode
  3111. *
  3112. * @param avctx The context which will be set up to use the given codec.
  3113. * @param codec The codec to use within the context.
  3114. * @return zero on success, a negative value on error
  3115. * @see avcodec_alloc_context, avcodec_find_decoder, avcodec_find_encoder
  3116. */
  3117. int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
  3118. #if LIBAVCODEC_VERSION_MAJOR < 53
  3119. /**
  3120. * Decode an audio frame from buf into samples.
  3121. * Wrapper function which calls avcodec_decode_audio3.
  3122. *
  3123. * @deprecated Use avcodec_decode_audio3 instead.
  3124. * @param avctx the codec context
  3125. * @param[out] samples the output buffer
  3126. * @param[in,out] frame_size_ptr the output buffer size in bytes
  3127. * @param[in] buf the input buffer
  3128. * @param[in] buf_size the input buffer size in bytes
  3129. * @return On error a negative value is returned, otherwise the number of bytes
  3130. * used or zero if no frame could be decompressed.
  3131. */
  3132. attribute_deprecated int avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples,
  3133. int *frame_size_ptr,
  3134. const uint8_t *buf, int buf_size);
  3135. #endif
  3136. /**
  3137. * Decode the audio frame of size avpkt->size from avpkt->data into samples.
  3138. * Some decoders may support multiple frames in a single AVPacket, such
  3139. * decoders would then just decode the first frame. In this case,
  3140. * avcodec_decode_audio3 has to be called again with an AVPacket that contains
  3141. * the remaining data in order to decode the second frame etc.
  3142. * If no frame
  3143. * could be outputted, frame_size_ptr is zero. Otherwise, it is the
  3144. * decompressed frame size in bytes.
  3145. *
  3146. * @warning You must set frame_size_ptr to the allocated size of the
  3147. * output buffer before calling avcodec_decode_audio3().
  3148. *
  3149. * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than
  3150. * the actual read bytes because some optimized bitstream readers read 32 or 64
  3151. * bits at once and could read over the end.
  3152. *
  3153. * @warning The end of the input buffer avpkt->data should be set to 0 to ensure that
  3154. * no overreading happens for damaged MPEG streams.
  3155. *
  3156. * @note You might have to align the input buffer avpkt->data and output buffer
  3157. * samples. The alignment requirements depend on the CPU: On some CPUs it isn't
  3158. * necessary at all, on others it won't work at all if not aligned and on others
  3159. * it will work but it will have an impact on performance.
  3160. *
  3161. * In practice, avpkt->data should have 4 byte alignment at minimum and
  3162. * samples should be 16 byte aligned unless the CPU doesn't need it
  3163. * (AltiVec and SSE do).
  3164. *
  3165. * @param avctx the codec context
  3166. * @param[out] samples the output buffer, sample type in avctx->sample_fmt
  3167. * @param[in,out] frame_size_ptr the output buffer size in bytes
  3168. * @param[in] avpkt The input AVPacket containing the input buffer.
  3169. * You can create such packet with av_init_packet() and by then setting
  3170. * data and size, some decoders might in addition need other fields.
  3171. * All decoders are designed to use the least fields possible though.
  3172. * @return On error a negative value is returned, otherwise the number of bytes
  3173. * used or zero if no frame data was decompressed (used) from the input AVPacket.
  3174. */
  3175. int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples,
  3176. int *frame_size_ptr,
  3177. AVPacket *avpkt);
  3178. #if LIBAVCODEC_VERSION_MAJOR < 53
  3179. /**
  3180. * Decode a video frame from buf into picture.
  3181. * Wrapper function which calls avcodec_decode_video2.
  3182. *
  3183. * @deprecated Use avcodec_decode_video2 instead.
  3184. * @param avctx the codec context
  3185. * @param[out] picture The AVFrame in which the decoded video frame will be stored.
  3186. * @param[in] buf the input buffer
  3187. * @param[in] buf_size the size of the input buffer in bytes
  3188. * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero.
  3189. * @return On error a negative value is returned, otherwise the number of bytes
  3190. * used or zero if no frame could be decompressed.
  3191. */
  3192. attribute_deprecated int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
  3193. int *got_picture_ptr,
  3194. const uint8_t *buf, int buf_size);
  3195. #endif
  3196. /**
  3197. * Decode the video frame of size avpkt->size from avpkt->data into picture.
  3198. * Some decoders may support multiple frames in a single AVPacket, such
  3199. * decoders would then just decode the first frame.
  3200. *
  3201. * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than
  3202. * the actual read bytes because some optimized bitstream readers read 32 or 64
  3203. * bits at once and could read over the end.
  3204. *
  3205. * @warning The end of the input buffer buf should be set to 0 to ensure that
  3206. * no overreading happens for damaged MPEG streams.
  3207. *
  3208. * @note You might have to align the input buffer avpkt->data.
  3209. * The alignment requirements depend on the CPU: on some CPUs it isn't
  3210. * necessary at all, on others it won't work at all if not aligned and on others
  3211. * it will work but it will have an impact on performance.
  3212. *
  3213. * In practice, avpkt->data should have 4 byte alignment at minimum.
  3214. *
  3215. * @note Some codecs have a delay between input and output, these need to be
  3216. * fed with avpkt->data=NULL, avpkt->size=0 at the end to return the remaining frames.
  3217. *
  3218. * @param avctx the codec context
  3219. * @param[out] picture The AVFrame in which the decoded video frame will be stored.
  3220. * Use avcodec_alloc_frame to get an AVFrame, the codec will
  3221. * allocate memory for the actual bitmap.
  3222. * with default get/release_buffer(), the decoder frees/reuses the bitmap as it sees fit.
  3223. * with overridden get/release_buffer() (needs CODEC_CAP_DR1) the user decides into what buffer the decoder
  3224. * decodes and the decoder tells the user once it does not need the data anymore,
  3225. * the user app can at this point free/reuse/keep the memory as it sees fit.
  3226. *
  3227. * @param[in] avpkt The input AVpacket containing the input buffer.
  3228. * You can create such packet with av_init_packet() and by then setting
  3229. * data and size, some decoders might in addition need other fields like
  3230. * flags&AV_PKT_FLAG_KEY. All decoders are designed to use the least
  3231. * fields possible.
  3232. * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero.
  3233. * @return On error a negative value is returned, otherwise the number of bytes
  3234. * used or zero if no frame could be decompressed.
  3235. */
  3236. int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
  3237. int *got_picture_ptr,
  3238. AVPacket *avpkt);
  3239. #if LIBAVCODEC_VERSION_MAJOR < 53
  3240. /* Decode a subtitle message. Return -1 if error, otherwise return the
  3241. * number of bytes used. If no subtitle could be decompressed,
  3242. * got_sub_ptr is zero. Otherwise, the subtitle is stored in *sub. */
  3243. attribute_deprecated int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub,
  3244. int *got_sub_ptr,
  3245. const uint8_t *buf, int buf_size);
  3246. #endif
  3247. /**
  3248. * Decode a subtitle message.
  3249. * Return a negative value on error, otherwise return the number of bytes used.
  3250. * If no subtitle could be decompressed, got_sub_ptr is zero.
  3251. * Otherwise, the subtitle is stored in *sub.
  3252. * Note that CODEC_CAP_DR1 is not available for subtitle codecs. This is for
  3253. * simplicity, because the performance difference is expect to be negligible
  3254. * and reusing a get_buffer written for video codecs would probably perform badly
  3255. * due to a potentially very different allocation pattern.
  3256. *
  3257. * @param avctx the codec context
  3258. * @param[out] sub The AVSubtitle in which the decoded subtitle will be stored, must be
  3259. freed with avsubtitle_free if *got_sub_ptr is set.
  3260. * @param[in,out] got_sub_ptr Zero if no subtitle could be decompressed, otherwise, it is nonzero.
  3261. * @param[in] avpkt The input AVPacket containing the input buffer.
  3262. */
  3263. int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
  3264. int *got_sub_ptr,
  3265. AVPacket *avpkt);
  3266. /**
  3267. * Frees all allocated data in the given subtitle struct.
  3268. *
  3269. * @param sub AVSubtitle to free.
  3270. */
  3271. void avsubtitle_free(AVSubtitle *sub);
  3272. int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata,
  3273. int *data_size_ptr,
  3274. uint8_t *buf, int buf_size);
  3275. /**
  3276. * Encode an audio frame from samples into buf.
  3277. *
  3278. * @note The output buffer should be at least FF_MIN_BUFFER_SIZE bytes large.
  3279. * However, for PCM audio the user will know how much space is needed
  3280. * because it depends on the value passed in buf_size as described
  3281. * below. In that case a lower value can be used.
  3282. *
  3283. * @param avctx the codec context
  3284. * @param[out] buf the output buffer
  3285. * @param[in] buf_size the output buffer size
  3286. * @param[in] samples the input buffer containing the samples
  3287. * The number of samples read from this buffer is frame_size*channels,
  3288. * both of which are defined in avctx.
  3289. * For PCM audio the number of samples read from samples is equal to
  3290. * buf_size * input_sample_size / output_sample_size.
  3291. * @return On error a negative value is returned, on success zero or the number
  3292. * of bytes used to encode the data read from the input buffer.
  3293. */
  3294. int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
  3295. const short *samples);
  3296. /**
  3297. * Encode a video frame from pict into buf.
  3298. * The input picture should be
  3299. * stored using a specific format, namely avctx.pix_fmt.
  3300. *
  3301. * @param avctx the codec context
  3302. * @param[out] buf the output buffer for the bitstream of encoded frame
  3303. * @param[in] buf_size the size of the output buffer in bytes
  3304. * @param[in] pict the input picture to encode
  3305. * @return On error a negative value is returned, on success zero or the number
  3306. * of bytes used from the output buffer.
  3307. */
  3308. int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
  3309. const AVFrame *pict);
  3310. int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
  3311. const AVSubtitle *sub);
  3312. int avcodec_close(AVCodecContext *avctx);
  3313. /**
  3314. * Register all the codecs, parsers and bitstream filters which were enabled at
  3315. * configuration time. If you do not call this function you can select exactly
  3316. * which formats you want to support, by using the individual registration
  3317. * functions.
  3318. *
  3319. * @see avcodec_register
  3320. * @see av_register_codec_parser
  3321. * @see av_register_bitstream_filter
  3322. */
  3323. void avcodec_register_all(void);
  3324. /**
  3325. * Flush buffers, should be called when seeking or when switching to a different stream.
  3326. */
  3327. void avcodec_flush_buffers(AVCodecContext *avctx);
  3328. void avcodec_default_free_buffers(AVCodecContext *s);
  3329. /* misc useful functions */
  3330. /**
  3331. * Return a single letter to describe the given picture type pict_type.
  3332. *
  3333. * @param[in] pict_type the picture type
  3334. * @return A single character representing the picture type.
  3335. */
  3336. char av_get_pict_type_char(int pict_type);
  3337. /**
  3338. * Return codec bits per sample.
  3339. *
  3340. * @param[in] codec_id the codec
  3341. * @return Number of bits per sample or zero if unknown for the given codec.
  3342. */
  3343. int av_get_bits_per_sample(enum CodecID codec_id);
  3344. /**
  3345. * Return sample format bits per sample.
  3346. *
  3347. * @param[in] sample_fmt the sample format
  3348. * @return Number of bits per sample or zero if unknown for the given sample format.
  3349. */
  3350. int av_get_bits_per_sample_format(enum SampleFormat sample_fmt);
  3351. /* frame parsing */
  3352. typedef struct AVCodecParserContext {
  3353. void *priv_data;
  3354. struct AVCodecParser *parser;
  3355. int64_t frame_offset; /* offset of the current frame */
  3356. int64_t cur_offset; /* current offset
  3357. (incremented by each av_parser_parse()) */
  3358. int64_t next_frame_offset; /* offset of the next frame */
  3359. /* video info */
  3360. int pict_type; /* XXX: Put it back in AVCodecContext. */
  3361. /**
  3362. * This field is used for proper frame duration computation in lavf.
  3363. * It signals, how much longer the frame duration of the current frame
  3364. * is compared to normal frame duration.
  3365. *
  3366. * frame_duration = (1 + repeat_pict) * time_base
  3367. *
  3368. * It is used by codecs like H.264 to display telecined material.
  3369. */
  3370. int repeat_pict; /* XXX: Put it back in AVCodecContext. */
  3371. int64_t pts; /* pts of the current frame */
  3372. int64_t dts; /* dts of the current frame */
  3373. /* private data */
  3374. int64_t last_pts;
  3375. int64_t last_dts;
  3376. int fetch_timestamp;
  3377. #define AV_PARSER_PTS_NB 4
  3378. int cur_frame_start_index;
  3379. int64_t cur_frame_offset[AV_PARSER_PTS_NB];
  3380. int64_t cur_frame_pts[AV_PARSER_PTS_NB];
  3381. int64_t cur_frame_dts[AV_PARSER_PTS_NB];
  3382. int flags;
  3383. #define PARSER_FLAG_COMPLETE_FRAMES 0x0001
  3384. #define PARSER_FLAG_ONCE 0x0002
  3385. int64_t offset; ///< byte offset from starting packet start
  3386. int64_t cur_frame_end[AV_PARSER_PTS_NB];
  3387. /*!
  3388. * Set by parser to 1 for key frames and 0 for non-key frames.
  3389. * It is initialized to -1, so if the parser doesn't set this flag,
  3390. * old-style fallback using FF_I_TYPE picture type as key frames
  3391. * will be used.
  3392. */
  3393. int key_frame;
  3394. /**
  3395. * Time difference in stream time base units from the pts of this
  3396. * packet to the point at which the output from the decoder has converged
  3397. * independent from the availability of previous frames. That is, the
  3398. * frames are virtually identical no matter if decoding started from
  3399. * the very first frame or from this keyframe.
  3400. * Is AV_NOPTS_VALUE if unknown.
  3401. * This field is not the display duration of the current frame.
  3402. * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY
  3403. * set.
  3404. *
  3405. * The purpose of this field is to allow seeking in streams that have no
  3406. * keyframes in the conventional sense. It corresponds to the
  3407. * recovery point SEI in H.264 and match_time_delta in NUT. It is also
  3408. * essential for some types of subtitle streams to ensure that all
  3409. * subtitles are correctly displayed after seeking.
  3410. */
  3411. int64_t convergence_duration;
  3412. // Timestamp generation support:
  3413. /**
  3414. * Synchronization point for start of timestamp generation.
  3415. *
  3416. * Set to >0 for sync point, 0 for no sync point and <0 for undefined
  3417. * (default).
  3418. *
  3419. * For example, this corresponds to presence of H.264 buffering period
  3420. * SEI message.
  3421. */
  3422. int dts_sync_point;
  3423. /**
  3424. * Offset of the current timestamp against last timestamp sync point in
  3425. * units of AVCodecContext.time_base.
  3426. *
  3427. * Set to INT_MIN when dts_sync_point unused. Otherwise, it must
  3428. * contain a valid timestamp offset.
  3429. *
  3430. * Note that the timestamp of sync point has usually a nonzero
  3431. * dts_ref_dts_delta, which refers to the previous sync point. Offset of
  3432. * the next frame after timestamp sync point will be usually 1.
  3433. *
  3434. * For example, this corresponds to H.264 cpb_removal_delay.
  3435. */
  3436. int dts_ref_dts_delta;
  3437. /**
  3438. * Presentation delay of current frame in units of AVCodecContext.time_base.
  3439. *
  3440. * Set to INT_MIN when dts_sync_point unused. Otherwise, it must
  3441. * contain valid non-negative timestamp delta (presentation time of a frame
  3442. * must not lie in the past).
  3443. *
  3444. * This delay represents the difference between decoding and presentation
  3445. * time of the frame.
  3446. *
  3447. * For example, this corresponds to H.264 dpb_output_delay.
  3448. */
  3449. int pts_dts_delta;
  3450. /**
  3451. * Position of the packet in file.
  3452. *
  3453. * Analogous to cur_frame_pts/dts
  3454. */
  3455. int64_t cur_frame_pos[AV_PARSER_PTS_NB];
  3456. /**
  3457. * Byte position of currently parsed frame in stream.
  3458. */
  3459. int64_t pos;
  3460. /**
  3461. * Previous frame byte position.
  3462. */
  3463. int64_t last_pos;
  3464. } AVCodecParserContext;
  3465. typedef struct AVCodecParser {
  3466. int codec_ids[5]; /* several codec IDs are permitted */
  3467. int priv_data_size;
  3468. int (*parser_init)(AVCodecParserContext *s);
  3469. int (*parser_parse)(AVCodecParserContext *s,
  3470. AVCodecContext *avctx,
  3471. const uint8_t **poutbuf, int *poutbuf_size,
  3472. const uint8_t *buf, int buf_size);
  3473. void (*parser_close)(AVCodecParserContext *s);
  3474. int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size);
  3475. struct AVCodecParser *next;
  3476. } AVCodecParser;
  3477. AVCodecParser *av_parser_next(AVCodecParser *c);
  3478. void av_register_codec_parser(AVCodecParser *parser);
  3479. AVCodecParserContext *av_parser_init(int codec_id);
  3480. #if LIBAVCODEC_VERSION_MAJOR < 53
  3481. attribute_deprecated
  3482. int av_parser_parse(AVCodecParserContext *s,
  3483. AVCodecContext *avctx,
  3484. uint8_t **poutbuf, int *poutbuf_size,
  3485. const uint8_t *buf, int buf_size,
  3486. int64_t pts, int64_t dts);
  3487. #endif
  3488. /**
  3489. * Parse a packet.
  3490. *
  3491. * @param s parser context.
  3492. * @param avctx codec context.
  3493. * @param poutbuf set to pointer to parsed buffer or NULL if not yet finished.
  3494. * @param poutbuf_size set to size of parsed buffer or zero if not yet finished.
  3495. * @param buf input buffer.
  3496. * @param buf_size input length, to signal EOF, this should be 0 (so that the last frame can be output).
  3497. * @param pts input presentation timestamp.
  3498. * @param dts input decoding timestamp.
  3499. * @param pos input byte position in stream.
  3500. * @return the number of bytes of the input bitstream used.
  3501. *
  3502. * Example:
  3503. * @code
  3504. * while(in_len){
  3505. * len = av_parser_parse2(myparser, AVCodecContext, &data, &size,
  3506. * in_data, in_len,
  3507. * pts, dts, pos);
  3508. * in_data += len;
  3509. * in_len -= len;
  3510. *
  3511. * if(size)
  3512. * decode_frame(data, size);
  3513. * }
  3514. * @endcode
  3515. */
  3516. int av_parser_parse2(AVCodecParserContext *s,
  3517. AVCodecContext *avctx,
  3518. uint8_t **poutbuf, int *poutbuf_size,
  3519. const uint8_t *buf, int buf_size,
  3520. int64_t pts, int64_t dts,
  3521. int64_t pos);
  3522. int av_parser_change(AVCodecParserContext *s,
  3523. AVCodecContext *avctx,
  3524. uint8_t **poutbuf, int *poutbuf_size,
  3525. const uint8_t *buf, int buf_size, int keyframe);
  3526. void av_parser_close(AVCodecParserContext *s);
  3527. typedef struct AVBitStreamFilterContext {
  3528. void *priv_data;
  3529. struct AVBitStreamFilter *filter;
  3530. AVCodecParserContext *parser;
  3531. struct AVBitStreamFilterContext *next;
  3532. } AVBitStreamFilterContext;
  3533. typedef struct AVBitStreamFilter {
  3534. const char *name;
  3535. int priv_data_size;
  3536. int (*filter)(AVBitStreamFilterContext *bsfc,
  3537. AVCodecContext *avctx, const char *args,
  3538. uint8_t **poutbuf, int *poutbuf_size,
  3539. const uint8_t *buf, int buf_size, int keyframe);
  3540. void (*close)(AVBitStreamFilterContext *bsfc);
  3541. struct AVBitStreamFilter *next;
  3542. } AVBitStreamFilter;
  3543. void av_register_bitstream_filter(AVBitStreamFilter *bsf);
  3544. AVBitStreamFilterContext *av_bitstream_filter_init(const char *name);
  3545. int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc,
  3546. AVCodecContext *avctx, const char *args,
  3547. uint8_t **poutbuf, int *poutbuf_size,
  3548. const uint8_t *buf, int buf_size, int keyframe);
  3549. void av_bitstream_filter_close(AVBitStreamFilterContext *bsf);
  3550. AVBitStreamFilter *av_bitstream_filter_next(AVBitStreamFilter *f);
  3551. /* memory */
  3552. /**
  3553. * Reallocate the given block if it is not large enough, otherwise do nothing.
  3554. *
  3555. * @see av_realloc
  3556. */
  3557. void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
  3558. /**
  3559. * Allocate a buffer, reusing the given one if large enough.
  3560. *
  3561. * Contrary to av_fast_realloc the current buffer contents might not be
  3562. * preserved and on error the old buffer is freed, thus no special
  3563. * handling to avoid memleaks is necessary.
  3564. *
  3565. * @param ptr pointer to pointer to already allocated buffer, overwritten with pointer to new buffer
  3566. * @param size size of the buffer *ptr points to
  3567. * @param min_size minimum size of *ptr buffer after returning, *ptr will be NULL and
  3568. * *size 0 if an error occurred.
  3569. */
  3570. void av_fast_malloc(void *ptr, unsigned int *size, unsigned int min_size);
  3571. #if LIBAVCODEC_VERSION_MAJOR < 53
  3572. /**
  3573. * @deprecated Deprecated in favor of av_image_copy().
  3574. */
  3575. attribute_deprecated
  3576. void av_picture_data_copy(uint8_t *dst_data[4], int dst_linesize[4],
  3577. uint8_t *src_data[4], int src_linesize[4],
  3578. enum PixelFormat pix_fmt, int width, int height);
  3579. #endif
  3580. /**
  3581. * Copy image src to dst. Wraps av_picture_data_copy() above.
  3582. */
  3583. void av_picture_copy(AVPicture *dst, const AVPicture *src,
  3584. enum PixelFormat pix_fmt, int width, int height);
  3585. /**
  3586. * Crop image top and left side.
  3587. */
  3588. int av_picture_crop(AVPicture *dst, const AVPicture *src,
  3589. enum PixelFormat pix_fmt, int top_band, int left_band);
  3590. /**
  3591. * Pad image.
  3592. */
  3593. int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, enum PixelFormat pix_fmt,
  3594. int padtop, int padbottom, int padleft, int padright, int *color);
  3595. /**
  3596. * Encode extradata length to a buffer. Used by xiph codecs.
  3597. *
  3598. * @param s buffer to write to; must be at least (v/255+1) bytes long
  3599. * @param v size of extradata in bytes
  3600. * @return number of bytes written to the buffer.
  3601. */
  3602. unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
  3603. #if LIBAVCODEC_VERSION_MAJOR < 53
  3604. /**
  3605. * Parse str and put in width_ptr and height_ptr the detected values.
  3606. *
  3607. * @deprecated Deprecated in favor of av_parse_video_size().
  3608. */
  3609. attribute_deprecated int av_parse_video_frame_size(int *width_ptr, int *height_ptr, const char *str);
  3610. /**
  3611. * Parse str and store the detected values in *frame_rate.
  3612. *
  3613. * @deprecated Deprecated in favor of av_parse_video_rate().
  3614. */
  3615. attribute_deprecated int av_parse_video_frame_rate(AVRational *frame_rate, const char *str);
  3616. #endif
  3617. /**
  3618. * Logs a generic warning message about a missing feature. This function is
  3619. * intended to be used internally by FFmpeg (libavcodec, libavformat, etc.)
  3620. * only, and would normally not be used by applications.
  3621. * @param[in] avc a pointer to an arbitrary struct of which the first field is
  3622. * a pointer to an AVClass struct
  3623. * @param[in] feature string containing the name of the missing feature
  3624. * @param[in] want_sample indicates if samples are wanted which exhibit this feature.
  3625. * If want_sample is non-zero, additional verbage will be added to the log
  3626. * message which tells the user how to report samples to the development
  3627. * mailing list.
  3628. */
  3629. void av_log_missing_feature(void *avc, const char *feature, int want_sample);
  3630. /**
  3631. * Log a generic warning message asking for a sample. This function is
  3632. * intended to be used internally by FFmpeg (libavcodec, libavformat, etc.)
  3633. * only, and would normally not be used by applications.
  3634. * @param[in] avc a pointer to an arbitrary struct of which the first field is
  3635. * a pointer to an AVClass struct
  3636. * @param[in] msg string containing an optional message, or NULL if no message
  3637. */
  3638. void av_log_ask_for_sample(void *avc, const char *msg);
  3639. /**
  3640. * Register the hardware accelerator hwaccel.
  3641. */
  3642. void av_register_hwaccel(AVHWAccel *hwaccel);
  3643. /**
  3644. * If hwaccel is NULL, returns the first registered hardware accelerator,
  3645. * if hwaccel is non-NULL, returns the next registered hardware accelerator
  3646. * after hwaccel, or NULL if hwaccel is the last one.
  3647. */
  3648. AVHWAccel *av_hwaccel_next(AVHWAccel *hwaccel);
  3649. /**
  3650. * Lock operation used by lockmgr
  3651. */
  3652. enum AVLockOp {
  3653. AV_LOCK_CREATE, ///< Create a mutex
  3654. AV_LOCK_OBTAIN, ///< Lock the mutex
  3655. AV_LOCK_RELEASE, ///< Unlock the mutex
  3656. AV_LOCK_DESTROY, ///< Free mutex resources
  3657. };
  3658. /**
  3659. * Register a user provided lock manager supporting the operations
  3660. * specified by AVLockOp. mutex points to a (void *) where the
  3661. * lockmgr should store/get a pointer to a user allocated mutex. It's
  3662. * NULL upon AV_LOCK_CREATE and != NULL for all other ops.
  3663. *
  3664. * @param cb User defined callback. Note: FFmpeg may invoke calls to this
  3665. * callback during the call to av_lockmgr_register().
  3666. * Thus, the application must be prepared to handle that.
  3667. * If cb is set to NULL the lockmgr will be unregistered.
  3668. * Also note that during unregistration the previously registered
  3669. * lockmgr callback may also be invoked.
  3670. */
  3671. int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op));
  3672. #endif /* AVCODEC_AVCODEC_H */