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.

5002 lines
164KB

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