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.

5454 lines
180KB

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