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.

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