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.

4404 lines
142KB

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