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.

4876 lines
160KB

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