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.

4563 lines
147KB

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