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.

4896 lines
161KB

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