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.

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