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.

5039 lines
171KB

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