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.

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