Path: blob/master/dep/ffmpeg/include/libavcodec/avcodec.h
4216 views
/*1* copyright (c) 2001 Fabrice Bellard2*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_AVCODEC_H21#define AVCODEC_AVCODEC_H2223/**24* @file25* @ingroup libavc26* Libavcodec external API header27*/2829#include "libavutil/samplefmt.h"30#include "libavutil/attributes.h"31#include "libavutil/avutil.h"32#include "libavutil/buffer.h"33#include "libavutil/channel_layout.h"34#include "libavutil/dict.h"35#include "libavutil/frame.h"36#include "libavutil/log.h"37#include "libavutil/pixfmt.h"38#include "libavutil/rational.h"3940#include "codec.h"41#include "codec_id.h"42#include "defs.h"43#include "packet.h"44#include "version_major.h"45#ifndef HAVE_AV_CONFIG_H46/* When included as part of the ffmpeg build, only include the major version47* to avoid unnecessary rebuilds. When included externally, keep including48* the full version information. */49#include "version.h"5051#include "codec_desc.h"52#include "codec_par.h"53#endif5455struct AVCodecParameters;5657/**58* @defgroup libavc libavcodec59* Encoding/Decoding Library60*61* @{62*63* @defgroup lavc_decoding Decoding64* @{65* @}66*67* @defgroup lavc_encoding Encoding68* @{69* @}70*71* @defgroup lavc_codec Codecs72* @{73* @defgroup lavc_codec_native Native Codecs74* @{75* @}76* @defgroup lavc_codec_wrappers External library wrappers77* @{78* @}79* @defgroup lavc_codec_hwaccel Hardware Accelerators bridge80* @{81* @}82* @}83* @defgroup lavc_internal Internal84* @{85* @}86* @}87*/8889/**90* @ingroup libavc91* @defgroup lavc_encdec send/receive encoding and decoding API overview92* @{93*94* The avcodec_send_packet()/avcodec_receive_frame()/avcodec_send_frame()/95* avcodec_receive_packet() functions provide an encode/decode API, which96* decouples input and output.97*98* The API is very similar for encoding/decoding and audio/video, and works as99* follows:100* - Set up and open the AVCodecContext as usual.101* - Send valid input:102* - For decoding, call avcodec_send_packet() to give the decoder raw103* compressed data in an AVPacket.104* - For encoding, call avcodec_send_frame() to give the encoder an AVFrame105* containing uncompressed audio or video.106*107* In both cases, it is recommended that AVPackets and AVFrames are108* refcounted, or libavcodec might have to copy the input data. (libavformat109* always returns refcounted AVPackets, and av_frame_get_buffer() allocates110* refcounted AVFrames.)111* - Receive output in a loop. Periodically call one of the avcodec_receive_*()112* functions and process their output:113* - For decoding, call avcodec_receive_frame(). On success, it will return114* an AVFrame containing uncompressed audio or video data.115* - For encoding, call avcodec_receive_packet(). On success, it will return116* an AVPacket with a compressed frame.117*118* Repeat this call until it returns AVERROR(EAGAIN) or an error. The119* AVERROR(EAGAIN) return value means that new input data is required to120* return new output. In this case, continue with sending input. For each121* input frame/packet, the codec will typically return 1 output frame/packet,122* but it can also be 0 or more than 1.123*124* At the beginning of decoding or encoding, the codec might accept multiple125* input frames/packets without returning a frame, until its internal buffers126* are filled. This situation is handled transparently if you follow the steps127* outlined above.128*129* In theory, sending input can result in EAGAIN - this should happen only if130* not all output was received. You can use this to structure alternative decode131* or encode loops other than the one suggested above. For example, you could132* try sending new input on each iteration, and try to receive output if that133* returns EAGAIN.134*135* End of stream situations. These require "flushing" (aka draining) the codec,136* as the codec might buffer multiple frames or packets internally for137* performance or out of necessity (consider B-frames).138* This is handled as follows:139* - Instead of valid input, send NULL to the avcodec_send_packet() (decoding)140* or avcodec_send_frame() (encoding) functions. This will enter draining141* mode.142* - Call avcodec_receive_frame() (decoding) or avcodec_receive_packet()143* (encoding) in a loop until AVERROR_EOF is returned. The functions will144* not return AVERROR(EAGAIN), unless you forgot to enter draining mode.145* - Before decoding can be resumed again, the codec has to be reset with146* avcodec_flush_buffers().147*148* Using the API as outlined above is highly recommended. But it is also149* possible to call functions outside of this rigid schema. For example, you can150* call avcodec_send_packet() repeatedly without calling151* avcodec_receive_frame(). In this case, avcodec_send_packet() will succeed152* until the codec's internal buffer has been filled up (which is typically of153* size 1 per output frame, after initial input), and then reject input with154* AVERROR(EAGAIN). Once it starts rejecting input, you have no choice but to155* read at least some output.156*157* Not all codecs will follow a rigid and predictable dataflow; the only158* guarantee is that an AVERROR(EAGAIN) return value on a send/receive call on159* one end implies that a receive/send call on the other end will succeed, or160* at least will not fail with AVERROR(EAGAIN). In general, no codec will161* permit unlimited buffering of input or output.162*163* A codec is not allowed to return AVERROR(EAGAIN) for both sending and receiving. This164* would be an invalid state, which could put the codec user into an endless165* loop. The API has no concept of time either: it cannot happen that trying to166* do avcodec_send_packet() results in AVERROR(EAGAIN), but a repeated call 1 second167* later accepts the packet (with no other receive/flush API calls involved).168* The API is a strict state machine, and the passage of time is not supposed169* to influence it. Some timing-dependent behavior might still be deemed170* acceptable in certain cases. But it must never result in both send/receive171* returning EAGAIN at the same time at any point. It must also absolutely be172* avoided that the current state is "unstable" and can "flip-flop" between173* the send/receive APIs allowing progress. For example, it's not allowed that174* the codec randomly decides that it actually wants to consume a packet now175* instead of returning a frame, after it just returned AVERROR(EAGAIN) on an176* avcodec_send_packet() call.177* @}178*/179180/**181* @defgroup lavc_core Core functions/structures.182* @ingroup libavc183*184* Basic definitions, functions for querying libavcodec capabilities,185* allocating core structures, etc.186* @{187*/188189#if FF_API_BUFFER_MIN_SIZE190/**191* @ingroup lavc_encoding192* minimum encoding buffer size193* Used to avoid some checks during header writing.194* @deprecated Unused: avcodec_receive_packet() does not work195* with preallocated packet buffers.196*/197#define AV_INPUT_BUFFER_MIN_SIZE 16384198#endif199200/**201* @ingroup lavc_encoding202*/203typedef struct RcOverride{204int start_frame;205int end_frame;206int qscale; // If this is 0 then quality_factor will be used instead.207float quality_factor;208} RcOverride;209210/* encoding support211These flags can be passed in AVCodecContext.flags before initialization.212Note: Not everything is supported yet.213*/214215/**216* Allow decoders to produce frames with data planes that are not aligned217* to CPU requirements (e.g. due to cropping).218*/219#define AV_CODEC_FLAG_UNALIGNED (1 << 0)220/**221* Use fixed qscale.222*/223#define AV_CODEC_FLAG_QSCALE (1 << 1)224/**225* 4 MV per MB allowed / advanced prediction for H.263.226*/227#define AV_CODEC_FLAG_4MV (1 << 2)228/**229* Output even those frames that might be corrupted.230*/231#define AV_CODEC_FLAG_OUTPUT_CORRUPT (1 << 3)232/**233* Use qpel MC.234*/235#define AV_CODEC_FLAG_QPEL (1 << 4)236#if FF_API_DROPCHANGED237/**238* Don't output frames whose parameters differ from first239* decoded frame in stream.240*241* @deprecated callers should implement this functionality in their own code242*/243#define AV_CODEC_FLAG_DROPCHANGED (1 << 5)244#endif245/**246* Request the encoder to output reconstructed frames, i.e.\ frames that would247* be produced by decoding the encoded bistream. These frames may be retrieved248* by calling avcodec_receive_frame() immediately after a successful call to249* avcodec_receive_packet().250*251* Should only be used with encoders flagged with the252* @ref AV_CODEC_CAP_ENCODER_RECON_FRAME capability.253*254* @note255* Each reconstructed frame returned by the encoder corresponds to the last256* encoded packet, i.e. the frames are returned in coded order rather than257* presentation order.258*259* @note260* Frame parameters (like pixel format or dimensions) do not have to match the261* AVCodecContext values. Make sure to use the values from the returned frame.262*/263#define AV_CODEC_FLAG_RECON_FRAME (1 << 6)264/**265* @par decoding266* Request the decoder to propagate each packet's AVPacket.opaque and267* AVPacket.opaque_ref to its corresponding output AVFrame.268*269* @par encoding:270* Request the encoder to propagate each frame's AVFrame.opaque and271* AVFrame.opaque_ref values to its corresponding output AVPacket.272*273* @par274* May only be set on encoders that have the275* @ref AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE capability flag.276*277* @note278* While in typical cases one input frame produces exactly one output packet279* (perhaps after a delay), in general the mapping of frames to packets is280* M-to-N, so281* - Any number of input frames may be associated with any given output packet.282* This includes zero - e.g. some encoders may output packets that carry only283* metadata about the whole stream.284* - A given input frame may be associated with any number of output packets.285* Again this includes zero - e.g. some encoders may drop frames under certain286* conditions.287* .288* This implies that when using this flag, the caller must NOT assume that289* - a given input frame's opaques will necessarily appear on some output packet;290* - every output packet will have some non-NULL opaque value.291* .292* When an output packet contains multiple frames, the opaque values will be293* taken from the first of those.294*295* @note296* The converse holds for decoders, with frames and packets switched.297*/298#define AV_CODEC_FLAG_COPY_OPAQUE (1 << 7)299/**300* Signal to the encoder that the values of AVFrame.duration are valid and301* should be used (typically for transferring them to output packets).302*303* If this flag is not set, frame durations are ignored.304*/305#define AV_CODEC_FLAG_FRAME_DURATION (1 << 8)306/**307* Use internal 2pass ratecontrol in first pass mode.308*/309#define AV_CODEC_FLAG_PASS1 (1 << 9)310/**311* Use internal 2pass ratecontrol in second pass mode.312*/313#define AV_CODEC_FLAG_PASS2 (1 << 10)314/**315* loop filter.316*/317#define AV_CODEC_FLAG_LOOP_FILTER (1 << 11)318/**319* Only decode/encode grayscale.320*/321#define AV_CODEC_FLAG_GRAY (1 << 13)322/**323* error[?] variables will be set during encoding.324*/325#define AV_CODEC_FLAG_PSNR (1 << 15)326/**327* Use interlaced DCT.328*/329#define AV_CODEC_FLAG_INTERLACED_DCT (1 << 18)330/**331* Force low delay.332*/333#define AV_CODEC_FLAG_LOW_DELAY (1 << 19)334/**335* Place global headers in extradata instead of every keyframe.336*/337#define AV_CODEC_FLAG_GLOBAL_HEADER (1 << 22)338/**339* Use only bitexact stuff (except (I)DCT).340*/341#define AV_CODEC_FLAG_BITEXACT (1 << 23)342/* Fx : Flag for H.263+ extra options */343/**344* H.263 advanced intra coding / MPEG-4 AC prediction345*/346#define AV_CODEC_FLAG_AC_PRED (1 << 24)347/**348* interlaced motion estimation349*/350#define AV_CODEC_FLAG_INTERLACED_ME (1 << 29)351#define AV_CODEC_FLAG_CLOSED_GOP (1U << 31)352353/**354* Allow non spec compliant speedup tricks.355*/356#define AV_CODEC_FLAG2_FAST (1 << 0)357/**358* Skip bitstream encoding.359*/360#define AV_CODEC_FLAG2_NO_OUTPUT (1 << 2)361/**362* Place global headers at every keyframe instead of in extradata.363*/364#define AV_CODEC_FLAG2_LOCAL_HEADER (1 << 3)365366/**367* Input bitstream might be truncated at a packet boundaries368* instead of only at frame boundaries.369*/370#define AV_CODEC_FLAG2_CHUNKS (1 << 15)371/**372* Discard cropping information from SPS.373*/374#define AV_CODEC_FLAG2_IGNORE_CROP (1 << 16)375376/**377* Show all frames before the first keyframe378*/379#define AV_CODEC_FLAG2_SHOW_ALL (1 << 22)380/**381* Export motion vectors through frame side data382*/383#define AV_CODEC_FLAG2_EXPORT_MVS (1 << 28)384/**385* Do not skip samples and export skip information as frame side data386*/387#define AV_CODEC_FLAG2_SKIP_MANUAL (1 << 29)388/**389* Do not reset ASS ReadOrder field on flush (subtitles decoding)390*/391#define AV_CODEC_FLAG2_RO_FLUSH_NOOP (1 << 30)392/**393* Generate/parse ICC profiles on encode/decode, as appropriate for the type of394* file. No effect on codecs which cannot contain embedded ICC profiles, or395* when compiled without support for lcms2.396*/397#define AV_CODEC_FLAG2_ICC_PROFILES (1U << 31)398399/* Exported side data.400These flags can be passed in AVCodecContext.export_side_data before initialization.401*/402/**403* Export motion vectors through frame side data404*/405#define AV_CODEC_EXPORT_DATA_MVS (1 << 0)406/**407* Export encoder Producer Reference Time through packet side data408*/409#define AV_CODEC_EXPORT_DATA_PRFT (1 << 1)410/**411* Decoding only.412* Export the AVVideoEncParams structure through frame side data.413*/414#define AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS (1 << 2)415/**416* Decoding only.417* Do not apply film grain, export it instead.418*/419#define AV_CODEC_EXPORT_DATA_FILM_GRAIN (1 << 3)420421/**422* Decoding only.423* Do not apply picture enhancement layers, export them instead.424*/425#define AV_CODEC_EXPORT_DATA_ENHANCEMENTS (1 << 4)426427/**428* The decoder will keep a reference to the frame and may reuse it later.429*/430#define AV_GET_BUFFER_FLAG_REF (1 << 0)431432/**433* The encoder will keep a reference to the packet and may reuse it later.434*/435#define AV_GET_ENCODE_BUFFER_FLAG_REF (1 << 0)436437/**438* main external API structure.439* New fields can be added to the end with minor version bumps.440* Removal, reordering and changes to existing fields require a major441* version bump.442* You can use AVOptions (av_opt* / av_set/get*()) to access these fields from user443* applications.444* The name string for AVOptions options matches the associated command line445* parameter name and can be found in libavcodec/options_table.h446* The AVOption/command line parameter names differ in some cases from the C447* structure field names for historic reasons or brevity.448* sizeof(AVCodecContext) must not be used outside libav*.449*/450typedef struct AVCodecContext {451/**452* information on struct for av_log453* - set by avcodec_alloc_context3454*/455const AVClass *av_class;456int log_level_offset;457458enum AVMediaType codec_type; /* see AVMEDIA_TYPE_xxx */459const struct AVCodec *codec;460enum AVCodecID codec_id; /* see AV_CODEC_ID_xxx */461462/**463* fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').464* This is used to work around some encoder bugs.465* A demuxer should set this to what is stored in the field used to identify the codec.466* If there are multiple such fields in a container then the demuxer should choose the one467* which maximizes the information about the used codec.468* If the codec tag field in a container is larger than 32 bits then the demuxer should469* remap the longer ID to 32 bits with a table or other structure. Alternatively a new470* extra_codec_tag + size could be added but for this a clear advantage must be demonstrated471* first.472* - encoding: Set by user, if not then the default based on codec_id will be used.473* - decoding: Set by user, will be converted to uppercase by libavcodec during init.474*/475unsigned int codec_tag;476477void *priv_data;478479/**480* Private context used for internal data.481*482* Unlike priv_data, this is not codec-specific. It is used in general483* libavcodec functions.484*/485struct AVCodecInternal *internal;486487/**488* Private data of the user, can be used to carry app specific stuff.489* - encoding: Set by user.490* - decoding: Set by user.491*/492void *opaque;493494/**495* the average bitrate496* - encoding: Set by user; unused for constant quantizer encoding.497* - decoding: Set by user, may be overwritten by libavcodec498* if this info is available in the stream499*/500int64_t bit_rate;501502/**503* AV_CODEC_FLAG_*.504* - encoding: Set by user.505* - decoding: Set by user.506*/507int flags;508509/**510* AV_CODEC_FLAG2_*511* - encoding: Set by user.512* - decoding: Set by user.513*/514int flags2;515516/**517* some codecs need / can use extradata like Huffman tables.518* MJPEG: Huffman tables519* rv10: additional flags520* MPEG-4: global headers (they can be in the bitstream or here)521* The allocated memory should be AV_INPUT_BUFFER_PADDING_SIZE bytes larger522* than extradata_size to avoid problems if it is read with the bitstream reader.523* The bytewise contents of extradata must not depend on the architecture or CPU endianness.524* Must be allocated with the av_malloc() family of functions.525* - encoding: Set/allocated/freed by libavcodec.526* - decoding: Set/allocated/freed by user.527*/528uint8_t *extradata;529int extradata_size;530531/**532* This is the fundamental unit of time (in seconds) in terms533* of which frame timestamps are represented. For fixed-fps content,534* timebase should be 1/framerate and timestamp increments should be535* identically 1.536* This often, but not always is the inverse of the frame rate or field rate537* for video. 1/time_base is not the average frame rate if the frame rate is not538* constant.539*540* Like containers, elementary streams also can store timestamps, 1/time_base541* is the unit in which these timestamps are specified.542* As example of such codec time base see ISO/IEC 14496-2:2001(E)543* vop_time_increment_resolution and fixed_vop_rate544* (fixed_vop_rate == 0 implies that it is different from the framerate)545*546* - encoding: MUST be set by user.547* - decoding: unused.548*/549AVRational time_base;550551/**552* Timebase in which pkt_dts/pts and AVPacket.dts/pts are expressed.553* - encoding: unused.554* - decoding: set by user.555*/556AVRational pkt_timebase;557558/**559* - decoding: For codecs that store a framerate value in the compressed560* bitstream, the decoder may export it here. { 0, 1} when561* unknown.562* - encoding: May be used to signal the framerate of CFR content to an563* encoder.564*/565AVRational framerate;566567#if FF_API_TICKS_PER_FRAME568/**569* For some codecs, the time base is closer to the field rate than the frame rate.570* Most notably, H.264 and MPEG-2 specify time_base as half of frame duration571* if no telecine is used ...572*573* Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2.574*575* @deprecated576* - decoding: Use AVCodecDescriptor.props & AV_CODEC_PROP_FIELDS577* - encoding: Set AVCodecContext.framerate instead578*579*/580attribute_deprecated581int ticks_per_frame;582#endif583584/**585* Codec delay.586*587* Encoding: Number of frames delay there will be from the encoder input to588* the decoder output. (we assume the decoder matches the spec)589* Decoding: Number of frames delay in addition to what a standard decoder590* as specified in the spec would produce.591*592* Video:593* Number of frames the decoded output will be delayed relative to the594* encoded input.595*596* Audio:597* For encoding, this field is unused (see initial_padding).598*599* For decoding, this is the number of samples the decoder needs to600* output before the decoder's output is valid. When seeking, you should601* start decoding this many samples prior to your desired seek point.602*603* - encoding: Set by libavcodec.604* - decoding: Set by libavcodec.605*/606int delay;607608609/* video only */610/**611* picture width / height.612*613* @note Those fields may not match the values of the last614* AVFrame output by avcodec_receive_frame() due frame615* reordering.616*617* - encoding: MUST be set by user.618* - decoding: May be set by the user before opening the decoder if known e.g.619* from the container. Some decoders will require the dimensions620* to be set by the caller. During decoding, the decoder may621* overwrite those values as required while parsing the data.622*/623int width, height;624625/**626* Bitstream width / height, may be different from width/height e.g. when627* the decoded frame is cropped before being output or lowres is enabled.628*629* @note Those field may not match the value of the last630* AVFrame output by avcodec_receive_frame() due frame631* reordering.632*633* - encoding: unused634* - decoding: May be set by the user before opening the decoder if known635* e.g. from the container. During decoding, the decoder may636* overwrite those values as required while parsing the data.637*/638int coded_width, coded_height;639640/**641* sample aspect ratio (0 if unknown)642* That is the width of a pixel divided by the height of the pixel.643* Numerator and denominator must be relatively prime and smaller than 256 for some video standards.644* - encoding: Set by user.645* - decoding: Set by libavcodec.646*/647AVRational sample_aspect_ratio;648649/**650* Pixel format, see AV_PIX_FMT_xxx.651* May be set by the demuxer if known from headers.652* May be overridden by the decoder if it knows better.653*654* @note This field may not match the value of the last655* AVFrame output by avcodec_receive_frame() due frame656* reordering.657*658* - encoding: Set by user.659* - decoding: Set by user if known, overridden by libavcodec while660* parsing the data.661*/662enum AVPixelFormat pix_fmt;663664/**665* Nominal unaccelerated pixel format, see AV_PIX_FMT_xxx.666* - encoding: unused.667* - decoding: Set by libavcodec before calling get_format()668*/669enum AVPixelFormat sw_pix_fmt;670671/**672* Chromaticity coordinates of the source primaries.673* - encoding: Set by user674* - decoding: Set by libavcodec675*/676enum AVColorPrimaries color_primaries;677678/**679* Color Transfer Characteristic.680* - encoding: Set by user681* - decoding: Set by libavcodec682*/683enum AVColorTransferCharacteristic color_trc;684685/**686* YUV colorspace type.687* - encoding: Set by user688* - decoding: Set by libavcodec689*/690enum AVColorSpace colorspace;691692/**693* MPEG vs JPEG YUV range.694* - encoding: Set by user to override the default output color range value,695* If not specified, libavcodec sets the color range depending on the696* output format.697* - decoding: Set by libavcodec, can be set by the user to propagate the698* color range to components reading from the decoder context.699*/700enum AVColorRange color_range;701702/**703* This defines the location of chroma samples.704* - encoding: Set by user705* - decoding: Set by libavcodec706*/707enum AVChromaLocation chroma_sample_location;708709/** Field order710* - encoding: set by libavcodec711* - decoding: Set by user.712*/713enum AVFieldOrder field_order;714715/**716* number of reference frames717* - encoding: Set by user.718* - decoding: Set by lavc.719*/720int refs;721722/**723* Size of the frame reordering buffer in the decoder.724* For MPEG-2 it is 1 IPB or 0 low delay IP.725* - encoding: Set by libavcodec.726* - decoding: Set by libavcodec.727*/728int has_b_frames;729730/**731* slice flags732* - encoding: unused733* - decoding: Set by user.734*/735int slice_flags;736#define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display737#define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG-2 field pics)738#define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)739740/**741* If non NULL, 'draw_horiz_band' is called by the libavcodec742* decoder to draw a horizontal band. It improves cache usage. Not743* all codecs can do that. You must check the codec capabilities744* beforehand.745* When multithreading is used, it may be called from multiple threads746* at the same time; threads might draw different parts of the same AVFrame,747* or multiple AVFrames, and there is no guarantee that slices will be drawn748* in order.749* The function is also used by hardware acceleration APIs.750* It is called at least once during frame decoding to pass751* the data needed for hardware render.752* In that mode instead of pixel data, AVFrame points to753* a structure specific to the acceleration API. The application754* reads the structure and can change some fields to indicate progress755* or mark state.756* - encoding: unused757* - decoding: Set by user.758* @param height the height of the slice759* @param y the y position of the slice760* @param type 1->top field, 2->bottom field, 3->frame761* @param offset offset into the AVFrame.data from which the slice should be read762*/763void (*draw_horiz_band)(struct AVCodecContext *s,764const AVFrame *src, int offset[AV_NUM_DATA_POINTERS],765int y, int type, int height);766767/**768* Callback to negotiate the pixel format. Decoding only, may be set by the769* caller before avcodec_open2().770*771* Called by some decoders to select the pixel format that will be used for772* the output frames. This is mainly used to set up hardware acceleration,773* then the provided format list contains the corresponding hwaccel pixel774* formats alongside the "software" one. The software pixel format may also775* be retrieved from \ref sw_pix_fmt.776*777* This callback will be called when the coded frame properties (such as778* resolution, pixel format, etc.) change and more than one output format is779* supported for those new properties. If a hardware pixel format is chosen780* and initialization for it fails, the callback may be called again781* immediately.782*783* This callback may be called from different threads if the decoder is784* multi-threaded, but not from more than one thread simultaneously.785*786* @param fmt list of formats which may be used in the current787* configuration, terminated by AV_PIX_FMT_NONE.788* @warning Behavior is undefined if the callback returns a value other789* than one of the formats in fmt or AV_PIX_FMT_NONE.790* @return the chosen format or AV_PIX_FMT_NONE791*/792enum AVPixelFormat (*get_format)(struct AVCodecContext *s, const enum AVPixelFormat * fmt);793794/**795* maximum number of B-frames between non-B-frames796* Note: The output will be delayed by max_b_frames+1 relative to the input.797* - encoding: Set by user.798* - decoding: unused799*/800int max_b_frames;801802/**803* qscale factor between IP and B-frames804* If > 0 then the last P-frame quantizer will be used (q= lastp_q*factor+offset).805* If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).806* - encoding: Set by user.807* - decoding: unused808*/809float b_quant_factor;810811/**812* qscale offset between IP and B-frames813* - encoding: Set by user.814* - decoding: unused815*/816float b_quant_offset;817818/**819* qscale factor between P- and I-frames820* If > 0 then the last P-frame quantizer will be used (q = lastp_q * factor + offset).821* If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).822* - encoding: Set by user.823* - decoding: unused824*/825float i_quant_factor;826827/**828* qscale offset between P and I-frames829* - encoding: Set by user.830* - decoding: unused831*/832float i_quant_offset;833834/**835* luminance masking (0-> disabled)836* - encoding: Set by user.837* - decoding: unused838*/839float lumi_masking;840841/**842* temporary complexity masking (0-> disabled)843* - encoding: Set by user.844* - decoding: unused845*/846float temporal_cplx_masking;847848/**849* spatial complexity masking (0-> disabled)850* - encoding: Set by user.851* - decoding: unused852*/853float spatial_cplx_masking;854855/**856* p block masking (0-> disabled)857* - encoding: Set by user.858* - decoding: unused859*/860float p_masking;861862/**863* darkness masking (0-> disabled)864* - encoding: Set by user.865* - decoding: unused866*/867float dark_masking;868869/**870* noise vs. sse weight for the nsse comparison function871* - encoding: Set by user.872* - decoding: unused873*/874int nsse_weight;875876/**877* motion estimation comparison function878* - encoding: Set by user.879* - decoding: unused880*/881int me_cmp;882/**883* subpixel motion estimation comparison function884* - encoding: Set by user.885* - decoding: unused886*/887int me_sub_cmp;888/**889* macroblock comparison function (not supported yet)890* - encoding: Set by user.891* - decoding: unused892*/893int mb_cmp;894/**895* interlaced DCT comparison function896* - encoding: Set by user.897* - decoding: unused898*/899int ildct_cmp;900#define FF_CMP_SAD 0901#define FF_CMP_SSE 1902#define FF_CMP_SATD 2903#define FF_CMP_DCT 3904#define FF_CMP_PSNR 4905#define FF_CMP_BIT 5906#define FF_CMP_RD 6907#define FF_CMP_ZERO 7908#define FF_CMP_VSAD 8909#define FF_CMP_VSSE 9910#define FF_CMP_NSSE 10911#define FF_CMP_W53 11912#define FF_CMP_W97 12913#define FF_CMP_DCTMAX 13914#define FF_CMP_DCT264 14915#define FF_CMP_MEDIAN_SAD 15916#define FF_CMP_CHROMA 256917918/**919* ME diamond size & shape920* - encoding: Set by user.921* - decoding: unused922*/923int dia_size;924925/**926* amount of previous MV predictors (2a+1 x 2a+1 square)927* - encoding: Set by user.928* - decoding: unused929*/930int last_predictor_count;931932/**933* motion estimation prepass comparison function934* - encoding: Set by user.935* - decoding: unused936*/937int me_pre_cmp;938939/**940* ME prepass diamond size & shape941* - encoding: Set by user.942* - decoding: unused943*/944int pre_dia_size;945946/**947* subpel ME quality948* - encoding: Set by user.949* - decoding: unused950*/951int me_subpel_quality;952953/**954* maximum motion estimation search range in subpel units955* If 0 then no limit.956*957* - encoding: Set by user.958* - decoding: unused959*/960int me_range;961962/**963* macroblock decision mode964* - encoding: Set by user.965* - decoding: unused966*/967int mb_decision;968#define FF_MB_DECISION_SIMPLE 0 ///< uses mb_cmp969#define FF_MB_DECISION_BITS 1 ///< chooses the one which needs the fewest bits970#define FF_MB_DECISION_RD 2 ///< rate distortion971972/**973* custom intra quantization matrix974* Must be allocated with the av_malloc() family of functions, and will be freed in975* avcodec_free_context().976* - encoding: Set/allocated by user, freed by libavcodec. Can be NULL.977* - decoding: Set/allocated/freed by libavcodec.978*/979uint16_t *intra_matrix;980981/**982* custom inter quantization matrix983* Must be allocated with the av_malloc() family of functions, and will be freed in984* avcodec_free_context().985* - encoding: Set/allocated by user, freed by libavcodec. Can be NULL.986* - decoding: Set/allocated/freed by libavcodec.987*/988uint16_t *inter_matrix;989990/**991* custom intra quantization matrix992* - encoding: Set by user, can be NULL.993* - decoding: unused.994*/995uint16_t *chroma_intra_matrix;996997/**998* precision of the intra DC coefficient - 8999* - encoding: Set by user.1000* - decoding: Set by libavcodec1001*/1002int intra_dc_precision;10031004/**1005* minimum MB Lagrange multiplier1006* - encoding: Set by user.1007* - decoding: unused1008*/1009int mb_lmin;10101011/**1012* maximum MB Lagrange multiplier1013* - encoding: Set by user.1014* - decoding: unused1015*/1016int mb_lmax;10171018/**1019* - encoding: Set by user.1020* - decoding: unused1021*/1022int bidir_refine;10231024/**1025* minimum GOP size1026* - encoding: Set by user.1027* - decoding: unused1028*/1029int keyint_min;10301031/**1032* the number of pictures in a group of pictures, or 0 for intra_only1033* - encoding: Set by user.1034* - decoding: unused1035*/1036int gop_size;10371038/**1039* Note: Value depends upon the compare function used for fullpel ME.1040* - encoding: Set by user.1041* - decoding: unused1042*/1043int mv0_threshold;10441045/**1046* Number of slices.1047* Indicates number of picture subdivisions. Used for parallelized1048* decoding.1049* - encoding: Set by user1050* - decoding: unused1051*/1052int slices;10531054/* audio only */1055int sample_rate; ///< samples per second10561057/**1058* audio sample format1059* - encoding: Set by user.1060* - decoding: Set by libavcodec.1061*/1062enum AVSampleFormat sample_fmt; ///< sample format10631064/**1065* Audio channel layout.1066* - encoding: must be set by the caller, to one of AVCodec.ch_layouts.1067* - decoding: may be set by the caller if known e.g. from the container.1068* The decoder can then override during decoding as needed.1069*/1070AVChannelLayout ch_layout;10711072/* The following data should not be initialized. */1073/**1074* Number of samples per channel in an audio frame.1075*1076* - encoding: set by libavcodec in avcodec_open2(). Each submitted frame1077* except the last must contain exactly frame_size samples per channel.1078* May be 0 when the codec has AV_CODEC_CAP_VARIABLE_FRAME_SIZE set, then the1079* frame size is not restricted.1080* - decoding: may be set by some decoders to indicate constant frame size1081*/1082int frame_size;10831084/**1085* number of bytes per packet if constant and known or 01086* Used by some WAV based audio codecs.1087*/1088int block_align;10891090/**1091* Audio cutoff bandwidth (0 means "automatic")1092* - encoding: Set by user.1093* - decoding: unused1094*/1095int cutoff;10961097/**1098* Type of service that the audio stream conveys.1099* - encoding: Set by user.1100* - decoding: Set by libavcodec.1101*/1102enum AVAudioServiceType audio_service_type;11031104/**1105* desired sample format1106* - encoding: Not used.1107* - decoding: Set by user.1108* Decoder will decode to this format if it can.1109*/1110enum AVSampleFormat request_sample_fmt;11111112/**1113* Audio only. The number of "priming" samples (padding) inserted by the1114* encoder at the beginning of the audio. I.e. this number of leading1115* decoded samples must be discarded by the caller to get the original audio1116* without leading padding.1117*1118* - decoding: unused1119* - encoding: Set by libavcodec. The timestamps on the output packets are1120* adjusted by the encoder so that they always refer to the1121* first sample of the data actually contained in the packet,1122* including any added padding. E.g. if the timebase is1123* 1/samplerate and the timestamp of the first input sample is1124* 0, the timestamp of the first output packet will be1125* -initial_padding.1126*/1127int initial_padding;11281129/**1130* Audio only. The amount of padding (in samples) appended by the encoder to1131* the end of the audio. I.e. this number of decoded samples must be1132* discarded by the caller from the end of the stream to get the original1133* audio without any trailing padding.1134*1135* - decoding: unused1136* - encoding: unused1137*/1138int trailing_padding;11391140/**1141* Number of samples to skip after a discontinuity1142* - decoding: unused1143* - encoding: set by libavcodec1144*/1145int seek_preroll;11461147/**1148* This callback is called at the beginning of each frame to get data1149* buffer(s) for it. There may be one contiguous buffer for all the data or1150* there may be a buffer per each data plane or anything in between. What1151* this means is, you may set however many entries in buf[] you feel necessary.1152* Each buffer must be reference-counted using the AVBuffer API (see description1153* of buf[] below).1154*1155* The following fields will be set in the frame before this callback is1156* called:1157* - format1158* - width, height (video only)1159* - sample_rate, channel_layout, nb_samples (audio only)1160* Their values may differ from the corresponding values in1161* AVCodecContext. This callback must use the frame values, not the codec1162* context values, to calculate the required buffer size.1163*1164* This callback must fill the following fields in the frame:1165* - data[]1166* - linesize[]1167* - extended_data:1168* * if the data is planar audio with more than 8 channels, then this1169* callback must allocate and fill extended_data to contain all pointers1170* to all data planes. data[] must hold as many pointers as it can.1171* extended_data must be allocated with av_malloc() and will be freed in1172* av_frame_unref().1173* * otherwise extended_data must point to data1174* - buf[] must contain one or more pointers to AVBufferRef structures. Each of1175* the frame's data and extended_data pointers must be contained in these. That1176* is, one AVBufferRef for each allocated chunk of memory, not necessarily one1177* AVBufferRef per data[] entry. See: av_buffer_create(), av_buffer_alloc(),1178* and av_buffer_ref().1179* - extended_buf and nb_extended_buf must be allocated with av_malloc() by1180* this callback and filled with the extra buffers if there are more1181* buffers than buf[] can hold. extended_buf will be freed in1182* av_frame_unref().1183* Decoders will generally initialize the whole buffer before it is output1184* but it can in rare error conditions happen that uninitialized data is passed1185* through. \important The buffers returned by get_buffer* should thus not contain sensitive1186* data.1187*1188* If AV_CODEC_CAP_DR1 is not set then get_buffer2() must call1189* avcodec_default_get_buffer2() instead of providing buffers allocated by1190* some other means.1191*1192* Each data plane must be aligned to the maximum required by the target1193* CPU.1194*1195* @see avcodec_default_get_buffer2()1196*1197* Video:1198*1199* If AV_GET_BUFFER_FLAG_REF is set in flags then the frame may be reused1200* (read and/or written to if it is writable) later by libavcodec.1201*1202* avcodec_align_dimensions2() should be used to find the required width and1203* height, as they normally need to be rounded up to the next multiple of 16.1204*1205* Some decoders do not support linesizes changing between frames.1206*1207* If frame multithreading is used, this callback may be called from a1208* different thread, but not from more than one at once. Does not need to be1209* reentrant.1210*1211* @see avcodec_align_dimensions2()1212*1213* Audio:1214*1215* Decoders request a buffer of a particular size by setting1216* AVFrame.nb_samples prior to calling get_buffer2(). The decoder may,1217* however, utilize only part of the buffer by setting AVFrame.nb_samples1218* to a smaller value in the output frame.1219*1220* As a convenience, av_samples_get_buffer_size() and1221* av_samples_fill_arrays() in libavutil may be used by custom get_buffer2()1222* functions to find the required data size and to fill data pointers and1223* linesize. In AVFrame.linesize, only linesize[0] may be set for audio1224* since all planes must be the same size.1225*1226* @see av_samples_get_buffer_size(), av_samples_fill_arrays()1227*1228* - encoding: unused1229* - decoding: Set by libavcodec, user can override.1230*/1231int (*get_buffer2)(struct AVCodecContext *s, AVFrame *frame, int flags);12321233/* - encoding parameters */1234/**1235* number of bits the bitstream is allowed to diverge from the reference.1236* the reference can be CBR (for CBR pass1) or VBR (for pass2)1237* - encoding: Set by user; unused for constant quantizer encoding.1238* - decoding: unused1239*/1240int bit_rate_tolerance;12411242/**1243* Global quality for codecs which cannot change it per frame.1244* This should be proportional to MPEG-1/2/4 qscale.1245* - encoding: Set by user.1246* - decoding: unused1247*/1248int global_quality;12491250/**1251* - encoding: Set by user.1252* - decoding: unused1253*/1254int compression_level;1255#define FF_COMPRESSION_DEFAULT -112561257float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)1258float qblur; ///< amount of qscale smoothing over time (0.0-1.0)12591260/**1261* minimum quantizer1262* - encoding: Set by user.1263* - decoding: unused1264*/1265int qmin;12661267/**1268* maximum quantizer1269* - encoding: Set by user.1270* - decoding: unused1271*/1272int qmax;12731274/**1275* maximum quantizer difference between frames1276* - encoding: Set by user.1277* - decoding: unused1278*/1279int max_qdiff;12801281/**1282* decoder bitstream buffer size1283* - encoding: Set by user.1284* - decoding: May be set by libavcodec.1285*/1286int rc_buffer_size;12871288/**1289* ratecontrol override, see RcOverride1290* - encoding: Allocated/set/freed by user.1291* - decoding: unused1292*/1293int rc_override_count;1294RcOverride *rc_override;12951296/**1297* maximum bitrate1298* - encoding: Set by user.1299* - decoding: Set by user, may be overwritten by libavcodec.1300*/1301int64_t rc_max_rate;13021303/**1304* minimum bitrate1305* - encoding: Set by user.1306* - decoding: unused1307*/1308int64_t rc_min_rate;13091310/**1311* Ratecontrol attempt to use, at maximum, <value> of what can be used without an underflow.1312* - encoding: Set by user.1313* - decoding: unused.1314*/1315float rc_max_available_vbv_use;13161317/**1318* Ratecontrol attempt to use, at least, <value> times the amount needed to prevent a vbv overflow.1319* - encoding: Set by user.1320* - decoding: unused.1321*/1322float rc_min_vbv_overflow_use;13231324/**1325* Number of bits which should be loaded into the rc buffer before decoding starts.1326* - encoding: Set by user.1327* - decoding: unused1328*/1329int rc_initial_buffer_occupancy;13301331/**1332* trellis RD quantization1333* - encoding: Set by user.1334* - decoding: unused1335*/1336int trellis;13371338/**1339* pass1 encoding statistics output buffer1340* - encoding: Set by libavcodec.1341* - decoding: unused1342*/1343char *stats_out;13441345/**1346* pass2 encoding statistics input buffer1347* Concatenated stuff from stats_out of pass1 should be placed here.1348* - encoding: Allocated/set/freed by user.1349* - decoding: unused1350*/1351char *stats_in;13521353/**1354* Work around bugs in encoders which sometimes cannot be detected automatically.1355* - encoding: Set by user1356* - decoding: Set by user1357*/1358int workaround_bugs;1359#define FF_BUG_AUTODETECT 1 ///< autodetection1360#define FF_BUG_XVID_ILACE 41361#define FF_BUG_UMP4 81362#define FF_BUG_NO_PADDING 161363#define FF_BUG_AMV 321364#define FF_BUG_QPEL_CHROMA 641365#define FF_BUG_STD_QPEL 1281366#define FF_BUG_QPEL_CHROMA2 2561367#define FF_BUG_DIRECT_BLOCKSIZE 5121368#define FF_BUG_EDGE 10241369#define FF_BUG_HPEL_CHROMA 20481370#define FF_BUG_DC_CLIP 40961371#define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders.1372#define FF_BUG_TRUNCATED 163841373#define FF_BUG_IEDGE 3276813741375/**1376* strictly follow the standard (MPEG-4, ...).1377* - encoding: Set by user.1378* - decoding: Set by user.1379* Setting this to STRICT or higher means the encoder and decoder will1380* generally do stupid things, whereas setting it to unofficial or lower1381* will mean the encoder might produce output that is not supported by all1382* spec-compliant decoders. Decoders don't differentiate between normal,1383* unofficial and experimental (that is, they always try to decode things1384* when they can) unless they are explicitly asked to behave stupidly1385* (=strictly conform to the specs)1386* This may only be set to one of the FF_COMPLIANCE_* values in defs.h.1387*/1388int strict_std_compliance;13891390/**1391* error concealment flags1392* - encoding: unused1393* - decoding: Set by user.1394*/1395int error_concealment;1396#define FF_EC_GUESS_MVS 11397#define FF_EC_DEBLOCK 21398#define FF_EC_FAVOR_INTER 25613991400/**1401* debug1402* - encoding: Set by user.1403* - decoding: Set by user.1404*/1405int debug;1406#define FF_DEBUG_PICT_INFO 11407#define FF_DEBUG_RC 21408#define FF_DEBUG_BITSTREAM 41409#define FF_DEBUG_MB_TYPE 81410#define FF_DEBUG_QP 161411#define FF_DEBUG_DCT_COEFF 0x000000401412#define FF_DEBUG_SKIP 0x000000801413#define FF_DEBUG_STARTCODE 0x000001001414#define FF_DEBUG_ER 0x000004001415#define FF_DEBUG_MMCO 0x000008001416#define FF_DEBUG_BUGS 0x000010001417#define FF_DEBUG_BUFFERS 0x000080001418#define FF_DEBUG_THREADS 0x000100001419#define FF_DEBUG_GREEN_MD 0x008000001420#define FF_DEBUG_NOMC 0x0100000014211422/**1423* Error recognition; may misdetect some more or less valid parts as errors.1424* This is a bitfield of the AV_EF_* values defined in defs.h.1425*1426* - encoding: Set by user.1427* - decoding: Set by user.1428*/1429int err_recognition;14301431/**1432* Hardware accelerator in use1433* - encoding: unused.1434* - decoding: Set by libavcodec1435*/1436const struct AVHWAccel *hwaccel;14371438/**1439* Legacy hardware accelerator context.1440*1441* For some hardware acceleration methods, the caller may use this field to1442* signal hwaccel-specific data to the codec. The struct pointed to by this1443* pointer is hwaccel-dependent and defined in the respective header. Please1444* refer to the FFmpeg HW accelerator documentation to know how to fill1445* this.1446*1447* In most cases this field is optional - the necessary information may also1448* be provided to libavcodec through @ref hw_frames_ctx or @ref1449* hw_device_ctx (see avcodec_get_hw_config()). However, in some cases it1450* may be the only method of signalling some (optional) information.1451*1452* The struct and its contents are owned by the caller.1453*1454* - encoding: May be set by the caller before avcodec_open2(). Must remain1455* valid until avcodec_free_context().1456* - decoding: May be set by the caller in the get_format() callback.1457* Must remain valid until the next get_format() call,1458* or avcodec_free_context() (whichever comes first).1459*/1460void *hwaccel_context;14611462/**1463* A reference to the AVHWFramesContext describing the input (for encoding)1464* or output (decoding) frames. The reference is set by the caller and1465* afterwards owned (and freed) by libavcodec - it should never be read by1466* the caller after being set.1467*1468* - decoding: This field should be set by the caller from the get_format()1469* callback. The previous reference (if any) will always be1470* unreffed by libavcodec before the get_format() call.1471*1472* If the default get_buffer2() is used with a hwaccel pixel1473* format, then this AVHWFramesContext will be used for1474* allocating the frame buffers.1475*1476* - encoding: For hardware encoders configured to use a hwaccel pixel1477* format, this field should be set by the caller to a reference1478* to the AVHWFramesContext describing input frames.1479* AVHWFramesContext.format must be equal to1480* AVCodecContext.pix_fmt.1481*1482* This field should be set before avcodec_open2() is called.1483*/1484AVBufferRef *hw_frames_ctx;14851486/**1487* A reference to the AVHWDeviceContext describing the device which will1488* be used by a hardware encoder/decoder. The reference is set by the1489* caller and afterwards owned (and freed) by libavcodec.1490*1491* This should be used if either the codec device does not require1492* hardware frames or any that are used are to be allocated internally by1493* libavcodec. If the user wishes to supply any of the frames used as1494* encoder input or decoder output then hw_frames_ctx should be used1495* instead. When hw_frames_ctx is set in get_format() for a decoder, this1496* field will be ignored while decoding the associated stream segment, but1497* may again be used on a following one after another get_format() call.1498*1499* For both encoders and decoders this field should be set before1500* avcodec_open2() is called and must not be written to thereafter.1501*1502* Note that some decoders may require this field to be set initially in1503* order to support hw_frames_ctx at all - in that case, all frames1504* contexts used must be created on the same device.1505*/1506AVBufferRef *hw_device_ctx;15071508/**1509* Bit set of AV_HWACCEL_FLAG_* flags, which affect hardware accelerated1510* decoding (if active).1511* - encoding: unused1512* - decoding: Set by user (either before avcodec_open2(), or in the1513* AVCodecContext.get_format callback)1514*/1515int hwaccel_flags;15161517/**1518* Video decoding only. Sets the number of extra hardware frames which1519* the decoder will allocate for use by the caller. This must be set1520* before avcodec_open2() is called.1521*1522* Some hardware decoders require all frames that they will use for1523* output to be defined in advance before decoding starts. For such1524* decoders, the hardware frame pool must therefore be of a fixed size.1525* The extra frames set here are on top of any number that the decoder1526* needs internally in order to operate normally (for example, frames1527* used as reference pictures).1528*/1529int extra_hw_frames;15301531/**1532* error1533* - encoding: Set by libavcodec if flags & AV_CODEC_FLAG_PSNR.1534* - decoding: unused1535*/1536uint64_t error[AV_NUM_DATA_POINTERS];15371538/**1539* DCT algorithm, see FF_DCT_* below1540* - encoding: Set by user.1541* - decoding: unused1542*/1543int dct_algo;1544#define FF_DCT_AUTO 01545#define FF_DCT_FASTINT 11546#define FF_DCT_INT 21547#define FF_DCT_MMX 31548#define FF_DCT_ALTIVEC 51549#define FF_DCT_FAAN 61550#define FF_DCT_NEON 715511552/**1553* IDCT algorithm, see FF_IDCT_* below.1554* - encoding: Set by user.1555* - decoding: Set by user.1556*/1557int idct_algo;1558#define FF_IDCT_AUTO 01559#define FF_IDCT_INT 11560#define FF_IDCT_SIMPLE 21561#define FF_IDCT_SIMPLEMMX 31562#define FF_IDCT_ARM 71563#define FF_IDCT_ALTIVEC 81564#define FF_IDCT_SIMPLEARM 101565#define FF_IDCT_XVID 141566#define FF_IDCT_SIMPLEARMV5TE 161567#define FF_IDCT_SIMPLEARMV6 171568#define FF_IDCT_FAAN 201569#define FF_IDCT_SIMPLENEON 221570#define FF_IDCT_SIMPLEAUTO 12815711572/**1573* bits per sample/pixel from the demuxer (needed for huffyuv).1574* - encoding: Set by libavcodec.1575* - decoding: Set by user.1576*/1577int bits_per_coded_sample;15781579/**1580* Bits per sample/pixel of internal libavcodec pixel/sample format.1581* - encoding: set by user.1582* - decoding: set by libavcodec.1583*/1584int bits_per_raw_sample;15851586/**1587* thread count1588* is used to decide how many independent tasks should be passed to execute()1589* - encoding: Set by user.1590* - decoding: Set by user.1591*/1592int thread_count;15931594/**1595* Which multithreading methods to use.1596* Use of FF_THREAD_FRAME will increase decoding delay by one frame per thread,1597* so clients which cannot provide future frames should not use it.1598*1599* - encoding: Set by user, otherwise the default is used.1600* - decoding: Set by user, otherwise the default is used.1601*/1602int thread_type;1603#define FF_THREAD_FRAME 1 ///< Decode more than one frame at once1604#define FF_THREAD_SLICE 2 ///< Decode more than one part of a single frame at once16051606/**1607* Which multithreading methods are in use by the codec.1608* - encoding: Set by libavcodec.1609* - decoding: Set by libavcodec.1610*/1611int active_thread_type;16121613/**1614* The codec may call this to execute several independent things.1615* It will return only after finishing all tasks.1616* The user may replace this with some multithreaded implementation,1617* the default implementation will execute the parts serially.1618* @param count the number of things to execute1619* - encoding: Set by libavcodec, user can override.1620* - decoding: Set by libavcodec, user can override.1621*/1622int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size);16231624/**1625* The codec may call this to execute several independent things.1626* It will return only after finishing all tasks.1627* The user may replace this with some multithreaded implementation,1628* the default implementation will execute the parts serially.1629* @param c context passed also to func1630* @param count the number of things to execute1631* @param arg2 argument passed unchanged to func1632* @param ret return values of executed functions, must have space for "count" values. May be NULL.1633* @param func function that will be called count times, with jobnr from 0 to count-1.1634* threadnr will be in the range 0 to c->thread_count-1 < MAX_THREADS and so that no1635* two instances of func executing at the same time will have the same threadnr.1636* @return always 0 currently, but code should handle a future improvement where when any call to func1637* returns < 0 no further calls to func may be done and < 0 is returned.1638* - encoding: Set by libavcodec, user can override.1639* - decoding: Set by libavcodec, user can override.1640*/1641int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count);16421643/**1644* profile1645* - encoding: Set by user.1646* - decoding: Set by libavcodec.1647* See the AV_PROFILE_* defines in defs.h.1648*/1649int profile;1650#if FF_API_FF_PROFILE_LEVEL1651/** @deprecated The following defines are deprecated; use AV_PROFILE_*1652* in defs.h instead. */1653#define FF_PROFILE_UNKNOWN -991654#define FF_PROFILE_RESERVED -10016551656#define FF_PROFILE_AAC_MAIN 01657#define FF_PROFILE_AAC_LOW 11658#define FF_PROFILE_AAC_SSR 21659#define FF_PROFILE_AAC_LTP 31660#define FF_PROFILE_AAC_HE 41661#define FF_PROFILE_AAC_HE_V2 281662#define FF_PROFILE_AAC_LD 221663#define FF_PROFILE_AAC_ELD 381664#define FF_PROFILE_MPEG2_AAC_LOW 1281665#define FF_PROFILE_MPEG2_AAC_HE 13116661667#define FF_PROFILE_DNXHD 01668#define FF_PROFILE_DNXHR_LB 11669#define FF_PROFILE_DNXHR_SQ 21670#define FF_PROFILE_DNXHR_HQ 31671#define FF_PROFILE_DNXHR_HQX 41672#define FF_PROFILE_DNXHR_444 516731674#define FF_PROFILE_DTS 201675#define FF_PROFILE_DTS_ES 301676#define FF_PROFILE_DTS_96_24 401677#define FF_PROFILE_DTS_HD_HRA 501678#define FF_PROFILE_DTS_HD_MA 601679#define FF_PROFILE_DTS_EXPRESS 701680#define FF_PROFILE_DTS_HD_MA_X 611681#define FF_PROFILE_DTS_HD_MA_X_IMAX 62168216831684#define FF_PROFILE_EAC3_DDP_ATMOS 3016851686#define FF_PROFILE_TRUEHD_ATMOS 3016871688#define FF_PROFILE_MPEG2_422 01689#define FF_PROFILE_MPEG2_HIGH 11690#define FF_PROFILE_MPEG2_SS 21691#define FF_PROFILE_MPEG2_SNR_SCALABLE 31692#define FF_PROFILE_MPEG2_MAIN 41693#define FF_PROFILE_MPEG2_SIMPLE 516941695#define FF_PROFILE_H264_CONSTRAINED (1<<9) // 8+1; constraint_set1_flag1696#define FF_PROFILE_H264_INTRA (1<<11) // 8+3; constraint_set3_flag16971698#define FF_PROFILE_H264_BASELINE 661699#define FF_PROFILE_H264_CONSTRAINED_BASELINE (66|FF_PROFILE_H264_CONSTRAINED)1700#define FF_PROFILE_H264_MAIN 771701#define FF_PROFILE_H264_EXTENDED 881702#define FF_PROFILE_H264_HIGH 1001703#define FF_PROFILE_H264_HIGH_10 1101704#define FF_PROFILE_H264_HIGH_10_INTRA (110|FF_PROFILE_H264_INTRA)1705#define FF_PROFILE_H264_MULTIVIEW_HIGH 1181706#define FF_PROFILE_H264_HIGH_422 1221707#define FF_PROFILE_H264_HIGH_422_INTRA (122|FF_PROFILE_H264_INTRA)1708#define FF_PROFILE_H264_STEREO_HIGH 1281709#define FF_PROFILE_H264_HIGH_444 1441710#define FF_PROFILE_H264_HIGH_444_PREDICTIVE 2441711#define FF_PROFILE_H264_HIGH_444_INTRA (244|FF_PROFILE_H264_INTRA)1712#define FF_PROFILE_H264_CAVLC_444 4417131714#define FF_PROFILE_VC1_SIMPLE 01715#define FF_PROFILE_VC1_MAIN 11716#define FF_PROFILE_VC1_COMPLEX 21717#define FF_PROFILE_VC1_ADVANCED 317181719#define FF_PROFILE_MPEG4_SIMPLE 01720#define FF_PROFILE_MPEG4_SIMPLE_SCALABLE 11721#define FF_PROFILE_MPEG4_CORE 21722#define FF_PROFILE_MPEG4_MAIN 31723#define FF_PROFILE_MPEG4_N_BIT 41724#define FF_PROFILE_MPEG4_SCALABLE_TEXTURE 51725#define FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION 61726#define FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE 71727#define FF_PROFILE_MPEG4_HYBRID 81728#define FF_PROFILE_MPEG4_ADVANCED_REAL_TIME 91729#define FF_PROFILE_MPEG4_CORE_SCALABLE 101730#define FF_PROFILE_MPEG4_ADVANCED_CODING 111731#define FF_PROFILE_MPEG4_ADVANCED_CORE 121732#define FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE 131733#define FF_PROFILE_MPEG4_SIMPLE_STUDIO 141734#define FF_PROFILE_MPEG4_ADVANCED_SIMPLE 1517351736#define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_0 11737#define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_1 21738#define FF_PROFILE_JPEG2000_CSTREAM_NO_RESTRICTION 327681739#define FF_PROFILE_JPEG2000_DCINEMA_2K 31740#define FF_PROFILE_JPEG2000_DCINEMA_4K 417411742#define FF_PROFILE_VP9_0 01743#define FF_PROFILE_VP9_1 11744#define FF_PROFILE_VP9_2 21745#define FF_PROFILE_VP9_3 317461747#define FF_PROFILE_HEVC_MAIN 11748#define FF_PROFILE_HEVC_MAIN_10 21749#define FF_PROFILE_HEVC_MAIN_STILL_PICTURE 31750#define FF_PROFILE_HEVC_REXT 41751#define FF_PROFILE_HEVC_SCC 917521753#define FF_PROFILE_VVC_MAIN_10 11754#define FF_PROFILE_VVC_MAIN_10_444 3317551756#define FF_PROFILE_AV1_MAIN 01757#define FF_PROFILE_AV1_HIGH 11758#define FF_PROFILE_AV1_PROFESSIONAL 217591760#define FF_PROFILE_MJPEG_HUFFMAN_BASELINE_DCT 0xc01761#define FF_PROFILE_MJPEG_HUFFMAN_EXTENDED_SEQUENTIAL_DCT 0xc11762#define FF_PROFILE_MJPEG_HUFFMAN_PROGRESSIVE_DCT 0xc21763#define FF_PROFILE_MJPEG_HUFFMAN_LOSSLESS 0xc31764#define FF_PROFILE_MJPEG_JPEG_LS 0xf717651766#define FF_PROFILE_SBC_MSBC 117671768#define FF_PROFILE_PRORES_PROXY 01769#define FF_PROFILE_PRORES_LT 11770#define FF_PROFILE_PRORES_STANDARD 21771#define FF_PROFILE_PRORES_HQ 31772#define FF_PROFILE_PRORES_4444 41773#define FF_PROFILE_PRORES_XQ 517741775#define FF_PROFILE_ARIB_PROFILE_A 01776#define FF_PROFILE_ARIB_PROFILE_C 117771778#define FF_PROFILE_KLVA_SYNC 01779#define FF_PROFILE_KLVA_ASYNC 117801781#define FF_PROFILE_EVC_BASELINE 01782#define FF_PROFILE_EVC_MAIN 11783#endif17841785/**1786* Encoding level descriptor.1787* - encoding: Set by user, corresponds to a specific level defined by the1788* codec, usually corresponding to the profile level, if not specified it1789* is set to FF_LEVEL_UNKNOWN.1790* - decoding: Set by libavcodec.1791* See AV_LEVEL_* in defs.h.1792*/1793int level;1794#if FF_API_FF_PROFILE_LEVEL1795/** @deprecated The following define is deprecated; use AV_LEVEL_UNKOWN1796* in defs.h instead. */1797#define FF_LEVEL_UNKNOWN -991798#endif17991800/**1801* Properties of the stream that gets decoded1802* - encoding: unused1803* - decoding: set by libavcodec1804*/1805unsigned properties;1806#define FF_CODEC_PROPERTY_LOSSLESS 0x000000011807#define FF_CODEC_PROPERTY_CLOSED_CAPTIONS 0x000000021808#define FF_CODEC_PROPERTY_FILM_GRAIN 0x0000000418091810/**1811* Skip loop filtering for selected frames.1812* - encoding: unused1813* - decoding: Set by user.1814*/1815enum AVDiscard skip_loop_filter;18161817/**1818* Skip IDCT/dequantization for selected frames.1819* - encoding: unused1820* - decoding: Set by user.1821*/1822enum AVDiscard skip_idct;18231824/**1825* Skip decoding for selected frames.1826* - encoding: unused1827* - decoding: Set by user.1828*/1829enum AVDiscard skip_frame;18301831/**1832* Skip processing alpha if supported by codec.1833* Note that if the format uses pre-multiplied alpha (common with VP6,1834* and recommended due to better video quality/compression)1835* the image will look as if alpha-blended onto a black background.1836* However for formats that do not use pre-multiplied alpha1837* there might be serious artefacts (though e.g. libswscale currently1838* assumes pre-multiplied alpha anyway).1839*1840* - decoding: set by user1841* - encoding: unused1842*/1843int skip_alpha;18441845/**1846* Number of macroblock rows at the top which are skipped.1847* - encoding: unused1848* - decoding: Set by user.1849*/1850int skip_top;18511852/**1853* Number of macroblock rows at the bottom which are skipped.1854* - encoding: unused1855* - decoding: Set by user.1856*/1857int skip_bottom;18581859/**1860* low resolution decoding, 1-> 1/2 size, 2->1/4 size1861* - encoding: unused1862* - decoding: Set by user.1863*/1864int lowres;18651866/**1867* AVCodecDescriptor1868* - encoding: unused.1869* - decoding: set by libavcodec.1870*/1871const struct AVCodecDescriptor *codec_descriptor;18721873/**1874* Character encoding of the input subtitles file.1875* - decoding: set by user1876* - encoding: unused1877*/1878char *sub_charenc;18791880/**1881* Subtitles character encoding mode. Formats or codecs might be adjusting1882* this setting (if they are doing the conversion themselves for instance).1883* - decoding: set by libavcodec1884* - encoding: unused1885*/1886int sub_charenc_mode;1887#define FF_SUB_CHARENC_MODE_DO_NOTHING -1 ///< do nothing (demuxer outputs a stream supposed to be already in UTF-8, or the codec is bitmap for instance)1888#define FF_SUB_CHARENC_MODE_AUTOMATIC 0 ///< libavcodec will select the mode itself1889#define FF_SUB_CHARENC_MODE_PRE_DECODER 1 ///< the AVPacket data needs to be recoded to UTF-8 before being fed to the decoder, requires iconv1890#define FF_SUB_CHARENC_MODE_IGNORE 2 ///< neither convert the subtitles, nor check them for valid UTF-818911892/**1893* Header containing style information for text subtitles.1894* For SUBTITLE_ASS subtitle type, it should contain the whole ASS1895* [Script Info] and [V4+ Styles] section, plus the [Events] line and1896* the Format line following. It shouldn't include any Dialogue line.1897* - encoding: Set/allocated/freed by user (before avcodec_open2())1898* - decoding: Set/allocated/freed by libavcodec (by avcodec_open2())1899*/1900int subtitle_header_size;1901uint8_t *subtitle_header;19021903/**1904* dump format separator.1905* can be ", " or "\n " or anything else1906* - encoding: Set by user.1907* - decoding: Set by user.1908*/1909uint8_t *dump_separator;19101911/**1912* ',' separated list of allowed decoders.1913* If NULL then all are allowed1914* - encoding: unused1915* - decoding: set by user1916*/1917char *codec_whitelist;19181919/**1920* Additional data associated with the entire coded stream.1921*1922* - decoding: may be set by user before calling avcodec_open2().1923* - encoding: may be set by libavcodec after avcodec_open2().1924*/1925AVPacketSideData *coded_side_data;1926int nb_coded_side_data;19271928/**1929* Bit set of AV_CODEC_EXPORT_DATA_* flags, which affects the kind of1930* metadata exported in frame, packet, or coded stream side data by1931* decoders and encoders.1932*1933* - decoding: set by user1934* - encoding: set by user1935*/1936int export_side_data;19371938/**1939* The number of pixels per image to maximally accept.1940*1941* - decoding: set by user1942* - encoding: set by user1943*/1944int64_t max_pixels;19451946/**1947* Video decoding only. Certain video codecs support cropping, meaning that1948* only a sub-rectangle of the decoded frame is intended for display. This1949* option controls how cropping is handled by libavcodec.1950*1951* When set to 1 (the default), libavcodec will apply cropping internally.1952* I.e. it will modify the output frame width/height fields and offset the1953* data pointers (only by as much as possible while preserving alignment, or1954* by the full amount if the AV_CODEC_FLAG_UNALIGNED flag is set) so that1955* the frames output by the decoder refer only to the cropped area. The1956* crop_* fields of the output frames will be zero.1957*1958* When set to 0, the width/height fields of the output frames will be set1959* to the coded dimensions and the crop_* fields will describe the cropping1960* rectangle. Applying the cropping is left to the caller.1961*1962* @warning When hardware acceleration with opaque output frames is used,1963* libavcodec is unable to apply cropping from the top/left border.1964*1965* @note when this option is set to zero, the width/height fields of the1966* AVCodecContext and output AVFrames have different meanings. The codec1967* context fields store display dimensions (with the coded dimensions in1968* coded_width/height), while the frame fields store the coded dimensions1969* (with the display dimensions being determined by the crop_* fields).1970*/1971int apply_cropping;19721973/**1974* The percentage of damaged samples to discard a frame.1975*1976* - decoding: set by user1977* - encoding: unused1978*/1979int discard_damaged_percentage;19801981/**1982* The number of samples per frame to maximally accept.1983*1984* - decoding: set by user1985* - encoding: set by user1986*/1987int64_t max_samples;19881989/**1990* This callback is called at the beginning of each packet to get a data1991* buffer for it.1992*1993* The following field will be set in the packet before this callback is1994* called:1995* - size1996* This callback must use the above value to calculate the required buffer size,1997* which must padded by at least AV_INPUT_BUFFER_PADDING_SIZE bytes.1998*1999* In some specific cases, the encoder may not use the entire buffer allocated by this2000* callback. This will be reflected in the size value in the packet once returned by2001* avcodec_receive_packet().2002*2003* This callback must fill the following fields in the packet:2004* - data: alignment requirements for AVPacket apply, if any. Some architectures and2005* encoders may benefit from having aligned data.2006* - buf: must contain a pointer to an AVBufferRef structure. The packet's2007* data pointer must be contained in it. See: av_buffer_create(), av_buffer_alloc(),2008* and av_buffer_ref().2009*2010* If AV_CODEC_CAP_DR1 is not set then get_encode_buffer() must call2011* avcodec_default_get_encode_buffer() instead of providing a buffer allocated by2012* some other means.2013*2014* The flags field may contain a combination of AV_GET_ENCODE_BUFFER_FLAG_ flags.2015* They may be used for example to hint what use the buffer may get after being2016* created.2017* Implementations of this callback may ignore flags they don't understand.2018* If AV_GET_ENCODE_BUFFER_FLAG_REF is set in flags then the packet may be reused2019* (read and/or written to if it is writable) later by libavcodec.2020*2021* This callback must be thread-safe, as when frame threading is used, it may2022* be called from multiple threads simultaneously.2023*2024* @see avcodec_default_get_encode_buffer()2025*2026* - encoding: Set by libavcodec, user can override.2027* - decoding: unused2028*/2029int (*get_encode_buffer)(struct AVCodecContext *s, AVPacket *pkt, int flags);20302031/**2032* Frame counter, set by libavcodec.2033*2034* - decoding: total number of frames returned from the decoder so far.2035* - encoding: total number of frames passed to the encoder so far.2036*2037* @note the counter is not incremented if encoding/decoding resulted in2038* an error.2039*/2040int64_t frame_num;20412042/**2043* Decoding only. May be set by the caller before avcodec_open2() to an2044* av_malloc()'ed array (or via AVOptions). Owned and freed by the decoder2045* afterwards.2046*2047* Side data attached to decoded frames may come from several sources:2048* 1. coded_side_data, which the decoder will for certain types translate2049* from packet-type to frame-type and attach to frames;2050* 2. side data attached to an AVPacket sent for decoding (same2051* considerations as above);2052* 3. extracted from the coded bytestream.2053* The first two cases are supplied by the caller and typically come from a2054* container.2055*2056* This array configures decoder behaviour in cases when side data of the2057* same type is present both in the coded bytestream and in the2058* user-supplied side data (items 1. and 2. above). In all cases, at most2059* one instance of each side data type will be attached to output frames. By2060* default it will be the bytestream side data. Adding an2061* AVPacketSideDataType value to this array will flip the preference for2062* this type, thus making the decoder prefer user-supplied side data over2063* bytestream. In case side data of the same type is present both in2064* coded_data and attacked to a packet, the packet instance always has2065* priority.2066*2067* The array may also contain a single -1, in which case the preference is2068* switched for all side data types.2069*/2070int *side_data_prefer_packet;2071/**2072* Number of entries in side_data_prefer_packet.2073*/2074unsigned nb_side_data_prefer_packet;20752076/**2077* Array containing static side data, such as HDR10 CLL / MDCV structures.2078* Side data entries should be allocated by usage of helpers defined in2079* libavutil/frame.h.2080*2081* - encoding: may be set by user before calling avcodec_open2() for2082* encoder configuration. Afterwards owned and freed by the2083* encoder.2084* - decoding: may be set by libavcodec in avcodec_open2().2085*/2086AVFrameSideData **decoded_side_data;2087int nb_decoded_side_data;2088} AVCodecContext;20892090/**2091* @defgroup lavc_hwaccel AVHWAccel2092*2093* @note Nothing in this structure should be accessed by the user. At some2094* point in future it will not be externally visible at all.2095*2096* @{2097*/2098typedef struct AVHWAccel {2099/**2100* Name of the hardware accelerated codec.2101* The name is globally unique among encoders and among decoders (but an2102* encoder and a decoder can share the same name).2103*/2104const char *name;21052106/**2107* Type of codec implemented by the hardware accelerator.2108*2109* See AVMEDIA_TYPE_xxx2110*/2111enum AVMediaType type;21122113/**2114* Codec implemented by the hardware accelerator.2115*2116* See AV_CODEC_ID_xxx2117*/2118enum AVCodecID id;21192120/**2121* Supported pixel format.2122*2123* Only hardware accelerated formats are supported here.2124*/2125enum AVPixelFormat pix_fmt;21262127/**2128* Hardware accelerated codec capabilities.2129* see AV_HWACCEL_CODEC_CAP_*2130*/2131int capabilities;2132} AVHWAccel;21332134/**2135* HWAccel is experimental and is thus avoided in favor of non experimental2136* codecs2137*/2138#define AV_HWACCEL_CODEC_CAP_EXPERIMENTAL 0x020021392140/**2141* Hardware acceleration should be used for decoding even if the codec level2142* used is unknown or higher than the maximum supported level reported by the2143* hardware driver.2144*2145* It's generally a good idea to pass this flag unless you have a specific2146* reason not to, as hardware tends to under-report supported levels.2147*/2148#define AV_HWACCEL_FLAG_IGNORE_LEVEL (1 << 0)21492150/**2151* Hardware acceleration can output YUV pixel formats with a different chroma2152* sampling than 4:2:0 and/or other than 8 bits per component.2153*/2154#define AV_HWACCEL_FLAG_ALLOW_HIGH_DEPTH (1 << 1)21552156/**2157* Hardware acceleration should still be attempted for decoding when the2158* codec profile does not match the reported capabilities of the hardware.2159*2160* For example, this can be used to try to decode baseline profile H.2642161* streams in hardware - it will often succeed, because many streams marked2162* as baseline profile actually conform to constrained baseline profile.2163*2164* @warning If the stream is actually not supported then the behaviour is2165* undefined, and may include returning entirely incorrect output2166* while indicating success.2167*/2168#define AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH (1 << 2)21692170/**2171* Some hardware decoders (namely nvdec) can either output direct decoder2172* surfaces, or make an on-device copy and return said copy.2173* There is a hard limit on how many decoder surfaces there can be, and it2174* cannot be accurately guessed ahead of time.2175* For some processing chains, this can be okay, but others will run into the2176* limit and in turn produce very confusing errors that require fine tuning of2177* more or less obscure options by the user, or in extreme cases cannot be2178* resolved at all without inserting an avfilter that forces a copy.2179*2180* Thus, the hwaccel will by default make a copy for safety and resilience.2181* If a users really wants to minimize the amount of copies, they can set this2182* flag and ensure their processing chain does not exhaust the surface pool.2183*/2184#define AV_HWACCEL_FLAG_UNSAFE_OUTPUT (1 << 3)21852186/**2187* @}2188*/21892190enum AVSubtitleType {2191SUBTITLE_NONE,21922193SUBTITLE_BITMAP, ///< A bitmap, pict will be set21942195/**2196* Plain text, the text field must be set by the decoder and is2197* authoritative. ass and pict fields may contain approximations.2198*/2199SUBTITLE_TEXT,22002201/**2202* Formatted text, the ass field must be set by the decoder and is2203* authoritative. pict and text fields may contain approximations.2204*/2205SUBTITLE_ASS,2206};22072208#define AV_SUBTITLE_FLAG_FORCED 0x0000000122092210typedef struct AVSubtitleRect {2211int x; ///< top left corner of pict, undefined when pict is not set2212int y; ///< top left corner of pict, undefined when pict is not set2213int w; ///< width of pict, undefined when pict is not set2214int h; ///< height of pict, undefined when pict is not set2215int nb_colors; ///< number of colors in pict, undefined when pict is not set22162217/**2218* data+linesize for the bitmap of this subtitle.2219* Can be set for text/ass as well once they are rendered.2220*/2221uint8_t *data[4];2222int linesize[4];22232224int flags;2225enum AVSubtitleType type;22262227char *text; ///< 0 terminated plain UTF-8 text22282229/**2230* 0 terminated ASS/SSA compatible event line.2231* The presentation of this is unaffected by the other values in this2232* struct.2233*/2234char *ass;2235} AVSubtitleRect;22362237typedef struct AVSubtitle {2238uint16_t format; /* 0 = graphics */2239uint32_t start_display_time; /* relative to packet pts, in ms */2240uint32_t end_display_time; /* relative to packet pts, in ms */2241unsigned num_rects;2242AVSubtitleRect **rects;2243int64_t pts; ///< Same as packet pts, in AV_TIME_BASE2244} AVSubtitle;22452246/**2247* Return the LIBAVCODEC_VERSION_INT constant.2248*/2249unsigned avcodec_version(void);22502251/**2252* Return the libavcodec build-time configuration.2253*/2254const char *avcodec_configuration(void);22552256/**2257* Return the libavcodec license.2258*/2259const char *avcodec_license(void);22602261/**2262* Allocate an AVCodecContext and set its fields to default values. The2263* resulting struct should be freed with avcodec_free_context().2264*2265* @param codec if non-NULL, allocate private data and initialize defaults2266* for the given codec. It is illegal to then call avcodec_open2()2267* with a different codec.2268* If NULL, then the codec-specific defaults won't be initialized,2269* which may result in suboptimal default settings (this is2270* important mainly for encoders, e.g. libx264).2271*2272* @return An AVCodecContext filled with default values or NULL on failure.2273*/2274AVCodecContext *avcodec_alloc_context3(const AVCodec *codec);22752276/**2277* Free the codec context and everything associated with it and write NULL to2278* the provided pointer.2279*/2280void avcodec_free_context(AVCodecContext **avctx);22812282/**2283* Get the AVClass for AVCodecContext. It can be used in combination with2284* AV_OPT_SEARCH_FAKE_OBJ for examining options.2285*2286* @see av_opt_find().2287*/2288const AVClass *avcodec_get_class(void);22892290/**2291* Get the AVClass for AVSubtitleRect. It can be used in combination with2292* AV_OPT_SEARCH_FAKE_OBJ for examining options.2293*2294* @see av_opt_find().2295*/2296const AVClass *avcodec_get_subtitle_rect_class(void);22972298/**2299* Fill the parameters struct based on the values from the supplied codec2300* context. Any allocated fields in par are freed and replaced with duplicates2301* of the corresponding fields in codec.2302*2303* @return >= 0 on success, a negative AVERROR code on failure2304*/2305int avcodec_parameters_from_context(struct AVCodecParameters *par,2306const AVCodecContext *codec);23072308/**2309* Fill the codec context based on the values from the supplied codec2310* parameters. Any allocated fields in codec that have a corresponding field in2311* par are freed and replaced with duplicates of the corresponding field in par.2312* Fields in codec that do not have a counterpart in par are not touched.2313*2314* @return >= 0 on success, a negative AVERROR code on failure.2315*/2316int avcodec_parameters_to_context(AVCodecContext *codec,2317const struct AVCodecParameters *par);23182319/**2320* Initialize the AVCodecContext to use the given AVCodec. Prior to using this2321* function the context has to be allocated with avcodec_alloc_context3().2322*2323* The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),2324* avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for2325* retrieving a codec.2326*2327* Depending on the codec, you might need to set options in the codec context2328* also for decoding (e.g. width, height, or the pixel or audio sample format in2329* the case the information is not available in the bitstream, as when decoding2330* raw audio or video).2331*2332* Options in the codec context can be set either by setting them in the options2333* AVDictionary, or by setting the values in the context itself, directly or by2334* using the av_opt_set() API before calling this function.2335*2336* Example:2337* @code2338* av_dict_set(&opts, "b", "2.5M", 0);2339* codec = avcodec_find_decoder(AV_CODEC_ID_H264);2340* if (!codec)2341* exit(1);2342*2343* context = avcodec_alloc_context3(codec);2344*2345* if (avcodec_open2(context, codec, opts) < 0)2346* exit(1);2347* @endcode2348*2349* In the case AVCodecParameters are available (e.g. when demuxing a stream2350* using libavformat, and accessing the AVStream contained in the demuxer), the2351* codec parameters can be copied to the codec context using2352* avcodec_parameters_to_context(), as in the following example:2353*2354* @code2355* AVStream *stream = ...;2356* context = avcodec_alloc_context3(codec);2357* if (avcodec_parameters_to_context(context, stream->codecpar) < 0)2358* exit(1);2359* if (avcodec_open2(context, codec, NULL) < 0)2360* exit(1);2361* @endcode2362*2363* @note Always call this function before using decoding routines (such as2364* @ref avcodec_receive_frame()).2365*2366* @param avctx The context to initialize.2367* @param codec The codec to open this context for. If a non-NULL codec has been2368* previously passed to avcodec_alloc_context3() or2369* for this context, then this parameter MUST be either NULL or2370* equal to the previously passed codec.2371* @param options A dictionary filled with AVCodecContext and codec-private2372* options, which are set on top of the options already set in2373* avctx, can be NULL. On return this object will be filled with2374* options that were not found in the avctx codec context.2375*2376* @return zero on success, a negative value on error2377* @see avcodec_alloc_context3(), avcodec_find_decoder(), avcodec_find_encoder(),2378* av_dict_set(), av_opt_set(), av_opt_find(), avcodec_parameters_to_context()2379*/2380int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options);23812382#if FF_API_AVCODEC_CLOSE2383/**2384* Close a given AVCodecContext and free all the data associated with it2385* (but not the AVCodecContext itself).2386*2387* Calling this function on an AVCodecContext that hasn't been opened will free2388* the codec-specific data allocated in avcodec_alloc_context3() with a non-NULL2389* codec. Subsequent calls will do nothing.2390*2391* @deprecated Do not use this function. Use avcodec_free_context() to destroy a2392* codec context (either open or closed). Opening and closing a codec context2393* multiple times is not supported anymore -- use multiple codec contexts2394* instead.2395*/2396attribute_deprecated2397int avcodec_close(AVCodecContext *avctx);2398#endif23992400/**2401* Free all allocated data in the given subtitle struct.2402*2403* @param sub AVSubtitle to free.2404*/2405void avsubtitle_free(AVSubtitle *sub);24062407/**2408* @}2409*/24102411/**2412* @addtogroup lavc_decoding2413* @{2414*/24152416/**2417* The default callback for AVCodecContext.get_buffer2(). It is made public so2418* it can be called by custom get_buffer2() implementations for decoders without2419* AV_CODEC_CAP_DR1 set.2420*/2421int avcodec_default_get_buffer2(AVCodecContext *s, AVFrame *frame, int flags);24222423/**2424* The default callback for AVCodecContext.get_encode_buffer(). It is made public so2425* it can be called by custom get_encode_buffer() implementations for encoders without2426* AV_CODEC_CAP_DR1 set.2427*/2428int avcodec_default_get_encode_buffer(AVCodecContext *s, AVPacket *pkt, int flags);24292430/**2431* Modify width and height values so that they will result in a memory2432* buffer that is acceptable for the codec if you do not use any horizontal2433* padding.2434*2435* May only be used if a codec with AV_CODEC_CAP_DR1 has been opened.2436*/2437void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);24382439/**2440* Modify width and height values so that they will result in a memory2441* buffer that is acceptable for the codec if you also ensure that all2442* line sizes are a multiple of the respective linesize_align[i].2443*2444* May only be used if a codec with AV_CODEC_CAP_DR1 has been opened.2445*/2446void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,2447int linesize_align[AV_NUM_DATA_POINTERS]);24482449/**2450* Decode a subtitle message.2451* Return a negative value on error, otherwise return the number of bytes used.2452* If no subtitle could be decompressed, got_sub_ptr is zero.2453* Otherwise, the subtitle is stored in *sub.2454* Note that AV_CODEC_CAP_DR1 is not available for subtitle codecs. This is for2455* simplicity, because the performance difference is expected to be negligible2456* and reusing a get_buffer written for video codecs would probably perform badly2457* due to a potentially very different allocation pattern.2458*2459* Some decoders (those marked with AV_CODEC_CAP_DELAY) have a delay between input2460* and output. This means that for some packets they will not immediately2461* produce decoded output and need to be flushed at the end of decoding to get2462* all the decoded data. Flushing is done by calling this function with packets2463* with avpkt->data set to NULL and avpkt->size set to 0 until it stops2464* returning subtitles. It is safe to flush even those decoders that are not2465* marked with AV_CODEC_CAP_DELAY, then no subtitles will be returned.2466*2467* @note The AVCodecContext MUST have been opened with @ref avcodec_open2()2468* before packets may be fed to the decoder.2469*2470* @param avctx the codec context2471* @param[out] sub The preallocated AVSubtitle in which the decoded subtitle will be stored,2472* must be freed with avsubtitle_free if *got_sub_ptr is set.2473* @param[in,out] got_sub_ptr Zero if no subtitle could be decompressed, otherwise, it is nonzero.2474* @param[in] avpkt The input AVPacket containing the input buffer.2475*/2476int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,2477int *got_sub_ptr, const AVPacket *avpkt);24782479/**2480* Supply raw packet data as input to a decoder.2481*2482* Internally, this call will copy relevant AVCodecContext fields, which can2483* influence decoding per-packet, and apply them when the packet is actually2484* decoded. (For example AVCodecContext.skip_frame, which might direct the2485* decoder to drop the frame contained by the packet sent with this function.)2486*2487* @warning The input buffer, avpkt->data must be AV_INPUT_BUFFER_PADDING_SIZE2488* larger than the actual read bytes because some optimized bitstream2489* readers read 32 or 64 bits at once and could read over the end.2490*2491* @note The AVCodecContext MUST have been opened with @ref avcodec_open2()2492* before packets may be fed to the decoder.2493*2494* @param avctx codec context2495* @param[in] avpkt The input AVPacket. Usually, this will be a single video2496* frame, or several complete audio frames.2497* Ownership of the packet remains with the caller, and the2498* decoder will not write to the packet. The decoder may create2499* a reference to the packet data (or copy it if the packet is2500* not reference-counted).2501* Unlike with older APIs, the packet is always fully consumed,2502* and if it contains multiple frames (e.g. some audio codecs),2503* will require you to call avcodec_receive_frame() multiple2504* times afterwards before you can send a new packet.2505* It can be NULL (or an AVPacket with data set to NULL and2506* size set to 0); in this case, it is considered a flush2507* packet, which signals the end of the stream. Sending the2508* first flush packet will return success. Subsequent ones are2509* unnecessary and will return AVERROR_EOF. If the decoder2510* still has frames buffered, it will return them after sending2511* a flush packet.2512*2513* @retval 0 success2514* @retval AVERROR(EAGAIN) input is not accepted in the current state - user2515* must read output with avcodec_receive_frame() (once2516* all output is read, the packet should be resent,2517* and the call will not fail with EAGAIN).2518* @retval AVERROR_EOF the decoder has been flushed, and no new packets can be2519* sent to it (also returned if more than 1 flush2520* packet is sent)2521* @retval AVERROR(EINVAL) codec not opened, it is an encoder, or requires flush2522* @retval AVERROR(ENOMEM) failed to add packet to internal queue, or similar2523* @retval "another negative error code" legitimate decoding errors2524*/2525int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt);25262527/**2528* Return decoded output data from a decoder or encoder (when the2529* @ref AV_CODEC_FLAG_RECON_FRAME flag is used).2530*2531* @param avctx codec context2532* @param frame This will be set to a reference-counted video or audio2533* frame (depending on the decoder type) allocated by the2534* codec. Note that the function will always call2535* av_frame_unref(frame) before doing anything else.2536*2537* @retval 0 success, a frame was returned2538* @retval AVERROR(EAGAIN) output is not available in this state - user must2539* try to send new input2540* @retval AVERROR_EOF the codec has been fully flushed, and there will be2541* no more output frames2542* @retval AVERROR(EINVAL) codec not opened, or it is an encoder without the2543* @ref AV_CODEC_FLAG_RECON_FRAME flag enabled2544* @retval "other negative error code" legitimate decoding errors2545*/2546int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame);25472548/**2549* Supply a raw video or audio frame to the encoder. Use avcodec_receive_packet()2550* to retrieve buffered output packets.2551*2552* @param avctx codec context2553* @param[in] frame AVFrame containing the raw audio or video frame to be encoded.2554* Ownership of the frame remains with the caller, and the2555* encoder will not write to the frame. The encoder may create2556* a reference to the frame data (or copy it if the frame is2557* not reference-counted).2558* It can be NULL, in which case it is considered a flush2559* packet. This signals the end of the stream. If the encoder2560* still has packets buffered, it will return them after this2561* call. Once flushing mode has been entered, additional flush2562* packets are ignored, and sending frames will return2563* AVERROR_EOF.2564*2565* For audio:2566* If AV_CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame2567* can have any number of samples.2568* If it is not set, frame->nb_samples must be equal to2569* avctx->frame_size for all frames except the last.2570* The final frame may be smaller than avctx->frame_size.2571* @retval 0 success2572* @retval AVERROR(EAGAIN) input is not accepted in the current state - user must2573* read output with avcodec_receive_packet() (once all2574* output is read, the packet should be resent, and the2575* call will not fail with EAGAIN).2576* @retval AVERROR_EOF the encoder has been flushed, and no new frames can2577* be sent to it2578* @retval AVERROR(EINVAL) codec not opened, it is a decoder, or requires flush2579* @retval AVERROR(ENOMEM) failed to add packet to internal queue, or similar2580* @retval "another negative error code" legitimate encoding errors2581*/2582int avcodec_send_frame(AVCodecContext *avctx, const AVFrame *frame);25832584/**2585* Read encoded data from the encoder.2586*2587* @param avctx codec context2588* @param avpkt This will be set to a reference-counted packet allocated by the2589* encoder. Note that the function will always call2590* av_packet_unref(avpkt) before doing anything else.2591* @retval 0 success2592* @retval AVERROR(EAGAIN) output is not available in the current state - user must2593* try to send input2594* @retval AVERROR_EOF the encoder has been fully flushed, and there will be no2595* more output packets2596* @retval AVERROR(EINVAL) codec not opened, or it is a decoder2597* @retval "another negative error code" legitimate encoding errors2598*/2599int avcodec_receive_packet(AVCodecContext *avctx, AVPacket *avpkt);26002601/**2602* Create and return a AVHWFramesContext with values adequate for hardware2603* decoding. This is meant to get called from the get_format callback, and is2604* a helper for preparing a AVHWFramesContext for AVCodecContext.hw_frames_ctx.2605* This API is for decoding with certain hardware acceleration modes/APIs only.2606*2607* The returned AVHWFramesContext is not initialized. The caller must do this2608* with av_hwframe_ctx_init().2609*2610* Calling this function is not a requirement, but makes it simpler to avoid2611* codec or hardware API specific details when manually allocating frames.2612*2613* Alternatively to this, an API user can set AVCodecContext.hw_device_ctx,2614* which sets up AVCodecContext.hw_frames_ctx fully automatically, and makes2615* it unnecessary to call this function or having to care about2616* AVHWFramesContext initialization at all.2617*2618* There are a number of requirements for calling this function:2619*2620* - It must be called from get_format with the same avctx parameter that was2621* passed to get_format. Calling it outside of get_format is not allowed, and2622* can trigger undefined behavior.2623* - The function is not always supported (see description of return values).2624* Even if this function returns successfully, hwaccel initialization could2625* fail later. (The degree to which implementations check whether the stream2626* is actually supported varies. Some do this check only after the user's2627* get_format callback returns.)2628* - The hw_pix_fmt must be one of the choices suggested by get_format. If the2629* user decides to use a AVHWFramesContext prepared with this API function,2630* the user must return the same hw_pix_fmt from get_format.2631* - The device_ref passed to this function must support the given hw_pix_fmt.2632* - After calling this API function, it is the user's responsibility to2633* initialize the AVHWFramesContext (returned by the out_frames_ref parameter),2634* and to set AVCodecContext.hw_frames_ctx to it. If done, this must be done2635* before returning from get_format (this is implied by the normal2636* AVCodecContext.hw_frames_ctx API rules).2637* - The AVHWFramesContext parameters may change every time time get_format is2638* called. Also, AVCodecContext.hw_frames_ctx is reset before get_format. So2639* you are inherently required to go through this process again on every2640* get_format call.2641* - It is perfectly possible to call this function without actually using2642* the resulting AVHWFramesContext. One use-case might be trying to reuse a2643* previously initialized AVHWFramesContext, and calling this API function2644* only to test whether the required frame parameters have changed.2645* - Fields that use dynamically allocated values of any kind must not be set2646* by the user unless setting them is explicitly allowed by the documentation.2647* If the user sets AVHWFramesContext.free and AVHWFramesContext.user_opaque,2648* the new free callback must call the potentially set previous free callback.2649* This API call may set any dynamically allocated fields, including the free2650* callback.2651*2652* The function will set at least the following fields on AVHWFramesContext2653* (potentially more, depending on hwaccel API):2654*2655* - All fields set by av_hwframe_ctx_alloc().2656* - Set the format field to hw_pix_fmt.2657* - Set the sw_format field to the most suited and most versatile format. (An2658* implication is that this will prefer generic formats over opaque formats2659* with arbitrary restrictions, if possible.)2660* - Set the width/height fields to the coded frame size, rounded up to the2661* API-specific minimum alignment.2662* - Only _if_ the hwaccel requires a pre-allocated pool: set the initial_pool_size2663* field to the number of maximum reference surfaces possible with the codec,2664* plus 1 surface for the user to work (meaning the user can safely reference2665* at most 1 decoded surface at a time), plus additional buffering introduced2666* by frame threading. If the hwaccel does not require pre-allocation, the2667* field is left to 0, and the decoder will allocate new surfaces on demand2668* during decoding.2669* - Possibly AVHWFramesContext.hwctx fields, depending on the underlying2670* hardware API.2671*2672* Essentially, out_frames_ref returns the same as av_hwframe_ctx_alloc(), but2673* with basic frame parameters set.2674*2675* The function is stateless, and does not change the AVCodecContext or the2676* device_ref AVHWDeviceContext.2677*2678* @param avctx The context which is currently calling get_format, and which2679* implicitly contains all state needed for filling the returned2680* AVHWFramesContext properly.2681* @param device_ref A reference to the AVHWDeviceContext describing the device2682* which will be used by the hardware decoder.2683* @param hw_pix_fmt The hwaccel format you are going to return from get_format.2684* @param out_frames_ref On success, set to a reference to an _uninitialized_2685* AVHWFramesContext, created from the given device_ref.2686* Fields will be set to values required for decoding.2687* Not changed if an error is returned.2688* @return zero on success, a negative value on error. The following error codes2689* have special semantics:2690* AVERROR(ENOENT): the decoder does not support this functionality. Setup2691* is always manual, or it is a decoder which does not2692* support setting AVCodecContext.hw_frames_ctx at all,2693* or it is a software format.2694* AVERROR(EINVAL): it is known that hardware decoding is not supported for2695* this configuration, or the device_ref is not supported2696* for the hwaccel referenced by hw_pix_fmt.2697*/2698int avcodec_get_hw_frames_parameters(AVCodecContext *avctx,2699AVBufferRef *device_ref,2700enum AVPixelFormat hw_pix_fmt,2701AVBufferRef **out_frames_ref);27022703enum AVCodecConfig {2704AV_CODEC_CONFIG_PIX_FORMAT, ///< AVPixelFormat, terminated by AV_PIX_FMT_NONE2705AV_CODEC_CONFIG_FRAME_RATE, ///< AVRational, terminated by {0, 0}2706AV_CODEC_CONFIG_SAMPLE_RATE, ///< int, terminated by 02707AV_CODEC_CONFIG_SAMPLE_FORMAT, ///< AVSampleFormat, terminated by AV_SAMPLE_FMT_NONE2708AV_CODEC_CONFIG_CHANNEL_LAYOUT, ///< AVChannelLayout, terminated by {0}2709AV_CODEC_CONFIG_COLOR_RANGE, ///< AVColorRange, terminated by AVCOL_RANGE_UNSPECIFIED2710AV_CODEC_CONFIG_COLOR_SPACE, ///< AVColorSpace, terminated by AVCOL_SPC_UNSPECIFIED2711};27122713/**2714* Retrieve a list of all supported values for a given configuration type.2715*2716* @param avctx An optional context to use. Values such as2717* `strict_std_compliance` may affect the result. If NULL,2718* default values are used.2719* @param codec The codec to query, or NULL to use avctx->codec.2720* @param config The configuration to query.2721* @param flags Currently unused; should be set to zero.2722* @param out_configs On success, set to a list of configurations, terminated2723* by a config-specific terminator, or NULL if all2724* possible values are supported.2725* @param out_num_configs On success, set to the number of elements in2726*out_configs, excluding the terminator. Optional.2727*/2728int avcodec_get_supported_config(const AVCodecContext *avctx,2729const AVCodec *codec, enum AVCodecConfig config,2730unsigned flags, const void **out_configs,2731int *out_num_configs);2732273327342735/**2736* @defgroup lavc_parsing Frame parsing2737* @{2738*/27392740enum AVPictureStructure {2741AV_PICTURE_STRUCTURE_UNKNOWN, ///< unknown2742AV_PICTURE_STRUCTURE_TOP_FIELD, ///< coded as top field2743AV_PICTURE_STRUCTURE_BOTTOM_FIELD, ///< coded as bottom field2744AV_PICTURE_STRUCTURE_FRAME, ///< coded as frame2745};27462747typedef struct AVCodecParserContext {2748void *priv_data;2749const struct AVCodecParser *parser;2750int64_t frame_offset; /* offset of the current frame */2751int64_t cur_offset; /* current offset2752(incremented by each av_parser_parse()) */2753int64_t next_frame_offset; /* offset of the next frame */2754/* video info */2755int pict_type; /* XXX: Put it back in AVCodecContext. */2756/**2757* This field is used for proper frame duration computation in lavf.2758* It signals, how much longer the frame duration of the current frame2759* is compared to normal frame duration.2760*2761* frame_duration = (1 + repeat_pict) * time_base2762*2763* It is used by codecs like H.264 to display telecined material.2764*/2765int repeat_pict; /* XXX: Put it back in AVCodecContext. */2766int64_t pts; /* pts of the current frame */2767int64_t dts; /* dts of the current frame */27682769/* private data */2770int64_t last_pts;2771int64_t last_dts;2772int fetch_timestamp;27732774#define AV_PARSER_PTS_NB 42775int cur_frame_start_index;2776int64_t cur_frame_offset[AV_PARSER_PTS_NB];2777int64_t cur_frame_pts[AV_PARSER_PTS_NB];2778int64_t cur_frame_dts[AV_PARSER_PTS_NB];27792780int flags;2781#define PARSER_FLAG_COMPLETE_FRAMES 0x00012782#define PARSER_FLAG_ONCE 0x00022783/// Set if the parser has a valid file offset2784#define PARSER_FLAG_FETCHED_OFFSET 0x00042785#define PARSER_FLAG_USE_CODEC_TS 0x100027862787int64_t offset; ///< byte offset from starting packet start2788int64_t cur_frame_end[AV_PARSER_PTS_NB];27892790/**2791* Set by parser to 1 for key frames and 0 for non-key frames.2792* It is initialized to -1, so if the parser doesn't set this flag,2793* old-style fallback using AV_PICTURE_TYPE_I picture type as key frames2794* will be used.2795*/2796int key_frame;27972798// Timestamp generation support:2799/**2800* Synchronization point for start of timestamp generation.2801*2802* Set to >0 for sync point, 0 for no sync point and <0 for undefined2803* (default).2804*2805* For example, this corresponds to presence of H.264 buffering period2806* SEI message.2807*/2808int dts_sync_point;28092810/**2811* Offset of the current timestamp against last timestamp sync point in2812* units of AVCodecContext.time_base.2813*2814* Set to INT_MIN when dts_sync_point unused. Otherwise, it must2815* contain a valid timestamp offset.2816*2817* Note that the timestamp of sync point has usually a nonzero2818* dts_ref_dts_delta, which refers to the previous sync point. Offset of2819* the next frame after timestamp sync point will be usually 1.2820*2821* For example, this corresponds to H.264 cpb_removal_delay.2822*/2823int dts_ref_dts_delta;28242825/**2826* Presentation delay of current frame in units of AVCodecContext.time_base.2827*2828* Set to INT_MIN when dts_sync_point unused. Otherwise, it must2829* contain valid non-negative timestamp delta (presentation time of a frame2830* must not lie in the past).2831*2832* This delay represents the difference between decoding and presentation2833* time of the frame.2834*2835* For example, this corresponds to H.264 dpb_output_delay.2836*/2837int pts_dts_delta;28382839/**2840* Position of the packet in file.2841*2842* Analogous to cur_frame_pts/dts2843*/2844int64_t cur_frame_pos[AV_PARSER_PTS_NB];28452846/**2847* Byte position of currently parsed frame in stream.2848*/2849int64_t pos;28502851/**2852* Previous frame byte position.2853*/2854int64_t last_pos;28552856/**2857* Duration of the current frame.2858* For audio, this is in units of 1 / AVCodecContext.sample_rate.2859* For all other types, this is in units of AVCodecContext.time_base.2860*/2861int duration;28622863enum AVFieldOrder field_order;28642865/**2866* Indicate whether a picture is coded as a frame, top field or bottom field.2867*2868* For example, H.264 field_pic_flag equal to 0 corresponds to2869* AV_PICTURE_STRUCTURE_FRAME. An H.264 picture with field_pic_flag2870* equal to 1 and bottom_field_flag equal to 0 corresponds to2871* AV_PICTURE_STRUCTURE_TOP_FIELD.2872*/2873enum AVPictureStructure picture_structure;28742875/**2876* Picture number incremented in presentation or output order.2877* This field may be reinitialized at the first picture of a new sequence.2878*2879* For example, this corresponds to H.264 PicOrderCnt.2880*/2881int output_picture_number;28822883/**2884* Dimensions of the decoded video intended for presentation.2885*/2886int width;2887int height;28882889/**2890* Dimensions of the coded video.2891*/2892int coded_width;2893int coded_height;28942895/**2896* The format of the coded data, corresponds to enum AVPixelFormat for video2897* and for enum AVSampleFormat for audio.2898*2899* Note that a decoder can have considerable freedom in how exactly it2900* decodes the data, so the format reported here might be different from the2901* one returned by a decoder.2902*/2903int format;2904} AVCodecParserContext;29052906typedef struct AVCodecParser {2907int codec_ids[7]; /* several codec IDs are permitted */2908int priv_data_size;2909int (*parser_init)(AVCodecParserContext *s);2910/* This callback never returns an error, a negative value means that2911* the frame start was in a previous packet. */2912int (*parser_parse)(AVCodecParserContext *s,2913AVCodecContext *avctx,2914const uint8_t **poutbuf, int *poutbuf_size,2915const uint8_t *buf, int buf_size);2916void (*parser_close)(AVCodecParserContext *s);2917int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size);2918} AVCodecParser;29192920/**2921* Iterate over all registered codec parsers.2922*2923* @param opaque a pointer where libavcodec will store the iteration state. Must2924* point to NULL to start the iteration.2925*2926* @return the next registered codec parser or NULL when the iteration is2927* finished2928*/2929const AVCodecParser *av_parser_iterate(void **opaque);29302931AVCodecParserContext *av_parser_init(int codec_id);29322933/**2934* Parse a packet.2935*2936* @param s parser context.2937* @param avctx codec context.2938* @param poutbuf set to pointer to parsed buffer or NULL if not yet finished.2939* @param poutbuf_size set to size of parsed buffer or zero if not yet finished.2940* @param buf input buffer.2941* @param buf_size buffer size in bytes without the padding. I.e. the full buffer2942size is assumed to be buf_size + AV_INPUT_BUFFER_PADDING_SIZE.2943To signal EOF, this should be 0 (so that the last frame2944can be output).2945* @param pts input presentation timestamp.2946* @param dts input decoding timestamp.2947* @param pos input byte position in stream.2948* @return the number of bytes of the input bitstream used.2949*2950* Example:2951* @code2952* while(in_len){2953* len = av_parser_parse2(myparser, AVCodecContext, &data, &size,2954* in_data, in_len,2955* pts, dts, pos);2956* in_data += len;2957* in_len -= len;2958*2959* if(size)2960* decode_frame(data, size);2961* }2962* @endcode2963*/2964int av_parser_parse2(AVCodecParserContext *s,2965AVCodecContext *avctx,2966uint8_t **poutbuf, int *poutbuf_size,2967const uint8_t *buf, int buf_size,2968int64_t pts, int64_t dts,2969int64_t pos);29702971void av_parser_close(AVCodecParserContext *s);29722973/**2974* @}2975* @}2976*/29772978/**2979* @addtogroup lavc_encoding2980* @{2981*/29822983int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,2984const AVSubtitle *sub);298529862987/**2988* @}2989*/29902991/**2992* @defgroup lavc_misc Utility functions2993* @ingroup libavc2994*2995* Miscellaneous utility functions related to both encoding and decoding2996* (or neither).2997* @{2998*/29993000/**3001* @defgroup lavc_misc_pixfmt Pixel formats3002*3003* Functions for working with pixel formats.3004* @{3005*/30063007/**3008* Return a value representing the fourCC code associated to the3009* pixel format pix_fmt, or 0 if no associated fourCC code can be3010* found.3011*/3012unsigned int avcodec_pix_fmt_to_codec_tag(enum AVPixelFormat pix_fmt);30133014/**3015* Find the best pixel format to convert to given a certain source pixel3016* format. When converting from one pixel format to another, information loss3017* may occur. For example, when converting from RGB24 to GRAY, the color3018* information will be lost. Similarly, other losses occur when converting from3019* some formats to other formats. avcodec_find_best_pix_fmt_of_2() searches which of3020* the given pixel formats should be used to suffer the least amount of loss.3021* The pixel formats from which it chooses one, are determined by the3022* pix_fmt_list parameter.3023*3024*3025* @param[in] pix_fmt_list AV_PIX_FMT_NONE terminated array of pixel formats to choose from3026* @param[in] src_pix_fmt source pixel format3027* @param[in] has_alpha Whether the source pixel format alpha channel is used.3028* @param[out] loss_ptr Combination of flags informing you what kind of losses will occur.3029* @return The best pixel format to convert to or -1 if none was found.3030*/3031enum AVPixelFormat avcodec_find_best_pix_fmt_of_list(const enum AVPixelFormat *pix_fmt_list,3032enum AVPixelFormat src_pix_fmt,3033int has_alpha, int *loss_ptr);30343035enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum AVPixelFormat * fmt);30363037/**3038* @}3039*/30403041void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);30423043int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size);3044int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count);3045//FIXME func typedef30463047/**3048* Fill AVFrame audio data and linesize pointers.3049*3050* The buffer buf must be a preallocated buffer with a size big enough3051* to contain the specified samples amount. The filled AVFrame data3052* pointers will point to this buffer.3053*3054* AVFrame extended_data channel pointers are allocated if necessary for3055* planar audio.3056*3057* @param frame the AVFrame3058* frame->nb_samples must be set prior to calling the3059* function. This function fills in frame->data,3060* frame->extended_data, frame->linesize[0].3061* @param nb_channels channel count3062* @param sample_fmt sample format3063* @param buf buffer to use for frame data3064* @param buf_size size of buffer3065* @param align plane size sample alignment (0 = default)3066* @return >=0 on success, negative error code on failure3067* @todo return the size in bytes required to store the samples in3068* case of success, at the next libavutil bump3069*/3070int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels,3071enum AVSampleFormat sample_fmt, const uint8_t *buf,3072int buf_size, int align);30733074/**3075* Reset the internal codec state / flush internal buffers. Should be called3076* e.g. when seeking or when switching to a different stream.3077*3078* @note for decoders, this function just releases any references the decoder3079* might keep internally, but the caller's references remain valid.3080*3081* @note for encoders, this function will only do something if the encoder3082* declares support for AV_CODEC_CAP_ENCODER_FLUSH. When called, the encoder3083* will drain any remaining packets, and can then be re-used for a different3084* stream (as opposed to sending a null frame which will leave the encoder3085* in a permanent EOF state after draining). This can be desirable if the3086* cost of tearing down and replacing the encoder instance is high.3087*/3088void avcodec_flush_buffers(AVCodecContext *avctx);30893090/**3091* Return audio frame duration.3092*3093* @param avctx codec context3094* @param frame_bytes size of the frame, or 0 if unknown3095* @return frame duration, in samples, if known. 0 if not able to3096* determine.3097*/3098int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes);30993100/* memory */31013102/**3103* Same behaviour av_fast_malloc but the buffer has additional3104* AV_INPUT_BUFFER_PADDING_SIZE at the end which will always be 0.3105*3106* In addition the whole buffer will initially and after resizes3107* be 0-initialized so that no uninitialized data will ever appear.3108*/3109void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size);31103111/**3112* Same behaviour av_fast_padded_malloc except that buffer will always3113* be 0-initialized after call.3114*/3115void av_fast_padded_mallocz(void *ptr, unsigned int *size, size_t min_size);31163117/**3118* @return a positive value if s is open (i.e. avcodec_open2() was called on it3119* with no corresponding avcodec_close()), 0 otherwise.3120*/3121int avcodec_is_open(AVCodecContext *s);31223123/**3124* @}3125*/31263127#endif /* AVCODEC_AVCODEC_H */312831293130