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.

3689 lines
118KB

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