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.

6305 lines
208KB

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