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.

5016 lines
171KB

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