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.

5295 lines
169KB

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