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.

5114 lines
173KB

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