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.

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