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.

5395 lines
178KB

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