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.

4188 lines
136KB

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