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.

4384 lines
140KB

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