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.

4551 lines
144KB

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