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.

4691 lines
152KB

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