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.

4483 lines
144KB

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