Path: blob/master/dep/ffmpeg/include/libavcodec/codec.h
7410 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 is experimental and is thus avoided in favor of non experimental84* encoders85*/86#define AV_CODEC_CAP_EXPERIMENTAL (1 << 9)87/**88* Codec should fill in channel configuration and samplerate instead of container89*/90#define AV_CODEC_CAP_CHANNEL_CONF (1 << 10)91/**92* Codec supports frame-level multithreading.93*/94#define AV_CODEC_CAP_FRAME_THREADS (1 << 12)95/**96* Codec supports slice-based (or partition-based) multithreading.97*/98#define AV_CODEC_CAP_SLICE_THREADS (1 << 13)99/**100* Codec supports changed parameters at any point.101*/102#define AV_CODEC_CAP_PARAM_CHANGE (1 << 14)103/**104* Codec supports multithreading through a method other than slice- or105* frame-level multithreading. Typically this marks wrappers around106* multithreading-capable external libraries.107*/108#define AV_CODEC_CAP_OTHER_THREADS (1 << 15)109/**110* Audio encoder supports receiving a different number of samples in each call.111*/112#define AV_CODEC_CAP_VARIABLE_FRAME_SIZE (1 << 16)113/**114* Decoder is not a preferred choice for probing.115* This indicates that the decoder is not a good choice for probing.116* It could for example be an expensive to spin up hardware decoder,117* or it could simply not provide a lot of useful information about118* the stream.119* A decoder marked with this flag should only be used as last resort120* choice for probing.121*/122#define AV_CODEC_CAP_AVOID_PROBING (1 << 17)123124/**125* Codec is backed by a hardware implementation. Typically used to126* identify a non-hwaccel hardware decoder. For information about hwaccels, use127* avcodec_get_hw_config() instead.128*/129#define AV_CODEC_CAP_HARDWARE (1 << 18)130131/**132* Codec is potentially backed by a hardware implementation, but not133* necessarily. This is used instead of AV_CODEC_CAP_HARDWARE, if the134* implementation provides some sort of internal fallback.135*/136#define AV_CODEC_CAP_HYBRID (1 << 19)137138/**139* This encoder can reorder user opaque values from input AVFrames and return140* them with corresponding output packets.141* @see AV_CODEC_FLAG_COPY_OPAQUE142*/143#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE (1 << 20)144145/**146* This encoder can be flushed using avcodec_flush_buffers(). If this flag is147* not set, the encoder must be closed and reopened to ensure that no frames148* remain pending.149*/150#define AV_CODEC_CAP_ENCODER_FLUSH (1 << 21)151152/**153* The encoder is able to output reconstructed frame data, i.e. raw frames that154* would be produced by decoding the encoded bitstream.155*156* Reconstructed frame output is enabled by the AV_CODEC_FLAG_RECON_FRAME flag.157*/158#define AV_CODEC_CAP_ENCODER_RECON_FRAME (1 << 22)159160/**161* AVProfile.162*/163typedef struct AVProfile {164int profile;165const char *name; ///< short name for the profile166} AVProfile;167168/**169* AVCodec.170*/171typedef struct AVCodec {172/**173* Name of the codec implementation.174* The name is globally unique among encoders and among decoders (but an175* encoder and a decoder can share the same name).176* This is the primary way to find a codec from the user perspective.177*/178const char *name;179/**180* Descriptive name for the codec, meant to be more human readable than name.181* You should use the NULL_IF_CONFIG_SMALL() macro to define it.182*/183const char *long_name;184enum AVMediaType type;185enum AVCodecID id;186/**187* Codec capabilities.188* see AV_CODEC_CAP_*189*/190int capabilities;191uint8_t max_lowres; ///< maximum value for lowres supported by the decoder192193/**194* Deprecated codec capabilities.195*/196attribute_deprecated197const AVRational *supported_framerates; ///< @deprecated use avcodec_get_supported_config()198attribute_deprecated199const enum AVPixelFormat *pix_fmts; ///< @deprecated use avcodec_get_supported_config()200attribute_deprecated201const int *supported_samplerates; ///< @deprecated use avcodec_get_supported_config()202attribute_deprecated203const enum AVSampleFormat *sample_fmts; ///< @deprecated use avcodec_get_supported_config()204205const AVClass *priv_class; ///< AVClass for the private context206const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {AV_PROFILE_UNKNOWN}207208/**209* Group name of the codec implementation.210* This is a short symbolic name of the wrapper backing this codec. A211* wrapper uses some kind of external implementation for the codec, such212* as an external library, or a codec implementation provided by the OS or213* the hardware.214* If this field is NULL, this is a builtin, libavcodec native codec.215* If non-NULL, this will be the suffix in AVCodec.name in most cases216* (usually AVCodec.name will be of the form "<codec_name>_<wrapper_name>").217*/218const char *wrapper_name;219220/**221* Array of supported channel layouts, terminated with a zeroed layout.222* @deprecated use avcodec_get_supported_config()223*/224attribute_deprecated225const AVChannelLayout *ch_layouts;226} AVCodec;227228/**229* Iterate over all registered codecs.230*231* @param opaque a pointer where libavcodec will store the iteration state. Must232* point to NULL to start the iteration.233*234* @return the next registered codec or NULL when the iteration is235* finished236*/237const AVCodec *av_codec_iterate(void **opaque);238239/**240* Find a registered decoder with a matching codec ID.241*242* @param id AVCodecID of the requested decoder243* @return A decoder if one was found, NULL otherwise.244*/245const AVCodec *avcodec_find_decoder(enum AVCodecID id);246247/**248* Find a registered decoder with the specified name.249*250* @param name name of the requested decoder251* @return A decoder if one was found, NULL otherwise.252*/253const AVCodec *avcodec_find_decoder_by_name(const char *name);254255/**256* Find a registered encoder with a matching codec ID.257*258* @param id AVCodecID of the requested encoder259* @return An encoder if one was found, NULL otherwise.260*/261const AVCodec *avcodec_find_encoder(enum AVCodecID id);262263/**264* Find a registered encoder with the specified name.265*266* @param name name of the requested encoder267* @return An encoder if one was found, NULL otherwise.268*/269const AVCodec *avcodec_find_encoder_by_name(const char *name);270/**271* @return a non-zero number if codec is an encoder, zero otherwise272*/273int av_codec_is_encoder(const AVCodec *codec);274275/**276* @return a non-zero number if codec is a decoder, zero otherwise277*/278int av_codec_is_decoder(const AVCodec *codec);279280/**281* Return a name for the specified profile, if available.282*283* @param codec the codec that is searched for the given profile284* @param profile the profile value for which a name is requested285* @return A name for the profile if found, NULL otherwise.286*/287const char *av_get_profile_name(const AVCodec *codec, int profile);288289enum {290/**291* The codec supports this format via the hw_device_ctx interface.292*293* When selecting this format, AVCodecContext.hw_device_ctx should294* have been set to a device of the specified type before calling295* avcodec_open2().296*/297AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX = 0x01,298/**299* The codec supports this format via the hw_frames_ctx interface.300*301* When selecting this format for a decoder,302* AVCodecContext.hw_frames_ctx should be set to a suitable frames303* context inside the get_format() callback. The frames context304* must have been created on a device of the specified type.305*306* When selecting this format for an encoder,307* AVCodecContext.hw_frames_ctx should be set to the context which308* will be used for the input frames before calling avcodec_open2().309*/310AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX = 0x02,311/**312* The codec supports this format by some internal method.313*314* This format can be selected without any additional configuration -315* no device or frames context is required.316*/317AV_CODEC_HW_CONFIG_METHOD_INTERNAL = 0x04,318/**319* The codec supports this format by some ad-hoc method.320*321* Additional settings and/or function calls are required. See the322* codec-specific documentation for details. (Methods requiring323* this sort of configuration are deprecated and others should be324* used in preference.)325*/326AV_CODEC_HW_CONFIG_METHOD_AD_HOC = 0x08,327};328329typedef struct AVCodecHWConfig {330/**331* For decoders, a hardware pixel format which that decoder may be332* able to decode to if suitable hardware is available.333*334* For encoders, a pixel format which the encoder may be able to335* accept. If set to AV_PIX_FMT_NONE, this applies to all pixel336* formats supported by the codec.337*/338enum AVPixelFormat pix_fmt;339/**340* Bit set of AV_CODEC_HW_CONFIG_METHOD_* flags, describing the possible341* setup methods which can be used with this configuration.342*/343int methods;344/**345* The device type associated with the configuration.346*347* Must be set for AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX and348* AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX, otherwise unused.349*/350enum AVHWDeviceType device_type;351} AVCodecHWConfig;352353/**354* Retrieve supported hardware configurations for a codec.355*356* Values of index from zero to some maximum return the indexed configuration357* descriptor; all other values return NULL. If the codec does not support358* any hardware configurations then it will always return NULL.359*/360const AVCodecHWConfig *avcodec_get_hw_config(const AVCodec *codec, int index);361362/**363* @}364*/365366#endif /* AVCODEC_CODEC_H */367368369