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.

4697 lines
157KB

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