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.

5348 lines
175KB

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