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 #ifndef SWSCALE_SWSCALE_INTERNAL_H
22 #define SWSCALE_SWSCALE_INTERNAL_H
23
24 #include <stdatomic.h>
25
26 #include "config.h"
27
37 #if HAVE_ALTIVEC
39 #endif
41
42 #define STR(s) AV_TOSTRING(s) // AV_STRINGIFY is too long
43
44 #define YUVRGB_TABLE_HEADROOM 512
45 #define YUVRGB_TABLE_LUMA_HEADROOM 512
46
47 #define MAX_FILTER_SIZE SWS_MAX_FILTER_SIZE
48
49 #if HAVE_BIGENDIAN
50 #define ALT32_CORR (-1)
51 #else
53 #endif
54
55 #if ARCH_X86_64
56 # define APCK_PTR2 8
57 # define APCK_COEF 16
58 # define APCK_SIZE 24
59 #else
63 #endif
64
65 #define RETCODE_USE_CASCADE -12345
66
68
78
85
86 typedef struct Range {
90
96
98
100 int srcStride[], int srcSliceY, int srcSliceH,
101 uint8_t *
dst[],
int dstStride[]);
102
103 /**
104 * Write one line of horizontally scaled data to planar output
105 * without any additional vertical scaling (or point-scaling).
106 *
107 * @param src scaled source data, 15 bits for 8-10-bit output,
108 * 19 bits for 16-bit output (in int32_t)
109 * @param dest pointer to the output plane. For >8-bit
110 * output, this is in uint16_t
111 * @param dstW width of destination in pixels
112 * @param dither ordered dither array of type int16_t and size 8
113 * @param offset Dither offset
114 */
117
118 /**
119 * Write one line of horizontally scaled data to planar output
120 * with multi-point vertical scaling between input pixels.
121 *
122 * @param filter vertical luma/alpha scaling coefficients, 12 bits [0,4096]
123 * @param src scaled luma (Y) or alpha (A) source data, 15 bits for
124 * 8-10-bit output, 19 bits for 16-bit output (in int32_t)
125 * @param filterSize number of vertical input lines to scale
126 * @param dest pointer to output plane. For >8-bit
127 * output, this is in uint16_t
128 * @param dstW width of destination pixels
129 * @param offset Dither offset
130 */
132 const int16_t **
src, uint8_t *dest,
int dstW,
134
135 /**
136 * Write one line of horizontally scaled chroma to interleaved output
137 * with multi-point vertical scaling between input pixels.
138 *
139 * @param dstFormat destination pixel format
140 * @param chrDither ordered dither array of type uint8_t and size 8
141 * @param chrFilter vertical chroma scaling coefficients, 12 bits [0,4096]
142 * @param chrUSrc scaled chroma (U) source data, 15 bits for 8-10-bit
143 * output, 19 bits for 16-bit output (in int32_t)
144 * @param chrVSrc scaled chroma (V) source data, 15 bits for 8-10-bit
145 * output, 19 bits for 16-bit output (in int32_t)
146 * @param chrFilterSize number of vertical chroma input lines to scale
147 * @param dest pointer to the output plane. For >8-bit
148 * output, this is in uint16_t
149 * @param dstW width of chroma planes
150 */
152 const uint8_t *chrDither,
153 const int16_t *chrFilter,
154 int chrFilterSize,
155 const int16_t **chrUSrc,
156 const int16_t **chrVSrc,
157 uint8_t *dest,
int dstW);
158
159 /**
160 * Write one line of horizontally scaled Y/U/V/A to packed-pixel YUV/RGB
161 * output without any additional vertical scaling (or point-scaling). Note
162 * that this function may do chroma scaling, see the "uvalpha" argument.
163 *
164 * @param c SWS scaling context
165 * @param lumSrc scaled luma (Y) source data, 15 bits for 8-10-bit output,
166 * 19 bits for 16-bit output (in int32_t)
167 * @param chrUSrc scaled chroma (U) source data, 15 bits for 8-10-bit output,
168 * 19 bits for 16-bit output (in int32_t)
169 * @param chrVSrc scaled chroma (V) source data, 15 bits for 8-10-bit output,
170 * 19 bits for 16-bit output (in int32_t)
171 * @param alpSrc scaled alpha (A) source data, 15 bits for 8-10-bit output,
172 * 19 bits for 16-bit output (in int32_t)
173 * @param dest pointer to the output plane. For 16-bit output, this is
174 * uint16_t
175 * @param dstW width of lumSrc and alpSrc in pixels, number of pixels
176 * to write into dest[]
177 * @param uvalpha chroma scaling coefficient for the second line of chroma
178 * pixels, either 2048 or 0. If 0, one chroma input is used
179 * for 2 output pixels (or if the SWS_FLAG_FULL_CHR_INT flag
180 * is set, it generates 1 output pixel). If 2048, two chroma
181 * input pixels should be averaged for 2 output pixels (this
182 * only happens if SWS_FLAG_FULL_CHR_INT is not set)
183 * @param y vertical line number for this output. This does not need
184 * to be used to calculate the offset in the destination,
185 * but can be used to generate comfort noise using dithering
186 * for some output formats.
187 */
189 const int16_t *chrUSrc[2],
190 const int16_t *chrVSrc[2],
191 const int16_t *alpSrc, uint8_t *dest,
192 int dstW,
int uvalpha,
int y);
193 /**
194 * Write one line of horizontally scaled Y/U/V/A to packed-pixel YUV/RGB
195 * output by doing bilinear scaling between two input lines.
196 *
197 * @param c SWS scaling context
198 * @param lumSrc scaled luma (Y) source data, 15 bits for 8-10-bit output,
199 * 19 bits for 16-bit output (in int32_t)
200 * @param chrUSrc scaled chroma (U) source data, 15 bits for 8-10-bit output,
201 * 19 bits for 16-bit output (in int32_t)
202 * @param chrVSrc scaled chroma (V) source data, 15 bits for 8-10-bit output,
203 * 19 bits for 16-bit output (in int32_t)
204 * @param alpSrc scaled alpha (A) source data, 15 bits for 8-10-bit output,
205 * 19 bits for 16-bit output (in int32_t)
206 * @param dest pointer to the output plane. For 16-bit output, this is
207 * uint16_t
208 * @param dstW width of lumSrc and alpSrc in pixels, number of pixels
209 * to write into dest[]
210 * @param yalpha luma/alpha scaling coefficients for the second input line.
211 * The first line's coefficients can be calculated by using
212 * 4096 - yalpha
213 * @param uvalpha chroma scaling coefficient for the second input line. The
214 * first line's coefficients can be calculated by using
215 * 4096 - uvalpha
216 * @param y vertical line number for this output. This does not need
217 * to be used to calculate the offset in the destination,
218 * but can be used to generate comfort noise using dithering
219 * for some output formats.
220 */
222 const int16_t *chrUSrc[2],
223 const int16_t *chrVSrc[2],
224 const int16_t *alpSrc[2],
225 uint8_t *dest,
226 int dstW,
int yalpha,
int uvalpha,
int y);
227 /**
228 * Write one line of horizontally scaled Y/U/V/A to packed-pixel YUV/RGB
229 * output by doing multi-point vertical scaling between input pixels.
230 *
231 * @param c SWS scaling context
232 * @param lumFilter vertical luma/alpha scaling coefficients, 12 bits [0,4096]
233 * @param lumSrc scaled luma (Y) source data, 15 bits for 8-10-bit output,
234 * 19 bits for 16-bit output (in int32_t)
235 * @param lumFilterSize number of vertical luma/alpha input lines to scale
236 * @param chrFilter vertical chroma scaling coefficients, 12 bits [0,4096]
237 * @param chrUSrc scaled chroma (U) source data, 15 bits for 8-10-bit output,
238 * 19 bits for 16-bit output (in int32_t)
239 * @param chrVSrc scaled chroma (V) source data, 15 bits for 8-10-bit output,
240 * 19 bits for 16-bit output (in int32_t)
241 * @param chrFilterSize number of vertical chroma input lines to scale
242 * @param alpSrc scaled alpha (A) source data, 15 bits for 8-10-bit output,
243 * 19 bits for 16-bit output (in int32_t)
244 * @param dest pointer to the output plane. For 16-bit output, this is
245 * uint16_t
246 * @param dstW width of lumSrc and alpSrc in pixels, number of pixels
247 * to write into dest[]
248 * @param y vertical line number for this output. This does not need
249 * to be used to calculate the offset in the destination,
250 * but can be used to generate comfort noise using dithering
251 * or some output formats.
252 */
254 const int16_t **lumSrc, int lumFilterSize,
255 const int16_t *chrFilter,
256 const int16_t **chrUSrc,
257 const int16_t **chrVSrc, int chrFilterSize,
258 const int16_t **alpSrc, uint8_t *dest,
260
261 /**
262 * Write one line of horizontally scaled Y/U/V/A to YUV/RGB
263 * output by doing multi-point vertical scaling between input pixels.
264 *
265 * @param c SWS scaling context
266 * @param lumFilter vertical luma/alpha scaling coefficients, 12 bits [0,4096]
267 * @param lumSrc scaled luma (Y) source data, 15 bits for 8-10-bit output,
268 * 19 bits for 16-bit output (in int32_t)
269 * @param lumFilterSize number of vertical luma/alpha input lines to scale
270 * @param chrFilter vertical chroma scaling coefficients, 12 bits [0,4096]
271 * @param chrUSrc scaled chroma (U) source data, 15 bits for 8-10-bit output,
272 * 19 bits for 16-bit output (in int32_t)
273 * @param chrVSrc scaled chroma (V) source data, 15 bits for 8-10-bit output,
274 * 19 bits for 16-bit output (in int32_t)
275 * @param chrFilterSize number of vertical chroma input lines to scale
276 * @param alpSrc scaled alpha (A) source data, 15 bits for 8-10-bit output,
277 * 19 bits for 16-bit output (in int32_t)
278 * @param dest pointer to the output planes. For 16-bit output, this is
279 * uint16_t
280 * @param dstW width of lumSrc and alpSrc in pixels, number of pixels
281 * to write into dest[]
282 * @param y vertical line number for this output. This does not need
283 * to be used to calculate the offset in the destination,
284 * but can be used to generate comfort noise using dithering
285 * or some output formats.
286 */
288 const int16_t **lumSrc, int lumFilterSize,
289 const int16_t *chrFilter,
290 const int16_t **chrUSrc,
291 const int16_t **chrVSrc, int chrFilterSize,
292 const int16_t **alpSrc, uint8_t **dest,
294
297
298 /* This struct should be aligned on at least a 32-byte boundary. */
300 /**
301 * info on struct for av_log
302 */
304
306
311
312 // values passed to current sws_receive_slice() call
315
316 /**
317 * Note that src, dst, srcStride, dstStride will be copied in the
318 * sws_scale() wrapper so they can be freely modified here.
319 */
321 int srcW;
///< Width of source luma/alpha planes.
322 int srcH;
///< Height of source luma/alpha planes.
323 int dstH;
///< Height of destination luma/alpha planes.
324 int chrSrcW;
///< Width of source chroma planes.
325 int chrSrcH;
///< Height of source chroma planes.
326 int chrDstW;
///< Width of destination chroma planes.
327 int chrDstH;
///< Height of destination chroma planes.
332 int dstFormatBpp;
///< Number of bits per pixel of the destination pixel format.
333 int srcFormatBpp;
///< Number of bits per pixel of the source pixel format.
335 int chrSrcHSubSample;
///< Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in source image.
336 int chrSrcVSubSample;
///< Binary logarithm of vertical subsampling factor between luma/alpha and chroma planes in source image.
337 int chrDstHSubSample;
///< Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in destination image.
338 int chrDstVSubSample;
///< Binary logarithm of vertical subsampling factor between luma/alpha and chroma planes in destination image.
339 int vChrDrop;
///< Binary logarithm of extra vertical subsampling factor in source image chroma planes specified by user.
340 int sliceDir;
///< Direction that slices are fed to the scaler (1 = top-to-bottom, -1 = bottom-to-top).
342 double param[2];
///< Input parameters for scaling algorithms that need them.
343
346
348
349 /* The cascaded_* fields allow spliting a scaler task into multiple
350 * sequential steps, this is for example used to limit the maximum
351 * downscaling factor that needs to be supported in one scaler.
352 */
359
365
371
374
376
377 /**
378 * @name Scaled horizontal lines ring buffer.
379 * The horizontal scaler keeps just enough scaled lines in a ring buffer
380 * so they may be passed to the vertical scaler. The pointers to the
381 * allocated buffers for each line are duplicated in sequence in the ring
382 * buffer to simplify indexing and avoid wrapping around between lines
383 * inside the vertical scaler code. The wrapping is done before the
384 * vertical scaler is called.
385 */
386 //@{
387 int lastInLumBuf;
///< Last scaled horizontal luma/alpha line from source in the ring buffer.
388 int lastInChrBuf;
///< Last scaled horizontal chroma line from source in the ring buffer.
389 //@}
390
393
394 /**
395 * @name Horizontal and vertical filters.
396 * To better understand the following fields, here is a pseudo-code of
397 * their usage in filtering a horizontal line:
398 * @code
399 * for (i = 0; i < width; i++) {
400 * dst[i] = 0;
401 * for (j = 0; j < filterSize; j++)
402 * dst[i] += src[ filterPos[i] + j ] * filter[ filterSize * i + j ];
403 * dst[i] >>= FRAC_BITS; // The actual implementation is fixed-point.
404 * }
405 * @endcode
406 */
407 //@{
408 int16_t *
hLumFilter;
///< Array of horizontal filter coefficients for luma/alpha planes.
409 int16_t *
hChrFilter;
///< Array of horizontal filter coefficients for chroma planes.
410 int16_t *
vLumFilter;
///< Array of vertical filter coefficients for luma/alpha planes.
411 int16_t *
vChrFilter;
///< Array of vertical filter coefficients for chroma planes.
412 int32_t *
hLumFilterPos;
///< Array of horizontal filter starting positions for each dst[i] for luma/alpha planes.
414 int32_t *
vLumFilterPos;
///< Array of vertical filter starting positions for each dst[i] for luma/alpha planes.
420 //@}
421
424 uint8_t *
lumMmxextFilterCode;
///< Runtime-generated MMXEXT horizontal fast bilinear scaler code for luma/alpha planes.
425 uint8_t *
chrMmxextFilterCode;
///< Runtime-generated MMXEXT horizontal fast bilinear scaler code for chroma planes.
426
429
430 int dstY;
///< Last destination vertical line output from last slice.
431 int flags;
///< Flags passed by the user to select scaler algorithm, optimizations, subsampling, etc...
432 void *
yuvTable;
// pointer to the yuv->rgb table start so it can be freed()
433 // alignment ensures the offset can be added in a single
434 // instruction on e.g. ARM
449 #define RGB2YUV_SHIFT 15
450
452
453 //Colorspace stuff
457 int srcRange;
///< 0 = MPG YUV range, 1 = JPG YUV range (source image).
458 int dstRange;
///< 0 = MPG YUV range, 1 = JPG YUV range (destination image).
473
474 #define RED_DITHER "0*8"
475 #define GREEN_DITHER "1*8"
476 #define BLUE_DITHER "2*8"
477 #define Y_COEFF "3*8"
478 #define VR_COEFF "4*8"
479 #define UB_COEFF "5*8"
480 #define VG_COEFF "6*8"
481 #define UG_COEFF "7*8"
482 #define Y_OFFSET "8*8"
483 #define U_OFFSET "9*8"
484 #define V_OFFSET "10*8"
485 #define LUM_MMX_FILTER_OFFSET "11*8"
486 #define CHR_MMX_FILTER_OFFSET "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)
487 #define DSTW_OFFSET "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2"
488 #define ESP_OFFSET "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+8"
489 #define VROUNDER_OFFSET "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+16"
490 #define U_TEMP "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+24"
491 #define V_TEMP "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+32"
492 #define Y_TEMP "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+40"
493 #define ALP_MMX_FILTER_OFFSET "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+48"
494 #define UV_OFF_PX "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*3+48"
495 #define UV_OFF_BYTE "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*3+56"
496 #define DITHER16 "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*3+64"
497 #define DITHER32 "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*3+80"
498 #define DITHER32_INT (11*8+4*4*MAX_FILTER_SIZE*3+80) // value equal to above, used for checking that the struct hasn't been changed by mistake
499
503
514 int dstW;
///< Width of destination luma/alpha planes.
521 // alignment of these values is not necessary, but merely here
522 // to maintain the same offset across x8632 and x86-64. Once we
523 // use proper offset macros in the asm, they can be removed.
528
530
531 #if HAVE_ALTIVEC
532 vector signed short CY;
533 vector signed short CRV;
534 vector signed short CBU;
535 vector signed short CGU;
536 vector signed short CGV;
537 vector signed short OY;
538 vector
unsigned short CSHIFT;
539 vector signed short *vYCoeffsBank, *vCCoeffsBank;
540 #endif
541
543
544 /* pre defined color-spaces gamma */
545 #define XYZ_GAMMA (2.6f)
546 #define RGB_GAMMA (2.2f)
553
554 /* function pointers for swscale() */
562
563 /// Opaque data pointer passed to all input functions.
565
566 /// Unscaled conversion of luma plane to YV12 for horizontal scaler.
568 int width, uint32_t *pal,
void *opq);
569 /// Unscaled conversion of alpha plane to YV12 for horizontal scaler.
571 int width, uint32_t *pal,
void *opq);
572 /// Unscaled conversion of chroma planes to YV12 for horizontal scaler.
574 const uint8_t *
src1,
const uint8_t *
src2,
const uint8_t *src3,
575 int width, uint32_t *pal,
void *opq);
576
577 /**
578 * Functions to read planar input, such as planar RGB, and convert
579 * internally to Y/UV/A.
580 */
581 /** @{ */
583 void *opq);
587 void *opq);
588 /** @} */
589
590 /**
591 * Scale one horizontal line of input data using a bilinear filter
592 * to produce one line of output data. Compared to SwsContext->hScale(),
593 * please take note of the following caveats when using these:
594 * - Scaling is done using only 7 bits instead of 14-bit coefficients.
595 * - You can use no more than 5 input pixels to produce 4 output
596 * pixels. Therefore, this filter should not be used for downscaling
597 * by more than ~20% in width (because that equals more than 5/4th
598 * downscaling and thus more than 5 pixels input per 4 pixels output).
599 * - In general, bilinear filters create artifacts during downscaling
600 * (even when <20%), because one output pixel will span more than one
601 * input pixel, and thus some pixels will need edges of both neighbor
602 * pixels to interpolate the output pixel. Since you can use at most
603 * two input pixels per output pixel in bilinear scaling, this is
604 * impossible and thus downscaling by any size will create artifacts.
605 * To enable this type of scaling, set SWS_FLAG_FAST_BILINEAR
606 * in SwsContext->flags.
607 */
608 /** @{ */
610 int16_t *
dst,
int dstWidth,
611 const uint8_t *
src,
int srcW,
int xInc);
613 int16_t *dst1, int16_t *dst2, int dstWidth,
614 const uint8_t *
src1,
const uint8_t *
src2,
616 /** @} */
617
618 /**
619 * Scale one horizontal line of input data using a filter over the input
620 * lines, to produce one (differently sized) line of output data.
621 *
622 * @param dst pointer to destination buffer for horizontally scaled
623 * data. If the number of bits per component of one
624 * destination pixel (SwsContext->dstBpc) is <= 10, data
625 * will be 15 bpc in 16 bits (int16_t) width. Else (i.e.
626 * SwsContext->dstBpc == 16), data will be 19bpc in
627 * 32 bits (int32_t) width.
628 * @param dstW width of destination image
629 * @param src pointer to source data to be scaled. If the number of
630 * bits per component of a source pixel (SwsContext->srcBpc)
631 * is 8, this is 8bpc in 8 bits (uint8_t) width. Else
632 * (i.e. SwsContext->dstBpc > 8), this is native depth
633 * in 16 bits (uint16_t) width. In other words, for 9-bit
634 * YUV input, this is 9bpc, for 10-bit YUV input, this is
635 * 10bpc, and for 16-bit RGB or YUV, this is 16bpc.
636 * @param filter filter coefficients to be used per output pixel for
637 * scaling. This contains 14bpp filtering coefficients.
638 * Guaranteed to contain dstW * filterSize entries.
639 * @param filterPos position of the first input pixel to be used for
640 * each output pixel during scaling. Guaranteed to
641 * contain dstW entries.
642 * @param filterSize the number of input coefficients to be used (and
643 * thus the number of input pixels to be used) for
644 * creating a single output pixel. Is aligned to 4
645 * (and input coefficients thus padded with zeroes)
646 * to simplify creating SIMD code.
647 */
648 /** @{ */
650 const uint8_t *
src,
const int16_t *
filter,
651 const int32_t *filterPos,
int filterSize);
653 const uint8_t *
src,
const int16_t *
filter,
654 const int32_t *filterPos,
int filterSize);
655 /** @} */
656
657 /// Color range conversion function for luma plane if needed.
659 /// Color range conversion function for chroma planes if needed.
661
663
665
667
668 // scratch buffer for converting packed rgb0 sources
669 // filled with a copy of the input frame + fully opaque alpha,
670 // then passed as input to further conversion
673
674 // scratch buffer for converting XYZ sources
675 // filled with the input converted to rgb48
676 // then passed as input to further conversion
679
683
686 //FIXME check init (where 0)
687
694
696
701
705
707 {
710 return desc->comp[0].depth == 16;
711 }
712
714 {
717 return desc->comp[0].depth == 32;
718 }
719
721 {
724 return desc->comp[0].depth >= 9 &&
desc->comp[0].depth <= 14;
725 }
726
728 {
732 }
733
735 {
739 }
740
742 {
746 }
747
748 /*
749 * Identity semi-planar YUV formats. Specifically, those are YUV formats
750 * where the second and third components (U & V) are on the same plane.
751 */
753 {
757 }
758
760 {
764 }
765
767 {
772 desc->nb_components <= 2 &&
775 }
776
778 {
797 }
798
800 {
819 }
820
822 {
826 }
827
829 {
832 return desc->comp[1].depth == 8;
833 }
834
836 {
841 }
842
844 {
848 }
849
851 {
855 }
856
858 {
862 return 1;
864 }
865
867 {
873 }
874
876 {
880 }
881
883 {
887 }
888
890 {
895 }
896
898 {
906 return 1;
907 default:
908 return 0;
909 }
910 }
911
912 /*
913 * Identity formats where the data is in the high bits, and the low bits are shifted away.
914 */
916 {
921 return 0;
922 for (
i = 0;
i <
desc->nb_components;
i++) {
923 if (!
desc->comp[
i].shift)
924 return 0;
925 if ((
desc->comp[
i].shift +
desc->comp[
i].depth) & 0x7)
926 return 0;
927 }
928 return 1;
929 }
930
931 /*
932 * Identity formats where the chroma planes are swapped (CrCb order).
933 */
935 {
939 return 0;
941 return 0;
942 if (
desc->nb_components < 3)
943 return 0;
945 return desc->comp[1].offset >
desc->comp[2].offset;
946 else
947 return desc->comp[1].plane >
desc->comp[2].plane;
948 }
949
952
960
962
964
965 /**
966 * Set c->convert_unscaled to an unscaled converter if one exists for the
967 * specific source and destination formats, bit depths, flags, etc.
968 */
973
975
992
994 const uint8_t *
src,
int srcW,
int xInc);
996 int dstWidth,
const uint8_t *
src1,
997 const uint8_t *
src2,
int srcW,
int xInc);
1000 int numSplits);
1002 int dstWidth,
const uint8_t *
src,
1003 int srcW,
int xInc);
1005 int dstWidth,
const uint8_t *
src1,
1006 const uint8_t *
src2,
int srcW,
int xInc);
1007
1009 int srcStride[], int srcSliceY, int srcSliceH,
1010 uint8_t *
dst[],
int dstStride[]);
1011
1013 int srcSliceY,
int srcSliceH,
int width,
1014 uint8_t *
dst,
int dstStride);
1015
1017 int alpha,
int bits,
const int big_endian)
1018 {
1019 uint8_t *ptr = plane +
stride * y;
1021 if (big_endian != HAVE_BIGENDIAN)
1024 for (
int j = 0; j <
width; j++)
1027 }
1028 }
1029
1031 int alpha,
int bits,
const int big_endian,
int is_float)
1032 {
1033 uint8_t *ptr = plane +
stride * y;
1034 uint32_t v;
1035 uint32_t onef32 = 0x3f800000;
1036 if (is_float)
1037 v =
alpha ? onef32 : 0;
1038 else
1040 if (big_endian != HAVE_BIGENDIAN)
1042
1044 for (
int j = 0; j <
width; j++)
1047 }
1048 }
1049
1050
1051 #define MAX_SLICE_PLANES 4
1052
1053 /// Slice plane
1055 {
1060 uint8_t **
tmp;
///< Tmp line buffer used by mmx code
1062
1063 /**
1064 * Struct which defines a slice of an image to be scaled or an output for
1065 * a scaled slice.
1066 * A slice can also be used as intermediate ring buffer for scaling steps.
1067 */
1069 {
1073 int is_ring;
///< flag to identify if this slice is a ring buffer
1078
1079 /**
1080 * Struct which holds all necessary data for processing a slice.
1081 * A processing step can be a color conversion or horizontal/vertical scaling.
1082 */
1084 {
1087
1088 int alpha;
///< Flag for processing alpha channel
1090
1091 /// Function for processing input slice sliceH lines starting from line sliceY
1094
1095 // warp input lines in the form (src + width*i + j) to slice format (line[i][j])
1096 // relative=true means first line src[x][0] otherwise first line is src[x][lum/crh Y]
1098
1099 // Initialize scaler filter descriptor chain
1101
1102 // Free all filter data
1104
1105 /*
1106 function for applying ring buffer logic into slice s
1107 It checks if the slice can hold more @lum lines, if yes
1108 do nothing otherwise remove @lum least used lines.
1109 It applies the same procedure for @chr lines.
1110 */
1112
1113 /// initializes gamma conversion descriptor
1115
1116 /// initializes lum pixel format conversion descriptor
1118
1119 /// initializes lum horizontal scaling descriptor
1121
1122 /// initializes chr pixel format conversion descriptor
1124
1125 /// initializes chr horizontal scaling descriptor
1127
1129
1130 /// initializes vertical scaling descriptors
1132
1133 /// setup vertical scaler functions
1137
1139 int nb_jobs, int nb_threads);
1140
1141 //number of extra lines to process
1142 #define MAX_LINES_AHEAD 4
1143
1144 //shuffle filter and filterPos for hyScale and hcScale filters in avx2
1146 #endif /* SWSCALE_SWSCALE_INTERNAL_H */