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.

4382 lines
141KB

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