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.

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