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.

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