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.

5382 lines
180KB

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