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.

5307 lines
177KB

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