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.

4801 lines
158KB

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