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.

4762 lines
155KB

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