Path: blob/a-new-beginning/libavutil.xcframework/macos-arm64/libavutil.framework/Versions/A/Headers/frame.h
2 views
/*1* This file is part of FFmpeg.2*3* FFmpeg is free software; you can redistribute it and/or4* modify it under the terms of the GNU Lesser General Public5* License as published by the Free Software Foundation; either6* version 2.1 of the License, or (at your option) any later version.7*8* FFmpeg is distributed in the hope that it will be useful,9* but WITHOUT ANY WARRANTY; without even the implied warranty of10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU11* Lesser General Public License for more details.12*13* You should have received a copy of the GNU Lesser General Public14* License along with FFmpeg; if not, write to the Free Software15* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA16*/1718/**19* @file20* @ingroup lavu_frame21* reference-counted frame API22*/2324#ifndef AVUTIL_FRAME_H25#define AVUTIL_FRAME_H2627#include <stddef.h>28#include <stdint.h>2930#include "avutil.h"31#include "buffer.h"32#include "channel_layout.h"33#include "dict.h"34#include "rational.h"35#include "samplefmt.h"36#include "pixfmt.h"37#include "version.h"383940/**41* @defgroup lavu_frame AVFrame42* @ingroup lavu_data43*44* @{45* AVFrame is an abstraction for reference-counted raw multimedia data.46*/4748enum AVFrameSideDataType {49/**50* The data is the AVPanScan struct defined in libavcodec.51*/52AV_FRAME_DATA_PANSCAN,53/**54* ATSC A53 Part 4 Closed Captions.55* A53 CC bitstream is stored as uint8_t in AVFrameSideData.data.56* The number of bytes of CC data is AVFrameSideData.size.57*/58AV_FRAME_DATA_A53_CC,59/**60* Stereoscopic 3d metadata.61* The data is the AVStereo3D struct defined in libavutil/stereo3d.h.62*/63AV_FRAME_DATA_STEREO3D,64/**65* The data is the AVMatrixEncoding enum defined in libavutil/channel_layout.h.66*/67AV_FRAME_DATA_MATRIXENCODING,68/**69* Metadata relevant to a downmix procedure.70* The data is the AVDownmixInfo struct defined in libavutil/downmix_info.h.71*/72AV_FRAME_DATA_DOWNMIX_INFO,73/**74* ReplayGain information in the form of the AVReplayGain struct.75*/76AV_FRAME_DATA_REPLAYGAIN,77/**78* This side data contains a 3x3 transformation matrix describing an affine79* transformation that needs to be applied to the frame for correct80* presentation.81*82* See libavutil/display.h for a detailed description of the data.83*/84AV_FRAME_DATA_DISPLAYMATRIX,85/**86* Active Format Description data consisting of a single byte as specified87* in ETSI TS 101 154 using AVActiveFormatDescription enum.88*/89AV_FRAME_DATA_AFD,90/**91* Motion vectors exported by some codecs (on demand through the export_mvs92* flag set in the libavcodec AVCodecContext flags2 option).93* The data is the AVMotionVector struct defined in94* libavutil/motion_vector.h.95*/96AV_FRAME_DATA_MOTION_VECTORS,97/**98* Recommmends skipping the specified number of samples. This is exported99* only if the "skip_manual" AVOption is set in libavcodec.100* This has the same format as AV_PKT_DATA_SKIP_SAMPLES.101* @code102* u32le number of samples to skip from start of this packet103* u32le number of samples to skip from end of this packet104* u8 reason for start skip105* u8 reason for end skip (0=padding silence, 1=convergence)106* @endcode107*/108AV_FRAME_DATA_SKIP_SAMPLES,109/**110* This side data must be associated with an audio frame and corresponds to111* enum AVAudioServiceType defined in avcodec.h.112*/113AV_FRAME_DATA_AUDIO_SERVICE_TYPE,114/**115* Mastering display metadata associated with a video frame. The payload is116* an AVMasteringDisplayMetadata type and contains information about the117* mastering display color volume.118*/119AV_FRAME_DATA_MASTERING_DISPLAY_METADATA,120/**121* The GOP timecode in 25 bit timecode format. Data format is 64-bit integer.122* This is set on the first frame of a GOP that has a temporal reference of 0.123*/124AV_FRAME_DATA_GOP_TIMECODE,125126/**127* The data represents the AVSphericalMapping structure defined in128* libavutil/spherical.h.129*/130AV_FRAME_DATA_SPHERICAL,131132/**133* Content light level (based on CTA-861.3). This payload contains data in134* the form of the AVContentLightMetadata struct.135*/136AV_FRAME_DATA_CONTENT_LIGHT_LEVEL,137138/**139* The data contains an ICC profile as an opaque octet buffer following the140* format described by ISO 15076-1 with an optional name defined in the141* metadata key entry "name".142*/143AV_FRAME_DATA_ICC_PROFILE,144145/**146* Timecode which conforms to SMPTE ST 12-1. The data is an array of 4 uint32_t147* where the first uint32_t describes how many (1-3) of the other timecodes are used.148* The timecode format is described in the documentation of av_timecode_get_smpte_from_framenum()149* function in libavutil/timecode.h.150*/151AV_FRAME_DATA_S12M_TIMECODE,152153/**154* HDR dynamic metadata associated with a video frame. The payload is155* an AVDynamicHDRPlus type and contains information for color156* volume transform - application 4 of SMPTE 2094-40:2016 standard.157*/158AV_FRAME_DATA_DYNAMIC_HDR_PLUS,159160/**161* Regions Of Interest, the data is an array of AVRegionOfInterest type, the number of162* array element is implied by AVFrameSideData.size / AVRegionOfInterest.self_size.163*/164AV_FRAME_DATA_REGIONS_OF_INTEREST,165166/**167* Encoding parameters for a video frame, as described by AVVideoEncParams.168*/169AV_FRAME_DATA_VIDEO_ENC_PARAMS,170171/**172* User data unregistered metadata associated with a video frame.173* This is the H.26[45] UDU SEI message, and shouldn't be used for any other purpose174* The data is stored as uint8_t in AVFrameSideData.data which is 16 bytes of175* uuid_iso_iec_11578 followed by AVFrameSideData.size - 16 bytes of user_data_payload_byte.176*/177AV_FRAME_DATA_SEI_UNREGISTERED,178179/**180* Film grain parameters for a frame, described by AVFilmGrainParams.181* Must be present for every frame which should have film grain applied.182*/183AV_FRAME_DATA_FILM_GRAIN_PARAMS,184185/**186* Bounding boxes for object detection and classification,187* as described by AVDetectionBBoxHeader.188*/189AV_FRAME_DATA_DETECTION_BBOXES,190191/**192* Dolby Vision RPU raw data, suitable for passing to x265193* or other libraries. Array of uint8_t, with NAL emulation194* bytes intact.195*/196AV_FRAME_DATA_DOVI_RPU_BUFFER,197198/**199* Parsed Dolby Vision metadata, suitable for passing to a software200* implementation. The payload is the AVDOVIMetadata struct defined in201* libavutil/dovi_meta.h.202*/203AV_FRAME_DATA_DOVI_METADATA,204205/**206* HDR Vivid dynamic metadata associated with a video frame. The payload is207* an AVDynamicHDRVivid type and contains information for color208* volume transform - CUVA 005.1-2021.209*/210AV_FRAME_DATA_DYNAMIC_HDR_VIVID,211212/**213* Ambient viewing environment metadata, as defined by H.274.214*/215AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT,216};217218enum AVActiveFormatDescription {219AV_AFD_SAME = 8,220AV_AFD_4_3 = 9,221AV_AFD_16_9 = 10,222AV_AFD_14_9 = 11,223AV_AFD_4_3_SP_14_9 = 13,224AV_AFD_16_9_SP_14_9 = 14,225AV_AFD_SP_4_3 = 15,226};227228229/**230* Structure to hold side data for an AVFrame.231*232* sizeof(AVFrameSideData) is not a part of the public ABI, so new fields may be added233* to the end with a minor bump.234*/235typedef struct AVFrameSideData {236enum AVFrameSideDataType type;237uint8_t *data;238size_t size;239AVDictionary *metadata;240AVBufferRef *buf;241} AVFrameSideData;242243/**244* Structure describing a single Region Of Interest.245*246* When multiple regions are defined in a single side-data block, they247* should be ordered from most to least important - some encoders are only248* capable of supporting a limited number of distinct regions, so will have249* to truncate the list.250*251* When overlapping regions are defined, the first region containing a given252* area of the frame applies.253*/254typedef struct AVRegionOfInterest {255/**256* Must be set to the size of this data structure (that is,257* sizeof(AVRegionOfInterest)).258*/259uint32_t self_size;260/**261* Distance in pixels from the top edge of the frame to the top and262* bottom edges and from the left edge of the frame to the left and263* right edges of the rectangle defining this region of interest.264*265* The constraints on a region are encoder dependent, so the region266* actually affected may be slightly larger for alignment or other267* reasons.268*/269int top;270int bottom;271int left;272int right;273/**274* Quantisation offset.275*276* Must be in the range -1 to +1. A value of zero indicates no quality277* change. A negative value asks for better quality (less quantisation),278* while a positive value asks for worse quality (greater quantisation).279*280* The range is calibrated so that the extreme values indicate the281* largest possible offset - if the rest of the frame is encoded with the282* worst possible quality, an offset of -1 indicates that this region283* should be encoded with the best possible quality anyway. Intermediate284* values are then interpolated in some codec-dependent way.285*286* For example, in 10-bit H.264 the quantisation parameter varies between287* -12 and 51. A typical qoffset value of -1/10 therefore indicates that288* this region should be encoded with a QP around one-tenth of the full289* range better than the rest of the frame. So, if most of the frame290* were to be encoded with a QP of around 30, this region would get a QP291* of around 24 (an offset of approximately -1/10 * (51 - -12) = -6.3).292* An extreme value of -1 would indicate that this region should be293* encoded with the best possible quality regardless of the treatment of294* the rest of the frame - that is, should be encoded at a QP of -12.295*/296AVRational qoffset;297} AVRegionOfInterest;298299/**300* This structure describes decoded (raw) audio or video data.301*302* AVFrame must be allocated using av_frame_alloc(). Note that this only303* allocates the AVFrame itself, the buffers for the data must be managed304* through other means (see below).305* AVFrame must be freed with av_frame_free().306*307* AVFrame is typically allocated once and then reused multiple times to hold308* different data (e.g. a single AVFrame to hold frames received from a309* decoder). In such a case, av_frame_unref() will free any references held by310* the frame and reset it to its original clean state before it311* is reused again.312*313* The data described by an AVFrame is usually reference counted through the314* AVBuffer API. The underlying buffer references are stored in AVFrame.buf /315* AVFrame.extended_buf. An AVFrame is considered to be reference counted if at316* least one reference is set, i.e. if AVFrame.buf[0] != NULL. In such a case,317* every single data plane must be contained in one of the buffers in318* AVFrame.buf or AVFrame.extended_buf.319* There may be a single buffer for all the data, or one separate buffer for320* each plane, or anything in between.321*322* sizeof(AVFrame) is not a part of the public ABI, so new fields may be added323* to the end with a minor bump.324*325* Fields can be accessed through AVOptions, the name string used, matches the326* C structure field name for fields accessible through AVOptions. The AVClass327* for AVFrame can be obtained from avcodec_get_frame_class()328*/329typedef struct AVFrame {330#define AV_NUM_DATA_POINTERS 8331/**332* pointer to the picture/channel planes.333* This might be different from the first allocated byte. For video,334* it could even point to the end of the image data.335*336* All pointers in data and extended_data must point into one of the337* AVBufferRef in buf or extended_buf.338*339* Some decoders access areas outside 0,0 - width,height, please340* see avcodec_align_dimensions2(). Some filters and swscale can read341* up to 16 bytes beyond the planes, if these filters are to be used,342* then 16 extra bytes must be allocated.343*344* NOTE: Pointers not needed by the format MUST be set to NULL.345*346* @attention In case of video, the data[] pointers can point to the347* end of image data in order to reverse line order, when used in348* combination with negative values in the linesize[] array.349*/350uint8_t *data[AV_NUM_DATA_POINTERS];351352/**353* For video, a positive or negative value, which is typically indicating354* the size in bytes of each picture line, but it can also be:355* - the negative byte size of lines for vertical flipping356* (with data[n] pointing to the end of the data357* - a positive or negative multiple of the byte size as for accessing358* even and odd fields of a frame (possibly flipped)359*360* For audio, only linesize[0] may be set. For planar audio, each channel361* plane must be the same size.362*363* For video the linesizes should be multiples of the CPUs alignment364* preference, this is 16 or 32 for modern desktop CPUs.365* Some code requires such alignment other code can be slower without366* correct alignment, for yet other it makes no difference.367*368* @note The linesize may be larger than the size of usable data -- there369* may be extra padding present for performance reasons.370*371* @attention In case of video, line size values can be negative to achieve372* a vertically inverted iteration over image lines.373*/374int linesize[AV_NUM_DATA_POINTERS];375376/**377* pointers to the data planes/channels.378*379* For video, this should simply point to data[].380*381* For planar audio, each channel has a separate data pointer, and382* linesize[0] contains the size of each channel buffer.383* For packed audio, there is just one data pointer, and linesize[0]384* contains the total size of the buffer for all channels.385*386* Note: Both data and extended_data should always be set in a valid frame,387* but for planar audio with more channels that can fit in data,388* extended_data must be used in order to access all channels.389*/390uint8_t **extended_data;391392/**393* @name Video dimensions394* Video frames only. The coded dimensions (in pixels) of the video frame,395* i.e. the size of the rectangle that contains some well-defined values.396*397* @note The part of the frame intended for display/presentation is further398* restricted by the @ref cropping "Cropping rectangle".399* @{400*/401int width, height;402/**403* @}404*/405406/**407* number of audio samples (per channel) described by this frame408*/409int nb_samples;410411/**412* format of the frame, -1 if unknown or unset413* Values correspond to enum AVPixelFormat for video frames,414* enum AVSampleFormat for audio)415*/416int format;417418/**419* 1 -> keyframe, 0-> not420*/421int key_frame;422423/**424* Picture type of the frame.425*/426enum AVPictureType pict_type;427428/**429* Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.430*/431AVRational sample_aspect_ratio;432433/**434* Presentation timestamp in time_base units (time when frame should be shown to user).435*/436int64_t pts;437438/**439* DTS copied from the AVPacket that triggered returning this frame. (if frame threading isn't used)440* This is also the Presentation time of this AVFrame calculated from441* only AVPacket.dts values without pts values.442*/443int64_t pkt_dts;444445/**446* Time base for the timestamps in this frame.447* In the future, this field may be set on frames output by decoders or448* filters, but its value will be by default ignored on input to encoders449* or filters.450*/451AVRational time_base;452453#if FF_API_FRAME_PICTURE_NUMBER454/**455* picture number in bitstream order456*/457attribute_deprecated458int coded_picture_number;459/**460* picture number in display order461*/462attribute_deprecated463int display_picture_number;464#endif465466/**467* quality (between 1 (good) and FF_LAMBDA_MAX (bad))468*/469int quality;470471/**472* for some private data of the user473*/474void *opaque;475476/**477* When decoding, this signals how much the picture must be delayed.478* extra_delay = repeat_pict / (2*fps)479*/480int repeat_pict;481482/**483* The content of the picture is interlaced.484*/485int interlaced_frame;486487/**488* If the content is interlaced, is top field displayed first.489*/490int top_field_first;491492/**493* Tell user application that palette has changed from previous frame.494*/495int palette_has_changed;496497#if FF_API_REORDERED_OPAQUE498/**499* reordered opaque 64 bits (generally an integer or a double precision float500* PTS but can be anything).501* The user sets AVCodecContext.reordered_opaque to represent the input at502* that time,503* the decoder reorders values as needed and sets AVFrame.reordered_opaque504* to exactly one of the values provided by the user through AVCodecContext.reordered_opaque505*506* @deprecated Use AV_CODEC_FLAG_COPY_OPAQUE instead507*/508attribute_deprecated509int64_t reordered_opaque;510#endif511512/**513* Sample rate of the audio data.514*/515int sample_rate;516517#if FF_API_OLD_CHANNEL_LAYOUT518/**519* Channel layout of the audio data.520* @deprecated use ch_layout instead521*/522attribute_deprecated523uint64_t channel_layout;524#endif525526/**527* AVBuffer references backing the data for this frame. All the pointers in528* data and extended_data must point inside one of the buffers in buf or529* extended_buf. This array must be filled contiguously -- if buf[i] is530* non-NULL then buf[j] must also be non-NULL for all j < i.531*532* There may be at most one AVBuffer per data plane, so for video this array533* always contains all the references. For planar audio with more than534* AV_NUM_DATA_POINTERS channels, there may be more buffers than can fit in535* this array. Then the extra AVBufferRef pointers are stored in the536* extended_buf array.537*/538AVBufferRef *buf[AV_NUM_DATA_POINTERS];539540/**541* For planar audio which requires more than AV_NUM_DATA_POINTERS542* AVBufferRef pointers, this array will hold all the references which543* cannot fit into AVFrame.buf.544*545* Note that this is different from AVFrame.extended_data, which always546* contains all the pointers. This array only contains the extra pointers,547* which cannot fit into AVFrame.buf.548*549* This array is always allocated using av_malloc() by whoever constructs550* the frame. It is freed in av_frame_unref().551*/552AVBufferRef **extended_buf;553/**554* Number of elements in extended_buf.555*/556int nb_extended_buf;557558AVFrameSideData **side_data;559int nb_side_data;560561/**562* @defgroup lavu_frame_flags AV_FRAME_FLAGS563* @ingroup lavu_frame564* Flags describing additional frame properties.565*566* @{567*/568569/**570* The frame data may be corrupted, e.g. due to decoding errors.571*/572#define AV_FRAME_FLAG_CORRUPT (1 << 0)573/**574* A flag to mark the frames which need to be decoded, but shouldn't be output.575*/576#define AV_FRAME_FLAG_DISCARD (1 << 2)577/**578* @}579*/580581/**582* Frame flags, a combination of @ref lavu_frame_flags583*/584int flags;585586/**587* MPEG vs JPEG YUV range.588* - encoding: Set by user589* - decoding: Set by libavcodec590*/591enum AVColorRange color_range;592593enum AVColorPrimaries color_primaries;594595enum AVColorTransferCharacteristic color_trc;596597/**598* YUV colorspace type.599* - encoding: Set by user600* - decoding: Set by libavcodec601*/602enum AVColorSpace colorspace;603604enum AVChromaLocation chroma_location;605606/**607* frame timestamp estimated using various heuristics, in stream time base608* - encoding: unused609* - decoding: set by libavcodec, read by user.610*/611int64_t best_effort_timestamp;612613/**614* reordered pos from the last AVPacket that has been input into the decoder615* - encoding: unused616* - decoding: Read by user.617*/618int64_t pkt_pos;619620#if FF_API_PKT_DURATION621/**622* duration of the corresponding packet, expressed in623* AVStream->time_base units, 0 if unknown.624* - encoding: unused625* - decoding: Read by user.626*627* @deprecated use duration instead628*/629attribute_deprecated630int64_t pkt_duration;631#endif632633/**634* metadata.635* - encoding: Set by user.636* - decoding: Set by libavcodec.637*/638AVDictionary *metadata;639640/**641* decode error flags of the frame, set to a combination of642* FF_DECODE_ERROR_xxx flags if the decoder produced a frame, but there643* were errors during the decoding.644* - encoding: unused645* - decoding: set by libavcodec, read by user.646*/647int decode_error_flags;648#define FF_DECODE_ERROR_INVALID_BITSTREAM 1649#define FF_DECODE_ERROR_MISSING_REFERENCE 2650#define FF_DECODE_ERROR_CONCEALMENT_ACTIVE 4651#define FF_DECODE_ERROR_DECODE_SLICES 8652653#if FF_API_OLD_CHANNEL_LAYOUT654/**655* number of audio channels, only used for audio.656* - encoding: unused657* - decoding: Read by user.658* @deprecated use ch_layout instead659*/660attribute_deprecated661int channels;662#endif663664/**665* size of the corresponding packet containing the compressed666* frame.667* It is set to a negative value if unknown.668* - encoding: unused669* - decoding: set by libavcodec, read by user.670*/671int pkt_size;672673/**674* For hwaccel-format frames, this should be a reference to the675* AVHWFramesContext describing the frame.676*/677AVBufferRef *hw_frames_ctx;678679/**680* AVBufferRef for free use by the API user. FFmpeg will never check the681* contents of the buffer ref. FFmpeg calls av_buffer_unref() on it when682* the frame is unreferenced. av_frame_copy_props() calls create a new683* reference with av_buffer_ref() for the target frame's opaque_ref field.684*685* This is unrelated to the opaque field, although it serves a similar686* purpose.687*/688AVBufferRef *opaque_ref;689690/**691* @anchor cropping692* @name Cropping693* Video frames only. The number of pixels to discard from the the694* top/bottom/left/right border of the frame to obtain the sub-rectangle of695* the frame intended for presentation.696* @{697*/698size_t crop_top;699size_t crop_bottom;700size_t crop_left;701size_t crop_right;702/**703* @}704*/705706/**707* AVBufferRef for internal use by a single libav* library.708* Must not be used to transfer data between libraries.709* Has to be NULL when ownership of the frame leaves the respective library.710*711* Code outside the FFmpeg libs should never check or change the contents of the buffer ref.712*713* FFmpeg calls av_buffer_unref() on it when the frame is unreferenced.714* av_frame_copy_props() calls create a new reference with av_buffer_ref()715* for the target frame's private_ref field.716*/717AVBufferRef *private_ref;718719/**720* Channel layout of the audio data.721*/722AVChannelLayout ch_layout;723724/**725* Duration of the frame, in the same units as pts. 0 if unknown.726*/727int64_t duration;728} AVFrame;729730731/**732* Allocate an AVFrame and set its fields to default values. The resulting733* struct must be freed using av_frame_free().734*735* @return An AVFrame filled with default values or NULL on failure.736*737* @note this only allocates the AVFrame itself, not the data buffers. Those738* must be allocated through other means, e.g. with av_frame_get_buffer() or739* manually.740*/741AVFrame *av_frame_alloc(void);742743/**744* Free the frame and any dynamically allocated objects in it,745* e.g. extended_data. If the frame is reference counted, it will be746* unreferenced first.747*748* @param frame frame to be freed. The pointer will be set to NULL.749*/750void av_frame_free(AVFrame **frame);751752/**753* Set up a new reference to the data described by the source frame.754*755* Copy frame properties from src to dst and create a new reference for each756* AVBufferRef from src.757*758* If src is not reference counted, new buffers are allocated and the data is759* copied.760*761* @warning: dst MUST have been either unreferenced with av_frame_unref(dst),762* or newly allocated with av_frame_alloc() before calling this763* function, or undefined behavior will occur.764*765* @return 0 on success, a negative AVERROR on error766*/767int av_frame_ref(AVFrame *dst, const AVFrame *src);768769/**770* Create a new frame that references the same data as src.771*772* This is a shortcut for av_frame_alloc()+av_frame_ref().773*774* @return newly created AVFrame on success, NULL on error.775*/776AVFrame *av_frame_clone(const AVFrame *src);777778/**779* Unreference all the buffers referenced by frame and reset the frame fields.780*/781void av_frame_unref(AVFrame *frame);782783/**784* Move everything contained in src to dst and reset src.785*786* @warning: dst is not unreferenced, but directly overwritten without reading787* or deallocating its contents. Call av_frame_unref(dst) manually788* before calling this function to ensure that no memory is leaked.789*/790void av_frame_move_ref(AVFrame *dst, AVFrame *src);791792/**793* Allocate new buffer(s) for audio or video data.794*795* The following fields must be set on frame before calling this function:796* - format (pixel format for video, sample format for audio)797* - width and height for video798* - nb_samples and ch_layout for audio799*800* This function will fill AVFrame.data and AVFrame.buf arrays and, if801* necessary, allocate and fill AVFrame.extended_data and AVFrame.extended_buf.802* For planar formats, one buffer will be allocated for each plane.803*804* @warning: if frame already has been allocated, calling this function will805* leak memory. In addition, undefined behavior can occur in certain806* cases.807*808* @param frame frame in which to store the new buffers.809* @param align Required buffer size alignment. If equal to 0, alignment will be810* chosen automatically for the current CPU. It is highly811* recommended to pass 0 here unless you know what you are doing.812*813* @return 0 on success, a negative AVERROR on error.814*/815int av_frame_get_buffer(AVFrame *frame, int align);816817/**818* Check if the frame data is writable.819*820* @return A positive value if the frame data is writable (which is true if and821* only if each of the underlying buffers has only one reference, namely the one822* stored in this frame). Return 0 otherwise.823*824* If 1 is returned the answer is valid until av_buffer_ref() is called on any825* of the underlying AVBufferRefs (e.g. through av_frame_ref() or directly).826*827* @see av_frame_make_writable(), av_buffer_is_writable()828*/829int av_frame_is_writable(AVFrame *frame);830831/**832* Ensure that the frame data is writable, avoiding data copy if possible.833*834* Do nothing if the frame is writable, allocate new buffers and copy the data835* if it is not. Non-refcounted frames behave as non-writable, i.e. a copy836* is always made.837*838* @return 0 on success, a negative AVERROR on error.839*840* @see av_frame_is_writable(), av_buffer_is_writable(),841* av_buffer_make_writable()842*/843int av_frame_make_writable(AVFrame *frame);844845/**846* Copy the frame data from src to dst.847*848* This function does not allocate anything, dst must be already initialized and849* allocated with the same parameters as src.850*851* This function only copies the frame data (i.e. the contents of the data /852* extended data arrays), not any other properties.853*854* @return >= 0 on success, a negative AVERROR on error.855*/856int av_frame_copy(AVFrame *dst, const AVFrame *src);857858/**859* Copy only "metadata" fields from src to dst.860*861* Metadata for the purpose of this function are those fields that do not affect862* the data layout in the buffers. E.g. pts, sample rate (for audio) or sample863* aspect ratio (for video), but not width/height or channel layout.864* Side data is also copied.865*/866int av_frame_copy_props(AVFrame *dst, const AVFrame *src);867868/**869* Get the buffer reference a given data plane is stored in.870*871* @param frame the frame to get the plane's buffer from872* @param plane index of the data plane of interest in frame->extended_data.873*874* @return the buffer reference that contains the plane or NULL if the input875* frame is not valid.876*/877AVBufferRef *av_frame_get_plane_buffer(AVFrame *frame, int plane);878879/**880* Add a new side data to a frame.881*882* @param frame a frame to which the side data should be added883* @param type type of the added side data884* @param size size of the side data885*886* @return newly added side data on success, NULL on error887*/888AVFrameSideData *av_frame_new_side_data(AVFrame *frame,889enum AVFrameSideDataType type,890size_t size);891892/**893* Add a new side data to a frame from an existing AVBufferRef894*895* @param frame a frame to which the side data should be added896* @param type the type of the added side data897* @param buf an AVBufferRef to add as side data. The ownership of898* the reference is transferred to the frame.899*900* @return newly added side data on success, NULL on error. On failure901* the frame is unchanged and the AVBufferRef remains owned by902* the caller.903*/904AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame *frame,905enum AVFrameSideDataType type,906AVBufferRef *buf);907908/**909* @return a pointer to the side data of a given type on success, NULL if there910* is no side data with such type in this frame.911*/912AVFrameSideData *av_frame_get_side_data(const AVFrame *frame,913enum AVFrameSideDataType type);914915/**916* Remove and free all side data instances of the given type.917*/918void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type);919920921/**922* Flags for frame cropping.923*/924enum {925/**926* Apply the maximum possible cropping, even if it requires setting the927* AVFrame.data[] entries to unaligned pointers. Passing unaligned data928* to FFmpeg API is generally not allowed, and causes undefined behavior929* (such as crashes). You can pass unaligned data only to FFmpeg APIs that930* are explicitly documented to accept it. Use this flag only if you931* absolutely know what you are doing.932*/933AV_FRAME_CROP_UNALIGNED = 1 << 0,934};935936/**937* Crop the given video AVFrame according to its crop_left/crop_top/crop_right/938* crop_bottom fields. If cropping is successful, the function will adjust the939* data pointers and the width/height fields, and set the crop fields to 0.940*941* In all cases, the cropping boundaries will be rounded to the inherent942* alignment of the pixel format. In some cases, such as for opaque hwaccel943* formats, the left/top cropping is ignored. The crop fields are set to 0 even944* if the cropping was rounded or ignored.945*946* @param frame the frame which should be cropped947* @param flags Some combination of AV_FRAME_CROP_* flags, or 0.948*949* @return >= 0 on success, a negative AVERROR on error. If the cropping fields950* were invalid, AVERROR(ERANGE) is returned, and nothing is changed.951*/952int av_frame_apply_cropping(AVFrame *frame, int flags);953954/**955* @return a string identifying the side data type956*/957const char *av_frame_side_data_name(enum AVFrameSideDataType type);958959/**960* @}961*/962963#endif /* AVUTIL_FRAME_H */964965966