Path: blob/master/dep/ffmpeg/include/libavcodec/codec.h
4216 views
/*1* AVCodec public API2*3* This file is part of FFmpeg.4*5* FFmpeg is free software; you can redistribute it and/or6* modify it under the terms of the GNU Lesser General Public7* License as published by the Free Software Foundation; either8* version 2.1 of the License, or (at your option) any later version.9*10* FFmpeg is distributed in the hope that it will be useful,11* but WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU13* Lesser General Public License for more details.14*15* You should have received a copy of the GNU Lesser General Public16* License along with FFmpeg; if not, write to the Free Software17* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA18*/1920#ifndef AVCODEC_CODEC_H21#define AVCODEC_CODEC_H2223#include <stdint.h>2425#include "libavutil/avutil.h"26#include "libavutil/hwcontext.h"27#include "libavutil/log.h"28#include "libavutil/pixfmt.h"29#include "libavutil/rational.h"30#include "libavutil/samplefmt.h"3132#include "libavcodec/codec_id.h"33#include "libavcodec/version_major.h"3435/**36* @addtogroup lavc_core37* @{38*/3940/**41* Decoder can use draw_horiz_band callback.42*/43#define AV_CODEC_CAP_DRAW_HORIZ_BAND (1 << 0)44/**45* Codec uses get_buffer() or get_encode_buffer() for allocating buffers and46* supports custom allocators.47* If not set, it might not use get_buffer() or get_encode_buffer() at all, or48* use operations that assume the buffer was allocated by49* avcodec_default_get_buffer2 or avcodec_default_get_encode_buffer.50*/51#define AV_CODEC_CAP_DR1 (1 << 1)52/**53* Encoder or decoder requires flushing with NULL input at the end in order to54* give the complete and correct output.55*56* NOTE: If this flag is not set, the codec is guaranteed to never be fed with57* with NULL data. The user can still send NULL data to the public encode58* or decode function, but libavcodec will not pass it along to the codec59* unless this flag is set.60*61* Decoders:62* The decoder has a non-zero delay and needs to be fed with avpkt->data=NULL,63* avpkt->size=0 at the end to get the delayed data until the decoder no longer64* returns frames.65*66* Encoders:67* The encoder needs to be fed with NULL data at the end of encoding until the68* encoder no longer returns data.69*70* NOTE: For encoders implementing the AVCodec.encode2() function, setting this71* flag also means that the encoder must set the pts and duration for72* each output packet. If this flag is not set, the pts and duration will73* be determined by libavcodec from the input frame.74*/75#define AV_CODEC_CAP_DELAY (1 << 5)76/**77* Codec can be fed a final frame with a smaller size.78* This can be used to prevent truncation of the last audio samples.79*/80#define AV_CODEC_CAP_SMALL_LAST_FRAME (1 << 6)8182#if FF_API_SUBFRAMES83/**84* Codec can output multiple frames per AVPacket85* Normally demuxers return one frame at a time, demuxers which do not do86* are connected to a parser to split what they return into proper frames.87* This flag is reserved to the very rare category of codecs which have a88* bitstream that cannot be split into frames without timeconsuming89* operations like full decoding. Demuxers carrying such bitstreams thus90* may return multiple frames in a packet. This has many disadvantages like91* prohibiting stream copy in many cases thus it should only be considered92* as a last resort.93*/94#define AV_CODEC_CAP_SUBFRAMES (1 << 8)95#endif9697/**98* Codec is experimental and is thus avoided in favor of non experimental99* encoders100*/101#define AV_CODEC_CAP_EXPERIMENTAL (1 << 9)102/**103* Codec should fill in channel configuration and samplerate instead of container104*/105#define AV_CODEC_CAP_CHANNEL_CONF (1 << 10)106/**107* Codec supports frame-level multithreading.108*/109#define AV_CODEC_CAP_FRAME_THREADS (1 << 12)110/**111* Codec supports slice-based (or partition-based) multithreading.112*/113#define AV_CODEC_CAP_SLICE_THREADS (1 << 13)114/**115* Codec supports changed parameters at any point.116*/117#define AV_CODEC_CAP_PARAM_CHANGE (1 << 14)118/**119* Codec supports multithreading through a method other than slice- or120* frame-level multithreading. Typically this marks wrappers around121* multithreading-capable external libraries.122*/123#define AV_CODEC_CAP_OTHER_THREADS (1 << 15)124/**125* Audio encoder supports receiving a different number of samples in each call.126*/127#define AV_CODEC_CAP_VARIABLE_FRAME_SIZE (1 << 16)128/**129* Decoder is not a preferred choice for probing.130* This indicates that the decoder is not a good choice for probing.131* It could for example be an expensive to spin up hardware decoder,132* or it could simply not provide a lot of useful information about133* the stream.134* A decoder marked with this flag should only be used as last resort135* choice for probing.136*/137#define AV_CODEC_CAP_AVOID_PROBING (1 << 17)138139/**140* Codec is backed by a hardware implementation. Typically used to141* identify a non-hwaccel hardware decoder. For information about hwaccels, use142* avcodec_get_hw_config() instead.143*/144#define AV_CODEC_CAP_HARDWARE (1 << 18)145146/**147* Codec is potentially backed by a hardware implementation, but not148* necessarily. This is used instead of AV_CODEC_CAP_HARDWARE, if the149* implementation provides some sort of internal fallback.150*/151#define AV_CODEC_CAP_HYBRID (1 << 19)152153/**154* This encoder can reorder user opaque values from input AVFrames and return155* them with corresponding output packets.156* @see AV_CODEC_FLAG_COPY_OPAQUE157*/158#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE (1 << 20)159160/**161* This encoder can be flushed using avcodec_flush_buffers(). If this flag is162* not set, the encoder must be closed and reopened to ensure that no frames163* remain pending.164*/165#define AV_CODEC_CAP_ENCODER_FLUSH (1 << 21)166167/**168* The encoder is able to output reconstructed frame data, i.e. raw frames that169* would be produced by decoding the encoded bitstream.170*171* Reconstructed frame output is enabled by the AV_CODEC_FLAG_RECON_FRAME flag.172*/173#define AV_CODEC_CAP_ENCODER_RECON_FRAME (1 << 22)174175/**176* AVProfile.177*/178typedef struct AVProfile {179int profile;180const char *name; ///< short name for the profile181} AVProfile;182183/**184* AVCodec.185*/186typedef struct AVCodec {187/**188* Name of the codec implementation.189* The name is globally unique among encoders and among decoders (but an190* encoder and a decoder can share the same name).191* This is the primary way to find a codec from the user perspective.192*/193const char *name;194/**195* Descriptive name for the codec, meant to be more human readable than name.196* You should use the NULL_IF_CONFIG_SMALL() macro to define it.197*/198const char *long_name;199enum AVMediaType type;200enum AVCodecID id;201/**202* Codec capabilities.203* see AV_CODEC_CAP_*204*/205int capabilities;206uint8_t max_lowres; ///< maximum value for lowres supported by the decoder207208/**209* Deprecated codec capabilities.210*/211attribute_deprecated212const AVRational *supported_framerates; ///< @deprecated use avcodec_get_supported_config()213attribute_deprecated214const enum AVPixelFormat *pix_fmts; ///< @deprecated use avcodec_get_supported_config()215attribute_deprecated216const int *supported_samplerates; ///< @deprecated use avcodec_get_supported_config()217attribute_deprecated218const enum AVSampleFormat *sample_fmts; ///< @deprecated use avcodec_get_supported_config()219220const AVClass *priv_class; ///< AVClass for the private context221const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {AV_PROFILE_UNKNOWN}222223/**224* Group name of the codec implementation.225* This is a short symbolic name of the wrapper backing this codec. A226* wrapper uses some kind of external implementation for the codec, such227* as an external library, or a codec implementation provided by the OS or228* the hardware.229* If this field is NULL, this is a builtin, libavcodec native codec.230* If non-NULL, this will be the suffix in AVCodec.name in most cases231* (usually AVCodec.name will be of the form "<codec_name>_<wrapper_name>").232*/233const char *wrapper_name;234235/**236* Array of supported channel layouts, terminated with a zeroed layout.237* @deprecated use avcodec_get_supported_config()238*/239attribute_deprecated240const AVChannelLayout *ch_layouts;241} AVCodec;242243/**244* Iterate over all registered codecs.245*246* @param opaque a pointer where libavcodec will store the iteration state. Must247* point to NULL to start the iteration.248*249* @return the next registered codec or NULL when the iteration is250* finished251*/252const AVCodec *av_codec_iterate(void **opaque);253254/**255* Find a registered decoder with a matching codec ID.256*257* @param id AVCodecID of the requested decoder258* @return A decoder if one was found, NULL otherwise.259*/260const AVCodec *avcodec_find_decoder(enum AVCodecID id);261262/**263* Find a registered decoder with the specified name.264*265* @param name name of the requested decoder266* @return A decoder if one was found, NULL otherwise.267*/268const AVCodec *avcodec_find_decoder_by_name(const char *name);269270/**271* Find a registered encoder with a matching codec ID.272*273* @param id AVCodecID of the requested encoder274* @return An encoder if one was found, NULL otherwise.275*/276const AVCodec *avcodec_find_encoder(enum AVCodecID id);277278/**279* Find a registered encoder with the specified name.280*281* @param name name of the requested encoder282* @return An encoder if one was found, NULL otherwise.283*/284const AVCodec *avcodec_find_encoder_by_name(const char *name);285/**286* @return a non-zero number if codec is an encoder, zero otherwise287*/288int av_codec_is_encoder(const AVCodec *codec);289290/**291* @return a non-zero number if codec is a decoder, zero otherwise292*/293int av_codec_is_decoder(const AVCodec *codec);294295/**296* Return a name for the specified profile, if available.297*298* @param codec the codec that is searched for the given profile299* @param profile the profile value for which a name is requested300* @return A name for the profile if found, NULL otherwise.301*/302const char *av_get_profile_name(const AVCodec *codec, int profile);303304enum {305/**306* The codec supports this format via the hw_device_ctx interface.307*308* When selecting this format, AVCodecContext.hw_device_ctx should309* have been set to a device of the specified type before calling310* avcodec_open2().311*/312AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX = 0x01,313/**314* The codec supports this format via the hw_frames_ctx interface.315*316* When selecting this format for a decoder,317* AVCodecContext.hw_frames_ctx should be set to a suitable frames318* context inside the get_format() callback. The frames context319* must have been created on a device of the specified type.320*321* When selecting this format for an encoder,322* AVCodecContext.hw_frames_ctx should be set to the context which323* will be used for the input frames before calling avcodec_open2().324*/325AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX = 0x02,326/**327* The codec supports this format by some internal method.328*329* This format can be selected without any additional configuration -330* no device or frames context is required.331*/332AV_CODEC_HW_CONFIG_METHOD_INTERNAL = 0x04,333/**334* The codec supports this format by some ad-hoc method.335*336* Additional settings and/or function calls are required. See the337* codec-specific documentation for details. (Methods requiring338* this sort of configuration are deprecated and others should be339* used in preference.)340*/341AV_CODEC_HW_CONFIG_METHOD_AD_HOC = 0x08,342};343344typedef struct AVCodecHWConfig {345/**346* For decoders, a hardware pixel format which that decoder may be347* able to decode to if suitable hardware is available.348*349* For encoders, a pixel format which the encoder may be able to350* accept. If set to AV_PIX_FMT_NONE, this applies to all pixel351* formats supported by the codec.352*/353enum AVPixelFormat pix_fmt;354/**355* Bit set of AV_CODEC_HW_CONFIG_METHOD_* flags, describing the possible356* setup methods which can be used with this configuration.357*/358int methods;359/**360* The device type associated with the configuration.361*362* Must be set for AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX and363* AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX, otherwise unused.364*/365enum AVHWDeviceType device_type;366} AVCodecHWConfig;367368/**369* Retrieve supported hardware configurations for a codec.370*371* Values of index from zero to some maximum return the indexed configuration372* descriptor; all other values return NULL. If the codec does not support373* any hardware configurations then it will always return NULL.374*/375const AVCodecHWConfig *avcodec_get_hw_config(const AVCodec *codec, int index);376377/**378* @}379*/380381#endif /* AVCODEC_CODEC_H */382383384