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.

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