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.

5112 lines
173KB

  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. * @ingroup libavc
  25. * Libavcodec external API header
  26. */
  27. #include <errno.h>
  28. #include "libavutil/samplefmt.h"
  29. #include "libavutil/attributes.h"
  30. #include "libavutil/avutil.h"
  31. #include "libavutil/buffer.h"
  32. #include "libavutil/cpu.h"
  33. #include "libavutil/channel_layout.h"
  34. #include "libavutil/dict.h"
  35. #include "libavutil/frame.h"
  36. #include "libavutil/log.h"
  37. #include "libavutil/pixfmt.h"
  38. #include "libavutil/rational.h"
  39. #include "version.h"
  40. #if FF_API_FAST_MALLOC
  41. // to provide fast_*alloc
  42. #include "libavutil/mem.h"
  43. #endif
  44. /**
  45. * @defgroup libavc Encoding/Decoding Library
  46. * @{
  47. *
  48. * @defgroup lavc_decoding Decoding
  49. * @{
  50. * @}
  51. *
  52. * @defgroup lavc_encoding Encoding
  53. * @{
  54. * @}
  55. *
  56. * @defgroup lavc_codec Codecs
  57. * @{
  58. * @defgroup lavc_codec_native Native Codecs
  59. * @{
  60. * @}
  61. * @defgroup lavc_codec_wrappers External library wrappers
  62. * @{
  63. * @}
  64. * @defgroup lavc_codec_hwaccel Hardware Accelerators bridge
  65. * @{
  66. * @}
  67. * @}
  68. * @defgroup lavc_internal Internal
  69. * @{
  70. * @}
  71. * @}
  72. *
  73. */
  74. /**
  75. * @defgroup lavc_core Core functions/structures.
  76. * @ingroup libavc
  77. *
  78. * Basic definitions, functions for querying libavcodec capabilities,
  79. * allocating core structures, etc.
  80. * @{
  81. */
  82. /**
  83. * Identify the syntax and semantics of the bitstream.
  84. * The principle is roughly:
  85. * Two decoders with the same ID can decode the same streams.
  86. * Two encoders with the same ID can encode compatible streams.
  87. * There may be slight deviations from the principle due to implementation
  88. * details.
  89. *
  90. * If you add a codec ID to this list, add it so that
  91. * 1. no value of a existing codec ID changes (that would break ABI),
  92. * 2. Give it a value which when taken as ASCII is recognized uniquely by a human as this specific codec.
  93. * This ensures that 2 forks can independently add AVCodecIDs without producing conflicts.
  94. *
  95. * After adding new codec IDs, do not forget to add an entry to the codec
  96. * descriptor list and bump libavcodec minor version.
  97. */
  98. enum AVCodecID {
  99. AV_CODEC_ID_NONE,
  100. /* video codecs */
  101. AV_CODEC_ID_MPEG1VIDEO,
  102. AV_CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding
  103. #if FF_API_XVMC
  104. AV_CODEC_ID_MPEG2VIDEO_XVMC,
  105. #endif /* FF_API_XVMC */
  106. AV_CODEC_ID_H261,
  107. AV_CODEC_ID_H263,
  108. AV_CODEC_ID_RV10,
  109. AV_CODEC_ID_RV20,
  110. AV_CODEC_ID_MJPEG,
  111. AV_CODEC_ID_MJPEGB,
  112. AV_CODEC_ID_LJPEG,
  113. AV_CODEC_ID_SP5X,
  114. AV_CODEC_ID_JPEGLS,
  115. AV_CODEC_ID_MPEG4,
  116. AV_CODEC_ID_RAWVIDEO,
  117. AV_CODEC_ID_MSMPEG4V1,
  118. AV_CODEC_ID_MSMPEG4V2,
  119. AV_CODEC_ID_MSMPEG4V3,
  120. AV_CODEC_ID_WMV1,
  121. AV_CODEC_ID_WMV2,
  122. AV_CODEC_ID_H263P,
  123. AV_CODEC_ID_H263I,
  124. AV_CODEC_ID_FLV1,
  125. AV_CODEC_ID_SVQ1,
  126. AV_CODEC_ID_SVQ3,
  127. AV_CODEC_ID_DVVIDEO,
  128. AV_CODEC_ID_HUFFYUV,
  129. AV_CODEC_ID_CYUV,
  130. AV_CODEC_ID_H264,
  131. AV_CODEC_ID_INDEO3,
  132. AV_CODEC_ID_VP3,
  133. AV_CODEC_ID_THEORA,
  134. AV_CODEC_ID_ASV1,
  135. AV_CODEC_ID_ASV2,
  136. AV_CODEC_ID_FFV1,
  137. AV_CODEC_ID_4XM,
  138. AV_CODEC_ID_VCR1,
  139. AV_CODEC_ID_CLJR,
  140. AV_CODEC_ID_MDEC,
  141. AV_CODEC_ID_ROQ,
  142. AV_CODEC_ID_INTERPLAY_VIDEO,
  143. AV_CODEC_ID_XAN_WC3,
  144. AV_CODEC_ID_XAN_WC4,
  145. AV_CODEC_ID_RPZA,
  146. AV_CODEC_ID_CINEPAK,
  147. AV_CODEC_ID_WS_VQA,
  148. AV_CODEC_ID_MSRLE,
  149. AV_CODEC_ID_MSVIDEO1,
  150. AV_CODEC_ID_IDCIN,
  151. AV_CODEC_ID_8BPS,
  152. AV_CODEC_ID_SMC,
  153. AV_CODEC_ID_FLIC,
  154. AV_CODEC_ID_TRUEMOTION1,
  155. AV_CODEC_ID_VMDVIDEO,
  156. AV_CODEC_ID_MSZH,
  157. AV_CODEC_ID_ZLIB,
  158. AV_CODEC_ID_QTRLE,
  159. AV_CODEC_ID_TSCC,
  160. AV_CODEC_ID_ULTI,
  161. AV_CODEC_ID_QDRAW,
  162. AV_CODEC_ID_VIXL,
  163. AV_CODEC_ID_QPEG,
  164. AV_CODEC_ID_PNG,
  165. AV_CODEC_ID_PPM,
  166. AV_CODEC_ID_PBM,
  167. AV_CODEC_ID_PGM,
  168. AV_CODEC_ID_PGMYUV,
  169. AV_CODEC_ID_PAM,
  170. AV_CODEC_ID_FFVHUFF,
  171. AV_CODEC_ID_RV30,
  172. AV_CODEC_ID_RV40,
  173. AV_CODEC_ID_VC1,
  174. AV_CODEC_ID_WMV3,
  175. AV_CODEC_ID_LOCO,
  176. AV_CODEC_ID_WNV1,
  177. AV_CODEC_ID_AASC,
  178. AV_CODEC_ID_INDEO2,
  179. AV_CODEC_ID_FRAPS,
  180. AV_CODEC_ID_TRUEMOTION2,
  181. AV_CODEC_ID_BMP,
  182. AV_CODEC_ID_CSCD,
  183. AV_CODEC_ID_MMVIDEO,
  184. AV_CODEC_ID_ZMBV,
  185. AV_CODEC_ID_AVS,
  186. AV_CODEC_ID_SMACKVIDEO,
  187. AV_CODEC_ID_NUV,
  188. AV_CODEC_ID_KMVC,
  189. AV_CODEC_ID_FLASHSV,
  190. AV_CODEC_ID_CAVS,
  191. AV_CODEC_ID_JPEG2000,
  192. AV_CODEC_ID_VMNC,
  193. AV_CODEC_ID_VP5,
  194. AV_CODEC_ID_VP6,
  195. AV_CODEC_ID_VP6F,
  196. AV_CODEC_ID_TARGA,
  197. AV_CODEC_ID_DSICINVIDEO,
  198. AV_CODEC_ID_TIERTEXSEQVIDEO,
  199. AV_CODEC_ID_TIFF,
  200. AV_CODEC_ID_GIF,
  201. AV_CODEC_ID_DXA,
  202. AV_CODEC_ID_DNXHD,
  203. AV_CODEC_ID_THP,
  204. AV_CODEC_ID_SGI,
  205. AV_CODEC_ID_C93,
  206. AV_CODEC_ID_BETHSOFTVID,
  207. AV_CODEC_ID_PTX,
  208. AV_CODEC_ID_TXD,
  209. AV_CODEC_ID_VP6A,
  210. AV_CODEC_ID_AMV,
  211. AV_CODEC_ID_VB,
  212. AV_CODEC_ID_PCX,
  213. AV_CODEC_ID_SUNRAST,
  214. AV_CODEC_ID_INDEO4,
  215. AV_CODEC_ID_INDEO5,
  216. AV_CODEC_ID_MIMIC,
  217. AV_CODEC_ID_RL2,
  218. AV_CODEC_ID_ESCAPE124,
  219. AV_CODEC_ID_DIRAC,
  220. AV_CODEC_ID_BFI,
  221. AV_CODEC_ID_CMV,
  222. AV_CODEC_ID_MOTIONPIXELS,
  223. AV_CODEC_ID_TGV,
  224. AV_CODEC_ID_TGQ,
  225. AV_CODEC_ID_TQI,
  226. AV_CODEC_ID_AURA,
  227. AV_CODEC_ID_AURA2,
  228. AV_CODEC_ID_V210X,
  229. AV_CODEC_ID_TMV,
  230. AV_CODEC_ID_V210,
  231. AV_CODEC_ID_DPX,
  232. AV_CODEC_ID_MAD,
  233. AV_CODEC_ID_FRWU,
  234. AV_CODEC_ID_FLASHSV2,
  235. AV_CODEC_ID_CDGRAPHICS,
  236. AV_CODEC_ID_R210,
  237. AV_CODEC_ID_ANM,
  238. AV_CODEC_ID_BINKVIDEO,
  239. AV_CODEC_ID_IFF_ILBM,
  240. AV_CODEC_ID_IFF_BYTERUN1,
  241. AV_CODEC_ID_KGV1,
  242. AV_CODEC_ID_YOP,
  243. AV_CODEC_ID_VP8,
  244. AV_CODEC_ID_PICTOR,
  245. AV_CODEC_ID_ANSI,
  246. AV_CODEC_ID_A64_MULTI,
  247. AV_CODEC_ID_A64_MULTI5,
  248. AV_CODEC_ID_R10K,
  249. AV_CODEC_ID_MXPEG,
  250. AV_CODEC_ID_LAGARITH,
  251. AV_CODEC_ID_PRORES,
  252. AV_CODEC_ID_JV,
  253. AV_CODEC_ID_DFA,
  254. AV_CODEC_ID_WMV3IMAGE,
  255. AV_CODEC_ID_VC1IMAGE,
  256. AV_CODEC_ID_UTVIDEO,
  257. AV_CODEC_ID_BMV_VIDEO,
  258. AV_CODEC_ID_VBLE,
  259. AV_CODEC_ID_DXTORY,
  260. AV_CODEC_ID_V410,
  261. AV_CODEC_ID_XWD,
  262. AV_CODEC_ID_CDXL,
  263. AV_CODEC_ID_XBM,
  264. AV_CODEC_ID_ZEROCODEC,
  265. AV_CODEC_ID_MSS1,
  266. AV_CODEC_ID_MSA1,
  267. AV_CODEC_ID_TSCC2,
  268. AV_CODEC_ID_MTS2,
  269. AV_CODEC_ID_CLLC,
  270. AV_CODEC_ID_MSS2,
  271. AV_CODEC_ID_VP9,
  272. AV_CODEC_ID_AIC,
  273. AV_CODEC_ID_ESCAPE130_DEPRECATED,
  274. AV_CODEC_ID_G2M_DEPRECATED,
  275. AV_CODEC_ID_WEBP_DEPRECATED,
  276. AV_CODEC_ID_HNM4_VIDEO,
  277. AV_CODEC_ID_HEVC_DEPRECATED,
  278. AV_CODEC_ID_FIC,
  279. AV_CODEC_ID_ALIAS_PIX,
  280. AV_CODEC_ID_BRENDER_PIX_DEPRECATED,
  281. AV_CODEC_ID_BRENDER_PIX= MKBETAG('B','P','I','X'),
  282. AV_CODEC_ID_Y41P = MKBETAG('Y','4','1','P'),
  283. AV_CODEC_ID_ESCAPE130 = MKBETAG('E','1','3','0'),
  284. AV_CODEC_ID_EXR = MKBETAG('0','E','X','R'),
  285. AV_CODEC_ID_AVRP = MKBETAG('A','V','R','P'),
  286. AV_CODEC_ID_012V = MKBETAG('0','1','2','V'),
  287. AV_CODEC_ID_G2M = MKBETAG( 0 ,'G','2','M'),
  288. AV_CODEC_ID_AVUI = MKBETAG('A','V','U','I'),
  289. AV_CODEC_ID_AYUV = MKBETAG('A','Y','U','V'),
  290. AV_CODEC_ID_TARGA_Y216 = MKBETAG('T','2','1','6'),
  291. AV_CODEC_ID_V308 = MKBETAG('V','3','0','8'),
  292. AV_CODEC_ID_V408 = MKBETAG('V','4','0','8'),
  293. AV_CODEC_ID_YUV4 = MKBETAG('Y','U','V','4'),
  294. AV_CODEC_ID_SANM = MKBETAG('S','A','N','M'),
  295. AV_CODEC_ID_PAF_VIDEO = MKBETAG('P','A','F','V'),
  296. AV_CODEC_ID_AVRN = MKBETAG('A','V','R','n'),
  297. AV_CODEC_ID_CPIA = MKBETAG('C','P','I','A'),
  298. AV_CODEC_ID_XFACE = MKBETAG('X','F','A','C'),
  299. AV_CODEC_ID_SGIRLE = MKBETAG('S','G','I','R'),
  300. AV_CODEC_ID_MVC1 = MKBETAG('M','V','C','1'),
  301. AV_CODEC_ID_MVC2 = MKBETAG('M','V','C','2'),
  302. AV_CODEC_ID_SNOW = MKBETAG('S','N','O','W'),
  303. AV_CODEC_ID_WEBP = MKBETAG('W','E','B','P'),
  304. AV_CODEC_ID_SMVJPEG = MKBETAG('S','M','V','J'),
  305. AV_CODEC_ID_HEVC = MKBETAG('H','2','6','5'),
  306. #define AV_CODEC_ID_H265 AV_CODEC_ID_HEVC
  307. AV_CODEC_ID_VP7 = MKBETAG('V','P','7','0'),
  308. /* various PCM "codecs" */
  309. AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
  310. AV_CODEC_ID_PCM_S16LE = 0x10000,
  311. AV_CODEC_ID_PCM_S16BE,
  312. AV_CODEC_ID_PCM_U16LE,
  313. AV_CODEC_ID_PCM_U16BE,
  314. AV_CODEC_ID_PCM_S8,
  315. AV_CODEC_ID_PCM_U8,
  316. AV_CODEC_ID_PCM_MULAW,
  317. AV_CODEC_ID_PCM_ALAW,
  318. AV_CODEC_ID_PCM_S32LE,
  319. AV_CODEC_ID_PCM_S32BE,
  320. AV_CODEC_ID_PCM_U32LE,
  321. AV_CODEC_ID_PCM_U32BE,
  322. AV_CODEC_ID_PCM_S24LE,
  323. AV_CODEC_ID_PCM_S24BE,
  324. AV_CODEC_ID_PCM_U24LE,
  325. AV_CODEC_ID_PCM_U24BE,
  326. AV_CODEC_ID_PCM_S24DAUD,
  327. AV_CODEC_ID_PCM_ZORK,
  328. AV_CODEC_ID_PCM_S16LE_PLANAR,
  329. AV_CODEC_ID_PCM_DVD,
  330. AV_CODEC_ID_PCM_F32BE,
  331. AV_CODEC_ID_PCM_F32LE,
  332. AV_CODEC_ID_PCM_F64BE,
  333. AV_CODEC_ID_PCM_F64LE,
  334. AV_CODEC_ID_PCM_BLURAY,
  335. AV_CODEC_ID_PCM_LXF,
  336. AV_CODEC_ID_S302M,
  337. AV_CODEC_ID_PCM_S8_PLANAR,
  338. AV_CODEC_ID_PCM_S24LE_PLANAR_DEPRECATED,
  339. AV_CODEC_ID_PCM_S32LE_PLANAR_DEPRECATED,
  340. AV_CODEC_ID_PCM_S24LE_PLANAR = MKBETAG(24,'P','S','P'),
  341. AV_CODEC_ID_PCM_S32LE_PLANAR = MKBETAG(32,'P','S','P'),
  342. AV_CODEC_ID_PCM_S16BE_PLANAR = MKBETAG('P','S','P',16),
  343. /* various ADPCM codecs */
  344. AV_CODEC_ID_ADPCM_IMA_QT = 0x11000,
  345. AV_CODEC_ID_ADPCM_IMA_WAV,
  346. AV_CODEC_ID_ADPCM_IMA_DK3,
  347. AV_CODEC_ID_ADPCM_IMA_DK4,
  348. AV_CODEC_ID_ADPCM_IMA_WS,
  349. AV_CODEC_ID_ADPCM_IMA_SMJPEG,
  350. AV_CODEC_ID_ADPCM_MS,
  351. AV_CODEC_ID_ADPCM_4XM,
  352. AV_CODEC_ID_ADPCM_XA,
  353. AV_CODEC_ID_ADPCM_ADX,
  354. AV_CODEC_ID_ADPCM_EA,
  355. AV_CODEC_ID_ADPCM_G726,
  356. AV_CODEC_ID_ADPCM_CT,
  357. AV_CODEC_ID_ADPCM_SWF,
  358. AV_CODEC_ID_ADPCM_YAMAHA,
  359. AV_CODEC_ID_ADPCM_SBPRO_4,
  360. AV_CODEC_ID_ADPCM_SBPRO_3,
  361. AV_CODEC_ID_ADPCM_SBPRO_2,
  362. AV_CODEC_ID_ADPCM_THP,
  363. AV_CODEC_ID_ADPCM_IMA_AMV,
  364. AV_CODEC_ID_ADPCM_EA_R1,
  365. AV_CODEC_ID_ADPCM_EA_R3,
  366. AV_CODEC_ID_ADPCM_EA_R2,
  367. AV_CODEC_ID_ADPCM_IMA_EA_SEAD,
  368. AV_CODEC_ID_ADPCM_IMA_EA_EACS,
  369. AV_CODEC_ID_ADPCM_EA_XAS,
  370. AV_CODEC_ID_ADPCM_EA_MAXIS_XA,
  371. AV_CODEC_ID_ADPCM_IMA_ISS,
  372. AV_CODEC_ID_ADPCM_G722,
  373. AV_CODEC_ID_ADPCM_IMA_APC,
  374. AV_CODEC_ID_VIMA = MKBETAG('V','I','M','A'),
  375. AV_CODEC_ID_ADPCM_AFC = MKBETAG('A','F','C',' '),
  376. AV_CODEC_ID_ADPCM_IMA_OKI = MKBETAG('O','K','I',' '),
  377. AV_CODEC_ID_ADPCM_DTK = MKBETAG('D','T','K',' '),
  378. AV_CODEC_ID_ADPCM_IMA_RAD = MKBETAG('R','A','D',' '),
  379. AV_CODEC_ID_ADPCM_G726LE = MKBETAG('6','2','7','G'),
  380. /* AMR */
  381. AV_CODEC_ID_AMR_NB = 0x12000,
  382. AV_CODEC_ID_AMR_WB,
  383. /* RealAudio codecs*/
  384. AV_CODEC_ID_RA_144 = 0x13000,
  385. AV_CODEC_ID_RA_288,
  386. /* various DPCM codecs */
  387. AV_CODEC_ID_ROQ_DPCM = 0x14000,
  388. AV_CODEC_ID_INTERPLAY_DPCM,
  389. AV_CODEC_ID_XAN_DPCM,
  390. AV_CODEC_ID_SOL_DPCM,
  391. /* audio codecs */
  392. AV_CODEC_ID_MP2 = 0x15000,
  393. AV_CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3
  394. AV_CODEC_ID_AAC,
  395. AV_CODEC_ID_AC3,
  396. AV_CODEC_ID_DTS,
  397. AV_CODEC_ID_VORBIS,
  398. AV_CODEC_ID_DVAUDIO,
  399. AV_CODEC_ID_WMAV1,
  400. AV_CODEC_ID_WMAV2,
  401. AV_CODEC_ID_MACE3,
  402. AV_CODEC_ID_MACE6,
  403. AV_CODEC_ID_VMDAUDIO,
  404. AV_CODEC_ID_FLAC,
  405. AV_CODEC_ID_MP3ADU,
  406. AV_CODEC_ID_MP3ON4,
  407. AV_CODEC_ID_SHORTEN,
  408. AV_CODEC_ID_ALAC,
  409. AV_CODEC_ID_WESTWOOD_SND1,
  410. AV_CODEC_ID_GSM, ///< as in Berlin toast format
  411. AV_CODEC_ID_QDM2,
  412. AV_CODEC_ID_COOK,
  413. AV_CODEC_ID_TRUESPEECH,
  414. AV_CODEC_ID_TTA,
  415. AV_CODEC_ID_SMACKAUDIO,
  416. AV_CODEC_ID_QCELP,
  417. AV_CODEC_ID_WAVPACK,
  418. AV_CODEC_ID_DSICINAUDIO,
  419. AV_CODEC_ID_IMC,
  420. AV_CODEC_ID_MUSEPACK7,
  421. AV_CODEC_ID_MLP,
  422. AV_CODEC_ID_GSM_MS, /* as found in WAV */
  423. AV_CODEC_ID_ATRAC3,
  424. #if FF_API_VOXWARE
  425. AV_CODEC_ID_VOXWARE,
  426. #endif
  427. AV_CODEC_ID_APE,
  428. AV_CODEC_ID_NELLYMOSER,
  429. AV_CODEC_ID_MUSEPACK8,
  430. AV_CODEC_ID_SPEEX,
  431. AV_CODEC_ID_WMAVOICE,
  432. AV_CODEC_ID_WMAPRO,
  433. AV_CODEC_ID_WMALOSSLESS,
  434. AV_CODEC_ID_ATRAC3P,
  435. AV_CODEC_ID_EAC3,
  436. AV_CODEC_ID_SIPR,
  437. AV_CODEC_ID_MP1,
  438. AV_CODEC_ID_TWINVQ,
  439. AV_CODEC_ID_TRUEHD,
  440. AV_CODEC_ID_MP4ALS,
  441. AV_CODEC_ID_ATRAC1,
  442. AV_CODEC_ID_BINKAUDIO_RDFT,
  443. AV_CODEC_ID_BINKAUDIO_DCT,
  444. AV_CODEC_ID_AAC_LATM,
  445. AV_CODEC_ID_QDMC,
  446. AV_CODEC_ID_CELT,
  447. AV_CODEC_ID_G723_1,
  448. AV_CODEC_ID_G729,
  449. AV_CODEC_ID_8SVX_EXP,
  450. AV_CODEC_ID_8SVX_FIB,
  451. AV_CODEC_ID_BMV_AUDIO,
  452. AV_CODEC_ID_RALF,
  453. AV_CODEC_ID_IAC,
  454. AV_CODEC_ID_ILBC,
  455. AV_CODEC_ID_OPUS_DEPRECATED,
  456. AV_CODEC_ID_COMFORT_NOISE,
  457. AV_CODEC_ID_TAK_DEPRECATED,
  458. AV_CODEC_ID_METASOUND,
  459. AV_CODEC_ID_FFWAVESYNTH = MKBETAG('F','F','W','S'),
  460. AV_CODEC_ID_SONIC = MKBETAG('S','O','N','C'),
  461. AV_CODEC_ID_SONIC_LS = MKBETAG('S','O','N','L'),
  462. AV_CODEC_ID_PAF_AUDIO = MKBETAG('P','A','F','A'),
  463. AV_CODEC_ID_OPUS = MKBETAG('O','P','U','S'),
  464. AV_CODEC_ID_TAK = MKBETAG('t','B','a','K'),
  465. AV_CODEC_ID_EVRC = MKBETAG('s','e','v','c'),
  466. AV_CODEC_ID_SMV = MKBETAG('s','s','m','v'),
  467. /* subtitle codecs */
  468. AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs.
  469. AV_CODEC_ID_DVD_SUBTITLE = 0x17000,
  470. AV_CODEC_ID_DVB_SUBTITLE,
  471. AV_CODEC_ID_TEXT, ///< raw UTF-8 text
  472. AV_CODEC_ID_XSUB,
  473. AV_CODEC_ID_SSA,
  474. AV_CODEC_ID_MOV_TEXT,
  475. AV_CODEC_ID_HDMV_PGS_SUBTITLE,
  476. AV_CODEC_ID_DVB_TELETEXT,
  477. AV_CODEC_ID_SRT,
  478. AV_CODEC_ID_MICRODVD = MKBETAG('m','D','V','D'),
  479. AV_CODEC_ID_EIA_608 = MKBETAG('c','6','0','8'),
  480. AV_CODEC_ID_JACOSUB = MKBETAG('J','S','U','B'),
  481. AV_CODEC_ID_SAMI = MKBETAG('S','A','M','I'),
  482. AV_CODEC_ID_REALTEXT = MKBETAG('R','T','X','T'),
  483. AV_CODEC_ID_SUBVIEWER1 = MKBETAG('S','b','V','1'),
  484. AV_CODEC_ID_SUBVIEWER = MKBETAG('S','u','b','V'),
  485. AV_CODEC_ID_SUBRIP = MKBETAG('S','R','i','p'),
  486. AV_CODEC_ID_WEBVTT = MKBETAG('W','V','T','T'),
  487. AV_CODEC_ID_MPL2 = MKBETAG('M','P','L','2'),
  488. AV_CODEC_ID_VPLAYER = MKBETAG('V','P','l','r'),
  489. AV_CODEC_ID_PJS = MKBETAG('P','h','J','S'),
  490. AV_CODEC_ID_ASS = MKBETAG('A','S','S',' '), ///< ASS as defined in Matroska
  491. /* other specific kind of codecs (generally used for attachments) */
  492. AV_CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs.
  493. AV_CODEC_ID_TTF = 0x18000,
  494. AV_CODEC_ID_BINTEXT = MKBETAG('B','T','X','T'),
  495. AV_CODEC_ID_XBIN = MKBETAG('X','B','I','N'),
  496. AV_CODEC_ID_IDF = MKBETAG( 0 ,'I','D','F'),
  497. AV_CODEC_ID_OTF = MKBETAG( 0 ,'O','T','F'),
  498. AV_CODEC_ID_SMPTE_KLV = MKBETAG('K','L','V','A'),
  499. AV_CODEC_ID_DVD_NAV = MKBETAG('D','N','A','V'),
  500. AV_CODEC_ID_TIMED_ID3 = MKBETAG('T','I','D','3'),
  501. AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it
  502. AV_CODEC_ID_MPEG2TS = 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS
  503. * stream (only used by libavformat) */
  504. AV_CODEC_ID_MPEG4SYSTEMS = 0x20001, /**< _FAKE_ codec to indicate a MPEG-4 Systems
  505. * stream (only used by libavformat) */
  506. AV_CODEC_ID_FFMETADATA = 0x21000, ///< Dummy codec for streams containing only metadata information.
  507. #if FF_API_CODEC_ID
  508. #include "old_codec_ids.h"
  509. #endif
  510. };
  511. /**
  512. * This struct describes the properties of a single codec described by an
  513. * AVCodecID.
  514. * @see avcodec_get_descriptor()
  515. */
  516. typedef struct AVCodecDescriptor {
  517. enum AVCodecID id;
  518. enum AVMediaType type;
  519. /**
  520. * Name of the codec described by this descriptor. It is non-empty and
  521. * unique for each codec descriptor. It should contain alphanumeric
  522. * characters and '_' only.
  523. */
  524. const char *name;
  525. /**
  526. * A more descriptive name for this codec. May be NULL.
  527. */
  528. const char *long_name;
  529. /**
  530. * Codec properties, a combination of AV_CODEC_PROP_* flags.
  531. */
  532. int props;
  533. } AVCodecDescriptor;
  534. /**
  535. * Codec uses only intra compression.
  536. * Video codecs only.
  537. */
  538. #define AV_CODEC_PROP_INTRA_ONLY (1 << 0)
  539. /**
  540. * Codec supports lossy compression. Audio and video codecs only.
  541. * @note a codec may support both lossy and lossless
  542. * compression modes
  543. */
  544. #define AV_CODEC_PROP_LOSSY (1 << 1)
  545. /**
  546. * Codec supports lossless compression. Audio and video codecs only.
  547. */
  548. #define AV_CODEC_PROP_LOSSLESS (1 << 2)
  549. /**
  550. * Subtitle codec is bitmap based
  551. * Decoded AVSubtitle data can be read from the AVSubtitleRect->pict field.
  552. */
  553. #define AV_CODEC_PROP_BITMAP_SUB (1 << 16)
  554. /**
  555. * Subtitle codec is text based.
  556. * Decoded AVSubtitle data can be read from the AVSubtitleRect->ass field.
  557. */
  558. #define AV_CODEC_PROP_TEXT_SUB (1 << 17)
  559. /**
  560. * @ingroup lavc_decoding
  561. * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
  562. * This is mainly needed because some optimized bitstream readers read
  563. * 32 or 64 bit at once and could read over the end.<br>
  564. * Note: If the first 23 bits of the additional bytes are not 0, then damaged
  565. * MPEG bitstreams could cause overread and segfault.
  566. */
  567. #define FF_INPUT_BUFFER_PADDING_SIZE 16
  568. /**
  569. * @ingroup lavc_encoding
  570. * minimum encoding buffer size
  571. * Used to avoid some checks during header writing.
  572. */
  573. #define FF_MIN_BUFFER_SIZE 16384
  574. /**
  575. * @ingroup lavc_encoding
  576. * motion estimation type.
  577. */
  578. enum Motion_Est_ID {
  579. ME_ZERO = 1, ///< no search, that is use 0,0 vector whenever one is needed
  580. ME_FULL,
  581. ME_LOG,
  582. ME_PHODS,
  583. ME_EPZS, ///< enhanced predictive zonal search
  584. ME_X1, ///< reserved for experiments
  585. ME_HEX, ///< hexagon based search
  586. ME_UMH, ///< uneven multi-hexagon search
  587. ME_TESA, ///< transformed exhaustive search algorithm
  588. ME_ITER=50, ///< iterative search
  589. };
  590. /**
  591. * @ingroup lavc_decoding
  592. */
  593. enum AVDiscard{
  594. /* We leave some space between them for extensions (drop some
  595. * keyframes for intra-only or drop just some bidir frames). */
  596. AVDISCARD_NONE =-16, ///< discard nothing
  597. AVDISCARD_DEFAULT = 0, ///< discard useless packets like 0 size packets in avi
  598. AVDISCARD_NONREF = 8, ///< discard all non reference
  599. AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames
  600. AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes
  601. AVDISCARD_ALL = 48, ///< discard all
  602. };
  603. enum AVColorPrimaries{
  604. AVCOL_PRI_BT709 = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B
  605. AVCOL_PRI_UNSPECIFIED = 2,
  606. AVCOL_PRI_BT470M = 4,
  607. AVCOL_PRI_BT470BG = 5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
  608. AVCOL_PRI_SMPTE170M = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
  609. AVCOL_PRI_SMPTE240M = 7, ///< functionally identical to above
  610. AVCOL_PRI_FILM = 8,
  611. AVCOL_PRI_BT2020 = 9, ///< ITU-R BT2020
  612. AVCOL_PRI_NB , ///< Not part of ABI
  613. };
  614. enum AVColorTransferCharacteristic{
  615. AVCOL_TRC_BT709 = 1, ///< also ITU-R BT1361
  616. AVCOL_TRC_UNSPECIFIED = 2,
  617. AVCOL_TRC_GAMMA22 = 4, ///< also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
  618. AVCOL_TRC_GAMMA28 = 5, ///< also ITU-R BT470BG
  619. AVCOL_TRC_SMPTE170M = 6, ///< also ITU-R BT601-6 525 or 625 / ITU-R BT1358 525 or 625 / ITU-R BT1700 NTSC
  620. AVCOL_TRC_SMPTE240M = 7,
  621. AVCOL_TRC_LINEAR = 8, ///< "Linear transfer characteristics"
  622. AVCOL_TRC_LOG = 9, ///< "Logarithmic transfer characteristic (100:1 range)"
  623. AVCOL_TRC_LOG_SQRT = 10, ///< "Logarithmic transfer characteristic (100 * Sqrt( 10 ) : 1 range)"
  624. AVCOL_TRC_IEC61966_2_4 = 11, ///< IEC 61966-2-4
  625. AVCOL_TRC_BT1361_ECG = 12, ///< ITU-R BT1361 Extended Colour Gamut
  626. AVCOL_TRC_IEC61966_2_1 = 13, ///< IEC 61966-2-1 (sRGB or sYCC)
  627. AVCOL_TRC_BT2020_10 = 14, ///< ITU-R BT2020 for 10 bit system
  628. AVCOL_TRC_BT2020_12 = 15, ///< ITU-R BT2020 for 12 bit system
  629. AVCOL_TRC_NB , ///< Not part of ABI
  630. };
  631. /**
  632. * X X 3 4 X X are luma samples,
  633. * 1 2 1-6 are possible chroma positions
  634. * X X 5 6 X 0 is undefined/unknown position
  635. */
  636. enum AVChromaLocation{
  637. AVCHROMA_LOC_UNSPECIFIED = 0,
  638. AVCHROMA_LOC_LEFT = 1, ///< mpeg2/4, h264 default
  639. AVCHROMA_LOC_CENTER = 2, ///< mpeg1, jpeg, h263
  640. AVCHROMA_LOC_TOPLEFT = 3, ///< DV
  641. AVCHROMA_LOC_TOP = 4,
  642. AVCHROMA_LOC_BOTTOMLEFT = 5,
  643. AVCHROMA_LOC_BOTTOM = 6,
  644. AVCHROMA_LOC_NB , ///< Not part of ABI
  645. };
  646. enum AVAudioServiceType {
  647. AV_AUDIO_SERVICE_TYPE_MAIN = 0,
  648. AV_AUDIO_SERVICE_TYPE_EFFECTS = 1,
  649. AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED = 2,
  650. AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED = 3,
  651. AV_AUDIO_SERVICE_TYPE_DIALOGUE = 4,
  652. AV_AUDIO_SERVICE_TYPE_COMMENTARY = 5,
  653. AV_AUDIO_SERVICE_TYPE_EMERGENCY = 6,
  654. AV_AUDIO_SERVICE_TYPE_VOICE_OVER = 7,
  655. AV_AUDIO_SERVICE_TYPE_KARAOKE = 8,
  656. AV_AUDIO_SERVICE_TYPE_NB , ///< Not part of ABI
  657. };
  658. /**
  659. * @ingroup lavc_encoding
  660. */
  661. typedef struct RcOverride{
  662. int start_frame;
  663. int end_frame;
  664. int qscale; // If this is 0 then quality_factor will be used instead.
  665. float quality_factor;
  666. } RcOverride;
  667. #if FF_API_MAX_BFRAMES
  668. /**
  669. * @deprecated there is no libavcodec-wide limit on the number of B-frames
  670. */
  671. #define FF_MAX_B_FRAMES 16
  672. #endif
  673. /* encoding support
  674. These flags can be passed in AVCodecContext.flags before initialization.
  675. Note: Not everything is supported yet.
  676. */
  677. /**
  678. * Allow decoders to produce frames with data planes that are not aligned
  679. * to CPU requirements (e.g. due to cropping).
  680. */
  681. #define CODEC_FLAG_UNALIGNED 0x0001
  682. #define CODEC_FLAG_QSCALE 0x0002 ///< Use fixed qscale.
  683. #define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed / advanced prediction for H.263.
  684. #define CODEC_FLAG_OUTPUT_CORRUPT 0x0008 ///< Output even those frames that might be corrupted
  685. #define CODEC_FLAG_QPEL 0x0010 ///< Use qpel MC.
  686. #define CODEC_FLAG_GMC 0x0020 ///< Use GMC.
  687. #define CODEC_FLAG_MV0 0x0040 ///< Always try a MB with MV=<0,0>.
  688. /**
  689. * The parent program guarantees that the input for B-frames containing
  690. * streams is not written to for at least s->max_b_frames+1 frames, if
  691. * this is not set the input will be copied.
  692. */
  693. #define CODEC_FLAG_INPUT_PRESERVED 0x0100
  694. #define CODEC_FLAG_PASS1 0x0200 ///< Use internal 2pass ratecontrol in first pass mode.
  695. #define CODEC_FLAG_PASS2 0x0400 ///< Use internal 2pass ratecontrol in second pass mode.
  696. #define CODEC_FLAG_GRAY 0x2000 ///< Only decode/encode grayscale.
  697. #if FF_API_EMU_EDGE
  698. /**
  699. * @deprecated edges are not used/required anymore. I.e. this flag is now always
  700. * set.
  701. */
  702. #define CODEC_FLAG_EMU_EDGE 0x4000
  703. #endif
  704. #define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding.
  705. #define CODEC_FLAG_TRUNCATED 0x00010000 /** Input bitstream might be truncated at a random
  706. location instead of only at frame boundaries. */
  707. #define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< Normalize adaptive quantization.
  708. #define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< Use interlaced DCT.
  709. #define CODEC_FLAG_LOW_DELAY 0x00080000 ///< Force low delay.
  710. #define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< Place global headers in extradata instead of every keyframe.
  711. #define CODEC_FLAG_BITEXACT 0x00800000 ///< Use only bitexact stuff (except (I)DCT).
  712. /* Fx : Flag for h263+ extra options */
  713. #define CODEC_FLAG_AC_PRED 0x01000000 ///< H.263 advanced intra coding / MPEG-4 AC prediction
  714. #define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter
  715. #define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation
  716. #define CODEC_FLAG_CLOSED_GOP 0x80000000
  717. #define CODEC_FLAG2_FAST 0x00000001 ///< Allow non spec compliant speedup tricks.
  718. #define CODEC_FLAG2_NO_OUTPUT 0x00000004 ///< Skip bitstream encoding.
  719. #define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< Place global headers at every keyframe instead of in extradata.
  720. #define CODEC_FLAG2_DROP_FRAME_TIMECODE 0x00002000 ///< timecode is in drop frame format. DEPRECATED!!!!
  721. #define CODEC_FLAG2_IGNORE_CROP 0x00010000 ///< Discard cropping information from SPS.
  722. #define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries.
  723. #define CODEC_FLAG2_SHOW_ALL 0x00400000 ///< Show all frames before the first keyframe
  724. /* Unsupported options :
  725. * Syntax Arithmetic coding (SAC)
  726. * Reference Picture Selection
  727. * Independent Segment Decoding */
  728. /* /Fx */
  729. /* codec capabilities */
  730. #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< Decoder can use draw_horiz_band callback.
  731. /**
  732. * Codec uses get_buffer() for allocating buffers and supports custom allocators.
  733. * If not set, it might not use get_buffer() at all or use operations that
  734. * assume the buffer was allocated by avcodec_default_get_buffer.
  735. */
  736. #define CODEC_CAP_DR1 0x0002
  737. #define CODEC_CAP_TRUNCATED 0x0008
  738. #if FF_API_XVMC
  739. /* Codec can export data for HW decoding. This flag indicates that
  740. * the codec would call get_format() with list that might contain HW accelerated
  741. * pixel formats (XvMC, VDPAU, VAAPI, etc). The application can pick any of them
  742. * including raw image format.
  743. * The application can use the passed context to determine bitstream version,
  744. * chroma format, resolution etc.
  745. */
  746. #define CODEC_CAP_HWACCEL 0x0010
  747. #endif /* FF_API_XVMC */
  748. /**
  749. * Encoder or decoder requires flushing with NULL input at the end in order to
  750. * give the complete and correct output.
  751. *
  752. * NOTE: If this flag is not set, the codec is guaranteed to never be fed with
  753. * with NULL data. The user can still send NULL data to the public encode
  754. * or decode function, but libavcodec will not pass it along to the codec
  755. * unless this flag is set.
  756. *
  757. * Decoders:
  758. * The decoder has a non-zero delay and needs to be fed with avpkt->data=NULL,
  759. * avpkt->size=0 at the end to get the delayed data until the decoder no longer
  760. * returns frames.
  761. *
  762. * Encoders:
  763. * The encoder needs to be fed with NULL data at the end of encoding until the
  764. * encoder no longer returns data.
  765. *
  766. * NOTE: For encoders implementing the AVCodec.encode2() function, setting this
  767. * flag also means that the encoder must set the pts and duration for
  768. * each output packet. If this flag is not set, the pts and duration will
  769. * be determined by libavcodec from the input frame.
  770. */
  771. #define CODEC_CAP_DELAY 0x0020
  772. /**
  773. * Codec can be fed a final frame with a smaller size.
  774. * This can be used to prevent truncation of the last audio samples.
  775. */
  776. #define CODEC_CAP_SMALL_LAST_FRAME 0x0040
  777. #if FF_API_CAP_VDPAU
  778. /**
  779. * Codec can export data for HW decoding (VDPAU).
  780. */
  781. #define CODEC_CAP_HWACCEL_VDPAU 0x0080
  782. #endif
  783. /**
  784. * Codec can output multiple frames per AVPacket
  785. * Normally demuxers return one frame at a time, demuxers which do not do
  786. * are connected to a parser to split what they return into proper frames.
  787. * This flag is reserved to the very rare category of codecs which have a
  788. * bitstream that cannot be split into frames without timeconsuming
  789. * operations like full decoding. Demuxers carring such bitstreams thus
  790. * may return multiple frames in a packet. This has many disadvantages like
  791. * prohibiting stream copy in many cases thus it should only be considered
  792. * as a last resort.
  793. */
  794. #define CODEC_CAP_SUBFRAMES 0x0100
  795. /**
  796. * Codec is experimental and is thus avoided in favor of non experimental
  797. * encoders
  798. */
  799. #define CODEC_CAP_EXPERIMENTAL 0x0200
  800. /**
  801. * Codec should fill in channel configuration and samplerate instead of container
  802. */
  803. #define CODEC_CAP_CHANNEL_CONF 0x0400
  804. #if FF_API_NEG_LINESIZES
  805. /**
  806. * @deprecated no codecs use this capability
  807. */
  808. #define CODEC_CAP_NEG_LINESIZES 0x0800
  809. #endif
  810. /**
  811. * Codec supports frame-level multithreading.
  812. */
  813. #define CODEC_CAP_FRAME_THREADS 0x1000
  814. /**
  815. * Codec supports slice-based (or partition-based) multithreading.
  816. */
  817. #define CODEC_CAP_SLICE_THREADS 0x2000
  818. /**
  819. * Codec supports changed parameters at any point.
  820. */
  821. #define CODEC_CAP_PARAM_CHANGE 0x4000
  822. /**
  823. * Codec supports avctx->thread_count == 0 (auto).
  824. */
  825. #define CODEC_CAP_AUTO_THREADS 0x8000
  826. /**
  827. * Audio encoder supports receiving a different number of samples in each call.
  828. */
  829. #define CODEC_CAP_VARIABLE_FRAME_SIZE 0x10000
  830. /**
  831. * Codec is intra only.
  832. */
  833. #define CODEC_CAP_INTRA_ONLY 0x40000000
  834. /**
  835. * Codec is lossless.
  836. */
  837. #define CODEC_CAP_LOSSLESS 0x80000000
  838. #if FF_API_MB_TYPE
  839. //The following defines may change, don't expect compatibility if you use them.
  840. #define MB_TYPE_INTRA4x4 0x0001
  841. #define MB_TYPE_INTRA16x16 0x0002 //FIXME H.264-specific
  842. #define MB_TYPE_INTRA_PCM 0x0004 //FIXME H.264-specific
  843. #define MB_TYPE_16x16 0x0008
  844. #define MB_TYPE_16x8 0x0010
  845. #define MB_TYPE_8x16 0x0020
  846. #define MB_TYPE_8x8 0x0040
  847. #define MB_TYPE_INTERLACED 0x0080
  848. #define MB_TYPE_DIRECT2 0x0100 //FIXME
  849. #define MB_TYPE_ACPRED 0x0200
  850. #define MB_TYPE_GMC 0x0400
  851. #define MB_TYPE_SKIP 0x0800
  852. #define MB_TYPE_P0L0 0x1000
  853. #define MB_TYPE_P1L0 0x2000
  854. #define MB_TYPE_P0L1 0x4000
  855. #define MB_TYPE_P1L1 0x8000
  856. #define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0)
  857. #define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1)
  858. #define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1)
  859. #define MB_TYPE_QUANT 0x00010000
  860. #define MB_TYPE_CBP 0x00020000
  861. //Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...)
  862. #endif
  863. /**
  864. * Pan Scan area.
  865. * This specifies the area which should be displayed.
  866. * Note there may be multiple such areas for one frame.
  867. */
  868. typedef struct AVPanScan{
  869. /**
  870. * id
  871. * - encoding: Set by user.
  872. * - decoding: Set by libavcodec.
  873. */
  874. int id;
  875. /**
  876. * width and height in 1/16 pel
  877. * - encoding: Set by user.
  878. * - decoding: Set by libavcodec.
  879. */
  880. int width;
  881. int height;
  882. /**
  883. * position of the top left corner in 1/16 pel for up to 3 fields/frames
  884. * - encoding: Set by user.
  885. * - decoding: Set by libavcodec.
  886. */
  887. int16_t position[3][2];
  888. }AVPanScan;
  889. #if FF_API_QSCALE_TYPE
  890. #define FF_QSCALE_TYPE_MPEG1 0
  891. #define FF_QSCALE_TYPE_MPEG2 1
  892. #define FF_QSCALE_TYPE_H264 2
  893. #define FF_QSCALE_TYPE_VP56 3
  894. #endif
  895. #if FF_API_GET_BUFFER
  896. #define FF_BUFFER_TYPE_INTERNAL 1
  897. #define FF_BUFFER_TYPE_USER 2 ///< direct rendering buffers (image is (de)allocated by user)
  898. #define FF_BUFFER_TYPE_SHARED 4 ///< Buffer from somewhere else; don't deallocate image (data/base), all other tables are not shared.
  899. #define FF_BUFFER_TYPE_COPY 8 ///< Just a (modified) copy of some other buffer, don't deallocate anything.
  900. #define FF_BUFFER_HINTS_VALID 0x01 // Buffer hints value is meaningful (if 0 ignore).
  901. #define FF_BUFFER_HINTS_READABLE 0x02 // Codec will read from buffer.
  902. #define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content.
  903. #define FF_BUFFER_HINTS_REUSABLE 0x08 // Codec will reuse the buffer (update).
  904. #endif
  905. /**
  906. * The decoder will keep a reference to the frame and may reuse it later.
  907. */
  908. #define AV_GET_BUFFER_FLAG_REF (1 << 0)
  909. /**
  910. * @defgroup lavc_packet AVPacket
  911. *
  912. * Types and functions for working with AVPacket.
  913. * @{
  914. */
  915. enum AVPacketSideDataType {
  916. AV_PKT_DATA_PALETTE,
  917. AV_PKT_DATA_NEW_EXTRADATA,
  918. /**
  919. * An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:
  920. * @code
  921. * u32le param_flags
  922. * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT)
  923. * s32le channel_count
  924. * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT)
  925. * u64le channel_layout
  926. * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE)
  927. * s32le sample_rate
  928. * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS)
  929. * s32le width
  930. * s32le height
  931. * @endcode
  932. */
  933. AV_PKT_DATA_PARAM_CHANGE,
  934. /**
  935. * An AV_PKT_DATA_H263_MB_INFO side data packet contains a number of
  936. * structures with info about macroblocks relevant to splitting the
  937. * packet into smaller packets on macroblock edges (e.g. as for RFC 2190).
  938. * That is, it does not necessarily contain info about all macroblocks,
  939. * as long as the distance between macroblocks in the info is smaller
  940. * than the target payload size.
  941. * Each MB info structure is 12 bytes, and is laid out as follows:
  942. * @code
  943. * u32le bit offset from the start of the packet
  944. * u8 current quantizer at the start of the macroblock
  945. * u8 GOB number
  946. * u16le macroblock address within the GOB
  947. * u8 horizontal MV predictor
  948. * u8 vertical MV predictor
  949. * u8 horizontal MV predictor for block number 3
  950. * u8 vertical MV predictor for block number 3
  951. * @endcode
  952. */
  953. AV_PKT_DATA_H263_MB_INFO,
  954. /**
  955. * This side data should be associated with an audio stream and contains
  956. * ReplayGain information in form of the AVReplayGain struct.
  957. */
  958. AV_PKT_DATA_REPLAYGAIN,
  959. /**
  960. * Recommmends skipping the specified number of samples
  961. * @code
  962. * u32le number of samples to skip from start of this packet
  963. * u32le number of samples to skip from end of this packet
  964. * u8 reason for start skip
  965. * u8 reason for end skip (0=padding silence, 1=convergence)
  966. * @endcode
  967. */
  968. AV_PKT_DATA_SKIP_SAMPLES=70,
  969. /**
  970. * An AV_PKT_DATA_JP_DUALMONO side data packet indicates that
  971. * the packet may contain "dual mono" audio specific to Japanese DTV
  972. * and if it is true, recommends only the selected channel to be used.
  973. * @code
  974. * u8 selected channels (0=mail/left, 1=sub/right, 2=both)
  975. * @endcode
  976. */
  977. AV_PKT_DATA_JP_DUALMONO,
  978. /**
  979. * A list of zero terminated key/value strings. There is no end marker for
  980. * the list, so it is required to rely on the side data size to stop.
  981. */
  982. AV_PKT_DATA_STRINGS_METADATA,
  983. /**
  984. * Subtitle event position
  985. * @code
  986. * u32le x1
  987. * u32le y1
  988. * u32le x2
  989. * u32le y2
  990. * @endcode
  991. */
  992. AV_PKT_DATA_SUBTITLE_POSITION,
  993. /**
  994. * Data found in BlockAdditional element of matroska container. There is
  995. * no end marker for the data, so it is required to rely on the side data
  996. * size to recognize the end. 8 byte id (as found in BlockAddId) followed
  997. * by data.
  998. */
  999. AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL,
  1000. /**
  1001. * The optional first identifier line of a WebVTT cue.
  1002. */
  1003. AV_PKT_DATA_WEBVTT_IDENTIFIER,
  1004. /**
  1005. * The optional settings (rendering instructions) that immediately
  1006. * follow the timestamp specifier of a WebVTT cue.
  1007. */
  1008. AV_PKT_DATA_WEBVTT_SETTINGS,
  1009. /**
  1010. * A list of zero terminated key/value strings. There is no end marker for
  1011. * the list, so it is required to rely on the side data size to stop. This
  1012. * side data includes updated metadata which appeared in the stream.
  1013. */
  1014. AV_PKT_DATA_METADATA_UPDATE,
  1015. };
  1016. typedef struct AVPacketSideData {
  1017. uint8_t *data;
  1018. int size;
  1019. enum AVPacketSideDataType type;
  1020. } AVPacketSideData;
  1021. /**
  1022. * This structure stores compressed data. It is typically exported by demuxers
  1023. * and then passed as input to decoders, or received as output from encoders and
  1024. * then passed to muxers.
  1025. *
  1026. * For video, it should typically contain one compressed frame. For audio it may
  1027. * contain several compressed frames.
  1028. *
  1029. * AVPacket is one of the few structs in FFmpeg, whose size is a part of public
  1030. * ABI. Thus it may be allocated on stack and no new fields can be added to it
  1031. * without libavcodec and libavformat major bump.
  1032. *
  1033. * The semantics of data ownership depends on the buf or destruct (deprecated)
  1034. * fields. If either is set, the packet data is dynamically allocated and is
  1035. * valid indefinitely until av_free_packet() is called (which in turn calls
  1036. * av_buffer_unref()/the destruct callback to free the data). If neither is set,
  1037. * the packet data is typically backed by some static buffer somewhere and is
  1038. * only valid for a limited time (e.g. until the next read call when demuxing).
  1039. *
  1040. * The side data is always allocated with av_malloc() and is freed in
  1041. * av_free_packet().
  1042. */
  1043. typedef struct AVPacket {
  1044. /**
  1045. * A reference to the reference-counted buffer where the packet data is
  1046. * stored.
  1047. * May be NULL, then the packet data is not reference-counted.
  1048. */
  1049. AVBufferRef *buf;
  1050. /**
  1051. * Presentation timestamp in AVStream->time_base units; the time at which
  1052. * the decompressed packet will be presented to the user.
  1053. * Can be AV_NOPTS_VALUE if it is not stored in the file.
  1054. * pts MUST be larger or equal to dts as presentation cannot happen before
  1055. * decompression, unless one wants to view hex dumps. Some formats misuse
  1056. * the terms dts and pts/cts to mean something different. Such timestamps
  1057. * must be converted to true pts/dts before they are stored in AVPacket.
  1058. */
  1059. int64_t pts;
  1060. /**
  1061. * Decompression timestamp in AVStream->time_base units; the time at which
  1062. * the packet is decompressed.
  1063. * Can be AV_NOPTS_VALUE if it is not stored in the file.
  1064. */
  1065. int64_t dts;
  1066. uint8_t *data;
  1067. int size;
  1068. int stream_index;
  1069. /**
  1070. * A combination of AV_PKT_FLAG values
  1071. */
  1072. int flags;
  1073. /**
  1074. * Additional packet data that can be provided by the container.
  1075. * Packet can contain several types of side information.
  1076. */
  1077. AVPacketSideData *side_data;
  1078. int side_data_elems;
  1079. /**
  1080. * Duration of this packet in AVStream->time_base units, 0 if unknown.
  1081. * Equals next_pts - this_pts in presentation order.
  1082. */
  1083. int duration;
  1084. #if FF_API_DESTRUCT_PACKET
  1085. attribute_deprecated
  1086. void (*destruct)(struct AVPacket *);
  1087. attribute_deprecated
  1088. void *priv;
  1089. #endif
  1090. int64_t pos; ///< byte position in stream, -1 if unknown
  1091. /**
  1092. * Time difference in AVStream->time_base units from the pts of this
  1093. * packet to the point at which the output from the decoder has converged
  1094. * independent from the availability of previous frames. That is, the
  1095. * frames are virtually identical no matter if decoding started from
  1096. * the very first frame or from this keyframe.
  1097. * Is AV_NOPTS_VALUE if unknown.
  1098. * This field is not the display duration of the current packet.
  1099. * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY
  1100. * set.
  1101. *
  1102. * The purpose of this field is to allow seeking in streams that have no
  1103. * keyframes in the conventional sense. It corresponds to the
  1104. * recovery point SEI in H.264 and match_time_delta in NUT. It is also
  1105. * essential for some types of subtitle streams to ensure that all
  1106. * subtitles are correctly displayed after seeking.
  1107. */
  1108. int64_t convergence_duration;
  1109. } AVPacket;
  1110. #define AV_PKT_FLAG_KEY 0x0001 ///< The packet contains a keyframe
  1111. #define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted
  1112. enum AVSideDataParamChangeFlags {
  1113. AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT = 0x0001,
  1114. AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002,
  1115. AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE = 0x0004,
  1116. AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = 0x0008,
  1117. };
  1118. /**
  1119. * @}
  1120. */
  1121. struct AVCodecInternal;
  1122. enum AVFieldOrder {
  1123. AV_FIELD_UNKNOWN,
  1124. AV_FIELD_PROGRESSIVE,
  1125. AV_FIELD_TT, //< Top coded_first, top displayed first
  1126. AV_FIELD_BB, //< Bottom coded first, bottom displayed first
  1127. AV_FIELD_TB, //< Top coded first, bottom displayed first
  1128. AV_FIELD_BT, //< Bottom coded first, top displayed first
  1129. };
  1130. /**
  1131. * main external API structure.
  1132. * New fields can be added to the end with minor version bumps.
  1133. * Removal, reordering and changes to existing fields require a major
  1134. * version bump.
  1135. * Please use AVOptions (av_opt* / av_set/get*()) to access these fields from user
  1136. * applications.
  1137. * sizeof(AVCodecContext) must not be used outside libav*.
  1138. */
  1139. typedef struct AVCodecContext {
  1140. /**
  1141. * information on struct for av_log
  1142. * - set by avcodec_alloc_context3
  1143. */
  1144. const AVClass *av_class;
  1145. int log_level_offset;
  1146. enum AVMediaType codec_type; /* see AVMEDIA_TYPE_xxx */
  1147. const struct AVCodec *codec;
  1148. char codec_name[32];
  1149. enum AVCodecID codec_id; /* see AV_CODEC_ID_xxx */
  1150. /**
  1151. * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
  1152. * This is used to work around some encoder bugs.
  1153. * A demuxer should set this to what is stored in the field used to identify the codec.
  1154. * If there are multiple such fields in a container then the demuxer should choose the one
  1155. * which maximizes the information about the used codec.
  1156. * If the codec tag field in a container is larger than 32 bits then the demuxer should
  1157. * remap the longer ID to 32 bits with a table or other structure. Alternatively a new
  1158. * extra_codec_tag + size could be added but for this a clear advantage must be demonstrated
  1159. * first.
  1160. * - encoding: Set by user, if not then the default based on codec_id will be used.
  1161. * - decoding: Set by user, will be converted to uppercase by libavcodec during init.
  1162. */
  1163. unsigned int codec_tag;
  1164. /**
  1165. * fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
  1166. * This is used to work around some encoder bugs.
  1167. * - encoding: unused
  1168. * - decoding: Set by user, will be converted to uppercase by libavcodec during init.
  1169. */
  1170. unsigned int stream_codec_tag;
  1171. void *priv_data;
  1172. /**
  1173. * Private context used for internal data.
  1174. *
  1175. * Unlike priv_data, this is not codec-specific. It is used in general
  1176. * libavcodec functions.
  1177. */
  1178. struct AVCodecInternal *internal;
  1179. /**
  1180. * Private data of the user, can be used to carry app specific stuff.
  1181. * - encoding: Set by user.
  1182. * - decoding: Set by user.
  1183. */
  1184. void *opaque;
  1185. /**
  1186. * the average bitrate
  1187. * - encoding: Set by user; unused for constant quantizer encoding.
  1188. * - decoding: Set by libavcodec. 0 or some bitrate if this info is available in the stream.
  1189. */
  1190. int bit_rate;
  1191. /**
  1192. * number of bits the bitstream is allowed to diverge from the reference.
  1193. * the reference can be CBR (for CBR pass1) or VBR (for pass2)
  1194. * - encoding: Set by user; unused for constant quantizer encoding.
  1195. * - decoding: unused
  1196. */
  1197. int bit_rate_tolerance;
  1198. /**
  1199. * Global quality for codecs which cannot change it per frame.
  1200. * This should be proportional to MPEG-1/2/4 qscale.
  1201. * - encoding: Set by user.
  1202. * - decoding: unused
  1203. */
  1204. int global_quality;
  1205. /**
  1206. * - encoding: Set by user.
  1207. * - decoding: unused
  1208. */
  1209. int compression_level;
  1210. #define FF_COMPRESSION_DEFAULT -1
  1211. /**
  1212. * CODEC_FLAG_*.
  1213. * - encoding: Set by user.
  1214. * - decoding: Set by user.
  1215. */
  1216. int flags;
  1217. /**
  1218. * CODEC_FLAG2_*
  1219. * - encoding: Set by user.
  1220. * - decoding: Set by user.
  1221. */
  1222. int flags2;
  1223. /**
  1224. * some codecs need / can use extradata like Huffman tables.
  1225. * mjpeg: Huffman tables
  1226. * rv10: additional flags
  1227. * mpeg4: global headers (they can be in the bitstream or here)
  1228. * The allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger
  1229. * than extradata_size to avoid problems if it is read with the bitstream reader.
  1230. * The bytewise contents of extradata must not depend on the architecture or CPU endianness.
  1231. * - encoding: Set/allocated/freed by libavcodec.
  1232. * - decoding: Set/allocated/freed by user.
  1233. */
  1234. uint8_t *extradata;
  1235. int extradata_size;
  1236. /**
  1237. * This is the fundamental unit of time (in seconds) in terms
  1238. * of which frame timestamps are represented. For fixed-fps content,
  1239. * timebase should be 1/framerate and timestamp increments should be
  1240. * identically 1.
  1241. * - encoding: MUST be set by user.
  1242. * - decoding: Set by libavcodec.
  1243. */
  1244. AVRational time_base;
  1245. /**
  1246. * For some codecs, the time base is closer to the field rate than the frame rate.
  1247. * Most notably, H.264 and MPEG-2 specify time_base as half of frame duration
  1248. * if no telecine is used ...
  1249. *
  1250. * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2.
  1251. */
  1252. int ticks_per_frame;
  1253. /**
  1254. * Codec delay.
  1255. *
  1256. * Encoding: Number of frames delay there will be from the encoder input to
  1257. * the decoder output. (we assume the decoder matches the spec)
  1258. * Decoding: Number of frames delay in addition to what a standard decoder
  1259. * as specified in the spec would produce.
  1260. *
  1261. * Video:
  1262. * Number of frames the decoded output will be delayed relative to the
  1263. * encoded input.
  1264. *
  1265. * Audio:
  1266. * For encoding, this is the number of "priming" samples added to the
  1267. * beginning of the stream. The decoded output will be delayed by this
  1268. * many samples relative to the input to the encoder. Note that this
  1269. * field is purely informational and does not directly affect the pts
  1270. * output by the encoder, which should always be based on the actual
  1271. * presentation time, including any delay.
  1272. * For decoding, this is the number of samples the decoder needs to
  1273. * output before the decoder's output is valid. When seeking, you should
  1274. * start decoding this many samples prior to your desired seek point.
  1275. *
  1276. * - encoding: Set by libavcodec.
  1277. * - decoding: Set by libavcodec.
  1278. */
  1279. int delay;
  1280. /* video only */
  1281. /**
  1282. * picture width / height.
  1283. * - encoding: MUST be set by user.
  1284. * - decoding: May be set by the user before opening the decoder if known e.g.
  1285. * from the container. Some decoders will require the dimensions
  1286. * to be set by the caller. During decoding, the decoder may
  1287. * overwrite those values as required.
  1288. */
  1289. int width, height;
  1290. /**
  1291. * Bitstream width / height, may be different from width/height e.g. when
  1292. * the decoded frame is cropped before being output or lowres is enabled.
  1293. * - encoding: unused
  1294. * - decoding: May be set by the user before opening the decoder if known
  1295. * e.g. from the container. During decoding, the decoder may
  1296. * overwrite those values as required.
  1297. */
  1298. int coded_width, coded_height;
  1299. #if FF_API_ASPECT_EXTENDED
  1300. #define FF_ASPECT_EXTENDED 15
  1301. #endif
  1302. /**
  1303. * the number of pictures in a group of pictures, or 0 for intra_only
  1304. * - encoding: Set by user.
  1305. * - decoding: unused
  1306. */
  1307. int gop_size;
  1308. /**
  1309. * Pixel format, see AV_PIX_FMT_xxx.
  1310. * May be set by the demuxer if known from headers.
  1311. * May be overridden by the decoder if it knows better.
  1312. * - encoding: Set by user.
  1313. * - decoding: Set by user if known, overridden by libavcodec if known
  1314. */
  1315. enum AVPixelFormat pix_fmt;
  1316. /**
  1317. * Motion estimation algorithm used for video coding.
  1318. * 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex),
  1319. * 8 (umh), 9 (iter), 10 (tesa) [7, 8, 10 are x264 specific, 9 is snow specific]
  1320. * - encoding: MUST be set by user.
  1321. * - decoding: unused
  1322. */
  1323. int me_method;
  1324. /**
  1325. * If non NULL, 'draw_horiz_band' is called by the libavcodec
  1326. * decoder to draw a horizontal band. It improves cache usage. Not
  1327. * all codecs can do that. You must check the codec capabilities
  1328. * beforehand.
  1329. * When multithreading is used, it may be called from multiple threads
  1330. * at the same time; threads might draw different parts of the same AVFrame,
  1331. * or multiple AVFrames, and there is no guarantee that slices will be drawn
  1332. * in order.
  1333. * The function is also used by hardware acceleration APIs.
  1334. * It is called at least once during frame decoding to pass
  1335. * the data needed for hardware render.
  1336. * In that mode instead of pixel data, AVFrame points to
  1337. * a structure specific to the acceleration API. The application
  1338. * reads the structure and can change some fields to indicate progress
  1339. * or mark state.
  1340. * - encoding: unused
  1341. * - decoding: Set by user.
  1342. * @param height the height of the slice
  1343. * @param y the y position of the slice
  1344. * @param type 1->top field, 2->bottom field, 3->frame
  1345. * @param offset offset into the AVFrame.data from which the slice should be read
  1346. */
  1347. void (*draw_horiz_band)(struct AVCodecContext *s,
  1348. const AVFrame *src, int offset[AV_NUM_DATA_POINTERS],
  1349. int y, int type, int height);
  1350. /**
  1351. * callback to negotiate the pixelFormat
  1352. * @param fmt is the list of formats which are supported by the codec,
  1353. * it is terminated by -1 as 0 is a valid format, the formats are ordered by quality.
  1354. * The first is always the native one.
  1355. * @return the chosen format
  1356. * - encoding: unused
  1357. * - decoding: Set by user, if not set the native format will be chosen.
  1358. */
  1359. enum AVPixelFormat (*get_format)(struct AVCodecContext *s, const enum AVPixelFormat * fmt);
  1360. /**
  1361. * maximum number of B-frames between non-B-frames
  1362. * Note: The output will be delayed by max_b_frames+1 relative to the input.
  1363. * - encoding: Set by user.
  1364. * - decoding: unused
  1365. */
  1366. int max_b_frames;
  1367. /**
  1368. * qscale factor between IP and B-frames
  1369. * If > 0 then the last P-frame quantizer will be used (q= lastp_q*factor+offset).
  1370. * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
  1371. * - encoding: Set by user.
  1372. * - decoding: unused
  1373. */
  1374. float b_quant_factor;
  1375. /** obsolete FIXME remove */
  1376. int rc_strategy;
  1377. #define FF_RC_STRATEGY_XVID 1
  1378. int b_frame_strategy;
  1379. /**
  1380. * qscale offset between IP and B-frames
  1381. * - encoding: Set by user.
  1382. * - decoding: unused
  1383. */
  1384. float b_quant_offset;
  1385. /**
  1386. * Size of the frame reordering buffer in the decoder.
  1387. * For MPEG-2 it is 1 IPB or 0 low delay IP.
  1388. * - encoding: Set by libavcodec.
  1389. * - decoding: Set by libavcodec.
  1390. */
  1391. int has_b_frames;
  1392. /**
  1393. * 0-> h263 quant 1-> mpeg quant
  1394. * - encoding: Set by user.
  1395. * - decoding: unused
  1396. */
  1397. int mpeg_quant;
  1398. /**
  1399. * qscale factor between P and I-frames
  1400. * If > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset).
  1401. * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
  1402. * - encoding: Set by user.
  1403. * - decoding: unused
  1404. */
  1405. float i_quant_factor;
  1406. /**
  1407. * qscale offset between P and I-frames
  1408. * - encoding: Set by user.
  1409. * - decoding: unused
  1410. */
  1411. float i_quant_offset;
  1412. /**
  1413. * luminance masking (0-> disabled)
  1414. * - encoding: Set by user.
  1415. * - decoding: unused
  1416. */
  1417. float lumi_masking;
  1418. /**
  1419. * temporary complexity masking (0-> disabled)
  1420. * - encoding: Set by user.
  1421. * - decoding: unused
  1422. */
  1423. float temporal_cplx_masking;
  1424. /**
  1425. * spatial complexity masking (0-> disabled)
  1426. * - encoding: Set by user.
  1427. * - decoding: unused
  1428. */
  1429. float spatial_cplx_masking;
  1430. /**
  1431. * p block masking (0-> disabled)
  1432. * - encoding: Set by user.
  1433. * - decoding: unused
  1434. */
  1435. float p_masking;
  1436. /**
  1437. * darkness masking (0-> disabled)
  1438. * - encoding: Set by user.
  1439. * - decoding: unused
  1440. */
  1441. float dark_masking;
  1442. /**
  1443. * slice count
  1444. * - encoding: Set by libavcodec.
  1445. * - decoding: Set by user (or 0).
  1446. */
  1447. int slice_count;
  1448. /**
  1449. * prediction method (needed for huffyuv)
  1450. * - encoding: Set by user.
  1451. * - decoding: unused
  1452. */
  1453. int prediction_method;
  1454. #define FF_PRED_LEFT 0
  1455. #define FF_PRED_PLANE 1
  1456. #define FF_PRED_MEDIAN 2
  1457. /**
  1458. * slice offsets in the frame in bytes
  1459. * - encoding: Set/allocated by libavcodec.
  1460. * - decoding: Set/allocated by user (or NULL).
  1461. */
  1462. int *slice_offset;
  1463. /**
  1464. * sample aspect ratio (0 if unknown)
  1465. * That is the width of a pixel divided by the height of the pixel.
  1466. * Numerator and denominator must be relatively prime and smaller than 256 for some video standards.
  1467. * - encoding: Set by user.
  1468. * - decoding: Set by libavcodec.
  1469. */
  1470. AVRational sample_aspect_ratio;
  1471. /**
  1472. * motion estimation comparison function
  1473. * - encoding: Set by user.
  1474. * - decoding: unused
  1475. */
  1476. int me_cmp;
  1477. /**
  1478. * subpixel motion estimation comparison function
  1479. * - encoding: Set by user.
  1480. * - decoding: unused
  1481. */
  1482. int me_sub_cmp;
  1483. /**
  1484. * macroblock comparison function (not supported yet)
  1485. * - encoding: Set by user.
  1486. * - decoding: unused
  1487. */
  1488. int mb_cmp;
  1489. /**
  1490. * interlaced DCT comparison function
  1491. * - encoding: Set by user.
  1492. * - decoding: unused
  1493. */
  1494. int ildct_cmp;
  1495. #define FF_CMP_SAD 0
  1496. #define FF_CMP_SSE 1
  1497. #define FF_CMP_SATD 2
  1498. #define FF_CMP_DCT 3
  1499. #define FF_CMP_PSNR 4
  1500. #define FF_CMP_BIT 5
  1501. #define FF_CMP_RD 6
  1502. #define FF_CMP_ZERO 7
  1503. #define FF_CMP_VSAD 8
  1504. #define FF_CMP_VSSE 9
  1505. #define FF_CMP_NSSE 10
  1506. #define FF_CMP_W53 11
  1507. #define FF_CMP_W97 12
  1508. #define FF_CMP_DCTMAX 13
  1509. #define FF_CMP_DCT264 14
  1510. #define FF_CMP_CHROMA 256
  1511. /**
  1512. * ME diamond size & shape
  1513. * - encoding: Set by user.
  1514. * - decoding: unused
  1515. */
  1516. int dia_size;
  1517. /**
  1518. * amount of previous MV predictors (2a+1 x 2a+1 square)
  1519. * - encoding: Set by user.
  1520. * - decoding: unused
  1521. */
  1522. int last_predictor_count;
  1523. /**
  1524. * prepass for motion estimation
  1525. * - encoding: Set by user.
  1526. * - decoding: unused
  1527. */
  1528. int pre_me;
  1529. /**
  1530. * motion estimation prepass comparison function
  1531. * - encoding: Set by user.
  1532. * - decoding: unused
  1533. */
  1534. int me_pre_cmp;
  1535. /**
  1536. * ME prepass diamond size & shape
  1537. * - encoding: Set by user.
  1538. * - decoding: unused
  1539. */
  1540. int pre_dia_size;
  1541. /**
  1542. * subpel ME quality
  1543. * - encoding: Set by user.
  1544. * - decoding: unused
  1545. */
  1546. int me_subpel_quality;
  1547. /**
  1548. * DTG active format information (additional aspect ratio
  1549. * information only used in DVB MPEG-2 transport streams)
  1550. * 0 if not set.
  1551. *
  1552. * - encoding: unused
  1553. * - decoding: Set by decoder.
  1554. */
  1555. int dtg_active_format;
  1556. #define FF_DTG_AFD_SAME 8
  1557. #define FF_DTG_AFD_4_3 9
  1558. #define FF_DTG_AFD_16_9 10
  1559. #define FF_DTG_AFD_14_9 11
  1560. #define FF_DTG_AFD_4_3_SP_14_9 13
  1561. #define FF_DTG_AFD_16_9_SP_14_9 14
  1562. #define FF_DTG_AFD_SP_4_3 15
  1563. /**
  1564. * maximum motion estimation search range in subpel units
  1565. * If 0 then no limit.
  1566. *
  1567. * - encoding: Set by user.
  1568. * - decoding: unused
  1569. */
  1570. int me_range;
  1571. /**
  1572. * intra quantizer bias
  1573. * - encoding: Set by user.
  1574. * - decoding: unused
  1575. */
  1576. int intra_quant_bias;
  1577. #define FF_DEFAULT_QUANT_BIAS 999999
  1578. /**
  1579. * inter quantizer bias
  1580. * - encoding: Set by user.
  1581. * - decoding: unused
  1582. */
  1583. int inter_quant_bias;
  1584. /**
  1585. * slice flags
  1586. * - encoding: unused
  1587. * - decoding: Set by user.
  1588. */
  1589. int slice_flags;
  1590. #define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display
  1591. #define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics)
  1592. #define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
  1593. #if FF_API_XVMC
  1594. /**
  1595. * XVideo Motion Acceleration
  1596. * - encoding: forbidden
  1597. * - decoding: set by decoder
  1598. * @deprecated XvMC doesn't need it anymore.
  1599. */
  1600. attribute_deprecated int xvmc_acceleration;
  1601. #endif /* FF_API_XVMC */
  1602. /**
  1603. * macroblock decision mode
  1604. * - encoding: Set by user.
  1605. * - decoding: unused
  1606. */
  1607. int mb_decision;
  1608. #define FF_MB_DECISION_SIMPLE 0 ///< uses mb_cmp
  1609. #define FF_MB_DECISION_BITS 1 ///< chooses the one which needs the fewest bits
  1610. #define FF_MB_DECISION_RD 2 ///< rate distortion
  1611. /**
  1612. * custom intra quantization matrix
  1613. * - encoding: Set by user, can be NULL.
  1614. * - decoding: Set by libavcodec.
  1615. */
  1616. uint16_t *intra_matrix;
  1617. /**
  1618. * custom inter quantization matrix
  1619. * - encoding: Set by user, can be NULL.
  1620. * - decoding: Set by libavcodec.
  1621. */
  1622. uint16_t *inter_matrix;
  1623. /**
  1624. * scene change detection threshold
  1625. * 0 is default, larger means fewer detected scene changes.
  1626. * - encoding: Set by user.
  1627. * - decoding: unused
  1628. */
  1629. int scenechange_threshold;
  1630. /**
  1631. * noise reduction strength
  1632. * - encoding: Set by user.
  1633. * - decoding: unused
  1634. */
  1635. int noise_reduction;
  1636. /**
  1637. * Motion estimation threshold below which no motion estimation is
  1638. * performed, but instead the user specified motion vectors are used.
  1639. *
  1640. * - encoding: Set by user.
  1641. * - decoding: unused
  1642. */
  1643. int me_threshold;
  1644. /**
  1645. * Macroblock threshold below which the user specified macroblock types will be used.
  1646. * - encoding: Set by user.
  1647. * - decoding: unused
  1648. */
  1649. int mb_threshold;
  1650. /**
  1651. * precision of the intra DC coefficient - 8
  1652. * - encoding: Set by user.
  1653. * - decoding: unused
  1654. */
  1655. int intra_dc_precision;
  1656. /**
  1657. * Number of macroblock rows at the top which are skipped.
  1658. * - encoding: unused
  1659. * - decoding: Set by user.
  1660. */
  1661. int skip_top;
  1662. /**
  1663. * Number of macroblock rows at the bottom which are skipped.
  1664. * - encoding: unused
  1665. * - decoding: Set by user.
  1666. */
  1667. int skip_bottom;
  1668. /**
  1669. * Border processing masking, raises the quantizer for mbs on the borders
  1670. * of the picture.
  1671. * - encoding: Set by user.
  1672. * - decoding: unused
  1673. */
  1674. float border_masking;
  1675. /**
  1676. * minimum MB lagrange multipler
  1677. * - encoding: Set by user.
  1678. * - decoding: unused
  1679. */
  1680. int mb_lmin;
  1681. /**
  1682. * maximum MB lagrange multipler
  1683. * - encoding: Set by user.
  1684. * - decoding: unused
  1685. */
  1686. int mb_lmax;
  1687. /**
  1688. *
  1689. * - encoding: Set by user.
  1690. * - decoding: unused
  1691. */
  1692. int me_penalty_compensation;
  1693. /**
  1694. *
  1695. * - encoding: Set by user.
  1696. * - decoding: unused
  1697. */
  1698. int bidir_refine;
  1699. /**
  1700. *
  1701. * - encoding: Set by user.
  1702. * - decoding: unused
  1703. */
  1704. int brd_scale;
  1705. /**
  1706. * minimum GOP size
  1707. * - encoding: Set by user.
  1708. * - decoding: unused
  1709. */
  1710. int keyint_min;
  1711. /**
  1712. * number of reference frames
  1713. * - encoding: Set by user.
  1714. * - decoding: Set by lavc.
  1715. */
  1716. int refs;
  1717. /**
  1718. * chroma qp offset from luma
  1719. * - encoding: Set by user.
  1720. * - decoding: unused
  1721. */
  1722. int chromaoffset;
  1723. /**
  1724. * Multiplied by qscale for each frame and added to scene_change_score.
  1725. * - encoding: Set by user.
  1726. * - decoding: unused
  1727. */
  1728. int scenechange_factor;
  1729. /**
  1730. *
  1731. * Note: Value depends upon the compare function used for fullpel ME.
  1732. * - encoding: Set by user.
  1733. * - decoding: unused
  1734. */
  1735. int mv0_threshold;
  1736. /**
  1737. * Adjust sensitivity of b_frame_strategy 1.
  1738. * - encoding: Set by user.
  1739. * - decoding: unused
  1740. */
  1741. int b_sensitivity;
  1742. /**
  1743. * Chromaticity coordinates of the source primaries.
  1744. * - encoding: Set by user
  1745. * - decoding: Set by libavcodec
  1746. */
  1747. enum AVColorPrimaries color_primaries;
  1748. /**
  1749. * Color Transfer Characteristic.
  1750. * - encoding: Set by user
  1751. * - decoding: Set by libavcodec
  1752. */
  1753. enum AVColorTransferCharacteristic color_trc;
  1754. /**
  1755. * YUV colorspace type.
  1756. * - encoding: Set by user
  1757. * - decoding: Set by libavcodec
  1758. */
  1759. enum AVColorSpace colorspace;
  1760. /**
  1761. * MPEG vs JPEG YUV range.
  1762. * - encoding: Set by user
  1763. * - decoding: Set by libavcodec
  1764. */
  1765. enum AVColorRange color_range;
  1766. /**
  1767. * This defines the location of chroma samples.
  1768. * - encoding: Set by user
  1769. * - decoding: Set by libavcodec
  1770. */
  1771. enum AVChromaLocation chroma_sample_location;
  1772. /**
  1773. * Number of slices.
  1774. * Indicates number of picture subdivisions. Used for parallelized
  1775. * decoding.
  1776. * - encoding: Set by user
  1777. * - decoding: unused
  1778. */
  1779. int slices;
  1780. /** Field order
  1781. * - encoding: set by libavcodec
  1782. * - decoding: Set by user.
  1783. */
  1784. enum AVFieldOrder field_order;
  1785. /* audio only */
  1786. int sample_rate; ///< samples per second
  1787. int channels; ///< number of audio channels
  1788. /**
  1789. * audio sample format
  1790. * - encoding: Set by user.
  1791. * - decoding: Set by libavcodec.
  1792. */
  1793. enum AVSampleFormat sample_fmt; ///< sample format
  1794. /* The following data should not be initialized. */
  1795. /**
  1796. * Number of samples per channel in an audio frame.
  1797. *
  1798. * - encoding: set by libavcodec in avcodec_open2(). Each submitted frame
  1799. * except the last must contain exactly frame_size samples per channel.
  1800. * May be 0 when the codec has CODEC_CAP_VARIABLE_FRAME_SIZE set, then the
  1801. * frame size is not restricted.
  1802. * - decoding: may be set by some decoders to indicate constant frame size
  1803. */
  1804. int frame_size;
  1805. /**
  1806. * Frame counter, set by libavcodec.
  1807. *
  1808. * - decoding: total number of frames returned from the decoder so far.
  1809. * - encoding: total number of frames passed to the encoder so far.
  1810. *
  1811. * @note the counter is not incremented if encoding/decoding resulted in
  1812. * an error.
  1813. */
  1814. int frame_number;
  1815. /**
  1816. * number of bytes per packet if constant and known or 0
  1817. * Used by some WAV based audio codecs.
  1818. */
  1819. int block_align;
  1820. /**
  1821. * Audio cutoff bandwidth (0 means "automatic")
  1822. * - encoding: Set by user.
  1823. * - decoding: unused
  1824. */
  1825. int cutoff;
  1826. #if FF_API_REQUEST_CHANNELS
  1827. /**
  1828. * Decoder should decode to this many channels if it can (0 for default)
  1829. * - encoding: unused
  1830. * - decoding: Set by user.
  1831. * @deprecated Deprecated in favor of request_channel_layout.
  1832. */
  1833. attribute_deprecated int request_channels;
  1834. #endif
  1835. /**
  1836. * Audio channel layout.
  1837. * - encoding: set by user.
  1838. * - decoding: set by user, may be overwritten by libavcodec.
  1839. */
  1840. uint64_t channel_layout;
  1841. /**
  1842. * Request decoder to use this channel layout if it can (0 for default)
  1843. * - encoding: unused
  1844. * - decoding: Set by user.
  1845. */
  1846. uint64_t request_channel_layout;
  1847. /**
  1848. * Type of service that the audio stream conveys.
  1849. * - encoding: Set by user.
  1850. * - decoding: Set by libavcodec.
  1851. */
  1852. enum AVAudioServiceType audio_service_type;
  1853. /**
  1854. * desired sample format
  1855. * - encoding: Not used.
  1856. * - decoding: Set by user.
  1857. * Decoder will decode to this format if it can.
  1858. */
  1859. enum AVSampleFormat request_sample_fmt;
  1860. #if FF_API_GET_BUFFER
  1861. /**
  1862. * Called at the beginning of each frame to get a buffer for it.
  1863. *
  1864. * The function will set AVFrame.data[], AVFrame.linesize[].
  1865. * AVFrame.extended_data[] must also be set, but it should be the same as
  1866. * AVFrame.data[] except for planar audio with more channels than can fit
  1867. * in AVFrame.data[]. In that case, AVFrame.data[] shall still contain as
  1868. * many data pointers as it can hold.
  1869. *
  1870. * if CODEC_CAP_DR1 is not set then get_buffer() must call
  1871. * avcodec_default_get_buffer() instead of providing buffers allocated by
  1872. * some other means.
  1873. *
  1874. * AVFrame.data[] should be 32- or 16-byte-aligned unless the CPU doesn't
  1875. * need it. avcodec_default_get_buffer() aligns the output buffer properly,
  1876. * but if get_buffer() is overridden then alignment considerations should
  1877. * be taken into account.
  1878. *
  1879. * @see avcodec_default_get_buffer()
  1880. *
  1881. * Video:
  1882. *
  1883. * If pic.reference is set then the frame will be read later by libavcodec.
  1884. * avcodec_align_dimensions2() should be used to find the required width and
  1885. * height, as they normally need to be rounded up to the next multiple of 16.
  1886. *
  1887. * If frame multithreading is used and thread_safe_callbacks is set,
  1888. * it may be called from a different thread, but not from more than one at
  1889. * once. Does not need to be reentrant.
  1890. *
  1891. * @see release_buffer(), reget_buffer()
  1892. * @see avcodec_align_dimensions2()
  1893. *
  1894. * Audio:
  1895. *
  1896. * Decoders request a buffer of a particular size by setting
  1897. * AVFrame.nb_samples prior to calling get_buffer(). The decoder may,
  1898. * however, utilize only part of the buffer by setting AVFrame.nb_samples
  1899. * to a smaller value in the output frame.
  1900. *
  1901. * Decoders cannot use the buffer after returning from
  1902. * avcodec_decode_audio4(), so they will not call release_buffer(), as it
  1903. * is assumed to be released immediately upon return. In some rare cases,
  1904. * a decoder may need to call get_buffer() more than once in a single
  1905. * call to avcodec_decode_audio4(). In that case, when get_buffer() is
  1906. * called again after it has already been called once, the previously
  1907. * acquired buffer is assumed to be released at that time and may not be
  1908. * reused by the decoder.
  1909. *
  1910. * As a convenience, av_samples_get_buffer_size() and
  1911. * av_samples_fill_arrays() in libavutil may be used by custom get_buffer()
  1912. * functions to find the required data size and to fill data pointers and
  1913. * linesize. In AVFrame.linesize, only linesize[0] may be set for audio
  1914. * since all planes must be the same size.
  1915. *
  1916. * @see av_samples_get_buffer_size(), av_samples_fill_arrays()
  1917. *
  1918. * - encoding: unused
  1919. * - decoding: Set by libavcodec, user can override.
  1920. *
  1921. * @deprecated use get_buffer2()
  1922. */
  1923. attribute_deprecated
  1924. int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
  1925. /**
  1926. * Called to release buffers which were allocated with get_buffer.
  1927. * A released buffer can be reused in get_buffer().
  1928. * pic.data[*] must be set to NULL.
  1929. * May be called from a different thread if frame multithreading is used,
  1930. * but not by more than one thread at once, so does not need to be reentrant.
  1931. * - encoding: unused
  1932. * - decoding: Set by libavcodec, user can override.
  1933. *
  1934. * @deprecated custom freeing callbacks should be set from get_buffer2()
  1935. */
  1936. attribute_deprecated
  1937. void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
  1938. /**
  1939. * Called at the beginning of a frame to get cr buffer for it.
  1940. * Buffer type (size, hints) must be the same. libavcodec won't check it.
  1941. * libavcodec will pass previous buffer in pic, function should return
  1942. * same buffer or new buffer with old frame "painted" into it.
  1943. * If pic.data[0] == NULL must behave like get_buffer().
  1944. * if CODEC_CAP_DR1 is not set then reget_buffer() must call
  1945. * avcodec_default_reget_buffer() instead of providing buffers allocated by
  1946. * some other means.
  1947. * - encoding: unused
  1948. * - decoding: Set by libavcodec, user can override.
  1949. */
  1950. attribute_deprecated
  1951. int (*reget_buffer)(struct AVCodecContext *c, AVFrame *pic);
  1952. #endif
  1953. /**
  1954. * This callback is called at the beginning of each frame to get data
  1955. * buffer(s) for it. There may be one contiguous buffer for all the data or
  1956. * there may be a buffer per each data plane or anything in between. What
  1957. * this means is, you may set however many entries in buf[] you feel necessary.
  1958. * Each buffer must be reference-counted using the AVBuffer API (see description
  1959. * of buf[] below).
  1960. *
  1961. * The following fields will be set in the frame before this callback is
  1962. * called:
  1963. * - format
  1964. * - width, height (video only)
  1965. * - sample_rate, channel_layout, nb_samples (audio only)
  1966. * Their values may differ from the corresponding values in
  1967. * AVCodecContext. This callback must use the frame values, not the codec
  1968. * context values, to calculate the required buffer size.
  1969. *
  1970. * This callback must fill the following fields in the frame:
  1971. * - data[]
  1972. * - linesize[]
  1973. * - extended_data:
  1974. * * if the data is planar audio with more than 8 channels, then this
  1975. * callback must allocate and fill extended_data to contain all pointers
  1976. * to all data planes. data[] must hold as many pointers as it can.
  1977. * extended_data must be allocated with av_malloc() and will be freed in
  1978. * av_frame_unref().
  1979. * * otherwise exended_data must point to data
  1980. * - buf[] must contain one or more pointers to AVBufferRef structures. Each of
  1981. * the frame's data and extended_data pointers must be contained in these. That
  1982. * is, one AVBufferRef for each allocated chunk of memory, not necessarily one
  1983. * AVBufferRef per data[] entry. See: av_buffer_create(), av_buffer_alloc(),
  1984. * and av_buffer_ref().
  1985. * - extended_buf and nb_extended_buf must be allocated with av_malloc() by
  1986. * this callback and filled with the extra buffers if there are more
  1987. * buffers than buf[] can hold. extended_buf will be freed in
  1988. * av_frame_unref().
  1989. *
  1990. * If CODEC_CAP_DR1 is not set then get_buffer2() must call
  1991. * avcodec_default_get_buffer2() instead of providing buffers allocated by
  1992. * some other means.
  1993. *
  1994. * Each data plane must be aligned to the maximum required by the target
  1995. * CPU.
  1996. *
  1997. * @see avcodec_default_get_buffer2()
  1998. *
  1999. * Video:
  2000. *
  2001. * If AV_GET_BUFFER_FLAG_REF is set in flags then the frame may be reused
  2002. * (read and/or written to if it is writable) later by libavcodec.
  2003. *
  2004. * avcodec_align_dimensions2() should be used to find the required width and
  2005. * height, as they normally need to be rounded up to the next multiple of 16.
  2006. *
  2007. * Some decoders do not support linesizes changing between frames.
  2008. *
  2009. * If frame multithreading is used and thread_safe_callbacks is set,
  2010. * this callback may be called from a different thread, but not from more
  2011. * than one at once. Does not need to be reentrant.
  2012. *
  2013. * @see avcodec_align_dimensions2()
  2014. *
  2015. * Audio:
  2016. *
  2017. * Decoders request a buffer of a particular size by setting
  2018. * AVFrame.nb_samples prior to calling get_buffer2(). The decoder may,
  2019. * however, utilize only part of the buffer by setting AVFrame.nb_samples
  2020. * to a smaller value in the output frame.
  2021. *
  2022. * As a convenience, av_samples_get_buffer_size() and
  2023. * av_samples_fill_arrays() in libavutil may be used by custom get_buffer2()
  2024. * functions to find the required data size and to fill data pointers and
  2025. * linesize. In AVFrame.linesize, only linesize[0] may be set for audio
  2026. * since all planes must be the same size.
  2027. *
  2028. * @see av_samples_get_buffer_size(), av_samples_fill_arrays()
  2029. *
  2030. * - encoding: unused
  2031. * - decoding: Set by libavcodec, user can override.
  2032. */
  2033. int (*get_buffer2)(struct AVCodecContext *s, AVFrame *frame, int flags);
  2034. /**
  2035. * If non-zero, the decoded audio and video frames returned from
  2036. * avcodec_decode_video2() and avcodec_decode_audio4() are reference-counted
  2037. * and are valid indefinitely. The caller must free them with
  2038. * av_frame_unref() when they are not needed anymore.
  2039. * Otherwise, the decoded frames must not be freed by the caller and are
  2040. * only valid until the next decode call.
  2041. *
  2042. * - encoding: unused
  2043. * - decoding: set by the caller before avcodec_open2().
  2044. */
  2045. int refcounted_frames;
  2046. /* - encoding parameters */
  2047. float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)
  2048. float qblur; ///< amount of qscale smoothing over time (0.0-1.0)
  2049. /**
  2050. * minimum quantizer
  2051. * - encoding: Set by user.
  2052. * - decoding: unused
  2053. */
  2054. int qmin;
  2055. /**
  2056. * maximum quantizer
  2057. * - encoding: Set by user.
  2058. * - decoding: unused
  2059. */
  2060. int qmax;
  2061. /**
  2062. * maximum quantizer difference between frames
  2063. * - encoding: Set by user.
  2064. * - decoding: unused
  2065. */
  2066. int max_qdiff;
  2067. /**
  2068. * ratecontrol qmin qmax limiting method
  2069. * 0-> clipping, 1-> use a nice continuous function to limit qscale wthin qmin/qmax.
  2070. * - encoding: Set by user.
  2071. * - decoding: unused
  2072. */
  2073. float rc_qsquish;
  2074. float rc_qmod_amp;
  2075. int rc_qmod_freq;
  2076. /**
  2077. * decoder bitstream buffer size
  2078. * - encoding: Set by user.
  2079. * - decoding: unused
  2080. */
  2081. int rc_buffer_size;
  2082. /**
  2083. * ratecontrol override, see RcOverride
  2084. * - encoding: Allocated/set/freed by user.
  2085. * - decoding: unused
  2086. */
  2087. int rc_override_count;
  2088. RcOverride *rc_override;
  2089. /**
  2090. * rate control equation
  2091. * - encoding: Set by user
  2092. * - decoding: unused
  2093. */
  2094. const char *rc_eq;
  2095. /**
  2096. * maximum bitrate
  2097. * - encoding: Set by user.
  2098. * - decoding: unused
  2099. */
  2100. int rc_max_rate;
  2101. /**
  2102. * minimum bitrate
  2103. * - encoding: Set by user.
  2104. * - decoding: unused
  2105. */
  2106. int rc_min_rate;
  2107. float rc_buffer_aggressivity;
  2108. /**
  2109. * initial complexity for pass1 ratecontrol
  2110. * - encoding: Set by user.
  2111. * - decoding: unused
  2112. */
  2113. float rc_initial_cplx;
  2114. /**
  2115. * Ratecontrol attempt to use, at maximum, <value> of what can be used without an underflow.
  2116. * - encoding: Set by user.
  2117. * - decoding: unused.
  2118. */
  2119. float rc_max_available_vbv_use;
  2120. /**
  2121. * Ratecontrol attempt to use, at least, <value> times the amount needed to prevent a vbv overflow.
  2122. * - encoding: Set by user.
  2123. * - decoding: unused.
  2124. */
  2125. float rc_min_vbv_overflow_use;
  2126. /**
  2127. * Number of bits which should be loaded into the rc buffer before decoding starts.
  2128. * - encoding: Set by user.
  2129. * - decoding: unused
  2130. */
  2131. int rc_initial_buffer_occupancy;
  2132. #define FF_CODER_TYPE_VLC 0
  2133. #define FF_CODER_TYPE_AC 1
  2134. #define FF_CODER_TYPE_RAW 2
  2135. #define FF_CODER_TYPE_RLE 3
  2136. #define FF_CODER_TYPE_DEFLATE 4
  2137. /**
  2138. * coder type
  2139. * - encoding: Set by user.
  2140. * - decoding: unused
  2141. */
  2142. int coder_type;
  2143. /**
  2144. * context model
  2145. * - encoding: Set by user.
  2146. * - decoding: unused
  2147. */
  2148. int context_model;
  2149. /**
  2150. * minimum Lagrange multipler
  2151. * - encoding: Set by user.
  2152. * - decoding: unused
  2153. */
  2154. int lmin;
  2155. /**
  2156. * maximum Lagrange multipler
  2157. * - encoding: Set by user.
  2158. * - decoding: unused
  2159. */
  2160. int lmax;
  2161. /**
  2162. * frame skip threshold
  2163. * - encoding: Set by user.
  2164. * - decoding: unused
  2165. */
  2166. int frame_skip_threshold;
  2167. /**
  2168. * frame skip factor
  2169. * - encoding: Set by user.
  2170. * - decoding: unused
  2171. */
  2172. int frame_skip_factor;
  2173. /**
  2174. * frame skip exponent
  2175. * - encoding: Set by user.
  2176. * - decoding: unused
  2177. */
  2178. int frame_skip_exp;
  2179. /**
  2180. * frame skip comparison function
  2181. * - encoding: Set by user.
  2182. * - decoding: unused
  2183. */
  2184. int frame_skip_cmp;
  2185. /**
  2186. * trellis RD quantization
  2187. * - encoding: Set by user.
  2188. * - decoding: unused
  2189. */
  2190. int trellis;
  2191. /**
  2192. * - encoding: Set by user.
  2193. * - decoding: unused
  2194. */
  2195. int min_prediction_order;
  2196. /**
  2197. * - encoding: Set by user.
  2198. * - decoding: unused
  2199. */
  2200. int max_prediction_order;
  2201. /**
  2202. * GOP timecode frame start number
  2203. * - encoding: Set by user, in non drop frame format
  2204. * - decoding: Set by libavcodec (timecode in the 25 bits format, -1 if unset)
  2205. */
  2206. int64_t timecode_frame_start;
  2207. /* The RTP callback: This function is called */
  2208. /* every time the encoder has a packet to send. */
  2209. /* It depends on the encoder if the data starts */
  2210. /* with a Start Code (it should). H.263 does. */
  2211. /* mb_nb contains the number of macroblocks */
  2212. /* encoded in the RTP payload. */
  2213. void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb);
  2214. int rtp_payload_size; /* The size of the RTP payload: the coder will */
  2215. /* do its best to deliver a chunk with size */
  2216. /* below rtp_payload_size, the chunk will start */
  2217. /* with a start code on some codecs like H.263. */
  2218. /* This doesn't take account of any particular */
  2219. /* headers inside the transmitted RTP payload. */
  2220. /* statistics, used for 2-pass encoding */
  2221. int mv_bits;
  2222. int header_bits;
  2223. int i_tex_bits;
  2224. int p_tex_bits;
  2225. int i_count;
  2226. int p_count;
  2227. int skip_count;
  2228. int misc_bits;
  2229. /**
  2230. * number of bits used for the previously encoded frame
  2231. * - encoding: Set by libavcodec.
  2232. * - decoding: unused
  2233. */
  2234. int frame_bits;
  2235. /**
  2236. * pass1 encoding statistics output buffer
  2237. * - encoding: Set by libavcodec.
  2238. * - decoding: unused
  2239. */
  2240. char *stats_out;
  2241. /**
  2242. * pass2 encoding statistics input buffer
  2243. * Concatenated stuff from stats_out of pass1 should be placed here.
  2244. * - encoding: Allocated/set/freed by user.
  2245. * - decoding: unused
  2246. */
  2247. char *stats_in;
  2248. /**
  2249. * Work around bugs in encoders which sometimes cannot be detected automatically.
  2250. * - encoding: Set by user
  2251. * - decoding: Set by user
  2252. */
  2253. int workaround_bugs;
  2254. #define FF_BUG_AUTODETECT 1 ///< autodetection
  2255. #if FF_API_OLD_MSMPEG4
  2256. #define FF_BUG_OLD_MSMPEG4 2
  2257. #endif
  2258. #define FF_BUG_XVID_ILACE 4
  2259. #define FF_BUG_UMP4 8
  2260. #define FF_BUG_NO_PADDING 16
  2261. #define FF_BUG_AMV 32
  2262. #if FF_API_AC_VLC
  2263. #define FF_BUG_AC_VLC 0 ///< Will be removed, libavcodec can now handle these non-compliant files by default.
  2264. #endif
  2265. #define FF_BUG_QPEL_CHROMA 64
  2266. #define FF_BUG_STD_QPEL 128
  2267. #define FF_BUG_QPEL_CHROMA2 256
  2268. #define FF_BUG_DIRECT_BLOCKSIZE 512
  2269. #define FF_BUG_EDGE 1024
  2270. #define FF_BUG_HPEL_CHROMA 2048
  2271. #define FF_BUG_DC_CLIP 4096
  2272. #define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders.
  2273. #define FF_BUG_TRUNCATED 16384
  2274. /**
  2275. * strictly follow the standard (MPEG4, ...).
  2276. * - encoding: Set by user.
  2277. * - decoding: Set by user.
  2278. * Setting this to STRICT or higher means the encoder and decoder will
  2279. * generally do stupid things, whereas setting it to unofficial or lower
  2280. * will mean the encoder might produce output that is not supported by all
  2281. * spec-compliant decoders. Decoders don't differentiate between normal,
  2282. * unofficial and experimental (that is, they always try to decode things
  2283. * when they can) unless they are explicitly asked to behave stupidly
  2284. * (=strictly conform to the specs)
  2285. */
  2286. int strict_std_compliance;
  2287. #define FF_COMPLIANCE_VERY_STRICT 2 ///< Strictly conform to an older more strict version of the spec or reference software.
  2288. #define FF_COMPLIANCE_STRICT 1 ///< Strictly conform to all the things in the spec no matter what consequences.
  2289. #define FF_COMPLIANCE_NORMAL 0
  2290. #define FF_COMPLIANCE_UNOFFICIAL -1 ///< Allow unofficial extensions
  2291. #define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things.
  2292. /**
  2293. * error concealment flags
  2294. * - encoding: unused
  2295. * - decoding: Set by user.
  2296. */
  2297. int error_concealment;
  2298. #define FF_EC_GUESS_MVS 1
  2299. #define FF_EC_DEBLOCK 2
  2300. /**
  2301. * debug
  2302. * - encoding: Set by user.
  2303. * - decoding: Set by user.
  2304. */
  2305. int debug;
  2306. #define FF_DEBUG_PICT_INFO 1
  2307. #define FF_DEBUG_RC 2
  2308. #define FF_DEBUG_BITSTREAM 4
  2309. #define FF_DEBUG_MB_TYPE 8
  2310. #define FF_DEBUG_QP 16
  2311. #if FF_API_DEBUG_MV
  2312. /**
  2313. * @deprecated this option does nothing
  2314. */
  2315. #define FF_DEBUG_MV 32
  2316. #endif
  2317. #define FF_DEBUG_DCT_COEFF 0x00000040
  2318. #define FF_DEBUG_SKIP 0x00000080
  2319. #define FF_DEBUG_STARTCODE 0x00000100
  2320. #define FF_DEBUG_PTS 0x00000200
  2321. #define FF_DEBUG_ER 0x00000400
  2322. #define FF_DEBUG_MMCO 0x00000800
  2323. #define FF_DEBUG_BUGS 0x00001000
  2324. #if FF_API_DEBUG_MV
  2325. #define FF_DEBUG_VIS_QP 0x00002000 ///< only access through AVOptions from outside libavcodec
  2326. #define FF_DEBUG_VIS_MB_TYPE 0x00004000 ///< only access through AVOptions from outside libavcodec
  2327. #endif
  2328. #define FF_DEBUG_BUFFERS 0x00008000
  2329. #define FF_DEBUG_THREADS 0x00010000
  2330. #if FF_API_DEBUG_MV
  2331. /**
  2332. * debug
  2333. * Code outside libavcodec should access this field using AVOptions
  2334. * - encoding: Set by user.
  2335. * - decoding: Set by user.
  2336. */
  2337. int debug_mv;
  2338. #define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames
  2339. #define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames
  2340. #define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames
  2341. #endif
  2342. /**
  2343. * Error recognition; may misdetect some more or less valid parts as errors.
  2344. * - encoding: unused
  2345. * - decoding: Set by user.
  2346. */
  2347. int err_recognition;
  2348. /**
  2349. * Verify checksums embedded in the bitstream (could be of either encoded or
  2350. * decoded data, depending on the codec) and print an error message on mismatch.
  2351. * If AV_EF_EXPLODE is also set, a mismatching checksum will result in the
  2352. * decoder returning an error.
  2353. */
  2354. #define AV_EF_CRCCHECK (1<<0)
  2355. #define AV_EF_BITSTREAM (1<<1) ///< detect bitstream specification deviations
  2356. #define AV_EF_BUFFER (1<<2) ///< detect improper bitstream length
  2357. #define AV_EF_EXPLODE (1<<3) ///< abort decoding on minor error detection
  2358. #define AV_EF_CAREFUL (1<<16) ///< consider things that violate the spec, are fast to calculate and have not been seen in the wild as errors
  2359. #define AV_EF_COMPLIANT (1<<17) ///< consider all spec non compliancies as errors
  2360. #define AV_EF_AGGRESSIVE (1<<18) ///< consider things that a sane encoder should not do as an error
  2361. /**
  2362. * opaque 64bit number (generally a PTS) that will be reordered and
  2363. * output in AVFrame.reordered_opaque
  2364. * @deprecated in favor of pkt_pts
  2365. * - encoding: unused
  2366. * - decoding: Set by user.
  2367. */
  2368. int64_t reordered_opaque;
  2369. /**
  2370. * Hardware accelerator in use
  2371. * - encoding: unused.
  2372. * - decoding: Set by libavcodec
  2373. */
  2374. struct AVHWAccel *hwaccel;
  2375. /**
  2376. * Hardware accelerator context.
  2377. * For some hardware accelerators, a global context needs to be
  2378. * provided by the user. In that case, this holds display-dependent
  2379. * data FFmpeg cannot instantiate itself. Please refer to the
  2380. * FFmpeg HW accelerator documentation to know how to fill this
  2381. * is. e.g. for VA API, this is a struct vaapi_context.
  2382. * - encoding: unused
  2383. * - decoding: Set by user
  2384. */
  2385. void *hwaccel_context;
  2386. /**
  2387. * error
  2388. * - encoding: Set by libavcodec if flags&CODEC_FLAG_PSNR.
  2389. * - decoding: unused
  2390. */
  2391. uint64_t error[AV_NUM_DATA_POINTERS];
  2392. /**
  2393. * DCT algorithm, see FF_DCT_* below
  2394. * - encoding: Set by user.
  2395. * - decoding: unused
  2396. */
  2397. int dct_algo;
  2398. #define FF_DCT_AUTO 0
  2399. #define FF_DCT_FASTINT 1
  2400. #define FF_DCT_INT 2
  2401. #define FF_DCT_MMX 3
  2402. #define FF_DCT_ALTIVEC 5
  2403. #define FF_DCT_FAAN 6
  2404. /**
  2405. * IDCT algorithm, see FF_IDCT_* below.
  2406. * - encoding: Set by user.
  2407. * - decoding: Set by user.
  2408. */
  2409. int idct_algo;
  2410. #define FF_IDCT_AUTO 0
  2411. #define FF_IDCT_INT 1
  2412. #define FF_IDCT_SIMPLE 2
  2413. #define FF_IDCT_SIMPLEMMX 3
  2414. #define FF_IDCT_ARM 7
  2415. #define FF_IDCT_ALTIVEC 8
  2416. #if FF_API_ARCH_SH4
  2417. #define FF_IDCT_SH4 9
  2418. #endif
  2419. #define FF_IDCT_SIMPLEARM 10
  2420. #define FF_IDCT_IPP 13
  2421. #define FF_IDCT_XVIDMMX 14
  2422. #define FF_IDCT_SIMPLEARMV5TE 16
  2423. #define FF_IDCT_SIMPLEARMV6 17
  2424. #if FF_API_ARCH_SPARC
  2425. #define FF_IDCT_SIMPLEVIS 18
  2426. #endif
  2427. #define FF_IDCT_FAAN 20
  2428. #define FF_IDCT_SIMPLENEON 22
  2429. #if FF_API_ARCH_ALPHA
  2430. #define FF_IDCT_SIMPLEALPHA 23
  2431. #endif
  2432. /**
  2433. * bits per sample/pixel from the demuxer (needed for huffyuv).
  2434. * - encoding: Set by libavcodec.
  2435. * - decoding: Set by user.
  2436. */
  2437. int bits_per_coded_sample;
  2438. /**
  2439. * Bits per sample/pixel of internal libavcodec pixel/sample format.
  2440. * - encoding: set by user.
  2441. * - decoding: set by libavcodec.
  2442. */
  2443. int bits_per_raw_sample;
  2444. #if FF_API_LOWRES
  2445. /**
  2446. * low resolution decoding, 1-> 1/2 size, 2->1/4 size
  2447. * - encoding: unused
  2448. * - decoding: Set by user.
  2449. * Code outside libavcodec should access this field using:
  2450. * av_codec_{get,set}_lowres(avctx)
  2451. */
  2452. int lowres;
  2453. #endif
  2454. /**
  2455. * the picture in the bitstream
  2456. * - encoding: Set by libavcodec.
  2457. * - decoding: unused
  2458. */
  2459. AVFrame *coded_frame;
  2460. /**
  2461. * thread count
  2462. * is used to decide how many independent tasks should be passed to execute()
  2463. * - encoding: Set by user.
  2464. * - decoding: Set by user.
  2465. */
  2466. int thread_count;
  2467. /**
  2468. * Which multithreading methods to use.
  2469. * Use of FF_THREAD_FRAME will increase decoding delay by one frame per thread,
  2470. * so clients which cannot provide future frames should not use it.
  2471. *
  2472. * - encoding: Set by user, otherwise the default is used.
  2473. * - decoding: Set by user, otherwise the default is used.
  2474. */
  2475. int thread_type;
  2476. #define FF_THREAD_FRAME 1 ///< Decode more than one frame at once
  2477. #define FF_THREAD_SLICE 2 ///< Decode more than one part of a single frame at once
  2478. /**
  2479. * Which multithreading methods are in use by the codec.
  2480. * - encoding: Set by libavcodec.
  2481. * - decoding: Set by libavcodec.
  2482. */
  2483. int active_thread_type;
  2484. /**
  2485. * Set by the client if its custom get_buffer() callback can be called
  2486. * synchronously from another thread, which allows faster multithreaded decoding.
  2487. * draw_horiz_band() will be called from other threads regardless of this setting.
  2488. * Ignored if the default get_buffer() is used.
  2489. * - encoding: Set by user.
  2490. * - decoding: Set by user.
  2491. */
  2492. int thread_safe_callbacks;
  2493. /**
  2494. * The codec may call this to execute several independent things.
  2495. * It will return only after finishing all tasks.
  2496. * The user may replace this with some multithreaded implementation,
  2497. * the default implementation will execute the parts serially.
  2498. * @param count the number of things to execute
  2499. * - encoding: Set by libavcodec, user can override.
  2500. * - decoding: Set by libavcodec, user can override.
  2501. */
  2502. int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size);
  2503. /**
  2504. * The codec may call this to execute several independent things.
  2505. * It will return only after finishing all tasks.
  2506. * The user may replace this with some multithreaded implementation,
  2507. * the default implementation will execute the parts serially.
  2508. * Also see avcodec_thread_init and e.g. the --enable-pthread configure option.
  2509. * @param c context passed also to func
  2510. * @param count the number of things to execute
  2511. * @param arg2 argument passed unchanged to func
  2512. * @param ret return values of executed functions, must have space for "count" values. May be NULL.
  2513. * @param func function that will be called count times, with jobnr from 0 to count-1.
  2514. * threadnr will be in the range 0 to c->thread_count-1 < MAX_THREADS and so that no
  2515. * two instances of func executing at the same time will have the same threadnr.
  2516. * @return always 0 currently, but code should handle a future improvement where when any call to func
  2517. * returns < 0 no further calls to func may be done and < 0 is returned.
  2518. * - encoding: Set by libavcodec, user can override.
  2519. * - decoding: Set by libavcodec, user can override.
  2520. */
  2521. int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count);
  2522. #if FF_API_THREAD_OPAQUE
  2523. /**
  2524. * @deprecated this field should not be used from outside of lavc
  2525. */
  2526. attribute_deprecated
  2527. void *thread_opaque;
  2528. #endif
  2529. /**
  2530. * noise vs. sse weight for the nsse comparsion function
  2531. * - encoding: Set by user.
  2532. * - decoding: unused
  2533. */
  2534. int nsse_weight;
  2535. /**
  2536. * profile
  2537. * - encoding: Set by user.
  2538. * - decoding: Set by libavcodec.
  2539. */
  2540. int profile;
  2541. #define FF_PROFILE_UNKNOWN -99
  2542. #define FF_PROFILE_RESERVED -100
  2543. #define FF_PROFILE_AAC_MAIN 0
  2544. #define FF_PROFILE_AAC_LOW 1
  2545. #define FF_PROFILE_AAC_SSR 2
  2546. #define FF_PROFILE_AAC_LTP 3
  2547. #define FF_PROFILE_AAC_HE 4
  2548. #define FF_PROFILE_AAC_HE_V2 28
  2549. #define FF_PROFILE_AAC_LD 22
  2550. #define FF_PROFILE_AAC_ELD 38
  2551. #define FF_PROFILE_MPEG2_AAC_LOW 128
  2552. #define FF_PROFILE_MPEG2_AAC_HE 131
  2553. #define FF_PROFILE_DTS 20
  2554. #define FF_PROFILE_DTS_ES 30
  2555. #define FF_PROFILE_DTS_96_24 40
  2556. #define FF_PROFILE_DTS_HD_HRA 50
  2557. #define FF_PROFILE_DTS_HD_MA 60
  2558. #define FF_PROFILE_MPEG2_422 0
  2559. #define FF_PROFILE_MPEG2_HIGH 1
  2560. #define FF_PROFILE_MPEG2_SS 2
  2561. #define FF_PROFILE_MPEG2_SNR_SCALABLE 3
  2562. #define FF_PROFILE_MPEG2_MAIN 4
  2563. #define FF_PROFILE_MPEG2_SIMPLE 5
  2564. #define FF_PROFILE_H264_CONSTRAINED (1<<9) // 8+1; constraint_set1_flag
  2565. #define FF_PROFILE_H264_INTRA (1<<11) // 8+3; constraint_set3_flag
  2566. #define FF_PROFILE_H264_BASELINE 66
  2567. #define FF_PROFILE_H264_CONSTRAINED_BASELINE (66|FF_PROFILE_H264_CONSTRAINED)
  2568. #define FF_PROFILE_H264_MAIN 77
  2569. #define FF_PROFILE_H264_EXTENDED 88
  2570. #define FF_PROFILE_H264_HIGH 100
  2571. #define FF_PROFILE_H264_HIGH_10 110
  2572. #define FF_PROFILE_H264_HIGH_10_INTRA (110|FF_PROFILE_H264_INTRA)
  2573. #define FF_PROFILE_H264_HIGH_422 122
  2574. #define FF_PROFILE_H264_HIGH_422_INTRA (122|FF_PROFILE_H264_INTRA)
  2575. #define FF_PROFILE_H264_HIGH_444 144
  2576. #define FF_PROFILE_H264_HIGH_444_PREDICTIVE 244
  2577. #define FF_PROFILE_H264_HIGH_444_INTRA (244|FF_PROFILE_H264_INTRA)
  2578. #define FF_PROFILE_H264_CAVLC_444 44
  2579. #define FF_PROFILE_VC1_SIMPLE 0
  2580. #define FF_PROFILE_VC1_MAIN 1
  2581. #define FF_PROFILE_VC1_COMPLEX 2
  2582. #define FF_PROFILE_VC1_ADVANCED 3
  2583. #define FF_PROFILE_MPEG4_SIMPLE 0
  2584. #define FF_PROFILE_MPEG4_SIMPLE_SCALABLE 1
  2585. #define FF_PROFILE_MPEG4_CORE 2
  2586. #define FF_PROFILE_MPEG4_MAIN 3
  2587. #define FF_PROFILE_MPEG4_N_BIT 4
  2588. #define FF_PROFILE_MPEG4_SCALABLE_TEXTURE 5
  2589. #define FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION 6
  2590. #define FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE 7
  2591. #define FF_PROFILE_MPEG4_HYBRID 8
  2592. #define FF_PROFILE_MPEG4_ADVANCED_REAL_TIME 9
  2593. #define FF_PROFILE_MPEG4_CORE_SCALABLE 10
  2594. #define FF_PROFILE_MPEG4_ADVANCED_CODING 11
  2595. #define FF_PROFILE_MPEG4_ADVANCED_CORE 12
  2596. #define FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE 13
  2597. #define FF_PROFILE_MPEG4_SIMPLE_STUDIO 14
  2598. #define FF_PROFILE_MPEG4_ADVANCED_SIMPLE 15
  2599. #define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_0 0
  2600. #define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_1 1
  2601. #define FF_PROFILE_JPEG2000_CSTREAM_NO_RESTRICTION 2
  2602. #define FF_PROFILE_JPEG2000_DCINEMA_2K 3
  2603. #define FF_PROFILE_JPEG2000_DCINEMA_4K 4
  2604. #define FF_PROFILE_HEVC_MAIN 1
  2605. #define FF_PROFILE_HEVC_MAIN_10 2
  2606. #define FF_PROFILE_HEVC_MAIN_STILL_PICTURE 3
  2607. /**
  2608. * level
  2609. * - encoding: Set by user.
  2610. * - decoding: Set by libavcodec.
  2611. */
  2612. int level;
  2613. #define FF_LEVEL_UNKNOWN -99
  2614. /**
  2615. * Skip loop filtering for selected frames.
  2616. * - encoding: unused
  2617. * - decoding: Set by user.
  2618. */
  2619. enum AVDiscard skip_loop_filter;
  2620. /**
  2621. * Skip IDCT/dequantization for selected frames.
  2622. * - encoding: unused
  2623. * - decoding: Set by user.
  2624. */
  2625. enum AVDiscard skip_idct;
  2626. /**
  2627. * Skip decoding for selected frames.
  2628. * - encoding: unused
  2629. * - decoding: Set by user.
  2630. */
  2631. enum AVDiscard skip_frame;
  2632. /**
  2633. * Header containing style information for text subtitles.
  2634. * For SUBTITLE_ASS subtitle type, it should contain the whole ASS
  2635. * [Script Info] and [V4+ Styles] section, plus the [Events] line and
  2636. * the Format line following. It shouldn't include any Dialogue line.
  2637. * - encoding: Set/allocated/freed by user (before avcodec_open2())
  2638. * - decoding: Set/allocated/freed by libavcodec (by avcodec_open2())
  2639. */
  2640. uint8_t *subtitle_header;
  2641. int subtitle_header_size;
  2642. #if FF_API_ERROR_RATE
  2643. /**
  2644. * @deprecated use the 'error_rate' private AVOption of the mpegvideo
  2645. * encoders
  2646. */
  2647. attribute_deprecated
  2648. int error_rate;
  2649. #endif
  2650. #if FF_API_CODEC_PKT
  2651. /**
  2652. * @deprecated this field is not supposed to be accessed from outside lavc
  2653. */
  2654. attribute_deprecated
  2655. AVPacket *pkt;
  2656. #endif
  2657. /**
  2658. * VBV delay coded in the last frame (in periods of a 27 MHz clock).
  2659. * Used for compliant TS muxing.
  2660. * - encoding: Set by libavcodec.
  2661. * - decoding: unused.
  2662. */
  2663. uint64_t vbv_delay;
  2664. /**
  2665. * Timebase in which pkt_dts/pts and AVPacket.dts/pts are.
  2666. * Code outside libavcodec should access this field using:
  2667. * av_codec_{get,set}_pkt_timebase(avctx)
  2668. * - encoding unused.
  2669. * - decoding set by user.
  2670. */
  2671. AVRational pkt_timebase;
  2672. /**
  2673. * AVCodecDescriptor
  2674. * Code outside libavcodec should access this field using:
  2675. * av_codec_{get,set}_codec_descriptor(avctx)
  2676. * - encoding: unused.
  2677. * - decoding: set by libavcodec.
  2678. */
  2679. const AVCodecDescriptor *codec_descriptor;
  2680. #if !FF_API_LOWRES
  2681. /**
  2682. * low resolution decoding, 1-> 1/2 size, 2->1/4 size
  2683. * - encoding: unused
  2684. * - decoding: Set by user.
  2685. * Code outside libavcodec should access this field using:
  2686. * av_codec_{get,set}_lowres(avctx)
  2687. */
  2688. int lowres;
  2689. #endif
  2690. /**
  2691. * Current statistics for PTS correction.
  2692. * - decoding: maintained and used by libavcodec, not intended to be used by user apps
  2693. * - encoding: unused
  2694. */
  2695. int64_t pts_correction_num_faulty_pts; /// Number of incorrect PTS values so far
  2696. int64_t pts_correction_num_faulty_dts; /// Number of incorrect DTS values so far
  2697. int64_t pts_correction_last_pts; /// PTS of the last frame
  2698. int64_t pts_correction_last_dts; /// DTS of the last frame
  2699. /**
  2700. * Character encoding of the input subtitles file.
  2701. * - decoding: set by user
  2702. * - encoding: unused
  2703. */
  2704. char *sub_charenc;
  2705. /**
  2706. * Subtitles character encoding mode. Formats or codecs might be adjusting
  2707. * this setting (if they are doing the conversion themselves for instance).
  2708. * - decoding: set by libavcodec
  2709. * - encoding: unused
  2710. */
  2711. int sub_charenc_mode;
  2712. #define FF_SUB_CHARENC_MODE_DO_NOTHING -1 ///< do nothing (demuxer outputs a stream supposed to be already in UTF-8, or the codec is bitmap for instance)
  2713. #define FF_SUB_CHARENC_MODE_AUTOMATIC 0 ///< libavcodec will select the mode itself
  2714. #define FF_SUB_CHARENC_MODE_PRE_DECODER 1 ///< the AVPacket data needs to be recoded to UTF-8 before being fed to the decoder, requires iconv
  2715. /**
  2716. * Skip processing alpha if supported by codec.
  2717. * Note that if the format uses pre-multiplied alpha (common with VP6,
  2718. * and recommended due to better video quality/compression)
  2719. * the image will look as if alpha-blended onto a black background.
  2720. * However for formats that do not use pre-multiplied alpha
  2721. * there might be serious artefacts (though e.g. libswscale currently
  2722. * assumes pre-multiplied alpha anyway).
  2723. * Code outside libavcodec should access this field using AVOptions
  2724. *
  2725. * - decoding: set by user
  2726. * - encoding: unused
  2727. */
  2728. int skip_alpha;
  2729. /**
  2730. * Number of samples to skip after a discontinuity
  2731. * - decoding: unused
  2732. * - encoding: set by libavcodec
  2733. */
  2734. int seek_preroll;
  2735. #if !FF_API_DEBUG_MV
  2736. /**
  2737. * debug motion vectors
  2738. * Code outside libavcodec should access this field using AVOptions
  2739. * - encoding: Set by user.
  2740. * - decoding: Set by user.
  2741. */
  2742. int debug_mv;
  2743. #define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames
  2744. #define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames
  2745. #define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames
  2746. #endif
  2747. /**
  2748. * custom intra quantization matrix
  2749. * Code outside libavcodec should access this field using av_codec_g/set_chroma_intra_matrix()
  2750. * - encoding: Set by user, can be NULL.
  2751. * - decoding: unused.
  2752. */
  2753. uint16_t *chroma_intra_matrix;
  2754. } AVCodecContext;
  2755. AVRational av_codec_get_pkt_timebase (const AVCodecContext *avctx);
  2756. void av_codec_set_pkt_timebase (AVCodecContext *avctx, AVRational val);
  2757. const AVCodecDescriptor *av_codec_get_codec_descriptor(const AVCodecContext *avctx);
  2758. void av_codec_set_codec_descriptor(AVCodecContext *avctx, const AVCodecDescriptor *desc);
  2759. int av_codec_get_lowres(const AVCodecContext *avctx);
  2760. void av_codec_set_lowres(AVCodecContext *avctx, int val);
  2761. int av_codec_get_seek_preroll(const AVCodecContext *avctx);
  2762. void av_codec_set_seek_preroll(AVCodecContext *avctx, int val);
  2763. uint16_t *av_codec_get_chroma_intra_matrix(const AVCodecContext *avctx);
  2764. void av_codec_set_chroma_intra_matrix(AVCodecContext *avctx, uint16_t *val);
  2765. /**
  2766. * AVProfile.
  2767. */
  2768. typedef struct AVProfile {
  2769. int profile;
  2770. const char *name; ///< short name for the profile
  2771. } AVProfile;
  2772. typedef struct AVCodecDefault AVCodecDefault;
  2773. struct AVSubtitle;
  2774. /**
  2775. * AVCodec.
  2776. */
  2777. typedef struct AVCodec {
  2778. /**
  2779. * Name of the codec implementation.
  2780. * The name is globally unique among encoders and among decoders (but an
  2781. * encoder and a decoder can share the same name).
  2782. * This is the primary way to find a codec from the user perspective.
  2783. */
  2784. const char *name;
  2785. /**
  2786. * Descriptive name for the codec, meant to be more human readable than name.
  2787. * You should use the NULL_IF_CONFIG_SMALL() macro to define it.
  2788. */
  2789. const char *long_name;
  2790. enum AVMediaType type;
  2791. enum AVCodecID id;
  2792. /**
  2793. * Codec capabilities.
  2794. * see CODEC_CAP_*
  2795. */
  2796. int capabilities;
  2797. const AVRational *supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0}
  2798. const enum AVPixelFormat *pix_fmts; ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1
  2799. const int *supported_samplerates; ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0
  2800. const enum AVSampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1
  2801. const uint64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0
  2802. #if FF_API_LOWRES
  2803. uint8_t max_lowres; ///< maximum value for lowres supported by the decoder, no direct access, use av_codec_get_max_lowres()
  2804. #endif
  2805. const AVClass *priv_class; ///< AVClass for the private context
  2806. const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}
  2807. /*****************************************************************
  2808. * No fields below this line are part of the public API. They
  2809. * may not be used outside of libavcodec and can be changed and
  2810. * removed at will.
  2811. * New public fields should be added right above.
  2812. *****************************************************************
  2813. */
  2814. int priv_data_size;
  2815. struct AVCodec *next;
  2816. /**
  2817. * @name Frame-level threading support functions
  2818. * @{
  2819. */
  2820. /**
  2821. * If defined, called on thread contexts when they are created.
  2822. * If the codec allocates writable tables in init(), re-allocate them here.
  2823. * priv_data will be set to a copy of the original.
  2824. */
  2825. int (*init_thread_copy)(AVCodecContext *);
  2826. /**
  2827. * Copy necessary context variables from a previous thread context to the current one.
  2828. * If not defined, the next thread will start automatically; otherwise, the codec
  2829. * must call ff_thread_finish_setup().
  2830. *
  2831. * dst and src will (rarely) point to the same context, in which case memcpy should be skipped.
  2832. */
  2833. int (*update_thread_context)(AVCodecContext *dst, const AVCodecContext *src);
  2834. /** @} */
  2835. /**
  2836. * Private codec-specific defaults.
  2837. */
  2838. const AVCodecDefault *defaults;
  2839. /**
  2840. * Initialize codec static data, called from avcodec_register().
  2841. */
  2842. void (*init_static_data)(struct AVCodec *codec);
  2843. int (*init)(AVCodecContext *);
  2844. int (*encode_sub)(AVCodecContext *, uint8_t *buf, int buf_size,
  2845. const struct AVSubtitle *sub);
  2846. /**
  2847. * Encode data to an AVPacket.
  2848. *
  2849. * @param avctx codec context
  2850. * @param avpkt output AVPacket (may contain a user-provided buffer)
  2851. * @param[in] frame AVFrame containing the raw data to be encoded
  2852. * @param[out] got_packet_ptr encoder sets to 0 or 1 to indicate that a
  2853. * non-empty packet was returned in avpkt.
  2854. * @return 0 on success, negative error code on failure
  2855. */
  2856. int (*encode2)(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame,
  2857. int *got_packet_ptr);
  2858. int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt);
  2859. int (*close)(AVCodecContext *);
  2860. /**
  2861. * Flush buffers.
  2862. * Will be called when seeking
  2863. */
  2864. void (*flush)(AVCodecContext *);
  2865. } AVCodec;
  2866. int av_codec_get_max_lowres(const AVCodec *codec);
  2867. struct MpegEncContext;
  2868. /**
  2869. * AVHWAccel.
  2870. */
  2871. typedef struct AVHWAccel {
  2872. /**
  2873. * Name of the hardware accelerated codec.
  2874. * The name is globally unique among encoders and among decoders (but an
  2875. * encoder and a decoder can share the same name).
  2876. */
  2877. const char *name;
  2878. /**
  2879. * Type of codec implemented by the hardware accelerator.
  2880. *
  2881. * See AVMEDIA_TYPE_xxx
  2882. */
  2883. enum AVMediaType type;
  2884. /**
  2885. * Codec implemented by the hardware accelerator.
  2886. *
  2887. * See AV_CODEC_ID_xxx
  2888. */
  2889. enum AVCodecID id;
  2890. /**
  2891. * Supported pixel format.
  2892. *
  2893. * Only hardware accelerated formats are supported here.
  2894. */
  2895. enum AVPixelFormat pix_fmt;
  2896. /**
  2897. * Hardware accelerated codec capabilities.
  2898. * see FF_HWACCEL_CODEC_CAP_*
  2899. */
  2900. int capabilities;
  2901. struct AVHWAccel *next;
  2902. /**
  2903. * Called at the beginning of each frame or field picture.
  2904. *
  2905. * Meaningful frame information (codec specific) is guaranteed to
  2906. * be parsed at this point. This function is mandatory.
  2907. *
  2908. * Note that buf can be NULL along with buf_size set to 0.
  2909. * Otherwise, this means the whole frame is available at this point.
  2910. *
  2911. * @param avctx the codec context
  2912. * @param buf the frame data buffer base
  2913. * @param buf_size the size of the frame in bytes
  2914. * @return zero if successful, a negative value otherwise
  2915. */
  2916. int (*start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
  2917. /**
  2918. * Callback for each slice.
  2919. *
  2920. * Meaningful slice information (codec specific) is guaranteed to
  2921. * be parsed at this point. This function is mandatory.
  2922. * The only exception is XvMC, that works on MB level.
  2923. *
  2924. * @param avctx the codec context
  2925. * @param buf the slice data buffer base
  2926. * @param buf_size the size of the slice in bytes
  2927. * @return zero if successful, a negative value otherwise
  2928. */
  2929. int (*decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
  2930. /**
  2931. * Called at the end of each frame or field picture.
  2932. *
  2933. * The whole picture is parsed at this point and can now be sent
  2934. * to the hardware accelerator. This function is mandatory.
  2935. *
  2936. * @param avctx the codec context
  2937. * @return zero if successful, a negative value otherwise
  2938. */
  2939. int (*end_frame)(AVCodecContext *avctx);
  2940. /**
  2941. * Size of HW accelerator private data.
  2942. *
  2943. * Private data is allocated with av_mallocz() before
  2944. * AVCodecContext.get_buffer() and deallocated after
  2945. * AVCodecContext.release_buffer().
  2946. */
  2947. int priv_data_size;
  2948. /**
  2949. * Called for every Macroblock in a slice.
  2950. *
  2951. * XvMC uses it to replace the ff_MPV_decode_mb().
  2952. * Instead of decoding to raw picture, MB parameters are
  2953. * stored in an array provided by the video driver.
  2954. *
  2955. * @param s the mpeg context
  2956. */
  2957. void (*decode_mb)(struct MpegEncContext *s);
  2958. } AVHWAccel;
  2959. /**
  2960. * @defgroup lavc_picture AVPicture
  2961. *
  2962. * Functions for working with AVPicture
  2963. * @{
  2964. */
  2965. /**
  2966. * Picture data structure.
  2967. *
  2968. * Up to four components can be stored into it, the last component is
  2969. * alpha.
  2970. */
  2971. typedef struct AVPicture {
  2972. uint8_t *data[AV_NUM_DATA_POINTERS]; ///< pointers to the image data planes
  2973. int linesize[AV_NUM_DATA_POINTERS]; ///< number of bytes per line
  2974. } AVPicture;
  2975. /**
  2976. * @}
  2977. */
  2978. enum AVSubtitleType {
  2979. SUBTITLE_NONE,
  2980. SUBTITLE_BITMAP, ///< A bitmap, pict will be set
  2981. /**
  2982. * Plain text, the text field must be set by the decoder and is
  2983. * authoritative. ass and pict fields may contain approximations.
  2984. */
  2985. SUBTITLE_TEXT,
  2986. /**
  2987. * Formatted text, the ass field must be set by the decoder and is
  2988. * authoritative. pict and text fields may contain approximations.
  2989. */
  2990. SUBTITLE_ASS,
  2991. };
  2992. #define AV_SUBTITLE_FLAG_FORCED 0x00000001
  2993. typedef struct AVSubtitleRect {
  2994. int x; ///< top left corner of pict, undefined when pict is not set
  2995. int y; ///< top left corner of pict, undefined when pict is not set
  2996. int w; ///< width of pict, undefined when pict is not set
  2997. int h; ///< height of pict, undefined when pict is not set
  2998. int nb_colors; ///< number of colors in pict, undefined when pict is not set
  2999. /**
  3000. * data+linesize for the bitmap of this subtitle.
  3001. * can be set for text/ass as well once they where rendered
  3002. */
  3003. AVPicture pict;
  3004. enum AVSubtitleType type;
  3005. char *text; ///< 0 terminated plain UTF-8 text
  3006. /**
  3007. * 0 terminated ASS/SSA compatible event line.
  3008. * The presentation of this is unaffected by the other values in this
  3009. * struct.
  3010. */
  3011. char *ass;
  3012. int flags;
  3013. } AVSubtitleRect;
  3014. typedef struct AVSubtitle {
  3015. uint16_t format; /* 0 = graphics */
  3016. uint32_t start_display_time; /* relative to packet pts, in ms */
  3017. uint32_t end_display_time; /* relative to packet pts, in ms */
  3018. unsigned num_rects;
  3019. AVSubtitleRect **rects;
  3020. int64_t pts; ///< Same as packet pts, in AV_TIME_BASE
  3021. } AVSubtitle;
  3022. /**
  3023. * If c is NULL, returns the first registered codec,
  3024. * if c is non-NULL, returns the next registered codec after c,
  3025. * or NULL if c is the last one.
  3026. */
  3027. AVCodec *av_codec_next(const AVCodec *c);
  3028. /**
  3029. * Return the LIBAVCODEC_VERSION_INT constant.
  3030. */
  3031. unsigned avcodec_version(void);
  3032. /**
  3033. * Return the libavcodec build-time configuration.
  3034. */
  3035. const char *avcodec_configuration(void);
  3036. /**
  3037. * Return the libavcodec license.
  3038. */
  3039. const char *avcodec_license(void);
  3040. /**
  3041. * Register the codec codec and initialize libavcodec.
  3042. *
  3043. * @warning either this function or avcodec_register_all() must be called
  3044. * before any other libavcodec functions.
  3045. *
  3046. * @see avcodec_register_all()
  3047. */
  3048. void avcodec_register(AVCodec *codec);
  3049. /**
  3050. * Register all the codecs, parsers and bitstream filters which were enabled at
  3051. * configuration time. If you do not call this function you can select exactly
  3052. * which formats you want to support, by using the individual registration
  3053. * functions.
  3054. *
  3055. * @see avcodec_register
  3056. * @see av_register_codec_parser
  3057. * @see av_register_bitstream_filter
  3058. */
  3059. void avcodec_register_all(void);
  3060. /**
  3061. * Allocate an AVCodecContext and set its fields to default values. The
  3062. * resulting struct can be deallocated by calling avcodec_close() on it followed
  3063. * by av_free().
  3064. *
  3065. * @param codec if non-NULL, allocate private data and initialize defaults
  3066. * for the given codec. It is illegal to then call avcodec_open2()
  3067. * with a different codec.
  3068. * If NULL, then the codec-specific defaults won't be initialized,
  3069. * which may result in suboptimal default settings (this is
  3070. * important mainly for encoders, e.g. libx264).
  3071. *
  3072. * @return An AVCodecContext filled with default values or NULL on failure.
  3073. * @see avcodec_get_context_defaults
  3074. */
  3075. AVCodecContext *avcodec_alloc_context3(const AVCodec *codec);
  3076. /**
  3077. * Set the fields of the given AVCodecContext to default values corresponding
  3078. * to the given codec (defaults may be codec-dependent).
  3079. *
  3080. * Do not call this function if a non-NULL codec has been passed
  3081. * to avcodec_alloc_context3() that allocated this AVCodecContext.
  3082. * If codec is non-NULL, it is illegal to call avcodec_open2() with a
  3083. * different codec on this AVCodecContext.
  3084. */
  3085. int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec);
  3086. /**
  3087. * Get the AVClass for AVCodecContext. It can be used in combination with
  3088. * AV_OPT_SEARCH_FAKE_OBJ for examining options.
  3089. *
  3090. * @see av_opt_find().
  3091. */
  3092. const AVClass *avcodec_get_class(void);
  3093. /**
  3094. * Get the AVClass for AVFrame. It can be used in combination with
  3095. * AV_OPT_SEARCH_FAKE_OBJ for examining options.
  3096. *
  3097. * @see av_opt_find().
  3098. */
  3099. const AVClass *avcodec_get_frame_class(void);
  3100. /**
  3101. * Get the AVClass for AVSubtitleRect. It can be used in combination with
  3102. * AV_OPT_SEARCH_FAKE_OBJ for examining options.
  3103. *
  3104. * @see av_opt_find().
  3105. */
  3106. const AVClass *avcodec_get_subtitle_rect_class(void);
  3107. /**
  3108. * Copy the settings of the source AVCodecContext into the destination
  3109. * AVCodecContext. The resulting destination codec context will be
  3110. * unopened, i.e. you are required to call avcodec_open2() before you
  3111. * can use this AVCodecContext to decode/encode video/audio data.
  3112. *
  3113. * @param dest target codec context, should be initialized with
  3114. * avcodec_alloc_context3(NULL), but otherwise uninitialized
  3115. * @param src source codec context
  3116. * @return AVERROR() on error (e.g. memory allocation error), 0 on success
  3117. */
  3118. int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src);
  3119. #if FF_API_AVFRAME_LAVC
  3120. /**
  3121. * @deprecated use av_frame_alloc()
  3122. */
  3123. attribute_deprecated
  3124. AVFrame *avcodec_alloc_frame(void);
  3125. /**
  3126. * Set the fields of the given AVFrame to default values.
  3127. *
  3128. * @param frame The AVFrame of which the fields should be set to default values.
  3129. *
  3130. * @deprecated use av_frame_unref()
  3131. */
  3132. attribute_deprecated
  3133. void avcodec_get_frame_defaults(AVFrame *frame);
  3134. /**
  3135. * Free the frame and any dynamically allocated objects in it,
  3136. * e.g. extended_data.
  3137. *
  3138. * @param frame frame to be freed. The pointer will be set to NULL.
  3139. *
  3140. * @warning this function does NOT free the data buffers themselves
  3141. * (it does not know how, since they might have been allocated with
  3142. * a custom get_buffer()).
  3143. *
  3144. * @deprecated use av_frame_free()
  3145. */
  3146. attribute_deprecated
  3147. void avcodec_free_frame(AVFrame **frame);
  3148. #endif
  3149. /**
  3150. * Initialize the AVCodecContext to use the given AVCodec. Prior to using this
  3151. * function the context has to be allocated with avcodec_alloc_context3().
  3152. *
  3153. * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),
  3154. * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for
  3155. * retrieving a codec.
  3156. *
  3157. * @warning This function is not thread safe!
  3158. *
  3159. * @code
  3160. * avcodec_register_all();
  3161. * av_dict_set(&opts, "b", "2.5M", 0);
  3162. * codec = avcodec_find_decoder(AV_CODEC_ID_H264);
  3163. * if (!codec)
  3164. * exit(1);
  3165. *
  3166. * context = avcodec_alloc_context3(codec);
  3167. *
  3168. * if (avcodec_open2(context, codec, opts) < 0)
  3169. * exit(1);
  3170. * @endcode
  3171. *
  3172. * @param avctx The context to initialize.
  3173. * @param codec The codec to open this context for. If a non-NULL codec has been
  3174. * previously passed to avcodec_alloc_context3() or
  3175. * avcodec_get_context_defaults3() for this context, then this
  3176. * parameter MUST be either NULL or equal to the previously passed
  3177. * codec.
  3178. * @param options A dictionary filled with AVCodecContext and codec-private options.
  3179. * On return this object will be filled with options that were not found.
  3180. *
  3181. * @return zero on success, a negative value on error
  3182. * @see avcodec_alloc_context3(), avcodec_find_decoder(), avcodec_find_encoder(),
  3183. * av_dict_set(), av_opt_find().
  3184. */
  3185. int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options);
  3186. /**
  3187. * Close a given AVCodecContext and free all the data associated with it
  3188. * (but not the AVCodecContext itself).
  3189. *
  3190. * Calling this function on an AVCodecContext that hasn't been opened will free
  3191. * the codec-specific data allocated in avcodec_alloc_context3() /
  3192. * avcodec_get_context_defaults3() with a non-NULL codec. Subsequent calls will
  3193. * do nothing.
  3194. */
  3195. int avcodec_close(AVCodecContext *avctx);
  3196. /**
  3197. * Free all allocated data in the given subtitle struct.
  3198. *
  3199. * @param sub AVSubtitle to free.
  3200. */
  3201. void avsubtitle_free(AVSubtitle *sub);
  3202. /**
  3203. * @}
  3204. */
  3205. /**
  3206. * @addtogroup lavc_packet
  3207. * @{
  3208. */
  3209. #if FF_API_DESTRUCT_PACKET
  3210. /**
  3211. * Default packet destructor.
  3212. * @deprecated use the AVBuffer API instead
  3213. */
  3214. attribute_deprecated
  3215. void av_destruct_packet(AVPacket *pkt);
  3216. #endif
  3217. /**
  3218. * Initialize optional fields of a packet with default values.
  3219. *
  3220. * Note, this does not touch the data and size members, which have to be
  3221. * initialized separately.
  3222. *
  3223. * @param pkt packet
  3224. */
  3225. void av_init_packet(AVPacket *pkt);
  3226. /**
  3227. * Allocate the payload of a packet and initialize its fields with
  3228. * default values.
  3229. *
  3230. * @param pkt packet
  3231. * @param size wanted payload size
  3232. * @return 0 if OK, AVERROR_xxx otherwise
  3233. */
  3234. int av_new_packet(AVPacket *pkt, int size);
  3235. /**
  3236. * Reduce packet size, correctly zeroing padding
  3237. *
  3238. * @param pkt packet
  3239. * @param size new size
  3240. */
  3241. void av_shrink_packet(AVPacket *pkt, int size);
  3242. /**
  3243. * Increase packet size, correctly zeroing padding
  3244. *
  3245. * @param pkt packet
  3246. * @param grow_by number of bytes by which to increase the size of the packet
  3247. */
  3248. int av_grow_packet(AVPacket *pkt, int grow_by);
  3249. /**
  3250. * Initialize a reference-counted packet from av_malloc()ed data.
  3251. *
  3252. * @param pkt packet to be initialized. This function will set the data, size,
  3253. * buf and destruct fields, all others are left untouched.
  3254. * @param data Data allocated by av_malloc() to be used as packet data. If this
  3255. * function returns successfully, the data is owned by the underlying AVBuffer.
  3256. * The caller may not access the data through other means.
  3257. * @param size size of data in bytes, without the padding. I.e. the full buffer
  3258. * size is assumed to be size + FF_INPUT_BUFFER_PADDING_SIZE.
  3259. *
  3260. * @return 0 on success, a negative AVERROR on error
  3261. */
  3262. int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size);
  3263. /**
  3264. * @warning This is a hack - the packet memory allocation stuff is broken. The
  3265. * packet is allocated if it was not really allocated.
  3266. */
  3267. int av_dup_packet(AVPacket *pkt);
  3268. /**
  3269. * Copy packet, including contents
  3270. *
  3271. * @return 0 on success, negative AVERROR on fail
  3272. */
  3273. int av_copy_packet(AVPacket *dst, AVPacket *src);
  3274. /**
  3275. * Copy packet side data
  3276. *
  3277. * @return 0 on success, negative AVERROR on fail
  3278. */
  3279. int av_copy_packet_side_data(AVPacket *dst, AVPacket *src);
  3280. /**
  3281. * Free a packet.
  3282. *
  3283. * @param pkt packet to free
  3284. */
  3285. void av_free_packet(AVPacket *pkt);
  3286. /**
  3287. * Allocate new information of a packet.
  3288. *
  3289. * @param pkt packet
  3290. * @param type side information type
  3291. * @param size side information size
  3292. * @return pointer to fresh allocated data or NULL otherwise
  3293. */
  3294. uint8_t* av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
  3295. int size);
  3296. /**
  3297. * Shrink the already allocated side data buffer
  3298. *
  3299. * @param pkt packet
  3300. * @param type side information type
  3301. * @param size new side information size
  3302. * @return 0 on success, < 0 on failure
  3303. */
  3304. int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
  3305. int size);
  3306. /**
  3307. * Get side information from packet.
  3308. *
  3309. * @param pkt packet
  3310. * @param type desired side information type
  3311. * @param size pointer for side information size to store (optional)
  3312. * @return pointer to data if present or NULL otherwise
  3313. */
  3314. uint8_t* av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
  3315. int *size);
  3316. int av_packet_merge_side_data(AVPacket *pkt);
  3317. int av_packet_split_side_data(AVPacket *pkt);
  3318. /**
  3319. * Pack a dictionary for use in side_data.
  3320. *
  3321. * @param dict The dictionary to pack.
  3322. * @param size pointer to store the size of the returned data
  3323. * @return pointer to data if successful, NULL otherwise
  3324. */
  3325. uint8_t *av_packet_pack_dictionary(AVDictionary *dict, int *size);
  3326. /**
  3327. * Unpack a dictionary from side_data.
  3328. *
  3329. * @param data data from side_data
  3330. * @param size size of the data
  3331. * @param dict the metadata storage dictionary
  3332. * @return 0 on success, < 0 on failure
  3333. */
  3334. int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **dict);
  3335. /**
  3336. * Convenience function to free all the side data stored.
  3337. * All the other fields stay untouched.
  3338. *
  3339. * @param pkt packet
  3340. */
  3341. void av_packet_free_side_data(AVPacket *pkt);
  3342. /**
  3343. * Setup a new reference to the data described by a given packet
  3344. *
  3345. * If src is reference-counted, setup dst as a new reference to the
  3346. * buffer in src. Otherwise allocate a new buffer in dst and copy the
  3347. * data from src into it.
  3348. *
  3349. * All the other fields are copied from src.
  3350. *
  3351. * @see av_packet_unref
  3352. *
  3353. * @param dst Destination packet
  3354. * @param src Source packet
  3355. *
  3356. * @return 0 on success, a negative AVERROR on error.
  3357. */
  3358. int av_packet_ref(AVPacket *dst, AVPacket *src);
  3359. /**
  3360. * Wipe the packet.
  3361. *
  3362. * Unreference the buffer referenced by the packet and reset the
  3363. * remaining packet fields to their default values.
  3364. *
  3365. * @param pkt The packet to be unreferenced.
  3366. */
  3367. void av_packet_unref(AVPacket *pkt);
  3368. /**
  3369. * Move every field in src to dst and reset src.
  3370. *
  3371. * @see av_packet_unref
  3372. *
  3373. * @param src Source packet, will be reset
  3374. * @param dst Destination packet
  3375. */
  3376. void av_packet_move_ref(AVPacket *dst, AVPacket *src);
  3377. /**
  3378. * Copy only "properties" fields from src to dst.
  3379. *
  3380. * Properties for the purpose of this function are all the fields
  3381. * beside those related to the packet data (buf, data, size)
  3382. *
  3383. * @param dst Destination packet
  3384. * @param src Source packet
  3385. *
  3386. * @return 0 on success AVERROR on failure.
  3387. *
  3388. */
  3389. int av_packet_copy_props(AVPacket *dst, const AVPacket *src);
  3390. /**
  3391. * @}
  3392. */
  3393. /**
  3394. * @addtogroup lavc_decoding
  3395. * @{
  3396. */
  3397. /**
  3398. * Find a registered decoder with a matching codec ID.
  3399. *
  3400. * @param id AVCodecID of the requested decoder
  3401. * @return A decoder if one was found, NULL otherwise.
  3402. */
  3403. AVCodec *avcodec_find_decoder(enum AVCodecID id);
  3404. /**
  3405. * Find a registered decoder with the specified name.
  3406. *
  3407. * @param name name of the requested decoder
  3408. * @return A decoder if one was found, NULL otherwise.
  3409. */
  3410. AVCodec *avcodec_find_decoder_by_name(const char *name);
  3411. #if FF_API_GET_BUFFER
  3412. attribute_deprecated int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
  3413. attribute_deprecated void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
  3414. attribute_deprecated int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic);
  3415. #endif
  3416. /**
  3417. * The default callback for AVCodecContext.get_buffer2(). It is made public so
  3418. * it can be called by custom get_buffer2() implementations for decoders without
  3419. * CODEC_CAP_DR1 set.
  3420. */
  3421. int avcodec_default_get_buffer2(AVCodecContext *s, AVFrame *frame, int flags);
  3422. #if FF_API_EMU_EDGE
  3423. /**
  3424. * Return the amount of padding in pixels which the get_buffer callback must
  3425. * provide around the edge of the image for codecs which do not have the
  3426. * CODEC_FLAG_EMU_EDGE flag.
  3427. *
  3428. * @return Required padding in pixels.
  3429. *
  3430. * @deprecated CODEC_FLAG_EMU_EDGE is deprecated, so this function is no longer
  3431. * needed
  3432. */
  3433. attribute_deprecated
  3434. unsigned avcodec_get_edge_width(void);
  3435. #endif
  3436. /**
  3437. * Modify width and height values so that they will result in a memory
  3438. * buffer that is acceptable for the codec if you do not use any horizontal
  3439. * padding.
  3440. *
  3441. * May only be used if a codec with CODEC_CAP_DR1 has been opened.
  3442. */
  3443. void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);
  3444. /**
  3445. * Modify width and height values so that they will result in a memory
  3446. * buffer that is acceptable for the codec if you also ensure that all
  3447. * line sizes are a multiple of the respective linesize_align[i].
  3448. *
  3449. * May only be used if a codec with CODEC_CAP_DR1 has been opened.
  3450. */
  3451. void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
  3452. int linesize_align[AV_NUM_DATA_POINTERS]);
  3453. /**
  3454. * Converts AVChromaLocation to swscale x/y chroma position.
  3455. *
  3456. * The positions represent the chroma (0,0) position in a coordinates system
  3457. * with luma (0,0) representing the origin and luma(1,1) representing 256,256
  3458. *
  3459. * @param xpos horizontal chroma sample position
  3460. * @param ypos vertical chroma sample position
  3461. */
  3462. int avcodec_enum_to_chroma_pos(int *xpos, int *ypos, enum AVChromaLocation pos);
  3463. /**
  3464. * Converts swscale x/y chroma position to AVChromaLocation.
  3465. *
  3466. * The positions represent the chroma (0,0) position in a coordinates system
  3467. * with luma (0,0) representing the origin and luma(1,1) representing 256,256
  3468. *
  3469. * @param xpos horizontal chroma sample position
  3470. * @param ypos vertical chroma sample position
  3471. */
  3472. enum AVChromaLocation avcodec_chroma_pos_to_enum(int xpos, int ypos);
  3473. #if FF_API_OLD_DECODE_AUDIO
  3474. /**
  3475. * Wrapper function which calls avcodec_decode_audio4.
  3476. *
  3477. * @deprecated Use avcodec_decode_audio4 instead.
  3478. *
  3479. * Decode the audio frame of size avpkt->size from avpkt->data into samples.
  3480. * Some decoders may support multiple frames in a single AVPacket, such
  3481. * decoders would then just decode the first frame. In this case,
  3482. * avcodec_decode_audio3 has to be called again with an AVPacket that contains
  3483. * the remaining data in order to decode the second frame etc.
  3484. * If no frame
  3485. * could be outputted, frame_size_ptr is zero. Otherwise, it is the
  3486. * decompressed frame size in bytes.
  3487. *
  3488. * @warning You must set frame_size_ptr to the allocated size of the
  3489. * output buffer before calling avcodec_decode_audio3().
  3490. *
  3491. * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than
  3492. * the actual read bytes because some optimized bitstream readers read 32 or 64
  3493. * bits at once and could read over the end.
  3494. *
  3495. * @warning The end of the input buffer avpkt->data should be set to 0 to ensure that
  3496. * no overreading happens for damaged MPEG streams.
  3497. *
  3498. * @warning You must not provide a custom get_buffer() when using
  3499. * avcodec_decode_audio3(). Doing so will override it with
  3500. * avcodec_default_get_buffer. Use avcodec_decode_audio4() instead,
  3501. * which does allow the application to provide a custom get_buffer().
  3502. *
  3503. * @note You might have to align the input buffer avpkt->data and output buffer
  3504. * samples. The alignment requirements depend on the CPU: On some CPUs it isn't
  3505. * necessary at all, on others it won't work at all if not aligned and on others
  3506. * it will work but it will have an impact on performance.
  3507. *
  3508. * In practice, avpkt->data should have 4 byte alignment at minimum and
  3509. * samples should be 16 byte aligned unless the CPU doesn't need it
  3510. * (AltiVec and SSE do).
  3511. *
  3512. * @note Codecs which have the CODEC_CAP_DELAY capability set have a delay
  3513. * between input and output, these need to be fed with avpkt->data=NULL,
  3514. * avpkt->size=0 at the end to return the remaining frames.
  3515. *
  3516. * @param avctx the codec context
  3517. * @param[out] samples the output buffer, sample type in avctx->sample_fmt
  3518. * If the sample format is planar, each channel plane will
  3519. * be the same size, with no padding between channels.
  3520. * @param[in,out] frame_size_ptr the output buffer size in bytes
  3521. * @param[in] avpkt The input AVPacket containing the input buffer.
  3522. * You can create such packet with av_init_packet() and by then setting
  3523. * data and size, some decoders might in addition need other fields.
  3524. * All decoders are designed to use the least fields possible though.
  3525. * @return On error a negative value is returned, otherwise the number of bytes
  3526. * used or zero if no frame data was decompressed (used) from the input AVPacket.
  3527. */
  3528. attribute_deprecated int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples,
  3529. int *frame_size_ptr,
  3530. AVPacket *avpkt);
  3531. #endif
  3532. /**
  3533. * Decode the audio frame of size avpkt->size from avpkt->data into frame.
  3534. *
  3535. * Some decoders may support multiple frames in a single AVPacket. Such
  3536. * decoders would then just decode the first frame and the return value would be
  3537. * less than the packet size. In this case, avcodec_decode_audio4 has to be
  3538. * called again with an AVPacket containing the remaining data in order to
  3539. * decode the second frame, etc... Even if no frames are returned, the packet
  3540. * needs to be fed to the decoder with remaining data until it is completely
  3541. * consumed or an error occurs.
  3542. *
  3543. * Some decoders (those marked with CODEC_CAP_DELAY) have a delay between input
  3544. * and output. This means that for some packets they will not immediately
  3545. * produce decoded output and need to be flushed at the end of decoding to get
  3546. * all the decoded data. Flushing is done by calling this function with packets
  3547. * with avpkt->data set to NULL and avpkt->size set to 0 until it stops
  3548. * returning samples. It is safe to flush even those decoders that are not
  3549. * marked with CODEC_CAP_DELAY, then no samples will be returned.
  3550. *
  3551. * @warning The input buffer, avpkt->data must be FF_INPUT_BUFFER_PADDING_SIZE
  3552. * larger than the actual read bytes because some optimized bitstream
  3553. * readers read 32 or 64 bits at once and could read over the end.
  3554. *
  3555. * @param avctx the codec context
  3556. * @param[out] frame The AVFrame in which to store decoded audio samples.
  3557. * The decoder will allocate a buffer for the decoded frame by
  3558. * calling the AVCodecContext.get_buffer2() callback.
  3559. * When AVCodecContext.refcounted_frames is set to 1, the frame is
  3560. * reference counted and the returned reference belongs to the
  3561. * caller. The caller must release the frame using av_frame_unref()
  3562. * when the frame is no longer needed. The caller may safely write
  3563. * to the frame if av_frame_is_writable() returns 1.
  3564. * When AVCodecContext.refcounted_frames is set to 0, the returned
  3565. * reference belongs to the decoder and is valid only until the
  3566. * next call to this function or until closing or flushing the
  3567. * decoder. The caller may not write to it.
  3568. * @param[out] got_frame_ptr Zero if no frame could be decoded, otherwise it is
  3569. * non-zero. Note that this field being set to zero
  3570. * does not mean that an error has occurred. For
  3571. * decoders with CODEC_CAP_DELAY set, no given decode
  3572. * call is guaranteed to produce a frame.
  3573. * @param[in] avpkt The input AVPacket containing the input buffer.
  3574. * At least avpkt->data and avpkt->size should be set. Some
  3575. * decoders might also require additional fields to be set.
  3576. * @return A negative error code is returned if an error occurred during
  3577. * decoding, otherwise the number of bytes consumed from the input
  3578. * AVPacket is returned.
  3579. */
  3580. int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame,
  3581. int *got_frame_ptr, const AVPacket *avpkt);
  3582. /**
  3583. * Decode the video frame of size avpkt->size from avpkt->data into picture.
  3584. * Some decoders may support multiple frames in a single AVPacket, such
  3585. * decoders would then just decode the first frame.
  3586. *
  3587. * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than
  3588. * the actual read bytes because some optimized bitstream readers read 32 or 64
  3589. * bits at once and could read over the end.
  3590. *
  3591. * @warning The end of the input buffer buf should be set to 0 to ensure that
  3592. * no overreading happens for damaged MPEG streams.
  3593. *
  3594. * @note Codecs which have the CODEC_CAP_DELAY capability set have a delay
  3595. * between input and output, these need to be fed with avpkt->data=NULL,
  3596. * avpkt->size=0 at the end to return the remaining frames.
  3597. *
  3598. * @param avctx the codec context
  3599. * @param[out] picture The AVFrame in which the decoded video frame will be stored.
  3600. * Use av_frame_alloc() to get an AVFrame. The codec will
  3601. * allocate memory for the actual bitmap by calling the
  3602. * AVCodecContext.get_buffer2() callback.
  3603. * When AVCodecContext.refcounted_frames is set to 1, the frame is
  3604. * reference counted and the returned reference belongs to the
  3605. * caller. The caller must release the frame using av_frame_unref()
  3606. * when the frame is no longer needed. The caller may safely write
  3607. * to the frame if av_frame_is_writable() returns 1.
  3608. * When AVCodecContext.refcounted_frames is set to 0, the returned
  3609. * reference belongs to the decoder and is valid only until the
  3610. * next call to this function or until closing or flushing the
  3611. * decoder. The caller may not write to it.
  3612. *
  3613. * @param[in] avpkt The input AVPacket containing the input buffer.
  3614. * You can create such packet with av_init_packet() and by then setting
  3615. * data and size, some decoders might in addition need other fields like
  3616. * flags&AV_PKT_FLAG_KEY. All decoders are designed to use the least
  3617. * fields possible.
  3618. * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero.
  3619. * @return On error a negative value is returned, otherwise the number of bytes
  3620. * used or zero if no frame could be decompressed.
  3621. */
  3622. int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
  3623. int *got_picture_ptr,
  3624. const AVPacket *avpkt);
  3625. /**
  3626. * Decode a subtitle message.
  3627. * Return a negative value on error, otherwise return the number of bytes used.
  3628. * If no subtitle could be decompressed, got_sub_ptr is zero.
  3629. * Otherwise, the subtitle is stored in *sub.
  3630. * Note that CODEC_CAP_DR1 is not available for subtitle codecs. This is for
  3631. * simplicity, because the performance difference is expect to be negligible
  3632. * and reusing a get_buffer written for video codecs would probably perform badly
  3633. * due to a potentially very different allocation pattern.
  3634. *
  3635. * Some decoders (those marked with CODEC_CAP_DELAY) have a delay between input
  3636. * and output. This means that for some packets they will not immediately
  3637. * produce decoded output and need to be flushed at the end of decoding to get
  3638. * all the decoded data. Flushing is done by calling this function with packets
  3639. * with avpkt->data set to NULL and avpkt->size set to 0 until it stops
  3640. * returning subtitles. It is safe to flush even those decoders that are not
  3641. * marked with CODEC_CAP_DELAY, then no subtitles will be returned.
  3642. *
  3643. * @param avctx the codec context
  3644. * @param[out] sub The AVSubtitle in which the decoded subtitle will be stored, must be
  3645. freed with avsubtitle_free if *got_sub_ptr is set.
  3646. * @param[in,out] got_sub_ptr Zero if no subtitle could be decompressed, otherwise, it is nonzero.
  3647. * @param[in] avpkt The input AVPacket containing the input buffer.
  3648. */
  3649. int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
  3650. int *got_sub_ptr,
  3651. AVPacket *avpkt);
  3652. /**
  3653. * @defgroup lavc_parsing Frame parsing
  3654. * @{
  3655. */
  3656. enum AVPictureStructure {
  3657. AV_PICTURE_STRUCTURE_UNKNOWN, //< unknown
  3658. AV_PICTURE_STRUCTURE_TOP_FIELD, //< coded as top field
  3659. AV_PICTURE_STRUCTURE_BOTTOM_FIELD, //< coded as bottom field
  3660. AV_PICTURE_STRUCTURE_FRAME, //< coded as frame
  3661. };
  3662. typedef struct AVCodecParserContext {
  3663. void *priv_data;
  3664. struct AVCodecParser *parser;
  3665. int64_t frame_offset; /* offset of the current frame */
  3666. int64_t cur_offset; /* current offset
  3667. (incremented by each av_parser_parse()) */
  3668. int64_t next_frame_offset; /* offset of the next frame */
  3669. /* video info */
  3670. int pict_type; /* XXX: Put it back in AVCodecContext. */
  3671. /**
  3672. * This field is used for proper frame duration computation in lavf.
  3673. * It signals, how much longer the frame duration of the current frame
  3674. * is compared to normal frame duration.
  3675. *
  3676. * frame_duration = (1 + repeat_pict) * time_base
  3677. *
  3678. * It is used by codecs like H.264 to display telecined material.
  3679. */
  3680. int repeat_pict; /* XXX: Put it back in AVCodecContext. */
  3681. int64_t pts; /* pts of the current frame */
  3682. int64_t dts; /* dts of the current frame */
  3683. /* private data */
  3684. int64_t last_pts;
  3685. int64_t last_dts;
  3686. int fetch_timestamp;
  3687. #define AV_PARSER_PTS_NB 4
  3688. int cur_frame_start_index;
  3689. int64_t cur_frame_offset[AV_PARSER_PTS_NB];
  3690. int64_t cur_frame_pts[AV_PARSER_PTS_NB];
  3691. int64_t cur_frame_dts[AV_PARSER_PTS_NB];
  3692. int flags;
  3693. #define PARSER_FLAG_COMPLETE_FRAMES 0x0001
  3694. #define PARSER_FLAG_ONCE 0x0002
  3695. /// Set if the parser has a valid file offset
  3696. #define PARSER_FLAG_FETCHED_OFFSET 0x0004
  3697. #define PARSER_FLAG_USE_CODEC_TS 0x1000
  3698. int64_t offset; ///< byte offset from starting packet start
  3699. int64_t cur_frame_end[AV_PARSER_PTS_NB];
  3700. /**
  3701. * Set by parser to 1 for key frames and 0 for non-key frames.
  3702. * It is initialized to -1, so if the parser doesn't set this flag,
  3703. * old-style fallback using AV_PICTURE_TYPE_I picture type as key frames
  3704. * will be used.
  3705. */
  3706. int key_frame;
  3707. /**
  3708. * Time difference in stream time base units from the pts of this
  3709. * packet to the point at which the output from the decoder has converged
  3710. * independent from the availability of previous frames. That is, the
  3711. * frames are virtually identical no matter if decoding started from
  3712. * the very first frame or from this keyframe.
  3713. * Is AV_NOPTS_VALUE if unknown.
  3714. * This field is not the display duration of the current frame.
  3715. * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY
  3716. * set.
  3717. *
  3718. * The purpose of this field is to allow seeking in streams that have no
  3719. * keyframes in the conventional sense. It corresponds to the
  3720. * recovery point SEI in H.264 and match_time_delta in NUT. It is also
  3721. * essential for some types of subtitle streams to ensure that all
  3722. * subtitles are correctly displayed after seeking.
  3723. */
  3724. int64_t convergence_duration;
  3725. // Timestamp generation support:
  3726. /**
  3727. * Synchronization point for start of timestamp generation.
  3728. *
  3729. * Set to >0 for sync point, 0 for no sync point and <0 for undefined
  3730. * (default).
  3731. *
  3732. * For example, this corresponds to presence of H.264 buffering period
  3733. * SEI message.
  3734. */
  3735. int dts_sync_point;
  3736. /**
  3737. * Offset of the current timestamp against last timestamp sync point in
  3738. * units of AVCodecContext.time_base.
  3739. *
  3740. * Set to INT_MIN when dts_sync_point unused. Otherwise, it must
  3741. * contain a valid timestamp offset.
  3742. *
  3743. * Note that the timestamp of sync point has usually a nonzero
  3744. * dts_ref_dts_delta, which refers to the previous sync point. Offset of
  3745. * the next frame after timestamp sync point will be usually 1.
  3746. *
  3747. * For example, this corresponds to H.264 cpb_removal_delay.
  3748. */
  3749. int dts_ref_dts_delta;
  3750. /**
  3751. * Presentation delay of current frame in units of AVCodecContext.time_base.
  3752. *
  3753. * Set to INT_MIN when dts_sync_point unused. Otherwise, it must
  3754. * contain valid non-negative timestamp delta (presentation time of a frame
  3755. * must not lie in the past).
  3756. *
  3757. * This delay represents the difference between decoding and presentation
  3758. * time of the frame.
  3759. *
  3760. * For example, this corresponds to H.264 dpb_output_delay.
  3761. */
  3762. int pts_dts_delta;
  3763. /**
  3764. * Position of the packet in file.
  3765. *
  3766. * Analogous to cur_frame_pts/dts
  3767. */
  3768. int64_t cur_frame_pos[AV_PARSER_PTS_NB];
  3769. /**
  3770. * Byte position of currently parsed frame in stream.
  3771. */
  3772. int64_t pos;
  3773. /**
  3774. * Previous frame byte position.
  3775. */
  3776. int64_t last_pos;
  3777. /**
  3778. * Duration of the current frame.
  3779. * For audio, this is in units of 1 / AVCodecContext.sample_rate.
  3780. * For all other types, this is in units of AVCodecContext.time_base.
  3781. */
  3782. int duration;
  3783. enum AVFieldOrder field_order;
  3784. /**
  3785. * Indicate whether a picture is coded as a frame, top field or bottom field.
  3786. *
  3787. * For example, H.264 field_pic_flag equal to 0 corresponds to
  3788. * AV_PICTURE_STRUCTURE_FRAME. An H.264 picture with field_pic_flag
  3789. * equal to 1 and bottom_field_flag equal to 0 corresponds to
  3790. * AV_PICTURE_STRUCTURE_TOP_FIELD.
  3791. */
  3792. enum AVPictureStructure picture_structure;
  3793. /**
  3794. * Picture number incremented in presentation or output order.
  3795. * This field may be reinitialized at the first picture of a new sequence.
  3796. *
  3797. * For example, this corresponds to H.264 PicOrderCnt.
  3798. */
  3799. int output_picture_number;
  3800. } AVCodecParserContext;
  3801. typedef struct AVCodecParser {
  3802. int codec_ids[5]; /* several codec IDs are permitted */
  3803. int priv_data_size;
  3804. int (*parser_init)(AVCodecParserContext *s);
  3805. int (*parser_parse)(AVCodecParserContext *s,
  3806. AVCodecContext *avctx,
  3807. const uint8_t **poutbuf, int *poutbuf_size,
  3808. const uint8_t *buf, int buf_size);
  3809. void (*parser_close)(AVCodecParserContext *s);
  3810. int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size);
  3811. struct AVCodecParser *next;
  3812. } AVCodecParser;
  3813. AVCodecParser *av_parser_next(AVCodecParser *c);
  3814. void av_register_codec_parser(AVCodecParser *parser);
  3815. AVCodecParserContext *av_parser_init(int codec_id);
  3816. /**
  3817. * Parse a packet.
  3818. *
  3819. * @param s parser context.
  3820. * @param avctx codec context.
  3821. * @param poutbuf set to pointer to parsed buffer or NULL if not yet finished.
  3822. * @param poutbuf_size set to size of parsed buffer or zero if not yet finished.
  3823. * @param buf input buffer.
  3824. * @param buf_size input length, to signal EOF, this should be 0 (so that the last frame can be output).
  3825. * @param pts input presentation timestamp.
  3826. * @param dts input decoding timestamp.
  3827. * @param pos input byte position in stream.
  3828. * @return the number of bytes of the input bitstream used.
  3829. *
  3830. * Example:
  3831. * @code
  3832. * while(in_len){
  3833. * len = av_parser_parse2(myparser, AVCodecContext, &data, &size,
  3834. * in_data, in_len,
  3835. * pts, dts, pos);
  3836. * in_data += len;
  3837. * in_len -= len;
  3838. *
  3839. * if(size)
  3840. * decode_frame(data, size);
  3841. * }
  3842. * @endcode
  3843. */
  3844. int av_parser_parse2(AVCodecParserContext *s,
  3845. AVCodecContext *avctx,
  3846. uint8_t **poutbuf, int *poutbuf_size,
  3847. const uint8_t *buf, int buf_size,
  3848. int64_t pts, int64_t dts,
  3849. int64_t pos);
  3850. /**
  3851. * @return 0 if the output buffer is a subset of the input, 1 if it is allocated and must be freed
  3852. * @deprecated use AVBitStreamFilter
  3853. */
  3854. int av_parser_change(AVCodecParserContext *s,
  3855. AVCodecContext *avctx,
  3856. uint8_t **poutbuf, int *poutbuf_size,
  3857. const uint8_t *buf, int buf_size, int keyframe);
  3858. void av_parser_close(AVCodecParserContext *s);
  3859. /**
  3860. * @}
  3861. * @}
  3862. */
  3863. /**
  3864. * @addtogroup lavc_encoding
  3865. * @{
  3866. */
  3867. /**
  3868. * Find a registered encoder with a matching codec ID.
  3869. *
  3870. * @param id AVCodecID of the requested encoder
  3871. * @return An encoder if one was found, NULL otherwise.
  3872. */
  3873. AVCodec *avcodec_find_encoder(enum AVCodecID id);
  3874. /**
  3875. * Find a registered encoder with the specified name.
  3876. *
  3877. * @param name name of the requested encoder
  3878. * @return An encoder if one was found, NULL otherwise.
  3879. */
  3880. AVCodec *avcodec_find_encoder_by_name(const char *name);
  3881. #if FF_API_OLD_ENCODE_AUDIO
  3882. /**
  3883. * Encode an audio frame from samples into buf.
  3884. *
  3885. * @deprecated Use avcodec_encode_audio2 instead.
  3886. *
  3887. * @note The output buffer should be at least FF_MIN_BUFFER_SIZE bytes large.
  3888. * However, for codecs with avctx->frame_size equal to 0 (e.g. PCM) the user
  3889. * will know how much space is needed because it depends on the value passed
  3890. * in buf_size as described below. In that case a lower value can be used.
  3891. *
  3892. * @param avctx the codec context
  3893. * @param[out] buf the output buffer
  3894. * @param[in] buf_size the output buffer size
  3895. * @param[in] samples the input buffer containing the samples
  3896. * The number of samples read from this buffer is frame_size*channels,
  3897. * both of which are defined in avctx.
  3898. * For codecs which have avctx->frame_size equal to 0 (e.g. PCM) the number of
  3899. * samples read from samples is equal to:
  3900. * buf_size * 8 / (avctx->channels * av_get_bits_per_sample(avctx->codec_id))
  3901. * This also implies that av_get_bits_per_sample() must not return 0 for these
  3902. * codecs.
  3903. * @return On error a negative value is returned, on success zero or the number
  3904. * of bytes used to encode the data read from the input buffer.
  3905. */
  3906. int attribute_deprecated avcodec_encode_audio(AVCodecContext *avctx,
  3907. uint8_t *buf, int buf_size,
  3908. const short *samples);
  3909. #endif
  3910. /**
  3911. * Encode a frame of audio.
  3912. *
  3913. * Takes input samples from frame and writes the next output packet, if
  3914. * available, to avpkt. The output packet does not necessarily contain data for
  3915. * the most recent frame, as encoders can delay, split, and combine input frames
  3916. * internally as needed.
  3917. *
  3918. * @param avctx codec context
  3919. * @param avpkt output AVPacket.
  3920. * The user can supply an output buffer by setting
  3921. * avpkt->data and avpkt->size prior to calling the
  3922. * function, but if the size of the user-provided data is not
  3923. * large enough, encoding will fail. If avpkt->data and
  3924. * avpkt->size are set, avpkt->destruct must also be set. All
  3925. * other AVPacket fields will be reset by the encoder using
  3926. * av_init_packet(). If avpkt->data is NULL, the encoder will
  3927. * allocate it. The encoder will set avpkt->size to the size
  3928. * of the output packet.
  3929. *
  3930. * If this function fails or produces no output, avpkt will be
  3931. * freed using av_free_packet() (i.e. avpkt->destruct will be
  3932. * called to free the user supplied buffer).
  3933. * @param[in] frame AVFrame containing the raw audio data to be encoded.
  3934. * May be NULL when flushing an encoder that has the
  3935. * CODEC_CAP_DELAY capability set.
  3936. * If CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame
  3937. * can have any number of samples.
  3938. * If it is not set, frame->nb_samples must be equal to
  3939. * avctx->frame_size for all frames except the last.
  3940. * The final frame may be smaller than avctx->frame_size.
  3941. * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the
  3942. * output packet is non-empty, and to 0 if it is
  3943. * empty. If the function returns an error, the
  3944. * packet can be assumed to be invalid, and the
  3945. * value of got_packet_ptr is undefined and should
  3946. * not be used.
  3947. * @return 0 on success, negative error code on failure
  3948. */
  3949. int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt,
  3950. const AVFrame *frame, int *got_packet_ptr);
  3951. #if FF_API_OLD_ENCODE_VIDEO
  3952. /**
  3953. * @deprecated use avcodec_encode_video2() instead.
  3954. *
  3955. * Encode a video frame from pict into buf.
  3956. * The input picture should be
  3957. * stored using a specific format, namely avctx.pix_fmt.
  3958. *
  3959. * @param avctx the codec context
  3960. * @param[out] buf the output buffer for the bitstream of encoded frame
  3961. * @param[in] buf_size the size of the output buffer in bytes
  3962. * @param[in] pict the input picture to encode
  3963. * @return On error a negative value is returned, on success zero or the number
  3964. * of bytes used from the output buffer.
  3965. */
  3966. attribute_deprecated
  3967. int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
  3968. const AVFrame *pict);
  3969. #endif
  3970. /**
  3971. * Encode a frame of video.
  3972. *
  3973. * Takes input raw video data from frame and writes the next output packet, if
  3974. * available, to avpkt. The output packet does not necessarily contain data for
  3975. * the most recent frame, as encoders can delay and reorder input frames
  3976. * internally as needed.
  3977. *
  3978. * @param avctx codec context
  3979. * @param avpkt output AVPacket.
  3980. * The user can supply an output buffer by setting
  3981. * avpkt->data and avpkt->size prior to calling the
  3982. * function, but if the size of the user-provided data is not
  3983. * large enough, encoding will fail. All other AVPacket fields
  3984. * will be reset by the encoder using av_init_packet(). If
  3985. * avpkt->data is NULL, the encoder will allocate it.
  3986. * The encoder will set avpkt->size to the size of the
  3987. * output packet. The returned data (if any) belongs to the
  3988. * caller, he is responsible for freeing it.
  3989. *
  3990. * If this function fails or produces no output, avpkt will be
  3991. * freed using av_free_packet() (i.e. avpkt->destruct will be
  3992. * called to free the user supplied buffer).
  3993. * @param[in] frame AVFrame containing the raw video data to be encoded.
  3994. * May be NULL when flushing an encoder that has the
  3995. * CODEC_CAP_DELAY capability set.
  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_video2(AVCodecContext *avctx, AVPacket *avpkt,
  4005. const AVFrame *frame, int *got_packet_ptr);
  4006. int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
  4007. const AVSubtitle *sub);
  4008. /**
  4009. * @}
  4010. */
  4011. #if FF_API_AVCODEC_RESAMPLE
  4012. /**
  4013. * @defgroup lavc_resample Audio resampling
  4014. * @ingroup libavc
  4015. * @deprecated use libswresample instead
  4016. *
  4017. * @{
  4018. */
  4019. struct ReSampleContext;
  4020. struct AVResampleContext;
  4021. typedef struct ReSampleContext ReSampleContext;
  4022. /**
  4023. * Initialize audio resampling context.
  4024. *
  4025. * @param output_channels number of output channels
  4026. * @param input_channels number of input channels
  4027. * @param output_rate output sample rate
  4028. * @param input_rate input sample rate
  4029. * @param sample_fmt_out requested output sample format
  4030. * @param sample_fmt_in input sample format
  4031. * @param filter_length length of each FIR filter in the filterbank relative to the cutoff frequency
  4032. * @param log2_phase_count log2 of the number of entries in the polyphase filterbank
  4033. * @param linear if 1 then the used FIR filter will be linearly interpolated
  4034. between the 2 closest, if 0 the closest will be used
  4035. * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate
  4036. * @return allocated ReSampleContext, NULL if error occurred
  4037. */
  4038. attribute_deprecated
  4039. ReSampleContext *av_audio_resample_init(int output_channels, int input_channels,
  4040. int output_rate, int input_rate,
  4041. enum AVSampleFormat sample_fmt_out,
  4042. enum AVSampleFormat sample_fmt_in,
  4043. int filter_length, int log2_phase_count,
  4044. int linear, double cutoff);
  4045. attribute_deprecated
  4046. int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
  4047. /**
  4048. * Free resample context.
  4049. *
  4050. * @param s a non-NULL pointer to a resample context previously
  4051. * created with av_audio_resample_init()
  4052. */
  4053. attribute_deprecated
  4054. void audio_resample_close(ReSampleContext *s);
  4055. /**
  4056. * Initialize an audio resampler.
  4057. * Note, if either rate is not an integer then simply scale both rates up so they are.
  4058. * @param filter_length length of each FIR filter in the filterbank relative to the cutoff freq
  4059. * @param log2_phase_count log2 of the number of entries in the polyphase filterbank
  4060. * @param linear If 1 then the used FIR filter will be linearly interpolated
  4061. between the 2 closest, if 0 the closest will be used
  4062. * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate
  4063. */
  4064. attribute_deprecated
  4065. struct AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_length, int log2_phase_count, int linear, double cutoff);
  4066. /**
  4067. * Resample an array of samples using a previously configured context.
  4068. * @param src an array of unconsumed samples
  4069. * @param consumed the number of samples of src which have been consumed are returned here
  4070. * @param src_size the number of unconsumed samples available
  4071. * @param dst_size the amount of space in samples available in dst
  4072. * @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.
  4073. * @return the number of samples written in dst or -1 if an error occurred
  4074. */
  4075. attribute_deprecated
  4076. int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx);
  4077. /**
  4078. * Compensate samplerate/timestamp drift. The compensation is done by changing
  4079. * the resampler parameters, so no audible clicks or similar distortions occur
  4080. * @param compensation_distance distance in output samples over which the compensation should be performed
  4081. * @param sample_delta number of output samples which should be output less
  4082. *
  4083. * example: av_resample_compensate(c, 10, 500)
  4084. * here instead of 510 samples only 500 samples would be output
  4085. *
  4086. * note, due to rounding the actual compensation might be slightly different,
  4087. * especially if the compensation_distance is large and the in_rate used during init is small
  4088. */
  4089. attribute_deprecated
  4090. void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance);
  4091. attribute_deprecated
  4092. void av_resample_close(struct AVResampleContext *c);
  4093. /**
  4094. * @}
  4095. */
  4096. #endif
  4097. /**
  4098. * @addtogroup lavc_picture
  4099. * @{
  4100. */
  4101. /**
  4102. * Allocate memory for the pixels of a picture and setup the AVPicture
  4103. * fields for it.
  4104. *
  4105. * Call avpicture_free() to free it.
  4106. *
  4107. * @param picture the picture structure to be filled in
  4108. * @param pix_fmt the pixel format of the picture
  4109. * @param width the width of the picture
  4110. * @param height the height of the picture
  4111. * @return zero if successful, a negative error code otherwise
  4112. *
  4113. * @see av_image_alloc(), avpicture_fill()
  4114. */
  4115. int avpicture_alloc(AVPicture *picture, enum AVPixelFormat pix_fmt, int width, int height);
  4116. /**
  4117. * Free a picture previously allocated by avpicture_alloc().
  4118. * The data buffer used by the AVPicture is freed, but the AVPicture structure
  4119. * itself is not.
  4120. *
  4121. * @param picture the AVPicture to be freed
  4122. */
  4123. void avpicture_free(AVPicture *picture);
  4124. /**
  4125. * Setup the picture fields based on the specified image parameters
  4126. * and the provided image data buffer.
  4127. *
  4128. * The picture fields are filled in by using the image data buffer
  4129. * pointed to by ptr.
  4130. *
  4131. * If ptr is NULL, the function will fill only the picture linesize
  4132. * array and return the required size for the image buffer.
  4133. *
  4134. * To allocate an image buffer and fill the picture data in one call,
  4135. * use avpicture_alloc().
  4136. *
  4137. * @param picture the picture to be filled in
  4138. * @param ptr buffer where the image data is stored, or NULL
  4139. * @param pix_fmt the pixel format of the image
  4140. * @param width the width of the image in pixels
  4141. * @param height the height of the image in pixels
  4142. * @return the size in bytes required for src, a negative error code
  4143. * in case of failure
  4144. *
  4145. * @see av_image_fill_arrays()
  4146. */
  4147. int avpicture_fill(AVPicture *picture, const uint8_t *ptr,
  4148. enum AVPixelFormat pix_fmt, int width, int height);
  4149. /**
  4150. * Copy pixel data from an AVPicture into a buffer.
  4151. *
  4152. * avpicture_get_size() can be used to compute the required size for
  4153. * the buffer to fill.
  4154. *
  4155. * @param src source picture with filled data
  4156. * @param pix_fmt picture pixel format
  4157. * @param width picture width
  4158. * @param height picture height
  4159. * @param dest destination buffer
  4160. * @param dest_size destination buffer size in bytes
  4161. * @return the number of bytes written to dest, or a negative value
  4162. * (error code) on error, for example if the destination buffer is not
  4163. * big enough
  4164. *
  4165. * @see av_image_copy_to_buffer()
  4166. */
  4167. int avpicture_layout(const AVPicture *src, enum AVPixelFormat pix_fmt,
  4168. int width, int height,
  4169. unsigned char *dest, int dest_size);
  4170. /**
  4171. * Calculate the size in bytes that a picture of the given width and height
  4172. * would occupy if stored in the given picture format.
  4173. *
  4174. * @param pix_fmt picture pixel format
  4175. * @param width picture width
  4176. * @param height picture height
  4177. * @return the computed picture buffer size or a negative error code
  4178. * in case of error
  4179. *
  4180. * @see av_image_get_buffer_size().
  4181. */
  4182. int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height);
  4183. #if FF_API_DEINTERLACE
  4184. /**
  4185. * deinterlace - if not supported return -1
  4186. *
  4187. * @deprecated - use yadif (in libavfilter) instead
  4188. */
  4189. attribute_deprecated
  4190. int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
  4191. enum AVPixelFormat pix_fmt, int width, int height);
  4192. #endif
  4193. /**
  4194. * Copy image src to dst. Wraps av_image_copy().
  4195. */
  4196. void av_picture_copy(AVPicture *dst, const AVPicture *src,
  4197. enum AVPixelFormat pix_fmt, int width, int height);
  4198. /**
  4199. * Crop image top and left side.
  4200. */
  4201. int av_picture_crop(AVPicture *dst, const AVPicture *src,
  4202. enum AVPixelFormat pix_fmt, int top_band, int left_band);
  4203. /**
  4204. * Pad image.
  4205. */
  4206. int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, enum AVPixelFormat pix_fmt,
  4207. int padtop, int padbottom, int padleft, int padright, int *color);
  4208. /**
  4209. * @}
  4210. */
  4211. /**
  4212. * @defgroup lavc_misc Utility functions
  4213. * @ingroup libavc
  4214. *
  4215. * Miscellaneous utility functions related to both encoding and decoding
  4216. * (or neither).
  4217. * @{
  4218. */
  4219. /**
  4220. * @defgroup lavc_misc_pixfmt Pixel formats
  4221. *
  4222. * Functions for working with pixel formats.
  4223. * @{
  4224. */
  4225. /**
  4226. * Utility function to access log2_chroma_w log2_chroma_h from
  4227. * the pixel format AVPixFmtDescriptor.
  4228. *
  4229. * This function asserts that pix_fmt is valid. See av_pix_fmt_get_chroma_sub_sample
  4230. * for one that returns a failure code and continues in case of invalid
  4231. * pix_fmts.
  4232. *
  4233. * @param[in] pix_fmt the pixel format
  4234. * @param[out] h_shift store log2_chroma_w
  4235. * @param[out] v_shift store log2_chroma_h
  4236. *
  4237. * @see av_pix_fmt_get_chroma_sub_sample
  4238. */
  4239. void avcodec_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift);
  4240. /**
  4241. * Return a value representing the fourCC code associated to the
  4242. * pixel format pix_fmt, or 0 if no associated fourCC code can be
  4243. * found.
  4244. */
  4245. unsigned int avcodec_pix_fmt_to_codec_tag(enum AVPixelFormat pix_fmt);
  4246. #define FF_LOSS_RESOLUTION 0x0001 /**< loss due to resolution change */
  4247. #define FF_LOSS_DEPTH 0x0002 /**< loss due to color depth change */
  4248. #define FF_LOSS_COLORSPACE 0x0004 /**< loss due to color space conversion */
  4249. #define FF_LOSS_ALPHA 0x0008 /**< loss of alpha bits */
  4250. #define FF_LOSS_COLORQUANT 0x0010 /**< loss due to color quantization */
  4251. #define FF_LOSS_CHROMA 0x0020 /**< loss of chroma (e.g. RGB to gray conversion) */
  4252. /**
  4253. * Compute what kind of losses will occur when converting from one specific
  4254. * pixel format to another.
  4255. * When converting from one pixel format to another, information loss may occur.
  4256. * For example, when converting from RGB24 to GRAY, the color information will
  4257. * be lost. Similarly, other losses occur when converting from some formats to
  4258. * other formats. These losses can involve loss of chroma, but also loss of
  4259. * resolution, loss of color depth, loss due to the color space conversion, loss
  4260. * of the alpha bits or loss due to color quantization.
  4261. * avcodec_get_fix_fmt_loss() informs you about the various types of losses
  4262. * which will occur when converting from one pixel format to another.
  4263. *
  4264. * @param[in] dst_pix_fmt destination pixel format
  4265. * @param[in] src_pix_fmt source pixel format
  4266. * @param[in] has_alpha Whether the source pixel format alpha channel is used.
  4267. * @return Combination of flags informing you what kind of losses will occur
  4268. * (maximum loss for an invalid dst_pix_fmt).
  4269. */
  4270. int avcodec_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt, enum AVPixelFormat src_pix_fmt,
  4271. int has_alpha);
  4272. /**
  4273. * Find the best pixel format to convert to given a certain source pixel
  4274. * format. When converting from one pixel format to another, information loss
  4275. * may occur. For example, when converting from RGB24 to GRAY, the color
  4276. * information will be lost. Similarly, other losses occur when converting from
  4277. * some formats to other formats. avcodec_find_best_pix_fmt_of_2() searches which of
  4278. * the given pixel formats should be used to suffer the least amount of loss.
  4279. * The pixel formats from which it chooses one, are determined by the
  4280. * pix_fmt_list parameter.
  4281. *
  4282. *
  4283. * @param[in] pix_fmt_list AV_PIX_FMT_NONE terminated array of pixel formats to choose from
  4284. * @param[in] src_pix_fmt source pixel format
  4285. * @param[in] has_alpha Whether the source pixel format alpha channel is used.
  4286. * @param[out] loss_ptr Combination of flags informing you what kind of losses will occur.
  4287. * @return The best pixel format to convert to or -1 if none was found.
  4288. */
  4289. enum AVPixelFormat avcodec_find_best_pix_fmt_of_list(const enum AVPixelFormat *pix_fmt_list,
  4290. enum AVPixelFormat src_pix_fmt,
  4291. int has_alpha, int *loss_ptr);
  4292. /**
  4293. * Find the best pixel format to convert to given a certain source pixel
  4294. * format and a selection of two destination pixel formats. When converting from
  4295. * one pixel format to another, information loss may occur. For example, when converting
  4296. * from RGB24 to GRAY, the color information will be lost. Similarly, other losses occur when
  4297. * converting from some formats to other formats. avcodec_find_best_pix_fmt_of_2() selects which of
  4298. * the given pixel formats should be used to suffer the least amount of loss.
  4299. *
  4300. * If one of the destination formats is AV_PIX_FMT_NONE the other pixel format (if valid) will be
  4301. * returned.
  4302. *
  4303. * @code
  4304. * src_pix_fmt = AV_PIX_FMT_YUV420P;
  4305. * dst_pix_fmt1= AV_PIX_FMT_RGB24;
  4306. * dst_pix_fmt2= AV_PIX_FMT_GRAY8;
  4307. * dst_pix_fmt3= AV_PIX_FMT_RGB8;
  4308. * loss= FF_LOSS_CHROMA; // don't care about chroma loss, so chroma loss will be ignored.
  4309. * dst_pix_fmt = avcodec_find_best_pix_fmt_of_2(dst_pix_fmt1, dst_pix_fmt2, src_pix_fmt, alpha, &loss);
  4310. * dst_pix_fmt = avcodec_find_best_pix_fmt_of_2(dst_pix_fmt, dst_pix_fmt3, src_pix_fmt, alpha, &loss);
  4311. * @endcode
  4312. *
  4313. * @param[in] dst_pix_fmt1 One of the two destination pixel formats to choose from
  4314. * @param[in] dst_pix_fmt2 The other of the two destination pixel formats to choose from
  4315. * @param[in] src_pix_fmt Source pixel format
  4316. * @param[in] has_alpha Whether the source pixel format alpha channel is used.
  4317. * @param[in, out] loss_ptr Combination of loss flags. In: selects which of the losses to ignore, i.e.
  4318. * NULL or value of zero means we care about all losses. Out: the loss
  4319. * that occurs when converting from src to selected dst pixel format.
  4320. * @return The best pixel format to convert to or -1 if none was found.
  4321. */
  4322. enum AVPixelFormat avcodec_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2,
  4323. enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr);
  4324. attribute_deprecated
  4325. #if AV_HAVE_INCOMPATIBLE_LIBAV_ABI
  4326. enum AVPixelFormat avcodec_find_best_pix_fmt2(const enum AVPixelFormat *pix_fmt_list,
  4327. enum AVPixelFormat src_pix_fmt,
  4328. int has_alpha, int *loss_ptr);
  4329. #else
  4330. enum AVPixelFormat avcodec_find_best_pix_fmt2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2,
  4331. enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr);
  4332. #endif
  4333. enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum AVPixelFormat * fmt);
  4334. /**
  4335. * @}
  4336. */
  4337. #if FF_API_SET_DIMENSIONS
  4338. /**
  4339. * @deprecated this function is not supposed to be used from outside of lavc
  4340. */
  4341. attribute_deprecated
  4342. void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
  4343. #endif
  4344. /**
  4345. * Put a string representing the codec tag codec_tag in buf.
  4346. *
  4347. * @param buf buffer to place codec tag in
  4348. * @param buf_size size in bytes of buf
  4349. * @param codec_tag codec tag to assign
  4350. * @return the length of the string that would have been generated if
  4351. * enough space had been available, excluding the trailing null
  4352. */
  4353. size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag);
  4354. void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
  4355. /**
  4356. * Return a name for the specified profile, if available.
  4357. *
  4358. * @param codec the codec that is searched for the given profile
  4359. * @param profile the profile value for which a name is requested
  4360. * @return A name for the profile if found, NULL otherwise.
  4361. */
  4362. const char *av_get_profile_name(const AVCodec *codec, int profile);
  4363. int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size);
  4364. int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count);
  4365. //FIXME func typedef
  4366. /**
  4367. * Fill AVFrame audio data and linesize pointers.
  4368. *
  4369. * The buffer buf must be a preallocated buffer with a size big enough
  4370. * to contain the specified samples amount. The filled AVFrame data
  4371. * pointers will point to this buffer.
  4372. *
  4373. * AVFrame extended_data channel pointers are allocated if necessary for
  4374. * planar audio.
  4375. *
  4376. * @param frame the AVFrame
  4377. * frame->nb_samples must be set prior to calling the
  4378. * function. This function fills in frame->data,
  4379. * frame->extended_data, frame->linesize[0].
  4380. * @param nb_channels channel count
  4381. * @param sample_fmt sample format
  4382. * @param buf buffer to use for frame data
  4383. * @param buf_size size of buffer
  4384. * @param align plane size sample alignment (0 = default)
  4385. * @return >=0 on success, negative error code on failure
  4386. * @todo return the size in bytes required to store the samples in
  4387. * case of success, at the next libavutil bump
  4388. */
  4389. int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels,
  4390. enum AVSampleFormat sample_fmt, const uint8_t *buf,
  4391. int buf_size, int align);
  4392. /**
  4393. * Reset the internal decoder state / flush internal buffers. Should be called
  4394. * e.g. when seeking or when switching to a different stream.
  4395. *
  4396. * @note when refcounted frames are not used (i.e. avctx->refcounted_frames is 0),
  4397. * this invalidates the frames previously returned from the decoder. When
  4398. * refcounted frames are used, the decoder just releases any references it might
  4399. * keep internally, but the caller's reference remains valid.
  4400. */
  4401. void avcodec_flush_buffers(AVCodecContext *avctx);
  4402. /**
  4403. * Return codec bits per sample.
  4404. *
  4405. * @param[in] codec_id the codec
  4406. * @return Number of bits per sample or zero if unknown for the given codec.
  4407. */
  4408. int av_get_bits_per_sample(enum AVCodecID codec_id);
  4409. /**
  4410. * Return the PCM codec associated with a sample format.
  4411. * @param be endianness, 0 for little, 1 for big,
  4412. * -1 (or anything else) for native
  4413. * @return AV_CODEC_ID_PCM_* or AV_CODEC_ID_NONE
  4414. */
  4415. enum AVCodecID av_get_pcm_codec(enum AVSampleFormat fmt, int be);
  4416. /**
  4417. * Return codec bits per sample.
  4418. * Only return non-zero if the bits per sample is exactly correct, not an
  4419. * approximation.
  4420. *
  4421. * @param[in] codec_id the codec
  4422. * @return Number of bits per sample or zero if unknown for the given codec.
  4423. */
  4424. int av_get_exact_bits_per_sample(enum AVCodecID codec_id);
  4425. /**
  4426. * Return audio frame duration.
  4427. *
  4428. * @param avctx codec context
  4429. * @param frame_bytes size of the frame, or 0 if unknown
  4430. * @return frame duration, in samples, if known. 0 if not able to
  4431. * determine.
  4432. */
  4433. int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes);
  4434. typedef struct AVBitStreamFilterContext {
  4435. void *priv_data;
  4436. struct AVBitStreamFilter *filter;
  4437. AVCodecParserContext *parser;
  4438. struct AVBitStreamFilterContext *next;
  4439. } AVBitStreamFilterContext;
  4440. typedef struct AVBitStreamFilter {
  4441. const char *name;
  4442. int priv_data_size;
  4443. int (*filter)(AVBitStreamFilterContext *bsfc,
  4444. AVCodecContext *avctx, const char *args,
  4445. uint8_t **poutbuf, int *poutbuf_size,
  4446. const uint8_t *buf, int buf_size, int keyframe);
  4447. void (*close)(AVBitStreamFilterContext *bsfc);
  4448. struct AVBitStreamFilter *next;
  4449. } AVBitStreamFilter;
  4450. /**
  4451. * Register a bitstream filter.
  4452. *
  4453. * The filter will be accessible to the application code through
  4454. * av_bitstream_filter_next() or can be directly initialized with
  4455. * av_bitstream_filter_init().
  4456. *
  4457. * @see avcodec_register_all()
  4458. */
  4459. void av_register_bitstream_filter(AVBitStreamFilter *bsf);
  4460. /**
  4461. * Create and initialize a bitstream filter context given a bitstream
  4462. * filter name.
  4463. *
  4464. * The returned context must be freed with av_bitstream_filter_close().
  4465. *
  4466. * @param name the name of the bitstream filter
  4467. * @return a bitstream filter context if a matching filter was found
  4468. * and successfully initialized, NULL otherwise
  4469. */
  4470. AVBitStreamFilterContext *av_bitstream_filter_init(const char *name);
  4471. /**
  4472. * Filter bitstream.
  4473. *
  4474. * This function filters the buffer buf with size buf_size, and places the
  4475. * filtered buffer in the buffer pointed to by poutbuf.
  4476. *
  4477. * The output buffer must be freed by the caller.
  4478. *
  4479. * @param bsfc bitstream filter context created by av_bitstream_filter_init()
  4480. * @param avctx AVCodecContext accessed by the filter, may be NULL.
  4481. * If specified, this must point to the encoder context of the
  4482. * output stream the packet is sent to.
  4483. * @param args arguments which specify the filter configuration, may be NULL
  4484. * @param poutbuf pointer which is updated to point to the filtered buffer
  4485. * @param poutbuf_size pointer which is updated to the filtered buffer size in bytes
  4486. * @param buf buffer containing the data to filter
  4487. * @param buf_size size in bytes of buf
  4488. * @param keyframe set to non-zero if the buffer to filter corresponds to a key-frame packet data
  4489. * @return >= 0 in case of success, or a negative error code in case of failure
  4490. *
  4491. * If the return value is positive, an output buffer is allocated and
  4492. * is availble in *poutbuf, and is distinct from the input buffer.
  4493. *
  4494. * If the return value is 0, the output buffer is not allocated and
  4495. * should be considered identical to the input buffer, or in case
  4496. * *poutbuf was set it points to the input buffer (not necessarily to
  4497. * its starting address).
  4498. */
  4499. int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc,
  4500. AVCodecContext *avctx, const char *args,
  4501. uint8_t **poutbuf, int *poutbuf_size,
  4502. const uint8_t *buf, int buf_size, int keyframe);
  4503. /**
  4504. * Release bitstream filter context.
  4505. *
  4506. * @param bsf the bitstream filter context created with
  4507. * av_bitstream_filter_init(), can be NULL
  4508. */
  4509. void av_bitstream_filter_close(AVBitStreamFilterContext *bsf);
  4510. /**
  4511. * If f is NULL, return the first registered bitstream filter,
  4512. * if f is non-NULL, return the next registered bitstream filter
  4513. * after f, or NULL if f is the last one.
  4514. *
  4515. * This function can be used to iterate over all registered bitstream
  4516. * filters.
  4517. */
  4518. AVBitStreamFilter *av_bitstream_filter_next(AVBitStreamFilter *f);
  4519. /* memory */
  4520. /**
  4521. * Same behaviour av_fast_malloc but the buffer has additional
  4522. * FF_INPUT_BUFFER_PADDING_SIZE at the end which will always be 0.
  4523. *
  4524. * In addition the whole buffer will initially and after resizes
  4525. * be 0-initialized so that no uninitialized data will ever appear.
  4526. */
  4527. void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size);
  4528. /**
  4529. * Same behaviour av_fast_padded_malloc except that buffer will always
  4530. * be 0-initialized after call.
  4531. */
  4532. void av_fast_padded_mallocz(void *ptr, unsigned int *size, size_t min_size);
  4533. /**
  4534. * Encode extradata length to a buffer. Used by xiph codecs.
  4535. *
  4536. * @param s buffer to write to; must be at least (v/255+1) bytes long
  4537. * @param v size of extradata in bytes
  4538. * @return number of bytes written to the buffer.
  4539. */
  4540. unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
  4541. #if FF_API_MISSING_SAMPLE
  4542. /**
  4543. * Log a generic warning message about a missing feature. This function is
  4544. * intended to be used internally by FFmpeg (libavcodec, libavformat, etc.)
  4545. * only, and would normally not be used by applications.
  4546. * @param[in] avc a pointer to an arbitrary struct of which the first field is
  4547. * a pointer to an AVClass struct
  4548. * @param[in] feature string containing the name of the missing feature
  4549. * @param[in] want_sample indicates if samples are wanted which exhibit this feature.
  4550. * If want_sample is non-zero, additional verbage will be added to the log
  4551. * message which tells the user how to report samples to the development
  4552. * mailing list.
  4553. * @deprecated Use avpriv_report_missing_feature() instead.
  4554. */
  4555. attribute_deprecated
  4556. void av_log_missing_feature(void *avc, const char *feature, int want_sample);
  4557. /**
  4558. * Log a generic warning message asking for a sample. This function is
  4559. * intended to be used internally by FFmpeg (libavcodec, libavformat, etc.)
  4560. * only, and would normally not be used by applications.
  4561. * @param[in] avc a pointer to an arbitrary struct of which the first field is
  4562. * a pointer to an AVClass struct
  4563. * @param[in] msg string containing an optional message, or NULL if no message
  4564. * @deprecated Use avpriv_request_sample() instead.
  4565. */
  4566. attribute_deprecated
  4567. void av_log_ask_for_sample(void *avc, const char *msg, ...) av_printf_format(2, 3);
  4568. #endif /* FF_API_MISSING_SAMPLE */
  4569. /**
  4570. * Register the hardware accelerator hwaccel.
  4571. */
  4572. void av_register_hwaccel(AVHWAccel *hwaccel);
  4573. /**
  4574. * If hwaccel is NULL, returns the first registered hardware accelerator,
  4575. * if hwaccel is non-NULL, returns the next registered hardware accelerator
  4576. * after hwaccel, or NULL if hwaccel is the last one.
  4577. */
  4578. AVHWAccel *av_hwaccel_next(AVHWAccel *hwaccel);
  4579. /**
  4580. * Lock operation used by lockmgr
  4581. */
  4582. enum AVLockOp {
  4583. AV_LOCK_CREATE, ///< Create a mutex
  4584. AV_LOCK_OBTAIN, ///< Lock the mutex
  4585. AV_LOCK_RELEASE, ///< Unlock the mutex
  4586. AV_LOCK_DESTROY, ///< Free mutex resources
  4587. };
  4588. /**
  4589. * Register a user provided lock manager supporting the operations
  4590. * specified by AVLockOp. mutex points to a (void *) where the
  4591. * lockmgr should store/get a pointer to a user allocated mutex. It's
  4592. * NULL upon AV_LOCK_CREATE and != NULL for all other ops.
  4593. *
  4594. * @param cb User defined callback. Note: FFmpeg may invoke calls to this
  4595. * callback during the call to av_lockmgr_register().
  4596. * Thus, the application must be prepared to handle that.
  4597. * If cb is set to NULL the lockmgr will be unregistered.
  4598. * Also note that during unregistration the previously registered
  4599. * lockmgr callback may also be invoked.
  4600. */
  4601. int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op));
  4602. /**
  4603. * Get the type of the given codec.
  4604. */
  4605. enum AVMediaType avcodec_get_type(enum AVCodecID codec_id);
  4606. /**
  4607. * Get the name of a codec.
  4608. * @return a static string identifying the codec; never NULL
  4609. */
  4610. const char *avcodec_get_name(enum AVCodecID id);
  4611. /**
  4612. * @return a positive value if s is open (i.e. avcodec_open2() was called on it
  4613. * with no corresponding avcodec_close()), 0 otherwise.
  4614. */
  4615. int avcodec_is_open(AVCodecContext *s);
  4616. /**
  4617. * @return a non-zero number if codec is an encoder, zero otherwise
  4618. */
  4619. int av_codec_is_encoder(const AVCodec *codec);
  4620. /**
  4621. * @return a non-zero number if codec is a decoder, zero otherwise
  4622. */
  4623. int av_codec_is_decoder(const AVCodec *codec);
  4624. /**
  4625. * @return descriptor for given codec ID or NULL if no descriptor exists.
  4626. */
  4627. const AVCodecDescriptor *avcodec_descriptor_get(enum AVCodecID id);
  4628. /**
  4629. * Iterate over all codec descriptors known to libavcodec.
  4630. *
  4631. * @param prev previous descriptor. NULL to get the first descriptor.
  4632. *
  4633. * @return next descriptor or NULL after the last descriptor
  4634. */
  4635. const AVCodecDescriptor *avcodec_descriptor_next(const AVCodecDescriptor *prev);
  4636. /**
  4637. * @return codec descriptor with the given name or NULL if no such descriptor
  4638. * exists.
  4639. */
  4640. const AVCodecDescriptor *avcodec_descriptor_get_by_name(const char *name);
  4641. /**
  4642. * @}
  4643. */
  4644. #endif /* AVCODEC_AVCODEC_H */