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.

4810 lines
161KB

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