Path: blob/a-new-beginning/libavcodec.xcframework/ios-arm64-simulator/libavcodec.framework/Headers/codec.h
2 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/**83* Codec can output multiple frames per AVPacket84* Normally demuxers return one frame at a time, demuxers which do not do85* are connected to a parser to split what they return into proper frames.86* This flag is reserved to the very rare category of codecs which have a87* bitstream that cannot be split into frames without timeconsuming88* operations like full decoding. Demuxers carrying such bitstreams thus89* may return multiple frames in a packet. This has many disadvantages like90* prohibiting stream copy in many cases thus it should only be considered91* as a last resort.92*/93#define AV_CODEC_CAP_SUBFRAMES (1 << 8)94/**95* Codec is experimental and is thus avoided in favor of non experimental96* encoders97*/98#define AV_CODEC_CAP_EXPERIMENTAL (1 << 9)99/**100* Codec should fill in channel configuration and samplerate instead of container101*/102#define AV_CODEC_CAP_CHANNEL_CONF (1 << 10)103/**104* Codec supports frame-level multithreading.105*/106#define AV_CODEC_CAP_FRAME_THREADS (1 << 12)107/**108* Codec supports slice-based (or partition-based) multithreading.109*/110#define AV_CODEC_CAP_SLICE_THREADS (1 << 13)111/**112* Codec supports changed parameters at any point.113*/114#define AV_CODEC_CAP_PARAM_CHANGE (1 << 14)115/**116* Codec supports multithreading through a method other than slice- or117* frame-level multithreading. Typically this marks wrappers around118* multithreading-capable external libraries.119*/120#define AV_CODEC_CAP_OTHER_THREADS (1 << 15)121/**122* Audio encoder supports receiving a different number of samples in each call.123*/124#define AV_CODEC_CAP_VARIABLE_FRAME_SIZE (1 << 16)125/**126* Decoder is not a preferred choice for probing.127* This indicates that the decoder is not a good choice for probing.128* It could for example be an expensive to spin up hardware decoder,129* or it could simply not provide a lot of useful information about130* the stream.131* A decoder marked with this flag should only be used as last resort132* choice for probing.133*/134#define AV_CODEC_CAP_AVOID_PROBING (1 << 17)135136/**137* Codec is backed by a hardware implementation. Typically used to138* identify a non-hwaccel hardware decoder. For information about hwaccels, use139* avcodec_get_hw_config() instead.140*/141#define AV_CODEC_CAP_HARDWARE (1 << 18)142143/**144* Codec is potentially backed by a hardware implementation, but not145* necessarily. This is used instead of AV_CODEC_CAP_HARDWARE, if the146* implementation provides some sort of internal fallback.147*/148#define AV_CODEC_CAP_HYBRID (1 << 19)149150/**151* This encoder can reorder user opaque values from input AVFrames and return152* them with corresponding output packets.153* @see AV_CODEC_FLAG_COPY_OPAQUE154*/155#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE (1 << 20)156157/**158* This encoder can be flushed using avcodec_flush_buffers(). If this flag is159* not set, the encoder must be closed and reopened to ensure that no frames160* remain pending.161*/162#define AV_CODEC_CAP_ENCODER_FLUSH (1 << 21)163164/**165* The encoder is able to output reconstructed frame data, i.e. raw frames that166* would be produced by decoding the encoded bitstream.167*168* Reconstructed frame output is enabled by the AV_CODEC_FLAG_RECON_FRAME flag.169*/170#define AV_CODEC_CAP_ENCODER_RECON_FRAME (1 << 22)171172/**173* AVProfile.174*/175typedef struct AVProfile {176int profile;177const char *name; ///< short name for the profile178} AVProfile;179180/**181* AVCodec.182*/183typedef struct AVCodec {184/**185* Name of the codec implementation.186* The name is globally unique among encoders and among decoders (but an187* encoder and a decoder can share the same name).188* This is the primary way to find a codec from the user perspective.189*/190const char *name;191/**192* Descriptive name for the codec, meant to be more human readable than name.193* You should use the NULL_IF_CONFIG_SMALL() macro to define it.194*/195const char *long_name;196enum AVMediaType type;197enum AVCodecID id;198/**199* Codec capabilities.200* see AV_CODEC_CAP_*201*/202int capabilities;203uint8_t max_lowres; ///< maximum value for lowres supported by the decoder204const AVRational *supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0}205const enum AVPixelFormat *pix_fmts; ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1206const int *supported_samplerates; ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0207const enum AVSampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1208#if FF_API_OLD_CHANNEL_LAYOUT209/**210* @deprecated use ch_layouts instead211*/212attribute_deprecated213const uint64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0214#endif215const AVClass *priv_class; ///< AVClass for the private context216const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}217218/**219* Group name of the codec implementation.220* This is a short symbolic name of the wrapper backing this codec. A221* wrapper uses some kind of external implementation for the codec, such222* as an external library, or a codec implementation provided by the OS or223* the hardware.224* If this field is NULL, this is a builtin, libavcodec native codec.225* If non-NULL, this will be the suffix in AVCodec.name in most cases226* (usually AVCodec.name will be of the form "<codec_name>_<wrapper_name>").227*/228const char *wrapper_name;229230/**231* Array of supported channel layouts, terminated with a zeroed layout.232*/233const AVChannelLayout *ch_layouts;234} AVCodec;235236/**237* Iterate over all registered codecs.238*239* @param opaque a pointer where libavcodec will store the iteration state. Must240* point to NULL to start the iteration.241*242* @return the next registered codec or NULL when the iteration is243* finished244*/245const AVCodec *av_codec_iterate(void **opaque);246247/**248* Find a registered decoder with a matching codec ID.249*250* @param id AVCodecID of the requested decoder251* @return A decoder if one was found, NULL otherwise.252*/253const AVCodec *avcodec_find_decoder(enum AVCodecID id);254255/**256* Find a registered decoder with the specified name.257*258* @param name name of the requested decoder259* @return A decoder if one was found, NULL otherwise.260*/261const AVCodec *avcodec_find_decoder_by_name(const char *name);262263/**264* Find a registered encoder with a matching codec ID.265*266* @param id AVCodecID of the requested encoder267* @return An encoder if one was found, NULL otherwise.268*/269const AVCodec *avcodec_find_encoder(enum AVCodecID id);270271/**272* Find a registered encoder with the specified name.273*274* @param name name of the requested encoder275* @return An encoder if one was found, NULL otherwise.276*/277const AVCodec *avcodec_find_encoder_by_name(const char *name);278/**279* @return a non-zero number if codec is an encoder, zero otherwise280*/281int av_codec_is_encoder(const AVCodec *codec);282283/**284* @return a non-zero number if codec is a decoder, zero otherwise285*/286int av_codec_is_decoder(const AVCodec *codec);287288/**289* Return a name for the specified profile, if available.290*291* @param codec the codec that is searched for the given profile292* @param profile the profile value for which a name is requested293* @return A name for the profile if found, NULL otherwise.294*/295const char *av_get_profile_name(const AVCodec *codec, int profile);296297enum {298/**299* The codec supports this format via the hw_device_ctx interface.300*301* When selecting this format, AVCodecContext.hw_device_ctx should302* have been set to a device of the specified type before calling303* avcodec_open2().304*/305AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX = 0x01,306/**307* The codec supports this format via the hw_frames_ctx interface.308*309* When selecting this format for a decoder,310* AVCodecContext.hw_frames_ctx should be set to a suitable frames311* context inside the get_format() callback. The frames context312* must have been created on a device of the specified type.313*314* When selecting this format for an encoder,315* AVCodecContext.hw_frames_ctx should be set to the context which316* will be used for the input frames before calling avcodec_open2().317*/318AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX = 0x02,319/**320* The codec supports this format by some internal method.321*322* This format can be selected without any additional configuration -323* no device or frames context is required.324*/325AV_CODEC_HW_CONFIG_METHOD_INTERNAL = 0x04,326/**327* The codec supports this format by some ad-hoc method.328*329* Additional settings and/or function calls are required. See the330* codec-specific documentation for details. (Methods requiring331* this sort of configuration are deprecated and others should be332* used in preference.)333*/334AV_CODEC_HW_CONFIG_METHOD_AD_HOC = 0x08,335};336337typedef struct AVCodecHWConfig {338/**339* For decoders, a hardware pixel format which that decoder may be340* able to decode to if suitable hardware is available.341*342* For encoders, a pixel format which the encoder may be able to343* accept. If set to AV_PIX_FMT_NONE, this applies to all pixel344* formats supported by the codec.345*/346enum AVPixelFormat pix_fmt;347/**348* Bit set of AV_CODEC_HW_CONFIG_METHOD_* flags, describing the possible349* setup methods which can be used with this configuration.350*/351int methods;352/**353* The device type associated with the configuration.354*355* Must be set for AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX and356* AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX, otherwise unused.357*/358enum AVHWDeviceType device_type;359} AVCodecHWConfig;360361/**362* Retrieve supported hardware configurations for a codec.363*364* Values of index from zero to some maximum return the indexed configuration365* descriptor; all other values return NULL. If the codec does not support366* any hardware configurations then it will always return NULL.367*/368const AVCodecHWConfig *avcodec_get_hw_config(const AVCodec *codec, int index);369370/**371* @}372*/373374#endif /* AVCODEC_CODEC_H */375376377