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.

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