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.

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