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.

4475 lines
143KB

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