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.

4434 lines
142KB

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