6387 lines · 211.4 KB · C
RawDownload
/* * copyright (c) 2001 Fabrice Bellard * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef AVCODEC_AVCODEC_H#define AVCODEC_AVCODEC_H /** * @file * @ingroup libavc * Libavcodec external API header */ #include <errno.h>#include "libavutil/samplefmt.h"#include "libavutil/attributes.h"#include "libavutil/avutil.h"#include "libavutil/buffer.h"#include "libavutil/cpu.h"#include "libavutil/channel_layout.h"#include "libavutil/dict.h"#include "libavutil/frame.h"#include "libavutil/log.h"#include "libavutil/pixfmt.h"#include "libavutil/rational.h" #include "version.h" /** * @defgroup libavc libavcodec * Encoding/Decoding Library * * @{ * * @defgroup lavc_decoding Decoding * @{ * @} * * @defgroup lavc_encoding Encoding * @{ * @} * * @defgroup lavc_codec Codecs * @{ * @defgroup lavc_codec_native Native Codecs * @{ * @} * @defgroup lavc_codec_wrappers External library wrappers * @{ * @} * @defgroup lavc_codec_hwaccel Hardware Accelerators bridge * @{ * @} * @} * @defgroup lavc_internal Internal * @{ * @} * @} */ /** * @ingroup libavc * @defgroup lavc_encdec send/receive encoding and decoding API overview * @{ * * The avcodec_send_packet()/avcodec_receive_frame()/avcodec_send_frame()/ * avcodec_receive_packet() functions provide an encode/decode API, which * decouples input and output. * * The API is very similar for encoding/decoding and audio/video, and works as * follows: * - Set up and open the AVCodecContext as usual. * - Send valid input: *   - For decoding, call avcodec_send_packet() to give the decoder raw *     compressed data in an AVPacket. *   - For encoding, call avcodec_send_frame() to give the encoder an AVFrame *     containing uncompressed audio or video. *   In both cases, it is recommended that AVPackets and AVFrames are *   refcounted, or libavcodec might have to copy the input data. (libavformat *   always returns refcounted AVPackets, and av_frame_get_buffer() allocates *   refcounted AVFrames.) * - Receive output in a loop. Periodically call one of the avcodec_receive_*() *   functions and process their output: *   - For decoding, call avcodec_receive_frame(). On success, it will return *     an AVFrame containing uncompressed audio or video data. *   - For encoding, call avcodec_receive_packet(). On success, it will return *     an AVPacket with a compressed frame. *   Repeat this call until it returns AVERROR(EAGAIN) or an error. The *   AVERROR(EAGAIN) return value means that new input data is required to *   return new output. In this case, continue with sending input. For each *   input frame/packet, the codec will typically return 1 output frame/packet, *   but it can also be 0 or more than 1. * * At the beginning of decoding or encoding, the codec might accept multiple * input frames/packets without returning a frame, until its internal buffers * are filled. This situation is handled transparently if you follow the steps * outlined above. * * In theory, sending input can result in EAGAIN - this should happen only if * not all output was received. You can use this to structure alternative decode * or encode loops other than the one suggested above. For example, you could * try sending new input on each iteration, and try to receive output if that * returns EAGAIN. * * End of stream situations. These require "flushing" (aka draining) the codec, * as the codec might buffer multiple frames or packets internally for * performance or out of necessity (consider B-frames). * This is handled as follows: * - Instead of valid input, send NULL to the avcodec_send_packet() (decoding) *   or avcodec_send_frame() (encoding) functions. This will enter draining *   mode. * - Call avcodec_receive_frame() (decoding) or avcodec_receive_packet() *   (encoding) in a loop until AVERROR_EOF is returned. The functions will *   not return AVERROR(EAGAIN), unless you forgot to enter draining mode. * - Before decoding can be resumed again, the codec has to be reset with *   avcodec_flush_buffers(). * * Using the API as outlined above is highly recommended. But it is also * possible to call functions outside of this rigid schema. For example, you can * call avcodec_send_packet() repeatedly without calling * avcodec_receive_frame(). In this case, avcodec_send_packet() will succeed * until the codec's internal buffer has been filled up (which is typically of * size 1 per output frame, after initial input), and then reject input with * AVERROR(EAGAIN). Once it starts rejecting input, you have no choice but to * read at least some output. * * Not all codecs will follow a rigid and predictable dataflow; the only * guarantee is that an AVERROR(EAGAIN) return value on a send/receive call on * one end implies that a receive/send call on the other end will succeed, or * at least will not fail with AVERROR(EAGAIN). In general, no codec will * permit unlimited buffering of input or output. * * This API replaces the following legacy functions: * - avcodec_decode_video2() and avcodec_decode_audio4(): *   Use avcodec_send_packet() to feed input to the decoder, then use *   avcodec_receive_frame() to receive decoded frames after each packet. *   Unlike with the old video decoding API, multiple frames might result from *   a packet. For audio, splitting the input packet into frames by partially *   decoding packets becomes transparent to the API user. You never need to *   feed an AVPacket to the API twice (unless it is rejected with AVERROR(EAGAIN) - then *   no data was read from the packet). *   Additionally, sending a flush/draining packet is required only once. * - avcodec_encode_video2()/avcodec_encode_audio2(): *   Use avcodec_send_frame() to feed input to the encoder, then use *   avcodec_receive_packet() to receive encoded packets. *   Providing user-allocated buffers for avcodec_receive_packet() is not *   possible. * - The new API does not handle subtitles yet. * * Mixing new and old function calls on the same AVCodecContext is not allowed, * and will result in undefined behavior. * * Some codecs might require using the new API; using the old API will return * an error when calling it. All codecs support the new API. * * A codec is not allowed to return AVERROR(EAGAIN) for both sending and receiving. This * would be an invalid state, which could put the codec user into an endless * loop. The API has no concept of time either: it cannot happen that trying to * do avcodec_send_packet() results in AVERROR(EAGAIN), but a repeated call 1 second * later accepts the packet (with no other receive/flush API calls involved). * The API is a strict state machine, and the passage of time is not supposed * to influence it. Some timing-dependent behavior might still be deemed * acceptable in certain cases. But it must never result in both send/receive * returning EAGAIN at the same time at any point. It must also absolutely be * avoided that the current state is "unstable" and can "flip-flop" between * the send/receive APIs allowing progress. For example, it's not allowed that * the codec randomly decides that it actually wants to consume a packet now * instead of returning a frame, after it just returned AVERROR(EAGAIN) on an * avcodec_send_packet() call. * @} */ /** * @defgroup lavc_core Core functions/structures. * @ingroup libavc * * Basic definitions, functions for querying libavcodec capabilities, * allocating core structures, etc. * @{ */  /** * Identify the syntax and semantics of the bitstream. * The principle is roughly: * Two decoders with the same ID can decode the same streams. * Two encoders with the same ID can encode compatible streams. * There may be slight deviations from the principle due to implementation * details. * * If you add a codec ID to this list, add it so that * 1. no value of an existing codec ID changes (that would break ABI), * 2. it is as close as possible to similar codecs * * After adding new codec IDs, do not forget to add an entry to the codec * descriptor list and bump libavcodec minor version. */enum AVCodecID {    AV_CODEC_ID_NONE,     /* video codecs */    AV_CODEC_ID_MPEG1VIDEO,    AV_CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding#if FF_API_XVMC    AV_CODEC_ID_MPEG2VIDEO_XVMC,#endif /* FF_API_XVMC */    AV_CODEC_ID_H261,    AV_CODEC_ID_H263,    AV_CODEC_ID_RV10,    AV_CODEC_ID_RV20,    AV_CODEC_ID_MJPEG,    AV_CODEC_ID_MJPEGB,    AV_CODEC_ID_LJPEG,    AV_CODEC_ID_SP5X,    AV_CODEC_ID_JPEGLS,    AV_CODEC_ID_MPEG4,    AV_CODEC_ID_RAWVIDEO,    AV_CODEC_ID_MSMPEG4V1,    AV_CODEC_ID_MSMPEG4V2,    AV_CODEC_ID_MSMPEG4V3,    AV_CODEC_ID_WMV1,    AV_CODEC_ID_WMV2,    AV_CODEC_ID_H263P,    AV_CODEC_ID_H263I,    AV_CODEC_ID_FLV1,    AV_CODEC_ID_SVQ1,    AV_CODEC_ID_SVQ3,    AV_CODEC_ID_DVVIDEO,    AV_CODEC_ID_HUFFYUV,    AV_CODEC_ID_CYUV,    AV_CODEC_ID_H264,    AV_CODEC_ID_INDEO3,    AV_CODEC_ID_VP3,    AV_CODEC_ID_THEORA,    AV_CODEC_ID_ASV1,    AV_CODEC_ID_ASV2,    AV_CODEC_ID_FFV1,    AV_CODEC_ID_4XM,    AV_CODEC_ID_VCR1,    AV_CODEC_ID_CLJR,    AV_CODEC_ID_MDEC,    AV_CODEC_ID_ROQ,    AV_CODEC_ID_INTERPLAY_VIDEO,    AV_CODEC_ID_XAN_WC3,    AV_CODEC_ID_XAN_WC4,    AV_CODEC_ID_RPZA,    AV_CODEC_ID_CINEPAK,    AV_CODEC_ID_WS_VQA,    AV_CODEC_ID_MSRLE,    AV_CODEC_ID_MSVIDEO1,    AV_CODEC_ID_IDCIN,    AV_CODEC_ID_8BPS,    AV_CODEC_ID_SMC,    AV_CODEC_ID_FLIC,    AV_CODEC_ID_TRUEMOTION1,    AV_CODEC_ID_VMDVIDEO,    AV_CODEC_ID_MSZH,    AV_CODEC_ID_ZLIB,    AV_CODEC_ID_QTRLE,    AV_CODEC_ID_TSCC,    AV_CODEC_ID_ULTI,    AV_CODEC_ID_QDRAW,    AV_CODEC_ID_VIXL,    AV_CODEC_ID_QPEG,    AV_CODEC_ID_PNG,    AV_CODEC_ID_PPM,    AV_CODEC_ID_PBM,    AV_CODEC_ID_PGM,    AV_CODEC_ID_PGMYUV,    AV_CODEC_ID_PAM,    AV_CODEC_ID_FFVHUFF,    AV_CODEC_ID_RV30,    AV_CODEC_ID_RV40,    AV_CODEC_ID_VC1,    AV_CODEC_ID_WMV3,    AV_CODEC_ID_LOCO,    AV_CODEC_ID_WNV1,    AV_CODEC_ID_AASC,    AV_CODEC_ID_INDEO2,    AV_CODEC_ID_FRAPS,    AV_CODEC_ID_TRUEMOTION2,    AV_CODEC_ID_BMP,    AV_CODEC_ID_CSCD,    AV_CODEC_ID_MMVIDEO,    AV_CODEC_ID_ZMBV,    AV_CODEC_ID_AVS,    AV_CODEC_ID_SMACKVIDEO,    AV_CODEC_ID_NUV,    AV_CODEC_ID_KMVC,    AV_CODEC_ID_FLASHSV,    AV_CODEC_ID_CAVS,    AV_CODEC_ID_JPEG2000,    AV_CODEC_ID_VMNC,    AV_CODEC_ID_VP5,    AV_CODEC_ID_VP6,    AV_CODEC_ID_VP6F,    AV_CODEC_ID_TARGA,    AV_CODEC_ID_DSICINVIDEO,    AV_CODEC_ID_TIERTEXSEQVIDEO,    AV_CODEC_ID_TIFF,    AV_CODEC_ID_GIF,    AV_CODEC_ID_DXA,    AV_CODEC_ID_DNXHD,    AV_CODEC_ID_THP,    AV_CODEC_ID_SGI,    AV_CODEC_ID_C93,    AV_CODEC_ID_BETHSOFTVID,    AV_CODEC_ID_PTX,    AV_CODEC_ID_TXD,    AV_CODEC_ID_VP6A,    AV_CODEC_ID_AMV,    AV_CODEC_ID_VB,    AV_CODEC_ID_PCX,    AV_CODEC_ID_SUNRAST,    AV_CODEC_ID_INDEO4,    AV_CODEC_ID_INDEO5,    AV_CODEC_ID_MIMIC,    AV_CODEC_ID_RL2,    AV_CODEC_ID_ESCAPE124,    AV_CODEC_ID_DIRAC,    AV_CODEC_ID_BFI,    AV_CODEC_ID_CMV,    AV_CODEC_ID_MOTIONPIXELS,    AV_CODEC_ID_TGV,    AV_CODEC_ID_TGQ,    AV_CODEC_ID_TQI,    AV_CODEC_ID_AURA,    AV_CODEC_ID_AURA2,    AV_CODEC_ID_V210X,    AV_CODEC_ID_TMV,    AV_CODEC_ID_V210,    AV_CODEC_ID_DPX,    AV_CODEC_ID_MAD,    AV_CODEC_ID_FRWU,    AV_CODEC_ID_FLASHSV2,    AV_CODEC_ID_CDGRAPHICS,    AV_CODEC_ID_R210,    AV_CODEC_ID_ANM,    AV_CODEC_ID_BINKVIDEO,    AV_CODEC_ID_IFF_ILBM,#define AV_CODEC_ID_IFF_BYTERUN1 AV_CODEC_ID_IFF_ILBM    AV_CODEC_ID_KGV1,    AV_CODEC_ID_YOP,    AV_CODEC_ID_VP8,    AV_CODEC_ID_PICTOR,    AV_CODEC_ID_ANSI,    AV_CODEC_ID_A64_MULTI,    AV_CODEC_ID_A64_MULTI5,    AV_CODEC_ID_R10K,    AV_CODEC_ID_MXPEG,    AV_CODEC_ID_LAGARITH,    AV_CODEC_ID_PRORES,    AV_CODEC_ID_JV,    AV_CODEC_ID_DFA,    AV_CODEC_ID_WMV3IMAGE,    AV_CODEC_ID_VC1IMAGE,    AV_CODEC_ID_UTVIDEO,    AV_CODEC_ID_BMV_VIDEO,    AV_CODEC_ID_VBLE,    AV_CODEC_ID_DXTORY,    AV_CODEC_ID_V410,    AV_CODEC_ID_XWD,    AV_CODEC_ID_CDXL,    AV_CODEC_ID_XBM,    AV_CODEC_ID_ZEROCODEC,    AV_CODEC_ID_MSS1,    AV_CODEC_ID_MSA1,    AV_CODEC_ID_TSCC2,    AV_CODEC_ID_MTS2,    AV_CODEC_ID_CLLC,    AV_CODEC_ID_MSS2,    AV_CODEC_ID_VP9,    AV_CODEC_ID_AIC,    AV_CODEC_ID_ESCAPE130,    AV_CODEC_ID_G2M,    AV_CODEC_ID_WEBP,    AV_CODEC_ID_HNM4_VIDEO,    AV_CODEC_ID_HEVC,#define AV_CODEC_ID_H265 AV_CODEC_ID_HEVC    AV_CODEC_ID_FIC,    AV_CODEC_ID_ALIAS_PIX,    AV_CODEC_ID_BRENDER_PIX,    AV_CODEC_ID_PAF_VIDEO,    AV_CODEC_ID_EXR,    AV_CODEC_ID_VP7,    AV_CODEC_ID_SANM,    AV_CODEC_ID_SGIRLE,    AV_CODEC_ID_MVC1,    AV_CODEC_ID_MVC2,    AV_CODEC_ID_HQX,    AV_CODEC_ID_TDSC,    AV_CODEC_ID_HQ_HQA,    AV_CODEC_ID_HAP,    AV_CODEC_ID_DDS,    AV_CODEC_ID_DXV,    AV_CODEC_ID_SCREENPRESSO,    AV_CODEC_ID_RSCC,     AV_CODEC_ID_Y41P = 0x8000,    AV_CODEC_ID_AVRP,    AV_CODEC_ID_012V,    AV_CODEC_ID_AVUI,    AV_CODEC_ID_AYUV,    AV_CODEC_ID_TARGA_Y216,    AV_CODEC_ID_V308,    AV_CODEC_ID_V408,    AV_CODEC_ID_YUV4,    AV_CODEC_ID_AVRN,    AV_CODEC_ID_CPIA,    AV_CODEC_ID_XFACE,    AV_CODEC_ID_SNOW,    AV_CODEC_ID_SMVJPEG,    AV_CODEC_ID_APNG,    AV_CODEC_ID_DAALA,    AV_CODEC_ID_CFHD,    AV_CODEC_ID_TRUEMOTION2RT,    AV_CODEC_ID_M101,    AV_CODEC_ID_MAGICYUV,    AV_CODEC_ID_SHEERVIDEO,    AV_CODEC_ID_YLC,    AV_CODEC_ID_PSD,    AV_CODEC_ID_PIXLET,    AV_CODEC_ID_SPEEDHQ,    AV_CODEC_ID_FMVC,    AV_CODEC_ID_SCPR,    AV_CODEC_ID_CLEARVIDEO,    AV_CODEC_ID_XPM,    AV_CODEC_ID_AV1,    AV_CODEC_ID_BITPACKED,    AV_CODEC_ID_MSCC,    AV_CODEC_ID_SRGC,    AV_CODEC_ID_SVG,     /* various PCM "codecs" */    AV_CODEC_ID_FIRST_AUDIO = 0x10000,     ///< A dummy id pointing at the start of audio codecs    AV_CODEC_ID_PCM_S16LE = 0x10000,    AV_CODEC_ID_PCM_S16BE,    AV_CODEC_ID_PCM_U16LE,    AV_CODEC_ID_PCM_U16BE,    AV_CODEC_ID_PCM_S8,    AV_CODEC_ID_PCM_U8,    AV_CODEC_ID_PCM_MULAW,    AV_CODEC_ID_PCM_ALAW,    AV_CODEC_ID_PCM_S32LE,    AV_CODEC_ID_PCM_S32BE,    AV_CODEC_ID_PCM_U32LE,    AV_CODEC_ID_PCM_U32BE,    AV_CODEC_ID_PCM_S24LE,    AV_CODEC_ID_PCM_S24BE,    AV_CODEC_ID_PCM_U24LE,    AV_CODEC_ID_PCM_U24BE,    AV_CODEC_ID_PCM_S24DAUD,    AV_CODEC_ID_PCM_ZORK,    AV_CODEC_ID_PCM_S16LE_PLANAR,    AV_CODEC_ID_PCM_DVD,    AV_CODEC_ID_PCM_F32BE,    AV_CODEC_ID_PCM_F32LE,    AV_CODEC_ID_PCM_F64BE,    AV_CODEC_ID_PCM_F64LE,    AV_CODEC_ID_PCM_BLURAY,    AV_CODEC_ID_PCM_LXF,    AV_CODEC_ID_S302M,    AV_CODEC_ID_PCM_S8_PLANAR,    AV_CODEC_ID_PCM_S24LE_PLANAR,    AV_CODEC_ID_PCM_S32LE_PLANAR,    AV_CODEC_ID_PCM_S16BE_PLANAR,     AV_CODEC_ID_PCM_S64LE = 0x10800,    AV_CODEC_ID_PCM_S64BE,    AV_CODEC_ID_PCM_F16LE,    AV_CODEC_ID_PCM_F24LE,     /* various ADPCM codecs */    AV_CODEC_ID_ADPCM_IMA_QT = 0x11000,    AV_CODEC_ID_ADPCM_IMA_WAV,    AV_CODEC_ID_ADPCM_IMA_DK3,    AV_CODEC_ID_ADPCM_IMA_DK4,    AV_CODEC_ID_ADPCM_IMA_WS,    AV_CODEC_ID_ADPCM_IMA_SMJPEG,    AV_CODEC_ID_ADPCM_MS,    AV_CODEC_ID_ADPCM_4XM,    AV_CODEC_ID_ADPCM_XA,    AV_CODEC_ID_ADPCM_ADX,    AV_CODEC_ID_ADPCM_EA,

Lines 1–500 of 6387.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t