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.

4862 lines
159KB

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