annotate ffmpeg/libswscale/swscale.h @ 13:844d341cf643 tip

Back up before ISMIR
author Yading Song <yading.song@eecs.qmul.ac.uk>
date Thu, 31 Oct 2013 13:17:06 +0000
parents f445c3017523
children
rev   line source
yading@11 1 /*
yading@11 2 * Copyright (C) 2001-2011 Michael Niedermayer <michaelni@gmx.at>
yading@11 3 *
yading@11 4 * This file is part of FFmpeg.
yading@11 5 *
yading@11 6 * FFmpeg is free software; you can redistribute it and/or
yading@11 7 * modify it under the terms of the GNU Lesser General Public
yading@11 8 * License as published by the Free Software Foundation; either
yading@11 9 * version 2.1 of the License, or (at your option) any later version.
yading@11 10 *
yading@11 11 * FFmpeg is distributed in the hope that it will be useful,
yading@11 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
yading@11 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
yading@11 14 * Lesser General Public License for more details.
yading@11 15 *
yading@11 16 * You should have received a copy of the GNU Lesser General Public
yading@11 17 * License along with FFmpeg; if not, write to the Free Software
yading@11 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
yading@11 19 */
yading@11 20
yading@11 21 #ifndef SWSCALE_SWSCALE_H
yading@11 22 #define SWSCALE_SWSCALE_H
yading@11 23
yading@11 24 /**
yading@11 25 * @file
yading@11 26 * @ingroup lsws
yading@11 27 * external API header
yading@11 28 */
yading@11 29
yading@11 30 /**
yading@11 31 * @defgroup lsws Libswscale
yading@11 32 * @{
yading@11 33 */
yading@11 34
yading@11 35 #include <stdint.h>
yading@11 36
yading@11 37 #include "libavutil/avutil.h"
yading@11 38 #include "libavutil/log.h"
yading@11 39 #include "libavutil/pixfmt.h"
yading@11 40 #include "version.h"
yading@11 41
yading@11 42 /**
yading@11 43 * Return the LIBSWSCALE_VERSION_INT constant.
yading@11 44 */
yading@11 45 unsigned swscale_version(void);
yading@11 46
yading@11 47 /**
yading@11 48 * Return the libswscale build-time configuration.
yading@11 49 */
yading@11 50 const char *swscale_configuration(void);
yading@11 51
yading@11 52 /**
yading@11 53 * Return the libswscale license.
yading@11 54 */
yading@11 55 const char *swscale_license(void);
yading@11 56
yading@11 57 /* values for the flags, the stuff on the command line is different */
yading@11 58 #define SWS_FAST_BILINEAR 1
yading@11 59 #define SWS_BILINEAR 2
yading@11 60 #define SWS_BICUBIC 4
yading@11 61 #define SWS_X 8
yading@11 62 #define SWS_POINT 0x10
yading@11 63 #define SWS_AREA 0x20
yading@11 64 #define SWS_BICUBLIN 0x40
yading@11 65 #define SWS_GAUSS 0x80
yading@11 66 #define SWS_SINC 0x100
yading@11 67 #define SWS_LANCZOS 0x200
yading@11 68 #define SWS_SPLINE 0x400
yading@11 69
yading@11 70 #define SWS_SRC_V_CHR_DROP_MASK 0x30000
yading@11 71 #define SWS_SRC_V_CHR_DROP_SHIFT 16
yading@11 72
yading@11 73 #define SWS_PARAM_DEFAULT 123456
yading@11 74
yading@11 75 #define SWS_PRINT_INFO 0x1000
yading@11 76
yading@11 77 //the following 3 flags are not completely implemented
yading@11 78 //internal chrominace subsampling info
yading@11 79 #define SWS_FULL_CHR_H_INT 0x2000
yading@11 80 //input subsampling info
yading@11 81 #define SWS_FULL_CHR_H_INP 0x4000
yading@11 82 #define SWS_DIRECT_BGR 0x8000
yading@11 83 #define SWS_ACCURATE_RND 0x40000
yading@11 84 #define SWS_BITEXACT 0x80000
yading@11 85 #define SWS_ERROR_DIFFUSION 0x800000
yading@11 86
yading@11 87 #if FF_API_SWS_CPU_CAPS
yading@11 88 /**
yading@11 89 * CPU caps are autodetected now, those flags
yading@11 90 * are only provided for API compatibility.
yading@11 91 */
yading@11 92 #define SWS_CPU_CAPS_MMX 0x80000000
yading@11 93 #define SWS_CPU_CAPS_MMXEXT 0x20000000
yading@11 94 #define SWS_CPU_CAPS_MMX2 0x20000000
yading@11 95 #define SWS_CPU_CAPS_3DNOW 0x40000000
yading@11 96 #define SWS_CPU_CAPS_ALTIVEC 0x10000000
yading@11 97 #define SWS_CPU_CAPS_BFIN 0x01000000
yading@11 98 #define SWS_CPU_CAPS_SSE2 0x02000000
yading@11 99 #endif
yading@11 100
yading@11 101 #define SWS_MAX_REDUCE_CUTOFF 0.002
yading@11 102
yading@11 103 #define SWS_CS_ITU709 1
yading@11 104 #define SWS_CS_FCC 4
yading@11 105 #define SWS_CS_ITU601 5
yading@11 106 #define SWS_CS_ITU624 5
yading@11 107 #define SWS_CS_SMPTE170M 5
yading@11 108 #define SWS_CS_SMPTE240M 7
yading@11 109 #define SWS_CS_DEFAULT 5
yading@11 110
yading@11 111 /**
yading@11 112 * Return a pointer to yuv<->rgb coefficients for the given colorspace
yading@11 113 * suitable for sws_setColorspaceDetails().
yading@11 114 *
yading@11 115 * @param colorspace One of the SWS_CS_* macros. If invalid,
yading@11 116 * SWS_CS_DEFAULT is used.
yading@11 117 */
yading@11 118 const int *sws_getCoefficients(int colorspace);
yading@11 119
yading@11 120 // when used for filters they must have an odd number of elements
yading@11 121 // coeffs cannot be shared between vectors
yading@11 122 typedef struct SwsVector {
yading@11 123 double *coeff; ///< pointer to the list of coefficients
yading@11 124 int length; ///< number of coefficients in the vector
yading@11 125 } SwsVector;
yading@11 126
yading@11 127 // vectors can be shared
yading@11 128 typedef struct SwsFilter {
yading@11 129 SwsVector *lumH;
yading@11 130 SwsVector *lumV;
yading@11 131 SwsVector *chrH;
yading@11 132 SwsVector *chrV;
yading@11 133 } SwsFilter;
yading@11 134
yading@11 135 struct SwsContext;
yading@11 136
yading@11 137 /**
yading@11 138 * Return a positive value if pix_fmt is a supported input format, 0
yading@11 139 * otherwise.
yading@11 140 */
yading@11 141 int sws_isSupportedInput(enum AVPixelFormat pix_fmt);
yading@11 142
yading@11 143 /**
yading@11 144 * Return a positive value if pix_fmt is a supported output format, 0
yading@11 145 * otherwise.
yading@11 146 */
yading@11 147 int sws_isSupportedOutput(enum AVPixelFormat pix_fmt);
yading@11 148
yading@11 149 /**
yading@11 150 * Allocate an empty SwsContext. This must be filled and passed to
yading@11 151 * sws_init_context(). For filling see AVOptions, options.c and
yading@11 152 * sws_setColorspaceDetails().
yading@11 153 */
yading@11 154 struct SwsContext *sws_alloc_context(void);
yading@11 155
yading@11 156 /**
yading@11 157 * Initialize the swscaler context sws_context.
yading@11 158 *
yading@11 159 * @return zero or positive value on success, a negative value on
yading@11 160 * error
yading@11 161 */
yading@11 162 int sws_init_context(struct SwsContext *sws_context, SwsFilter *srcFilter, SwsFilter *dstFilter);
yading@11 163
yading@11 164 /**
yading@11 165 * Free the swscaler context swsContext.
yading@11 166 * If swsContext is NULL, then does nothing.
yading@11 167 */
yading@11 168 void sws_freeContext(struct SwsContext *swsContext);
yading@11 169
yading@11 170 #if FF_API_SWS_GETCONTEXT
yading@11 171 /**
yading@11 172 * Allocate and return an SwsContext. You need it to perform
yading@11 173 * scaling/conversion operations using sws_scale().
yading@11 174 *
yading@11 175 * @param srcW the width of the source image
yading@11 176 * @param srcH the height of the source image
yading@11 177 * @param srcFormat the source image format
yading@11 178 * @param dstW the width of the destination image
yading@11 179 * @param dstH the height of the destination image
yading@11 180 * @param dstFormat the destination image format
yading@11 181 * @param flags specify which algorithm and options to use for rescaling
yading@11 182 * @return a pointer to an allocated context, or NULL in case of error
yading@11 183 * @note this function is to be removed after a saner alternative is
yading@11 184 * written
yading@11 185 * @deprecated Use sws_getCachedContext() instead.
yading@11 186 */
yading@11 187 struct SwsContext *sws_getContext(int srcW, int srcH, enum AVPixelFormat srcFormat,
yading@11 188 int dstW, int dstH, enum AVPixelFormat dstFormat,
yading@11 189 int flags, SwsFilter *srcFilter,
yading@11 190 SwsFilter *dstFilter, const double *param);
yading@11 191 #endif
yading@11 192
yading@11 193 /**
yading@11 194 * Scale the image slice in srcSlice and put the resulting scaled
yading@11 195 * slice in the image in dst. A slice is a sequence of consecutive
yading@11 196 * rows in an image.
yading@11 197 *
yading@11 198 * Slices have to be provided in sequential order, either in
yading@11 199 * top-bottom or bottom-top order. If slices are provided in
yading@11 200 * non-sequential order the behavior of the function is undefined.
yading@11 201 *
yading@11 202 * @param c the scaling context previously created with
yading@11 203 * sws_getContext()
yading@11 204 * @param srcSlice the array containing the pointers to the planes of
yading@11 205 * the source slice
yading@11 206 * @param srcStride the array containing the strides for each plane of
yading@11 207 * the source image
yading@11 208 * @param srcSliceY the position in the source image of the slice to
yading@11 209 * process, that is the number (counted starting from
yading@11 210 * zero) in the image of the first row of the slice
yading@11 211 * @param srcSliceH the height of the source slice, that is the number
yading@11 212 * of rows in the slice
yading@11 213 * @param dst the array containing the pointers to the planes of
yading@11 214 * the destination image
yading@11 215 * @param dstStride the array containing the strides for each plane of
yading@11 216 * the destination image
yading@11 217 * @return the height of the output slice
yading@11 218 */
yading@11 219 int sws_scale(struct SwsContext *c, const uint8_t *const srcSlice[],
yading@11 220 const int srcStride[], int srcSliceY, int srcSliceH,
yading@11 221 uint8_t *const dst[], const int dstStride[]);
yading@11 222
yading@11 223 /**
yading@11 224 * @param dstRange flag indicating the while-black range of the output (1=jpeg / 0=mpeg)
yading@11 225 * @param srcRange flag indicating the while-black range of the input (1=jpeg / 0=mpeg)
yading@11 226 * @param table the yuv2rgb coefficients describing the output yuv space, normally ff_yuv2rgb_coeffs[x]
yading@11 227 * @param inv_table the yuv2rgb coefficients describing the input yuv space, normally ff_yuv2rgb_coeffs[x]
yading@11 228 * @param brightness 16.16 fixed point brightness correction
yading@11 229 * @param contrast 16.16 fixed point contrast correction
yading@11 230 * @param saturation 16.16 fixed point saturation correction
yading@11 231 * @return -1 if not supported
yading@11 232 */
yading@11 233 int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4],
yading@11 234 int srcRange, const int table[4], int dstRange,
yading@11 235 int brightness, int contrast, int saturation);
yading@11 236
yading@11 237 /**
yading@11 238 * @return -1 if not supported
yading@11 239 */
yading@11 240 int sws_getColorspaceDetails(struct SwsContext *c, int **inv_table,
yading@11 241 int *srcRange, int **table, int *dstRange,
yading@11 242 int *brightness, int *contrast, int *saturation);
yading@11 243
yading@11 244 /**
yading@11 245 * Allocate and return an uninitialized vector with length coefficients.
yading@11 246 */
yading@11 247 SwsVector *sws_allocVec(int length);
yading@11 248
yading@11 249 /**
yading@11 250 * Return a normalized Gaussian curve used to filter stuff
yading@11 251 * quality = 3 is high quality, lower is lower quality.
yading@11 252 */
yading@11 253 SwsVector *sws_getGaussianVec(double variance, double quality);
yading@11 254
yading@11 255 /**
yading@11 256 * Allocate and return a vector with length coefficients, all
yading@11 257 * with the same value c.
yading@11 258 */
yading@11 259 SwsVector *sws_getConstVec(double c, int length);
yading@11 260
yading@11 261 /**
yading@11 262 * Allocate and return a vector with just one coefficient, with
yading@11 263 * value 1.0.
yading@11 264 */
yading@11 265 SwsVector *sws_getIdentityVec(void);
yading@11 266
yading@11 267 /**
yading@11 268 * Scale all the coefficients of a by the scalar value.
yading@11 269 */
yading@11 270 void sws_scaleVec(SwsVector *a, double scalar);
yading@11 271
yading@11 272 /**
yading@11 273 * Scale all the coefficients of a so that their sum equals height.
yading@11 274 */
yading@11 275 void sws_normalizeVec(SwsVector *a, double height);
yading@11 276 void sws_convVec(SwsVector *a, SwsVector *b);
yading@11 277 void sws_addVec(SwsVector *a, SwsVector *b);
yading@11 278 void sws_subVec(SwsVector *a, SwsVector *b);
yading@11 279 void sws_shiftVec(SwsVector *a, int shift);
yading@11 280
yading@11 281 /**
yading@11 282 * Allocate and return a clone of the vector a, that is a vector
yading@11 283 * with the same coefficients as a.
yading@11 284 */
yading@11 285 SwsVector *sws_cloneVec(SwsVector *a);
yading@11 286
yading@11 287 /**
yading@11 288 * Print with av_log() a textual representation of the vector a
yading@11 289 * if log_level <= av_log_level.
yading@11 290 */
yading@11 291 void sws_printVec2(SwsVector *a, AVClass *log_ctx, int log_level);
yading@11 292
yading@11 293 void sws_freeVec(SwsVector *a);
yading@11 294
yading@11 295 SwsFilter *sws_getDefaultFilter(float lumaGBlur, float chromaGBlur,
yading@11 296 float lumaSharpen, float chromaSharpen,
yading@11 297 float chromaHShift, float chromaVShift,
yading@11 298 int verbose);
yading@11 299 void sws_freeFilter(SwsFilter *filter);
yading@11 300
yading@11 301 /**
yading@11 302 * Check if context can be reused, otherwise reallocate a new one.
yading@11 303 *
yading@11 304 * If context is NULL, just calls sws_getContext() to get a new
yading@11 305 * context. Otherwise, checks if the parameters are the ones already
yading@11 306 * saved in context. If that is the case, returns the current
yading@11 307 * context. Otherwise, frees context and gets a new context with
yading@11 308 * the new parameters.
yading@11 309 *
yading@11 310 * Be warned that srcFilter and dstFilter are not checked, they
yading@11 311 * are assumed to remain the same.
yading@11 312 */
yading@11 313 struct SwsContext *sws_getCachedContext(struct SwsContext *context,
yading@11 314 int srcW, int srcH, enum AVPixelFormat srcFormat,
yading@11 315 int dstW, int dstH, enum AVPixelFormat dstFormat,
yading@11 316 int flags, SwsFilter *srcFilter,
yading@11 317 SwsFilter *dstFilter, const double *param);
yading@11 318
yading@11 319 /**
yading@11 320 * Convert an 8-bit paletted frame into a frame with a color depth of 32 bits.
yading@11 321 *
yading@11 322 * The output frame will have the same packed format as the palette.
yading@11 323 *
yading@11 324 * @param src source frame buffer
yading@11 325 * @param dst destination frame buffer
yading@11 326 * @param num_pixels number of pixels to convert
yading@11 327 * @param palette array with [256] entries, which must match color arrangement (RGB or BGR) of src
yading@11 328 */
yading@11 329 void sws_convertPalette8ToPacked32(const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette);
yading@11 330
yading@11 331 /**
yading@11 332 * Convert an 8-bit paletted frame into a frame with a color depth of 24 bits.
yading@11 333 *
yading@11 334 * With the palette format "ABCD", the destination frame ends up with the format "ABC".
yading@11 335 *
yading@11 336 * @param src source frame buffer
yading@11 337 * @param dst destination frame buffer
yading@11 338 * @param num_pixels number of pixels to convert
yading@11 339 * @param palette array with [256] entries, which must match color arrangement (RGB or BGR) of src
yading@11 340 */
yading@11 341 void sws_convertPalette8ToPacked24(const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette);
yading@11 342
yading@11 343 /**
yading@11 344 * Get the AVClass for swsContext. It can be used in combination with
yading@11 345 * AV_OPT_SEARCH_FAKE_OBJ for examining options.
yading@11 346 *
yading@11 347 * @see av_opt_find().
yading@11 348 */
yading@11 349 const AVClass *sws_get_class(void);
yading@11 350
yading@11 351 /**
yading@11 352 * @}
yading@11 353 */
yading@11 354
yading@11 355 #endif /* SWSCALE_SWSCALE_H */