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.

5361 lines
179KB

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