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.

5247 lines
176KB

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