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.

4869 lines
160KB

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