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.

4494 lines
145KB

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