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.

4734 lines
160KB

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