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.

4433 lines
141KB

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