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.

4103 lines
132KB

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