Path: blob/a-new-beginning/libavcodec.xcframework/ios-arm64/libavcodec.framework/Headers/avcodec.h
2 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/dict.h"34#include "libavutil/frame.h"35#include "libavutil/log.h"36#include "libavutil/pixfmt.h"37#include "libavutil/rational.h"3839#include "codec.h"40#include "codec_desc.h"41#include "codec_par.h"42#include "codec_id.h"43#include "defs.h"44#include "packet.h"45#include "version_major.h"46#ifndef HAVE_AV_CONFIG_H47/* When included as part of the ffmpeg build, only include the major version48* to avoid unnecessary rebuilds. When included externally, keep including49* the full version information. */50#include "version.h"51#endif5253/**54* @defgroup libavc libavcodec55* Encoding/Decoding Library56*57* @{58*59* @defgroup lavc_decoding Decoding60* @{61* @}62*63* @defgroup lavc_encoding Encoding64* @{65* @}66*67* @defgroup lavc_codec Codecs68* @{69* @defgroup lavc_codec_native Native Codecs70* @{71* @}72* @defgroup lavc_codec_wrappers External library wrappers73* @{74* @}75* @defgroup lavc_codec_hwaccel Hardware Accelerators bridge76* @{77* @}78* @}79* @defgroup lavc_internal Internal80* @{81* @}82* @}83*/8485/**86* @ingroup libavc87* @defgroup lavc_encdec send/receive encoding and decoding API overview88* @{89*90* The avcodec_send_packet()/avcodec_receive_frame()/avcodec_send_frame()/91* avcodec_receive_packet() functions provide an encode/decode API, which92* decouples input and output.93*94* The API is very similar for encoding/decoding and audio/video, and works as95* follows:96* - Set up and open the AVCodecContext as usual.97* - Send valid input:98* - For decoding, call avcodec_send_packet() to give the decoder raw99* compressed data in an AVPacket.100* - For encoding, call avcodec_send_frame() to give the encoder an AVFrame101* containing uncompressed audio or video.102*103* In both cases, it is recommended that AVPackets and AVFrames are104* refcounted, or libavcodec might have to copy the input data. (libavformat105* always returns refcounted AVPackets, and av_frame_get_buffer() allocates106* refcounted AVFrames.)107* - Receive output in a loop. Periodically call one of the avcodec_receive_*()108* functions and process their output:109* - For decoding, call avcodec_receive_frame(). On success, it will return110* an AVFrame containing uncompressed audio or video data.111* - For encoding, call avcodec_receive_packet(). On success, it will return112* an AVPacket with a compressed frame.113*114* Repeat this call until it returns AVERROR(EAGAIN) or an error. The115* AVERROR(EAGAIN) return value means that new input data is required to116* return new output. In this case, continue with sending input. For each117* input frame/packet, the codec will typically return 1 output frame/packet,118* but it can also be 0 or more than 1.119*120* At the beginning of decoding or encoding, the codec might accept multiple121* input frames/packets without returning a frame, until its internal buffers122* are filled. This situation is handled transparently if you follow the steps123* outlined above.124*125* In theory, sending input can result in EAGAIN - this should happen only if126* not all output was received. You can use this to structure alternative decode127* or encode loops other than the one suggested above. For example, you could128* try sending new input on each iteration, and try to receive output if that129* returns EAGAIN.130*131* End of stream situations. These require "flushing" (aka draining) the codec,132* as the codec might buffer multiple frames or packets internally for133* performance or out of necessity (consider B-frames).134* This is handled as follows:135* - Instead of valid input, send NULL to the avcodec_send_packet() (decoding)136* or avcodec_send_frame() (encoding) functions. This will enter draining137* mode.138* - Call avcodec_receive_frame() (decoding) or avcodec_receive_packet()139* (encoding) in a loop until AVERROR_EOF is returned. The functions will140* not return AVERROR(EAGAIN), unless you forgot to enter draining mode.141* - Before decoding can be resumed again, the codec has to be reset with142* avcodec_flush_buffers().143*144* Using the API as outlined above is highly recommended. But it is also145* possible to call functions outside of this rigid schema. For example, you can146* call avcodec_send_packet() repeatedly without calling147* avcodec_receive_frame(). In this case, avcodec_send_packet() will succeed148* until the codec's internal buffer has been filled up (which is typically of149* size 1 per output frame, after initial input), and then reject input with150* AVERROR(EAGAIN). Once it starts rejecting input, you have no choice but to151* read at least some output.152*153* Not all codecs will follow a rigid and predictable dataflow; the only154* guarantee is that an AVERROR(EAGAIN) return value on a send/receive call on155* one end implies that a receive/send call on the other end will succeed, or156* at least will not fail with AVERROR(EAGAIN). In general, no codec will157* permit unlimited buffering of input or output.158*159* A codec is not allowed to return AVERROR(EAGAIN) for both sending and receiving. This160* would be an invalid state, which could put the codec user into an endless161* loop. The API has no concept of time either: it cannot happen that trying to162* do avcodec_send_packet() results in AVERROR(EAGAIN), but a repeated call 1 second163* later accepts the packet (with no other receive/flush API calls involved).164* The API is a strict state machine, and the passage of time is not supposed165* to influence it. Some timing-dependent behavior might still be deemed166* acceptable in certain cases. But it must never result in both send/receive167* returning EAGAIN at the same time at any point. It must also absolutely be168* avoided that the current state is "unstable" and can "flip-flop" between169* the send/receive APIs allowing progress. For example, it's not allowed that170* the codec randomly decides that it actually wants to consume a packet now171* instead of returning a frame, after it just returned AVERROR(EAGAIN) on an172* avcodec_send_packet() call.173* @}174*/175176/**177* @defgroup lavc_core Core functions/structures.178* @ingroup libavc179*180* Basic definitions, functions for querying libavcodec capabilities,181* allocating core structures, etc.182* @{183*/184185/**186* @ingroup lavc_encoding187* minimum encoding buffer size188* Used to avoid some checks during header writing.189*/190#define AV_INPUT_BUFFER_MIN_SIZE 16384191192/**193* @ingroup lavc_encoding194*/195typedef struct RcOverride{196int start_frame;197int end_frame;198int qscale; // If this is 0 then quality_factor will be used instead.199float quality_factor;200} RcOverride;201202/* encoding support203These flags can be passed in AVCodecContext.flags before initialization.204Note: Not everything is supported yet.205*/206207/**208* Allow decoders to produce frames with data planes that are not aligned209* to CPU requirements (e.g. due to cropping).210*/211#define AV_CODEC_FLAG_UNALIGNED (1 << 0)212/**213* Use fixed qscale.214*/215#define AV_CODEC_FLAG_QSCALE (1 << 1)216/**217* 4 MV per MB allowed / advanced prediction for H.263.218*/219#define AV_CODEC_FLAG_4MV (1 << 2)220/**221* Output even those frames that might be corrupted.222*/223#define AV_CODEC_FLAG_OUTPUT_CORRUPT (1 << 3)224/**225* Use qpel MC.226*/227#define AV_CODEC_FLAG_QPEL (1 << 4)228/**229* Don't output frames whose parameters differ from first230* decoded frame in stream.231*/232#define AV_CODEC_FLAG_DROPCHANGED (1 << 5)233/**234* Request the encoder to output reconstructed frames, i.e.\ frames that would235* be produced by decoding the encoded bistream. These frames may be retrieved236* by calling avcodec_receive_frame() immediately after a successful call to237* avcodec_receive_packet().238*239* Should only be used with encoders flagged with the240* @ref AV_CODEC_CAP_ENCODER_RECON_FRAME capability.241*/242#define AV_CODEC_FLAG_RECON_FRAME (1 << 6)243/**244* @par decoding245* Request the decoder to propagate each packets AVPacket.opaque and246* AVPacket.opaque_ref to its corresponding output AVFrame.247*248* @par encoding:249* Request the encoder to propagate each frame's AVFrame.opaque and250* AVFrame.opaque_ref values to its corresponding output AVPacket.251*252* @par253* May only be set on encoders that have the254* @ref AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE capability flag.255*256* @note257* While in typical cases one input frame produces exactly one output packet258* (perhaps after a delay), in general the mapping of frames to packets is259* M-to-N, so260* - Any number of input frames may be associated with any given output packet.261* This includes zero - e.g. some encoders may output packets that carry only262* metadata about the whole stream.263* - A given input frame may be associated with any number of output packets.264* Again this includes zero - e.g. some encoders may drop frames under certain265* conditions.266* .267* This implies that when using this flag, the caller must NOT assume that268* - a given input frame's opaques will necessarily appear on some output packet;269* - every output packet will have some non-NULL opaque value.270* .271* When an output packet contains multiple frames, the opaque values will be272* taken from the first of those.273*274* @note275* The converse holds for decoders, with frames and packets switched.276*/277#define AV_CODEC_FLAG_COPY_OPAQUE (1 << 7)278/**279* Signal to the encoder that the values of AVFrame.duration are valid and280* should be used (typically for transferring them to output packets).281*282* If this flag is not set, frame durations are ignored.283*/284#define AV_CODEC_FLAG_FRAME_DURATION (1 << 8)285/**286* Use internal 2pass ratecontrol in first pass mode.287*/288#define AV_CODEC_FLAG_PASS1 (1 << 9)289/**290* Use internal 2pass ratecontrol in second pass mode.291*/292#define AV_CODEC_FLAG_PASS2 (1 << 10)293/**294* loop filter.295*/296#define AV_CODEC_FLAG_LOOP_FILTER (1 << 11)297/**298* Only decode/encode grayscale.299*/300#define AV_CODEC_FLAG_GRAY (1 << 13)301/**302* error[?] variables will be set during encoding.303*/304#define AV_CODEC_FLAG_PSNR (1 << 15)305/**306* Use interlaced DCT.307*/308#define AV_CODEC_FLAG_INTERLACED_DCT (1 << 18)309/**310* Force low delay.311*/312#define AV_CODEC_FLAG_LOW_DELAY (1 << 19)313/**314* Place global headers in extradata instead of every keyframe.315*/316#define AV_CODEC_FLAG_GLOBAL_HEADER (1 << 22)317/**318* Use only bitexact stuff (except (I)DCT).319*/320#define AV_CODEC_FLAG_BITEXACT (1 << 23)321/* Fx : Flag for H.263+ extra options */322/**323* H.263 advanced intra coding / MPEG-4 AC prediction324*/325#define AV_CODEC_FLAG_AC_PRED (1 << 24)326/**327* interlaced motion estimation328*/329#define AV_CODEC_FLAG_INTERLACED_ME (1 << 29)330#define AV_CODEC_FLAG_CLOSED_GOP (1U << 31)331332/**333* Allow non spec compliant speedup tricks.334*/335#define AV_CODEC_FLAG2_FAST (1 << 0)336/**337* Skip bitstream encoding.338*/339#define AV_CODEC_FLAG2_NO_OUTPUT (1 << 2)340/**341* Place global headers at every keyframe instead of in extradata.342*/343#define AV_CODEC_FLAG2_LOCAL_HEADER (1 << 3)344345/**346* Input bitstream might be truncated at a packet boundaries347* instead of only at frame boundaries.348*/349#define AV_CODEC_FLAG2_CHUNKS (1 << 15)350/**351* Discard cropping information from SPS.352*/353#define AV_CODEC_FLAG2_IGNORE_CROP (1 << 16)354355/**356* Show all frames before the first keyframe357*/358#define AV_CODEC_FLAG2_SHOW_ALL (1 << 22)359/**360* Export motion vectors through frame side data361*/362#define AV_CODEC_FLAG2_EXPORT_MVS (1 << 28)363/**364* Do not skip samples and export skip information as frame side data365*/366#define AV_CODEC_FLAG2_SKIP_MANUAL (1 << 29)367/**368* Do not reset ASS ReadOrder field on flush (subtitles decoding)369*/370#define AV_CODEC_FLAG2_RO_FLUSH_NOOP (1 << 30)371/**372* Generate/parse ICC profiles on encode/decode, as appropriate for the type of373* file. No effect on codecs which cannot contain embedded ICC profiles, or374* when compiled without support for lcms2.375*/376#define AV_CODEC_FLAG2_ICC_PROFILES (1U << 31)377378/* Exported side data.379These flags can be passed in AVCodecContext.export_side_data before initialization.380*/381/**382* Export motion vectors through frame side data383*/384#define AV_CODEC_EXPORT_DATA_MVS (1 << 0)385/**386* Export encoder Producer Reference Time through packet side data387*/388#define AV_CODEC_EXPORT_DATA_PRFT (1 << 1)389/**390* Decoding only.391* Export the AVVideoEncParams structure through frame side data.392*/393#define AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS (1 << 2)394/**395* Decoding only.396* Do not apply film grain, export it instead.397*/398#define AV_CODEC_EXPORT_DATA_FILM_GRAIN (1 << 3)399400/**401* The decoder will keep a reference to the frame and may reuse it later.402*/403#define AV_GET_BUFFER_FLAG_REF (1 << 0)404405/**406* The encoder will keep a reference to the packet and may reuse it later.407*/408#define AV_GET_ENCODE_BUFFER_FLAG_REF (1 << 0)409410struct AVCodecInternal;411412/**413* main external API structure.414* New fields can be added to the end with minor version bumps.415* Removal, reordering and changes to existing fields require a major416* version bump.417* You can use AVOptions (av_opt* / av_set/get*()) to access these fields from user418* applications.419* The name string for AVOptions options matches the associated command line420* parameter name and can be found in libavcodec/options_table.h421* The AVOption/command line parameter names differ in some cases from the C422* structure field names for historic reasons or brevity.423* sizeof(AVCodecContext) must not be used outside libav*.424*/425typedef struct AVCodecContext {426/**427* information on struct for av_log428* - set by avcodec_alloc_context3429*/430const AVClass *av_class;431int log_level_offset;432433enum AVMediaType codec_type; /* see AVMEDIA_TYPE_xxx */434const struct AVCodec *codec;435enum AVCodecID codec_id; /* see AV_CODEC_ID_xxx */436437/**438* fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').439* This is used to work around some encoder bugs.440* A demuxer should set this to what is stored in the field used to identify the codec.441* If there are multiple such fields in a container then the demuxer should choose the one442* which maximizes the information about the used codec.443* If the codec tag field in a container is larger than 32 bits then the demuxer should444* remap the longer ID to 32 bits with a table or other structure. Alternatively a new445* extra_codec_tag + size could be added but for this a clear advantage must be demonstrated446* first.447* - encoding: Set by user, if not then the default based on codec_id will be used.448* - decoding: Set by user, will be converted to uppercase by libavcodec during init.449*/450unsigned int codec_tag;451452void *priv_data;453454/**455* Private context used for internal data.456*457* Unlike priv_data, this is not codec-specific. It is used in general458* libavcodec functions.459*/460struct AVCodecInternal *internal;461462/**463* Private data of the user, can be used to carry app specific stuff.464* - encoding: Set by user.465* - decoding: Set by user.466*/467void *opaque;468469/**470* the average bitrate471* - encoding: Set by user; unused for constant quantizer encoding.472* - decoding: Set by user, may be overwritten by libavcodec473* if this info is available in the stream474*/475int64_t bit_rate;476477/**478* number of bits the bitstream is allowed to diverge from the reference.479* the reference can be CBR (for CBR pass1) or VBR (for pass2)480* - encoding: Set by user; unused for constant quantizer encoding.481* - decoding: unused482*/483int bit_rate_tolerance;484485/**486* Global quality for codecs which cannot change it per frame.487* This should be proportional to MPEG-1/2/4 qscale.488* - encoding: Set by user.489* - decoding: unused490*/491int global_quality;492493/**494* - encoding: Set by user.495* - decoding: unused496*/497int compression_level;498#define FF_COMPRESSION_DEFAULT -1499500/**501* AV_CODEC_FLAG_*.502* - encoding: Set by user.503* - decoding: Set by user.504*/505int flags;506507/**508* AV_CODEC_FLAG2_*509* - encoding: Set by user.510* - decoding: Set by user.511*/512int flags2;513514/**515* some codecs need / can use extradata like Huffman tables.516* MJPEG: Huffman tables517* rv10: additional flags518* MPEG-4: global headers (they can be in the bitstream or here)519* The allocated memory should be AV_INPUT_BUFFER_PADDING_SIZE bytes larger520* than extradata_size to avoid problems if it is read with the bitstream reader.521* The bytewise contents of extradata must not depend on the architecture or CPU endianness.522* Must be allocated with the av_malloc() family of functions.523* - encoding: Set/allocated/freed by libavcodec.524* - decoding: Set/allocated/freed by user.525*/526uint8_t *extradata;527int extradata_size;528529/**530* This is the fundamental unit of time (in seconds) in terms531* of which frame timestamps are represented. For fixed-fps content,532* timebase should be 1/framerate and timestamp increments should be533* identically 1.534* This often, but not always is the inverse of the frame rate or field rate535* for video. 1/time_base is not the average frame rate if the frame rate is not536* constant.537*538* Like containers, elementary streams also can store timestamps, 1/time_base539* is the unit in which these timestamps are specified.540* As example of such codec time base see ISO/IEC 14496-2:2001(E)541* vop_time_increment_resolution and fixed_vop_rate542* (fixed_vop_rate == 0 implies that it is different from the framerate)543*544* - encoding: MUST be set by user.545* - decoding: unused.546*/547AVRational time_base;548549/**550* For some codecs, the time base is closer to the field rate than the frame rate.551* Most notably, H.264 and MPEG-2 specify time_base as half of frame duration552* if no telecine is used ...553*554* Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2.555*/556int ticks_per_frame;557558/**559* Codec delay.560*561* Encoding: Number of frames delay there will be from the encoder input to562* the decoder output. (we assume the decoder matches the spec)563* Decoding: Number of frames delay in addition to what a standard decoder564* as specified in the spec would produce.565*566* Video:567* Number of frames the decoded output will be delayed relative to the568* encoded input.569*570* Audio:571* For encoding, this field is unused (see initial_padding).572*573* For decoding, this is the number of samples the decoder needs to574* output before the decoder's output is valid. When seeking, you should575* start decoding this many samples prior to your desired seek point.576*577* - encoding: Set by libavcodec.578* - decoding: Set by libavcodec.579*/580int delay;581582583/* video only */584/**585* picture width / height.586*587* @note Those fields may not match the values of the last588* AVFrame output by avcodec_receive_frame() due frame589* reordering.590*591* - encoding: MUST be set by user.592* - decoding: May be set by the user before opening the decoder if known e.g.593* from the container. Some decoders will require the dimensions594* to be set by the caller. During decoding, the decoder may595* overwrite those values as required while parsing the data.596*/597int width, height;598599/**600* Bitstream width / height, may be different from width/height e.g. when601* the decoded frame is cropped before being output or lowres is enabled.602*603* @note Those field may not match the value of the last604* AVFrame output by avcodec_receive_frame() due frame605* reordering.606*607* - encoding: unused608* - decoding: May be set by the user before opening the decoder if known609* e.g. from the container. During decoding, the decoder may610* overwrite those values as required while parsing the data.611*/612int coded_width, coded_height;613614/**615* the number of pictures in a group of pictures, or 0 for intra_only616* - encoding: Set by user.617* - decoding: unused618*/619int gop_size;620621/**622* Pixel format, see AV_PIX_FMT_xxx.623* May be set by the demuxer if known from headers.624* May be overridden by the decoder if it knows better.625*626* @note This field may not match the value of the last627* AVFrame output by avcodec_receive_frame() due frame628* reordering.629*630* - encoding: Set by user.631* - decoding: Set by user if known, overridden by libavcodec while632* parsing the data.633*/634enum AVPixelFormat pix_fmt;635636/**637* If non NULL, 'draw_horiz_band' is called by the libavcodec638* decoder to draw a horizontal band. It improves cache usage. Not639* all codecs can do that. You must check the codec capabilities640* beforehand.641* When multithreading is used, it may be called from multiple threads642* at the same time; threads might draw different parts of the same AVFrame,643* or multiple AVFrames, and there is no guarantee that slices will be drawn644* in order.645* The function is also used by hardware acceleration APIs.646* It is called at least once during frame decoding to pass647* the data needed for hardware render.648* In that mode instead of pixel data, AVFrame points to649* a structure specific to the acceleration API. The application650* reads the structure and can change some fields to indicate progress651* or mark state.652* - encoding: unused653* - decoding: Set by user.654* @param height the height of the slice655* @param y the y position of the slice656* @param type 1->top field, 2->bottom field, 3->frame657* @param offset offset into the AVFrame.data from which the slice should be read658*/659void (*draw_horiz_band)(struct AVCodecContext *s,660const AVFrame *src, int offset[AV_NUM_DATA_POINTERS],661int y, int type, int height);662663/**664* Callback to negotiate the pixel format. Decoding only, may be set by the665* caller before avcodec_open2().666*667* Called by some decoders to select the pixel format that will be used for668* the output frames. This is mainly used to set up hardware acceleration,669* then the provided format list contains the corresponding hwaccel pixel670* formats alongside the "software" one. The software pixel format may also671* be retrieved from \ref sw_pix_fmt.672*673* This callback will be called when the coded frame properties (such as674* resolution, pixel format, etc.) change and more than one output format is675* supported for those new properties. If a hardware pixel format is chosen676* and initialization for it fails, the callback may be called again677* immediately.678*679* This callback may be called from different threads if the decoder is680* multi-threaded, but not from more than one thread simultaneously.681*682* @param fmt list of formats which may be used in the current683* configuration, terminated by AV_PIX_FMT_NONE.684* @warning Behavior is undefined if the callback returns a value other685* than one of the formats in fmt or AV_PIX_FMT_NONE.686* @return the chosen format or AV_PIX_FMT_NONE687*/688enum AVPixelFormat (*get_format)(struct AVCodecContext *s, const enum AVPixelFormat * fmt);689690/**691* maximum number of B-frames between non-B-frames692* Note: The output will be delayed by max_b_frames+1 relative to the input.693* - encoding: Set by user.694* - decoding: unused695*/696int max_b_frames;697698/**699* qscale factor between IP and B-frames700* If > 0 then the last P-frame quantizer will be used (q= lastp_q*factor+offset).701* If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).702* - encoding: Set by user.703* - decoding: unused704*/705float b_quant_factor;706707/**708* qscale offset between IP and B-frames709* - encoding: Set by user.710* - decoding: unused711*/712float b_quant_offset;713714/**715* Size of the frame reordering buffer in the decoder.716* For MPEG-2 it is 1 IPB or 0 low delay IP.717* - encoding: Set by libavcodec.718* - decoding: Set by libavcodec.719*/720int has_b_frames;721722/**723* qscale factor between P- and I-frames724* If > 0 then the last P-frame quantizer will be used (q = lastp_q * factor + offset).725* If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).726* - encoding: Set by user.727* - decoding: unused728*/729float i_quant_factor;730731/**732* qscale offset between P and I-frames733* - encoding: Set by user.734* - decoding: unused735*/736float i_quant_offset;737738/**739* luminance masking (0-> disabled)740* - encoding: Set by user.741* - decoding: unused742*/743float lumi_masking;744745/**746* temporary complexity masking (0-> disabled)747* - encoding: Set by user.748* - decoding: unused749*/750float temporal_cplx_masking;751752/**753* spatial complexity masking (0-> disabled)754* - encoding: Set by user.755* - decoding: unused756*/757float spatial_cplx_masking;758759/**760* p block masking (0-> disabled)761* - encoding: Set by user.762* - decoding: unused763*/764float p_masking;765766/**767* darkness masking (0-> disabled)768* - encoding: Set by user.769* - decoding: unused770*/771float dark_masking;772773/**774* slice count775* - encoding: Set by libavcodec.776* - decoding: Set by user (or 0).777*/778int slice_count;779780/**781* slice offsets in the frame in bytes782* - encoding: Set/allocated by libavcodec.783* - decoding: Set/allocated by user (or NULL).784*/785int *slice_offset;786787/**788* sample aspect ratio (0 if unknown)789* That is the width of a pixel divided by the height of the pixel.790* Numerator and denominator must be relatively prime and smaller than 256 for some video standards.791* - encoding: Set by user.792* - decoding: Set by libavcodec.793*/794AVRational sample_aspect_ratio;795796/**797* motion estimation comparison function798* - encoding: Set by user.799* - decoding: unused800*/801int me_cmp;802/**803* subpixel motion estimation comparison function804* - encoding: Set by user.805* - decoding: unused806*/807int me_sub_cmp;808/**809* macroblock comparison function (not supported yet)810* - encoding: Set by user.811* - decoding: unused812*/813int mb_cmp;814/**815* interlaced DCT comparison function816* - encoding: Set by user.817* - decoding: unused818*/819int ildct_cmp;820#define FF_CMP_SAD 0821#define FF_CMP_SSE 1822#define FF_CMP_SATD 2823#define FF_CMP_DCT 3824#define FF_CMP_PSNR 4825#define FF_CMP_BIT 5826#define FF_CMP_RD 6827#define FF_CMP_ZERO 7828#define FF_CMP_VSAD 8829#define FF_CMP_VSSE 9830#define FF_CMP_NSSE 10831#define FF_CMP_W53 11832#define FF_CMP_W97 12833#define FF_CMP_DCTMAX 13834#define FF_CMP_DCT264 14835#define FF_CMP_MEDIAN_SAD 15836#define FF_CMP_CHROMA 256837838/**839* ME diamond size & shape840* - encoding: Set by user.841* - decoding: unused842*/843int dia_size;844845/**846* amount of previous MV predictors (2a+1 x 2a+1 square)847* - encoding: Set by user.848* - decoding: unused849*/850int last_predictor_count;851852/**853* motion estimation prepass comparison function854* - encoding: Set by user.855* - decoding: unused856*/857int me_pre_cmp;858859/**860* ME prepass diamond size & shape861* - encoding: Set by user.862* - decoding: unused863*/864int pre_dia_size;865866/**867* subpel ME quality868* - encoding: Set by user.869* - decoding: unused870*/871int me_subpel_quality;872873/**874* maximum motion estimation search range in subpel units875* If 0 then no limit.876*877* - encoding: Set by user.878* - decoding: unused879*/880int me_range;881882/**883* slice flags884* - encoding: unused885* - decoding: Set by user.886*/887int slice_flags;888#define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display889#define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG-2 field pics)890#define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)891892/**893* macroblock decision mode894* - encoding: Set by user.895* - decoding: unused896*/897int mb_decision;898#define FF_MB_DECISION_SIMPLE 0 ///< uses mb_cmp899#define FF_MB_DECISION_BITS 1 ///< chooses the one which needs the fewest bits900#define FF_MB_DECISION_RD 2 ///< rate distortion901902/**903* custom intra quantization matrix904* Must be allocated with the av_malloc() family of functions, and will be freed in905* avcodec_free_context().906* - encoding: Set/allocated by user, freed by libavcodec. Can be NULL.907* - decoding: Set/allocated/freed by libavcodec.908*/909uint16_t *intra_matrix;910911/**912* custom inter quantization matrix913* Must be allocated with the av_malloc() family of functions, and will be freed in914* avcodec_free_context().915* - encoding: Set/allocated by user, freed by libavcodec. Can be NULL.916* - decoding: Set/allocated/freed by libavcodec.917*/918uint16_t *inter_matrix;919920/**921* precision of the intra DC coefficient - 8922* - encoding: Set by user.923* - decoding: Set by libavcodec924*/925int intra_dc_precision;926927/**928* Number of macroblock rows at the top which are skipped.929* - encoding: unused930* - decoding: Set by user.931*/932int skip_top;933934/**935* Number of macroblock rows at the bottom which are skipped.936* - encoding: unused937* - decoding: Set by user.938*/939int skip_bottom;940941/**942* minimum MB Lagrange multiplier943* - encoding: Set by user.944* - decoding: unused945*/946int mb_lmin;947948/**949* maximum MB Lagrange multiplier950* - encoding: Set by user.951* - decoding: unused952*/953int mb_lmax;954955/**956* - encoding: Set by user.957* - decoding: unused958*/959int bidir_refine;960961/**962* minimum GOP size963* - encoding: Set by user.964* - decoding: unused965*/966int keyint_min;967968/**969* number of reference frames970* - encoding: Set by user.971* - decoding: Set by lavc.972*/973int refs;974975/**976* Note: Value depends upon the compare function used for fullpel ME.977* - encoding: Set by user.978* - decoding: unused979*/980int mv0_threshold;981982/**983* Chromaticity coordinates of the source primaries.984* - encoding: Set by user985* - decoding: Set by libavcodec986*/987enum AVColorPrimaries color_primaries;988989/**990* Color Transfer Characteristic.991* - encoding: Set by user992* - decoding: Set by libavcodec993*/994enum AVColorTransferCharacteristic color_trc;995996/**997* YUV colorspace type.998* - encoding: Set by user999* - decoding: Set by libavcodec1000*/1001enum AVColorSpace colorspace;10021003/**1004* MPEG vs JPEG YUV range.1005* - encoding: Set by user1006* - decoding: Set by libavcodec1007*/1008enum AVColorRange color_range;10091010/**1011* This defines the location of chroma samples.1012* - encoding: Set by user1013* - decoding: Set by libavcodec1014*/1015enum AVChromaLocation chroma_sample_location;10161017/**1018* Number of slices.1019* Indicates number of picture subdivisions. Used for parallelized1020* decoding.1021* - encoding: Set by user1022* - decoding: unused1023*/1024int slices;10251026/** Field order1027* - encoding: set by libavcodec1028* - decoding: Set by user.1029*/1030enum AVFieldOrder field_order;10311032/* audio only */1033int sample_rate; ///< samples per second10341035#if FF_API_OLD_CHANNEL_LAYOUT1036/**1037* number of audio channels1038* @deprecated use ch_layout.nb_channels1039*/1040attribute_deprecated1041int channels;1042#endif10431044/**1045* audio sample format1046* - encoding: Set by user.1047* - decoding: Set by libavcodec.1048*/1049enum AVSampleFormat sample_fmt; ///< sample format10501051/* The following data should not be initialized. */1052/**1053* Number of samples per channel in an audio frame.1054*1055* - encoding: set by libavcodec in avcodec_open2(). Each submitted frame1056* except the last must contain exactly frame_size samples per channel.1057* May be 0 when the codec has AV_CODEC_CAP_VARIABLE_FRAME_SIZE set, then the1058* frame size is not restricted.1059* - decoding: may be set by some decoders to indicate constant frame size1060*/1061int frame_size;10621063#if FF_API_AVCTX_FRAME_NUMBER1064/**1065* Frame counter, set by libavcodec.1066*1067* - decoding: total number of frames returned from the decoder so far.1068* - encoding: total number of frames passed to the encoder so far.1069*1070* @note the counter is not incremented if encoding/decoding resulted in1071* an error.1072* @deprecated use frame_num instead1073*/1074attribute_deprecated1075int frame_number;1076#endif10771078/**1079* number of bytes per packet if constant and known or 01080* Used by some WAV based audio codecs.1081*/1082int block_align;10831084/**1085* Audio cutoff bandwidth (0 means "automatic")1086* - encoding: Set by user.1087* - decoding: unused1088*/1089int cutoff;10901091#if FF_API_OLD_CHANNEL_LAYOUT1092/**1093* Audio channel layout.1094* - encoding: set by user.1095* - decoding: set by user, may be overwritten by libavcodec.1096* @deprecated use ch_layout1097*/1098attribute_deprecated1099uint64_t channel_layout;11001101/**1102* Request decoder to use this channel layout if it can (0 for default)1103* - encoding: unused1104* - decoding: Set by user.1105* @deprecated use "downmix" codec private option1106*/1107attribute_deprecated1108uint64_t request_channel_layout;1109#endif11101111/**1112* Type of service that the audio stream conveys.1113* - encoding: Set by user.1114* - decoding: Set by libavcodec.1115*/1116enum AVAudioServiceType audio_service_type;11171118/**1119* desired sample format1120* - encoding: Not used.1121* - decoding: Set by user.1122* Decoder will decode to this format if it can.1123*/1124enum AVSampleFormat request_sample_fmt;11251126/**1127* This callback is called at the beginning of each frame to get data1128* buffer(s) for it. There may be one contiguous buffer for all the data or1129* there may be a buffer per each data plane or anything in between. What1130* this means is, you may set however many entries in buf[] you feel necessary.1131* Each buffer must be reference-counted using the AVBuffer API (see description1132* of buf[] below).1133*1134* The following fields will be set in the frame before this callback is1135* called:1136* - format1137* - width, height (video only)1138* - sample_rate, channel_layout, nb_samples (audio only)1139* Their values may differ from the corresponding values in1140* AVCodecContext. This callback must use the frame values, not the codec1141* context values, to calculate the required buffer size.1142*1143* This callback must fill the following fields in the frame:1144* - data[]1145* - linesize[]1146* - extended_data:1147* * if the data is planar audio with more than 8 channels, then this1148* callback must allocate and fill extended_data to contain all pointers1149* to all data planes. data[] must hold as many pointers as it can.1150* extended_data must be allocated with av_malloc() and will be freed in1151* av_frame_unref().1152* * otherwise extended_data must point to data1153* - buf[] must contain one or more pointers to AVBufferRef structures. Each of1154* the frame's data and extended_data pointers must be contained in these. That1155* is, one AVBufferRef for each allocated chunk of memory, not necessarily one1156* AVBufferRef per data[] entry. See: av_buffer_create(), av_buffer_alloc(),1157* and av_buffer_ref().1158* - extended_buf and nb_extended_buf must be allocated with av_malloc() by1159* this callback and filled with the extra buffers if there are more1160* buffers than buf[] can hold. extended_buf will be freed in1161* av_frame_unref().1162*1163* If AV_CODEC_CAP_DR1 is not set then get_buffer2() must call1164* avcodec_default_get_buffer2() instead of providing buffers allocated by1165* some other means.1166*1167* Each data plane must be aligned to the maximum required by the target1168* CPU.1169*1170* @see avcodec_default_get_buffer2()1171*1172* Video:1173*1174* If AV_GET_BUFFER_FLAG_REF is set in flags then the frame may be reused1175* (read and/or written to if it is writable) later by libavcodec.1176*1177* avcodec_align_dimensions2() should be used to find the required width and1178* height, as they normally need to be rounded up to the next multiple of 16.1179*1180* Some decoders do not support linesizes changing between frames.1181*1182* If frame multithreading is used, this callback may be called from a1183* different thread, but not from more than one at once. Does not need to be1184* reentrant.1185*1186* @see avcodec_align_dimensions2()1187*1188* Audio:1189*1190* Decoders request a buffer of a particular size by setting1191* AVFrame.nb_samples prior to calling get_buffer2(). The decoder may,1192* however, utilize only part of the buffer by setting AVFrame.nb_samples1193* to a smaller value in the output frame.1194*1195* As a convenience, av_samples_get_buffer_size() and1196* av_samples_fill_arrays() in libavutil may be used by custom get_buffer2()1197* functions to find the required data size and to fill data pointers and1198* linesize. In AVFrame.linesize, only linesize[0] may be set for audio1199* since all planes must be the same size.1200*1201* @see av_samples_get_buffer_size(), av_samples_fill_arrays()1202*1203* - encoding: unused1204* - decoding: Set by libavcodec, user can override.1205*/1206int (*get_buffer2)(struct AVCodecContext *s, AVFrame *frame, int flags);12071208/* - encoding parameters */1209float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)1210float qblur; ///< amount of qscale smoothing over time (0.0-1.0)12111212/**1213* minimum quantizer1214* - encoding: Set by user.1215* - decoding: unused1216*/1217int qmin;12181219/**1220* maximum quantizer1221* - encoding: Set by user.1222* - decoding: unused1223*/1224int qmax;12251226/**1227* maximum quantizer difference between frames1228* - encoding: Set by user.1229* - decoding: unused1230*/1231int max_qdiff;12321233/**1234* decoder bitstream buffer size1235* - encoding: Set by user.1236* - decoding: unused1237*/1238int rc_buffer_size;12391240/**1241* ratecontrol override, see RcOverride1242* - encoding: Allocated/set/freed by user.1243* - decoding: unused1244*/1245int rc_override_count;1246RcOverride *rc_override;12471248/**1249* maximum bitrate1250* - encoding: Set by user.1251* - decoding: Set by user, may be overwritten by libavcodec.1252*/1253int64_t rc_max_rate;12541255/**1256* minimum bitrate1257* - encoding: Set by user.1258* - decoding: unused1259*/1260int64_t rc_min_rate;12611262/**1263* Ratecontrol attempt to use, at maximum, <value> of what can be used without an underflow.1264* - encoding: Set by user.1265* - decoding: unused.1266*/1267float rc_max_available_vbv_use;12681269/**1270* Ratecontrol attempt to use, at least, <value> times the amount needed to prevent a vbv overflow.1271* - encoding: Set by user.1272* - decoding: unused.1273*/1274float rc_min_vbv_overflow_use;12751276/**1277* Number of bits which should be loaded into the rc buffer before decoding starts.1278* - encoding: Set by user.1279* - decoding: unused1280*/1281int rc_initial_buffer_occupancy;12821283/**1284* trellis RD quantization1285* - encoding: Set by user.1286* - decoding: unused1287*/1288int trellis;12891290/**1291* pass1 encoding statistics output buffer1292* - encoding: Set by libavcodec.1293* - decoding: unused1294*/1295char *stats_out;12961297/**1298* pass2 encoding statistics input buffer1299* Concatenated stuff from stats_out of pass1 should be placed here.1300* - encoding: Allocated/set/freed by user.1301* - decoding: unused1302*/1303char *stats_in;13041305/**1306* Work around bugs in encoders which sometimes cannot be detected automatically.1307* - encoding: Set by user1308* - decoding: Set by user1309*/1310int workaround_bugs;1311#define FF_BUG_AUTODETECT 1 ///< autodetection1312#define FF_BUG_XVID_ILACE 41313#define FF_BUG_UMP4 81314#define FF_BUG_NO_PADDING 161315#define FF_BUG_AMV 321316#define FF_BUG_QPEL_CHROMA 641317#define FF_BUG_STD_QPEL 1281318#define FF_BUG_QPEL_CHROMA2 2561319#define FF_BUG_DIRECT_BLOCKSIZE 5121320#define FF_BUG_EDGE 10241321#define FF_BUG_HPEL_CHROMA 20481322#define FF_BUG_DC_CLIP 40961323#define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders.1324#define FF_BUG_TRUNCATED 163841325#define FF_BUG_IEDGE 3276813261327/**1328* strictly follow the standard (MPEG-4, ...).1329* - encoding: Set by user.1330* - decoding: Set by user.1331* Setting this to STRICT or higher means the encoder and decoder will1332* generally do stupid things, whereas setting it to unofficial or lower1333* will mean the encoder might produce output that is not supported by all1334* spec-compliant decoders. Decoders don't differentiate between normal,1335* unofficial and experimental (that is, they always try to decode things1336* when they can) unless they are explicitly asked to behave stupidly1337* (=strictly conform to the specs)1338* This may only be set to one of the FF_COMPLIANCE_* values in defs.h.1339*/1340int strict_std_compliance;13411342/**1343* error concealment flags1344* - encoding: unused1345* - decoding: Set by user.1346*/1347int error_concealment;1348#define FF_EC_GUESS_MVS 11349#define FF_EC_DEBLOCK 21350#define FF_EC_FAVOR_INTER 25613511352/**1353* debug1354* - encoding: Set by user.1355* - decoding: Set by user.1356*/1357int debug;1358#define FF_DEBUG_PICT_INFO 11359#define FF_DEBUG_RC 21360#define FF_DEBUG_BITSTREAM 41361#define FF_DEBUG_MB_TYPE 81362#define FF_DEBUG_QP 161363#define FF_DEBUG_DCT_COEFF 0x000000401364#define FF_DEBUG_SKIP 0x000000801365#define FF_DEBUG_STARTCODE 0x000001001366#define FF_DEBUG_ER 0x000004001367#define FF_DEBUG_MMCO 0x000008001368#define FF_DEBUG_BUGS 0x000010001369#define FF_DEBUG_BUFFERS 0x000080001370#define FF_DEBUG_THREADS 0x000100001371#define FF_DEBUG_GREEN_MD 0x008000001372#define FF_DEBUG_NOMC 0x0100000013731374/**1375* Error recognition; may misdetect some more or less valid parts as errors.1376* This is a bitfield of the AV_EF_* values defined in defs.h.1377*1378* - encoding: Set by user.1379* - decoding: Set by user.1380*/1381int err_recognition;13821383#if FF_API_REORDERED_OPAQUE1384/**1385* opaque 64-bit number (generally a PTS) that will be reordered and1386* output in AVFrame.reordered_opaque1387* - encoding: Set by libavcodec to the reordered_opaque of the input1388* frame corresponding to the last returned packet. Only1389* supported by encoders with the1390* AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE capability.1391* - decoding: Set by user.1392*1393* @deprecated Use AV_CODEC_FLAG_COPY_OPAQUE instead1394*/1395attribute_deprecated1396int64_t reordered_opaque;1397#endif13981399/**1400* Hardware accelerator in use1401* - encoding: unused.1402* - decoding: Set by libavcodec1403*/1404const struct AVHWAccel *hwaccel;14051406/**1407* Legacy hardware accelerator context.1408*1409* For some hardware acceleration methods, the caller may use this field to1410* signal hwaccel-specific data to the codec. The struct pointed to by this1411* pointer is hwaccel-dependent and defined in the respective header. Please1412* refer to the FFmpeg HW accelerator documentation to know how to fill1413* this.1414*1415* In most cases this field is optional - the necessary information may also1416* be provided to libavcodec through @ref hw_frames_ctx or @ref1417* hw_device_ctx (see avcodec_get_hw_config()). However, in some cases it1418* may be the only method of signalling some (optional) information.1419*1420* The struct and its contents are owned by the caller.1421*1422* - encoding: May be set by the caller before avcodec_open2(). Must remain1423* valid until avcodec_free_context().1424* - decoding: May be set by the caller in the get_format() callback.1425* Must remain valid until the next get_format() call,1426* or avcodec_free_context() (whichever comes first).1427*/1428void *hwaccel_context;14291430/**1431* error1432* - encoding: Set by libavcodec if flags & AV_CODEC_FLAG_PSNR.1433* - decoding: unused1434*/1435uint64_t error[AV_NUM_DATA_POINTERS];14361437/**1438* DCT algorithm, see FF_DCT_* below1439* - encoding: Set by user.1440* - decoding: unused1441*/1442int dct_algo;1443#define FF_DCT_AUTO 01444#define FF_DCT_FASTINT 11445#define FF_DCT_INT 21446#define FF_DCT_MMX 31447#define FF_DCT_ALTIVEC 51448#define FF_DCT_FAAN 614491450/**1451* IDCT algorithm, see FF_IDCT_* below.1452* - encoding: Set by user.1453* - decoding: Set by user.1454*/1455int idct_algo;1456#define FF_IDCT_AUTO 01457#define FF_IDCT_INT 11458#define FF_IDCT_SIMPLE 21459#define FF_IDCT_SIMPLEMMX 31460#define FF_IDCT_ARM 71461#define FF_IDCT_ALTIVEC 81462#define FF_IDCT_SIMPLEARM 101463#define FF_IDCT_XVID 141464#define FF_IDCT_SIMPLEARMV5TE 161465#define FF_IDCT_SIMPLEARMV6 171466#define FF_IDCT_FAAN 201467#define FF_IDCT_SIMPLENEON 221468#if FF_API_IDCT_NONE1469// formerly used by xvmc1470#define FF_IDCT_NONE 241471#endif1472#define FF_IDCT_SIMPLEAUTO 12814731474/**1475* bits per sample/pixel from the demuxer (needed for huffyuv).1476* - encoding: Set by libavcodec.1477* - decoding: Set by user.1478*/1479int bits_per_coded_sample;14801481/**1482* Bits per sample/pixel of internal libavcodec pixel/sample format.1483* - encoding: set by user.1484* - decoding: set by libavcodec.1485*/1486int bits_per_raw_sample;14871488/**1489* low resolution decoding, 1-> 1/2 size, 2->1/4 size1490* - encoding: unused1491* - decoding: Set by user.1492*/1493int lowres;14941495/**1496* thread count1497* is used to decide how many independent tasks should be passed to execute()1498* - encoding: Set by user.1499* - decoding: Set by user.1500*/1501int thread_count;15021503/**1504* Which multithreading methods to use.1505* Use of FF_THREAD_FRAME will increase decoding delay by one frame per thread,1506* so clients which cannot provide future frames should not use it.1507*1508* - encoding: Set by user, otherwise the default is used.1509* - decoding: Set by user, otherwise the default is used.1510*/1511int thread_type;1512#define FF_THREAD_FRAME 1 ///< Decode more than one frame at once1513#define FF_THREAD_SLICE 2 ///< Decode more than one part of a single frame at once15141515/**1516* Which multithreading methods are in use by the codec.1517* - encoding: Set by libavcodec.1518* - decoding: Set by libavcodec.1519*/1520int active_thread_type;15211522/**1523* The codec may call this to execute several independent things.1524* It will return only after finishing all tasks.1525* The user may replace this with some multithreaded implementation,1526* the default implementation will execute the parts serially.1527* @param count the number of things to execute1528* - encoding: Set by libavcodec, user can override.1529* - decoding: Set by libavcodec, user can override.1530*/1531int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size);15321533/**1534* The codec may call this to execute several independent things.1535* It will return only after finishing all tasks.1536* The user may replace this with some multithreaded implementation,1537* the default implementation will execute the parts serially.1538* @param c context passed also to func1539* @param count the number of things to execute1540* @param arg2 argument passed unchanged to func1541* @param ret return values of executed functions, must have space for "count" values. May be NULL.1542* @param func function that will be called count times, with jobnr from 0 to count-1.1543* threadnr will be in the range 0 to c->thread_count-1 < MAX_THREADS and so that no1544* two instances of func executing at the same time will have the same threadnr.1545* @return always 0 currently, but code should handle a future improvement where when any call to func1546* returns < 0 no further calls to func may be done and < 0 is returned.1547* - encoding: Set by libavcodec, user can override.1548* - decoding: Set by libavcodec, user can override.1549*/1550int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count);15511552/**1553* noise vs. sse weight for the nsse comparison function1554* - encoding: Set by user.1555* - decoding: unused1556*/1557int nsse_weight;15581559/**1560* profile1561* - encoding: Set by user.1562* - decoding: Set by libavcodec.1563*/1564int profile;1565#define FF_PROFILE_UNKNOWN -991566#define FF_PROFILE_RESERVED -10015671568#define FF_PROFILE_AAC_MAIN 01569#define FF_PROFILE_AAC_LOW 11570#define FF_PROFILE_AAC_SSR 21571#define FF_PROFILE_AAC_LTP 31572#define FF_PROFILE_AAC_HE 41573#define FF_PROFILE_AAC_HE_V2 281574#define FF_PROFILE_AAC_LD 221575#define FF_PROFILE_AAC_ELD 381576#define FF_PROFILE_MPEG2_AAC_LOW 1281577#define FF_PROFILE_MPEG2_AAC_HE 13115781579#define FF_PROFILE_DNXHD 01580#define FF_PROFILE_DNXHR_LB 11581#define FF_PROFILE_DNXHR_SQ 21582#define FF_PROFILE_DNXHR_HQ 31583#define FF_PROFILE_DNXHR_HQX 41584#define FF_PROFILE_DNXHR_444 515851586#define FF_PROFILE_DTS 201587#define FF_PROFILE_DTS_ES 301588#define FF_PROFILE_DTS_96_24 401589#define FF_PROFILE_DTS_HD_HRA 501590#define FF_PROFILE_DTS_HD_MA 601591#define FF_PROFILE_DTS_EXPRESS 7015921593#define FF_PROFILE_MPEG2_422 01594#define FF_PROFILE_MPEG2_HIGH 11595#define FF_PROFILE_MPEG2_SS 21596#define FF_PROFILE_MPEG2_SNR_SCALABLE 31597#define FF_PROFILE_MPEG2_MAIN 41598#define FF_PROFILE_MPEG2_SIMPLE 515991600#define FF_PROFILE_H264_CONSTRAINED (1<<9) // 8+1; constraint_set1_flag1601#define FF_PROFILE_H264_INTRA (1<<11) // 8+3; constraint_set3_flag16021603#define FF_PROFILE_H264_BASELINE 661604#define FF_PROFILE_H264_CONSTRAINED_BASELINE (66|FF_PROFILE_H264_CONSTRAINED)1605#define FF_PROFILE_H264_MAIN 771606#define FF_PROFILE_H264_EXTENDED 881607#define FF_PROFILE_H264_HIGH 1001608#define FF_PROFILE_H264_HIGH_10 1101609#define FF_PROFILE_H264_HIGH_10_INTRA (110|FF_PROFILE_H264_INTRA)1610#define FF_PROFILE_H264_MULTIVIEW_HIGH 1181611#define FF_PROFILE_H264_HIGH_422 1221612#define FF_PROFILE_H264_HIGH_422_INTRA (122|FF_PROFILE_H264_INTRA)1613#define FF_PROFILE_H264_STEREO_HIGH 1281614#define FF_PROFILE_H264_HIGH_444 1441615#define FF_PROFILE_H264_HIGH_444_PREDICTIVE 2441616#define FF_PROFILE_H264_HIGH_444_INTRA (244|FF_PROFILE_H264_INTRA)1617#define FF_PROFILE_H264_CAVLC_444 4416181619#define FF_PROFILE_VC1_SIMPLE 01620#define FF_PROFILE_VC1_MAIN 11621#define FF_PROFILE_VC1_COMPLEX 21622#define FF_PROFILE_VC1_ADVANCED 316231624#define FF_PROFILE_MPEG4_SIMPLE 01625#define FF_PROFILE_MPEG4_SIMPLE_SCALABLE 11626#define FF_PROFILE_MPEG4_CORE 21627#define FF_PROFILE_MPEG4_MAIN 31628#define FF_PROFILE_MPEG4_N_BIT 41629#define FF_PROFILE_MPEG4_SCALABLE_TEXTURE 51630#define FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION 61631#define FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE 71632#define FF_PROFILE_MPEG4_HYBRID 81633#define FF_PROFILE_MPEG4_ADVANCED_REAL_TIME 91634#define FF_PROFILE_MPEG4_CORE_SCALABLE 101635#define FF_PROFILE_MPEG4_ADVANCED_CODING 111636#define FF_PROFILE_MPEG4_ADVANCED_CORE 121637#define FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE 131638#define FF_PROFILE_MPEG4_SIMPLE_STUDIO 141639#define FF_PROFILE_MPEG4_ADVANCED_SIMPLE 1516401641#define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_0 11642#define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_1 21643#define FF_PROFILE_JPEG2000_CSTREAM_NO_RESTRICTION 327681644#define FF_PROFILE_JPEG2000_DCINEMA_2K 31645#define FF_PROFILE_JPEG2000_DCINEMA_4K 416461647#define FF_PROFILE_VP9_0 01648#define FF_PROFILE_VP9_1 11649#define FF_PROFILE_VP9_2 21650#define FF_PROFILE_VP9_3 316511652#define FF_PROFILE_HEVC_MAIN 11653#define FF_PROFILE_HEVC_MAIN_10 21654#define FF_PROFILE_HEVC_MAIN_STILL_PICTURE 31655#define FF_PROFILE_HEVC_REXT 416561657#define FF_PROFILE_VVC_MAIN_10 11658#define FF_PROFILE_VVC_MAIN_10_444 3316591660#define FF_PROFILE_AV1_MAIN 01661#define FF_PROFILE_AV1_HIGH 11662#define FF_PROFILE_AV1_PROFESSIONAL 216631664#define FF_PROFILE_MJPEG_HUFFMAN_BASELINE_DCT 0xc01665#define FF_PROFILE_MJPEG_HUFFMAN_EXTENDED_SEQUENTIAL_DCT 0xc11666#define FF_PROFILE_MJPEG_HUFFMAN_PROGRESSIVE_DCT 0xc21667#define FF_PROFILE_MJPEG_HUFFMAN_LOSSLESS 0xc31668#define FF_PROFILE_MJPEG_JPEG_LS 0xf716691670#define FF_PROFILE_SBC_MSBC 116711672#define FF_PROFILE_PRORES_PROXY 01673#define FF_PROFILE_PRORES_LT 11674#define FF_PROFILE_PRORES_STANDARD 21675#define FF_PROFILE_PRORES_HQ 31676#define FF_PROFILE_PRORES_4444 41677#define FF_PROFILE_PRORES_XQ 516781679#define FF_PROFILE_ARIB_PROFILE_A 01680#define FF_PROFILE_ARIB_PROFILE_C 116811682#define FF_PROFILE_KLVA_SYNC 01683#define FF_PROFILE_KLVA_ASYNC 116841685/**1686* level1687* - encoding: Set by user.1688* - decoding: Set by libavcodec.1689*/1690int level;1691#define FF_LEVEL_UNKNOWN -9916921693/**1694* Skip loop filtering for selected frames.1695* - encoding: unused1696* - decoding: Set by user.1697*/1698enum AVDiscard skip_loop_filter;16991700/**1701* Skip IDCT/dequantization for selected frames.1702* - encoding: unused1703* - decoding: Set by user.1704*/1705enum AVDiscard skip_idct;17061707/**1708* Skip decoding for selected frames.1709* - encoding: unused1710* - decoding: Set by user.1711*/1712enum AVDiscard skip_frame;17131714/**1715* Header containing style information for text subtitles.1716* For SUBTITLE_ASS subtitle type, it should contain the whole ASS1717* [Script Info] and [V4+ Styles] section, plus the [Events] line and1718* the Format line following. It shouldn't include any Dialogue line.1719* - encoding: Set/allocated/freed by user (before avcodec_open2())1720* - decoding: Set/allocated/freed by libavcodec (by avcodec_open2())1721*/1722uint8_t *subtitle_header;1723int subtitle_header_size;17241725/**1726* Audio only. The number of "priming" samples (padding) inserted by the1727* encoder at the beginning of the audio. I.e. this number of leading1728* decoded samples must be discarded by the caller to get the original audio1729* without leading padding.1730*1731* - decoding: unused1732* - encoding: Set by libavcodec. The timestamps on the output packets are1733* adjusted by the encoder so that they always refer to the1734* first sample of the data actually contained in the packet,1735* including any added padding. E.g. if the timebase is1736* 1/samplerate and the timestamp of the first input sample is1737* 0, the timestamp of the first output packet will be1738* -initial_padding.1739*/1740int initial_padding;17411742/**1743* - decoding: For codecs that store a framerate value in the compressed1744* bitstream, the decoder may export it here. { 0, 1} when1745* unknown.1746* - encoding: May be used to signal the framerate of CFR content to an1747* encoder.1748*/1749AVRational framerate;17501751/**1752* Nominal unaccelerated pixel format, see AV_PIX_FMT_xxx.1753* - encoding: unused.1754* - decoding: Set by libavcodec before calling get_format()1755*/1756enum AVPixelFormat sw_pix_fmt;17571758/**1759* Timebase in which pkt_dts/pts and AVPacket.dts/pts are.1760* - encoding unused.1761* - decoding set by user.1762*/1763AVRational pkt_timebase;17641765/**1766* AVCodecDescriptor1767* - encoding: unused.1768* - decoding: set by libavcodec.1769*/1770const AVCodecDescriptor *codec_descriptor;17711772/**1773* Current statistics for PTS correction.1774* - decoding: maintained and used by libavcodec, not intended to be used by user apps1775* - encoding: unused1776*/1777int64_t pts_correction_num_faulty_pts; /// Number of incorrect PTS values so far1778int64_t pts_correction_num_faulty_dts; /// Number of incorrect DTS values so far1779int64_t pts_correction_last_pts; /// PTS of the last frame1780int64_t pts_correction_last_dts; /// DTS of the last frame17811782/**1783* Character encoding of the input subtitles file.1784* - decoding: set by user1785* - encoding: unused1786*/1787char *sub_charenc;17881789/**1790* Subtitles character encoding mode. Formats or codecs might be adjusting1791* this setting (if they are doing the conversion themselves for instance).1792* - decoding: set by libavcodec1793* - encoding: unused1794*/1795int sub_charenc_mode;1796#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)1797#define FF_SUB_CHARENC_MODE_AUTOMATIC 0 ///< libavcodec will select the mode itself1798#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 iconv1799#define FF_SUB_CHARENC_MODE_IGNORE 2 ///< neither convert the subtitles, nor check them for valid UTF-818001801/**1802* Skip processing alpha if supported by codec.1803* Note that if the format uses pre-multiplied alpha (common with VP6,1804* and recommended due to better video quality/compression)1805* the image will look as if alpha-blended onto a black background.1806* However for formats that do not use pre-multiplied alpha1807* there might be serious artefacts (though e.g. libswscale currently1808* assumes pre-multiplied alpha anyway).1809*1810* - decoding: set by user1811* - encoding: unused1812*/1813int skip_alpha;18141815/**1816* Number of samples to skip after a discontinuity1817* - decoding: unused1818* - encoding: set by libavcodec1819*/1820int seek_preroll;18211822/**1823* custom intra quantization matrix1824* - encoding: Set by user, can be NULL.1825* - decoding: unused.1826*/1827uint16_t *chroma_intra_matrix;18281829/**1830* dump format separator.1831* can be ", " or "\n " or anything else1832* - encoding: Set by user.1833* - decoding: Set by user.1834*/1835uint8_t *dump_separator;18361837/**1838* ',' separated list of allowed decoders.1839* If NULL then all are allowed1840* - encoding: unused1841* - decoding: set by user1842*/1843char *codec_whitelist;18441845/**1846* Properties of the stream that gets decoded1847* - encoding: unused1848* - decoding: set by libavcodec1849*/1850unsigned properties;1851#define FF_CODEC_PROPERTY_LOSSLESS 0x000000011852#define FF_CODEC_PROPERTY_CLOSED_CAPTIONS 0x000000021853#define FF_CODEC_PROPERTY_FILM_GRAIN 0x0000000418541855/**1856* Additional data associated with the entire coded stream.1857*1858* - decoding: unused1859* - encoding: may be set by libavcodec after avcodec_open2().1860*/1861AVPacketSideData *coded_side_data;1862int nb_coded_side_data;18631864/**1865* A reference to the AVHWFramesContext describing the input (for encoding)1866* or output (decoding) frames. The reference is set by the caller and1867* afterwards owned (and freed) by libavcodec - it should never be read by1868* the caller after being set.1869*1870* - decoding: This field should be set by the caller from the get_format()1871* callback. The previous reference (if any) will always be1872* unreffed by libavcodec before the get_format() call.1873*1874* If the default get_buffer2() is used with a hwaccel pixel1875* format, then this AVHWFramesContext will be used for1876* allocating the frame buffers.1877*1878* - encoding: For hardware encoders configured to use a hwaccel pixel1879* format, this field should be set by the caller to a reference1880* to the AVHWFramesContext describing input frames.1881* AVHWFramesContext.format must be equal to1882* AVCodecContext.pix_fmt.1883*1884* This field should be set before avcodec_open2() is called.1885*/1886AVBufferRef *hw_frames_ctx;18871888/**1889* Audio only. The amount of padding (in samples) appended by the encoder to1890* the end of the audio. I.e. this number of decoded samples must be1891* discarded by the caller from the end of the stream to get the original1892* audio without any trailing padding.1893*1894* - decoding: unused1895* - encoding: unused1896*/1897int trailing_padding;18981899/**1900* The number of pixels per image to maximally accept.1901*1902* - decoding: set by user1903* - encoding: set by user1904*/1905int64_t max_pixels;19061907/**1908* A reference to the AVHWDeviceContext describing the device which will1909* be used by a hardware encoder/decoder. The reference is set by the1910* caller and afterwards owned (and freed) by libavcodec.1911*1912* This should be used if either the codec device does not require1913* hardware frames or any that are used are to be allocated internally by1914* libavcodec. If the user wishes to supply any of the frames used as1915* encoder input or decoder output then hw_frames_ctx should be used1916* instead. When hw_frames_ctx is set in get_format() for a decoder, this1917* field will be ignored while decoding the associated stream segment, but1918* may again be used on a following one after another get_format() call.1919*1920* For both encoders and decoders this field should be set before1921* avcodec_open2() is called and must not be written to thereafter.1922*1923* Note that some decoders may require this field to be set initially in1924* order to support hw_frames_ctx at all - in that case, all frames1925* contexts used must be created on the same device.1926*/1927AVBufferRef *hw_device_ctx;19281929/**1930* Bit set of AV_HWACCEL_FLAG_* flags, which affect hardware accelerated1931* decoding (if active).1932* - encoding: unused1933* - decoding: Set by user (either before avcodec_open2(), or in the1934* AVCodecContext.get_format callback)1935*/1936int hwaccel_flags;19371938/**1939* Video decoding only. Certain video codecs support cropping, meaning that1940* only a sub-rectangle of the decoded frame is intended for display. This1941* option controls how cropping is handled by libavcodec.1942*1943* When set to 1 (the default), libavcodec will apply cropping internally.1944* I.e. it will modify the output frame width/height fields and offset the1945* data pointers (only by as much as possible while preserving alignment, or1946* by the full amount if the AV_CODEC_FLAG_UNALIGNED flag is set) so that1947* the frames output by the decoder refer only to the cropped area. The1948* crop_* fields of the output frames will be zero.1949*1950* When set to 0, the width/height fields of the output frames will be set1951* to the coded dimensions and the crop_* fields will describe the cropping1952* rectangle. Applying the cropping is left to the caller.1953*1954* @warning When hardware acceleration with opaque output frames is used,1955* libavcodec is unable to apply cropping from the top/left border.1956*1957* @note when this option is set to zero, the width/height fields of the1958* AVCodecContext and output AVFrames have different meanings. The codec1959* context fields store display dimensions (with the coded dimensions in1960* coded_width/height), while the frame fields store the coded dimensions1961* (with the display dimensions being determined by the crop_* fields).1962*/1963int apply_cropping;19641965/*1966* Video decoding only. Sets the number of extra hardware frames which1967* the decoder will allocate for use by the caller. This must be set1968* before avcodec_open2() is called.1969*1970* Some hardware decoders require all frames that they will use for1971* output to be defined in advance before decoding starts. For such1972* decoders, the hardware frame pool must therefore be of a fixed size.1973* The extra frames set here are on top of any number that the decoder1974* needs internally in order to operate normally (for example, frames1975* used as reference pictures).1976*/1977int extra_hw_frames;19781979/**1980* The percentage of damaged samples to discard a frame.1981*1982* - decoding: set by user1983* - encoding: unused1984*/1985int discard_damaged_percentage;19861987/**1988* The number of samples per frame to maximally accept.1989*1990* - decoding: set by user1991* - encoding: set by user1992*/1993int64_t max_samples;19941995/**1996* Bit set of AV_CODEC_EXPORT_DATA_* flags, which affects the kind of1997* metadata exported in frame, packet, or coded stream side data by1998* decoders and encoders.1999*2000* - decoding: set by user2001* - encoding: set by user2002*/2003int export_side_data;20042005/**2006* This callback is called at the beginning of each packet to get a data2007* buffer for it.2008*2009* The following field will be set in the packet before this callback is2010* called:2011* - size2012* This callback must use the above value to calculate the required buffer size,2013* which must padded by at least AV_INPUT_BUFFER_PADDING_SIZE bytes.2014*2015* In some specific cases, the encoder may not use the entire buffer allocated by this2016* callback. This will be reflected in the size value in the packet once returned by2017* avcodec_receive_packet().2018*2019* This callback must fill the following fields in the packet:2020* - data: alignment requirements for AVPacket apply, if any. Some architectures and2021* encoders may benefit from having aligned data.2022* - buf: must contain a pointer to an AVBufferRef structure. The packet's2023* data pointer must be contained in it. See: av_buffer_create(), av_buffer_alloc(),2024* and av_buffer_ref().2025*2026* If AV_CODEC_CAP_DR1 is not set then get_encode_buffer() must call2027* avcodec_default_get_encode_buffer() instead of providing a buffer allocated by2028* some other means.2029*2030* The flags field may contain a combination of AV_GET_ENCODE_BUFFER_FLAG_ flags.2031* They may be used for example to hint what use the buffer may get after being2032* created.2033* Implementations of this callback may ignore flags they don't understand.2034* If AV_GET_ENCODE_BUFFER_FLAG_REF is set in flags then the packet may be reused2035* (read and/or written to if it is writable) later by libavcodec.2036*2037* This callback must be thread-safe, as when frame threading is used, it may2038* be called from multiple threads simultaneously.2039*2040* @see avcodec_default_get_encode_buffer()2041*2042* - encoding: Set by libavcodec, user can override.2043* - decoding: unused2044*/2045int (*get_encode_buffer)(struct AVCodecContext *s, AVPacket *pkt, int flags);20462047/**2048* Audio channel layout.2049* - encoding: must be set by the caller, to one of AVCodec.ch_layouts.2050* - decoding: may be set by the caller if known e.g. from the container.2051* The decoder can then override during decoding as needed.2052*/2053AVChannelLayout ch_layout;20542055/**2056* Frame counter, set by libavcodec.2057*2058* - decoding: total number of frames returned from the decoder so far.2059* - encoding: total number of frames passed to the encoder so far.2060*2061* @note the counter is not incremented if encoding/decoding resulted in2062* an error.2063*/2064int64_t frame_num;2065} AVCodecContext;20662067/**2068* @defgroup lavc_hwaccel AVHWAccel2069*2070* @note Nothing in this structure should be accessed by the user. At some2071* point in future it will not be externally visible at all.2072*2073* @{2074*/2075typedef struct AVHWAccel {2076/**2077* Name of the hardware accelerated codec.2078* The name is globally unique among encoders and among decoders (but an2079* encoder and a decoder can share the same name).2080*/2081const char *name;20822083/**2084* Type of codec implemented by the hardware accelerator.2085*2086* See AVMEDIA_TYPE_xxx2087*/2088enum AVMediaType type;20892090/**2091* Codec implemented by the hardware accelerator.2092*2093* See AV_CODEC_ID_xxx2094*/2095enum AVCodecID id;20962097/**2098* Supported pixel format.2099*2100* Only hardware accelerated formats are supported here.2101*/2102enum AVPixelFormat pix_fmt;21032104/**2105* Hardware accelerated codec capabilities.2106* see AV_HWACCEL_CODEC_CAP_*2107*/2108int capabilities;21092110/*****************************************************************2111* No fields below this line are part of the public API. They2112* may not be used outside of libavcodec and can be changed and2113* removed at will.2114* New public fields should be added right above.2115*****************************************************************2116*/21172118/**2119* Allocate a custom buffer2120*/2121int (*alloc_frame)(AVCodecContext *avctx, AVFrame *frame);21222123/**2124* Called at the beginning of each frame or field picture.2125*2126* Meaningful frame information (codec specific) is guaranteed to2127* be parsed at this point. This function is mandatory.2128*2129* Note that buf can be NULL along with buf_size set to 0.2130* Otherwise, this means the whole frame is available at this point.2131*2132* @param avctx the codec context2133* @param buf the frame data buffer base2134* @param buf_size the size of the frame in bytes2135* @return zero if successful, a negative value otherwise2136*/2137int (*start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);21382139/**2140* Callback for parameter data (SPS/PPS/VPS etc).2141*2142* Useful for hardware decoders which keep persistent state about the2143* video parameters, and need to receive any changes to update that state.2144*2145* @param avctx the codec context2146* @param type the nal unit type2147* @param buf the nal unit data buffer2148* @param buf_size the size of the nal unit in bytes2149* @return zero if successful, a negative value otherwise2150*/2151int (*decode_params)(AVCodecContext *avctx, int type, const uint8_t *buf, uint32_t buf_size);21522153/**2154* Callback for each slice.2155*2156* Meaningful slice information (codec specific) is guaranteed to2157* be parsed at this point. This function is mandatory.2158*2159* @param avctx the codec context2160* @param buf the slice data buffer base2161* @param buf_size the size of the slice in bytes2162* @return zero if successful, a negative value otherwise2163*/2164int (*decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);21652166/**2167* Called at the end of each frame or field picture.2168*2169* The whole picture is parsed at this point and can now be sent2170* to the hardware accelerator. This function is mandatory.2171*2172* @param avctx the codec context2173* @return zero if successful, a negative value otherwise2174*/2175int (*end_frame)(AVCodecContext *avctx);21762177/**2178* Size of per-frame hardware accelerator private data.2179*2180* Private data is allocated with av_mallocz() before2181* AVCodecContext.get_buffer() and deallocated after2182* AVCodecContext.release_buffer().2183*/2184int frame_priv_data_size;21852186/**2187* Initialize the hwaccel private data.2188*2189* This will be called from ff_get_format(), after hwaccel and2190* hwaccel_context are set and the hwaccel private data in AVCodecInternal2191* is allocated.2192*/2193int (*init)(AVCodecContext *avctx);21942195/**2196* Uninitialize the hwaccel private data.2197*2198* This will be called from get_format() or avcodec_close(), after hwaccel2199* and hwaccel_context are already uninitialized.2200*/2201int (*uninit)(AVCodecContext *avctx);22022203/**2204* Size of the private data to allocate in2205* AVCodecInternal.hwaccel_priv_data.2206*/2207int priv_data_size;22082209/**2210* Internal hwaccel capabilities.2211*/2212int caps_internal;22132214/**2215* Fill the given hw_frames context with current codec parameters. Called2216* from get_format. Refer to avcodec_get_hw_frames_parameters() for2217* details.2218*2219* This CAN be called before AVHWAccel.init is called, and you must assume2220* that avctx->hwaccel_priv_data is invalid.2221*/2222int (*frame_params)(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx);2223} AVHWAccel;22242225/**2226* HWAccel is experimental and is thus avoided in favor of non experimental2227* codecs2228*/2229#define AV_HWACCEL_CODEC_CAP_EXPERIMENTAL 0x020022302231/**2232* Hardware acceleration should be used for decoding even if the codec level2233* used is unknown or higher than the maximum supported level reported by the2234* hardware driver.2235*2236* It's generally a good idea to pass this flag unless you have a specific2237* reason not to, as hardware tends to under-report supported levels.2238*/2239#define AV_HWACCEL_FLAG_IGNORE_LEVEL (1 << 0)22402241/**2242* Hardware acceleration can output YUV pixel formats with a different chroma2243* sampling than 4:2:0 and/or other than 8 bits per component.2244*/2245#define AV_HWACCEL_FLAG_ALLOW_HIGH_DEPTH (1 << 1)22462247/**2248* Hardware acceleration should still be attempted for decoding when the2249* codec profile does not match the reported capabilities of the hardware.2250*2251* For example, this can be used to try to decode baseline profile H.2642252* streams in hardware - it will often succeed, because many streams marked2253* as baseline profile actually conform to constrained baseline profile.2254*2255* @warning If the stream is actually not supported then the behaviour is2256* undefined, and may include returning entirely incorrect output2257* while indicating success.2258*/2259#define AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH (1 << 2)22602261/**2262* Some hardware decoders (namely nvdec) can either output direct decoder2263* surfaces, or make an on-device copy and return said copy.2264* There is a hard limit on how many decoder surfaces there can be, and it2265* cannot be accurately guessed ahead of time.2266* For some processing chains, this can be okay, but others will run into the2267* limit and in turn produce very confusing errors that require fine tuning of2268* more or less obscure options by the user, or in extreme cases cannot be2269* resolved at all without inserting an avfilter that forces a copy.2270*2271* Thus, the hwaccel will by default make a copy for safety and resilience.2272* If a users really wants to minimize the amount of copies, they can set this2273* flag and ensure their processing chain does not exhaust the surface pool.2274*/2275#define AV_HWACCEL_FLAG_UNSAFE_OUTPUT (1 << 3)22762277/**2278* @}2279*/22802281enum AVSubtitleType {2282SUBTITLE_NONE,22832284SUBTITLE_BITMAP, ///< A bitmap, pict will be set22852286/**2287* Plain text, the text field must be set by the decoder and is2288* authoritative. ass and pict fields may contain approximations.2289*/2290SUBTITLE_TEXT,22912292/**2293* Formatted text, the ass field must be set by the decoder and is2294* authoritative. pict and text fields may contain approximations.2295*/2296SUBTITLE_ASS,2297};22982299#define AV_SUBTITLE_FLAG_FORCED 0x0000000123002301typedef struct AVSubtitleRect {2302int x; ///< top left corner of pict, undefined when pict is not set2303int y; ///< top left corner of pict, undefined when pict is not set2304int w; ///< width of pict, undefined when pict is not set2305int h; ///< height of pict, undefined when pict is not set2306int nb_colors; ///< number of colors in pict, undefined when pict is not set23072308/**2309* data+linesize for the bitmap of this subtitle.2310* Can be set for text/ass as well once they are rendered.2311*/2312uint8_t *data[4];2313int linesize[4];23142315enum AVSubtitleType type;23162317char *text; ///< 0 terminated plain UTF-8 text23182319/**2320* 0 terminated ASS/SSA compatible event line.2321* The presentation of this is unaffected by the other values in this2322* struct.2323*/2324char *ass;23252326int flags;2327} AVSubtitleRect;23282329typedef struct AVSubtitle {2330uint16_t format; /* 0 = graphics */2331uint32_t start_display_time; /* relative to packet pts, in ms */2332uint32_t end_display_time; /* relative to packet pts, in ms */2333unsigned num_rects;2334AVSubtitleRect **rects;2335int64_t pts; ///< Same as packet pts, in AV_TIME_BASE2336} AVSubtitle;23372338/**2339* Return the LIBAVCODEC_VERSION_INT constant.2340*/2341unsigned avcodec_version(void);23422343/**2344* Return the libavcodec build-time configuration.2345*/2346const char *avcodec_configuration(void);23472348/**2349* Return the libavcodec license.2350*/2351const char *avcodec_license(void);23522353/**2354* Allocate an AVCodecContext and set its fields to default values. The2355* resulting struct should be freed with avcodec_free_context().2356*2357* @param codec if non-NULL, allocate private data and initialize defaults2358* for the given codec. It is illegal to then call avcodec_open2()2359* with a different codec.2360* If NULL, then the codec-specific defaults won't be initialized,2361* which may result in suboptimal default settings (this is2362* important mainly for encoders, e.g. libx264).2363*2364* @return An AVCodecContext filled with default values or NULL on failure.2365*/2366AVCodecContext *avcodec_alloc_context3(const AVCodec *codec);23672368/**2369* Free the codec context and everything associated with it and write NULL to2370* the provided pointer.2371*/2372void avcodec_free_context(AVCodecContext **avctx);23732374/**2375* Get the AVClass for AVCodecContext. It can be used in combination with2376* AV_OPT_SEARCH_FAKE_OBJ for examining options.2377*2378* @see av_opt_find().2379*/2380const AVClass *avcodec_get_class(void);23812382/**2383* Get the AVClass for AVSubtitleRect. It can be used in combination with2384* AV_OPT_SEARCH_FAKE_OBJ for examining options.2385*2386* @see av_opt_find().2387*/2388const AVClass *avcodec_get_subtitle_rect_class(void);23892390/**2391* Fill the parameters struct based on the values from the supplied codec2392* context. Any allocated fields in par are freed and replaced with duplicates2393* of the corresponding fields in codec.2394*2395* @return >= 0 on success, a negative AVERROR code on failure2396*/2397int avcodec_parameters_from_context(AVCodecParameters *par,2398const AVCodecContext *codec);23992400/**2401* Fill the codec context based on the values from the supplied codec2402* parameters. Any allocated fields in codec that have a corresponding field in2403* par are freed and replaced with duplicates of the corresponding field in par.2404* Fields in codec that do not have a counterpart in par are not touched.2405*2406* @return >= 0 on success, a negative AVERROR code on failure.2407*/2408int avcodec_parameters_to_context(AVCodecContext *codec,2409const AVCodecParameters *par);24102411/**2412* Initialize the AVCodecContext to use the given AVCodec. Prior to using this2413* function the context has to be allocated with avcodec_alloc_context3().2414*2415* The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),2416* avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for2417* retrieving a codec.2418*2419* @note Always call this function before using decoding routines (such as2420* @ref avcodec_receive_frame()).2421*2422* @code2423* av_dict_set(&opts, "b", "2.5M", 0);2424* codec = avcodec_find_decoder(AV_CODEC_ID_H264);2425* if (!codec)2426* exit(1);2427*2428* context = avcodec_alloc_context3(codec);2429*2430* if (avcodec_open2(context, codec, opts) < 0)2431* exit(1);2432* @endcode2433*2434* @param avctx The context to initialize.2435* @param codec The codec to open this context for. If a non-NULL codec has been2436* previously passed to avcodec_alloc_context3() or2437* for this context, then this parameter MUST be either NULL or2438* equal to the previously passed codec.2439* @param options A dictionary filled with AVCodecContext and codec-private options.2440* On return this object will be filled with options that were not found.2441*2442* @return zero on success, a negative value on error2443* @see avcodec_alloc_context3(), avcodec_find_decoder(), avcodec_find_encoder(),2444* av_dict_set(), av_opt_find().2445*/2446int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options);24472448/**2449* Close a given AVCodecContext and free all the data associated with it2450* (but not the AVCodecContext itself).2451*2452* Calling this function on an AVCodecContext that hasn't been opened will free2453* the codec-specific data allocated in avcodec_alloc_context3() with a non-NULL2454* codec. Subsequent calls will do nothing.2455*2456* @note Do not use this function. Use avcodec_free_context() to destroy a2457* codec context (either open or closed). Opening and closing a codec context2458* multiple times is not supported anymore -- use multiple codec contexts2459* instead.2460*/2461int avcodec_close(AVCodecContext *avctx);24622463/**2464* Free all allocated data in the given subtitle struct.2465*2466* @param sub AVSubtitle to free.2467*/2468void avsubtitle_free(AVSubtitle *sub);24692470/**2471* @}2472*/24732474/**2475* @addtogroup lavc_decoding2476* @{2477*/24782479/**2480* The default callback for AVCodecContext.get_buffer2(). It is made public so2481* it can be called by custom get_buffer2() implementations for decoders without2482* AV_CODEC_CAP_DR1 set.2483*/2484int avcodec_default_get_buffer2(AVCodecContext *s, AVFrame *frame, int flags);24852486/**2487* The default callback for AVCodecContext.get_encode_buffer(). It is made public so2488* it can be called by custom get_encode_buffer() implementations for encoders without2489* AV_CODEC_CAP_DR1 set.2490*/2491int avcodec_default_get_encode_buffer(AVCodecContext *s, AVPacket *pkt, int flags);24922493/**2494* Modify width and height values so that they will result in a memory2495* buffer that is acceptable for the codec if you do not use any horizontal2496* padding.2497*2498* May only be used if a codec with AV_CODEC_CAP_DR1 has been opened.2499*/2500void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);25012502/**2503* Modify width and height values so that they will result in a memory2504* buffer that is acceptable for the codec if you also ensure that all2505* line sizes are a multiple of the respective linesize_align[i].2506*2507* May only be used if a codec with AV_CODEC_CAP_DR1 has been opened.2508*/2509void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,2510int linesize_align[AV_NUM_DATA_POINTERS]);25112512#ifdef FF_API_AVCODEC_CHROMA_POS2513/**2514* Converts AVChromaLocation to swscale x/y chroma position.2515*2516* The positions represent the chroma (0,0) position in a coordinates system2517* with luma (0,0) representing the origin and luma(1,1) representing 256,2562518*2519* @param xpos horizontal chroma sample position2520* @param ypos vertical chroma sample position2521* @deprecated Use av_chroma_location_enum_to_pos() instead.2522*/2523attribute_deprecated2524int avcodec_enum_to_chroma_pos(int *xpos, int *ypos, enum AVChromaLocation pos);25252526/**2527* Converts swscale x/y chroma position to AVChromaLocation.2528*2529* The positions represent the chroma (0,0) position in a coordinates system2530* with luma (0,0) representing the origin and luma(1,1) representing 256,2562531*2532* @param xpos horizontal chroma sample position2533* @param ypos vertical chroma sample position2534* @deprecated Use av_chroma_location_pos_to_enum() instead.2535*/2536attribute_deprecated2537enum AVChromaLocation avcodec_chroma_pos_to_enum(int xpos, int ypos);2538#endif25392540/**2541* Decode a subtitle message.2542* Return a negative value on error, otherwise return the number of bytes used.2543* If no subtitle could be decompressed, got_sub_ptr is zero.2544* Otherwise, the subtitle is stored in *sub.2545* Note that AV_CODEC_CAP_DR1 is not available for subtitle codecs. This is for2546* simplicity, because the performance difference is expected to be negligible2547* and reusing a get_buffer written for video codecs would probably perform badly2548* due to a potentially very different allocation pattern.2549*2550* Some decoders (those marked with AV_CODEC_CAP_DELAY) have a delay between input2551* and output. This means that for some packets they will not immediately2552* produce decoded output and need to be flushed at the end of decoding to get2553* all the decoded data. Flushing is done by calling this function with packets2554* with avpkt->data set to NULL and avpkt->size set to 0 until it stops2555* returning subtitles. It is safe to flush even those decoders that are not2556* marked with AV_CODEC_CAP_DELAY, then no subtitles will be returned.2557*2558* @note The AVCodecContext MUST have been opened with @ref avcodec_open2()2559* before packets may be fed to the decoder.2560*2561* @param avctx the codec context2562* @param[out] sub The preallocated AVSubtitle in which the decoded subtitle will be stored,2563* must be freed with avsubtitle_free if *got_sub_ptr is set.2564* @param[in,out] got_sub_ptr Zero if no subtitle could be decompressed, otherwise, it is nonzero.2565* @param[in] avpkt The input AVPacket containing the input buffer.2566*/2567int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,2568int *got_sub_ptr, const AVPacket *avpkt);25692570/**2571* Supply raw packet data as input to a decoder.2572*2573* Internally, this call will copy relevant AVCodecContext fields, which can2574* influence decoding per-packet, and apply them when the packet is actually2575* decoded. (For example AVCodecContext.skip_frame, which might direct the2576* decoder to drop the frame contained by the packet sent with this function.)2577*2578* @warning The input buffer, avpkt->data must be AV_INPUT_BUFFER_PADDING_SIZE2579* larger than the actual read bytes because some optimized bitstream2580* readers read 32 or 64 bits at once and could read over the end.2581*2582* @note The AVCodecContext MUST have been opened with @ref avcodec_open2()2583* before packets may be fed to the decoder.2584*2585* @param avctx codec context2586* @param[in] avpkt The input AVPacket. Usually, this will be a single video2587* frame, or several complete audio frames.2588* Ownership of the packet remains with the caller, and the2589* decoder will not write to the packet. The decoder may create2590* a reference to the packet data (or copy it if the packet is2591* not reference-counted).2592* Unlike with older APIs, the packet is always fully consumed,2593* and if it contains multiple frames (e.g. some audio codecs),2594* will require you to call avcodec_receive_frame() multiple2595* times afterwards before you can send a new packet.2596* It can be NULL (or an AVPacket with data set to NULL and2597* size set to 0); in this case, it is considered a flush2598* packet, which signals the end of the stream. Sending the2599* first flush packet will return success. Subsequent ones are2600* unnecessary and will return AVERROR_EOF. If the decoder2601* still has frames buffered, it will return them after sending2602* a flush packet.2603*2604* @retval 0 success2605* @retval AVERROR(EAGAIN) input is not accepted in the current state - user2606* must read output with avcodec_receive_frame() (once2607* all output is read, the packet should be resent,2608* and the call will not fail with EAGAIN).2609* @retval AVERROR_EOF the decoder has been flushed, and no new packets can be2610* sent to it (also returned if more than 1 flush2611* packet is sent)2612* @retval AVERROR(EINVAL) codec not opened, it is an encoder, or requires flush2613* @retval AVERROR(ENOMEM) failed to add packet to internal queue, or similar2614* @retval "another negative error code" legitimate decoding errors2615*/2616int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt);26172618/**2619* Return decoded output data from a decoder or encoder (when the2620* AV_CODEC_FLAG_RECON_FRAME flag is used).2621*2622* @param avctx codec context2623* @param frame This will be set to a reference-counted video or audio2624* frame (depending on the decoder type) allocated by the2625* codec. Note that the function will always call2626* av_frame_unref(frame) before doing anything else.2627*2628* @retval 0 success, a frame was returned2629* @retval AVERROR(EAGAIN) output is not available in this state - user must2630* try to send new input2631* @retval AVERROR_EOF the codec has been fully flushed, and there will be2632* no more output frames2633* @retval AVERROR(EINVAL) codec not opened, or it is an encoder without the2634* AV_CODEC_FLAG_RECON_FRAME flag enabled2635* @retval AVERROR_INPUT_CHANGED current decoded frame has changed parameters with2636* respect to first decoded frame. Applicable when flag2637* AV_CODEC_FLAG_DROPCHANGED is set.2638* @retval "other negative error code" legitimate decoding errors2639*/2640int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame);26412642/**2643* Supply a raw video or audio frame to the encoder. Use avcodec_receive_packet()2644* to retrieve buffered output packets.2645*2646* @param avctx codec context2647* @param[in] frame AVFrame containing the raw audio or video frame to be encoded.2648* Ownership of the frame remains with the caller, and the2649* encoder will not write to the frame. The encoder may create2650* a reference to the frame data (or copy it if the frame is2651* not reference-counted).2652* It can be NULL, in which case it is considered a flush2653* packet. This signals the end of the stream. If the encoder2654* still has packets buffered, it will return them after this2655* call. Once flushing mode has been entered, additional flush2656* packets are ignored, and sending frames will return2657* AVERROR_EOF.2658*2659* For audio:2660* If AV_CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame2661* can have any number of samples.2662* If it is not set, frame->nb_samples must be equal to2663* avctx->frame_size for all frames except the last.2664* The final frame may be smaller than avctx->frame_size.2665* @retval 0 success2666* @retval AVERROR(EAGAIN) input is not accepted in the current state - user must2667* read output with avcodec_receive_packet() (once all2668* output is read, the packet should be resent, and the2669* call will not fail with EAGAIN).2670* @retval AVERROR_EOF the encoder has been flushed, and no new frames can2671* be sent to it2672* @retval AVERROR(EINVAL) codec not opened, it is a decoder, or requires flush2673* @retval AVERROR(ENOMEM) failed to add packet to internal queue, or similar2674* @retval "another negative error code" legitimate encoding errors2675*/2676int avcodec_send_frame(AVCodecContext *avctx, const AVFrame *frame);26772678/**2679* Read encoded data from the encoder.2680*2681* @param avctx codec context2682* @param avpkt This will be set to a reference-counted packet allocated by the2683* encoder. Note that the function will always call2684* av_packet_unref(avpkt) before doing anything else.2685* @retval 0 success2686* @retval AVERROR(EAGAIN) output is not available in the current state - user must2687* try to send input2688* @retval AVERROR_EOF the encoder has been fully flushed, and there will be no2689* more output packets2690* @retval AVERROR(EINVAL) codec not opened, or it is a decoder2691* @retval "another negative error code" legitimate encoding errors2692*/2693int avcodec_receive_packet(AVCodecContext *avctx, AVPacket *avpkt);26942695/**2696* Create and return a AVHWFramesContext with values adequate for hardware2697* decoding. This is meant to get called from the get_format callback, and is2698* a helper for preparing a AVHWFramesContext for AVCodecContext.hw_frames_ctx.2699* This API is for decoding with certain hardware acceleration modes/APIs only.2700*2701* The returned AVHWFramesContext is not initialized. The caller must do this2702* with av_hwframe_ctx_init().2703*2704* Calling this function is not a requirement, but makes it simpler to avoid2705* codec or hardware API specific details when manually allocating frames.2706*2707* Alternatively to this, an API user can set AVCodecContext.hw_device_ctx,2708* which sets up AVCodecContext.hw_frames_ctx fully automatically, and makes2709* it unnecessary to call this function or having to care about2710* AVHWFramesContext initialization at all.2711*2712* There are a number of requirements for calling this function:2713*2714* - It must be called from get_format with the same avctx parameter that was2715* passed to get_format. Calling it outside of get_format is not allowed, and2716* can trigger undefined behavior.2717* - The function is not always supported (see description of return values).2718* Even if this function returns successfully, hwaccel initialization could2719* fail later. (The degree to which implementations check whether the stream2720* is actually supported varies. Some do this check only after the user's2721* get_format callback returns.)2722* - The hw_pix_fmt must be one of the choices suggested by get_format. If the2723* user decides to use a AVHWFramesContext prepared with this API function,2724* the user must return the same hw_pix_fmt from get_format.2725* - The device_ref passed to this function must support the given hw_pix_fmt.2726* - After calling this API function, it is the user's responsibility to2727* initialize the AVHWFramesContext (returned by the out_frames_ref parameter),2728* and to set AVCodecContext.hw_frames_ctx to it. If done, this must be done2729* before returning from get_format (this is implied by the normal2730* AVCodecContext.hw_frames_ctx API rules).2731* - The AVHWFramesContext parameters may change every time time get_format is2732* called. Also, AVCodecContext.hw_frames_ctx is reset before get_format. So2733* you are inherently required to go through this process again on every2734* get_format call.2735* - It is perfectly possible to call this function without actually using2736* the resulting AVHWFramesContext. One use-case might be trying to reuse a2737* previously initialized AVHWFramesContext, and calling this API function2738* only to test whether the required frame parameters have changed.2739* - Fields that use dynamically allocated values of any kind must not be set2740* by the user unless setting them is explicitly allowed by the documentation.2741* If the user sets AVHWFramesContext.free and AVHWFramesContext.user_opaque,2742* the new free callback must call the potentially set previous free callback.2743* This API call may set any dynamically allocated fields, including the free2744* callback.2745*2746* The function will set at least the following fields on AVHWFramesContext2747* (potentially more, depending on hwaccel API):2748*2749* - All fields set by av_hwframe_ctx_alloc().2750* - Set the format field to hw_pix_fmt.2751* - Set the sw_format field to the most suited and most versatile format. (An2752* implication is that this will prefer generic formats over opaque formats2753* with arbitrary restrictions, if possible.)2754* - Set the width/height fields to the coded frame size, rounded up to the2755* API-specific minimum alignment.2756* - Only _if_ the hwaccel requires a pre-allocated pool: set the initial_pool_size2757* field to the number of maximum reference surfaces possible with the codec,2758* plus 1 surface for the user to work (meaning the user can safely reference2759* at most 1 decoded surface at a time), plus additional buffering introduced2760* by frame threading. If the hwaccel does not require pre-allocation, the2761* field is left to 0, and the decoder will allocate new surfaces on demand2762* during decoding.2763* - Possibly AVHWFramesContext.hwctx fields, depending on the underlying2764* hardware API.2765*2766* Essentially, out_frames_ref returns the same as av_hwframe_ctx_alloc(), but2767* with basic frame parameters set.2768*2769* The function is stateless, and does not change the AVCodecContext or the2770* device_ref AVHWDeviceContext.2771*2772* @param avctx The context which is currently calling get_format, and which2773* implicitly contains all state needed for filling the returned2774* AVHWFramesContext properly.2775* @param device_ref A reference to the AVHWDeviceContext describing the device2776* which will be used by the hardware decoder.2777* @param hw_pix_fmt The hwaccel format you are going to return from get_format.2778* @param out_frames_ref On success, set to a reference to an _uninitialized_2779* AVHWFramesContext, created from the given device_ref.2780* Fields will be set to values required for decoding.2781* Not changed if an error is returned.2782* @return zero on success, a negative value on error. The following error codes2783* have special semantics:2784* AVERROR(ENOENT): the decoder does not support this functionality. Setup2785* is always manual, or it is a decoder which does not2786* support setting AVCodecContext.hw_frames_ctx at all,2787* or it is a software format.2788* AVERROR(EINVAL): it is known that hardware decoding is not supported for2789* this configuration, or the device_ref is not supported2790* for the hwaccel referenced by hw_pix_fmt.2791*/2792int avcodec_get_hw_frames_parameters(AVCodecContext *avctx,2793AVBufferRef *device_ref,2794enum AVPixelFormat hw_pix_fmt,2795AVBufferRef **out_frames_ref);2796279727982799/**2800* @defgroup lavc_parsing Frame parsing2801* @{2802*/28032804enum AVPictureStructure {2805AV_PICTURE_STRUCTURE_UNKNOWN, ///< unknown2806AV_PICTURE_STRUCTURE_TOP_FIELD, ///< coded as top field2807AV_PICTURE_STRUCTURE_BOTTOM_FIELD, ///< coded as bottom field2808AV_PICTURE_STRUCTURE_FRAME, ///< coded as frame2809};28102811typedef struct AVCodecParserContext {2812void *priv_data;2813const struct AVCodecParser *parser;2814int64_t frame_offset; /* offset of the current frame */2815int64_t cur_offset; /* current offset2816(incremented by each av_parser_parse()) */2817int64_t next_frame_offset; /* offset of the next frame */2818/* video info */2819int pict_type; /* XXX: Put it back in AVCodecContext. */2820/**2821* This field is used for proper frame duration computation in lavf.2822* It signals, how much longer the frame duration of the current frame2823* is compared to normal frame duration.2824*2825* frame_duration = (1 + repeat_pict) * time_base2826*2827* It is used by codecs like H.264 to display telecined material.2828*/2829int repeat_pict; /* XXX: Put it back in AVCodecContext. */2830int64_t pts; /* pts of the current frame */2831int64_t dts; /* dts of the current frame */28322833/* private data */2834int64_t last_pts;2835int64_t last_dts;2836int fetch_timestamp;28372838#define AV_PARSER_PTS_NB 42839int cur_frame_start_index;2840int64_t cur_frame_offset[AV_PARSER_PTS_NB];2841int64_t cur_frame_pts[AV_PARSER_PTS_NB];2842int64_t cur_frame_dts[AV_PARSER_PTS_NB];28432844int flags;2845#define PARSER_FLAG_COMPLETE_FRAMES 0x00012846#define PARSER_FLAG_ONCE 0x00022847/// Set if the parser has a valid file offset2848#define PARSER_FLAG_FETCHED_OFFSET 0x00042849#define PARSER_FLAG_USE_CODEC_TS 0x100028502851int64_t offset; ///< byte offset from starting packet start2852int64_t cur_frame_end[AV_PARSER_PTS_NB];28532854/**2855* Set by parser to 1 for key frames and 0 for non-key frames.2856* It is initialized to -1, so if the parser doesn't set this flag,2857* old-style fallback using AV_PICTURE_TYPE_I picture type as key frames2858* will be used.2859*/2860int key_frame;28612862// Timestamp generation support:2863/**2864* Synchronization point for start of timestamp generation.2865*2866* Set to >0 for sync point, 0 for no sync point and <0 for undefined2867* (default).2868*2869* For example, this corresponds to presence of H.264 buffering period2870* SEI message.2871*/2872int dts_sync_point;28732874/**2875* Offset of the current timestamp against last timestamp sync point in2876* units of AVCodecContext.time_base.2877*2878* Set to INT_MIN when dts_sync_point unused. Otherwise, it must2879* contain a valid timestamp offset.2880*2881* Note that the timestamp of sync point has usually a nonzero2882* dts_ref_dts_delta, which refers to the previous sync point. Offset of2883* the next frame after timestamp sync point will be usually 1.2884*2885* For example, this corresponds to H.264 cpb_removal_delay.2886*/2887int dts_ref_dts_delta;28882889/**2890* Presentation delay of current frame in units of AVCodecContext.time_base.2891*2892* Set to INT_MIN when dts_sync_point unused. Otherwise, it must2893* contain valid non-negative timestamp delta (presentation time of a frame2894* must not lie in the past).2895*2896* This delay represents the difference between decoding and presentation2897* time of the frame.2898*2899* For example, this corresponds to H.264 dpb_output_delay.2900*/2901int pts_dts_delta;29022903/**2904* Position of the packet in file.2905*2906* Analogous to cur_frame_pts/dts2907*/2908int64_t cur_frame_pos[AV_PARSER_PTS_NB];29092910/**2911* Byte position of currently parsed frame in stream.2912*/2913int64_t pos;29142915/**2916* Previous frame byte position.2917*/2918int64_t last_pos;29192920/**2921* Duration of the current frame.2922* For audio, this is in units of 1 / AVCodecContext.sample_rate.2923* For all other types, this is in units of AVCodecContext.time_base.2924*/2925int duration;29262927enum AVFieldOrder field_order;29282929/**2930* Indicate whether a picture is coded as a frame, top field or bottom field.2931*2932* For example, H.264 field_pic_flag equal to 0 corresponds to2933* AV_PICTURE_STRUCTURE_FRAME. An H.264 picture with field_pic_flag2934* equal to 1 and bottom_field_flag equal to 0 corresponds to2935* AV_PICTURE_STRUCTURE_TOP_FIELD.2936*/2937enum AVPictureStructure picture_structure;29382939/**2940* Picture number incremented in presentation or output order.2941* This field may be reinitialized at the first picture of a new sequence.2942*2943* For example, this corresponds to H.264 PicOrderCnt.2944*/2945int output_picture_number;29462947/**2948* Dimensions of the decoded video intended for presentation.2949*/2950int width;2951int height;29522953/**2954* Dimensions of the coded video.2955*/2956int coded_width;2957int coded_height;29582959/**2960* The format of the coded data, corresponds to enum AVPixelFormat for video2961* and for enum AVSampleFormat for audio.2962*2963* Note that a decoder can have considerable freedom in how exactly it2964* decodes the data, so the format reported here might be different from the2965* one returned by a decoder.2966*/2967int format;2968} AVCodecParserContext;29692970typedef struct AVCodecParser {2971int codec_ids[7]; /* several codec IDs are permitted */2972int priv_data_size;2973int (*parser_init)(AVCodecParserContext *s);2974/* This callback never returns an error, a negative value means that2975* the frame start was in a previous packet. */2976int (*parser_parse)(AVCodecParserContext *s,2977AVCodecContext *avctx,2978const uint8_t **poutbuf, int *poutbuf_size,2979const uint8_t *buf, int buf_size);2980void (*parser_close)(AVCodecParserContext *s);2981int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size);2982} AVCodecParser;29832984/**2985* Iterate over all registered codec parsers.2986*2987* @param opaque a pointer where libavcodec will store the iteration state. Must2988* point to NULL to start the iteration.2989*2990* @return the next registered codec parser or NULL when the iteration is2991* finished2992*/2993const AVCodecParser *av_parser_iterate(void **opaque);29942995AVCodecParserContext *av_parser_init(int codec_id);29962997/**2998* Parse a packet.2999*3000* @param s parser context.3001* @param avctx codec context.3002* @param poutbuf set to pointer to parsed buffer or NULL if not yet finished.3003* @param poutbuf_size set to size of parsed buffer or zero if not yet finished.3004* @param buf input buffer.3005* @param buf_size buffer size in bytes without the padding. I.e. the full buffer3006size is assumed to be buf_size + AV_INPUT_BUFFER_PADDING_SIZE.3007To signal EOF, this should be 0 (so that the last frame3008can be output).3009* @param pts input presentation timestamp.3010* @param dts input decoding timestamp.3011* @param pos input byte position in stream.3012* @return the number of bytes of the input bitstream used.3013*3014* Example:3015* @code3016* while(in_len){3017* len = av_parser_parse2(myparser, AVCodecContext, &data, &size,3018* in_data, in_len,3019* pts, dts, pos);3020* in_data += len;3021* in_len -= len;3022*3023* if(size)3024* decode_frame(data, size);3025* }3026* @endcode3027*/3028int av_parser_parse2(AVCodecParserContext *s,3029AVCodecContext *avctx,3030uint8_t **poutbuf, int *poutbuf_size,3031const uint8_t *buf, int buf_size,3032int64_t pts, int64_t dts,3033int64_t pos);30343035void av_parser_close(AVCodecParserContext *s);30363037/**3038* @}3039* @}3040*/30413042/**3043* @addtogroup lavc_encoding3044* @{3045*/30463047int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,3048const AVSubtitle *sub);304930503051/**3052* @}3053*/30543055/**3056* @defgroup lavc_misc Utility functions3057* @ingroup libavc3058*3059* Miscellaneous utility functions related to both encoding and decoding3060* (or neither).3061* @{3062*/30633064/**3065* @defgroup lavc_misc_pixfmt Pixel formats3066*3067* Functions for working with pixel formats.3068* @{3069*/30703071/**3072* Return a value representing the fourCC code associated to the3073* pixel format pix_fmt, or 0 if no associated fourCC code can be3074* found.3075*/3076unsigned int avcodec_pix_fmt_to_codec_tag(enum AVPixelFormat pix_fmt);30773078/**3079* Find the best pixel format to convert to given a certain source pixel3080* format. When converting from one pixel format to another, information loss3081* may occur. For example, when converting from RGB24 to GRAY, the color3082* information will be lost. Similarly, other losses occur when converting from3083* some formats to other formats. avcodec_find_best_pix_fmt_of_2() searches which of3084* the given pixel formats should be used to suffer the least amount of loss.3085* The pixel formats from which it chooses one, are determined by the3086* pix_fmt_list parameter.3087*3088*3089* @param[in] pix_fmt_list AV_PIX_FMT_NONE terminated array of pixel formats to choose from3090* @param[in] src_pix_fmt source pixel format3091* @param[in] has_alpha Whether the source pixel format alpha channel is used.3092* @param[out] loss_ptr Combination of flags informing you what kind of losses will occur.3093* @return The best pixel format to convert to or -1 if none was found.3094*/3095enum AVPixelFormat avcodec_find_best_pix_fmt_of_list(const enum AVPixelFormat *pix_fmt_list,3096enum AVPixelFormat src_pix_fmt,3097int has_alpha, int *loss_ptr);30983099enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum AVPixelFormat * fmt);31003101/**3102* @}3103*/31043105void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);31063107int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size);3108int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count);3109//FIXME func typedef31103111/**3112* Fill AVFrame audio data and linesize pointers.3113*3114* The buffer buf must be a preallocated buffer with a size big enough3115* to contain the specified samples amount. The filled AVFrame data3116* pointers will point to this buffer.3117*3118* AVFrame extended_data channel pointers are allocated if necessary for3119* planar audio.3120*3121* @param frame the AVFrame3122* frame->nb_samples must be set prior to calling the3123* function. This function fills in frame->data,3124* frame->extended_data, frame->linesize[0].3125* @param nb_channels channel count3126* @param sample_fmt sample format3127* @param buf buffer to use for frame data3128* @param buf_size size of buffer3129* @param align plane size sample alignment (0 = default)3130* @return >=0 on success, negative error code on failure3131* @todo return the size in bytes required to store the samples in3132* case of success, at the next libavutil bump3133*/3134int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels,3135enum AVSampleFormat sample_fmt, const uint8_t *buf,3136int buf_size, int align);31373138/**3139* Reset the internal codec state / flush internal buffers. Should be called3140* e.g. when seeking or when switching to a different stream.3141*3142* @note for decoders, this function just releases any references the decoder3143* might keep internally, but the caller's references remain valid.3144*3145* @note for encoders, this function will only do something if the encoder3146* declares support for AV_CODEC_CAP_ENCODER_FLUSH. When called, the encoder3147* will drain any remaining packets, and can then be re-used for a different3148* stream (as opposed to sending a null frame which will leave the encoder3149* in a permanent EOF state after draining). This can be desirable if the3150* cost of tearing down and replacing the encoder instance is high.3151*/3152void avcodec_flush_buffers(AVCodecContext *avctx);31533154/**3155* Return audio frame duration.3156*3157* @param avctx codec context3158* @param frame_bytes size of the frame, or 0 if unknown3159* @return frame duration, in samples, if known. 0 if not able to3160* determine.3161*/3162int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes);31633164/* memory */31653166/**3167* Same behaviour av_fast_malloc but the buffer has additional3168* AV_INPUT_BUFFER_PADDING_SIZE at the end which will always be 0.3169*3170* In addition the whole buffer will initially and after resizes3171* be 0-initialized so that no uninitialized data will ever appear.3172*/3173void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size);31743175/**3176* Same behaviour av_fast_padded_malloc except that buffer will always3177* be 0-initialized after call.3178*/3179void av_fast_padded_mallocz(void *ptr, unsigned int *size, size_t min_size);31803181/**3182* @return a positive value if s is open (i.e. avcodec_open2() was called on it3183* with no corresponding avcodec_close()), 0 otherwise.3184*/3185int avcodec_is_open(AVCodecContext *s);31863187/**3188* @}3189*/31903191#endif /* AVCODEC_AVCODEC_H */319231933194