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.

4298 lines
138KB

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