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.

4402 lines
141KB

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