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.

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