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.

5002 lines
169KB

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