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.

4575 lines
148KB

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