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.

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