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.

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