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.

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