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.

6273 lines
207KB

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