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.

4978 lines
163KB

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