swscale.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2001-2003 Michael Niedermayer <michaelni@gmx.at>
3  *
4  * This file is part of Libav.
5  *
6  * Libav is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * Libav is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with Libav; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #ifndef SWSCALE_SWSCALE_H
22 #define SWSCALE_SWSCALE_H
23 
31 #include <stdint.h>
32 
33 #include "libavutil/avutil.h"
34 #include "libavutil/log.h"
35 #include "libavutil/pixfmt.h"
36 #include "version.h"
37 
44 unsigned swscale_version(void);
45 
49 const char *swscale_configuration(void);
50 
54 const char *swscale_license(void);
55 
56 /* values for the flags, the stuff on the command line is different */
57 #define SWS_FAST_BILINEAR 1
58 #define SWS_BILINEAR 2
59 #define SWS_BICUBIC 4
60 #define SWS_X 8
61 #define SWS_POINT 0x10
62 #define SWS_AREA 0x20
63 #define SWS_BICUBLIN 0x40
64 #define SWS_GAUSS 0x80
65 #define SWS_SINC 0x100
66 #define SWS_LANCZOS 0x200
67 #define SWS_SPLINE 0x400
68 
69 #define SWS_SRC_V_CHR_DROP_MASK 0x30000
70 #define SWS_SRC_V_CHR_DROP_SHIFT 16
71 
72 #define SWS_PARAM_DEFAULT 123456
73 
74 #define SWS_PRINT_INFO 0x1000
75 
76 //the following 3 flags are not completely implemented
77 //internal chrominance subsampling info
78 #define SWS_FULL_CHR_H_INT 0x2000
79 //input subsampling info
80 #define SWS_FULL_CHR_H_INP 0x4000
81 #define SWS_DIRECT_BGR 0x8000
82 #define SWS_ACCURATE_RND 0x40000
83 #define SWS_BITEXACT 0x80000
84 
85 #define SWS_MAX_REDUCE_CUTOFF 0.002
86 
87 #define SWS_CS_ITU709 1
88 #define SWS_CS_FCC 4
89 #define SWS_CS_ITU601 5
90 #define SWS_CS_ITU624 5
91 #define SWS_CS_SMPTE170M 5
92 #define SWS_CS_SMPTE240M 7
93 #define SWS_CS_DEFAULT 5
94 
102 const int *sws_getCoefficients(int colorspace);
103 
104 // when used for filters they must have an odd number of elements
105 // coeffs cannot be shared between vectors
106 typedef struct SwsVector {
107  double *coeff;
108  int length;
109 } SwsVector;
110 
111 // vectors can be shared
112 typedef struct SwsFilter {
117 } SwsFilter;
118 
119 struct SwsContext;
120 
125 int sws_isSupportedInput(enum AVPixelFormat pix_fmt);
126 
131 int sws_isSupportedOutput(enum AVPixelFormat pix_fmt);
132 
139 
145 struct SwsContext *sws_alloc_context(void);
146 
153 int sws_init_context(struct SwsContext *sws_context, SwsFilter *srcFilter, SwsFilter *dstFilter);
154 
159 void sws_freeContext(struct SwsContext *swsContext);
160 
176 struct SwsContext *sws_getContext(int srcW, int srcH, enum AVPixelFormat srcFormat,
177  int dstW, int dstH, enum AVPixelFormat dstFormat,
178  int flags, SwsFilter *srcFilter,
179  SwsFilter *dstFilter, const double *param);
180 
207 int sws_scale(struct SwsContext *c, const uint8_t *const srcSlice[],
208  const int srcStride[], int srcSliceY, int srcSliceH,
209  uint8_t *const dst[], const int dstStride[]);
210 
215 int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4],
216  int srcRange, const int table[4], int dstRange,
217  int brightness, int contrast, int saturation);
218 
222 int sws_getColorspaceDetails(struct SwsContext *c, int **inv_table,
223  int *srcRange, int **table, int *dstRange,
224  int *brightness, int *contrast, int *saturation);
225 
230 
235 SwsVector *sws_getGaussianVec(double variance, double quality);
236 
241 SwsVector *sws_getConstVec(double c, int length);
242 
248 
252 void sws_scaleVec(SwsVector *a, double scalar);
253 
257 void sws_normalizeVec(SwsVector *a, double height);
258 void sws_convVec(SwsVector *a, SwsVector *b);
259 void sws_addVec(SwsVector *a, SwsVector *b);
260 void sws_subVec(SwsVector *a, SwsVector *b);
261 void sws_shiftVec(SwsVector *a, int shift);
262 
268 
273 void sws_printVec2(SwsVector *a, AVClass *log_ctx, int log_level);
274 
275 void sws_freeVec(SwsVector *a);
276 
277 SwsFilter *sws_getDefaultFilter(float lumaGBlur, float chromaGBlur,
278  float lumaSharpen, float chromaSharpen,
279  float chromaHShift, float chromaVShift,
280  int verbose);
281 void sws_freeFilter(SwsFilter *filter);
282 
295 struct SwsContext *sws_getCachedContext(struct SwsContext *context,
296  int srcW, int srcH, enum AVPixelFormat srcFormat,
297  int dstW, int dstH, enum AVPixelFormat dstFormat,
298  int flags, SwsFilter *srcFilter,
299  SwsFilter *dstFilter, const double *param);
300 
311 void sws_convertPalette8ToPacked32(const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette);
312 
323 void sws_convertPalette8ToPacked24(const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette);
324 
331 const AVClass *sws_get_class(void);
332 
337 #endif /* SWSCALE_SWSCALE_H */
SwsVector * chrV
Definition: swscale.h:116
int sws_isSupportedOutput(enum AVPixelFormat pix_fmt)
Return a positive value if pix_fmt is a supported output format, 0 otherwise.
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.
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.
SwsVector * lumV
Definition: swscale.h:114
int sws_getColorspaceDetails(struct SwsContext *c, int **inv_table, int *srcRange, int **table, int *dstRange, int *brightness, int *contrast, int *saturation)
SwsVector * sws_getGaussianVec(double variance, double quality)
Return a normalized Gaussian curve used to filter stuff quality = 3 is high quality, lower is lower quality.
external API header
int sws_isSupportedEndiannessConversion(enum AVPixelFormat pix_fmt)
const char * swscale_configuration(void)
Return the libswscale build-time configuration.
void sws_subVec(SwsVector *a, SwsVector *b)
swscale version macros
const AVClass * sws_get_class(void)
Get the AVClass for swsContext.
int length
number of coefficients in the vector
Definition: swscale.h:108
void sws_addVec(SwsVector *a, SwsVector *b)
struct 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.
int sws_init_context(struct SwsContext *sws_context, SwsFilter *srcFilter, SwsFilter *dstFilter)
Initialize the swscaler context sws_context.
SwsFilter * sws_getDefaultFilter(float lumaGBlur, float chromaGBlur, float lumaSharpen, float chromaSharpen, float chromaHShift, float chromaVShift, int verbose)
void sws_printVec2(SwsVector *a, AVClass *log_ctx, int log_level)
Print with av_log() a textual representation of the vector a if log_level <= av_log_level.
void sws_scaleVec(SwsVector *a, double scalar)
Scale all the coefficients of a by the scalar value.
SwsVector * lumH
Definition: swscale.h:113
void sws_normalizeVec(SwsVector *a, double height)
Scale all the coefficients of a so that their sum equals height.
struct SwsContext * sws_getCachedContext(struct 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.
void sws_freeFilter(SwsFilter *filter)
SwsVector * sws_allocVec(int length)
Allocate and return an uninitialized vector with length coefficients.
SwsVector * chrH
Definition: swscale.h:115
SwsVector * sws_getIdentityVec(void)
Allocate and return a vector with just one coefficient, with value 1.0.
void sws_freeContext(struct SwsContext *swsContext)
Free the swscaler context swsContext.
const int * sws_getCoefficients(int colorspace)
Return a pointer to yuv<->rgb coefficients for the given colorspace suitable for sws_setColorspaceDet...
unsigned swscale_version(void)
int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4], int srcRange, const int table[4], int dstRange, int brightness, int contrast, int saturation)
double * coeff
pointer to the list of coefficients
Definition: swscale.h:107
void sws_freeVec(SwsVector *a)
int sws_scale(struct 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...
void sws_shiftVec(SwsVector *a, int shift)
Describe the class of an AVClass context structure.
Definition: log.h:34
SwsVector * sws_cloneVec(SwsVector *a)
Allocate and return a clone of the vector a, that is a vector with the same coefficients as a...
struct SwsContext * sws_alloc_context(void)
Allocate an empty SwsContext.
void sws_convVec(SwsVector *a, SwsVector *b)
pixel format definitions
int sws_isSupportedInput(enum AVPixelFormat pix_fmt)
Return a positive value if pix_fmt is a supported input format, 0 otherwise.
SwsVector * sws_getConstVec(double c, int length)
Allocate and return a vector with length coefficients, all with the same value c. ...
AVPixelFormat
Pixel format.
Definition: pixfmt.h:57
const char * swscale_license(void)
Return the libswscale license.