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.

4873 lines
160KB

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