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.

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