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.

4333 lines
142KB

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