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.

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