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.

5053 lines
171KB

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