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.

4714 lines
153KB

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