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.

4611 lines
154KB

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