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.

6151 lines
203KB

  1. /*
  2. * copyright (c) 2001 Fabrice Bellard
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #ifndef AVCODEC_AVCODEC_H
  21. #define AVCODEC_AVCODEC_H
  22. /**
  23. * @file
  24. * @ingroup libavc
  25. * Libavcodec external API header
  26. */
  27. #include <errno.h>
  28. #include "libavutil/samplefmt.h"
  29. #include "libavutil/attributes.h"
  30. #include "libavutil/avutil.h"
  31. #include "libavutil/buffer.h"
  32. #include "libavutil/cpu.h"
  33. #include "libavutil/channel_layout.h"
  34. #include "libavutil/dict.h"
  35. #include "libavutil/frame.h"
  36. #include "libavutil/log.h"
  37. #include "libavutil/pixfmt.h"
  38. #include "libavutil/rational.h"
  39. #include "version.h"
  40. /**
  41. * @defgroup libavc libavcodec
  42. * Encoding/Decoding Library
  43. *
  44. * @{
  45. *
  46. * @defgroup lavc_decoding Decoding
  47. * @{
  48. * @}
  49. *
  50. * @defgroup lavc_encoding Encoding
  51. * @{
  52. * @}
  53. *
  54. * @defgroup lavc_codec Codecs
  55. * @{
  56. * @defgroup lavc_codec_native Native Codecs
  57. * @{
  58. * @}
  59. * @defgroup lavc_codec_wrappers External library wrappers
  60. * @{
  61. * @}
  62. * @defgroup lavc_codec_hwaccel Hardware Accelerators bridge
  63. * @{
  64. * @}
  65. * @}
  66. * @defgroup lavc_internal Internal
  67. * @{
  68. * @}
  69. * @}
  70. */
  71. /**
  72. * @ingroup libavc
  73. * @defgroup lavc_encdec send/receive encoding and decoding API overview
  74. * @{
  75. *
  76. * The avcodec_send_packet()/avcodec_receive_frame()/avcodec_send_frame()/
  77. * avcodec_receive_packet() functions provide an encode/decode API, which
  78. * decouples input and output.
  79. *
  80. * The API is very similar for encoding/decoding and audio/video, and works as
  81. * follows:
  82. * - Set up and open the AVCodecContext as usual.
  83. * - Send valid input:
  84. * - For decoding, call avcodec_send_packet() to give the decoder raw
  85. * compressed data in an AVPacket.
  86. * - For encoding, call avcodec_send_frame() to give the encoder an AVFrame
  87. * containing uncompressed audio or video.
  88. * In both cases, it is recommended that AVPackets and AVFrames are
  89. * refcounted, or libavcodec might have to copy the input data. (libavformat
  90. * always returns refcounted AVPackets, and av_frame_get_buffer() allocates
  91. * refcounted AVFrames.)
  92. * - Receive output in a loop. Periodically call one of the avcodec_receive_*()
  93. * functions and process their output:
  94. * - For decoding, call avcodec_receive_frame(). On success, it will return
  95. * an AVFrame containing uncompressed audio or video data.
  96. * - For encoding, call avcodec_receive_packet(). On success, it will return
  97. * an AVPacket with a compressed frame.
  98. * Repeat this call until it returns AVERROR(EAGAIN) or an error. The
  99. * AVERROR(EAGAIN) return value means that new input data is required to
  100. * return new output. In this case, continue with sending input. For each
  101. * input frame/packet, the codec will typically return 1 output frame/packet,
  102. * but it can also be 0 or more than 1.
  103. *
  104. * At the beginning of decoding or encoding, the codec might accept multiple
  105. * input frames/packets without returning a frame, until its internal buffers
  106. * are filled. This situation is handled transparently if you follow the steps
  107. * outlined above.
  108. *
  109. * In theory, sending input can result in EAGAIN - this should happen only if
  110. * not all output was received. You can use this to structure alternative decode
  111. * or encode loops other than the one suggested above. For example, you could
  112. * try sending new input on each iteration, and try to receive output if that
  113. * returns EAGAIN.
  114. *
  115. * End of stream situations. These require "flushing" (aka draining) the codec,
  116. * as the codec might buffer multiple frames or packets internally for
  117. * performance or out of necessity (consider B-frames).
  118. * This is handled as follows:
  119. * - Instead of valid input, send NULL to the avcodec_send_packet() (decoding)
  120. * or avcodec_send_frame() (encoding) functions. This will enter draining
  121. * mode.
  122. * - Call avcodec_receive_frame() (decoding) or avcodec_receive_packet()
  123. * (encoding) in a loop until AVERROR_EOF is returned. The functions will
  124. * not return AVERROR(EAGAIN), unless you forgot to enter draining mode.
  125. * - Before decoding can be resumed again, the codec has to be reset with
  126. * avcodec_flush_buffers().
  127. *
  128. * Using the API as outlined above is highly recommended. But it is also
  129. * possible to call functions outside of this rigid schema. For example, you can
  130. * call avcodec_send_packet() repeatedly without calling
  131. * avcodec_receive_frame(). In this case, avcodec_send_packet() will succeed
  132. * until the codec's internal buffer has been filled up (which is typically of
  133. * size 1 per output frame, after initial input), and then reject input with
  134. * AVERROR(EAGAIN). Once it starts rejecting input, you have no choice but to
  135. * read at least some output.
  136. *
  137. * Not all codecs will follow a rigid and predictable dataflow; the only
  138. * guarantee is that an AVERROR(EAGAIN) return value on a send/receive call on
  139. * one end implies that a receive/send call on the other end will succeed, or
  140. * at least will not fail with AVERROR(EAGAIN). In general, no codec will
  141. * permit unlimited buffering of input or output.
  142. *
  143. * This API replaces the following legacy functions:
  144. * - avcodec_decode_video2() and avcodec_decode_audio4():
  145. * Use avcodec_send_packet() to feed input to the decoder, then use
  146. * avcodec_receive_frame() to receive decoded frames after each packet.
  147. * Unlike with the old video decoding API, multiple frames might result from
  148. * a packet. For audio, splitting the input packet into frames by partially
  149. * decoding packets becomes transparent to the API user. You never need to
  150. * feed an AVPacket to the API twice (unless it is rejected with AVERROR(EAGAIN) - then
  151. * no data was read from the packet).
  152. * Additionally, sending a flush/draining packet is required only once.
  153. * - avcodec_encode_video2()/avcodec_encode_audio2():
  154. * Use avcodec_send_frame() to feed input to the encoder, then use
  155. * avcodec_receive_packet() to receive encoded packets.
  156. * Providing user-allocated buffers for avcodec_receive_packet() is not
  157. * possible.
  158. * - The new API does not handle subtitles yet.
  159. *
  160. * Mixing new and old function calls on the same AVCodecContext is not allowed,
  161. * and will result in undefined behavior.
  162. *
  163. * Some codecs might require using the new API; using the old API will return
  164. * an error when calling it. All codecs support the new API.
  165. *
  166. * A codec is not allowed to return AVERROR(EAGAIN) for both sending and receiving. This
  167. * would be an invalid state, which could put the codec user into an endless
  168. * loop. The API has no concept of time either: it cannot happen that trying to
  169. * do avcodec_send_packet() results in AVERROR(EAGAIN), but a repeated call 1 second
  170. * later accepts the packet (with no other receive/flush API calls involved).
  171. * The API is a strict state machine, and the passage of time is not supposed
  172. * to influence it. Some timing-dependent behavior might still be deemed
  173. * acceptable in certain cases. But it must never result in both send/receive
  174. * returning EAGAIN at the same time at any point. It must also absolutely be
  175. * avoided that the current state is "unstable" and can "flip-flop" between
  176. * the send/receive APIs allowing progress. For example, it's not allowed that
  177. * the codec randomly decides that it actually wants to consume a packet now
  178. * instead of returning a frame, after it just returned AVERROR(EAGAIN) on an
  179. * avcodec_send_packet() call.
  180. * @}
  181. */
  182. /**
  183. * @defgroup lavc_core Core functions/structures.
  184. * @ingroup libavc
  185. *
  186. * Basic definitions, functions for querying libavcodec capabilities,
  187. * allocating core structures, etc.
  188. * @{
  189. */
  190. /**
  191. * Identify the syntax and semantics of the bitstream.
  192. * The principle is roughly:
  193. * Two decoders with the same ID can decode the same streams.
  194. * Two encoders with the same ID can encode compatible streams.
  195. * There may be slight deviations from the principle due to implementation
  196. * details.
  197. *
  198. * If you add a codec ID to this list, add it so that
  199. * 1. no value of an existing codec ID changes (that would break ABI),
  200. * 2. it is as close as possible to similar codecs
  201. *
  202. * After adding new codec IDs, do not forget to add an entry to the codec
  203. * descriptor list and bump libavcodec minor version.
  204. */
  205. enum AVCodecID {
  206. AV_CODEC_ID_NONE,
  207. /* video codecs */
  208. AV_CODEC_ID_MPEG1VIDEO,
  209. AV_CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding
  210. AV_CODEC_ID_H261,
  211. AV_CODEC_ID_H263,
  212. AV_CODEC_ID_RV10,
  213. AV_CODEC_ID_RV20,
  214. AV_CODEC_ID_MJPEG,
  215. AV_CODEC_ID_MJPEGB,
  216. AV_CODEC_ID_LJPEG,
  217. AV_CODEC_ID_SP5X,
  218. AV_CODEC_ID_JPEGLS,
  219. AV_CODEC_ID_MPEG4,
  220. AV_CODEC_ID_RAWVIDEO,
  221. AV_CODEC_ID_MSMPEG4V1,
  222. AV_CODEC_ID_MSMPEG4V2,
  223. AV_CODEC_ID_MSMPEG4V3,
  224. AV_CODEC_ID_WMV1,
  225. AV_CODEC_ID_WMV2,
  226. AV_CODEC_ID_H263P,
  227. AV_CODEC_ID_H263I,
  228. AV_CODEC_ID_FLV1,
  229. AV_CODEC_ID_SVQ1,
  230. AV_CODEC_ID_SVQ3,
  231. AV_CODEC_ID_DVVIDEO,
  232. AV_CODEC_ID_HUFFYUV,
  233. AV_CODEC_ID_CYUV,
  234. AV_CODEC_ID_H264,
  235. AV_CODEC_ID_INDEO3,
  236. AV_CODEC_ID_VP3,
  237. AV_CODEC_ID_THEORA,
  238. AV_CODEC_ID_ASV1,
  239. AV_CODEC_ID_ASV2,
  240. AV_CODEC_ID_FFV1,
  241. AV_CODEC_ID_4XM,
  242. AV_CODEC_ID_VCR1,
  243. AV_CODEC_ID_CLJR,
  244. AV_CODEC_ID_MDEC,
  245. AV_CODEC_ID_ROQ,
  246. AV_CODEC_ID_INTERPLAY_VIDEO,
  247. AV_CODEC_ID_XAN_WC3,
  248. AV_CODEC_ID_XAN_WC4,
  249. AV_CODEC_ID_RPZA,
  250. AV_CODEC_ID_CINEPAK,
  251. AV_CODEC_ID_WS_VQA,
  252. AV_CODEC_ID_MSRLE,
  253. AV_CODEC_ID_MSVIDEO1,
  254. AV_CODEC_ID_IDCIN,
  255. AV_CODEC_ID_8BPS,
  256. AV_CODEC_ID_SMC,
  257. AV_CODEC_ID_FLIC,
  258. AV_CODEC_ID_TRUEMOTION1,
  259. AV_CODEC_ID_VMDVIDEO,
  260. AV_CODEC_ID_MSZH,
  261. AV_CODEC_ID_ZLIB,
  262. AV_CODEC_ID_QTRLE,
  263. AV_CODEC_ID_TSCC,
  264. AV_CODEC_ID_ULTI,
  265. AV_CODEC_ID_QDRAW,
  266. AV_CODEC_ID_VIXL,
  267. AV_CODEC_ID_QPEG,
  268. AV_CODEC_ID_PNG,
  269. AV_CODEC_ID_PPM,
  270. AV_CODEC_ID_PBM,
  271. AV_CODEC_ID_PGM,
  272. AV_CODEC_ID_PGMYUV,
  273. AV_CODEC_ID_PAM,
  274. AV_CODEC_ID_FFVHUFF,
  275. AV_CODEC_ID_RV30,
  276. AV_CODEC_ID_RV40,
  277. AV_CODEC_ID_VC1,
  278. AV_CODEC_ID_WMV3,
  279. AV_CODEC_ID_LOCO,
  280. AV_CODEC_ID_WNV1,
  281. AV_CODEC_ID_AASC,
  282. AV_CODEC_ID_INDEO2,
  283. AV_CODEC_ID_FRAPS,
  284. AV_CODEC_ID_TRUEMOTION2,
  285. AV_CODEC_ID_BMP,
  286. AV_CODEC_ID_CSCD,
  287. AV_CODEC_ID_MMVIDEO,
  288. AV_CODEC_ID_ZMBV,
  289. AV_CODEC_ID_AVS,
  290. AV_CODEC_ID_SMACKVIDEO,
  291. AV_CODEC_ID_NUV,
  292. AV_CODEC_ID_KMVC,
  293. AV_CODEC_ID_FLASHSV,
  294. AV_CODEC_ID_CAVS,
  295. AV_CODEC_ID_JPEG2000,
  296. AV_CODEC_ID_VMNC,
  297. AV_CODEC_ID_VP5,
  298. AV_CODEC_ID_VP6,
  299. AV_CODEC_ID_VP6F,
  300. AV_CODEC_ID_TARGA,
  301. AV_CODEC_ID_DSICINVIDEO,
  302. AV_CODEC_ID_TIERTEXSEQVIDEO,
  303. AV_CODEC_ID_TIFF,
  304. AV_CODEC_ID_GIF,
  305. AV_CODEC_ID_DXA,
  306. AV_CODEC_ID_DNXHD,
  307. AV_CODEC_ID_THP,
  308. AV_CODEC_ID_SGI,
  309. AV_CODEC_ID_C93,
  310. AV_CODEC_ID_BETHSOFTVID,
  311. AV_CODEC_ID_PTX,
  312. AV_CODEC_ID_TXD,
  313. AV_CODEC_ID_VP6A,
  314. AV_CODEC_ID_AMV,
  315. AV_CODEC_ID_VB,
  316. AV_CODEC_ID_PCX,
  317. AV_CODEC_ID_SUNRAST,
  318. AV_CODEC_ID_INDEO4,
  319. AV_CODEC_ID_INDEO5,
  320. AV_CODEC_ID_MIMIC,
  321. AV_CODEC_ID_RL2,
  322. AV_CODEC_ID_ESCAPE124,
  323. AV_CODEC_ID_DIRAC,
  324. AV_CODEC_ID_BFI,
  325. AV_CODEC_ID_CMV,
  326. AV_CODEC_ID_MOTIONPIXELS,
  327. AV_CODEC_ID_TGV,
  328. AV_CODEC_ID_TGQ,
  329. AV_CODEC_ID_TQI,
  330. AV_CODEC_ID_AURA,
  331. AV_CODEC_ID_AURA2,
  332. AV_CODEC_ID_V210X,
  333. AV_CODEC_ID_TMV,
  334. AV_CODEC_ID_V210,
  335. AV_CODEC_ID_DPX,
  336. AV_CODEC_ID_MAD,
  337. AV_CODEC_ID_FRWU,
  338. AV_CODEC_ID_FLASHSV2,
  339. AV_CODEC_ID_CDGRAPHICS,
  340. AV_CODEC_ID_R210,
  341. AV_CODEC_ID_ANM,
  342. AV_CODEC_ID_BINKVIDEO,
  343. AV_CODEC_ID_IFF_ILBM,
  344. #define AV_CODEC_ID_IFF_BYTERUN1 AV_CODEC_ID_IFF_ILBM
  345. AV_CODEC_ID_KGV1,
  346. AV_CODEC_ID_YOP,
  347. AV_CODEC_ID_VP8,
  348. AV_CODEC_ID_PICTOR,
  349. AV_CODEC_ID_ANSI,
  350. AV_CODEC_ID_A64_MULTI,
  351. AV_CODEC_ID_A64_MULTI5,
  352. AV_CODEC_ID_R10K,
  353. AV_CODEC_ID_MXPEG,
  354. AV_CODEC_ID_LAGARITH,
  355. AV_CODEC_ID_PRORES,
  356. AV_CODEC_ID_JV,
  357. AV_CODEC_ID_DFA,
  358. AV_CODEC_ID_WMV3IMAGE,
  359. AV_CODEC_ID_VC1IMAGE,
  360. AV_CODEC_ID_UTVIDEO,
  361. AV_CODEC_ID_BMV_VIDEO,
  362. AV_CODEC_ID_VBLE,
  363. AV_CODEC_ID_DXTORY,
  364. AV_CODEC_ID_V410,
  365. AV_CODEC_ID_XWD,
  366. AV_CODEC_ID_CDXL,
  367. AV_CODEC_ID_XBM,
  368. AV_CODEC_ID_ZEROCODEC,
  369. AV_CODEC_ID_MSS1,
  370. AV_CODEC_ID_MSA1,
  371. AV_CODEC_ID_TSCC2,
  372. AV_CODEC_ID_MTS2,
  373. AV_CODEC_ID_CLLC,
  374. AV_CODEC_ID_MSS2,
  375. AV_CODEC_ID_VP9,
  376. AV_CODEC_ID_AIC,
  377. AV_CODEC_ID_ESCAPE130,
  378. AV_CODEC_ID_G2M,
  379. AV_CODEC_ID_WEBP,
  380. AV_CODEC_ID_HNM4_VIDEO,
  381. AV_CODEC_ID_HEVC,
  382. #define AV_CODEC_ID_H265 AV_CODEC_ID_HEVC
  383. AV_CODEC_ID_FIC,
  384. AV_CODEC_ID_ALIAS_PIX,
  385. AV_CODEC_ID_BRENDER_PIX,
  386. AV_CODEC_ID_PAF_VIDEO,
  387. AV_CODEC_ID_EXR,
  388. AV_CODEC_ID_VP7,
  389. AV_CODEC_ID_SANM,
  390. AV_CODEC_ID_SGIRLE,
  391. AV_CODEC_ID_MVC1,
  392. AV_CODEC_ID_MVC2,
  393. AV_CODEC_ID_HQX,
  394. AV_CODEC_ID_TDSC,
  395. AV_CODEC_ID_HQ_HQA,
  396. AV_CODEC_ID_HAP,
  397. AV_CODEC_ID_DDS,
  398. AV_CODEC_ID_DXV,
  399. AV_CODEC_ID_SCREENPRESSO,
  400. AV_CODEC_ID_RSCC,
  401. AV_CODEC_ID_Y41P = 0x8000,
  402. AV_CODEC_ID_AVRP,
  403. AV_CODEC_ID_012V,
  404. AV_CODEC_ID_AVUI,
  405. AV_CODEC_ID_AYUV,
  406. AV_CODEC_ID_TARGA_Y216,
  407. AV_CODEC_ID_V308,
  408. AV_CODEC_ID_V408,
  409. AV_CODEC_ID_YUV4,
  410. AV_CODEC_ID_AVRN,
  411. AV_CODEC_ID_CPIA,
  412. AV_CODEC_ID_XFACE,
  413. AV_CODEC_ID_SNOW,
  414. AV_CODEC_ID_SMVJPEG,
  415. AV_CODEC_ID_APNG,
  416. AV_CODEC_ID_DAALA,
  417. AV_CODEC_ID_CFHD,
  418. AV_CODEC_ID_TRUEMOTION2RT,
  419. AV_CODEC_ID_M101,
  420. AV_CODEC_ID_MAGICYUV,
  421. AV_CODEC_ID_SHEERVIDEO,
  422. AV_CODEC_ID_YLC,
  423. AV_CODEC_ID_PSD,
  424. AV_CODEC_ID_PIXLET,
  425. AV_CODEC_ID_SPEEDHQ,
  426. AV_CODEC_ID_FMVC,
  427. AV_CODEC_ID_SCPR,
  428. AV_CODEC_ID_CLEARVIDEO,
  429. AV_CODEC_ID_XPM,
  430. AV_CODEC_ID_AV1,
  431. AV_CODEC_ID_BITPACKED,
  432. AV_CODEC_ID_MSCC,
  433. AV_CODEC_ID_SRGC,
  434. AV_CODEC_ID_SVG,
  435. AV_CODEC_ID_GDV,
  436. AV_CODEC_ID_FITS,
  437. /* various PCM "codecs" */
  438. AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
  439. AV_CODEC_ID_PCM_S16LE = 0x10000,
  440. AV_CODEC_ID_PCM_S16BE,
  441. AV_CODEC_ID_PCM_U16LE,
  442. AV_CODEC_ID_PCM_U16BE,
  443. AV_CODEC_ID_PCM_S8,
  444. AV_CODEC_ID_PCM_U8,
  445. AV_CODEC_ID_PCM_MULAW,
  446. AV_CODEC_ID_PCM_ALAW,
  447. AV_CODEC_ID_PCM_S32LE,
  448. AV_CODEC_ID_PCM_S32BE,
  449. AV_CODEC_ID_PCM_U32LE,
  450. AV_CODEC_ID_PCM_U32BE,
  451. AV_CODEC_ID_PCM_S24LE,
  452. AV_CODEC_ID_PCM_S24BE,
  453. AV_CODEC_ID_PCM_U24LE,
  454. AV_CODEC_ID_PCM_U24BE,
  455. AV_CODEC_ID_PCM_S24DAUD,
  456. AV_CODEC_ID_PCM_ZORK,
  457. AV_CODEC_ID_PCM_S16LE_PLANAR,
  458. AV_CODEC_ID_PCM_DVD,
  459. AV_CODEC_ID_PCM_F32BE,
  460. AV_CODEC_ID_PCM_F32LE,
  461. AV_CODEC_ID_PCM_F64BE,
  462. AV_CODEC_ID_PCM_F64LE,
  463. AV_CODEC_ID_PCM_BLURAY,
  464. AV_CODEC_ID_PCM_LXF,
  465. AV_CODEC_ID_S302M,
  466. AV_CODEC_ID_PCM_S8_PLANAR,
  467. AV_CODEC_ID_PCM_S24LE_PLANAR,
  468. AV_CODEC_ID_PCM_S32LE_PLANAR,
  469. AV_CODEC_ID_PCM_S16BE_PLANAR,
  470. AV_CODEC_ID_PCM_S64LE = 0x10800,
  471. AV_CODEC_ID_PCM_S64BE,
  472. AV_CODEC_ID_PCM_F16LE,
  473. AV_CODEC_ID_PCM_F24LE,
  474. /* various ADPCM codecs */
  475. AV_CODEC_ID_ADPCM_IMA_QT = 0x11000,
  476. AV_CODEC_ID_ADPCM_IMA_WAV,
  477. AV_CODEC_ID_ADPCM_IMA_DK3,
  478. AV_CODEC_ID_ADPCM_IMA_DK4,
  479. AV_CODEC_ID_ADPCM_IMA_WS,
  480. AV_CODEC_ID_ADPCM_IMA_SMJPEG,
  481. AV_CODEC_ID_ADPCM_MS,
  482. AV_CODEC_ID_ADPCM_4XM,
  483. AV_CODEC_ID_ADPCM_XA,
  484. AV_CODEC_ID_ADPCM_ADX,
  485. AV_CODEC_ID_ADPCM_EA,
  486. AV_CODEC_ID_ADPCM_G726,
  487. AV_CODEC_ID_ADPCM_CT,
  488. AV_CODEC_ID_ADPCM_SWF,
  489. AV_CODEC_ID_ADPCM_YAMAHA,
  490. AV_CODEC_ID_ADPCM_SBPRO_4,
  491. AV_CODEC_ID_ADPCM_SBPRO_3,
  492. AV_CODEC_ID_ADPCM_SBPRO_2,
  493. AV_CODEC_ID_ADPCM_THP,
  494. AV_CODEC_ID_ADPCM_IMA_AMV,
  495. AV_CODEC_ID_ADPCM_EA_R1,
  496. AV_CODEC_ID_ADPCM_EA_R3,
  497. AV_CODEC_ID_ADPCM_EA_R2,
  498. AV_CODEC_ID_ADPCM_IMA_EA_SEAD,
  499. AV_CODEC_ID_ADPCM_IMA_EA_EACS,
  500. AV_CODEC_ID_ADPCM_EA_XAS,
  501. AV_CODEC_ID_ADPCM_EA_MAXIS_XA,
  502. AV_CODEC_ID_ADPCM_IMA_ISS,
  503. AV_CODEC_ID_ADPCM_G722,
  504. AV_CODEC_ID_ADPCM_IMA_APC,
  505. AV_CODEC_ID_ADPCM_VIMA,
  506. AV_CODEC_ID_ADPCM_AFC = 0x11800,
  507. AV_CODEC_ID_ADPCM_IMA_OKI,
  508. AV_CODEC_ID_ADPCM_DTK,
  509. AV_CODEC_ID_ADPCM_IMA_RAD,
  510. AV_CODEC_ID_ADPCM_G726LE,
  511. AV_CODEC_ID_ADPCM_THP_LE,
  512. AV_CODEC_ID_ADPCM_PSX,
  513. AV_CODEC_ID_ADPCM_AICA,
  514. AV_CODEC_ID_ADPCM_IMA_DAT4,
  515. AV_CODEC_ID_ADPCM_MTAF,
  516. /* AMR */
  517. AV_CODEC_ID_AMR_NB = 0x12000,
  518. AV_CODEC_ID_AMR_WB,
  519. /* RealAudio codecs*/
  520. AV_CODEC_ID_RA_144 = 0x13000,
  521. AV_CODEC_ID_RA_288,
  522. /* various DPCM codecs */
  523. AV_CODEC_ID_ROQ_DPCM = 0x14000,
  524. AV_CODEC_ID_INTERPLAY_DPCM,
  525. AV_CODEC_ID_XAN_DPCM,
  526. AV_CODEC_ID_SOL_DPCM,
  527. AV_CODEC_ID_SDX2_DPCM = 0x14800,
  528. AV_CODEC_ID_GREMLIN_DPCM,
  529. /* audio codecs */
  530. AV_CODEC_ID_MP2 = 0x15000,
  531. AV_CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3
  532. AV_CODEC_ID_AAC,
  533. AV_CODEC_ID_AC3,
  534. AV_CODEC_ID_DTS,
  535. AV_CODEC_ID_VORBIS,
  536. AV_CODEC_ID_DVAUDIO,
  537. AV_CODEC_ID_WMAV1,
  538. AV_CODEC_ID_WMAV2,
  539. AV_CODEC_ID_MACE3,
  540. AV_CODEC_ID_MACE6,
  541. AV_CODEC_ID_VMDAUDIO,
  542. AV_CODEC_ID_FLAC,
  543. AV_CODEC_ID_MP3ADU,
  544. AV_CODEC_ID_MP3ON4,
  545. AV_CODEC_ID_SHORTEN,
  546. AV_CODEC_ID_ALAC,
  547. AV_CODEC_ID_WESTWOOD_SND1,
  548. AV_CODEC_ID_GSM, ///< as in Berlin toast format
  549. AV_CODEC_ID_QDM2,
  550. AV_CODEC_ID_COOK,
  551. AV_CODEC_ID_TRUESPEECH,
  552. AV_CODEC_ID_TTA,
  553. AV_CODEC_ID_SMACKAUDIO,
  554. AV_CODEC_ID_QCELP,
  555. AV_CODEC_ID_WAVPACK,
  556. AV_CODEC_ID_DSICINAUDIO,
  557. AV_CODEC_ID_IMC,
  558. AV_CODEC_ID_MUSEPACK7,
  559. AV_CODEC_ID_MLP,
  560. AV_CODEC_ID_GSM_MS, /* as found in WAV */
  561. AV_CODEC_ID_ATRAC3,
  562. AV_CODEC_ID_APE,
  563. AV_CODEC_ID_NELLYMOSER,
  564. AV_CODEC_ID_MUSEPACK8,
  565. AV_CODEC_ID_SPEEX,
  566. AV_CODEC_ID_WMAVOICE,
  567. AV_CODEC_ID_WMAPRO,
  568. AV_CODEC_ID_WMALOSSLESS,
  569. AV_CODEC_ID_ATRAC3P,
  570. AV_CODEC_ID_EAC3,
  571. AV_CODEC_ID_SIPR,
  572. AV_CODEC_ID_MP1,
  573. AV_CODEC_ID_TWINVQ,
  574. AV_CODEC_ID_TRUEHD,
  575. AV_CODEC_ID_MP4ALS,
  576. AV_CODEC_ID_ATRAC1,
  577. AV_CODEC_ID_BINKAUDIO_RDFT,
  578. AV_CODEC_ID_BINKAUDIO_DCT,
  579. AV_CODEC_ID_AAC_LATM,
  580. AV_CODEC_ID_QDMC,
  581. AV_CODEC_ID_CELT,
  582. AV_CODEC_ID_G723_1,
  583. AV_CODEC_ID_G729,
  584. AV_CODEC_ID_8SVX_EXP,
  585. AV_CODEC_ID_8SVX_FIB,
  586. AV_CODEC_ID_BMV_AUDIO,
  587. AV_CODEC_ID_RALF,
  588. AV_CODEC_ID_IAC,
  589. AV_CODEC_ID_ILBC,
  590. AV_CODEC_ID_OPUS,
  591. AV_CODEC_ID_COMFORT_NOISE,
  592. AV_CODEC_ID_TAK,
  593. AV_CODEC_ID_METASOUND,
  594. AV_CODEC_ID_PAF_AUDIO,
  595. AV_CODEC_ID_ON2AVC,
  596. AV_CODEC_ID_DSS_SP,
  597. AV_CODEC_ID_FFWAVESYNTH = 0x15800,
  598. AV_CODEC_ID_SONIC,
  599. AV_CODEC_ID_SONIC_LS,
  600. AV_CODEC_ID_EVRC,
  601. AV_CODEC_ID_SMV,
  602. AV_CODEC_ID_DSD_LSBF,
  603. AV_CODEC_ID_DSD_MSBF,
  604. AV_CODEC_ID_DSD_LSBF_PLANAR,
  605. AV_CODEC_ID_DSD_MSBF_PLANAR,
  606. AV_CODEC_ID_4GV,
  607. AV_CODEC_ID_INTERPLAY_ACM,
  608. AV_CODEC_ID_XMA1,
  609. AV_CODEC_ID_XMA2,
  610. AV_CODEC_ID_DST,
  611. AV_CODEC_ID_ATRAC3AL,
  612. AV_CODEC_ID_ATRAC3PAL,
  613. AV_CODEC_ID_DOLBY_E,
  614. /* subtitle codecs */
  615. AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs.
  616. AV_CODEC_ID_DVD_SUBTITLE = 0x17000,
  617. AV_CODEC_ID_DVB_SUBTITLE,
  618. AV_CODEC_ID_TEXT, ///< raw UTF-8 text
  619. AV_CODEC_ID_XSUB,
  620. AV_CODEC_ID_SSA,
  621. AV_CODEC_ID_MOV_TEXT,
  622. AV_CODEC_ID_HDMV_PGS_SUBTITLE,
  623. AV_CODEC_ID_DVB_TELETEXT,
  624. AV_CODEC_ID_SRT,
  625. AV_CODEC_ID_MICRODVD = 0x17800,
  626. AV_CODEC_ID_EIA_608,
  627. AV_CODEC_ID_JACOSUB,
  628. AV_CODEC_ID_SAMI,
  629. AV_CODEC_ID_REALTEXT,
  630. AV_CODEC_ID_STL,
  631. AV_CODEC_ID_SUBVIEWER1,
  632. AV_CODEC_ID_SUBVIEWER,
  633. AV_CODEC_ID_SUBRIP,
  634. AV_CODEC_ID_WEBVTT,
  635. AV_CODEC_ID_MPL2,
  636. AV_CODEC_ID_VPLAYER,
  637. AV_CODEC_ID_PJS,
  638. AV_CODEC_ID_ASS,
  639. AV_CODEC_ID_HDMV_TEXT_SUBTITLE,
  640. /* other specific kind of codecs (generally used for attachments) */
  641. AV_CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs.
  642. AV_CODEC_ID_TTF = 0x18000,
  643. AV_CODEC_ID_SCTE_35, ///< Contain timestamp estimated through PCR of program stream.
  644. AV_CODEC_ID_BINTEXT = 0x18800,
  645. AV_CODEC_ID_XBIN,
  646. AV_CODEC_ID_IDF,
  647. AV_CODEC_ID_OTF,
  648. AV_CODEC_ID_SMPTE_KLV,
  649. AV_CODEC_ID_DVD_NAV,
  650. AV_CODEC_ID_TIMED_ID3,
  651. AV_CODEC_ID_BIN_DATA,
  652. AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it
  653. AV_CODEC_ID_MPEG2TS = 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS
  654. * stream (only used by libavformat) */
  655. AV_CODEC_ID_MPEG4SYSTEMS = 0x20001, /**< _FAKE_ codec to indicate a MPEG-4 Systems
  656. * stream (only used by libavformat) */
  657. AV_CODEC_ID_FFMETADATA = 0x21000, ///< Dummy codec for streams containing only metadata information.
  658. AV_CODEC_ID_WRAPPED_AVFRAME = 0x21001, ///< Passthrough codec, AVFrames wrapped in AVPacket
  659. };
  660. /**
  661. * This struct describes the properties of a single codec described by an
  662. * AVCodecID.
  663. * @see avcodec_descriptor_get()
  664. */
  665. typedef struct AVCodecDescriptor {
  666. enum AVCodecID id;
  667. enum AVMediaType type;
  668. /**
  669. * Name of the codec described by this descriptor. It is non-empty and
  670. * unique for each codec descriptor. It should contain alphanumeric
  671. * characters and '_' only.
  672. */
  673. const char *name;
  674. /**
  675. * A more descriptive name for this codec. May be NULL.
  676. */
  677. const char *long_name;
  678. /**
  679. * Codec properties, a combination of AV_CODEC_PROP_* flags.
  680. */
  681. int props;
  682. /**
  683. * MIME type(s) associated with the codec.
  684. * May be NULL; if not, a NULL-terminated array of MIME types.
  685. * The first item is always non-NULL and is the preferred MIME type.
  686. */
  687. const char *const *mime_types;
  688. /**
  689. * If non-NULL, an array of profiles recognized for this codec.
  690. * Terminated with FF_PROFILE_UNKNOWN.
  691. */
  692. const struct AVProfile *profiles;
  693. } AVCodecDescriptor;
  694. /**
  695. * Codec uses only intra compression.
  696. * Video and audio codecs only.
  697. */
  698. #define AV_CODEC_PROP_INTRA_ONLY (1 << 0)
  699. /**
  700. * Codec supports lossy compression. Audio and video codecs only.
  701. * @note a codec may support both lossy and lossless
  702. * compression modes
  703. */
  704. #define AV_CODEC_PROP_LOSSY (1 << 1)
  705. /**
  706. * Codec supports lossless compression. Audio and video codecs only.
  707. */
  708. #define AV_CODEC_PROP_LOSSLESS (1 << 2)
  709. /**
  710. * Codec supports frame reordering. That is, the coded order (the order in which
  711. * the encoded packets are output by the encoders / stored / input to the
  712. * decoders) may be different from the presentation order of the corresponding
  713. * frames.
  714. *
  715. * For codecs that do not have this property set, PTS and DTS should always be
  716. * equal.
  717. */
  718. #define AV_CODEC_PROP_REORDER (1 << 3)
  719. /**
  720. * Subtitle codec is bitmap based
  721. * Decoded AVSubtitle data can be read from the AVSubtitleRect->pict field.
  722. */
  723. #define AV_CODEC_PROP_BITMAP_SUB (1 << 16)
  724. /**
  725. * Subtitle codec is text based.
  726. * Decoded AVSubtitle data can be read from the AVSubtitleRect->ass field.
  727. */
  728. #define AV_CODEC_PROP_TEXT_SUB (1 << 17)
  729. /**
  730. * @ingroup lavc_decoding
  731. * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
  732. * This is mainly needed because some optimized bitstream readers read
  733. * 32 or 64 bit at once and could read over the end.<br>
  734. * Note: If the first 23 bits of the additional bytes are not 0, then damaged
  735. * MPEG bitstreams could cause overread and segfault.
  736. */
  737. #define AV_INPUT_BUFFER_PADDING_SIZE 32
  738. /**
  739. * @ingroup lavc_encoding
  740. * minimum encoding buffer size
  741. * Used to avoid some checks during header writing.
  742. */
  743. #define AV_INPUT_BUFFER_MIN_SIZE 16384
  744. #if FF_API_WITHOUT_PREFIX
  745. /**
  746. * @deprecated use AV_INPUT_BUFFER_PADDING_SIZE instead
  747. */
  748. #define FF_INPUT_BUFFER_PADDING_SIZE 32
  749. /**
  750. * @deprecated use AV_INPUT_BUFFER_MIN_SIZE instead
  751. */
  752. #define FF_MIN_BUFFER_SIZE 16384
  753. #endif /* FF_API_WITHOUT_PREFIX */
  754. /**
  755. * @ingroup lavc_encoding
  756. * motion estimation type.
  757. * @deprecated use codec private option instead
  758. */
  759. #if FF_API_MOTION_EST
  760. enum Motion_Est_ID {
  761. ME_ZERO = 1, ///< no search, that is use 0,0 vector whenever one is needed
  762. ME_FULL,
  763. ME_LOG,
  764. ME_PHODS,
  765. ME_EPZS, ///< enhanced predictive zonal search
  766. ME_X1, ///< reserved for experiments
  767. ME_HEX, ///< hexagon based search
  768. ME_UMH, ///< uneven multi-hexagon search
  769. ME_TESA, ///< transformed exhaustive search algorithm
  770. ME_ITER=50, ///< iterative search
  771. };
  772. #endif
  773. /**
  774. * @ingroup lavc_decoding
  775. */
  776. enum AVDiscard{
  777. /* We leave some space between them for extensions (drop some
  778. * keyframes for intra-only or drop just some bidir frames). */
  779. AVDISCARD_NONE =-16, ///< discard nothing
  780. AVDISCARD_DEFAULT = 0, ///< discard useless packets like 0 size packets in avi
  781. AVDISCARD_NONREF = 8, ///< discard all non reference
  782. AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames
  783. AVDISCARD_NONINTRA= 24, ///< discard all non intra frames
  784. AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes
  785. AVDISCARD_ALL = 48, ///< discard all
  786. };
  787. enum AVAudioServiceType {
  788. AV_AUDIO_SERVICE_TYPE_MAIN = 0,
  789. AV_AUDIO_SERVICE_TYPE_EFFECTS = 1,
  790. AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED = 2,
  791. AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED = 3,
  792. AV_AUDIO_SERVICE_TYPE_DIALOGUE = 4,
  793. AV_AUDIO_SERVICE_TYPE_COMMENTARY = 5,
  794. AV_AUDIO_SERVICE_TYPE_EMERGENCY = 6,
  795. AV_AUDIO_SERVICE_TYPE_VOICE_OVER = 7,
  796. AV_AUDIO_SERVICE_TYPE_KARAOKE = 8,
  797. AV_AUDIO_SERVICE_TYPE_NB , ///< Not part of ABI
  798. };
  799. /**
  800. * @ingroup lavc_encoding
  801. */
  802. typedef struct RcOverride{
  803. int start_frame;
  804. int end_frame;
  805. int qscale; // If this is 0 then quality_factor will be used instead.
  806. float quality_factor;
  807. } RcOverride;
  808. /* encoding support
  809. These flags can be passed in AVCodecContext.flags before initialization.
  810. Note: Not everything is supported yet.
  811. */
  812. /**
  813. * Allow decoders to produce frames with data planes that are not aligned
  814. * to CPU requirements (e.g. due to cropping).
  815. */
  816. #define AV_CODEC_FLAG_UNALIGNED (1 << 0)
  817. /**
  818. * Use fixed qscale.
  819. */
  820. #define AV_CODEC_FLAG_QSCALE (1 << 1)
  821. /**
  822. * 4 MV per MB allowed / advanced prediction for H.263.
  823. */
  824. #define AV_CODEC_FLAG_4MV (1 << 2)
  825. /**
  826. * Output even those frames that might be corrupted.
  827. */
  828. #define AV_CODEC_FLAG_OUTPUT_CORRUPT (1 << 3)
  829. /**
  830. * Use qpel MC.
  831. */
  832. #define AV_CODEC_FLAG_QPEL (1 << 4)
  833. /**
  834. * Use internal 2pass ratecontrol in first pass mode.
  835. */
  836. #define AV_CODEC_FLAG_PASS1 (1 << 9)
  837. /**
  838. * Use internal 2pass ratecontrol in second pass mode.
  839. */
  840. #define AV_CODEC_FLAG_PASS2 (1 << 10)
  841. /**
  842. * loop filter.
  843. */
  844. #define AV_CODEC_FLAG_LOOP_FILTER (1 << 11)
  845. /**
  846. * Only decode/encode grayscale.
  847. */
  848. #define AV_CODEC_FLAG_GRAY (1 << 13)
  849. /**
  850. * error[?] variables will be set during encoding.
  851. */
  852. #define AV_CODEC_FLAG_PSNR (1 << 15)
  853. /**
  854. * Input bitstream might be truncated at a random location
  855. * instead of only at frame boundaries.
  856. */
  857. #define AV_CODEC_FLAG_TRUNCATED (1 << 16)
  858. /**
  859. * Use interlaced DCT.
  860. */
  861. #define AV_CODEC_FLAG_INTERLACED_DCT (1 << 18)
  862. /**
  863. * Force low delay.
  864. */
  865. #define AV_CODEC_FLAG_LOW_DELAY (1 << 19)
  866. /**
  867. * Place global headers in extradata instead of every keyframe.
  868. */
  869. #define AV_CODEC_FLAG_GLOBAL_HEADER (1 << 22)
  870. /**
  871. * Use only bitexact stuff (except (I)DCT).
  872. */
  873. #define AV_CODEC_FLAG_BITEXACT (1 << 23)
  874. /* Fx : Flag for H.263+ extra options */
  875. /**
  876. * H.263 advanced intra coding / MPEG-4 AC prediction
  877. */
  878. #define AV_CODEC_FLAG_AC_PRED (1 << 24)
  879. /**
  880. * interlaced motion estimation
  881. */
  882. #define AV_CODEC_FLAG_INTERLACED_ME (1 << 29)
  883. #define AV_CODEC_FLAG_CLOSED_GOP (1U << 31)
  884. /**
  885. * Allow non spec compliant speedup tricks.
  886. */
  887. #define AV_CODEC_FLAG2_FAST (1 << 0)
  888. /**
  889. * Skip bitstream encoding.
  890. */
  891. #define AV_CODEC_FLAG2_NO_OUTPUT (1 << 2)
  892. /**
  893. * Place global headers at every keyframe instead of in extradata.
  894. */
  895. #define AV_CODEC_FLAG2_LOCAL_HEADER (1 << 3)
  896. /**
  897. * timecode is in drop frame format. DEPRECATED!!!!
  898. */
  899. #define AV_CODEC_FLAG2_DROP_FRAME_TIMECODE (1 << 13)
  900. /**
  901. * Input bitstream might be truncated at a packet boundaries
  902. * instead of only at frame boundaries.
  903. */
  904. #define AV_CODEC_FLAG2_CHUNKS (1 << 15)
  905. /**
  906. * Discard cropping information from SPS.
  907. */
  908. #define AV_CODEC_FLAG2_IGNORE_CROP (1 << 16)
  909. /**
  910. * Show all frames before the first keyframe
  911. */
  912. #define AV_CODEC_FLAG2_SHOW_ALL (1 << 22)
  913. /**
  914. * Export motion vectors through frame side data
  915. */
  916. #define AV_CODEC_FLAG2_EXPORT_MVS (1 << 28)
  917. /**
  918. * Do not skip samples and export skip information as frame side data
  919. */
  920. #define AV_CODEC_FLAG2_SKIP_MANUAL (1 << 29)
  921. /**
  922. * Do not reset ASS ReadOrder field on flush (subtitles decoding)
  923. */
  924. #define AV_CODEC_FLAG2_RO_FLUSH_NOOP (1 << 30)
  925. /* Unsupported options :
  926. * Syntax Arithmetic coding (SAC)
  927. * Reference Picture Selection
  928. * Independent Segment Decoding */
  929. /* /Fx */
  930. /* codec capabilities */
  931. /**
  932. * Decoder can use draw_horiz_band callback.
  933. */
  934. #define AV_CODEC_CAP_DRAW_HORIZ_BAND (1 << 0)
  935. /**
  936. * Codec uses get_buffer() for allocating buffers and supports custom allocators.
  937. * If not set, it might not use get_buffer() at all or use operations that
  938. * assume the buffer was allocated by avcodec_default_get_buffer.
  939. */
  940. #define AV_CODEC_CAP_DR1 (1 << 1)
  941. #define AV_CODEC_CAP_TRUNCATED (1 << 3)
  942. /**
  943. * Encoder or decoder requires flushing with NULL input at the end in order to
  944. * give the complete and correct output.
  945. *
  946. * NOTE: If this flag is not set, the codec is guaranteed to never be fed with
  947. * with NULL data. The user can still send NULL data to the public encode
  948. * or decode function, but libavcodec will not pass it along to the codec
  949. * unless this flag is set.
  950. *
  951. * Decoders:
  952. * The decoder has a non-zero delay and needs to be fed with avpkt->data=NULL,
  953. * avpkt->size=0 at the end to get the delayed data until the decoder no longer
  954. * returns frames.
  955. *
  956. * Encoders:
  957. * The encoder needs to be fed with NULL data at the end of encoding until the
  958. * encoder no longer returns data.
  959. *
  960. * NOTE: For encoders implementing the AVCodec.encode2() function, setting this
  961. * flag also means that the encoder must set the pts and duration for
  962. * each output packet. If this flag is not set, the pts and duration will
  963. * be determined by libavcodec from the input frame.
  964. */
  965. #define AV_CODEC_CAP_DELAY (1 << 5)
  966. /**
  967. * Codec can be fed a final frame with a smaller size.
  968. * This can be used to prevent truncation of the last audio samples.
  969. */
  970. #define AV_CODEC_CAP_SMALL_LAST_FRAME (1 << 6)
  971. /**
  972. * Codec can output multiple frames per AVPacket
  973. * Normally demuxers return one frame at a time, demuxers which do not do
  974. * are connected to a parser to split what they return into proper frames.
  975. * This flag is reserved to the very rare category of codecs which have a
  976. * bitstream that cannot be split into frames without timeconsuming
  977. * operations like full decoding. Demuxers carrying such bitstreams thus
  978. * may return multiple frames in a packet. This has many disadvantages like
  979. * prohibiting stream copy in many cases thus it should only be considered
  980. * as a last resort.
  981. */
  982. #define AV_CODEC_CAP_SUBFRAMES (1 << 8)
  983. /**
  984. * Codec is experimental and is thus avoided in favor of non experimental
  985. * encoders
  986. */
  987. #define AV_CODEC_CAP_EXPERIMENTAL (1 << 9)
  988. /**
  989. * Codec should fill in channel configuration and samplerate instead of container
  990. */
  991. #define AV_CODEC_CAP_CHANNEL_CONF (1 << 10)
  992. /**
  993. * Codec supports frame-level multithreading.
  994. */
  995. #define AV_CODEC_CAP_FRAME_THREADS (1 << 12)
  996. /**
  997. * Codec supports slice-based (or partition-based) multithreading.
  998. */
  999. #define AV_CODEC_CAP_SLICE_THREADS (1 << 13)
  1000. /**
  1001. * Codec supports changed parameters at any point.
  1002. */
  1003. #define AV_CODEC_CAP_PARAM_CHANGE (1 << 14)
  1004. /**
  1005. * Codec supports avctx->thread_count == 0 (auto).
  1006. */
  1007. #define AV_CODEC_CAP_AUTO_THREADS (1 << 15)
  1008. /**
  1009. * Audio encoder supports receiving a different number of samples in each call.
  1010. */
  1011. #define AV_CODEC_CAP_VARIABLE_FRAME_SIZE (1 << 16)
  1012. /**
  1013. * Decoder is not a preferred choice for probing.
  1014. * This indicates that the decoder is not a good choice for probing.
  1015. * It could for example be an expensive to spin up hardware decoder,
  1016. * or it could simply not provide a lot of useful information about
  1017. * the stream.
  1018. * A decoder marked with this flag should only be used as last resort
  1019. * choice for probing.
  1020. */
  1021. #define AV_CODEC_CAP_AVOID_PROBING (1 << 17)
  1022. /**
  1023. * Codec is intra only.
  1024. */
  1025. #define AV_CODEC_CAP_INTRA_ONLY 0x40000000
  1026. /**
  1027. * Codec is lossless.
  1028. */
  1029. #define AV_CODEC_CAP_LOSSLESS 0x80000000
  1030. #if FF_API_WITHOUT_PREFIX
  1031. /**
  1032. * Allow decoders to produce frames with data planes that are not aligned
  1033. * to CPU requirements (e.g. due to cropping).
  1034. */
  1035. #define CODEC_FLAG_UNALIGNED AV_CODEC_FLAG_UNALIGNED
  1036. #define CODEC_FLAG_QSCALE AV_CODEC_FLAG_QSCALE
  1037. #define CODEC_FLAG_4MV AV_CODEC_FLAG_4MV
  1038. #define CODEC_FLAG_OUTPUT_CORRUPT AV_CODEC_FLAG_OUTPUT_CORRUPT
  1039. #define CODEC_FLAG_QPEL AV_CODEC_FLAG_QPEL
  1040. #if FF_API_GMC
  1041. /**
  1042. * @deprecated use the "gmc" private option of the libxvid encoder
  1043. */
  1044. #define CODEC_FLAG_GMC 0x0020 ///< Use GMC.
  1045. #endif
  1046. #if FF_API_MV0
  1047. /**
  1048. * @deprecated use the flag "mv0" in the "mpv_flags" private option of the
  1049. * mpegvideo encoders
  1050. */
  1051. #define CODEC_FLAG_MV0 0x0040
  1052. #endif
  1053. #if FF_API_INPUT_PRESERVED
  1054. /**
  1055. * @deprecated passing reference-counted frames to the encoders replaces this
  1056. * flag
  1057. */
  1058. #define CODEC_FLAG_INPUT_PRESERVED 0x0100
  1059. #endif
  1060. #define CODEC_FLAG_PASS1 AV_CODEC_FLAG_PASS1
  1061. #define CODEC_FLAG_PASS2 AV_CODEC_FLAG_PASS2
  1062. #define CODEC_FLAG_GRAY AV_CODEC_FLAG_GRAY
  1063. #define CODEC_FLAG_PSNR AV_CODEC_FLAG_PSNR
  1064. #define CODEC_FLAG_TRUNCATED AV_CODEC_FLAG_TRUNCATED
  1065. #if FF_API_NORMALIZE_AQP
  1066. /**
  1067. * @deprecated use the flag "naq" in the "mpv_flags" private option of the
  1068. * mpegvideo encoders
  1069. */
  1070. #define CODEC_FLAG_NORMALIZE_AQP 0x00020000
  1071. #endif
  1072. #define CODEC_FLAG_INTERLACED_DCT AV_CODEC_FLAG_INTERLACED_DCT
  1073. #define CODEC_FLAG_LOW_DELAY AV_CODEC_FLAG_LOW_DELAY
  1074. #define CODEC_FLAG_GLOBAL_HEADER AV_CODEC_FLAG_GLOBAL_HEADER
  1075. #define CODEC_FLAG_BITEXACT AV_CODEC_FLAG_BITEXACT
  1076. #define CODEC_FLAG_AC_PRED AV_CODEC_FLAG_AC_PRED
  1077. #define CODEC_FLAG_LOOP_FILTER AV_CODEC_FLAG_LOOP_FILTER
  1078. #define CODEC_FLAG_INTERLACED_ME AV_CODEC_FLAG_INTERLACED_ME
  1079. #define CODEC_FLAG_CLOSED_GOP AV_CODEC_FLAG_CLOSED_GOP
  1080. #define CODEC_FLAG2_FAST AV_CODEC_FLAG2_FAST
  1081. #define CODEC_FLAG2_NO_OUTPUT AV_CODEC_FLAG2_NO_OUTPUT
  1082. #define CODEC_FLAG2_LOCAL_HEADER AV_CODEC_FLAG2_LOCAL_HEADER
  1083. #define CODEC_FLAG2_DROP_FRAME_TIMECODE AV_CODEC_FLAG2_DROP_FRAME_TIMECODE
  1084. #define CODEC_FLAG2_IGNORE_CROP AV_CODEC_FLAG2_IGNORE_CROP
  1085. #define CODEC_FLAG2_CHUNKS AV_CODEC_FLAG2_CHUNKS
  1086. #define CODEC_FLAG2_SHOW_ALL AV_CODEC_FLAG2_SHOW_ALL
  1087. #define CODEC_FLAG2_EXPORT_MVS AV_CODEC_FLAG2_EXPORT_MVS
  1088. #define CODEC_FLAG2_SKIP_MANUAL AV_CODEC_FLAG2_SKIP_MANUAL
  1089. /* Unsupported options :
  1090. * Syntax Arithmetic coding (SAC)
  1091. * Reference Picture Selection
  1092. * Independent Segment Decoding */
  1093. /* /Fx */
  1094. /* codec capabilities */
  1095. #define CODEC_CAP_DRAW_HORIZ_BAND AV_CODEC_CAP_DRAW_HORIZ_BAND ///< Decoder can use draw_horiz_band callback.
  1096. /**
  1097. * Codec uses get_buffer() for allocating buffers and supports custom allocators.
  1098. * If not set, it might not use get_buffer() at all or use operations that
  1099. * assume the buffer was allocated by avcodec_default_get_buffer.
  1100. */
  1101. #define CODEC_CAP_DR1 AV_CODEC_CAP_DR1
  1102. #define CODEC_CAP_TRUNCATED AV_CODEC_CAP_TRUNCATED
  1103. /**
  1104. * Encoder or decoder requires flushing with NULL input at the end in order to
  1105. * give the complete and correct output.
  1106. *
  1107. * NOTE: If this flag is not set, the codec is guaranteed to never be fed with
  1108. * with NULL data. The user can still send NULL data to the public encode
  1109. * or decode function, but libavcodec will not pass it along to the codec
  1110. * unless this flag is set.
  1111. *
  1112. * Decoders:
  1113. * The decoder has a non-zero delay and needs to be fed with avpkt->data=NULL,
  1114. * avpkt->size=0 at the end to get the delayed data until the decoder no longer
  1115. * returns frames.
  1116. *
  1117. * Encoders:
  1118. * The encoder needs to be fed with NULL data at the end of encoding until the
  1119. * encoder no longer returns data.
  1120. *
  1121. * NOTE: For encoders implementing the AVCodec.encode2() function, setting this
  1122. * flag also means that the encoder must set the pts and duration for
  1123. * each output packet. If this flag is not set, the pts and duration will
  1124. * be determined by libavcodec from the input frame.
  1125. */
  1126. #define CODEC_CAP_DELAY AV_CODEC_CAP_DELAY
  1127. /**
  1128. * Codec can be fed a final frame with a smaller size.
  1129. * This can be used to prevent truncation of the last audio samples.
  1130. */
  1131. #define CODEC_CAP_SMALL_LAST_FRAME AV_CODEC_CAP_SMALL_LAST_FRAME
  1132. /**
  1133. * Codec can output multiple frames per AVPacket
  1134. * Normally demuxers return one frame at a time, demuxers which do not do
  1135. * are connected to a parser to split what they return into proper frames.
  1136. * This flag is reserved to the very rare category of codecs which have a
  1137. * bitstream that cannot be split into frames without timeconsuming
  1138. * operations like full decoding. Demuxers carrying such bitstreams thus
  1139. * may return multiple frames in a packet. This has many disadvantages like
  1140. * prohibiting stream copy in many cases thus it should only be considered
  1141. * as a last resort.
  1142. */
  1143. #define CODEC_CAP_SUBFRAMES AV_CODEC_CAP_SUBFRAMES
  1144. /**
  1145. * Codec is experimental and is thus avoided in favor of non experimental
  1146. * encoders
  1147. */
  1148. #define CODEC_CAP_EXPERIMENTAL AV_CODEC_CAP_EXPERIMENTAL
  1149. /**
  1150. * Codec should fill in channel configuration and samplerate instead of container
  1151. */
  1152. #define CODEC_CAP_CHANNEL_CONF AV_CODEC_CAP_CHANNEL_CONF
  1153. /**
  1154. * Codec supports frame-level multithreading.
  1155. */
  1156. #define CODEC_CAP_FRAME_THREADS AV_CODEC_CAP_FRAME_THREADS
  1157. /**
  1158. * Codec supports slice-based (or partition-based) multithreading.
  1159. */
  1160. #define CODEC_CAP_SLICE_THREADS AV_CODEC_CAP_SLICE_THREADS
  1161. /**
  1162. * Codec supports changed parameters at any point.
  1163. */
  1164. #define CODEC_CAP_PARAM_CHANGE AV_CODEC_CAP_PARAM_CHANGE
  1165. /**
  1166. * Codec supports avctx->thread_count == 0 (auto).
  1167. */
  1168. #define CODEC_CAP_AUTO_THREADS AV_CODEC_CAP_AUTO_THREADS
  1169. /**
  1170. * Audio encoder supports receiving a different number of samples in each call.
  1171. */
  1172. #define CODEC_CAP_VARIABLE_FRAME_SIZE AV_CODEC_CAP_VARIABLE_FRAME_SIZE
  1173. /**
  1174. * Codec is intra only.
  1175. */
  1176. #define CODEC_CAP_INTRA_ONLY AV_CODEC_CAP_INTRA_ONLY
  1177. /**
  1178. * Codec is lossless.
  1179. */
  1180. #define CODEC_CAP_LOSSLESS AV_CODEC_CAP_LOSSLESS
  1181. /**
  1182. * HWAccel is experimental and is thus avoided in favor of non experimental
  1183. * codecs
  1184. */
  1185. #define HWACCEL_CODEC_CAP_EXPERIMENTAL 0x0200
  1186. #endif /* FF_API_WITHOUT_PREFIX */
  1187. /**
  1188. * Pan Scan area.
  1189. * This specifies the area which should be displayed.
  1190. * Note there may be multiple such areas for one frame.
  1191. */
  1192. typedef struct AVPanScan{
  1193. /**
  1194. * id
  1195. * - encoding: Set by user.
  1196. * - decoding: Set by libavcodec.
  1197. */
  1198. int id;
  1199. /**
  1200. * width and height in 1/16 pel
  1201. * - encoding: Set by user.
  1202. * - decoding: Set by libavcodec.
  1203. */
  1204. int width;
  1205. int height;
  1206. /**
  1207. * position of the top left corner in 1/16 pel for up to 3 fields/frames
  1208. * - encoding: Set by user.
  1209. * - decoding: Set by libavcodec.
  1210. */
  1211. int16_t position[3][2];
  1212. }AVPanScan;
  1213. /**
  1214. * This structure describes the bitrate properties of an encoded bitstream. It
  1215. * roughly corresponds to a subset the VBV parameters for MPEG-2 or HRD
  1216. * parameters for H.264/HEVC.
  1217. */
  1218. typedef struct AVCPBProperties {
  1219. /**
  1220. * Maximum bitrate of the stream, in bits per second.
  1221. * Zero if unknown or unspecified.
  1222. */
  1223. int max_bitrate;
  1224. /**
  1225. * Minimum bitrate of the stream, in bits per second.
  1226. * Zero if unknown or unspecified.
  1227. */
  1228. int min_bitrate;
  1229. /**
  1230. * Average bitrate of the stream, in bits per second.
  1231. * Zero if unknown or unspecified.
  1232. */
  1233. int avg_bitrate;
  1234. /**
  1235. * The size of the buffer to which the ratecontrol is applied, in bits.
  1236. * Zero if unknown or unspecified.
  1237. */
  1238. int buffer_size;
  1239. /**
  1240. * The delay between the time the packet this structure is associated with
  1241. * is received and the time when it should be decoded, in periods of a 27MHz
  1242. * clock.
  1243. *
  1244. * UINT64_MAX when unknown or unspecified.
  1245. */
  1246. uint64_t vbv_delay;
  1247. } AVCPBProperties;
  1248. /**
  1249. * The decoder will keep a reference to the frame and may reuse it later.
  1250. */
  1251. #define AV_GET_BUFFER_FLAG_REF (1 << 0)
  1252. /**
  1253. * @defgroup lavc_packet AVPacket
  1254. *
  1255. * Types and functions for working with AVPacket.
  1256. * @{
  1257. */
  1258. enum AVPacketSideDataType {
  1259. /**
  1260. * An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE
  1261. * bytes worth of palette. This side data signals that a new palette is
  1262. * present.
  1263. */
  1264. AV_PKT_DATA_PALETTE,
  1265. /**
  1266. * The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format
  1267. * that the extradata buffer was changed and the receiving side should
  1268. * act upon it appropriately. The new extradata is embedded in the side
  1269. * data buffer and should be immediately used for processing the current
  1270. * frame or packet.
  1271. */
  1272. AV_PKT_DATA_NEW_EXTRADATA,
  1273. /**
  1274. * An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:
  1275. * @code
  1276. * u32le param_flags
  1277. * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT)
  1278. * s32le channel_count
  1279. * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT)
  1280. * u64le channel_layout
  1281. * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE)
  1282. * s32le sample_rate
  1283. * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS)
  1284. * s32le width
  1285. * s32le height
  1286. * @endcode
  1287. */
  1288. AV_PKT_DATA_PARAM_CHANGE,
  1289. /**
  1290. * An AV_PKT_DATA_H263_MB_INFO side data packet contains a number of
  1291. * structures with info about macroblocks relevant to splitting the
  1292. * packet into smaller packets on macroblock edges (e.g. as for RFC 2190).
  1293. * That is, it does not necessarily contain info about all macroblocks,
  1294. * as long as the distance between macroblocks in the info is smaller
  1295. * than the target payload size.
  1296. * Each MB info structure is 12 bytes, and is laid out as follows:
  1297. * @code
  1298. * u32le bit offset from the start of the packet
  1299. * u8 current quantizer at the start of the macroblock
  1300. * u8 GOB number
  1301. * u16le macroblock address within the GOB
  1302. * u8 horizontal MV predictor
  1303. * u8 vertical MV predictor
  1304. * u8 horizontal MV predictor for block number 3
  1305. * u8 vertical MV predictor for block number 3
  1306. * @endcode
  1307. */
  1308. AV_PKT_DATA_H263_MB_INFO,
  1309. /**
  1310. * This side data should be associated with an audio stream and contains
  1311. * ReplayGain information in form of the AVReplayGain struct.
  1312. */
  1313. AV_PKT_DATA_REPLAYGAIN,
  1314. /**
  1315. * This side data contains a 3x3 transformation matrix describing an affine
  1316. * transformation that needs to be applied to the decoded video frames for
  1317. * correct presentation.
  1318. *
  1319. * See libavutil/display.h for a detailed description of the data.
  1320. */
  1321. AV_PKT_DATA_DISPLAYMATRIX,
  1322. /**
  1323. * This side data should be associated with a video stream and contains
  1324. * Stereoscopic 3D information in form of the AVStereo3D struct.
  1325. */
  1326. AV_PKT_DATA_STEREO3D,
  1327. /**
  1328. * This side data should be associated with an audio stream and corresponds
  1329. * to enum AVAudioServiceType.
  1330. */
  1331. AV_PKT_DATA_AUDIO_SERVICE_TYPE,
  1332. /**
  1333. * This side data contains quality related information from the encoder.
  1334. * @code
  1335. * u32le quality factor of the compressed frame. Allowed range is between 1 (good) and FF_LAMBDA_MAX (bad).
  1336. * u8 picture type
  1337. * u8 error count
  1338. * u16 reserved
  1339. * u64le[error count] sum of squared differences between encoder in and output
  1340. * @endcode
  1341. */
  1342. AV_PKT_DATA_QUALITY_STATS,
  1343. /**
  1344. * This side data contains an integer value representing the stream index
  1345. * of a "fallback" track. A fallback track indicates an alternate
  1346. * track to use when the current track can not be decoded for some reason.
  1347. * e.g. no decoder available for codec.
  1348. */
  1349. AV_PKT_DATA_FALLBACK_TRACK,
  1350. /**
  1351. * This side data corresponds to the AVCPBProperties struct.
  1352. */
  1353. AV_PKT_DATA_CPB_PROPERTIES,
  1354. /**
  1355. * Recommmends skipping the specified number of samples
  1356. * @code
  1357. * u32le number of samples to skip from start of this packet
  1358. * u32le number of samples to skip from end of this packet
  1359. * u8 reason for start skip
  1360. * u8 reason for end skip (0=padding silence, 1=convergence)
  1361. * @endcode
  1362. */
  1363. AV_PKT_DATA_SKIP_SAMPLES=70,
  1364. /**
  1365. * An AV_PKT_DATA_JP_DUALMONO side data packet indicates that
  1366. * the packet may contain "dual mono" audio specific to Japanese DTV
  1367. * and if it is true, recommends only the selected channel to be used.
  1368. * @code
  1369. * u8 selected channels (0=mail/left, 1=sub/right, 2=both)
  1370. * @endcode
  1371. */
  1372. AV_PKT_DATA_JP_DUALMONO,
  1373. /**
  1374. * A list of zero terminated key/value strings. There is no end marker for
  1375. * the list, so it is required to rely on the side data size to stop.
  1376. */
  1377. AV_PKT_DATA_STRINGS_METADATA,
  1378. /**
  1379. * Subtitle event position
  1380. * @code
  1381. * u32le x1
  1382. * u32le y1
  1383. * u32le x2
  1384. * u32le y2
  1385. * @endcode
  1386. */
  1387. AV_PKT_DATA_SUBTITLE_POSITION,
  1388. /**
  1389. * Data found in BlockAdditional element of matroska container. There is
  1390. * no end marker for the data, so it is required to rely on the side data
  1391. * size to recognize the end. 8 byte id (as found in BlockAddId) followed
  1392. * by data.
  1393. */
  1394. AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL,
  1395. /**
  1396. * The optional first identifier line of a WebVTT cue.
  1397. */
  1398. AV_PKT_DATA_WEBVTT_IDENTIFIER,
  1399. /**
  1400. * The optional settings (rendering instructions) that immediately
  1401. * follow the timestamp specifier of a WebVTT cue.
  1402. */
  1403. AV_PKT_DATA_WEBVTT_SETTINGS,
  1404. /**
  1405. * A list of zero terminated key/value strings. There is no end marker for
  1406. * the list, so it is required to rely on the side data size to stop. This
  1407. * side data includes updated metadata which appeared in the stream.
  1408. */
  1409. AV_PKT_DATA_METADATA_UPDATE,
  1410. /**
  1411. * MPEGTS stream ID, this is required to pass the stream ID
  1412. * information from the demuxer to the corresponding muxer.
  1413. */
  1414. AV_PKT_DATA_MPEGTS_STREAM_ID,
  1415. /**
  1416. * Mastering display metadata (based on SMPTE-2086:2014). This metadata
  1417. * should be associated with a video stream and contains data in the form
  1418. * of the AVMasteringDisplayMetadata struct.
  1419. */
  1420. AV_PKT_DATA_MASTERING_DISPLAY_METADATA,
  1421. /**
  1422. * This side data should be associated with a video stream and corresponds
  1423. * to the AVSphericalMapping structure.
  1424. */
  1425. AV_PKT_DATA_SPHERICAL,
  1426. /**
  1427. * Content light level (based on CTA-861.3). This metadata should be
  1428. * associated with a video stream and contains data in the form of the
  1429. * AVContentLightMetadata struct.
  1430. */
  1431. AV_PKT_DATA_CONTENT_LIGHT_LEVEL,
  1432. /**
  1433. * ATSC A53 Part 4 Closed Captions. This metadata should be associated with
  1434. * a video stream. A53 CC bitstream is stored as uint8_t in AVPacketSideData.data.
  1435. * The number of bytes of CC data is AVPacketSideData.size.
  1436. */
  1437. AV_PKT_DATA_A53_CC,
  1438. /**
  1439. * The number of side data elements (in fact a bit more than it).
  1440. * This is not part of the public API/ABI in the sense that it may
  1441. * change when new side data types are added.
  1442. * This must stay the last enum value.
  1443. * If its value becomes huge, some code using it
  1444. * needs to be updated as it assumes it to be smaller than other limits.
  1445. */
  1446. AV_PKT_DATA_NB
  1447. };
  1448. #define AV_PKT_DATA_QUALITY_FACTOR AV_PKT_DATA_QUALITY_STATS //DEPRECATED
  1449. typedef struct AVPacketSideData {
  1450. uint8_t *data;
  1451. int size;
  1452. enum AVPacketSideDataType type;
  1453. } AVPacketSideData;
  1454. /**
  1455. * This structure stores compressed data. It is typically exported by demuxers
  1456. * and then passed as input to decoders, or received as output from encoders and
  1457. * then passed to muxers.
  1458. *
  1459. * For video, it should typically contain one compressed frame. For audio it may
  1460. * contain several compressed frames. Encoders are allowed to output empty
  1461. * packets, with no compressed data, containing only side data
  1462. * (e.g. to update some stream parameters at the end of encoding).
  1463. *
  1464. * AVPacket is one of the few structs in FFmpeg, whose size is a part of public
  1465. * ABI. Thus it may be allocated on stack and no new fields can be added to it
  1466. * without libavcodec and libavformat major bump.
  1467. *
  1468. * The semantics of data ownership depends on the buf field.
  1469. * If it is set, the packet data is dynamically allocated and is
  1470. * valid indefinitely until a call to av_packet_unref() reduces the
  1471. * reference count to 0.
  1472. *
  1473. * If the buf field is not set av_packet_ref() would make a copy instead
  1474. * of increasing the reference count.
  1475. *
  1476. * The side data is always allocated with av_malloc(), copied by
  1477. * av_packet_ref() and freed by av_packet_unref().
  1478. *
  1479. * @see av_packet_ref
  1480. * @see av_packet_unref
  1481. */
  1482. typedef struct AVPacket {
  1483. /**
  1484. * A reference to the reference-counted buffer where the packet data is
  1485. * stored.
  1486. * May be NULL, then the packet data is not reference-counted.
  1487. */
  1488. AVBufferRef *buf;
  1489. /**
  1490. * Presentation timestamp in AVStream->time_base units; the time at which
  1491. * the decompressed packet will be presented to the user.
  1492. * Can be AV_NOPTS_VALUE if it is not stored in the file.
  1493. * pts MUST be larger or equal to dts as presentation cannot happen before
  1494. * decompression, unless one wants to view hex dumps. Some formats misuse
  1495. * the terms dts and pts/cts to mean something different. Such timestamps
  1496. * must be converted to true pts/dts before they are stored in AVPacket.
  1497. */
  1498. int64_t pts;
  1499. /**
  1500. * Decompression timestamp in AVStream->time_base units; the time at which
  1501. * the packet is decompressed.
  1502. * Can be AV_NOPTS_VALUE if it is not stored in the file.
  1503. */
  1504. int64_t dts;
  1505. uint8_t *data;
  1506. int size;
  1507. int stream_index;
  1508. /**
  1509. * A combination of AV_PKT_FLAG values
  1510. */
  1511. int flags;
  1512. /**
  1513. * Additional packet data that can be provided by the container.
  1514. * Packet can contain several types of side information.
  1515. */
  1516. AVPacketSideData *side_data;
  1517. int side_data_elems;
  1518. /**
  1519. * Duration of this packet in AVStream->time_base units, 0 if unknown.
  1520. * Equals next_pts - this_pts in presentation order.
  1521. */
  1522. int64_t duration;
  1523. int64_t pos; ///< byte position in stream, -1 if unknown
  1524. #if FF_API_CONVERGENCE_DURATION
  1525. /**
  1526. * @deprecated Same as the duration field, but as int64_t. This was required
  1527. * for Matroska subtitles, whose duration values could overflow when the
  1528. * duration field was still an int.
  1529. */
  1530. attribute_deprecated
  1531. int64_t convergence_duration;
  1532. #endif
  1533. } AVPacket;
  1534. #define AV_PKT_FLAG_KEY 0x0001 ///< The packet contains a keyframe
  1535. #define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted
  1536. /**
  1537. * Flag is used to discard packets which are required to maintain valid
  1538. * decoder state but are not required for output and should be dropped
  1539. * after decoding.
  1540. **/
  1541. #define AV_PKT_FLAG_DISCARD 0x0004
  1542. /**
  1543. * The packet comes from a trusted source.
  1544. *
  1545. * Otherwise-unsafe constructs such as arbitrary pointers to data
  1546. * outside the packet may be followed.
  1547. */
  1548. #define AV_PKT_FLAG_TRUSTED 0x0008
  1549. enum AVSideDataParamChangeFlags {
  1550. AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT = 0x0001,
  1551. AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002,
  1552. AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE = 0x0004,
  1553. AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = 0x0008,
  1554. };
  1555. /**
  1556. * @}
  1557. */
  1558. struct AVCodecInternal;
  1559. enum AVFieldOrder {
  1560. AV_FIELD_UNKNOWN,
  1561. AV_FIELD_PROGRESSIVE,
  1562. AV_FIELD_TT, //< Top coded_first, top displayed first
  1563. AV_FIELD_BB, //< Bottom coded first, bottom displayed first
  1564. AV_FIELD_TB, //< Top coded first, bottom displayed first
  1565. AV_FIELD_BT, //< Bottom coded first, top displayed first
  1566. };
  1567. /**
  1568. * main external API structure.
  1569. * New fields can be added to the end with minor version bumps.
  1570. * Removal, reordering and changes to existing fields require a major
  1571. * version bump.
  1572. * You can use AVOptions (av_opt* / av_set/get*()) to access these fields from user
  1573. * applications.
  1574. * The name string for AVOptions options matches the associated command line
  1575. * parameter name and can be found in libavcodec/options_table.h
  1576. * The AVOption/command line parameter names differ in some cases from the C
  1577. * structure field names for historic reasons or brevity.
  1578. * sizeof(AVCodecContext) must not be used outside libav*.
  1579. */
  1580. typedef struct AVCodecContext {
  1581. /**
  1582. * information on struct for av_log
  1583. * - set by avcodec_alloc_context3
  1584. */
  1585. const AVClass *av_class;
  1586. int log_level_offset;
  1587. enum AVMediaType codec_type; /* see AVMEDIA_TYPE_xxx */
  1588. const struct AVCodec *codec;
  1589. #if FF_API_CODEC_NAME
  1590. /**
  1591. * @deprecated this field is not used for anything in libavcodec
  1592. */
  1593. attribute_deprecated
  1594. char codec_name[32];
  1595. #endif
  1596. enum AVCodecID codec_id; /* see AV_CODEC_ID_xxx */
  1597. /**
  1598. * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
  1599. * This is used to work around some encoder bugs.
  1600. * A demuxer should set this to what is stored in the field used to identify the codec.
  1601. * If there are multiple such fields in a container then the demuxer should choose the one
  1602. * which maximizes the information about the used codec.
  1603. * If the codec tag field in a container is larger than 32 bits then the demuxer should
  1604. * remap the longer ID to 32 bits with a table or other structure. Alternatively a new
  1605. * extra_codec_tag + size could be added but for this a clear advantage must be demonstrated
  1606. * first.
  1607. * - encoding: Set by user, if not then the default based on codec_id will be used.
  1608. * - decoding: Set by user, will be converted to uppercase by libavcodec during init.
  1609. */
  1610. unsigned int codec_tag;
  1611. #if FF_API_STREAM_CODEC_TAG
  1612. /**
  1613. * @deprecated this field is unused
  1614. */
  1615. attribute_deprecated
  1616. unsigned int stream_codec_tag;
  1617. #endif
  1618. void *priv_data;
  1619. /**
  1620. * Private context used for internal data.
  1621. *
  1622. * Unlike priv_data, this is not codec-specific. It is used in general
  1623. * libavcodec functions.
  1624. */
  1625. struct AVCodecInternal *internal;
  1626. /**
  1627. * Private data of the user, can be used to carry app specific stuff.
  1628. * - encoding: Set by user.
  1629. * - decoding: Set by user.
  1630. */
  1631. void *opaque;
  1632. /**
  1633. * the average bitrate
  1634. * - encoding: Set by user; unused for constant quantizer encoding.
  1635. * - decoding: Set by user, may be overwritten by libavcodec
  1636. * if this info is available in the stream
  1637. */
  1638. int64_t bit_rate;
  1639. /**
  1640. * number of bits the bitstream is allowed to diverge from the reference.
  1641. * the reference can be CBR (for CBR pass1) or VBR (for pass2)
  1642. * - encoding: Set by user; unused for constant quantizer encoding.
  1643. * - decoding: unused
  1644. */
  1645. int bit_rate_tolerance;
  1646. /**
  1647. * Global quality for codecs which cannot change it per frame.
  1648. * This should be proportional to MPEG-1/2/4 qscale.
  1649. * - encoding: Set by user.
  1650. * - decoding: unused
  1651. */
  1652. int global_quality;
  1653. /**
  1654. * - encoding: Set by user.
  1655. * - decoding: unused
  1656. */
  1657. int compression_level;
  1658. #define FF_COMPRESSION_DEFAULT -1
  1659. /**
  1660. * AV_CODEC_FLAG_*.
  1661. * - encoding: Set by user.
  1662. * - decoding: Set by user.
  1663. */
  1664. int flags;
  1665. /**
  1666. * AV_CODEC_FLAG2_*
  1667. * - encoding: Set by user.
  1668. * - decoding: Set by user.
  1669. */
  1670. int flags2;
  1671. /**
  1672. * some codecs need / can use extradata like Huffman tables.
  1673. * MJPEG: Huffman tables
  1674. * rv10: additional flags
  1675. * MPEG-4: global headers (they can be in the bitstream or here)
  1676. * The allocated memory should be AV_INPUT_BUFFER_PADDING_SIZE bytes larger
  1677. * than extradata_size to avoid problems if it is read with the bitstream reader.
  1678. * The bytewise contents of extradata must not depend on the architecture or CPU endianness.
  1679. * - encoding: Set/allocated/freed by libavcodec.
  1680. * - decoding: Set/allocated/freed by user.
  1681. */
  1682. uint8_t *extradata;
  1683. int extradata_size;
  1684. /**
  1685. * This is the fundamental unit of time (in seconds) in terms
  1686. * of which frame timestamps are represented. For fixed-fps content,
  1687. * timebase should be 1/framerate and timestamp increments should be
  1688. * identically 1.
  1689. * This often, but not always is the inverse of the frame rate or field rate
  1690. * for video. 1/time_base is not the average frame rate if the frame rate is not
  1691. * constant.
  1692. *
  1693. * Like containers, elementary streams also can store timestamps, 1/time_base
  1694. * is the unit in which these timestamps are specified.
  1695. * As example of such codec time base see ISO/IEC 14496-2:2001(E)
  1696. * vop_time_increment_resolution and fixed_vop_rate
  1697. * (fixed_vop_rate == 0 implies that it is different from the framerate)
  1698. *
  1699. * - encoding: MUST be set by user.
  1700. * - decoding: the use of this field for decoding is deprecated.
  1701. * Use framerate instead.
  1702. */
  1703. AVRational time_base;
  1704. /**
  1705. * For some codecs, the time base is closer to the field rate than the frame rate.
  1706. * Most notably, H.264 and MPEG-2 specify time_base as half of frame duration
  1707. * if no telecine is used ...
  1708. *
  1709. * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2.
  1710. */
  1711. int ticks_per_frame;
  1712. /**
  1713. * Codec delay.
  1714. *
  1715. * Encoding: Number of frames delay there will be from the encoder input to
  1716. * the decoder output. (we assume the decoder matches the spec)
  1717. * Decoding: Number of frames delay in addition to what a standard decoder
  1718. * as specified in the spec would produce.
  1719. *
  1720. * Video:
  1721. * Number of frames the decoded output will be delayed relative to the
  1722. * encoded input.
  1723. *
  1724. * Audio:
  1725. * For encoding, this field is unused (see initial_padding).
  1726. *
  1727. * For decoding, this is the number of samples the decoder needs to
  1728. * output before the decoder's output is valid. When seeking, you should
  1729. * start decoding this many samples prior to your desired seek point.
  1730. *
  1731. * - encoding: Set by libavcodec.
  1732. * - decoding: Set by libavcodec.
  1733. */
  1734. int delay;
  1735. /* video only */
  1736. /**
  1737. * picture width / height.
  1738. *
  1739. * @note Those fields may not match the values of the last
  1740. * AVFrame output by avcodec_decode_video2 due frame
  1741. * reordering.
  1742. *
  1743. * - encoding: MUST be set by user.
  1744. * - decoding: May be set by the user before opening the decoder if known e.g.
  1745. * from the container. Some decoders will require the dimensions
  1746. * to be set by the caller. During decoding, the decoder may
  1747. * overwrite those values as required while parsing the data.
  1748. */
  1749. int width, height;
  1750. /**
  1751. * Bitstream width / height, may be different from width/height e.g. when
  1752. * the decoded frame is cropped before being output or lowres is enabled.
  1753. *
  1754. * @note Those field may not match the value of the last
  1755. * AVFrame output by avcodec_receive_frame() due frame
  1756. * reordering.
  1757. *
  1758. * - encoding: unused
  1759. * - decoding: May be set by the user before opening the decoder if known
  1760. * e.g. from the container. During decoding, the decoder may
  1761. * overwrite those values as required while parsing the data.
  1762. */
  1763. int coded_width, coded_height;
  1764. /**
  1765. * the number of pictures in a group of pictures, or 0 for intra_only
  1766. * - encoding: Set by user.
  1767. * - decoding: unused
  1768. */
  1769. int gop_size;
  1770. /**
  1771. * Pixel format, see AV_PIX_FMT_xxx.
  1772. * May be set by the demuxer if known from headers.
  1773. * May be overridden by the decoder if it knows better.
  1774. *
  1775. * @note This field may not match the value of the last
  1776. * AVFrame output by avcodec_receive_frame() due frame
  1777. * reordering.
  1778. *
  1779. * - encoding: Set by user.
  1780. * - decoding: Set by user if known, overridden by libavcodec while
  1781. * parsing the data.
  1782. */
  1783. enum AVPixelFormat pix_fmt;
  1784. #if FF_API_MOTION_EST
  1785. /**
  1786. * This option does nothing
  1787. * @deprecated use codec private options instead
  1788. */
  1789. attribute_deprecated int me_method;
  1790. #endif
  1791. /**
  1792. * If non NULL, 'draw_horiz_band' is called by the libavcodec
  1793. * decoder to draw a horizontal band. It improves cache usage. Not
  1794. * all codecs can do that. You must check the codec capabilities
  1795. * beforehand.
  1796. * When multithreading is used, it may be called from multiple threads
  1797. * at the same time; threads might draw different parts of the same AVFrame,
  1798. * or multiple AVFrames, and there is no guarantee that slices will be drawn
  1799. * in order.
  1800. * The function is also used by hardware acceleration APIs.
  1801. * It is called at least once during frame decoding to pass
  1802. * the data needed for hardware render.
  1803. * In that mode instead of pixel data, AVFrame points to
  1804. * a structure specific to the acceleration API. The application
  1805. * reads the structure and can change some fields to indicate progress
  1806. * or mark state.
  1807. * - encoding: unused
  1808. * - decoding: Set by user.
  1809. * @param height the height of the slice
  1810. * @param y the y position of the slice
  1811. * @param type 1->top field, 2->bottom field, 3->frame
  1812. * @param offset offset into the AVFrame.data from which the slice should be read
  1813. */
  1814. void (*draw_horiz_band)(struct AVCodecContext *s,
  1815. const AVFrame *src, int offset[AV_NUM_DATA_POINTERS],
  1816. int y, int type, int height);
  1817. /**
  1818. * callback to negotiate the pixelFormat
  1819. * @param fmt is the list of formats which are supported by the codec,
  1820. * it is terminated by -1 as 0 is a valid format, the formats are ordered by quality.
  1821. * The first is always the native one.
  1822. * @note The callback may be called again immediately if initialization for
  1823. * the selected (hardware-accelerated) pixel format failed.
  1824. * @warning Behavior is undefined if the callback returns a value not
  1825. * in the fmt list of formats.
  1826. * @return the chosen format
  1827. * - encoding: unused
  1828. * - decoding: Set by user, if not set the native format will be chosen.
  1829. */
  1830. enum AVPixelFormat (*get_format)(struct AVCodecContext *s, const enum AVPixelFormat * fmt);
  1831. /**
  1832. * maximum number of B-frames between non-B-frames
  1833. * Note: The output will be delayed by max_b_frames+1 relative to the input.
  1834. * - encoding: Set by user.
  1835. * - decoding: unused
  1836. */
  1837. int max_b_frames;
  1838. /**
  1839. * qscale factor between IP and B-frames
  1840. * If > 0 then the last P-frame quantizer will be used (q= lastp_q*factor+offset).
  1841. * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
  1842. * - encoding: Set by user.
  1843. * - decoding: unused
  1844. */
  1845. float b_quant_factor;
  1846. #if FF_API_RC_STRATEGY
  1847. /** @deprecated use codec private option instead */
  1848. attribute_deprecated int rc_strategy;
  1849. #define FF_RC_STRATEGY_XVID 1
  1850. #endif
  1851. #if FF_API_PRIVATE_OPT
  1852. /** @deprecated use encoder private options instead */
  1853. attribute_deprecated
  1854. int b_frame_strategy;
  1855. #endif
  1856. /**
  1857. * qscale offset between IP and B-frames
  1858. * - encoding: Set by user.
  1859. * - decoding: unused
  1860. */
  1861. float b_quant_offset;
  1862. /**
  1863. * Size of the frame reordering buffer in the decoder.
  1864. * For MPEG-2 it is 1 IPB or 0 low delay IP.
  1865. * - encoding: Set by libavcodec.
  1866. * - decoding: Set by libavcodec.
  1867. */
  1868. int has_b_frames;
  1869. #if FF_API_PRIVATE_OPT
  1870. /** @deprecated use encoder private options instead */
  1871. attribute_deprecated
  1872. int mpeg_quant;
  1873. #endif
  1874. /**
  1875. * qscale factor between P- and I-frames
  1876. * If > 0 then the last P-frame quantizer will be used (q = lastp_q * factor + offset).
  1877. * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
  1878. * - encoding: Set by user.
  1879. * - decoding: unused
  1880. */
  1881. float i_quant_factor;
  1882. /**
  1883. * qscale offset between P and I-frames
  1884. * - encoding: Set by user.
  1885. * - decoding: unused
  1886. */
  1887. float i_quant_offset;
  1888. /**
  1889. * luminance masking (0-> disabled)
  1890. * - encoding: Set by user.
  1891. * - decoding: unused
  1892. */
  1893. float lumi_masking;
  1894. /**
  1895. * temporary complexity masking (0-> disabled)
  1896. * - encoding: Set by user.
  1897. * - decoding: unused
  1898. */
  1899. float temporal_cplx_masking;
  1900. /**
  1901. * spatial complexity masking (0-> disabled)
  1902. * - encoding: Set by user.
  1903. * - decoding: unused
  1904. */
  1905. float spatial_cplx_masking;
  1906. /**
  1907. * p block masking (0-> disabled)
  1908. * - encoding: Set by user.
  1909. * - decoding: unused
  1910. */
  1911. float p_masking;
  1912. /**
  1913. * darkness masking (0-> disabled)
  1914. * - encoding: Set by user.
  1915. * - decoding: unused
  1916. */
  1917. float dark_masking;
  1918. /**
  1919. * slice count
  1920. * - encoding: Set by libavcodec.
  1921. * - decoding: Set by user (or 0).
  1922. */
  1923. int slice_count;
  1924. #if FF_API_PRIVATE_OPT
  1925. /** @deprecated use encoder private options instead */
  1926. attribute_deprecated
  1927. int prediction_method;
  1928. #define FF_PRED_LEFT 0
  1929. #define FF_PRED_PLANE 1
  1930. #define FF_PRED_MEDIAN 2
  1931. #endif
  1932. /**
  1933. * slice offsets in the frame in bytes
  1934. * - encoding: Set/allocated by libavcodec.
  1935. * - decoding: Set/allocated by user (or NULL).
  1936. */
  1937. int *slice_offset;
  1938. /**
  1939. * sample aspect ratio (0 if unknown)
  1940. * That is the width of a pixel divided by the height of the pixel.
  1941. * Numerator and denominator must be relatively prime and smaller than 256 for some video standards.
  1942. * - encoding: Set by user.
  1943. * - decoding: Set by libavcodec.
  1944. */
  1945. AVRational sample_aspect_ratio;
  1946. /**
  1947. * motion estimation comparison function
  1948. * - encoding: Set by user.
  1949. * - decoding: unused
  1950. */
  1951. int me_cmp;
  1952. /**
  1953. * subpixel motion estimation comparison function
  1954. * - encoding: Set by user.
  1955. * - decoding: unused
  1956. */
  1957. int me_sub_cmp;
  1958. /**
  1959. * macroblock comparison function (not supported yet)
  1960. * - encoding: Set by user.
  1961. * - decoding: unused
  1962. */
  1963. int mb_cmp;
  1964. /**
  1965. * interlaced DCT comparison function
  1966. * - encoding: Set by user.
  1967. * - decoding: unused
  1968. */
  1969. int ildct_cmp;
  1970. #define FF_CMP_SAD 0
  1971. #define FF_CMP_SSE 1
  1972. #define FF_CMP_SATD 2
  1973. #define FF_CMP_DCT 3
  1974. #define FF_CMP_PSNR 4
  1975. #define FF_CMP_BIT 5
  1976. #define FF_CMP_RD 6
  1977. #define FF_CMP_ZERO 7
  1978. #define FF_CMP_VSAD 8
  1979. #define FF_CMP_VSSE 9
  1980. #define FF_CMP_NSSE 10
  1981. #define FF_CMP_W53 11
  1982. #define FF_CMP_W97 12
  1983. #define FF_CMP_DCTMAX 13
  1984. #define FF_CMP_DCT264 14
  1985. #define FF_CMP_MEDIAN_SAD 15
  1986. #define FF_CMP_CHROMA 256
  1987. /**
  1988. * ME diamond size & shape
  1989. * - encoding: Set by user.
  1990. * - decoding: unused
  1991. */
  1992. int dia_size;
  1993. /**
  1994. * amount of previous MV predictors (2a+1 x 2a+1 square)
  1995. * - encoding: Set by user.
  1996. * - decoding: unused
  1997. */
  1998. int last_predictor_count;
  1999. #if FF_API_PRIVATE_OPT
  2000. /** @deprecated use encoder private options instead */
  2001. attribute_deprecated
  2002. int pre_me;
  2003. #endif
  2004. /**
  2005. * motion estimation prepass comparison function
  2006. * - encoding: Set by user.
  2007. * - decoding: unused
  2008. */
  2009. int me_pre_cmp;
  2010. /**
  2011. * ME prepass diamond size & shape
  2012. * - encoding: Set by user.
  2013. * - decoding: unused
  2014. */
  2015. int pre_dia_size;
  2016. /**
  2017. * subpel ME quality
  2018. * - encoding: Set by user.
  2019. * - decoding: unused
  2020. */
  2021. int me_subpel_quality;
  2022. #if FF_API_AFD
  2023. /**
  2024. * DTG active format information (additional aspect ratio
  2025. * information only used in DVB MPEG-2 transport streams)
  2026. * 0 if not set.
  2027. *
  2028. * - encoding: unused
  2029. * - decoding: Set by decoder.
  2030. * @deprecated Deprecated in favor of AVSideData
  2031. */
  2032. attribute_deprecated int dtg_active_format;
  2033. #define FF_DTG_AFD_SAME 8
  2034. #define FF_DTG_AFD_4_3 9
  2035. #define FF_DTG_AFD_16_9 10
  2036. #define FF_DTG_AFD_14_9 11
  2037. #define FF_DTG_AFD_4_3_SP_14_9 13
  2038. #define FF_DTG_AFD_16_9_SP_14_9 14
  2039. #define FF_DTG_AFD_SP_4_3 15
  2040. #endif /* FF_API_AFD */
  2041. /**
  2042. * maximum motion estimation search range in subpel units
  2043. * If 0 then no limit.
  2044. *
  2045. * - encoding: Set by user.
  2046. * - decoding: unused
  2047. */
  2048. int me_range;
  2049. #if FF_API_QUANT_BIAS
  2050. /**
  2051. * @deprecated use encoder private option instead
  2052. */
  2053. attribute_deprecated int intra_quant_bias;
  2054. #define FF_DEFAULT_QUANT_BIAS 999999
  2055. /**
  2056. * @deprecated use encoder private option instead
  2057. */
  2058. attribute_deprecated int inter_quant_bias;
  2059. #endif
  2060. /**
  2061. * slice flags
  2062. * - encoding: unused
  2063. * - decoding: Set by user.
  2064. */
  2065. int slice_flags;
  2066. #define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display
  2067. #define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG-2 field pics)
  2068. #define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
  2069. /**
  2070. * macroblock decision mode
  2071. * - encoding: Set by user.
  2072. * - decoding: unused
  2073. */
  2074. int mb_decision;
  2075. #define FF_MB_DECISION_SIMPLE 0 ///< uses mb_cmp
  2076. #define FF_MB_DECISION_BITS 1 ///< chooses the one which needs the fewest bits
  2077. #define FF_MB_DECISION_RD 2 ///< rate distortion
  2078. /**
  2079. * custom intra quantization matrix
  2080. * - encoding: Set by user, can be NULL.
  2081. * - decoding: Set by libavcodec.
  2082. */
  2083. uint16_t *intra_matrix;
  2084. /**
  2085. * custom inter quantization matrix
  2086. * - encoding: Set by user, can be NULL.
  2087. * - decoding: Set by libavcodec.
  2088. */
  2089. uint16_t *inter_matrix;
  2090. #if FF_API_PRIVATE_OPT
  2091. /** @deprecated use encoder private options instead */
  2092. attribute_deprecated
  2093. int scenechange_threshold;
  2094. /** @deprecated use encoder private options instead */
  2095. attribute_deprecated
  2096. int noise_reduction;
  2097. #endif
  2098. #if FF_API_MPV_OPT
  2099. /**
  2100. * @deprecated this field is unused
  2101. */
  2102. attribute_deprecated
  2103. int me_threshold;
  2104. /**
  2105. * @deprecated this field is unused
  2106. */
  2107. attribute_deprecated
  2108. int mb_threshold;
  2109. #endif
  2110. /**
  2111. * precision of the intra DC coefficient - 8
  2112. * - encoding: Set by user.
  2113. * - decoding: Set by libavcodec
  2114. */
  2115. int intra_dc_precision;
  2116. /**
  2117. * Number of macroblock rows at the top which are skipped.
  2118. * - encoding: unused
  2119. * - decoding: Set by user.
  2120. */
  2121. int skip_top;
  2122. /**
  2123. * Number of macroblock rows at the bottom which are skipped.
  2124. * - encoding: unused
  2125. * - decoding: Set by user.
  2126. */
  2127. int skip_bottom;
  2128. #if FF_API_MPV_OPT
  2129. /**
  2130. * @deprecated use encoder private options instead
  2131. */
  2132. attribute_deprecated
  2133. float border_masking;
  2134. #endif
  2135. /**
  2136. * minimum MB Lagrange multiplier
  2137. * - encoding: Set by user.
  2138. * - decoding: unused
  2139. */
  2140. int mb_lmin;
  2141. /**
  2142. * maximum MB Lagrange multiplier
  2143. * - encoding: Set by user.
  2144. * - decoding: unused
  2145. */
  2146. int mb_lmax;
  2147. #if FF_API_PRIVATE_OPT
  2148. /**
  2149. * @deprecated use encoder private options instead
  2150. */
  2151. attribute_deprecated
  2152. int me_penalty_compensation;
  2153. #endif
  2154. /**
  2155. * - encoding: Set by user.
  2156. * - decoding: unused
  2157. */
  2158. int bidir_refine;
  2159. #if FF_API_PRIVATE_OPT
  2160. /** @deprecated use encoder private options instead */
  2161. attribute_deprecated
  2162. int brd_scale;
  2163. #endif
  2164. /**
  2165. * minimum GOP size
  2166. * - encoding: Set by user.
  2167. * - decoding: unused
  2168. */
  2169. int keyint_min;
  2170. /**
  2171. * number of reference frames
  2172. * - encoding: Set by user.
  2173. * - decoding: Set by lavc.
  2174. */
  2175. int refs;
  2176. #if FF_API_PRIVATE_OPT
  2177. /** @deprecated use encoder private options instead */
  2178. attribute_deprecated
  2179. int chromaoffset;
  2180. #endif
  2181. #if FF_API_UNUSED_MEMBERS
  2182. /**
  2183. * Multiplied by qscale for each frame and added to scene_change_score.
  2184. * - encoding: Set by user.
  2185. * - decoding: unused
  2186. */
  2187. attribute_deprecated int scenechange_factor;
  2188. #endif
  2189. /**
  2190. * Note: Value depends upon the compare function used for fullpel ME.
  2191. * - encoding: Set by user.
  2192. * - decoding: unused
  2193. */
  2194. int mv0_threshold;
  2195. #if FF_API_PRIVATE_OPT
  2196. /** @deprecated use encoder private options instead */
  2197. attribute_deprecated
  2198. int b_sensitivity;
  2199. #endif
  2200. /**
  2201. * Chromaticity coordinates of the source primaries.
  2202. * - encoding: Set by user
  2203. * - decoding: Set by libavcodec
  2204. */
  2205. enum AVColorPrimaries color_primaries;
  2206. /**
  2207. * Color Transfer Characteristic.
  2208. * - encoding: Set by user
  2209. * - decoding: Set by libavcodec
  2210. */
  2211. enum AVColorTransferCharacteristic color_trc;
  2212. /**
  2213. * YUV colorspace type.
  2214. * - encoding: Set by user
  2215. * - decoding: Set by libavcodec
  2216. */
  2217. enum AVColorSpace colorspace;
  2218. /**
  2219. * MPEG vs JPEG YUV range.
  2220. * - encoding: Set by user
  2221. * - decoding: Set by libavcodec
  2222. */
  2223. enum AVColorRange color_range;
  2224. /**
  2225. * This defines the location of chroma samples.
  2226. * - encoding: Set by user
  2227. * - decoding: Set by libavcodec
  2228. */
  2229. enum AVChromaLocation chroma_sample_location;
  2230. /**
  2231. * Number of slices.
  2232. * Indicates number of picture subdivisions. Used for parallelized
  2233. * decoding.
  2234. * - encoding: Set by user
  2235. * - decoding: unused
  2236. */
  2237. int slices;
  2238. /** Field order
  2239. * - encoding: set by libavcodec
  2240. * - decoding: Set by user.
  2241. */
  2242. enum AVFieldOrder field_order;
  2243. /* audio only */
  2244. int sample_rate; ///< samples per second
  2245. int channels; ///< number of audio channels
  2246. /**
  2247. * audio sample format
  2248. * - encoding: Set by user.
  2249. * - decoding: Set by libavcodec.
  2250. */
  2251. enum AVSampleFormat sample_fmt; ///< sample format
  2252. /* The following data should not be initialized. */
  2253. /**
  2254. * Number of samples per channel in an audio frame.
  2255. *
  2256. * - encoding: set by libavcodec in avcodec_open2(). Each submitted frame
  2257. * except the last must contain exactly frame_size samples per channel.
  2258. * May be 0 when the codec has AV_CODEC_CAP_VARIABLE_FRAME_SIZE set, then the
  2259. * frame size is not restricted.
  2260. * - decoding: may be set by some decoders to indicate constant frame size
  2261. */
  2262. int frame_size;
  2263. /**
  2264. * Frame counter, set by libavcodec.
  2265. *
  2266. * - decoding: total number of frames returned from the decoder so far.
  2267. * - encoding: total number of frames passed to the encoder so far.
  2268. *
  2269. * @note the counter is not incremented if encoding/decoding resulted in
  2270. * an error.
  2271. */
  2272. int frame_number;
  2273. /**
  2274. * number of bytes per packet if constant and known or 0
  2275. * Used by some WAV based audio codecs.
  2276. */
  2277. int block_align;
  2278. /**
  2279. * Audio cutoff bandwidth (0 means "automatic")
  2280. * - encoding: Set by user.
  2281. * - decoding: unused
  2282. */
  2283. int cutoff;
  2284. /**
  2285. * Audio channel layout.
  2286. * - encoding: set by user.
  2287. * - decoding: set by user, may be overwritten by libavcodec.
  2288. */
  2289. uint64_t channel_layout;
  2290. /**
  2291. * Request decoder to use this channel layout if it can (0 for default)
  2292. * - encoding: unused
  2293. * - decoding: Set by user.
  2294. */
  2295. uint64_t request_channel_layout;
  2296. /**
  2297. * Type of service that the audio stream conveys.
  2298. * - encoding: Set by user.
  2299. * - decoding: Set by libavcodec.
  2300. */
  2301. enum AVAudioServiceType audio_service_type;
  2302. /**
  2303. * desired sample format
  2304. * - encoding: Not used.
  2305. * - decoding: Set by user.
  2306. * Decoder will decode to this format if it can.
  2307. */
  2308. enum AVSampleFormat request_sample_fmt;
  2309. /**
  2310. * This callback is called at the beginning of each frame to get data
  2311. * buffer(s) for it. There may be one contiguous buffer for all the data or
  2312. * there may be a buffer per each data plane or anything in between. What
  2313. * this means is, you may set however many entries in buf[] you feel necessary.
  2314. * Each buffer must be reference-counted using the AVBuffer API (see description
  2315. * of buf[] below).
  2316. *
  2317. * The following fields will be set in the frame before this callback is
  2318. * called:
  2319. * - format
  2320. * - width, height (video only)
  2321. * - sample_rate, channel_layout, nb_samples (audio only)
  2322. * Their values may differ from the corresponding values in
  2323. * AVCodecContext. This callback must use the frame values, not the codec
  2324. * context values, to calculate the required buffer size.
  2325. *
  2326. * This callback must fill the following fields in the frame:
  2327. * - data[]
  2328. * - linesize[]
  2329. * - extended_data:
  2330. * * if the data is planar audio with more than 8 channels, then this
  2331. * callback must allocate and fill extended_data to contain all pointers
  2332. * to all data planes. data[] must hold as many pointers as it can.
  2333. * extended_data must be allocated with av_malloc() and will be freed in
  2334. * av_frame_unref().
  2335. * * otherwise extended_data must point to data
  2336. * - buf[] must contain one or more pointers to AVBufferRef structures. Each of
  2337. * the frame's data and extended_data pointers must be contained in these. That
  2338. * is, one AVBufferRef for each allocated chunk of memory, not necessarily one
  2339. * AVBufferRef per data[] entry. See: av_buffer_create(), av_buffer_alloc(),
  2340. * and av_buffer_ref().
  2341. * - extended_buf and nb_extended_buf must be allocated with av_malloc() by
  2342. * this callback and filled with the extra buffers if there are more
  2343. * buffers than buf[] can hold. extended_buf will be freed in
  2344. * av_frame_unref().
  2345. *
  2346. * If AV_CODEC_CAP_DR1 is not set then get_buffer2() must call
  2347. * avcodec_default_get_buffer2() instead of providing buffers allocated by
  2348. * some other means.
  2349. *
  2350. * Each data plane must be aligned to the maximum required by the target
  2351. * CPU.
  2352. *
  2353. * @see avcodec_default_get_buffer2()
  2354. *
  2355. * Video:
  2356. *
  2357. * If AV_GET_BUFFER_FLAG_REF is set in flags then the frame may be reused
  2358. * (read and/or written to if it is writable) later by libavcodec.
  2359. *
  2360. * avcodec_align_dimensions2() should be used to find the required width and
  2361. * height, as they normally need to be rounded up to the next multiple of 16.
  2362. *
  2363. * Some decoders do not support linesizes changing between frames.
  2364. *
  2365. * If frame multithreading is used and thread_safe_callbacks is set,
  2366. * this callback may be called from a different thread, but not from more
  2367. * than one at once. Does not need to be reentrant.
  2368. *
  2369. * @see avcodec_align_dimensions2()
  2370. *
  2371. * Audio:
  2372. *
  2373. * Decoders request a buffer of a particular size by setting
  2374. * AVFrame.nb_samples prior to calling get_buffer2(). The decoder may,
  2375. * however, utilize only part of the buffer by setting AVFrame.nb_samples
  2376. * to a smaller value in the output frame.
  2377. *
  2378. * As a convenience, av_samples_get_buffer_size() and
  2379. * av_samples_fill_arrays() in libavutil may be used by custom get_buffer2()
  2380. * functions to find the required data size and to fill data pointers and
  2381. * linesize. In AVFrame.linesize, only linesize[0] may be set for audio
  2382. * since all planes must be the same size.
  2383. *
  2384. * @see av_samples_get_buffer_size(), av_samples_fill_arrays()
  2385. *
  2386. * - encoding: unused
  2387. * - decoding: Set by libavcodec, user can override.
  2388. */
  2389. int (*get_buffer2)(struct AVCodecContext *s, AVFrame *frame, int flags);
  2390. /**
  2391. * If non-zero, the decoded audio and video frames returned from
  2392. * avcodec_decode_video2() and avcodec_decode_audio4() are reference-counted
  2393. * and are valid indefinitely. The caller must free them with
  2394. * av_frame_unref() when they are not needed anymore.
  2395. * Otherwise, the decoded frames must not be freed by the caller and are
  2396. * only valid until the next decode call.
  2397. *
  2398. * This is always automatically enabled if avcodec_receive_frame() is used.
  2399. *
  2400. * - encoding: unused
  2401. * - decoding: set by the caller before avcodec_open2().
  2402. */
  2403. attribute_deprecated
  2404. int refcounted_frames;
  2405. /* - encoding parameters */
  2406. float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)
  2407. float qblur; ///< amount of qscale smoothing over time (0.0-1.0)
  2408. /**
  2409. * minimum quantizer
  2410. * - encoding: Set by user.
  2411. * - decoding: unused
  2412. */
  2413. int qmin;
  2414. /**
  2415. * maximum quantizer
  2416. * - encoding: Set by user.
  2417. * - decoding: unused
  2418. */
  2419. int qmax;
  2420. /**
  2421. * maximum quantizer difference between frames
  2422. * - encoding: Set by user.
  2423. * - decoding: unused
  2424. */
  2425. int max_qdiff;
  2426. #if FF_API_MPV_OPT
  2427. /**
  2428. * @deprecated use encoder private options instead
  2429. */
  2430. attribute_deprecated
  2431. float rc_qsquish;
  2432. attribute_deprecated
  2433. float rc_qmod_amp;
  2434. attribute_deprecated
  2435. int rc_qmod_freq;
  2436. #endif
  2437. /**
  2438. * decoder bitstream buffer size
  2439. * - encoding: Set by user.
  2440. * - decoding: unused
  2441. */
  2442. int rc_buffer_size;
  2443. /**
  2444. * ratecontrol override, see RcOverride
  2445. * - encoding: Allocated/set/freed by user.
  2446. * - decoding: unused
  2447. */
  2448. int rc_override_count;
  2449. RcOverride *rc_override;
  2450. #if FF_API_MPV_OPT
  2451. /**
  2452. * @deprecated use encoder private options instead
  2453. */
  2454. attribute_deprecated
  2455. const char *rc_eq;
  2456. #endif
  2457. /**
  2458. * maximum bitrate
  2459. * - encoding: Set by user.
  2460. * - decoding: Set by user, may be overwritten by libavcodec.
  2461. */
  2462. int64_t rc_max_rate;
  2463. /**
  2464. * minimum bitrate
  2465. * - encoding: Set by user.
  2466. * - decoding: unused
  2467. */
  2468. int64_t rc_min_rate;
  2469. #if FF_API_MPV_OPT
  2470. /**
  2471. * @deprecated use encoder private options instead
  2472. */
  2473. attribute_deprecated
  2474. float rc_buffer_aggressivity;
  2475. attribute_deprecated
  2476. float rc_initial_cplx;
  2477. #endif
  2478. /**
  2479. * Ratecontrol attempt to use, at maximum, <value> of what can be used without an underflow.
  2480. * - encoding: Set by user.
  2481. * - decoding: unused.
  2482. */
  2483. float rc_max_available_vbv_use;
  2484. /**
  2485. * Ratecontrol attempt to use, at least, <value> times the amount needed to prevent a vbv overflow.
  2486. * - encoding: Set by user.
  2487. * - decoding: unused.
  2488. */
  2489. float rc_min_vbv_overflow_use;
  2490. /**
  2491. * Number of bits which should be loaded into the rc buffer before decoding starts.
  2492. * - encoding: Set by user.
  2493. * - decoding: unused
  2494. */
  2495. int rc_initial_buffer_occupancy;
  2496. #if FF_API_CODER_TYPE
  2497. #define FF_CODER_TYPE_VLC 0
  2498. #define FF_CODER_TYPE_AC 1
  2499. #define FF_CODER_TYPE_RAW 2
  2500. #define FF_CODER_TYPE_RLE 3
  2501. #if FF_API_UNUSED_MEMBERS
  2502. #define FF_CODER_TYPE_DEFLATE 4
  2503. #endif /* FF_API_UNUSED_MEMBERS */
  2504. /**
  2505. * @deprecated use encoder private options instead
  2506. */
  2507. attribute_deprecated
  2508. int coder_type;
  2509. #endif /* FF_API_CODER_TYPE */
  2510. #if FF_API_PRIVATE_OPT
  2511. /** @deprecated use encoder private options instead */
  2512. attribute_deprecated
  2513. int context_model;
  2514. #endif
  2515. #if FF_API_MPV_OPT
  2516. /**
  2517. * @deprecated use encoder private options instead
  2518. */
  2519. attribute_deprecated
  2520. int lmin;
  2521. /**
  2522. * @deprecated use encoder private options instead
  2523. */
  2524. attribute_deprecated
  2525. int lmax;
  2526. #endif
  2527. #if FF_API_PRIVATE_OPT
  2528. /** @deprecated use encoder private options instead */
  2529. attribute_deprecated
  2530. int frame_skip_threshold;
  2531. /** @deprecated use encoder private options instead */
  2532. attribute_deprecated
  2533. int frame_skip_factor;
  2534. /** @deprecated use encoder private options instead */
  2535. attribute_deprecated
  2536. int frame_skip_exp;
  2537. /** @deprecated use encoder private options instead */
  2538. attribute_deprecated
  2539. int frame_skip_cmp;
  2540. #endif /* FF_API_PRIVATE_OPT */
  2541. /**
  2542. * trellis RD quantization
  2543. * - encoding: Set by user.
  2544. * - decoding: unused
  2545. */
  2546. int trellis;
  2547. #if FF_API_PRIVATE_OPT
  2548. /** @deprecated use encoder private options instead */
  2549. attribute_deprecated
  2550. int min_prediction_order;
  2551. /** @deprecated use encoder private options instead */
  2552. attribute_deprecated
  2553. int max_prediction_order;
  2554. /** @deprecated use encoder private options instead */
  2555. attribute_deprecated
  2556. int64_t timecode_frame_start;
  2557. #endif
  2558. #if FF_API_RTP_CALLBACK
  2559. /**
  2560. * @deprecated unused
  2561. */
  2562. /* The RTP callback: This function is called */
  2563. /* every time the encoder has a packet to send. */
  2564. /* It depends on the encoder if the data starts */
  2565. /* with a Start Code (it should). H.263 does. */
  2566. /* mb_nb contains the number of macroblocks */
  2567. /* encoded in the RTP payload. */
  2568. attribute_deprecated
  2569. void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb);
  2570. #endif
  2571. #if FF_API_PRIVATE_OPT
  2572. /** @deprecated use encoder private options instead */
  2573. attribute_deprecated
  2574. int rtp_payload_size; /* The size of the RTP payload: the coder will */
  2575. /* do its best to deliver a chunk with size */
  2576. /* below rtp_payload_size, the chunk will start */
  2577. /* with a start code on some codecs like H.263. */
  2578. /* This doesn't take account of any particular */
  2579. /* headers inside the transmitted RTP payload. */
  2580. #endif
  2581. #if FF_API_STAT_BITS
  2582. /* statistics, used for 2-pass encoding */
  2583. attribute_deprecated
  2584. int mv_bits;
  2585. attribute_deprecated
  2586. int header_bits;
  2587. attribute_deprecated
  2588. int i_tex_bits;
  2589. attribute_deprecated
  2590. int p_tex_bits;
  2591. attribute_deprecated
  2592. int i_count;
  2593. attribute_deprecated
  2594. int p_count;
  2595. attribute_deprecated
  2596. int skip_count;
  2597. attribute_deprecated
  2598. int misc_bits;
  2599. /** @deprecated this field is unused */
  2600. attribute_deprecated
  2601. int frame_bits;
  2602. #endif
  2603. /**
  2604. * pass1 encoding statistics output buffer
  2605. * - encoding: Set by libavcodec.
  2606. * - decoding: unused
  2607. */
  2608. char *stats_out;
  2609. /**
  2610. * pass2 encoding statistics input buffer
  2611. * Concatenated stuff from stats_out of pass1 should be placed here.
  2612. * - encoding: Allocated/set/freed by user.
  2613. * - decoding: unused
  2614. */
  2615. char *stats_in;
  2616. /**
  2617. * Work around bugs in encoders which sometimes cannot be detected automatically.
  2618. * - encoding: Set by user
  2619. * - decoding: Set by user
  2620. */
  2621. int workaround_bugs;
  2622. #define FF_BUG_AUTODETECT 1 ///< autodetection
  2623. #define FF_BUG_XVID_ILACE 4
  2624. #define FF_BUG_UMP4 8
  2625. #define FF_BUG_NO_PADDING 16
  2626. #define FF_BUG_AMV 32
  2627. #define FF_BUG_QPEL_CHROMA 64
  2628. #define FF_BUG_STD_QPEL 128
  2629. #define FF_BUG_QPEL_CHROMA2 256
  2630. #define FF_BUG_DIRECT_BLOCKSIZE 512
  2631. #define FF_BUG_EDGE 1024
  2632. #define FF_BUG_HPEL_CHROMA 2048
  2633. #define FF_BUG_DC_CLIP 4096
  2634. #define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders.
  2635. #define FF_BUG_TRUNCATED 16384
  2636. #define FF_BUG_IEDGE 32768
  2637. /**
  2638. * strictly follow the standard (MPEG-4, ...).
  2639. * - encoding: Set by user.
  2640. * - decoding: Set by user.
  2641. * Setting this to STRICT or higher means the encoder and decoder will
  2642. * generally do stupid things, whereas setting it to unofficial or lower
  2643. * will mean the encoder might produce output that is not supported by all
  2644. * spec-compliant decoders. Decoders don't differentiate between normal,
  2645. * unofficial and experimental (that is, they always try to decode things
  2646. * when they can) unless they are explicitly asked to behave stupidly
  2647. * (=strictly conform to the specs)
  2648. */
  2649. int strict_std_compliance;
  2650. #define FF_COMPLIANCE_VERY_STRICT 2 ///< Strictly conform to an older more strict version of the spec or reference software.
  2651. #define FF_COMPLIANCE_STRICT 1 ///< Strictly conform to all the things in the spec no matter what consequences.
  2652. #define FF_COMPLIANCE_NORMAL 0
  2653. #define FF_COMPLIANCE_UNOFFICIAL -1 ///< Allow unofficial extensions
  2654. #define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things.
  2655. /**
  2656. * error concealment flags
  2657. * - encoding: unused
  2658. * - decoding: Set by user.
  2659. */
  2660. int error_concealment;
  2661. #define FF_EC_GUESS_MVS 1
  2662. #define FF_EC_DEBLOCK 2
  2663. #define FF_EC_FAVOR_INTER 256
  2664. /**
  2665. * debug
  2666. * - encoding: Set by user.
  2667. * - decoding: Set by user.
  2668. */
  2669. int debug;
  2670. #define FF_DEBUG_PICT_INFO 1
  2671. #define FF_DEBUG_RC 2
  2672. #define FF_DEBUG_BITSTREAM 4
  2673. #define FF_DEBUG_MB_TYPE 8
  2674. #define FF_DEBUG_QP 16
  2675. #if FF_API_DEBUG_MV
  2676. /**
  2677. * @deprecated this option does nothing
  2678. */
  2679. #define FF_DEBUG_MV 32
  2680. #endif
  2681. #define FF_DEBUG_DCT_COEFF 0x00000040
  2682. #define FF_DEBUG_SKIP 0x00000080
  2683. #define FF_DEBUG_STARTCODE 0x00000100
  2684. #if FF_API_UNUSED_MEMBERS
  2685. #define FF_DEBUG_PTS 0x00000200
  2686. #endif /* FF_API_UNUSED_MEMBERS */
  2687. #define FF_DEBUG_ER 0x00000400
  2688. #define FF_DEBUG_MMCO 0x00000800
  2689. #define FF_DEBUG_BUGS 0x00001000
  2690. #if FF_API_DEBUG_MV
  2691. #define FF_DEBUG_VIS_QP 0x00002000
  2692. #define FF_DEBUG_VIS_MB_TYPE 0x00004000
  2693. #endif
  2694. #define FF_DEBUG_BUFFERS 0x00008000
  2695. #define FF_DEBUG_THREADS 0x00010000
  2696. #define FF_DEBUG_GREEN_MD 0x00800000
  2697. #define FF_DEBUG_NOMC 0x01000000
  2698. #if FF_API_DEBUG_MV
  2699. /**
  2700. * debug
  2701. * - encoding: Set by user.
  2702. * - decoding: Set by user.
  2703. */
  2704. int debug_mv;
  2705. #define FF_DEBUG_VIS_MV_P_FOR 0x00000001 // visualize forward predicted MVs of P-frames
  2706. #define FF_DEBUG_VIS_MV_B_FOR 0x00000002 // visualize forward predicted MVs of B-frames
  2707. #define FF_DEBUG_VIS_MV_B_BACK 0x00000004 // visualize backward predicted MVs of B-frames
  2708. #endif
  2709. /**
  2710. * Error recognition; may misdetect some more or less valid parts as errors.
  2711. * - encoding: unused
  2712. * - decoding: Set by user.
  2713. */
  2714. int err_recognition;
  2715. /**
  2716. * Verify checksums embedded in the bitstream (could be of either encoded or
  2717. * decoded data, depending on the codec) and print an error message on mismatch.
  2718. * If AV_EF_EXPLODE is also set, a mismatching checksum will result in the
  2719. * decoder returning an error.
  2720. */
  2721. #define AV_EF_CRCCHECK (1<<0)
  2722. #define AV_EF_BITSTREAM (1<<1) ///< detect bitstream specification deviations
  2723. #define AV_EF_BUFFER (1<<2) ///< detect improper bitstream length
  2724. #define AV_EF_EXPLODE (1<<3) ///< abort decoding on minor error detection
  2725. #define AV_EF_IGNORE_ERR (1<<15) ///< ignore errors and continue
  2726. #define AV_EF_CAREFUL (1<<16) ///< consider things that violate the spec, are fast to calculate and have not been seen in the wild as errors
  2727. #define AV_EF_COMPLIANT (1<<17) ///< consider all spec non compliances as errors
  2728. #define AV_EF_AGGRESSIVE (1<<18) ///< consider things that a sane encoder should not do as an error
  2729. /**
  2730. * opaque 64-bit number (generally a PTS) that will be reordered and
  2731. * output in AVFrame.reordered_opaque
  2732. * - encoding: unused
  2733. * - decoding: Set by user.
  2734. */
  2735. int64_t reordered_opaque;
  2736. /**
  2737. * Hardware accelerator in use
  2738. * - encoding: unused.
  2739. * - decoding: Set by libavcodec
  2740. */
  2741. struct AVHWAccel *hwaccel;
  2742. /**
  2743. * Hardware accelerator context.
  2744. * For some hardware accelerators, a global context needs to be
  2745. * provided by the user. In that case, this holds display-dependent
  2746. * data FFmpeg cannot instantiate itself. Please refer to the
  2747. * FFmpeg HW accelerator documentation to know how to fill this
  2748. * is. e.g. for VA API, this is a struct vaapi_context.
  2749. * - encoding: unused
  2750. * - decoding: Set by user
  2751. */
  2752. void *hwaccel_context;
  2753. /**
  2754. * error
  2755. * - encoding: Set by libavcodec if flags & AV_CODEC_FLAG_PSNR.
  2756. * - decoding: unused
  2757. */
  2758. uint64_t error[AV_NUM_DATA_POINTERS];
  2759. /**
  2760. * DCT algorithm, see FF_DCT_* below
  2761. * - encoding: Set by user.
  2762. * - decoding: unused
  2763. */
  2764. int dct_algo;
  2765. #define FF_DCT_AUTO 0
  2766. #define FF_DCT_FASTINT 1
  2767. #define FF_DCT_INT 2
  2768. #define FF_DCT_MMX 3
  2769. #define FF_DCT_ALTIVEC 5
  2770. #define FF_DCT_FAAN 6
  2771. /**
  2772. * IDCT algorithm, see FF_IDCT_* below.
  2773. * - encoding: Set by user.
  2774. * - decoding: Set by user.
  2775. */
  2776. int idct_algo;
  2777. #define FF_IDCT_AUTO 0
  2778. #define FF_IDCT_INT 1
  2779. #define FF_IDCT_SIMPLE 2
  2780. #define FF_IDCT_SIMPLEMMX 3
  2781. #define FF_IDCT_ARM 7
  2782. #define FF_IDCT_ALTIVEC 8
  2783. #define FF_IDCT_SIMPLEARM 10
  2784. #if FF_API_UNUSED_MEMBERS
  2785. #define FF_IDCT_IPP 13
  2786. #endif /* FF_API_UNUSED_MEMBERS */
  2787. #define FF_IDCT_XVID 14
  2788. #define FF_IDCT_SIMPLEARMV5TE 16
  2789. #define FF_IDCT_SIMPLEARMV6 17
  2790. #define FF_IDCT_FAAN 20
  2791. #define FF_IDCT_SIMPLENEON 22
  2792. #define FF_IDCT_NONE 24 /* Used by XvMC to extract IDCT coefficients with FF_IDCT_PERM_NONE */
  2793. #define FF_IDCT_SIMPLEAUTO 128
  2794. /**
  2795. * bits per sample/pixel from the demuxer (needed for huffyuv).
  2796. * - encoding: Set by libavcodec.
  2797. * - decoding: Set by user.
  2798. */
  2799. int bits_per_coded_sample;
  2800. /**
  2801. * Bits per sample/pixel of internal libavcodec pixel/sample format.
  2802. * - encoding: set by user.
  2803. * - decoding: set by libavcodec.
  2804. */
  2805. int bits_per_raw_sample;
  2806. #if FF_API_LOWRES
  2807. /**
  2808. * low resolution decoding, 1-> 1/2 size, 2->1/4 size
  2809. * - encoding: unused
  2810. * - decoding: Set by user.
  2811. */
  2812. int lowres;
  2813. #endif
  2814. #if FF_API_CODED_FRAME
  2815. /**
  2816. * the picture in the bitstream
  2817. * - encoding: Set by libavcodec.
  2818. * - decoding: unused
  2819. *
  2820. * @deprecated use the quality factor packet side data instead
  2821. */
  2822. attribute_deprecated AVFrame *coded_frame;
  2823. #endif
  2824. /**
  2825. * thread count
  2826. * is used to decide how many independent tasks should be passed to execute()
  2827. * - encoding: Set by user.
  2828. * - decoding: Set by user.
  2829. */
  2830. int thread_count;
  2831. /**
  2832. * Which multithreading methods to use.
  2833. * Use of FF_THREAD_FRAME will increase decoding delay by one frame per thread,
  2834. * so clients which cannot provide future frames should not use it.
  2835. *
  2836. * - encoding: Set by user, otherwise the default is used.
  2837. * - decoding: Set by user, otherwise the default is used.
  2838. */
  2839. int thread_type;
  2840. #define FF_THREAD_FRAME 1 ///< Decode more than one frame at once
  2841. #define FF_THREAD_SLICE 2 ///< Decode more than one part of a single frame at once
  2842. /**
  2843. * Which multithreading methods are in use by the codec.
  2844. * - encoding: Set by libavcodec.
  2845. * - decoding: Set by libavcodec.
  2846. */
  2847. int active_thread_type;
  2848. /**
  2849. * Set by the client if its custom get_buffer() callback can be called
  2850. * synchronously from another thread, which allows faster multithreaded decoding.
  2851. * draw_horiz_band() will be called from other threads regardless of this setting.
  2852. * Ignored if the default get_buffer() is used.
  2853. * - encoding: Set by user.
  2854. * - decoding: Set by user.
  2855. */
  2856. int thread_safe_callbacks;
  2857. /**
  2858. * The codec may call this to execute several independent things.
  2859. * It will return only after finishing all tasks.
  2860. * The user may replace this with some multithreaded implementation,
  2861. * the default implementation will execute the parts serially.
  2862. * @param count the number of things to execute
  2863. * - encoding: Set by libavcodec, user can override.
  2864. * - decoding: Set by libavcodec, user can override.
  2865. */
  2866. int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size);
  2867. /**
  2868. * The codec may call this to execute several independent things.
  2869. * It will return only after finishing all tasks.
  2870. * The user may replace this with some multithreaded implementation,
  2871. * the default implementation will execute the parts serially.
  2872. * Also see avcodec_thread_init and e.g. the --enable-pthread configure option.
  2873. * @param c context passed also to func
  2874. * @param count the number of things to execute
  2875. * @param arg2 argument passed unchanged to func
  2876. * @param ret return values of executed functions, must have space for "count" values. May be NULL.
  2877. * @param func function that will be called count times, with jobnr from 0 to count-1.
  2878. * threadnr will be in the range 0 to c->thread_count-1 < MAX_THREADS and so that no
  2879. * two instances of func executing at the same time will have the same threadnr.
  2880. * @return always 0 currently, but code should handle a future improvement where when any call to func
  2881. * returns < 0 no further calls to func may be done and < 0 is returned.
  2882. * - encoding: Set by libavcodec, user can override.
  2883. * - decoding: Set by libavcodec, user can override.
  2884. */
  2885. int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count);
  2886. /**
  2887. * noise vs. sse weight for the nsse comparison function
  2888. * - encoding: Set by user.
  2889. * - decoding: unused
  2890. */
  2891. int nsse_weight;
  2892. /**
  2893. * profile
  2894. * - encoding: Set by user.
  2895. * - decoding: Set by libavcodec.
  2896. */
  2897. int profile;
  2898. #define FF_PROFILE_UNKNOWN -99
  2899. #define FF_PROFILE_RESERVED -100
  2900. #define FF_PROFILE_AAC_MAIN 0
  2901. #define FF_PROFILE_AAC_LOW 1
  2902. #define FF_PROFILE_AAC_SSR 2
  2903. #define FF_PROFILE_AAC_LTP 3
  2904. #define FF_PROFILE_AAC_HE 4
  2905. #define FF_PROFILE_AAC_HE_V2 28
  2906. #define FF_PROFILE_AAC_LD 22
  2907. #define FF_PROFILE_AAC_ELD 38
  2908. #define FF_PROFILE_MPEG2_AAC_LOW 128
  2909. #define FF_PROFILE_MPEG2_AAC_HE 131
  2910. #define FF_PROFILE_DNXHD 0
  2911. #define FF_PROFILE_DNXHR_LB 1
  2912. #define FF_PROFILE_DNXHR_SQ 2
  2913. #define FF_PROFILE_DNXHR_HQ 3
  2914. #define FF_PROFILE_DNXHR_HQX 4
  2915. #define FF_PROFILE_DNXHR_444 5
  2916. #define FF_PROFILE_DTS 20
  2917. #define FF_PROFILE_DTS_ES 30
  2918. #define FF_PROFILE_DTS_96_24 40
  2919. #define FF_PROFILE_DTS_HD_HRA 50
  2920. #define FF_PROFILE_DTS_HD_MA 60
  2921. #define FF_PROFILE_DTS_EXPRESS 70
  2922. #define FF_PROFILE_MPEG2_422 0
  2923. #define FF_PROFILE_MPEG2_HIGH 1
  2924. #define FF_PROFILE_MPEG2_SS 2
  2925. #define FF_PROFILE_MPEG2_SNR_SCALABLE 3
  2926. #define FF_PROFILE_MPEG2_MAIN 4
  2927. #define FF_PROFILE_MPEG2_SIMPLE 5
  2928. #define FF_PROFILE_H264_CONSTRAINED (1<<9) // 8+1; constraint_set1_flag
  2929. #define FF_PROFILE_H264_INTRA (1<<11) // 8+3; constraint_set3_flag
  2930. #define FF_PROFILE_H264_BASELINE 66
  2931. #define FF_PROFILE_H264_CONSTRAINED_BASELINE (66|FF_PROFILE_H264_CONSTRAINED)
  2932. #define FF_PROFILE_H264_MAIN 77
  2933. #define FF_PROFILE_H264_EXTENDED 88
  2934. #define FF_PROFILE_H264_HIGH 100
  2935. #define FF_PROFILE_H264_HIGH_10 110
  2936. #define FF_PROFILE_H264_HIGH_10_INTRA (110|FF_PROFILE_H264_INTRA)
  2937. #define FF_PROFILE_H264_MULTIVIEW_HIGH 118
  2938. #define FF_PROFILE_H264_HIGH_422 122
  2939. #define FF_PROFILE_H264_HIGH_422_INTRA (122|FF_PROFILE_H264_INTRA)
  2940. #define FF_PROFILE_H264_STEREO_HIGH 128
  2941. #define FF_PROFILE_H264_HIGH_444 144
  2942. #define FF_PROFILE_H264_HIGH_444_PREDICTIVE 244
  2943. #define FF_PROFILE_H264_HIGH_444_INTRA (244|FF_PROFILE_H264_INTRA)
  2944. #define FF_PROFILE_H264_CAVLC_444 44
  2945. #define FF_PROFILE_VC1_SIMPLE 0
  2946. #define FF_PROFILE_VC1_MAIN 1
  2947. #define FF_PROFILE_VC1_COMPLEX 2
  2948. #define FF_PROFILE_VC1_ADVANCED 3
  2949. #define FF_PROFILE_MPEG4_SIMPLE 0
  2950. #define FF_PROFILE_MPEG4_SIMPLE_SCALABLE 1
  2951. #define FF_PROFILE_MPEG4_CORE 2
  2952. #define FF_PROFILE_MPEG4_MAIN 3
  2953. #define FF_PROFILE_MPEG4_N_BIT 4
  2954. #define FF_PROFILE_MPEG4_SCALABLE_TEXTURE 5
  2955. #define FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION 6
  2956. #define FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE 7
  2957. #define FF_PROFILE_MPEG4_HYBRID 8
  2958. #define FF_PROFILE_MPEG4_ADVANCED_REAL_TIME 9
  2959. #define FF_PROFILE_MPEG4_CORE_SCALABLE 10
  2960. #define FF_PROFILE_MPEG4_ADVANCED_CODING 11
  2961. #define FF_PROFILE_MPEG4_ADVANCED_CORE 12
  2962. #define FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE 13
  2963. #define FF_PROFILE_MPEG4_SIMPLE_STUDIO 14
  2964. #define FF_PROFILE_MPEG4_ADVANCED_SIMPLE 15
  2965. #define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_0 1
  2966. #define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_1 2
  2967. #define FF_PROFILE_JPEG2000_CSTREAM_NO_RESTRICTION 32768
  2968. #define FF_PROFILE_JPEG2000_DCINEMA_2K 3
  2969. #define FF_PROFILE_JPEG2000_DCINEMA_4K 4
  2970. #define FF_PROFILE_VP9_0 0
  2971. #define FF_PROFILE_VP9_1 1
  2972. #define FF_PROFILE_VP9_2 2
  2973. #define FF_PROFILE_VP9_3 3
  2974. #define FF_PROFILE_HEVC_MAIN 1
  2975. #define FF_PROFILE_HEVC_MAIN_10 2
  2976. #define FF_PROFILE_HEVC_MAIN_STILL_PICTURE 3
  2977. #define FF_PROFILE_HEVC_REXT 4
  2978. /**
  2979. * level
  2980. * - encoding: Set by user.
  2981. * - decoding: Set by libavcodec.
  2982. */
  2983. int level;
  2984. #define FF_LEVEL_UNKNOWN -99
  2985. /**
  2986. * Skip loop filtering for selected frames.
  2987. * - encoding: unused
  2988. * - decoding: Set by user.
  2989. */
  2990. enum AVDiscard skip_loop_filter;
  2991. /**
  2992. * Skip IDCT/dequantization for selected frames.
  2993. * - encoding: unused
  2994. * - decoding: Set by user.
  2995. */
  2996. enum AVDiscard skip_idct;
  2997. /**
  2998. * Skip decoding for selected frames.
  2999. * - encoding: unused
  3000. * - decoding: Set by user.
  3001. */
  3002. enum AVDiscard skip_frame;
  3003. /**
  3004. * Header containing style information for text subtitles.
  3005. * For SUBTITLE_ASS subtitle type, it should contain the whole ASS
  3006. * [Script Info] and [V4+ Styles] section, plus the [Events] line and
  3007. * the Format line following. It shouldn't include any Dialogue line.
  3008. * - encoding: Set/allocated/freed by user (before avcodec_open2())
  3009. * - decoding: Set/allocated/freed by libavcodec (by avcodec_open2())
  3010. */
  3011. uint8_t *subtitle_header;
  3012. int subtitle_header_size;
  3013. #if FF_API_VBV_DELAY
  3014. /**
  3015. * VBV delay coded in the last frame (in periods of a 27 MHz clock).
  3016. * Used for compliant TS muxing.
  3017. * - encoding: Set by libavcodec.
  3018. * - decoding: unused.
  3019. * @deprecated this value is now exported as a part of
  3020. * AV_PKT_DATA_CPB_PROPERTIES packet side data
  3021. */
  3022. attribute_deprecated
  3023. uint64_t vbv_delay;
  3024. #endif
  3025. #if FF_API_SIDEDATA_ONLY_PKT
  3026. /**
  3027. * Encoding only and set by default. Allow encoders to output packets
  3028. * that do not contain any encoded data, only side data.
  3029. *
  3030. * Some encoders need to output such packets, e.g. to update some stream
  3031. * parameters at the end of encoding.
  3032. *
  3033. * @deprecated this field disables the default behaviour and
  3034. * it is kept only for compatibility.
  3035. */
  3036. attribute_deprecated
  3037. int side_data_only_packets;
  3038. #endif
  3039. /**
  3040. * Audio only. The number of "priming" samples (padding) inserted by the
  3041. * encoder at the beginning of the audio. I.e. this number of leading
  3042. * decoded samples must be discarded by the caller to get the original audio
  3043. * without leading padding.
  3044. *
  3045. * - decoding: unused
  3046. * - encoding: Set by libavcodec. The timestamps on the output packets are
  3047. * adjusted by the encoder so that they always refer to the
  3048. * first sample of the data actually contained in the packet,
  3049. * including any added padding. E.g. if the timebase is
  3050. * 1/samplerate and the timestamp of the first input sample is
  3051. * 0, the timestamp of the first output packet will be
  3052. * -initial_padding.
  3053. */
  3054. int initial_padding;
  3055. /**
  3056. * - decoding: For codecs that store a framerate value in the compressed
  3057. * bitstream, the decoder may export it here. { 0, 1} when
  3058. * unknown.
  3059. * - encoding: May be used to signal the framerate of CFR content to an
  3060. * encoder.
  3061. */
  3062. AVRational framerate;
  3063. /**
  3064. * Nominal unaccelerated pixel format, see AV_PIX_FMT_xxx.
  3065. * - encoding: unused.
  3066. * - decoding: Set by libavcodec before calling get_format()
  3067. */
  3068. enum AVPixelFormat sw_pix_fmt;
  3069. /**
  3070. * Timebase in which pkt_dts/pts and AVPacket.dts/pts are.
  3071. * - encoding unused.
  3072. * - decoding set by user.
  3073. */
  3074. AVRational pkt_timebase;
  3075. /**
  3076. * AVCodecDescriptor
  3077. * - encoding: unused.
  3078. * - decoding: set by libavcodec.
  3079. */
  3080. const AVCodecDescriptor *codec_descriptor;
  3081. #if !FF_API_LOWRES
  3082. /**
  3083. * low resolution decoding, 1-> 1/2 size, 2->1/4 size
  3084. * - encoding: unused
  3085. * - decoding: Set by user.
  3086. */
  3087. int lowres;
  3088. #endif
  3089. /**
  3090. * Current statistics for PTS correction.
  3091. * - decoding: maintained and used by libavcodec, not intended to be used by user apps
  3092. * - encoding: unused
  3093. */
  3094. int64_t pts_correction_num_faulty_pts; /// Number of incorrect PTS values so far
  3095. int64_t pts_correction_num_faulty_dts; /// Number of incorrect DTS values so far
  3096. int64_t pts_correction_last_pts; /// PTS of the last frame
  3097. int64_t pts_correction_last_dts; /// DTS of the last frame
  3098. /**
  3099. * Character encoding of the input subtitles file.
  3100. * - decoding: set by user
  3101. * - encoding: unused
  3102. */
  3103. char *sub_charenc;
  3104. /**
  3105. * Subtitles character encoding mode. Formats or codecs might be adjusting
  3106. * this setting (if they are doing the conversion themselves for instance).
  3107. * - decoding: set by libavcodec
  3108. * - encoding: unused
  3109. */
  3110. int sub_charenc_mode;
  3111. #define FF_SUB_CHARENC_MODE_DO_NOTHING -1 ///< do nothing (demuxer outputs a stream supposed to be already in UTF-8, or the codec is bitmap for instance)
  3112. #define FF_SUB_CHARENC_MODE_AUTOMATIC 0 ///< libavcodec will select the mode itself
  3113. #define FF_SUB_CHARENC_MODE_PRE_DECODER 1 ///< the AVPacket data needs to be recoded to UTF-8 before being fed to the decoder, requires iconv
  3114. /**
  3115. * Skip processing alpha if supported by codec.
  3116. * Note that if the format uses pre-multiplied alpha (common with VP6,
  3117. * and recommended due to better video quality/compression)
  3118. * the image will look as if alpha-blended onto a black background.
  3119. * However for formats that do not use pre-multiplied alpha
  3120. * there might be serious artefacts (though e.g. libswscale currently
  3121. * assumes pre-multiplied alpha anyway).
  3122. *
  3123. * - decoding: set by user
  3124. * - encoding: unused
  3125. */
  3126. int skip_alpha;
  3127. /**
  3128. * Number of samples to skip after a discontinuity
  3129. * - decoding: unused
  3130. * - encoding: set by libavcodec
  3131. */
  3132. int seek_preroll;
  3133. #if !FF_API_DEBUG_MV
  3134. /**
  3135. * debug motion vectors
  3136. * - encoding: Set by user.
  3137. * - decoding: Set by user.
  3138. */
  3139. int debug_mv;
  3140. #define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames
  3141. #define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames
  3142. #define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames
  3143. #endif
  3144. /**
  3145. * custom intra quantization matrix
  3146. * - encoding: Set by user, can be NULL.
  3147. * - decoding: unused.
  3148. */
  3149. uint16_t *chroma_intra_matrix;
  3150. /**
  3151. * dump format separator.
  3152. * can be ", " or "\n " or anything else
  3153. * - encoding: Set by user.
  3154. * - decoding: Set by user.
  3155. */
  3156. uint8_t *dump_separator;
  3157. /**
  3158. * ',' separated list of allowed decoders.
  3159. * If NULL then all are allowed
  3160. * - encoding: unused
  3161. * - decoding: set by user
  3162. */
  3163. char *codec_whitelist;
  3164. /**
  3165. * Properties of the stream that gets decoded
  3166. * - encoding: unused
  3167. * - decoding: set by libavcodec
  3168. */
  3169. unsigned properties;
  3170. #define FF_CODEC_PROPERTY_LOSSLESS 0x00000001
  3171. #define FF_CODEC_PROPERTY_CLOSED_CAPTIONS 0x00000002
  3172. /**
  3173. * Additional data associated with the entire coded stream.
  3174. *
  3175. * - decoding: unused
  3176. * - encoding: may be set by libavcodec after avcodec_open2().
  3177. */
  3178. AVPacketSideData *coded_side_data;
  3179. int nb_coded_side_data;
  3180. /**
  3181. * A reference to the AVHWFramesContext describing the input (for encoding)
  3182. * or output (decoding) frames. The reference is set by the caller and
  3183. * afterwards owned (and freed) by libavcodec - it should never be read by
  3184. * the caller after being set.
  3185. *
  3186. * - decoding: This field should be set by the caller from the get_format()
  3187. * callback. The previous reference (if any) will always be
  3188. * unreffed by libavcodec before the get_format() call.
  3189. *
  3190. * If the default get_buffer2() is used with a hwaccel pixel
  3191. * format, then this AVHWFramesContext will be used for
  3192. * allocating the frame buffers.
  3193. *
  3194. * - encoding: For hardware encoders configured to use a hwaccel pixel
  3195. * format, this field should be set by the caller to a reference
  3196. * to the AVHWFramesContext describing input frames.
  3197. * AVHWFramesContext.format must be equal to
  3198. * AVCodecContext.pix_fmt.
  3199. *
  3200. * This field should be set before avcodec_open2() is called.
  3201. */
  3202. AVBufferRef *hw_frames_ctx;
  3203. /**
  3204. * Control the form of AVSubtitle.rects[N]->ass
  3205. * - decoding: set by user
  3206. * - encoding: unused
  3207. */
  3208. int sub_text_format;
  3209. #define FF_SUB_TEXT_FMT_ASS 0
  3210. #if FF_API_ASS_TIMING
  3211. #define FF_SUB_TEXT_FMT_ASS_WITH_TIMINGS 1
  3212. #endif
  3213. /**
  3214. * Audio only. The amount of padding (in samples) appended by the encoder to
  3215. * the end of the audio. I.e. this number of decoded samples must be
  3216. * discarded by the caller from the end of the stream to get the original
  3217. * audio without any trailing padding.
  3218. *
  3219. * - decoding: unused
  3220. * - encoding: unused
  3221. */
  3222. int trailing_padding;
  3223. /**
  3224. * The number of pixels per image to maximally accept.
  3225. *
  3226. * - decoding: set by user
  3227. * - encoding: set by user
  3228. */
  3229. int64_t max_pixels;
  3230. /**
  3231. * A reference to the AVHWDeviceContext describing the device which will
  3232. * be used by a hardware encoder/decoder. The reference is set by the
  3233. * caller and afterwards owned (and freed) by libavcodec.
  3234. *
  3235. * This should be used if either the codec device does not require
  3236. * hardware frames or any that are used are to be allocated internally by
  3237. * libavcodec. If the user wishes to supply any of the frames used as
  3238. * encoder input or decoder output then hw_frames_ctx should be used
  3239. * instead. When hw_frames_ctx is set in get_format() for a decoder, this
  3240. * field will be ignored while decoding the associated stream segment, but
  3241. * may again be used on a following one after another get_format() call.
  3242. *
  3243. * For both encoders and decoders this field should be set before
  3244. * avcodec_open2() is called and must not be written to thereafter.
  3245. *
  3246. * Note that some decoders may require this field to be set initially in
  3247. * order to support hw_frames_ctx at all - in that case, all frames
  3248. * contexts used must be created on the same device.
  3249. */
  3250. AVBufferRef *hw_device_ctx;
  3251. /**
  3252. * Bit set of AV_HWACCEL_FLAG_* flags, which affect hardware accelerated
  3253. * decoding (if active).
  3254. * - encoding: unused
  3255. * - decoding: Set by user (either before avcodec_open2(), or in the
  3256. * AVCodecContext.get_format callback)
  3257. */
  3258. int hwaccel_flags;
  3259. /**
  3260. * Video decoding only. Certain video codecs support cropping, meaning that
  3261. * only a sub-rectangle of the decoded frame is intended for display. This
  3262. * option controls how cropping is handled by libavcodec.
  3263. *
  3264. * When set to 1 (the default), libavcodec will apply cropping internally.
  3265. * I.e. it will modify the output frame width/height fields and offset the
  3266. * data pointers (only by as much as possible while preserving alignment, or
  3267. * by the full amount if the AV_CODEC_FLAG_UNALIGNED flag is set) so that
  3268. * the frames output by the decoder refer only to the cropped area. The
  3269. * crop_* fields of the output frames will be zero.
  3270. *
  3271. * When set to 0, the width/height fields of the output frames will be set
  3272. * to the coded dimensions and the crop_* fields will describe the cropping
  3273. * rectangle. Applying the cropping is left to the caller.
  3274. *
  3275. * @warning When hardware acceleration with opaque output frames is used,
  3276. * libavcodec is unable to apply cropping from the top/left border.
  3277. *
  3278. * @note when this option is set to zero, the width/height fields of the
  3279. * AVCodecContext and output AVFrames have different meanings. The codec
  3280. * context fields store display dimensions (with the coded dimensions in
  3281. * coded_width/height), while the frame fields store the coded dimensions
  3282. * (with the display dimensions being determined by the crop_* fields).
  3283. */
  3284. int apply_cropping;
  3285. } AVCodecContext;
  3286. AVRational av_codec_get_pkt_timebase (const AVCodecContext *avctx);
  3287. void av_codec_set_pkt_timebase (AVCodecContext *avctx, AVRational val);
  3288. const AVCodecDescriptor *av_codec_get_codec_descriptor(const AVCodecContext *avctx);
  3289. void av_codec_set_codec_descriptor(AVCodecContext *avctx, const AVCodecDescriptor *desc);
  3290. unsigned av_codec_get_codec_properties(const AVCodecContext *avctx);
  3291. int av_codec_get_lowres(const AVCodecContext *avctx);
  3292. void av_codec_set_lowres(AVCodecContext *avctx, int val);
  3293. int av_codec_get_seek_preroll(const AVCodecContext *avctx);
  3294. void av_codec_set_seek_preroll(AVCodecContext *avctx, int val);
  3295. uint16_t *av_codec_get_chroma_intra_matrix(const AVCodecContext *avctx);
  3296. void av_codec_set_chroma_intra_matrix(AVCodecContext *avctx, uint16_t *val);
  3297. /**
  3298. * AVProfile.
  3299. */
  3300. typedef struct AVProfile {
  3301. int profile;
  3302. const char *name; ///< short name for the profile
  3303. } AVProfile;
  3304. typedef struct AVCodecDefault AVCodecDefault;
  3305. struct AVSubtitle;
  3306. /**
  3307. * AVCodec.
  3308. */
  3309. typedef struct AVCodec {
  3310. /**
  3311. * Name of the codec implementation.
  3312. * The name is globally unique among encoders and among decoders (but an
  3313. * encoder and a decoder can share the same name).
  3314. * This is the primary way to find a codec from the user perspective.
  3315. */
  3316. const char *name;
  3317. /**
  3318. * Descriptive name for the codec, meant to be more human readable than name.
  3319. * You should use the NULL_IF_CONFIG_SMALL() macro to define it.
  3320. */
  3321. const char *long_name;
  3322. enum AVMediaType type;
  3323. enum AVCodecID id;
  3324. /**
  3325. * Codec capabilities.
  3326. * see AV_CODEC_CAP_*
  3327. */
  3328. int capabilities;
  3329. const AVRational *supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0}
  3330. const enum AVPixelFormat *pix_fmts; ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1
  3331. const int *supported_samplerates; ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0
  3332. const enum AVSampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1
  3333. const uint64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0
  3334. uint8_t max_lowres; ///< maximum value for lowres supported by the decoder
  3335. const AVClass *priv_class; ///< AVClass for the private context
  3336. const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}
  3337. /*****************************************************************
  3338. * No fields below this line are part of the public API. They
  3339. * may not be used outside of libavcodec and can be changed and
  3340. * removed at will.
  3341. * New public fields should be added right above.
  3342. *****************************************************************
  3343. */
  3344. int priv_data_size;
  3345. struct AVCodec *next;
  3346. /**
  3347. * @name Frame-level threading support functions
  3348. * @{
  3349. */
  3350. /**
  3351. * If defined, called on thread contexts when they are created.
  3352. * If the codec allocates writable tables in init(), re-allocate them here.
  3353. * priv_data will be set to a copy of the original.
  3354. */
  3355. int (*init_thread_copy)(AVCodecContext *);
  3356. /**
  3357. * Copy necessary context variables from a previous thread context to the current one.
  3358. * If not defined, the next thread will start automatically; otherwise, the codec
  3359. * must call ff_thread_finish_setup().
  3360. *
  3361. * dst and src will (rarely) point to the same context, in which case memcpy should be skipped.
  3362. */
  3363. int (*update_thread_context)(AVCodecContext *dst, const AVCodecContext *src);
  3364. /** @} */
  3365. /**
  3366. * Private codec-specific defaults.
  3367. */
  3368. const AVCodecDefault *defaults;
  3369. /**
  3370. * Initialize codec static data, called from avcodec_register().
  3371. */
  3372. void (*init_static_data)(struct AVCodec *codec);
  3373. int (*init)(AVCodecContext *);
  3374. int (*encode_sub)(AVCodecContext *, uint8_t *buf, int buf_size,
  3375. const struct AVSubtitle *sub);
  3376. /**
  3377. * Encode data to an AVPacket.
  3378. *
  3379. * @param avctx codec context
  3380. * @param avpkt output AVPacket (may contain a user-provided buffer)
  3381. * @param[in] frame AVFrame containing the raw data to be encoded
  3382. * @param[out] got_packet_ptr encoder sets to 0 or 1 to indicate that a
  3383. * non-empty packet was returned in avpkt.
  3384. * @return 0 on success, negative error code on failure
  3385. */
  3386. int (*encode2)(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame,
  3387. int *got_packet_ptr);
  3388. int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt);
  3389. int (*close)(AVCodecContext *);
  3390. /**
  3391. * Encode API with decoupled packet/frame dataflow. The API is the
  3392. * same as the avcodec_ prefixed APIs (avcodec_send_frame() etc.), except
  3393. * that:
  3394. * - never called if the codec is closed or the wrong type,
  3395. * - if AV_CODEC_CAP_DELAY is not set, drain frames are never sent,
  3396. * - only one drain frame is ever passed down,
  3397. */
  3398. int (*send_frame)(AVCodecContext *avctx, const AVFrame *frame);
  3399. int (*receive_packet)(AVCodecContext *avctx, AVPacket *avpkt);
  3400. /**
  3401. * Decode API with decoupled packet/frame dataflow. This function is called
  3402. * to get one output frame. It should call ff_decode_get_packet() to obtain
  3403. * input data.
  3404. */
  3405. int (*receive_frame)(AVCodecContext *avctx, AVFrame *frame);
  3406. /**
  3407. * Flush buffers.
  3408. * Will be called when seeking
  3409. */
  3410. void (*flush)(AVCodecContext *);
  3411. /**
  3412. * Internal codec capabilities.
  3413. * See FF_CODEC_CAP_* in internal.h
  3414. */
  3415. int caps_internal;
  3416. /**
  3417. * Decoding only, a comma-separated list of bitstream filters to apply to
  3418. * packets before decoding.
  3419. */
  3420. const char *bsfs;
  3421. } AVCodec;
  3422. int av_codec_get_max_lowres(const AVCodec *codec);
  3423. struct MpegEncContext;
  3424. /**
  3425. * @defgroup lavc_hwaccel AVHWAccel
  3426. * @{
  3427. */
  3428. typedef struct AVHWAccel {
  3429. /**
  3430. * Name of the hardware accelerated codec.
  3431. * The name is globally unique among encoders and among decoders (but an
  3432. * encoder and a decoder can share the same name).
  3433. */
  3434. const char *name;
  3435. /**
  3436. * Type of codec implemented by the hardware accelerator.
  3437. *
  3438. * See AVMEDIA_TYPE_xxx
  3439. */
  3440. enum AVMediaType type;
  3441. /**
  3442. * Codec implemented by the hardware accelerator.
  3443. *
  3444. * See AV_CODEC_ID_xxx
  3445. */
  3446. enum AVCodecID id;
  3447. /**
  3448. * Supported pixel format.
  3449. *
  3450. * Only hardware accelerated formats are supported here.
  3451. */
  3452. enum AVPixelFormat pix_fmt;
  3453. /**
  3454. * Hardware accelerated codec capabilities.
  3455. * see AV_HWACCEL_CODEC_CAP_*
  3456. */
  3457. int capabilities;
  3458. /*****************************************************************
  3459. * No fields below this line are part of the public API. They
  3460. * may not be used outside of libavcodec and can be changed and
  3461. * removed at will.
  3462. * New public fields should be added right above.
  3463. *****************************************************************
  3464. */
  3465. struct AVHWAccel *next;
  3466. /**
  3467. * Allocate a custom buffer
  3468. */
  3469. int (*alloc_frame)(AVCodecContext *avctx, AVFrame *frame);
  3470. /**
  3471. * Called at the beginning of each frame or field picture.
  3472. *
  3473. * Meaningful frame information (codec specific) is guaranteed to
  3474. * be parsed at this point. This function is mandatory.
  3475. *
  3476. * Note that buf can be NULL along with buf_size set to 0.
  3477. * Otherwise, this means the whole frame is available at this point.
  3478. *
  3479. * @param avctx the codec context
  3480. * @param buf the frame data buffer base
  3481. * @param buf_size the size of the frame in bytes
  3482. * @return zero if successful, a negative value otherwise
  3483. */
  3484. int (*start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
  3485. /**
  3486. * Callback for each slice.
  3487. *
  3488. * Meaningful slice information (codec specific) is guaranteed to
  3489. * be parsed at this point. This function is mandatory.
  3490. * The only exception is XvMC, that works on MB level.
  3491. *
  3492. * @param avctx the codec context
  3493. * @param buf the slice data buffer base
  3494. * @param buf_size the size of the slice in bytes
  3495. * @return zero if successful, a negative value otherwise
  3496. */
  3497. int (*decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
  3498. /**
  3499. * Called at the end of each frame or field picture.
  3500. *
  3501. * The whole picture is parsed at this point and can now be sent
  3502. * to the hardware accelerator. This function is mandatory.
  3503. *
  3504. * @param avctx the codec context
  3505. * @return zero if successful, a negative value otherwise
  3506. */
  3507. int (*end_frame)(AVCodecContext *avctx);
  3508. /**
  3509. * Size of per-frame hardware accelerator private data.
  3510. *
  3511. * Private data is allocated with av_mallocz() before
  3512. * AVCodecContext.get_buffer() and deallocated after
  3513. * AVCodecContext.release_buffer().
  3514. */
  3515. int frame_priv_data_size;
  3516. /**
  3517. * Called for every Macroblock in a slice.
  3518. *
  3519. * XvMC uses it to replace the ff_mpv_reconstruct_mb().
  3520. * Instead of decoding to raw picture, MB parameters are
  3521. * stored in an array provided by the video driver.
  3522. *
  3523. * @param s the mpeg context
  3524. */
  3525. void (*decode_mb)(struct MpegEncContext *s);
  3526. /**
  3527. * Initialize the hwaccel private data.
  3528. *
  3529. * This will be called from ff_get_format(), after hwaccel and
  3530. * hwaccel_context are set and the hwaccel private data in AVCodecInternal
  3531. * is allocated.
  3532. */
  3533. int (*init)(AVCodecContext *avctx);
  3534. /**
  3535. * Uninitialize the hwaccel private data.
  3536. *
  3537. * This will be called from get_format() or avcodec_close(), after hwaccel
  3538. * and hwaccel_context are already uninitialized.
  3539. */
  3540. int (*uninit)(AVCodecContext *avctx);
  3541. /**
  3542. * Size of the private data to allocate in
  3543. * AVCodecInternal.hwaccel_priv_data.
  3544. */
  3545. int priv_data_size;
  3546. /**
  3547. * Internal hwaccel capabilities.
  3548. */
  3549. int caps_internal;
  3550. } AVHWAccel;
  3551. /**
  3552. * HWAccel is experimental and is thus avoided in favor of non experimental
  3553. * codecs
  3554. */
  3555. #define AV_HWACCEL_CODEC_CAP_EXPERIMENTAL 0x0200
  3556. /**
  3557. * Hardware acceleration should be used for decoding even if the codec level
  3558. * used is unknown or higher than the maximum supported level reported by the
  3559. * hardware driver.
  3560. *
  3561. * It's generally a good idea to pass this flag unless you have a specific
  3562. * reason not to, as hardware tends to under-report supported levels.
  3563. */
  3564. #define AV_HWACCEL_FLAG_IGNORE_LEVEL (1 << 0)
  3565. /**
  3566. * Hardware acceleration can output YUV pixel formats with a different chroma
  3567. * sampling than 4:2:0 and/or other than 8 bits per component.
  3568. */
  3569. #define AV_HWACCEL_FLAG_ALLOW_HIGH_DEPTH (1 << 1)
  3570. /**
  3571. * Hardware acceleration should still be attempted for decoding when the
  3572. * codec profile does not match the reported capabilities of the hardware.
  3573. *
  3574. * For example, this can be used to try to decode baseline profile H.264
  3575. * streams in hardware - it will often succeed, because many streams marked
  3576. * as baseline profile actually conform to constrained baseline profile.
  3577. *
  3578. * @warning If the stream is actually not supported then the behaviour is
  3579. * undefined, and may include returning entirely incorrect output
  3580. * while indicating success.
  3581. */
  3582. #define AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH (1 << 2)
  3583. /**
  3584. * @}
  3585. */
  3586. #if FF_API_AVPICTURE
  3587. /**
  3588. * @defgroup lavc_picture AVPicture
  3589. *
  3590. * Functions for working with AVPicture
  3591. * @{
  3592. */
  3593. /**
  3594. * Picture data structure.
  3595. *
  3596. * Up to four components can be stored into it, the last component is
  3597. * alpha.
  3598. * @deprecated use AVFrame or imgutils functions instead
  3599. */
  3600. typedef struct AVPicture {
  3601. attribute_deprecated
  3602. uint8_t *data[AV_NUM_DATA_POINTERS]; ///< pointers to the image data planes
  3603. attribute_deprecated
  3604. int linesize[AV_NUM_DATA_POINTERS]; ///< number of bytes per line
  3605. } AVPicture;
  3606. /**
  3607. * @}
  3608. */
  3609. #endif
  3610. enum AVSubtitleType {
  3611. SUBTITLE_NONE,
  3612. SUBTITLE_BITMAP, ///< A bitmap, pict will be set
  3613. /**
  3614. * Plain text, the text field must be set by the decoder and is
  3615. * authoritative. ass and pict fields may contain approximations.
  3616. */
  3617. SUBTITLE_TEXT,
  3618. /**
  3619. * Formatted text, the ass field must be set by the decoder and is
  3620. * authoritative. pict and text fields may contain approximations.
  3621. */
  3622. SUBTITLE_ASS,
  3623. };
  3624. #define AV_SUBTITLE_FLAG_FORCED 0x00000001
  3625. typedef struct AVSubtitleRect {
  3626. int x; ///< top left corner of pict, undefined when pict is not set
  3627. int y; ///< top left corner of pict, undefined when pict is not set
  3628. int w; ///< width of pict, undefined when pict is not set
  3629. int h; ///< height of pict, undefined when pict is not set
  3630. int nb_colors; ///< number of colors in pict, undefined when pict is not set
  3631. #if FF_API_AVPICTURE
  3632. /**
  3633. * @deprecated unused
  3634. */
  3635. attribute_deprecated
  3636. AVPicture pict;
  3637. #endif
  3638. /**
  3639. * data+linesize for the bitmap of this subtitle.
  3640. * Can be set for text/ass as well once they are rendered.
  3641. */
  3642. uint8_t *data[4];
  3643. int linesize[4];
  3644. enum AVSubtitleType type;
  3645. char *text; ///< 0 terminated plain UTF-8 text
  3646. /**
  3647. * 0 terminated ASS/SSA compatible event line.
  3648. * The presentation of this is unaffected by the other values in this
  3649. * struct.
  3650. */
  3651. char *ass;
  3652. int flags;
  3653. } AVSubtitleRect;
  3654. typedef struct AVSubtitle {
  3655. uint16_t format; /* 0 = graphics */
  3656. uint32_t start_display_time; /* relative to packet pts, in ms */
  3657. uint32_t end_display_time; /* relative to packet pts, in ms */
  3658. unsigned num_rects;
  3659. AVSubtitleRect **rects;
  3660. int64_t pts; ///< Same as packet pts, in AV_TIME_BASE
  3661. } AVSubtitle;
  3662. /**
  3663. * This struct describes the properties of an encoded stream.
  3664. *
  3665. * sizeof(AVCodecParameters) is not a part of the public ABI, this struct must
  3666. * be allocated with avcodec_parameters_alloc() and freed with
  3667. * avcodec_parameters_free().
  3668. */
  3669. typedef struct AVCodecParameters {
  3670. /**
  3671. * General type of the encoded data.
  3672. */
  3673. enum AVMediaType codec_type;
  3674. /**
  3675. * Specific type of the encoded data (the codec used).
  3676. */
  3677. enum AVCodecID codec_id;
  3678. /**
  3679. * Additional information about the codec (corresponds to the AVI FOURCC).
  3680. */
  3681. uint32_t codec_tag;
  3682. /**
  3683. * Extra binary data needed for initializing the decoder, codec-dependent.
  3684. *
  3685. * Must be allocated with av_malloc() and will be freed by
  3686. * avcodec_parameters_free(). The allocated size of extradata must be at
  3687. * least extradata_size + AV_INPUT_BUFFER_PADDING_SIZE, with the padding
  3688. * bytes zeroed.
  3689. */
  3690. uint8_t *extradata;
  3691. /**
  3692. * Size of the extradata content in bytes.
  3693. */
  3694. int extradata_size;
  3695. /**
  3696. * - video: the pixel format, the value corresponds to enum AVPixelFormat.
  3697. * - audio: the sample format, the value corresponds to enum AVSampleFormat.
  3698. */
  3699. int format;
  3700. /**
  3701. * The average bitrate of the encoded data (in bits per second).
  3702. */
  3703. int64_t bit_rate;
  3704. /**
  3705. * The number of bits per sample in the codedwords.
  3706. *
  3707. * This is basically the bitrate per sample. It is mandatory for a bunch of
  3708. * formats to actually decode them. It's the number of bits for one sample in
  3709. * the actual coded bitstream.
  3710. *
  3711. * This could be for example 4 for ADPCM
  3712. * For PCM formats this matches bits_per_raw_sample
  3713. * Can be 0
  3714. */
  3715. int bits_per_coded_sample;
  3716. /**
  3717. * This is the number of valid bits in each output sample. If the
  3718. * sample format has more bits, the least significant bits are additional
  3719. * padding bits, which are always 0. Use right shifts to reduce the sample
  3720. * to its actual size. For example, audio formats with 24 bit samples will
  3721. * have bits_per_raw_sample set to 24, and format set to AV_SAMPLE_FMT_S32.
  3722. * To get the original sample use "(int32_t)sample >> 8"."
  3723. *
  3724. * For ADPCM this might be 12 or 16 or similar
  3725. * Can be 0
  3726. */
  3727. int bits_per_raw_sample;
  3728. /**
  3729. * Codec-specific bitstream restrictions that the stream conforms to.
  3730. */
  3731. int profile;
  3732. int level;
  3733. /**
  3734. * Video only. The dimensions of the video frame in pixels.
  3735. */
  3736. int width;
  3737. int height;
  3738. /**
  3739. * Video only. The aspect ratio (width / height) which a single pixel
  3740. * should have when displayed.
  3741. *
  3742. * When the aspect ratio is unknown / undefined, the numerator should be
  3743. * set to 0 (the denominator may have any value).
  3744. */
  3745. AVRational sample_aspect_ratio;
  3746. /**
  3747. * Video only. The order of the fields in interlaced video.
  3748. */
  3749. enum AVFieldOrder field_order;
  3750. /**
  3751. * Video only. Additional colorspace characteristics.
  3752. */
  3753. enum AVColorRange color_range;
  3754. enum AVColorPrimaries color_primaries;
  3755. enum AVColorTransferCharacteristic color_trc;
  3756. enum AVColorSpace color_space;
  3757. enum AVChromaLocation chroma_location;
  3758. /**
  3759. * Video only. Number of delayed frames.
  3760. */
  3761. int video_delay;
  3762. /**
  3763. * Audio only. The channel layout bitmask. May be 0 if the channel layout is
  3764. * unknown or unspecified, otherwise the number of bits set must be equal to
  3765. * the channels field.
  3766. */
  3767. uint64_t channel_layout;
  3768. /**
  3769. * Audio only. The number of audio channels.
  3770. */
  3771. int channels;
  3772. /**
  3773. * Audio only. The number of audio samples per second.
  3774. */
  3775. int sample_rate;
  3776. /**
  3777. * Audio only. The number of bytes per coded audio frame, required by some
  3778. * formats.
  3779. *
  3780. * Corresponds to nBlockAlign in WAVEFORMATEX.
  3781. */
  3782. int block_align;
  3783. /**
  3784. * Audio only. Audio frame size, if known. Required by some formats to be static.
  3785. */
  3786. int frame_size;
  3787. /**
  3788. * Audio only. The amount of padding (in samples) inserted by the encoder at
  3789. * the beginning of the audio. I.e. this number of leading decoded samples
  3790. * must be discarded by the caller to get the original audio without leading
  3791. * padding.
  3792. */
  3793. int initial_padding;
  3794. /**
  3795. * Audio only. The amount of padding (in samples) appended by the encoder to
  3796. * the end of the audio. I.e. this number of decoded samples must be
  3797. * discarded by the caller from the end of the stream to get the original
  3798. * audio without any trailing padding.
  3799. */
  3800. int trailing_padding;
  3801. /**
  3802. * Audio only. Number of samples to skip after a discontinuity.
  3803. */
  3804. int seek_preroll;
  3805. } AVCodecParameters;
  3806. /**
  3807. * If c is NULL, returns the first registered codec,
  3808. * if c is non-NULL, returns the next registered codec after c,
  3809. * or NULL if c is the last one.
  3810. */
  3811. AVCodec *av_codec_next(const AVCodec *c);
  3812. /**
  3813. * Return the LIBAVCODEC_VERSION_INT constant.
  3814. */
  3815. unsigned avcodec_version(void);
  3816. /**
  3817. * Return the libavcodec build-time configuration.
  3818. */
  3819. const char *avcodec_configuration(void);
  3820. /**
  3821. * Return the libavcodec license.
  3822. */
  3823. const char *avcodec_license(void);
  3824. /**
  3825. * Register the codec codec and initialize libavcodec.
  3826. *
  3827. * @warning either this function or avcodec_register_all() must be called
  3828. * before any other libavcodec functions.
  3829. *
  3830. * @see avcodec_register_all()
  3831. */
  3832. void avcodec_register(AVCodec *codec);
  3833. /**
  3834. * Register all the codecs, parsers and bitstream filters which were enabled at
  3835. * configuration time. If you do not call this function you can select exactly
  3836. * which formats you want to support, by using the individual registration
  3837. * functions.
  3838. *
  3839. * @see avcodec_register
  3840. * @see av_register_codec_parser
  3841. * @see av_register_bitstream_filter
  3842. */
  3843. void avcodec_register_all(void);
  3844. /**
  3845. * Allocate an AVCodecContext and set its fields to default values. The
  3846. * resulting struct should be freed with avcodec_free_context().
  3847. *
  3848. * @param codec if non-NULL, allocate private data and initialize defaults
  3849. * for the given codec. It is illegal to then call avcodec_open2()
  3850. * with a different codec.
  3851. * If NULL, then the codec-specific defaults won't be initialized,
  3852. * which may result in suboptimal default settings (this is
  3853. * important mainly for encoders, e.g. libx264).
  3854. *
  3855. * @return An AVCodecContext filled with default values or NULL on failure.
  3856. */
  3857. AVCodecContext *avcodec_alloc_context3(const AVCodec *codec);
  3858. /**
  3859. * Free the codec context and everything associated with it and write NULL to
  3860. * the provided pointer.
  3861. */
  3862. void avcodec_free_context(AVCodecContext **avctx);
  3863. #if FF_API_GET_CONTEXT_DEFAULTS
  3864. /**
  3865. * @deprecated This function should not be used, as closing and opening a codec
  3866. * context multiple time is not supported. A new codec context should be
  3867. * allocated for each new use.
  3868. */
  3869. int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec);
  3870. #endif
  3871. /**
  3872. * Get the AVClass for AVCodecContext. It can be used in combination with
  3873. * AV_OPT_SEARCH_FAKE_OBJ for examining options.
  3874. *
  3875. * @see av_opt_find().
  3876. */
  3877. const AVClass *avcodec_get_class(void);
  3878. #if FF_API_COPY_CONTEXT
  3879. /**
  3880. * Get the AVClass for AVFrame. It can be used in combination with
  3881. * AV_OPT_SEARCH_FAKE_OBJ for examining options.
  3882. *
  3883. * @see av_opt_find().
  3884. */
  3885. const AVClass *avcodec_get_frame_class(void);
  3886. /**
  3887. * Get the AVClass for AVSubtitleRect. It can be used in combination with
  3888. * AV_OPT_SEARCH_FAKE_OBJ for examining options.
  3889. *
  3890. * @see av_opt_find().
  3891. */
  3892. const AVClass *avcodec_get_subtitle_rect_class(void);
  3893. /**
  3894. * Copy the settings of the source AVCodecContext into the destination
  3895. * AVCodecContext. The resulting destination codec context will be
  3896. * unopened, i.e. you are required to call avcodec_open2() before you
  3897. * can use this AVCodecContext to decode/encode video/audio data.
  3898. *
  3899. * @param dest target codec context, should be initialized with
  3900. * avcodec_alloc_context3(NULL), but otherwise uninitialized
  3901. * @param src source codec context
  3902. * @return AVERROR() on error (e.g. memory allocation error), 0 on success
  3903. *
  3904. * @deprecated The semantics of this function are ill-defined and it should not
  3905. * be used. If you need to transfer the stream parameters from one codec context
  3906. * to another, use an intermediate AVCodecParameters instance and the
  3907. * avcodec_parameters_from_context() / avcodec_parameters_to_context()
  3908. * functions.
  3909. */
  3910. attribute_deprecated
  3911. int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src);
  3912. #endif
  3913. /**
  3914. * Allocate a new AVCodecParameters and set its fields to default values
  3915. * (unknown/invalid/0). The returned struct must be freed with
  3916. * avcodec_parameters_free().
  3917. */
  3918. AVCodecParameters *avcodec_parameters_alloc(void);
  3919. /**
  3920. * Free an AVCodecParameters instance and everything associated with it and
  3921. * write NULL to the supplied pointer.
  3922. */
  3923. void avcodec_parameters_free(AVCodecParameters **par);
  3924. /**
  3925. * Copy the contents of src to dst. Any allocated fields in dst are freed and
  3926. * replaced with newly allocated duplicates of the corresponding fields in src.
  3927. *
  3928. * @return >= 0 on success, a negative AVERROR code on failure.
  3929. */
  3930. int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src);
  3931. /**
  3932. * Fill the parameters struct based on the values from the supplied codec
  3933. * context. Any allocated fields in par are freed and replaced with duplicates
  3934. * of the corresponding fields in codec.
  3935. *
  3936. * @return >= 0 on success, a negative AVERROR code on failure
  3937. */
  3938. int avcodec_parameters_from_context(AVCodecParameters *par,
  3939. const AVCodecContext *codec);
  3940. /**
  3941. * Fill the codec context based on the values from the supplied codec
  3942. * parameters. Any allocated fields in codec that have a corresponding field in
  3943. * par are freed and replaced with duplicates of the corresponding field in par.
  3944. * Fields in codec that do not have a counterpart in par are not touched.
  3945. *
  3946. * @return >= 0 on success, a negative AVERROR code on failure.
  3947. */
  3948. int avcodec_parameters_to_context(AVCodecContext *codec,
  3949. const AVCodecParameters *par);
  3950. /**
  3951. * Initialize the AVCodecContext to use the given AVCodec. Prior to using this
  3952. * function the context has to be allocated with avcodec_alloc_context3().
  3953. *
  3954. * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),
  3955. * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for
  3956. * retrieving a codec.
  3957. *
  3958. * @warning This function is not thread safe!
  3959. *
  3960. * @note Always call this function before using decoding routines (such as
  3961. * @ref avcodec_receive_frame()).
  3962. *
  3963. * @code
  3964. * avcodec_register_all();
  3965. * av_dict_set(&opts, "b", "2.5M", 0);
  3966. * codec = avcodec_find_decoder(AV_CODEC_ID_H264);
  3967. * if (!codec)
  3968. * exit(1);
  3969. *
  3970. * context = avcodec_alloc_context3(codec);
  3971. *
  3972. * if (avcodec_open2(context, codec, opts) < 0)
  3973. * exit(1);
  3974. * @endcode
  3975. *
  3976. * @param avctx The context to initialize.
  3977. * @param codec The codec to open this context for. If a non-NULL codec has been
  3978. * previously passed to avcodec_alloc_context3() or
  3979. * for this context, then this parameter MUST be either NULL or
  3980. * equal to the previously passed codec.
  3981. * @param options A dictionary filled with AVCodecContext and codec-private options.
  3982. * On return this object will be filled with options that were not found.
  3983. *
  3984. * @return zero on success, a negative value on error
  3985. * @see avcodec_alloc_context3(), avcodec_find_decoder(), avcodec_find_encoder(),
  3986. * av_dict_set(), av_opt_find().
  3987. */
  3988. int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options);
  3989. /**
  3990. * Close a given AVCodecContext and free all the data associated with it
  3991. * (but not the AVCodecContext itself).
  3992. *
  3993. * Calling this function on an AVCodecContext that hasn't been opened will free
  3994. * the codec-specific data allocated in avcodec_alloc_context3() with a non-NULL
  3995. * codec. Subsequent calls will do nothing.
  3996. *
  3997. * @note Do not use this function. Use avcodec_free_context() to destroy a
  3998. * codec context (either open or closed). Opening and closing a codec context
  3999. * multiple times is not supported anymore -- use multiple codec contexts
  4000. * instead.
  4001. */
  4002. int avcodec_close(AVCodecContext *avctx);
  4003. /**
  4004. * Free all allocated data in the given subtitle struct.
  4005. *
  4006. * @param sub AVSubtitle to free.
  4007. */
  4008. void avsubtitle_free(AVSubtitle *sub);
  4009. /**
  4010. * @}
  4011. */
  4012. /**
  4013. * @addtogroup lavc_packet
  4014. * @{
  4015. */
  4016. /**
  4017. * Allocate an AVPacket and set its fields to default values. The resulting
  4018. * struct must be freed using av_packet_free().
  4019. *
  4020. * @return An AVPacket filled with default values or NULL on failure.
  4021. *
  4022. * @note this only allocates the AVPacket itself, not the data buffers. Those
  4023. * must be allocated through other means such as av_new_packet.
  4024. *
  4025. * @see av_new_packet
  4026. */
  4027. AVPacket *av_packet_alloc(void);
  4028. /**
  4029. * Create a new packet that references the same data as src.
  4030. *
  4031. * This is a shortcut for av_packet_alloc()+av_packet_ref().
  4032. *
  4033. * @return newly created AVPacket on success, NULL on error.
  4034. *
  4035. * @see av_packet_alloc
  4036. * @see av_packet_ref
  4037. */
  4038. AVPacket *av_packet_clone(const AVPacket *src);
  4039. /**
  4040. * Free the packet, if the packet is reference counted, it will be
  4041. * unreferenced first.
  4042. *
  4043. * @param pkt packet to be freed. The pointer will be set to NULL.
  4044. * @note passing NULL is a no-op.
  4045. */
  4046. void av_packet_free(AVPacket **pkt);
  4047. /**
  4048. * Initialize optional fields of a packet with default values.
  4049. *
  4050. * Note, this does not touch the data and size members, which have to be
  4051. * initialized separately.
  4052. *
  4053. * @param pkt packet
  4054. */
  4055. void av_init_packet(AVPacket *pkt);
  4056. /**
  4057. * Allocate the payload of a packet and initialize its fields with
  4058. * default values.
  4059. *
  4060. * @param pkt packet
  4061. * @param size wanted payload size
  4062. * @return 0 if OK, AVERROR_xxx otherwise
  4063. */
  4064. int av_new_packet(AVPacket *pkt, int size);
  4065. /**
  4066. * Reduce packet size, correctly zeroing padding
  4067. *
  4068. * @param pkt packet
  4069. * @param size new size
  4070. */
  4071. void av_shrink_packet(AVPacket *pkt, int size);
  4072. /**
  4073. * Increase packet size, correctly zeroing padding
  4074. *
  4075. * @param pkt packet
  4076. * @param grow_by number of bytes by which to increase the size of the packet
  4077. */
  4078. int av_grow_packet(AVPacket *pkt, int grow_by);
  4079. /**
  4080. * Initialize a reference-counted packet from av_malloc()ed data.
  4081. *
  4082. * @param pkt packet to be initialized. This function will set the data, size,
  4083. * buf and destruct fields, all others are left untouched.
  4084. * @param data Data allocated by av_malloc() to be used as packet data. If this
  4085. * function returns successfully, the data is owned by the underlying AVBuffer.
  4086. * The caller may not access the data through other means.
  4087. * @param size size of data in bytes, without the padding. I.e. the full buffer
  4088. * size is assumed to be size + AV_INPUT_BUFFER_PADDING_SIZE.
  4089. *
  4090. * @return 0 on success, a negative AVERROR on error
  4091. */
  4092. int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size);
  4093. #if FF_API_AVPACKET_OLD_API
  4094. /**
  4095. * @warning This is a hack - the packet memory allocation stuff is broken. The
  4096. * packet is allocated if it was not really allocated.
  4097. *
  4098. * @deprecated Use av_packet_ref
  4099. */
  4100. attribute_deprecated
  4101. int av_dup_packet(AVPacket *pkt);
  4102. /**
  4103. * Copy packet, including contents
  4104. *
  4105. * @return 0 on success, negative AVERROR on fail
  4106. *
  4107. * @deprecated Use av_packet_ref
  4108. */
  4109. attribute_deprecated
  4110. int av_copy_packet(AVPacket *dst, const AVPacket *src);
  4111. /**
  4112. * Copy packet side data
  4113. *
  4114. * @return 0 on success, negative AVERROR on fail
  4115. *
  4116. * @deprecated Use av_packet_copy_props
  4117. */
  4118. attribute_deprecated
  4119. int av_copy_packet_side_data(AVPacket *dst, const AVPacket *src);
  4120. /**
  4121. * Free a packet.
  4122. *
  4123. * @deprecated Use av_packet_unref
  4124. *
  4125. * @param pkt packet to free
  4126. */
  4127. attribute_deprecated
  4128. void av_free_packet(AVPacket *pkt);
  4129. #endif
  4130. /**
  4131. * Allocate new information of a packet.
  4132. *
  4133. * @param pkt packet
  4134. * @param type side information type
  4135. * @param size side information size
  4136. * @return pointer to fresh allocated data or NULL otherwise
  4137. */
  4138. uint8_t* av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
  4139. int size);
  4140. /**
  4141. * Wrap an existing array as a packet side data.
  4142. *
  4143. * @param pkt packet
  4144. * @param type side information type
  4145. * @param data the side data array. It must be allocated with the av_malloc()
  4146. * family of functions. The ownership of the data is transferred to
  4147. * pkt.
  4148. * @param size side information size
  4149. * @return a non-negative number on success, a negative AVERROR code on
  4150. * failure. On failure, the packet is unchanged and the data remains
  4151. * owned by the caller.
  4152. */
  4153. int av_packet_add_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
  4154. uint8_t *data, size_t size);
  4155. /**
  4156. * Shrink the already allocated side data buffer
  4157. *
  4158. * @param pkt packet
  4159. * @param type side information type
  4160. * @param size new side information size
  4161. * @return 0 on success, < 0 on failure
  4162. */
  4163. int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
  4164. int size);
  4165. /**
  4166. * Get side information from packet.
  4167. *
  4168. * @param pkt packet
  4169. * @param type desired side information type
  4170. * @param size pointer for side information size to store (optional)
  4171. * @return pointer to data if present or NULL otherwise
  4172. */
  4173. uint8_t* av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type,
  4174. int *size);
  4175. #if FF_API_MERGE_SD_API
  4176. attribute_deprecated
  4177. int av_packet_merge_side_data(AVPacket *pkt);
  4178. attribute_deprecated
  4179. int av_packet_split_side_data(AVPacket *pkt);
  4180. #endif
  4181. const char *av_packet_side_data_name(enum AVPacketSideDataType type);
  4182. /**
  4183. * Pack a dictionary for use in side_data.
  4184. *
  4185. * @param dict The dictionary to pack.
  4186. * @param size pointer to store the size of the returned data
  4187. * @return pointer to data if successful, NULL otherwise
  4188. */
  4189. uint8_t *av_packet_pack_dictionary(AVDictionary *dict, int *size);
  4190. /**
  4191. * Unpack a dictionary from side_data.
  4192. *
  4193. * @param data data from side_data
  4194. * @param size size of the data
  4195. * @param dict the metadata storage dictionary
  4196. * @return 0 on success, < 0 on failure
  4197. */
  4198. int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **dict);
  4199. /**
  4200. * Convenience function to free all the side data stored.
  4201. * All the other fields stay untouched.
  4202. *
  4203. * @param pkt packet
  4204. */
  4205. void av_packet_free_side_data(AVPacket *pkt);
  4206. /**
  4207. * Setup a new reference to the data described by a given packet
  4208. *
  4209. * If src is reference-counted, setup dst as a new reference to the
  4210. * buffer in src. Otherwise allocate a new buffer in dst and copy the
  4211. * data from src into it.
  4212. *
  4213. * All the other fields are copied from src.
  4214. *
  4215. * @see av_packet_unref
  4216. *
  4217. * @param dst Destination packet
  4218. * @param src Source packet
  4219. *
  4220. * @return 0 on success, a negative AVERROR on error.
  4221. */
  4222. int av_packet_ref(AVPacket *dst, const AVPacket *src);
  4223. /**
  4224. * Wipe the packet.
  4225. *
  4226. * Unreference the buffer referenced by the packet and reset the
  4227. * remaining packet fields to their default values.
  4228. *
  4229. * @param pkt The packet to be unreferenced.
  4230. */
  4231. void av_packet_unref(AVPacket *pkt);
  4232. /**
  4233. * Move every field in src to dst and reset src.
  4234. *
  4235. * @see av_packet_unref
  4236. *
  4237. * @param src Source packet, will be reset
  4238. * @param dst Destination packet
  4239. */
  4240. void av_packet_move_ref(AVPacket *dst, AVPacket *src);
  4241. /**
  4242. * Copy only "properties" fields from src to dst.
  4243. *
  4244. * Properties for the purpose of this function are all the fields
  4245. * beside those related to the packet data (buf, data, size)
  4246. *
  4247. * @param dst Destination packet
  4248. * @param src Source packet
  4249. *
  4250. * @return 0 on success AVERROR on failure.
  4251. */
  4252. int av_packet_copy_props(AVPacket *dst, const AVPacket *src);
  4253. /**
  4254. * Convert valid timing fields (timestamps / durations) in a packet from one
  4255. * timebase to another. Timestamps with unknown values (AV_NOPTS_VALUE) will be
  4256. * ignored.
  4257. *
  4258. * @param pkt packet on which the conversion will be performed
  4259. * @param tb_src source timebase, in which the timing fields in pkt are
  4260. * expressed
  4261. * @param tb_dst destination timebase, to which the timing fields will be
  4262. * converted
  4263. */
  4264. void av_packet_rescale_ts(AVPacket *pkt, AVRational tb_src, AVRational tb_dst);
  4265. /**
  4266. * @}
  4267. */
  4268. /**
  4269. * @addtogroup lavc_decoding
  4270. * @{
  4271. */
  4272. /**
  4273. * Find a registered decoder with a matching codec ID.
  4274. *
  4275. * @param id AVCodecID of the requested decoder
  4276. * @return A decoder if one was found, NULL otherwise.
  4277. */
  4278. AVCodec *avcodec_find_decoder(enum AVCodecID id);
  4279. /**
  4280. * Find a registered decoder with the specified name.
  4281. *
  4282. * @param name name of the requested decoder
  4283. * @return A decoder if one was found, NULL otherwise.
  4284. */
  4285. AVCodec *avcodec_find_decoder_by_name(const char *name);
  4286. /**
  4287. * The default callback for AVCodecContext.get_buffer2(). It is made public so
  4288. * it can be called by custom get_buffer2() implementations for decoders without
  4289. * AV_CODEC_CAP_DR1 set.
  4290. */
  4291. int avcodec_default_get_buffer2(AVCodecContext *s, AVFrame *frame, int flags);
  4292. /**
  4293. * Modify width and height values so that they will result in a memory
  4294. * buffer that is acceptable for the codec if you do not use any horizontal
  4295. * padding.
  4296. *
  4297. * May only be used if a codec with AV_CODEC_CAP_DR1 has been opened.
  4298. */
  4299. void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);
  4300. /**
  4301. * Modify width and height values so that they will result in a memory
  4302. * buffer that is acceptable for the codec if you also ensure that all
  4303. * line sizes are a multiple of the respective linesize_align[i].
  4304. *
  4305. * May only be used if a codec with AV_CODEC_CAP_DR1 has been opened.
  4306. */
  4307. void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
  4308. int linesize_align[AV_NUM_DATA_POINTERS]);
  4309. /**
  4310. * Converts AVChromaLocation to swscale x/y chroma position.
  4311. *
  4312. * The positions represent the chroma (0,0) position in a coordinates system
  4313. * with luma (0,0) representing the origin and luma(1,1) representing 256,256
  4314. *
  4315. * @param xpos horizontal chroma sample position
  4316. * @param ypos vertical chroma sample position
  4317. */
  4318. int avcodec_enum_to_chroma_pos(int *xpos, int *ypos, enum AVChromaLocation pos);
  4319. /**
  4320. * Converts swscale x/y chroma position to AVChromaLocation.
  4321. *
  4322. * The positions represent the chroma (0,0) position in a coordinates system
  4323. * with luma (0,0) representing the origin and luma(1,1) representing 256,256
  4324. *
  4325. * @param xpos horizontal chroma sample position
  4326. * @param ypos vertical chroma sample position
  4327. */
  4328. enum AVChromaLocation avcodec_chroma_pos_to_enum(int xpos, int ypos);
  4329. /**
  4330. * Decode the audio frame of size avpkt->size from avpkt->data into frame.
  4331. *
  4332. * Some decoders may support multiple frames in a single AVPacket. Such
  4333. * decoders would then just decode the first frame and the return value would be
  4334. * less than the packet size. In this case, avcodec_decode_audio4 has to be
  4335. * called again with an AVPacket containing the remaining data in order to
  4336. * decode the second frame, etc... Even if no frames are returned, the packet
  4337. * needs to be fed to the decoder with remaining data until it is completely
  4338. * consumed or an error occurs.
  4339. *
  4340. * Some decoders (those marked with AV_CODEC_CAP_DELAY) have a delay between input
  4341. * and output. This means that for some packets they will not immediately
  4342. * produce decoded output and need to be flushed at the end of decoding to get
  4343. * all the decoded data. Flushing is done by calling this function with packets
  4344. * with avpkt->data set to NULL and avpkt->size set to 0 until it stops
  4345. * returning samples. It is safe to flush even those decoders that are not
  4346. * marked with AV_CODEC_CAP_DELAY, then no samples will be returned.
  4347. *
  4348. * @warning The input buffer, avpkt->data must be AV_INPUT_BUFFER_PADDING_SIZE
  4349. * larger than the actual read bytes because some optimized bitstream
  4350. * readers read 32 or 64 bits at once and could read over the end.
  4351. *
  4352. * @note The AVCodecContext MUST have been opened with @ref avcodec_open2()
  4353. * before packets may be fed to the decoder.
  4354. *
  4355. * @param avctx the codec context
  4356. * @param[out] frame The AVFrame in which to store decoded audio samples.
  4357. * The decoder will allocate a buffer for the decoded frame by
  4358. * calling the AVCodecContext.get_buffer2() callback.
  4359. * When AVCodecContext.refcounted_frames is set to 1, the frame is
  4360. * reference counted and the returned reference belongs to the
  4361. * caller. The caller must release the frame using av_frame_unref()
  4362. * when the frame is no longer needed. The caller may safely write
  4363. * to the frame if av_frame_is_writable() returns 1.
  4364. * When AVCodecContext.refcounted_frames is set to 0, the returned
  4365. * reference belongs to the decoder and is valid only until the
  4366. * next call to this function or until closing or flushing the
  4367. * decoder. The caller may not write to it.
  4368. * @param[out] got_frame_ptr Zero if no frame could be decoded, otherwise it is
  4369. * non-zero. Note that this field being set to zero
  4370. * does not mean that an error has occurred. For
  4371. * decoders with AV_CODEC_CAP_DELAY set, no given decode
  4372. * call is guaranteed to produce a frame.
  4373. * @param[in] avpkt The input AVPacket containing the input buffer.
  4374. * At least avpkt->data and avpkt->size should be set. Some
  4375. * decoders might also require additional fields to be set.
  4376. * @return A negative error code is returned if an error occurred during
  4377. * decoding, otherwise the number of bytes consumed from the input
  4378. * AVPacket is returned.
  4379. *
  4380. * @deprecated Use avcodec_send_packet() and avcodec_receive_frame().
  4381. */
  4382. attribute_deprecated
  4383. int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame,
  4384. int *got_frame_ptr, const AVPacket *avpkt);
  4385. /**
  4386. * Decode the video frame of size avpkt->size from avpkt->data into picture.
  4387. * Some decoders may support multiple frames in a single AVPacket, such
  4388. * decoders would then just decode the first frame.
  4389. *
  4390. * @warning The input buffer must be AV_INPUT_BUFFER_PADDING_SIZE larger than
  4391. * the actual read bytes because some optimized bitstream readers read 32 or 64
  4392. * bits at once and could read over the end.
  4393. *
  4394. * @warning The end of the input buffer buf should be set to 0 to ensure that
  4395. * no overreading happens for damaged MPEG streams.
  4396. *
  4397. * @note Codecs which have the AV_CODEC_CAP_DELAY capability set have a delay
  4398. * between input and output, these need to be fed with avpkt->data=NULL,
  4399. * avpkt->size=0 at the end to return the remaining frames.
  4400. *
  4401. * @note The AVCodecContext MUST have been opened with @ref avcodec_open2()
  4402. * before packets may be fed to the decoder.
  4403. *
  4404. * @param avctx the codec context
  4405. * @param[out] picture The AVFrame in which the decoded video frame will be stored.
  4406. * Use av_frame_alloc() to get an AVFrame. The codec will
  4407. * allocate memory for the actual bitmap by calling the
  4408. * AVCodecContext.get_buffer2() callback.
  4409. * When AVCodecContext.refcounted_frames is set to 1, the frame is
  4410. * reference counted and the returned reference belongs to the
  4411. * caller. The caller must release the frame using av_frame_unref()
  4412. * when the frame is no longer needed. The caller may safely write
  4413. * to the frame if av_frame_is_writable() returns 1.
  4414. * When AVCodecContext.refcounted_frames is set to 0, the returned
  4415. * reference belongs to the decoder and is valid only until the
  4416. * next call to this function or until closing or flushing the
  4417. * decoder. The caller may not write to it.
  4418. *
  4419. * @param[in] avpkt The input AVPacket containing the input buffer.
  4420. * You can create such packet with av_init_packet() and by then setting
  4421. * data and size, some decoders might in addition need other fields like
  4422. * flags&AV_PKT_FLAG_KEY. All decoders are designed to use the least
  4423. * fields possible.
  4424. * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero.
  4425. * @return On error a negative value is returned, otherwise the number of bytes
  4426. * used or zero if no frame could be decompressed.
  4427. *
  4428. * @deprecated Use avcodec_send_packet() and avcodec_receive_frame().
  4429. */
  4430. attribute_deprecated
  4431. int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
  4432. int *got_picture_ptr,
  4433. const AVPacket *avpkt);
  4434. /**
  4435. * Decode a subtitle message.
  4436. * Return a negative value on error, otherwise return the number of bytes used.
  4437. * If no subtitle could be decompressed, got_sub_ptr is zero.
  4438. * Otherwise, the subtitle is stored in *sub.
  4439. * Note that AV_CODEC_CAP_DR1 is not available for subtitle codecs. This is for
  4440. * simplicity, because the performance difference is expect to be negligible
  4441. * and reusing a get_buffer written for video codecs would probably perform badly
  4442. * due to a potentially very different allocation pattern.
  4443. *
  4444. * Some decoders (those marked with AV_CODEC_CAP_DELAY) have a delay between input
  4445. * and output. This means that for some packets they will not immediately
  4446. * produce decoded output and need to be flushed at the end of decoding to get
  4447. * all the decoded data. Flushing is done by calling this function with packets
  4448. * with avpkt->data set to NULL and avpkt->size set to 0 until it stops
  4449. * returning subtitles. It is safe to flush even those decoders that are not
  4450. * marked with AV_CODEC_CAP_DELAY, then no subtitles will be returned.
  4451. *
  4452. * @note The AVCodecContext MUST have been opened with @ref avcodec_open2()
  4453. * before packets may be fed to the decoder.
  4454. *
  4455. * @param avctx the codec context
  4456. * @param[out] sub The Preallocated AVSubtitle in which the decoded subtitle will be stored,
  4457. * must be freed with avsubtitle_free if *got_sub_ptr is set.
  4458. * @param[in,out] got_sub_ptr Zero if no subtitle could be decompressed, otherwise, it is nonzero.
  4459. * @param[in] avpkt The input AVPacket containing the input buffer.
  4460. */
  4461. int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
  4462. int *got_sub_ptr,
  4463. AVPacket *avpkt);
  4464. /**
  4465. * Supply raw packet data as input to a decoder.
  4466. *
  4467. * Internally, this call will copy relevant AVCodecContext fields, which can
  4468. * influence decoding per-packet, and apply them when the packet is actually
  4469. * decoded. (For example AVCodecContext.skip_frame, which might direct the
  4470. * decoder to drop the frame contained by the packet sent with this function.)
  4471. *
  4472. * @warning The input buffer, avpkt->data must be AV_INPUT_BUFFER_PADDING_SIZE
  4473. * larger than the actual read bytes because some optimized bitstream
  4474. * readers read 32 or 64 bits at once and could read over the end.
  4475. *
  4476. * @warning Do not mix this API with the legacy API (like avcodec_decode_video2())
  4477. * on the same AVCodecContext. It will return unexpected results now
  4478. * or in future libavcodec versions.
  4479. *
  4480. * @note The AVCodecContext MUST have been opened with @ref avcodec_open2()
  4481. * before packets may be fed to the decoder.
  4482. *
  4483. * @param avctx codec context
  4484. * @param[in] avpkt The input AVPacket. Usually, this will be a single video
  4485. * frame, or several complete audio frames.
  4486. * Ownership of the packet remains with the caller, and the
  4487. * decoder will not write to the packet. The decoder may create
  4488. * a reference to the packet data (or copy it if the packet is
  4489. * not reference-counted).
  4490. * Unlike with older APIs, the packet is always fully consumed,
  4491. * and if it contains multiple frames (e.g. some audio codecs),
  4492. * will require you to call avcodec_receive_frame() multiple
  4493. * times afterwards before you can send a new packet.
  4494. * It can be NULL (or an AVPacket with data set to NULL and
  4495. * size set to 0); in this case, it is considered a flush
  4496. * packet, which signals the end of the stream. Sending the
  4497. * first flush packet will return success. Subsequent ones are
  4498. * unnecessary and will return AVERROR_EOF. If the decoder
  4499. * still has frames buffered, it will return them after sending
  4500. * a flush packet.
  4501. *
  4502. * @return 0 on success, otherwise negative error code:
  4503. * AVERROR(EAGAIN): input is not accepted in the current state - user
  4504. * must read output with avcodec_receive_frame() (once
  4505. * all output is read, the packet should be resent, and
  4506. * the call will not fail with EAGAIN).
  4507. * AVERROR_EOF: the decoder has been flushed, and no new packets can
  4508. * be sent to it (also returned if more than 1 flush
  4509. * packet is sent)
  4510. * AVERROR(EINVAL): codec not opened, it is an encoder, or requires flush
  4511. * AVERROR(ENOMEM): failed to add packet to internal queue, or similar
  4512. * other errors: legitimate decoding errors
  4513. */
  4514. int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt);
  4515. /**
  4516. * Return decoded output data from a decoder.
  4517. *
  4518. * @param avctx codec context
  4519. * @param frame This will be set to a reference-counted video or audio
  4520. * frame (depending on the decoder type) allocated by the
  4521. * decoder. Note that the function will always call
  4522. * av_frame_unref(frame) before doing anything else.
  4523. *
  4524. * @return
  4525. * 0: success, a frame was returned
  4526. * AVERROR(EAGAIN): output is not available in this state - user must try
  4527. * to send new input
  4528. * AVERROR_EOF: the decoder has been fully flushed, and there will be
  4529. * no more output frames
  4530. * AVERROR(EINVAL): codec not opened, or it is an encoder
  4531. * other negative values: legitimate decoding errors
  4532. */
  4533. int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame);
  4534. /**
  4535. * Supply a raw video or audio frame to the encoder. Use avcodec_receive_packet()
  4536. * to retrieve buffered output packets.
  4537. *
  4538. * @param avctx codec context
  4539. * @param[in] frame AVFrame containing the raw audio or video frame to be encoded.
  4540. * Ownership of the frame remains with the caller, and the
  4541. * encoder will not write to the frame. The encoder may create
  4542. * a reference to the frame data (or copy it if the frame is
  4543. * not reference-counted).
  4544. * It can be NULL, in which case it is considered a flush
  4545. * packet. This signals the end of the stream. If the encoder
  4546. * still has packets buffered, it will return them after this
  4547. * call. Once flushing mode has been entered, additional flush
  4548. * packets are ignored, and sending frames will return
  4549. * AVERROR_EOF.
  4550. *
  4551. * For audio:
  4552. * If AV_CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame
  4553. * can have any number of samples.
  4554. * If it is not set, frame->nb_samples must be equal to
  4555. * avctx->frame_size for all frames except the last.
  4556. * The final frame may be smaller than avctx->frame_size.
  4557. * @return 0 on success, otherwise negative error code:
  4558. * AVERROR(EAGAIN): input is not accepted in the current state - user
  4559. * must read output with avcodec_receive_packet() (once
  4560. * all output is read, the packet should be resent, and
  4561. * the call will not fail with EAGAIN).
  4562. * AVERROR_EOF: the encoder has been flushed, and no new frames can
  4563. * be sent to it
  4564. * AVERROR(EINVAL): codec not opened, refcounted_frames not set, it is a
  4565. * decoder, or requires flush
  4566. * AVERROR(ENOMEM): failed to add packet to internal queue, or similar
  4567. * other errors: legitimate decoding errors
  4568. */
  4569. int avcodec_send_frame(AVCodecContext *avctx, const AVFrame *frame);
  4570. /**
  4571. * Read encoded data from the encoder.
  4572. *
  4573. * @param avctx codec context
  4574. * @param avpkt This will be set to a reference-counted packet allocated by the
  4575. * encoder. Note that the function will always call
  4576. * av_frame_unref(frame) before doing anything else.
  4577. * @return 0 on success, otherwise negative error code:
  4578. * AVERROR(EAGAIN): output is not available in the current state - user
  4579. * must try to send input
  4580. * AVERROR_EOF: the encoder has been fully flushed, and there will be
  4581. * no more output packets
  4582. * AVERROR(EINVAL): codec not opened, or it is an encoder
  4583. * other errors: legitimate decoding errors
  4584. */
  4585. int avcodec_receive_packet(AVCodecContext *avctx, AVPacket *avpkt);
  4586. /**
  4587. * @defgroup lavc_parsing Frame parsing
  4588. * @{
  4589. */
  4590. enum AVPictureStructure {
  4591. AV_PICTURE_STRUCTURE_UNKNOWN, //< unknown
  4592. AV_PICTURE_STRUCTURE_TOP_FIELD, //< coded as top field
  4593. AV_PICTURE_STRUCTURE_BOTTOM_FIELD, //< coded as bottom field
  4594. AV_PICTURE_STRUCTURE_FRAME, //< coded as frame
  4595. };
  4596. typedef struct AVCodecParserContext {
  4597. void *priv_data;
  4598. struct AVCodecParser *parser;
  4599. int64_t frame_offset; /* offset of the current frame */
  4600. int64_t cur_offset; /* current offset
  4601. (incremented by each av_parser_parse()) */
  4602. int64_t next_frame_offset; /* offset of the next frame */
  4603. /* video info */
  4604. int pict_type; /* XXX: Put it back in AVCodecContext. */
  4605. /**
  4606. * This field is used for proper frame duration computation in lavf.
  4607. * It signals, how much longer the frame duration of the current frame
  4608. * is compared to normal frame duration.
  4609. *
  4610. * frame_duration = (1 + repeat_pict) * time_base
  4611. *
  4612. * It is used by codecs like H.264 to display telecined material.
  4613. */
  4614. int repeat_pict; /* XXX: Put it back in AVCodecContext. */
  4615. int64_t pts; /* pts of the current frame */
  4616. int64_t dts; /* dts of the current frame */
  4617. /* private data */
  4618. int64_t last_pts;
  4619. int64_t last_dts;
  4620. int fetch_timestamp;
  4621. #define AV_PARSER_PTS_NB 4
  4622. int cur_frame_start_index;
  4623. int64_t cur_frame_offset[AV_PARSER_PTS_NB];
  4624. int64_t cur_frame_pts[AV_PARSER_PTS_NB];
  4625. int64_t cur_frame_dts[AV_PARSER_PTS_NB];
  4626. int flags;
  4627. #define PARSER_FLAG_COMPLETE_FRAMES 0x0001
  4628. #define PARSER_FLAG_ONCE 0x0002
  4629. /// Set if the parser has a valid file offset
  4630. #define PARSER_FLAG_FETCHED_OFFSET 0x0004
  4631. #define PARSER_FLAG_USE_CODEC_TS 0x1000
  4632. int64_t offset; ///< byte offset from starting packet start
  4633. int64_t cur_frame_end[AV_PARSER_PTS_NB];
  4634. /**
  4635. * Set by parser to 1 for key frames and 0 for non-key frames.
  4636. * It is initialized to -1, so if the parser doesn't set this flag,
  4637. * old-style fallback using AV_PICTURE_TYPE_I picture type as key frames
  4638. * will be used.
  4639. */
  4640. int key_frame;
  4641. #if FF_API_CONVERGENCE_DURATION
  4642. /**
  4643. * @deprecated unused
  4644. */
  4645. attribute_deprecated
  4646. int64_t convergence_duration;
  4647. #endif
  4648. // Timestamp generation support:
  4649. /**
  4650. * Synchronization point for start of timestamp generation.
  4651. *
  4652. * Set to >0 for sync point, 0 for no sync point and <0 for undefined
  4653. * (default).
  4654. *
  4655. * For example, this corresponds to presence of H.264 buffering period
  4656. * SEI message.
  4657. */
  4658. int dts_sync_point;
  4659. /**
  4660. * Offset of the current timestamp against last timestamp sync point in
  4661. * units of AVCodecContext.time_base.
  4662. *
  4663. * Set to INT_MIN when dts_sync_point unused. Otherwise, it must
  4664. * contain a valid timestamp offset.
  4665. *
  4666. * Note that the timestamp of sync point has usually a nonzero
  4667. * dts_ref_dts_delta, which refers to the previous sync point. Offset of
  4668. * the next frame after timestamp sync point will be usually 1.
  4669. *
  4670. * For example, this corresponds to H.264 cpb_removal_delay.
  4671. */
  4672. int dts_ref_dts_delta;
  4673. /**
  4674. * Presentation delay of current frame in units of AVCodecContext.time_base.
  4675. *
  4676. * Set to INT_MIN when dts_sync_point unused. Otherwise, it must
  4677. * contain valid non-negative timestamp delta (presentation time of a frame
  4678. * must not lie in the past).
  4679. *
  4680. * This delay represents the difference between decoding and presentation
  4681. * time of the frame.
  4682. *
  4683. * For example, this corresponds to H.264 dpb_output_delay.
  4684. */
  4685. int pts_dts_delta;
  4686. /**
  4687. * Position of the packet in file.
  4688. *
  4689. * Analogous to cur_frame_pts/dts
  4690. */
  4691. int64_t cur_frame_pos[AV_PARSER_PTS_NB];
  4692. /**
  4693. * Byte position of currently parsed frame in stream.
  4694. */
  4695. int64_t pos;
  4696. /**
  4697. * Previous frame byte position.
  4698. */
  4699. int64_t last_pos;
  4700. /**
  4701. * Duration of the current frame.
  4702. * For audio, this is in units of 1 / AVCodecContext.sample_rate.
  4703. * For all other types, this is in units of AVCodecContext.time_base.
  4704. */
  4705. int duration;
  4706. enum AVFieldOrder field_order;
  4707. /**
  4708. * Indicate whether a picture is coded as a frame, top field or bottom field.
  4709. *
  4710. * For example, H.264 field_pic_flag equal to 0 corresponds to
  4711. * AV_PICTURE_STRUCTURE_FRAME. An H.264 picture with field_pic_flag
  4712. * equal to 1 and bottom_field_flag equal to 0 corresponds to
  4713. * AV_PICTURE_STRUCTURE_TOP_FIELD.
  4714. */
  4715. enum AVPictureStructure picture_structure;
  4716. /**
  4717. * Picture number incremented in presentation or output order.
  4718. * This field may be reinitialized at the first picture of a new sequence.
  4719. *
  4720. * For example, this corresponds to H.264 PicOrderCnt.
  4721. */
  4722. int output_picture_number;
  4723. /**
  4724. * Dimensions of the decoded video intended for presentation.
  4725. */
  4726. int width;
  4727. int height;
  4728. /**
  4729. * Dimensions of the coded video.
  4730. */
  4731. int coded_width;
  4732. int coded_height;
  4733. /**
  4734. * The format of the coded data, corresponds to enum AVPixelFormat for video
  4735. * and for enum AVSampleFormat for audio.
  4736. *
  4737. * Note that a decoder can have considerable freedom in how exactly it
  4738. * decodes the data, so the format reported here might be different from the
  4739. * one returned by a decoder.
  4740. */
  4741. int format;
  4742. } AVCodecParserContext;
  4743. typedef struct AVCodecParser {
  4744. int codec_ids[5]; /* several codec IDs are permitted */
  4745. int priv_data_size;
  4746. int (*parser_init)(AVCodecParserContext *s);
  4747. /* This callback never returns an error, a negative value means that
  4748. * the frame start was in a previous packet. */
  4749. int (*parser_parse)(AVCodecParserContext *s,
  4750. AVCodecContext *avctx,
  4751. const uint8_t **poutbuf, int *poutbuf_size,
  4752. const uint8_t *buf, int buf_size);
  4753. void (*parser_close)(AVCodecParserContext *s);
  4754. int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size);
  4755. struct AVCodecParser *next;
  4756. } AVCodecParser;
  4757. AVCodecParser *av_parser_next(const AVCodecParser *c);
  4758. void av_register_codec_parser(AVCodecParser *parser);
  4759. AVCodecParserContext *av_parser_init(int codec_id);
  4760. /**
  4761. * Parse a packet.
  4762. *
  4763. * @param s parser context.
  4764. * @param avctx codec context.
  4765. * @param poutbuf set to pointer to parsed buffer or NULL if not yet finished.
  4766. * @param poutbuf_size set to size of parsed buffer or zero if not yet finished.
  4767. * @param buf input buffer.
  4768. * @param buf_size buffer size in bytes without the padding. I.e. the full buffer
  4769. size is assumed to be buf_size + AV_INPUT_BUFFER_PADDING_SIZE.
  4770. To signal EOF, this should be 0 (so that the last frame
  4771. can be output).
  4772. * @param pts input presentation timestamp.
  4773. * @param dts input decoding timestamp.
  4774. * @param pos input byte position in stream.
  4775. * @return the number of bytes of the input bitstream used.
  4776. *
  4777. * Example:
  4778. * @code
  4779. * while(in_len){
  4780. * len = av_parser_parse2(myparser, AVCodecContext, &data, &size,
  4781. * in_data, in_len,
  4782. * pts, dts, pos);
  4783. * in_data += len;
  4784. * in_len -= len;
  4785. *
  4786. * if(size)
  4787. * decode_frame(data, size);
  4788. * }
  4789. * @endcode
  4790. */
  4791. int av_parser_parse2(AVCodecParserContext *s,
  4792. AVCodecContext *avctx,
  4793. uint8_t **poutbuf, int *poutbuf_size,
  4794. const uint8_t *buf, int buf_size,
  4795. int64_t pts, int64_t dts,
  4796. int64_t pos);
  4797. /**
  4798. * @return 0 if the output buffer is a subset of the input, 1 if it is allocated and must be freed
  4799. * @deprecated use AVBitStreamFilter
  4800. */
  4801. int av_parser_change(AVCodecParserContext *s,
  4802. AVCodecContext *avctx,
  4803. uint8_t **poutbuf, int *poutbuf_size,
  4804. const uint8_t *buf, int buf_size, int keyframe);
  4805. void av_parser_close(AVCodecParserContext *s);
  4806. /**
  4807. * @}
  4808. * @}
  4809. */
  4810. /**
  4811. * @addtogroup lavc_encoding
  4812. * @{
  4813. */
  4814. /**
  4815. * Find a registered encoder with a matching codec ID.
  4816. *
  4817. * @param id AVCodecID of the requested encoder
  4818. * @return An encoder if one was found, NULL otherwise.
  4819. */
  4820. AVCodec *avcodec_find_encoder(enum AVCodecID id);
  4821. /**
  4822. * Find a registered encoder with the specified name.
  4823. *
  4824. * @param name name of the requested encoder
  4825. * @return An encoder if one was found, NULL otherwise.
  4826. */
  4827. AVCodec *avcodec_find_encoder_by_name(const char *name);
  4828. /**
  4829. * Encode a frame of audio.
  4830. *
  4831. * Takes input samples from frame and writes the next output packet, if
  4832. * available, to avpkt. The output packet does not necessarily contain data for
  4833. * the most recent frame, as encoders can delay, split, and combine input frames
  4834. * internally as needed.
  4835. *
  4836. * @param avctx codec context
  4837. * @param avpkt output AVPacket.
  4838. * The user can supply an output buffer by setting
  4839. * avpkt->data and avpkt->size prior to calling the
  4840. * function, but if the size of the user-provided data is not
  4841. * large enough, encoding will fail. If avpkt->data and
  4842. * avpkt->size are set, avpkt->destruct must also be set. All
  4843. * other AVPacket fields will be reset by the encoder using
  4844. * av_init_packet(). If avpkt->data is NULL, the encoder will
  4845. * allocate it. The encoder will set avpkt->size to the size
  4846. * of the output packet.
  4847. *
  4848. * If this function fails or produces no output, avpkt will be
  4849. * freed using av_packet_unref().
  4850. * @param[in] frame AVFrame containing the raw audio data to be encoded.
  4851. * May be NULL when flushing an encoder that has the
  4852. * AV_CODEC_CAP_DELAY capability set.
  4853. * If AV_CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame
  4854. * can have any number of samples.
  4855. * If it is not set, frame->nb_samples must be equal to
  4856. * avctx->frame_size for all frames except the last.
  4857. * The final frame may be smaller than avctx->frame_size.
  4858. * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the
  4859. * output packet is non-empty, and to 0 if it is
  4860. * empty. If the function returns an error, the
  4861. * packet can be assumed to be invalid, and the
  4862. * value of got_packet_ptr is undefined and should
  4863. * not be used.
  4864. * @return 0 on success, negative error code on failure
  4865. *
  4866. * @deprecated use avcodec_send_frame()/avcodec_receive_packet() instead
  4867. */
  4868. attribute_deprecated
  4869. int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt,
  4870. const AVFrame *frame, int *got_packet_ptr);
  4871. /**
  4872. * Encode a frame of video.
  4873. *
  4874. * Takes input raw video data from frame and writes the next output packet, if
  4875. * available, to avpkt. The output packet does not necessarily contain data for
  4876. * the most recent frame, as encoders can delay and reorder input frames
  4877. * internally as needed.
  4878. *
  4879. * @param avctx codec context
  4880. * @param avpkt output AVPacket.
  4881. * The user can supply an output buffer by setting
  4882. * avpkt->data and avpkt->size prior to calling the
  4883. * function, but if the size of the user-provided data is not
  4884. * large enough, encoding will fail. All other AVPacket fields
  4885. * will be reset by the encoder using av_init_packet(). If
  4886. * avpkt->data is NULL, the encoder will allocate it.
  4887. * The encoder will set avpkt->size to the size of the
  4888. * output packet. The returned data (if any) belongs to the
  4889. * caller, he is responsible for freeing it.
  4890. *
  4891. * If this function fails or produces no output, avpkt will be
  4892. * freed using av_packet_unref().
  4893. * @param[in] frame AVFrame containing the raw video data to be encoded.
  4894. * May be NULL when flushing an encoder that has the
  4895. * AV_CODEC_CAP_DELAY capability set.
  4896. * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the
  4897. * output packet is non-empty, and to 0 if it is
  4898. * empty. If the function returns an error, the
  4899. * packet can be assumed to be invalid, and the
  4900. * value of got_packet_ptr is undefined and should
  4901. * not be used.
  4902. * @return 0 on success, negative error code on failure
  4903. *
  4904. * @deprecated use avcodec_send_frame()/avcodec_receive_packet() instead
  4905. */
  4906. attribute_deprecated
  4907. int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt,
  4908. const AVFrame *frame, int *got_packet_ptr);
  4909. int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
  4910. const AVSubtitle *sub);
  4911. /**
  4912. * @}
  4913. */
  4914. #if FF_API_AVPICTURE
  4915. /**
  4916. * @addtogroup lavc_picture
  4917. * @{
  4918. */
  4919. /**
  4920. * @deprecated unused
  4921. */
  4922. attribute_deprecated
  4923. int avpicture_alloc(AVPicture *picture, enum AVPixelFormat pix_fmt, int width, int height);
  4924. /**
  4925. * @deprecated unused
  4926. */
  4927. attribute_deprecated
  4928. void avpicture_free(AVPicture *picture);
  4929. /**
  4930. * @deprecated use av_image_fill_arrays() instead.
  4931. */
  4932. attribute_deprecated
  4933. int avpicture_fill(AVPicture *picture, const uint8_t *ptr,
  4934. enum AVPixelFormat pix_fmt, int width, int height);
  4935. /**
  4936. * @deprecated use av_image_copy_to_buffer() instead.
  4937. */
  4938. attribute_deprecated
  4939. int avpicture_layout(const AVPicture *src, enum AVPixelFormat pix_fmt,
  4940. int width, int height,
  4941. unsigned char *dest, int dest_size);
  4942. /**
  4943. * @deprecated use av_image_get_buffer_size() instead.
  4944. */
  4945. attribute_deprecated
  4946. int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height);
  4947. /**
  4948. * @deprecated av_image_copy() instead.
  4949. */
  4950. attribute_deprecated
  4951. void av_picture_copy(AVPicture *dst, const AVPicture *src,
  4952. enum AVPixelFormat pix_fmt, int width, int height);
  4953. /**
  4954. * @deprecated unused
  4955. */
  4956. attribute_deprecated
  4957. int av_picture_crop(AVPicture *dst, const AVPicture *src,
  4958. enum AVPixelFormat pix_fmt, int top_band, int left_band);
  4959. /**
  4960. * @deprecated unused
  4961. */
  4962. attribute_deprecated
  4963. int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, enum AVPixelFormat pix_fmt,
  4964. int padtop, int padbottom, int padleft, int padright, int *color);
  4965. /**
  4966. * @}
  4967. */
  4968. #endif
  4969. /**
  4970. * @defgroup lavc_misc Utility functions
  4971. * @ingroup libavc
  4972. *
  4973. * Miscellaneous utility functions related to both encoding and decoding
  4974. * (or neither).
  4975. * @{
  4976. */
  4977. /**
  4978. * @defgroup lavc_misc_pixfmt Pixel formats
  4979. *
  4980. * Functions for working with pixel formats.
  4981. * @{
  4982. */
  4983. #if FF_API_GETCHROMA
  4984. /**
  4985. * @deprecated Use av_pix_fmt_get_chroma_sub_sample
  4986. */
  4987. attribute_deprecated
  4988. void avcodec_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift);
  4989. #endif
  4990. /**
  4991. * Return a value representing the fourCC code associated to the
  4992. * pixel format pix_fmt, or 0 if no associated fourCC code can be
  4993. * found.
  4994. */
  4995. unsigned int avcodec_pix_fmt_to_codec_tag(enum AVPixelFormat pix_fmt);
  4996. /**
  4997. * @deprecated see av_get_pix_fmt_loss()
  4998. */
  4999. int avcodec_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt, enum AVPixelFormat src_pix_fmt,
  5000. int has_alpha);
  5001. /**
  5002. * Find the best pixel format to convert to given a certain source pixel
  5003. * format. When converting from one pixel format to another, information loss
  5004. * may occur. For example, when converting from RGB24 to GRAY, the color
  5005. * information will be lost. Similarly, other losses occur when converting from
  5006. * some formats to other formats. avcodec_find_best_pix_fmt_of_2() searches which of
  5007. * the given pixel formats should be used to suffer the least amount of loss.
  5008. * The pixel formats from which it chooses one, are determined by the
  5009. * pix_fmt_list parameter.
  5010. *
  5011. *
  5012. * @param[in] pix_fmt_list AV_PIX_FMT_NONE terminated array of pixel formats to choose from
  5013. * @param[in] src_pix_fmt source pixel format
  5014. * @param[in] has_alpha Whether the source pixel format alpha channel is used.
  5015. * @param[out] loss_ptr Combination of flags informing you what kind of losses will occur.
  5016. * @return The best pixel format to convert to or -1 if none was found.
  5017. */
  5018. enum AVPixelFormat avcodec_find_best_pix_fmt_of_list(const enum AVPixelFormat *pix_fmt_list,
  5019. enum AVPixelFormat src_pix_fmt,
  5020. int has_alpha, int *loss_ptr);
  5021. /**
  5022. * @deprecated see av_find_best_pix_fmt_of_2()
  5023. */
  5024. enum AVPixelFormat avcodec_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2,
  5025. enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr);
  5026. attribute_deprecated
  5027. enum AVPixelFormat avcodec_find_best_pix_fmt2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2,
  5028. enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr);
  5029. enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum AVPixelFormat * fmt);
  5030. /**
  5031. * @}
  5032. */
  5033. #if FF_API_TAG_STRING
  5034. /**
  5035. * Put a string representing the codec tag codec_tag in buf.
  5036. *
  5037. * @param buf buffer to place codec tag in
  5038. * @param buf_size size in bytes of buf
  5039. * @param codec_tag codec tag to assign
  5040. * @return the length of the string that would have been generated if
  5041. * enough space had been available, excluding the trailing null
  5042. *
  5043. * @deprecated see av_fourcc_make_string() and av_fourcc2str().
  5044. */
  5045. attribute_deprecated
  5046. size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag);
  5047. #endif
  5048. void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
  5049. /**
  5050. * Return a name for the specified profile, if available.
  5051. *
  5052. * @param codec the codec that is searched for the given profile
  5053. * @param profile the profile value for which a name is requested
  5054. * @return A name for the profile if found, NULL otherwise.
  5055. */
  5056. const char *av_get_profile_name(const AVCodec *codec, int profile);
  5057. /**
  5058. * Return a name for the specified profile, if available.
  5059. *
  5060. * @param codec_id the ID of the codec to which the requested profile belongs
  5061. * @param profile the profile value for which a name is requested
  5062. * @return A name for the profile if found, NULL otherwise.
  5063. *
  5064. * @note unlike av_get_profile_name(), which searches a list of profiles
  5065. * supported by a specific decoder or encoder implementation, this
  5066. * function searches the list of profiles from the AVCodecDescriptor
  5067. */
  5068. const char *avcodec_profile_name(enum AVCodecID codec_id, int profile);
  5069. int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size);
  5070. int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count);
  5071. //FIXME func typedef
  5072. /**
  5073. * Fill AVFrame audio data and linesize pointers.
  5074. *
  5075. * The buffer buf must be a preallocated buffer with a size big enough
  5076. * to contain the specified samples amount. The filled AVFrame data
  5077. * pointers will point to this buffer.
  5078. *
  5079. * AVFrame extended_data channel pointers are allocated if necessary for
  5080. * planar audio.
  5081. *
  5082. * @param frame the AVFrame
  5083. * frame->nb_samples must be set prior to calling the
  5084. * function. This function fills in frame->data,
  5085. * frame->extended_data, frame->linesize[0].
  5086. * @param nb_channels channel count
  5087. * @param sample_fmt sample format
  5088. * @param buf buffer to use for frame data
  5089. * @param buf_size size of buffer
  5090. * @param align plane size sample alignment (0 = default)
  5091. * @return >=0 on success, negative error code on failure
  5092. * @todo return the size in bytes required to store the samples in
  5093. * case of success, at the next libavutil bump
  5094. */
  5095. int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels,
  5096. enum AVSampleFormat sample_fmt, const uint8_t *buf,
  5097. int buf_size, int align);
  5098. /**
  5099. * Reset the internal decoder state / flush internal buffers. Should be called
  5100. * e.g. when seeking or when switching to a different stream.
  5101. *
  5102. * @note when refcounted frames are not used (i.e. avctx->refcounted_frames is 0),
  5103. * this invalidates the frames previously returned from the decoder. When
  5104. * refcounted frames are used, the decoder just releases any references it might
  5105. * keep internally, but the caller's reference remains valid.
  5106. */
  5107. void avcodec_flush_buffers(AVCodecContext *avctx);
  5108. /**
  5109. * Return codec bits per sample.
  5110. *
  5111. * @param[in] codec_id the codec
  5112. * @return Number of bits per sample or zero if unknown for the given codec.
  5113. */
  5114. int av_get_bits_per_sample(enum AVCodecID codec_id);
  5115. /**
  5116. * Return the PCM codec associated with a sample format.
  5117. * @param be endianness, 0 for little, 1 for big,
  5118. * -1 (or anything else) for native
  5119. * @return AV_CODEC_ID_PCM_* or AV_CODEC_ID_NONE
  5120. */
  5121. enum AVCodecID av_get_pcm_codec(enum AVSampleFormat fmt, int be);
  5122. /**
  5123. * Return codec bits per sample.
  5124. * Only return non-zero if the bits per sample is exactly correct, not an
  5125. * approximation.
  5126. *
  5127. * @param[in] codec_id the codec
  5128. * @return Number of bits per sample or zero if unknown for the given codec.
  5129. */
  5130. int av_get_exact_bits_per_sample(enum AVCodecID codec_id);
  5131. /**
  5132. * Return audio frame duration.
  5133. *
  5134. * @param avctx codec context
  5135. * @param frame_bytes size of the frame, or 0 if unknown
  5136. * @return frame duration, in samples, if known. 0 if not able to
  5137. * determine.
  5138. */
  5139. int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes);
  5140. /**
  5141. * This function is the same as av_get_audio_frame_duration(), except it works
  5142. * with AVCodecParameters instead of an AVCodecContext.
  5143. */
  5144. int av_get_audio_frame_duration2(AVCodecParameters *par, int frame_bytes);
  5145. #if FF_API_OLD_BSF
  5146. typedef struct AVBitStreamFilterContext {
  5147. void *priv_data;
  5148. const struct AVBitStreamFilter *filter;
  5149. AVCodecParserContext *parser;
  5150. struct AVBitStreamFilterContext *next;
  5151. /**
  5152. * Internal default arguments, used if NULL is passed to av_bitstream_filter_filter().
  5153. * Not for access by library users.
  5154. */
  5155. char *args;
  5156. } AVBitStreamFilterContext;
  5157. #endif
  5158. typedef struct AVBSFInternal AVBSFInternal;
  5159. /**
  5160. * The bitstream filter state.
  5161. *
  5162. * This struct must be allocated with av_bsf_alloc() and freed with
  5163. * av_bsf_free().
  5164. *
  5165. * The fields in the struct will only be changed (by the caller or by the
  5166. * filter) as described in their documentation, and are to be considered
  5167. * immutable otherwise.
  5168. */
  5169. typedef struct AVBSFContext {
  5170. /**
  5171. * A class for logging and AVOptions
  5172. */
  5173. const AVClass *av_class;
  5174. /**
  5175. * The bitstream filter this context is an instance of.
  5176. */
  5177. const struct AVBitStreamFilter *filter;
  5178. /**
  5179. * Opaque libavcodec internal data. Must not be touched by the caller in any
  5180. * way.
  5181. */
  5182. AVBSFInternal *internal;
  5183. /**
  5184. * Opaque filter-specific private data. If filter->priv_class is non-NULL,
  5185. * this is an AVOptions-enabled struct.
  5186. */
  5187. void *priv_data;
  5188. /**
  5189. * Parameters of the input stream. This field is allocated in
  5190. * av_bsf_alloc(), it needs to be filled by the caller before
  5191. * av_bsf_init().
  5192. */
  5193. AVCodecParameters *par_in;
  5194. /**
  5195. * Parameters of the output stream. This field is allocated in
  5196. * av_bsf_alloc(), it is set by the filter in av_bsf_init().
  5197. */
  5198. AVCodecParameters *par_out;
  5199. /**
  5200. * The timebase used for the timestamps of the input packets. Set by the
  5201. * caller before av_bsf_init().
  5202. */
  5203. AVRational time_base_in;
  5204. /**
  5205. * The timebase used for the timestamps of the output packets. Set by the
  5206. * filter in av_bsf_init().
  5207. */
  5208. AVRational time_base_out;
  5209. } AVBSFContext;
  5210. typedef struct AVBitStreamFilter {
  5211. const char *name;
  5212. /**
  5213. * A list of codec ids supported by the filter, terminated by
  5214. * AV_CODEC_ID_NONE.
  5215. * May be NULL, in that case the bitstream filter works with any codec id.
  5216. */
  5217. const enum AVCodecID *codec_ids;
  5218. /**
  5219. * A class for the private data, used to declare bitstream filter private
  5220. * AVOptions. This field is NULL for bitstream filters that do not declare
  5221. * any options.
  5222. *
  5223. * If this field is non-NULL, the first member of the filter private data
  5224. * must be a pointer to AVClass, which will be set by libavcodec generic
  5225. * code to this class.
  5226. */
  5227. const AVClass *priv_class;
  5228. /*****************************************************************
  5229. * No fields below this line are part of the public API. They
  5230. * may not be used outside of libavcodec and can be changed and
  5231. * removed at will.
  5232. * New public fields should be added right above.
  5233. *****************************************************************
  5234. */
  5235. int priv_data_size;
  5236. int (*init)(AVBSFContext *ctx);
  5237. int (*filter)(AVBSFContext *ctx, AVPacket *pkt);
  5238. void (*close)(AVBSFContext *ctx);
  5239. } AVBitStreamFilter;
  5240. #if FF_API_OLD_BSF
  5241. /**
  5242. * Register a bitstream filter.
  5243. *
  5244. * The filter will be accessible to the application code through
  5245. * av_bitstream_filter_next() or can be directly initialized with
  5246. * av_bitstream_filter_init().
  5247. *
  5248. * @see avcodec_register_all()
  5249. */
  5250. attribute_deprecated
  5251. void av_register_bitstream_filter(AVBitStreamFilter *bsf);
  5252. /**
  5253. * Create and initialize a bitstream filter context given a bitstream
  5254. * filter name.
  5255. *
  5256. * The returned context must be freed with av_bitstream_filter_close().
  5257. *
  5258. * @param name the name of the bitstream filter
  5259. * @return a bitstream filter context if a matching filter was found
  5260. * and successfully initialized, NULL otherwise
  5261. */
  5262. attribute_deprecated
  5263. AVBitStreamFilterContext *av_bitstream_filter_init(const char *name);
  5264. /**
  5265. * Filter bitstream.
  5266. *
  5267. * This function filters the buffer buf with size buf_size, and places the
  5268. * filtered buffer in the buffer pointed to by poutbuf.
  5269. *
  5270. * The output buffer must be freed by the caller.
  5271. *
  5272. * @param bsfc bitstream filter context created by av_bitstream_filter_init()
  5273. * @param avctx AVCodecContext accessed by the filter, may be NULL.
  5274. * If specified, this must point to the encoder context of the
  5275. * output stream the packet is sent to.
  5276. * @param args arguments which specify the filter configuration, may be NULL
  5277. * @param poutbuf pointer which is updated to point to the filtered buffer
  5278. * @param poutbuf_size pointer which is updated to the filtered buffer size in bytes
  5279. * @param buf buffer containing the data to filter
  5280. * @param buf_size size in bytes of buf
  5281. * @param keyframe set to non-zero if the buffer to filter corresponds to a key-frame packet data
  5282. * @return >= 0 in case of success, or a negative error code in case of failure
  5283. *
  5284. * If the return value is positive, an output buffer is allocated and
  5285. * is available in *poutbuf, and is distinct from the input buffer.
  5286. *
  5287. * If the return value is 0, the output buffer is not allocated and
  5288. * should be considered identical to the input buffer, or in case
  5289. * *poutbuf was set it points to the input buffer (not necessarily to
  5290. * its starting address). A special case is if *poutbuf was set to NULL and
  5291. * *poutbuf_size was set to 0, which indicates the packet should be dropped.
  5292. */
  5293. attribute_deprecated
  5294. int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc,
  5295. AVCodecContext *avctx, const char *args,
  5296. uint8_t **poutbuf, int *poutbuf_size,
  5297. const uint8_t *buf, int buf_size, int keyframe);
  5298. /**
  5299. * Release bitstream filter context.
  5300. *
  5301. * @param bsf the bitstream filter context created with
  5302. * av_bitstream_filter_init(), can be NULL
  5303. */
  5304. attribute_deprecated
  5305. void av_bitstream_filter_close(AVBitStreamFilterContext *bsf);
  5306. /**
  5307. * If f is NULL, return the first registered bitstream filter,
  5308. * if f is non-NULL, return the next registered bitstream filter
  5309. * after f, or NULL if f is the last one.
  5310. *
  5311. * This function can be used to iterate over all registered bitstream
  5312. * filters.
  5313. */
  5314. attribute_deprecated
  5315. AVBitStreamFilter *av_bitstream_filter_next(const AVBitStreamFilter *f);
  5316. #endif
  5317. /**
  5318. * @return a bitstream filter with the specified name or NULL if no such
  5319. * bitstream filter exists.
  5320. */
  5321. const AVBitStreamFilter *av_bsf_get_by_name(const char *name);
  5322. /**
  5323. * Iterate over all registered bitstream filters.
  5324. *
  5325. * @param opaque a pointer where libavcodec will store the iteration state. Must
  5326. * point to NULL to start the iteration.
  5327. *
  5328. * @return the next registered bitstream filter or NULL when the iteration is
  5329. * finished
  5330. */
  5331. const AVBitStreamFilter *av_bsf_next(void **opaque);
  5332. /**
  5333. * Allocate a context for a given bitstream filter. The caller must fill in the
  5334. * context parameters as described in the documentation and then call
  5335. * av_bsf_init() before sending any data to the filter.
  5336. *
  5337. * @param filter the filter for which to allocate an instance.
  5338. * @param ctx a pointer into which the pointer to the newly-allocated context
  5339. * will be written. It must be freed with av_bsf_free() after the
  5340. * filtering is done.
  5341. *
  5342. * @return 0 on success, a negative AVERROR code on failure
  5343. */
  5344. int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **ctx);
  5345. /**
  5346. * Prepare the filter for use, after all the parameters and options have been
  5347. * set.
  5348. */
  5349. int av_bsf_init(AVBSFContext *ctx);
  5350. /**
  5351. * Submit a packet for filtering.
  5352. *
  5353. * After sending each packet, the filter must be completely drained by calling
  5354. * av_bsf_receive_packet() repeatedly until it returns AVERROR(EAGAIN) or
  5355. * AVERROR_EOF.
  5356. *
  5357. * @param pkt the packet to filter. The bitstream filter will take ownership of
  5358. * the packet and reset the contents of pkt. pkt is not touched if an error occurs.
  5359. * This parameter may be NULL, which signals the end of the stream (i.e. no more
  5360. * packets will be sent). That will cause the filter to output any packets it
  5361. * may have buffered internally.
  5362. *
  5363. * @return 0 on success, a negative AVERROR on error.
  5364. */
  5365. int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt);
  5366. /**
  5367. * Retrieve a filtered packet.
  5368. *
  5369. * @param[out] pkt this struct will be filled with the contents of the filtered
  5370. * packet. It is owned by the caller and must be freed using
  5371. * av_packet_unref() when it is no longer needed.
  5372. * This parameter should be "clean" (i.e. freshly allocated
  5373. * with av_packet_alloc() or unreffed with av_packet_unref())
  5374. * when this function is called. If this function returns
  5375. * successfully, the contents of pkt will be completely
  5376. * overwritten by the returned data. On failure, pkt is not
  5377. * touched.
  5378. *
  5379. * @return 0 on success. AVERROR(EAGAIN) if more packets need to be sent to the
  5380. * filter (using av_bsf_send_packet()) to get more output. AVERROR_EOF if there
  5381. * will be no further output from the filter. Another negative AVERROR value if
  5382. * an error occurs.
  5383. *
  5384. * @note one input packet may result in several output packets, so after sending
  5385. * a packet with av_bsf_send_packet(), this function needs to be called
  5386. * repeatedly until it stops returning 0. It is also possible for a filter to
  5387. * output fewer packets than were sent to it, so this function may return
  5388. * AVERROR(EAGAIN) immediately after a successful av_bsf_send_packet() call.
  5389. */
  5390. int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt);
  5391. /**
  5392. * Free a bitstream filter context and everything associated with it; write NULL
  5393. * into the supplied pointer.
  5394. */
  5395. void av_bsf_free(AVBSFContext **ctx);
  5396. /**
  5397. * Get the AVClass for AVBSFContext. It can be used in combination with
  5398. * AV_OPT_SEARCH_FAKE_OBJ for examining options.
  5399. *
  5400. * @see av_opt_find().
  5401. */
  5402. const AVClass *av_bsf_get_class(void);
  5403. /**
  5404. * Structure for chain/list of bitstream filters.
  5405. * Empty list can be allocated by av_bsf_list_alloc().
  5406. */
  5407. typedef struct AVBSFList AVBSFList;
  5408. /**
  5409. * Allocate empty list of bitstream filters.
  5410. * The list must be later freed by av_bsf_list_free()
  5411. * or finalized by av_bsf_list_finalize().
  5412. *
  5413. * @return Pointer to @ref AVBSFList on success, NULL in case of failure
  5414. */
  5415. AVBSFList *av_bsf_list_alloc(void);
  5416. /**
  5417. * Free list of bitstream filters.
  5418. *
  5419. * @param lst Pointer to pointer returned by av_bsf_list_alloc()
  5420. */
  5421. void av_bsf_list_free(AVBSFList **lst);
  5422. /**
  5423. * Append bitstream filter to the list of bitstream filters.
  5424. *
  5425. * @param lst List to append to
  5426. * @param bsf Filter context to be appended
  5427. *
  5428. * @return >=0 on success, negative AVERROR in case of failure
  5429. */
  5430. int av_bsf_list_append(AVBSFList *lst, AVBSFContext *bsf);
  5431. /**
  5432. * Construct new bitstream filter context given it's name and options
  5433. * and append it to the list of bitstream filters.
  5434. *
  5435. * @param lst List to append to
  5436. * @param bsf_name Name of the bitstream filter
  5437. * @param options Options for the bitstream filter, can be set to NULL
  5438. *
  5439. * @return >=0 on success, negative AVERROR in case of failure
  5440. */
  5441. int av_bsf_list_append2(AVBSFList *lst, const char * bsf_name, AVDictionary **options);
  5442. /**
  5443. * Finalize list of bitstream filters.
  5444. *
  5445. * This function will transform @ref AVBSFList to single @ref AVBSFContext,
  5446. * so the whole chain of bitstream filters can be treated as single filter
  5447. * freshly allocated by av_bsf_alloc().
  5448. * If the call is successful, @ref AVBSFList structure is freed and lst
  5449. * will be set to NULL. In case of failure, caller is responsible for
  5450. * freeing the structure by av_bsf_list_free()
  5451. *
  5452. * @param lst Filter list structure to be transformed
  5453. * @param[out] bsf Pointer to be set to newly created @ref AVBSFContext structure
  5454. * representing the chain of bitstream filters
  5455. *
  5456. * @return >=0 on success, negative AVERROR in case of failure
  5457. */
  5458. int av_bsf_list_finalize(AVBSFList **lst, AVBSFContext **bsf);
  5459. /**
  5460. * Parse string describing list of bitstream filters and create single
  5461. * @ref AVBSFContext describing the whole chain of bitstream filters.
  5462. * Resulting @ref AVBSFContext can be treated as any other @ref AVBSFContext freshly
  5463. * allocated by av_bsf_alloc().
  5464. *
  5465. * @param str String describing chain of bitstream filters in format
  5466. * `bsf1[=opt1=val1:opt2=val2][,bsf2]`
  5467. * @param[out] bsf Pointer to be set to newly created @ref AVBSFContext structure
  5468. * representing the chain of bitstream filters
  5469. *
  5470. * @return >=0 on success, negative AVERROR in case of failure
  5471. */
  5472. int av_bsf_list_parse_str(const char *str, AVBSFContext **bsf);
  5473. /**
  5474. * Get null/pass-through bitstream filter.
  5475. *
  5476. * @param[out] bsf Pointer to be set to new instance of pass-through bitstream filter
  5477. *
  5478. * @return
  5479. */
  5480. int av_bsf_get_null_filter(AVBSFContext **bsf);
  5481. /* memory */
  5482. /**
  5483. * Same behaviour av_fast_malloc but the buffer has additional
  5484. * AV_INPUT_BUFFER_PADDING_SIZE at the end which will always be 0.
  5485. *
  5486. * In addition the whole buffer will initially and after resizes
  5487. * be 0-initialized so that no uninitialized data will ever appear.
  5488. */
  5489. void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size);
  5490. /**
  5491. * Same behaviour av_fast_padded_malloc except that buffer will always
  5492. * be 0-initialized after call.
  5493. */
  5494. void av_fast_padded_mallocz(void *ptr, unsigned int *size, size_t min_size);
  5495. /**
  5496. * Encode extradata length to a buffer. Used by xiph codecs.
  5497. *
  5498. * @param s buffer to write to; must be at least (v/255+1) bytes long
  5499. * @param v size of extradata in bytes
  5500. * @return number of bytes written to the buffer.
  5501. */
  5502. unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
  5503. /**
  5504. * Register the hardware accelerator hwaccel.
  5505. */
  5506. void av_register_hwaccel(AVHWAccel *hwaccel);
  5507. /**
  5508. * If hwaccel is NULL, returns the first registered hardware accelerator,
  5509. * if hwaccel is non-NULL, returns the next registered hardware accelerator
  5510. * after hwaccel, or NULL if hwaccel is the last one.
  5511. */
  5512. AVHWAccel *av_hwaccel_next(const AVHWAccel *hwaccel);
  5513. /**
  5514. * Lock operation used by lockmgr
  5515. */
  5516. enum AVLockOp {
  5517. AV_LOCK_CREATE, ///< Create a mutex
  5518. AV_LOCK_OBTAIN, ///< Lock the mutex
  5519. AV_LOCK_RELEASE, ///< Unlock the mutex
  5520. AV_LOCK_DESTROY, ///< Free mutex resources
  5521. };
  5522. /**
  5523. * Register a user provided lock manager supporting the operations
  5524. * specified by AVLockOp. The "mutex" argument to the function points
  5525. * to a (void *) where the lockmgr should store/get a pointer to a user
  5526. * allocated mutex. It is NULL upon AV_LOCK_CREATE and equal to the
  5527. * value left by the last call for all other ops. If the lock manager is
  5528. * unable to perform the op then it should leave the mutex in the same
  5529. * state as when it was called and return a non-zero value. However,
  5530. * when called with AV_LOCK_DESTROY the mutex will always be assumed to
  5531. * have been successfully destroyed. If av_lockmgr_register succeeds
  5532. * it will return a non-negative value, if it fails it will return a
  5533. * negative value and destroy all mutex and unregister all callbacks.
  5534. * av_lockmgr_register is not thread-safe, it must be called from a
  5535. * single thread before any calls which make use of locking are used.
  5536. *
  5537. * @param cb User defined callback. av_lockmgr_register invokes calls
  5538. * to this callback and the previously registered callback.
  5539. * The callback will be used to create more than one mutex
  5540. * each of which must be backed by its own underlying locking
  5541. * mechanism (i.e. do not use a single static object to
  5542. * implement your lock manager). If cb is set to NULL the
  5543. * lockmgr will be unregistered.
  5544. */
  5545. int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op));
  5546. /**
  5547. * Get the type of the given codec.
  5548. */
  5549. enum AVMediaType avcodec_get_type(enum AVCodecID codec_id);
  5550. /**
  5551. * Get the name of a codec.
  5552. * @return a static string identifying the codec; never NULL
  5553. */
  5554. const char *avcodec_get_name(enum AVCodecID id);
  5555. /**
  5556. * @return a positive value if s is open (i.e. avcodec_open2() was called on it
  5557. * with no corresponding avcodec_close()), 0 otherwise.
  5558. */
  5559. int avcodec_is_open(AVCodecContext *s);
  5560. /**
  5561. * @return a non-zero number if codec is an encoder, zero otherwise
  5562. */
  5563. int av_codec_is_encoder(const AVCodec *codec);
  5564. /**
  5565. * @return a non-zero number if codec is a decoder, zero otherwise
  5566. */
  5567. int av_codec_is_decoder(const AVCodec *codec);
  5568. /**
  5569. * @return descriptor for given codec ID or NULL if no descriptor exists.
  5570. */
  5571. const AVCodecDescriptor *avcodec_descriptor_get(enum AVCodecID id);
  5572. /**
  5573. * Iterate over all codec descriptors known to libavcodec.
  5574. *
  5575. * @param prev previous descriptor. NULL to get the first descriptor.
  5576. *
  5577. * @return next descriptor or NULL after the last descriptor
  5578. */
  5579. const AVCodecDescriptor *avcodec_descriptor_next(const AVCodecDescriptor *prev);
  5580. /**
  5581. * @return codec descriptor with the given name or NULL if no such descriptor
  5582. * exists.
  5583. */
  5584. const AVCodecDescriptor *avcodec_descriptor_get_by_name(const char *name);
  5585. /**
  5586. * Allocate a CPB properties structure and initialize its fields to default
  5587. * values.
  5588. *
  5589. * @param size if non-NULL, the size of the allocated struct will be written
  5590. * here. This is useful for embedding it in side data.
  5591. *
  5592. * @return the newly allocated struct or NULL on failure
  5593. */
  5594. AVCPBProperties *av_cpb_properties_alloc(size_t *size);
  5595. /**
  5596. * @}
  5597. */
  5598. #endif /* AVCODEC_AVCODEC_H */