Path: blob/a-new-beginning/libswscale.xcframework/ios-arm64/libswscale.framework/Headers/swscale.h
2 views
/*1* Copyright (C) 2001-2011 Michael Niedermayer <[email protected]>2*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 SWSCALE_SWSCALE_H21#define SWSCALE_SWSCALE_H2223/**24* @file25* @ingroup libsws26* external API header27*/2829#include <stdint.h>3031#include "libavutil/avutil.h"32#include "libavutil/frame.h"33#include "libavutil/log.h"34#include "libavutil/pixfmt.h"35#include "version_major.h"36#ifndef HAVE_AV_CONFIG_H37/* When included as part of the ffmpeg build, only include the major version38* to avoid unnecessary rebuilds. When included externally, keep including39* the full version information. */40#include "version.h"41#endif4243/**44* @defgroup libsws libswscale45* Color conversion and scaling library.46*47* @{48*49* Return the LIBSWSCALE_VERSION_INT constant.50*/51unsigned swscale_version(void);5253/**54* Return the libswscale build-time configuration.55*/56const char *swscale_configuration(void);5758/**59* Return the libswscale license.60*/61const char *swscale_license(void);6263/* values for the flags, the stuff on the command line is different */64#define SWS_FAST_BILINEAR 165#define SWS_BILINEAR 266#define SWS_BICUBIC 467#define SWS_X 868#define SWS_POINT 0x1069#define SWS_AREA 0x2070#define SWS_BICUBLIN 0x4071#define SWS_GAUSS 0x8072#define SWS_SINC 0x10073#define SWS_LANCZOS 0x20074#define SWS_SPLINE 0x4007576#define SWS_SRC_V_CHR_DROP_MASK 0x3000077#define SWS_SRC_V_CHR_DROP_SHIFT 167879#define SWS_PARAM_DEFAULT 1234568081#define SWS_PRINT_INFO 0x10008283//the following 3 flags are not completely implemented84//internal chrominance subsampling info85#define SWS_FULL_CHR_H_INT 0x200086//input subsampling info87#define SWS_FULL_CHR_H_INP 0x400088#define SWS_DIRECT_BGR 0x800089#define SWS_ACCURATE_RND 0x4000090#define SWS_BITEXACT 0x8000091#define SWS_ERROR_DIFFUSION 0x8000009293#define SWS_MAX_REDUCE_CUTOFF 0.0029495#define SWS_CS_ITU709 196#define SWS_CS_FCC 497#define SWS_CS_ITU601 598#define SWS_CS_ITU624 599#define SWS_CS_SMPTE170M 5100#define SWS_CS_SMPTE240M 7101#define SWS_CS_DEFAULT 5102#define SWS_CS_BT2020 9103104/**105* Return a pointer to yuv<->rgb coefficients for the given colorspace106* suitable for sws_setColorspaceDetails().107*108* @param colorspace One of the SWS_CS_* macros. If invalid,109* SWS_CS_DEFAULT is used.110*/111const int *sws_getCoefficients(int colorspace);112113// when used for filters they must have an odd number of elements114// coeffs cannot be shared between vectors115typedef struct SwsVector {116double *coeff; ///< pointer to the list of coefficients117int length; ///< number of coefficients in the vector118} SwsVector;119120// vectors can be shared121typedef struct SwsFilter {122SwsVector *lumH;123SwsVector *lumV;124SwsVector *chrH;125SwsVector *chrV;126} SwsFilter;127128struct SwsContext;129130/**131* Return a positive value if pix_fmt is a supported input format, 0132* otherwise.133*/134int sws_isSupportedInput(enum AVPixelFormat pix_fmt);135136/**137* Return a positive value if pix_fmt is a supported output format, 0138* otherwise.139*/140int sws_isSupportedOutput(enum AVPixelFormat pix_fmt);141142/**143* @param[in] pix_fmt the pixel format144* @return a positive value if an endianness conversion for pix_fmt is145* supported, 0 otherwise.146*/147int sws_isSupportedEndiannessConversion(enum AVPixelFormat pix_fmt);148149/**150* Allocate an empty SwsContext. This must be filled and passed to151* sws_init_context(). For filling see AVOptions, options.c and152* sws_setColorspaceDetails().153*/154struct SwsContext *sws_alloc_context(void);155156/**157* Initialize the swscaler context sws_context.158*159* @return zero or positive value on success, a negative value on160* error161*/162av_warn_unused_result163int sws_init_context(struct SwsContext *sws_context, SwsFilter *srcFilter, SwsFilter *dstFilter);164165/**166* Free the swscaler context swsContext.167* If swsContext is NULL, then does nothing.168*/169void sws_freeContext(struct SwsContext *swsContext);170171/**172* Allocate and return an SwsContext. You need it to perform173* scaling/conversion operations using sws_scale().174*175* @param srcW the width of the source image176* @param srcH the height of the source image177* @param srcFormat the source image format178* @param dstW the width of the destination image179* @param dstH the height of the destination image180* @param dstFormat the destination image format181* @param flags specify which algorithm and options to use for rescaling182* @param param extra parameters to tune the used scaler183* For SWS_BICUBIC param[0] and [1] tune the shape of the basis184* function, param[0] tunes f(1) and param[1] f´(1)185* For SWS_GAUSS param[0] tunes the exponent and thus cutoff186* frequency187* For SWS_LANCZOS param[0] tunes the width of the window function188* @return a pointer to an allocated context, or NULL in case of error189* @note this function is to be removed after a saner alternative is190* written191*/192struct SwsContext *sws_getContext(int srcW, int srcH, enum AVPixelFormat srcFormat,193int dstW, int dstH, enum AVPixelFormat dstFormat,194int flags, SwsFilter *srcFilter,195SwsFilter *dstFilter, const double *param);196197/**198* Scale the image slice in srcSlice and put the resulting scaled199* slice in the image in dst. A slice is a sequence of consecutive200* rows in an image.201*202* Slices have to be provided in sequential order, either in203* top-bottom or bottom-top order. If slices are provided in204* non-sequential order the behavior of the function is undefined.205*206* @param c the scaling context previously created with207* sws_getContext()208* @param srcSlice the array containing the pointers to the planes of209* the source slice210* @param srcStride the array containing the strides for each plane of211* the source image212* @param srcSliceY the position in the source image of the slice to213* process, that is the number (counted starting from214* zero) in the image of the first row of the slice215* @param srcSliceH the height of the source slice, that is the number216* of rows in the slice217* @param dst the array containing the pointers to the planes of218* the destination image219* @param dstStride the array containing the strides for each plane of220* the destination image221* @return the height of the output slice222*/223int sws_scale(struct SwsContext *c, const uint8_t *const srcSlice[],224const int srcStride[], int srcSliceY, int srcSliceH,225uint8_t *const dst[], const int dstStride[]);226227/**228* Scale source data from src and write the output to dst.229*230* This is merely a convenience wrapper around231* - sws_frame_start()232* - sws_send_slice(0, src->height)233* - sws_receive_slice(0, dst->height)234* - sws_frame_end()235*236* @param c The scaling context237* @param dst The destination frame. See documentation for sws_frame_start() for238* more details.239* @param src The source frame.240*241* @return 0 on success, a negative AVERROR code on failure242*/243int sws_scale_frame(struct SwsContext *c, AVFrame *dst, const AVFrame *src);244245/**246* Initialize the scaling process for a given pair of source/destination frames.247* Must be called before any calls to sws_send_slice() and sws_receive_slice().248*249* This function will retain references to src and dst, so they must both use250* refcounted buffers (if allocated by the caller, in case of dst).251*252* @param c The scaling context253* @param dst The destination frame.254*255* The data buffers may either be already allocated by the caller or256* left clear, in which case they will be allocated by the scaler.257* The latter may have performance advantages - e.g. in certain cases258* some output planes may be references to input planes, rather than259* copies.260*261* Output data will be written into this frame in successful262* sws_receive_slice() calls.263* @param src The source frame. The data buffers must be allocated, but the264* frame data does not have to be ready at this point. Data265* availability is then signalled by sws_send_slice().266* @return 0 on success, a negative AVERROR code on failure267*268* @see sws_frame_end()269*/270int sws_frame_start(struct SwsContext *c, AVFrame *dst, const AVFrame *src);271272/**273* Finish the scaling process for a pair of source/destination frames previously274* submitted with sws_frame_start(). Must be called after all sws_send_slice()275* and sws_receive_slice() calls are done, before any new sws_frame_start()276* calls.277*278* @param c The scaling context279*/280void sws_frame_end(struct SwsContext *c);281282/**283* Indicate that a horizontal slice of input data is available in the source284* frame previously provided to sws_frame_start(). The slices may be provided in285* any order, but may not overlap. For vertically subsampled pixel formats, the286* slices must be aligned according to subsampling.287*288* @param c The scaling context289* @param slice_start first row of the slice290* @param slice_height number of rows in the slice291*292* @return a non-negative number on success, a negative AVERROR code on failure.293*/294int sws_send_slice(struct SwsContext *c, unsigned int slice_start,295unsigned int slice_height);296297/**298* Request a horizontal slice of the output data to be written into the frame299* previously provided to sws_frame_start().300*301* @param c The scaling context302* @param slice_start first row of the slice; must be a multiple of303* sws_receive_slice_alignment()304* @param slice_height number of rows in the slice; must be a multiple of305* sws_receive_slice_alignment(), except for the last slice306* (i.e. when slice_start+slice_height is equal to output307* frame height)308*309* @return a non-negative number if the data was successfully written into the output310* AVERROR(EAGAIN) if more input data needs to be provided before the311* output can be produced312* another negative AVERROR code on other kinds of scaling failure313*/314int sws_receive_slice(struct SwsContext *c, unsigned int slice_start,315unsigned int slice_height);316317/**318* Get the alignment required for slices319*320* @param c The scaling context321* @return alignment required for output slices requested with sws_receive_slice().322* Slice offsets and sizes passed to sws_receive_slice() must be323* multiples of the value returned from this function.324*/325unsigned int sws_receive_slice_alignment(const struct SwsContext *c);326327/**328* @param c the scaling context329* @param dstRange flag indicating the while-black range of the output (1=jpeg / 0=mpeg)330* @param srcRange flag indicating the while-black range of the input (1=jpeg / 0=mpeg)331* @param table the yuv2rgb coefficients describing the output yuv space, normally ff_yuv2rgb_coeffs[x]332* @param inv_table the yuv2rgb coefficients describing the input yuv space, normally ff_yuv2rgb_coeffs[x]333* @param brightness 16.16 fixed point brightness correction334* @param contrast 16.16 fixed point contrast correction335* @param saturation 16.16 fixed point saturation correction336*337* @return A negative error code on error, non negative otherwise.338* If `LIBSWSCALE_VERSION_MAJOR < 7`, returns -1 if not supported.339*/340int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4],341int srcRange, const int table[4], int dstRange,342int brightness, int contrast, int saturation);343344/**345* @return A negative error code on error, non negative otherwise.346* If `LIBSWSCALE_VERSION_MAJOR < 7`, returns -1 if not supported.347*/348int sws_getColorspaceDetails(struct SwsContext *c, int **inv_table,349int *srcRange, int **table, int *dstRange,350int *brightness, int *contrast, int *saturation);351352/**353* Allocate and return an uninitialized vector with length coefficients.354*/355SwsVector *sws_allocVec(int length);356357/**358* Return a normalized Gaussian curve used to filter stuff359* quality = 3 is high quality, lower is lower quality.360*/361SwsVector *sws_getGaussianVec(double variance, double quality);362363/**364* Scale all the coefficients of a by the scalar value.365*/366void sws_scaleVec(SwsVector *a, double scalar);367368/**369* Scale all the coefficients of a so that their sum equals height.370*/371void sws_normalizeVec(SwsVector *a, double height);372373void sws_freeVec(SwsVector *a);374375SwsFilter *sws_getDefaultFilter(float lumaGBlur, float chromaGBlur,376float lumaSharpen, float chromaSharpen,377float chromaHShift, float chromaVShift,378int verbose);379void sws_freeFilter(SwsFilter *filter);380381/**382* Check if context can be reused, otherwise reallocate a new one.383*384* If context is NULL, just calls sws_getContext() to get a new385* context. Otherwise, checks if the parameters are the ones already386* saved in context. If that is the case, returns the current387* context. Otherwise, frees context and gets a new context with388* the new parameters.389*390* Be warned that srcFilter and dstFilter are not checked, they391* are assumed to remain the same.392*/393struct SwsContext *sws_getCachedContext(struct SwsContext *context,394int srcW, int srcH, enum AVPixelFormat srcFormat,395int dstW, int dstH, enum AVPixelFormat dstFormat,396int flags, SwsFilter *srcFilter,397SwsFilter *dstFilter, const double *param);398399/**400* Convert an 8-bit paletted frame into a frame with a color depth of 32 bits.401*402* The output frame will have the same packed format as the palette.403*404* @param src source frame buffer405* @param dst destination frame buffer406* @param num_pixels number of pixels to convert407* @param palette array with [256] entries, which must match color arrangement (RGB or BGR) of src408*/409void sws_convertPalette8ToPacked32(const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette);410411/**412* Convert an 8-bit paletted frame into a frame with a color depth of 24 bits.413*414* With the palette format "ABCD", the destination frame ends up with the format "ABC".415*416* @param src source frame buffer417* @param dst destination frame buffer418* @param num_pixels number of pixels to convert419* @param palette array with [256] entries, which must match color arrangement (RGB or BGR) of src420*/421void sws_convertPalette8ToPacked24(const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette);422423/**424* Get the AVClass for swsContext. It can be used in combination with425* AV_OPT_SEARCH_FAKE_OBJ for examining options.426*427* @see av_opt_find().428*/429const AVClass *sws_get_class(void);430431/**432* @}433*/434435#endif /* SWSCALE_SWSCALE_H */436437438