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.

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