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.

4633 lines
149KB

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