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.

4488 lines
145KB

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