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.

4584 lines
148KB

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