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.

5139 lines
170KB

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