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.

5063 lines
167KB

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