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.

5021 lines
170KB

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