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.

4478 lines
144KB

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