1 /*
2 * Copyright (C) 2001-2011 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg 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 * FFmpeg 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 FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */20 21 moduleffmpeg.libswscale.swscale;
22 23 extern (C):
24 importffmpeg; @nogcnothrow:
25 26 /**
27 * @file
28 * @ingroup libsws
29 * external API header
30 */31 32 /**
33 * @defgroup libsws libswscale
34 * Color conversion and scaling library.
35 *
36 * @{
37 *
38 * Return the LIBSWSCALE_VERSION_INT constant.
39 */40 uintswscale_version ();
41 42 /**
43 * Return the libswscale build-time configuration.
44 */45 const(char)* swscale_configuration ();
46 47 /**
48 * Return the libswscale license.
49 */50 const(char)* swscale_license ();
51 52 /* values for the flags, the stuff on the command line is different */53 enumSWS_FAST_BILINEAR = 1;
54 enumSWS_BILINEAR = 2;
55 enumSWS_BICUBIC = 4;
56 enumSWS_X = 8;
57 enumSWS_POINT = 0x10;
58 enumSWS_AREA = 0x20;
59 enumSWS_BICUBLIN = 0x40;
60 enumSWS_GAUSS = 0x80;
61 enumSWS_SINC = 0x100;
62 enumSWS_LANCZOS = 0x200;
63 enumSWS_SPLINE = 0x400;
64 65 enumSWS_SRC_V_CHR_DROP_MASK = 0x30000;
66 enumSWS_SRC_V_CHR_DROP_SHIFT = 16;
67 68 enumSWS_PARAM_DEFAULT = 123456;
69 70 enumSWS_PRINT_INFO = 0x1000;
71 72 //the following 3 flags are not completely implemented73 //internal chrominance subsampling info74 enumSWS_FULL_CHR_H_INT = 0x2000;
75 //input subsampling info76 enumSWS_FULL_CHR_H_INP = 0x4000;
77 enumSWS_DIRECT_BGR = 0x8000;
78 enumSWS_ACCURATE_RND = 0x40000;
79 enumSWS_BITEXACT = 0x80000;
80 enumSWS_ERROR_DIFFUSION = 0x800000;
81 82 enumSWS_MAX_REDUCE_CUTOFF = 0.002;
83 84 enumSWS_CS_ITU709 = 1;
85 enumSWS_CS_FCC = 4;
86 enumSWS_CS_ITU601 = 5;
87 enumSWS_CS_ITU624 = 5;
88 enumSWS_CS_SMPTE170M = 5;
89 enumSWS_CS_SMPTE240M = 7;
90 enumSWS_CS_DEFAULT = 5;
91 enumSWS_CS_BT2020 = 9;
92 93 /**
94 * Return a pointer to yuv<->rgb coefficients for the given colorspace
95 * suitable for sws_setColorspaceDetails().
96 *
97 * @param colorspace One of the SWS_CS_* macros. If invalid,
98 * SWS_CS_DEFAULT is used.
99 */100 const(int)* sws_getCoefficients (intcolorspace);
101 102 // when used for filters they must have an odd number of elements103 // coeffs cannot be shared between vectors104 structSwsVector105 {
106 double* coeff; ///< pointer to the list of coefficients107 intlength; ///< number of coefficients in the vector108 }
109 110 // vectors can be shared111 structSwsFilter112 {
113 SwsVector* lumH;
114 SwsVector* lumV;
115 SwsVector* chrH;
116 SwsVector* chrV;
117 }
118 119 structSwsContext;
120 121 /**
122 * Return a positive value if pix_fmt is a supported input format, 0
123 * otherwise.
124 */125 intsws_isSupportedInput (AVPixelFormatpix_fmt);
126 127 /**
128 * Return a positive value if pix_fmt is a supported output format, 0
129 * otherwise.
130 */131 intsws_isSupportedOutput (AVPixelFormatpix_fmt);
132 133 /**
134 * @param[in] pix_fmt the pixel format
135 * @return a positive value if an endianness conversion for pix_fmt is
136 * supported, 0 otherwise.
137 */138 intsws_isSupportedEndiannessConversion (AVPixelFormatpix_fmt);
139 140 /**
141 * Allocate an empty SwsContext. This must be filled and passed to
142 * sws_init_context(). For filling see AVOptions, options.c and
143 * sws_setColorspaceDetails().
144 */145 SwsContext* sws_alloc_context ();
146 147 /**
148 * Initialize the swscaler context sws_context.
149 *
150 * @return zero or positive value on success, a negative value on
151 * error
152 */153 intsws_init_context (
154 SwsContext* sws_context,
155 SwsFilter* srcFilter,
156 SwsFilter* dstFilter);
157 158 /**
159 * Free the swscaler context swsContext.
160 * If swsContext is NULL, then does nothing.
161 */162 voidsws_freeContext (SwsContext* swsContext);
163 164 /**
165 * Allocate and return an SwsContext. You need it to perform
166 * scaling/conversion operations using sws_scale().
167 *
168 * @param srcW the width of the source image
169 * @param srcH the height of the source image
170 * @param srcFormat the source image format
171 * @param dstW the width of the destination image
172 * @param dstH the height of the destination image
173 * @param dstFormat the destination image format
174 * @param flags specify which algorithm and options to use for rescaling
175 * @param param extra parameters to tune the used scaler
176 * For SWS_BICUBIC param[0] and [1] tune the shape of the basis
177 * function, param[0] tunes f(1) and param[1] f´(1)
178 * For SWS_GAUSS param[0] tunes the exponent and thus cutoff
179 * frequency
180 * For SWS_LANCZOS param[0] tunes the width of the window function
181 * @return a pointer to an allocated context, or NULL in case of error
182 * @note this function is to be removed after a saner alternative is
183 * written
184 */185 SwsContext* sws_getContext (
186 intsrcW,
187 intsrcH,
188 AVPixelFormatsrcFormat,
189 intdstW,
190 intdstH,
191 AVPixelFormatdstFormat,
192 intflags,
193 SwsFilter* srcFilter,
194 SwsFilter* dstFilter,
195 const(double)* param);
196 197 /**
198 * Scale the image slice in srcSlice and put the resulting scaled
199 * slice in the image in dst. A slice is a sequence of consecutive
200 * rows in an image.
201 *
202 * Slices have to be provided in sequential order, either in
203 * top-bottom or bottom-top order. If slices are provided in
204 * non-sequential order the behavior of the function is undefined.
205 *
206 * @param c the scaling context previously created with
207 * sws_getContext()
208 * @param srcSlice the array containing the pointers to the planes of
209 * the source slice
210 * @param srcStride the array containing the strides for each plane of
211 * the source image
212 * @param srcSliceY the position in the source image of the slice to
213 * process, that is the number (counted starting from
214 * zero) in the image of the first row of the slice
215 * @param srcSliceH the height of the source slice, that is the number
216 * of rows in the slice
217 * @param dst the array containing the pointers to the planes of
218 * the destination image
219 * @param dstStride the array containing the strides for each plane of
220 * the destination image
221 * @return the height of the output slice
222 */223 intsws_scale (
224 SwsContext* c,
225 const(ubyte*)* srcSlice,
226 const(int)* srcStride,
227 intsrcSliceY,
228 intsrcSliceH,
229 const(ubyte*)* dst,
230 const(int)* dstStride);
231 232 /**
233 * @param dstRange flag indicating the while-black range of the output (1=jpeg / 0=mpeg)
234 * @param srcRange flag indicating the while-black range of the input (1=jpeg / 0=mpeg)
235 * @param table the yuv2rgb coefficients describing the output yuv space, normally ff_yuv2rgb_coeffs[x]
236 * @param inv_table the yuv2rgb coefficients describing the input yuv space, normally ff_yuv2rgb_coeffs[x]
237 * @param brightness 16.16 fixed point brightness correction
238 * @param contrast 16.16 fixed point contrast correction
239 * @param saturation 16.16 fixed point saturation correction
240 * @return -1 if not supported
241 */242 intsws_setColorspaceDetails (
243 SwsContext* c,
244 refconst(int)[4] inv_table,
245 intsrcRange,
246 refconst(int)[4] table,
247 intdstRange,
248 intbrightness,
249 intcontrast,
250 intsaturation);
251 252 /**
253 * @return -1 if not supported
254 */255 intsws_getColorspaceDetails (
256 SwsContext* c,
257 int** inv_table,
258 int* srcRange,
259 int** table,
260 int* dstRange,
261 int* brightness,
262 int* contrast,
263 int* saturation);
264 265 /**
266 * Allocate and return an uninitialized vector with length coefficients.
267 */268 SwsVector* sws_allocVec (intlength);
269 270 /**
271 * Return a normalized Gaussian curve used to filter stuff
272 * quality = 3 is high quality, lower is lower quality.
273 */274 SwsVector* sws_getGaussianVec (doublevariance, doublequality);
275 276 /**
277 * Scale all the coefficients of a by the scalar value.
278 */279 voidsws_scaleVec (SwsVector* a, doublescalar);
280 281 /**
282 * Scale all the coefficients of a so that their sum equals height.
283 */284 voidsws_normalizeVec (SwsVector* a, doubleheight);
285 286 SwsVector* sws_getConstVec (doublec, intlength);
287 SwsVector* sws_getIdentityVec ();
288 voidsws_convVec (SwsVector* a, SwsVector* b);
289 voidsws_addVec (SwsVector* a, SwsVector* b);
290 voidsws_subVec (SwsVector* a, SwsVector* b);
291 voidsws_shiftVec (SwsVector* a, intshift);
292 SwsVector* sws_cloneVec (SwsVector* a);
293 voidsws_printVec2 (SwsVector* a, AVClass* log_ctx, intlog_level);
294 295 voidsws_freeVec (SwsVector* a);
296 297 SwsFilter* sws_getDefaultFilter (
298 floatlumaGBlur,
299 floatchromaGBlur,
300 floatlumaSharpen,
301 floatchromaSharpen,
302 floatchromaHShift,
303 floatchromaVShift,
304 intverbose);
305 voidsws_freeFilter (SwsFilter* filter);
306 307 /**
308 * Check if context can be reused, otherwise reallocate a new one.
309 *
310 * If context is NULL, just calls sws_getContext() to get a new
311 * context. Otherwise, checks if the parameters are the ones already
312 * saved in context. If that is the case, returns the current
313 * context. Otherwise, frees context and gets a new context with
314 * the new parameters.
315 *
316 * Be warned that srcFilter and dstFilter are not checked, they
317 * are assumed to remain the same.
318 */319 SwsContext* sws_getCachedContext (
320 SwsContext* context,
321 intsrcW,
322 intsrcH,
323 AVPixelFormatsrcFormat,
324 intdstW,
325 intdstH,
326 AVPixelFormatdstFormat,
327 intflags,
328 SwsFilter* srcFilter,
329 SwsFilter* dstFilter,
330 const(double)* param);
331 332 /**
333 * Convert an 8-bit paletted frame into a frame with a color depth of 32 bits.
334 *
335 * The output frame will have the same packed format as the palette.
336 *
337 * @param src source frame buffer
338 * @param dst destination frame buffer
339 * @param num_pixels number of pixels to convert
340 * @param palette array with [256] entries, which must match color arrangement (RGB or BGR) of src
341 */342 voidsws_convertPalette8ToPacked32 (const(ubyte)* src, ubyte* dst, intnum_pixels, const(ubyte)* palette);
343 344 /**
345 * Convert an 8-bit paletted frame into a frame with a color depth of 24 bits.
346 *
347 * With the palette format "ABCD", the destination frame ends up with the format "ABC".
348 *
349 * @param src source frame buffer
350 * @param dst destination frame buffer
351 * @param num_pixels number of pixels to convert
352 * @param palette array with [256] entries, which must match color arrangement (RGB or BGR) of src
353 */354 voidsws_convertPalette8ToPacked24 (const(ubyte)* src, ubyte* dst, intnum_pixels, const(ubyte)* palette);
355 356 /**
357 * Get the AVClass for swsContext. It can be used in combination with
358 * AV_OPT_SEARCH_FAKE_OBJ for examining options.
359 *
360 * @see av_opt_find().
361 */362 const(AVClass)* sws_get_class ();
363 364 /**
365 * @}
366 */367 368 /* SWSCALE_SWSCALE_H */