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.

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