Go to the documentation of this file.
22 #ifndef SWSCALE_SWSCALE_H
23 #define SWSCALE_SWSCALE_H
38 #ifndef HAVE_AV_CONFIG_H
349 #define SWS_SRC_V_CHR_DROP_MASK 0x30000
350 #define SWS_SRC_V_CHR_DROP_SHIFT 16
352 #define SWS_PARAM_DEFAULT 123456
354 #define SWS_MAX_REDUCE_CUTOFF 0.002
356 #define SWS_CS_ITU709 1
358 #define SWS_CS_ITU601 5
359 #define SWS_CS_ITU624 5
360 #define SWS_CS_SMPTE170M 5
361 #define SWS_CS_SMPTE240M 7
362 #define SWS_CS_DEFAULT 5
363 #define SWS_CS_BT2020 9
452 SwsFilter *dstFilter,
const double *param);
482 const int srcStride[],
int srcSliceY,
int srcSliceH,
483 uint8_t *
const dst[],
const int dstStride[]);
537 unsigned int slice_height);
557 unsigned int slice_height);
584 int srcRange,
const int table[4],
int dstRange,
585 int brightness,
int contrast,
int saturation);
592 int *srcRange,
int **
table,
int *dstRange,
593 int *brightness,
int *contrast,
int *saturation);
619 float lumaSharpen,
float chromaSharpen,
620 float chromaHShift,
float chromaVShift,
640 const double *param);
int sws_setColorspaceDetails(SwsContext *c, const int inv_table[4], int srcRange, const int table[4], int dstRange, int brightness, int contrast, int saturation)
AVPixelFormat
Pixel format.
AVColorTransferCharacteristic
Color Transfer Characteristic.
int src_w
Deprecated frame property overrides, for the legacy API only.
@ SWS_ALPHA_BLEND_CHECKERBOARD
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce output
void sws_freeContext(SwsContext *swsContext)
Free the swscaler context swsContext.
This structure describes decoded (raw) audio or video data.
@ SWS_BILINEAR
bilinear filtering
int sws_test_primaries(enum AVColorPrimaries primaries, int output)
Test if a given set of color primaries is supported.
static const uint16_t table[]
unsigned flags
Bitmask of SWS_*.
void(* filter)(uint8_t *src, int stride, int qscale)
int sws_receive_slice(SwsContext *c, unsigned int slice_start, unsigned int slice_height)
Request a horizontal slice of the output data to be written into the frame previously provided to sws...
AVColorPrimaries
Chromaticity coordinates of the source primaries.
void sws_convertPalette8ToPacked24(const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette)
Convert an 8-bit paletted frame into a frame with a color depth of 24 bits.
@ SWS_BICUBLIN
bicubic luma, bilinear chroma
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about quality
void sws_freeVec(SwsVector *a)
@ SWS_FAST_BILINEAR
Scaler selection options.
@ SWS_FULL_CHR_H_INP
Perform full chroma interpolation when downscaling RGB sources.
int src_v_chr_pos
Source vertical chroma position in luma grid / 256.
SwsContext * sws_getCachedContext(SwsContext *context, int srcW, int srcH, enum AVPixelFormat srcFormat, int dstW, int dstH, enum AVPixelFormat dstFormat, int flags, SwsFilter *srcFilter, SwsFilter *dstFilter, const double *param)
Check if context can be reused, otherwise reallocate a new one.
const char * swscale_license(void)
Return the libswscale license.
av_warn_unused_result int sws_init_context(SwsContext *sws_context, SwsFilter *srcFilter, SwsFilter *dstFilter)
Initialize the swscaler context sws_context.
int sws_frame_setup(SwsContext *ctx, const AVFrame *dst, const AVFrame *src)
Like sws_scale_frame, but without actually scaling.
const AVClass * sws_get_class(void)
Get the AVClass for SwsContext.
SwsDither dither
Dither mode.
int threads
How many threads to use for processing, or 0 for automatic selection.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample format(the sample packing is implied by the sample format) and sample rate. The lists are not just lists
static enum AVPixelFormat pix_fmt
int length
number of coefficients in the vector
SwsVector * sws_allocVec(int length)
Allocate and return an uninitialized vector with length coefficients.
int sws_test_colorspace(enum AVColorSpace colorspace, int output)
Test if a given color space is supported.
SwsVector * sws_getGaussianVec(double variance, double quality)
Return a normalized Gaussian curve used to filter stuff quality = 3 is high quality,...
void sws_frame_end(SwsContext *c)
Finish the scaling process for a pair of source/destination frames previously submitted with sws_fram...
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option keep it simple and lowercase description are in without and describe what they for example set the foo of the bar offset is the offset of the field in your context
Describe the class of an AVClass context structure.
@ SWS_DIRECT_BGR
Deprecated flags.
@ SWS_BICUBIC
2-tap cubic B-spline
int gamma_flag
Use gamma correct scaling.
int sws_is_noop(const AVFrame *dst, const AVFrame *src)
Check if a given conversion is a noop.
SwsFilter * sws_getDefaultFilter(float lumaGBlur, float chromaGBlur, float lumaSharpen, float chromaSharpen, float chromaHShift, float chromaVShift, int verbose)
int sws_test_format(enum AVPixelFormat format, int output)
Test if a given pixel format is supported.
int src_range
Source is full range.
double * coeff
pointer to the list of coefficients
int dst_h_chr_pos
Destination horizontal chroma position.
void sws_scaleVec(SwsVector *a, double scalar)
Scale all the coefficients of a by the scalar value.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
SwsContext * sws_alloc_context(void)
Allocate an empty SwsContext and set its fields to default values.
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
void * opaque
Private data of the user, can be used to carry app specific stuff.
@ SWS_POINT
nearest neighbor
@ SWS_ALPHA_BLEND_UNIFORM
SwsAlphaBlend alpha_blend
Alpha blending mode.
@ SWS_SPLINE
cubic Keys spline
int src_h
Width and height of the source frame.
int sws_getColorspaceDetails(SwsContext *c, int **inv_table, int *srcRange, int **table, int *dstRange, int *brightness, int *contrast, int *saturation)
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
int sws_test_transfer(enum AVColorTransferCharacteristic trc, int output)
Test if a given color transfer function is supported.
const char * swscale_configuration(void)
Return the libswscale build-time configuration.
int sws_isSupportedInput(enum AVPixelFormat pix_fmt)
Return a positive value if pix_fmt is a supported input format, 0 otherwise.
int dst_format
Destination pixel format.
#define av_warn_unused_result
int sws_isSupportedEndiannessConversion(enum AVPixelFormat pix_fmt)
int sws_send_slice(SwsContext *c, unsigned int slice_start, unsigned int slice_height)
Indicate that a horizontal slice of input data is available in the source frame previously provided t...
AVColorSpace
YUV colorspace type.
int sws_isSupportedOutput(enum AVPixelFormat pix_fmt)
Return a positive value if pix_fmt is a supported output format, 0 otherwise.
int sws_test_frame(const AVFrame *frame, int output)
Helper function to run all sws_test_* against a frame, as well as testing the basic frame properties ...
int dst_h
Width and height of the destination frame.
void sws_freeFilter(SwsFilter *filter)
static int slice_start(SliceContext *sc, VVCContext *s, VVCFrameContext *fc, const CodedBitstreamUnit *unit, const int is_first_slice)
unsigned int sws_receive_slice_alignment(const SwsContext *c)
Get the alignment required for slices.
int sws_frame_start(SwsContext *c, AVFrame *dst, const AVFrame *src)
Initialize the scaling process for a given pair of source/destination frames.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
@ SWS_FULL_CHR_H_INT
Perform full chroma upsampling when upscaling to RGB.
SwsContext * sws_getContext(int srcW, int srcH, enum AVPixelFormat srcFormat, int dstW, int dstH, enum AVPixelFormat dstFormat, int flags, SwsFilter *srcFilter, SwsFilter *dstFilter, const double *param)
Allocate and return an SwsContext.
double scaler_params[2]
Extra parameters for fine-tuning certain scalers.
int sws_scale(SwsContext *c, const uint8_t *const srcSlice[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
Scale the image slice in srcSlice and put the resulting scaled slice in the image in dst.
@ SWS_PRINT_INFO
Emit verbose log of scaling parameters.
@ SWS_ERROR_DIFFUSION
Set SwsContext.dither instead.
@ SWS_GAUSS
gaussian approximation
@ SWS_STRICT
Return an error on underspecified conversions.
const int * sws_getCoefficients(int colorspace)
Return a pointer to yuv<->rgb coefficients for the given colorspace suitable for sws_setColorspaceDet...
int src_format
Source pixel format.
unsigned swscale_version(void)
int dst_range
Destination is full range.
void sws_free_context(SwsContext **ctx)
Free the context and everything associated with it, and write NULL to the provided pointer.
#define flags(name, subs,...)
int src_h_chr_pos
Source horizontal chroma position.
int sws_scale_frame(SwsContext *c, AVFrame *dst, const AVFrame *src)
Scale source data from src and write the output to dst.
@ SWS_ACCURATE_RND
Force bit-exact output.
@ SWS_LANCZOS
3-tap sinc/sinc
void sws_convertPalette8ToPacked32(const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette)
Convert an 8-bit paletted frame into a frame with a color depth of 32 bits.
int dst_v_chr_pos
Destination vertical chroma position.
@ SWS_SINC
unwindowed sinc
Main external API structure.
void sws_normalizeVec(SwsVector *a, double height)
Scale all the coefficients of a so that their sum equals height.