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.

4742 lines
154KB

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