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"
28
40
41 #define STR(s) AV_TOSTRING(s) // AV_STRINGIFY is too long
42
43 #define YUVRGB_TABLE_HEADROOM 512
44 #define YUVRGB_TABLE_LUMA_HEADROOM 512
45
46 #define MAX_FILTER_SIZE SWS_MAX_FILTER_SIZE
47
49
50 #if HAVE_BIGENDIAN
51 #define ALT32_CORR (-1)
52 #else
54 #endif
55
56 #if ARCH_X86_64
57 # define APCK_PTR2 8
58 # define APCK_COEF 16
59 # define APCK_SIZE 24
60 #else
64 #endif
65
66 #define RETCODE_USE_CASCADE -12345
67
69
79
86
87 typedef struct Range {
91
97
99
101 int srcStride[],
int srcSliceY,
int srcSliceH,
102 uint8_t *dst[], int dstStride[]);
103
104 /**
105 * Write one line of horizontally scaled data to planar output
106 * without any additional vertical scaling (or point-scaling).
107 *
108 * @param src scaled source data, 15 bits for 8-10-bit output,
109 * 19 bits for 16-bit output (in int32_t)
110 * @param dest pointer to the output plane. For >8-bit
111 * output, this is in uint16_t
112 * @param dstW width of destination in pixels
113 * @param dither ordered dither array of type int16_t and size 8
114 * @param offset Dither offset
115 */
118
119 /**
120 * Write one line of horizontally scaled data to planar output
121 * with multi-point vertical scaling between input pixels.
122 *
123 * @param filter vertical luma/alpha scaling coefficients, 12 bits [0,4096]
124 * @param src scaled luma (Y) or alpha (A) source data, 15 bits for
125 * 8-10-bit output, 19 bits for 16-bit output (in int32_t)
126 * @param filterSize number of vertical input lines to scale
127 * @param dest pointer to output plane. For >8-bit
128 * output, this is in uint16_t
129 * @param dstW width of destination pixels
130 * @param offset Dither offset
131 */
133 const int16_t **
src, uint8_t *dest,
int dstW,
135
136 /**
137 * Write one line of horizontally scaled chroma to interleaved output
138 * with multi-point vertical scaling between input pixels.
139 *
140 * @param dstFormat destination pixel format
141 * @param chrDither ordered dither array of type uint8_t and size 8
142 * @param chrFilter vertical chroma scaling coefficients, 12 bits [0,4096]
143 * @param chrUSrc scaled chroma (U) source data, 15 bits for 8-10-bit
144 * output, 19 bits for 16-bit output (in int32_t)
145 * @param chrVSrc scaled chroma (V) source data, 15 bits for 8-10-bit
146 * output, 19 bits for 16-bit output (in int32_t)
147 * @param chrFilterSize number of vertical chroma input lines to scale
148 * @param dest pointer to the output plane. For >8-bit
149 * output, this is in uint16_t
150 * @param dstW width of chroma planes
151 */
153 const uint8_t *chrDither,
154 const int16_t *chrFilter,
155 int chrFilterSize,
156 const int16_t **chrUSrc,
157 const int16_t **chrVSrc,
158 uint8_t *dest,
int dstW);
159
160 /**
161 * Write one line of horizontally scaled Y/U/V/A to packed-pixel YUV/RGB
162 * output without any additional vertical scaling (or point-scaling). Note
163 * that this function may do chroma scaling, see the "uvalpha" argument.
164 *
165 * @param c SWS scaling context
166 * @param lumSrc scaled luma (Y) source data, 15 bits for 8-10-bit output,
167 * 19 bits for 16-bit output (in int32_t)
168 * @param chrUSrc scaled chroma (U) source data, 15 bits for 8-10-bit output,
169 * 19 bits for 16-bit output (in int32_t)
170 * @param chrVSrc scaled chroma (V) source data, 15 bits for 8-10-bit output,
171 * 19 bits for 16-bit output (in int32_t)
172 * @param alpSrc scaled alpha (A) source data, 15 bits for 8-10-bit output,
173 * 19 bits for 16-bit output (in int32_t)
174 * @param dest pointer to the output plane. For 16-bit output, this is
175 * uint16_t
176 * @param dstW width of lumSrc and alpSrc in pixels, number of pixels
177 * to write into dest[]
178 * @param uvalpha chroma scaling coefficient for the second line of chroma
179 * pixels, either 2048 or 0. If 0, one chroma input is used
180 * for 2 output pixels (or if the SWS_FLAG_FULL_CHR_INT flag
181 * is set, it generates 1 output pixel). If 2048, two chroma
182 * input pixels should be averaged for 2 output pixels (this
183 * only happens if SWS_FLAG_FULL_CHR_INT is not set)
184 * @param y vertical line number for this output. This does not need
185 * to be used to calculate the offset in the destination,
186 * but can be used to generate comfort noise using dithering
187 * for some output formats.
188 */
190 const int16_t *chrUSrc[2],
191 const int16_t *chrVSrc[2],
192 const int16_t *alpSrc, uint8_t *dest,
193 int dstW,
int uvalpha,
int y);
194 /**
195 * Write one line of horizontally scaled Y/U/V/A to packed-pixel YUV/RGB
196 * output by doing bilinear scaling between two input lines.
197 *
198 * @param c SWS scaling context
199 * @param lumSrc scaled luma (Y) source data, 15 bits for 8-10-bit output,
200 * 19 bits for 16-bit output (in int32_t)
201 * @param chrUSrc scaled chroma (U) source data, 15 bits for 8-10-bit output,
202 * 19 bits for 16-bit output (in int32_t)
203 * @param chrVSrc scaled chroma (V) source data, 15 bits for 8-10-bit output,
204 * 19 bits for 16-bit output (in int32_t)
205 * @param alpSrc scaled alpha (A) source data, 15 bits for 8-10-bit output,
206 * 19 bits for 16-bit output (in int32_t)
207 * @param dest pointer to the output plane. For 16-bit output, this is
208 * uint16_t
209 * @param dstW width of lumSrc and alpSrc in pixels, number of pixels
210 * to write into dest[]
211 * @param yalpha luma/alpha scaling coefficients for the second input line.
212 * The first line's coefficients can be calculated by using
213 * 4096 - yalpha
214 * @param uvalpha chroma scaling coefficient for the second input line. The
215 * first line's coefficients can be calculated by using
216 * 4096 - uvalpha
217 * @param y vertical line number for this output. This does not need
218 * to be used to calculate the offset in the destination,
219 * but can be used to generate comfort noise using dithering
220 * for some output formats.
221 */
223 const int16_t *chrUSrc[2],
224 const int16_t *chrVSrc[2],
225 const int16_t *alpSrc[2],
226 uint8_t *dest,
227 int dstW,
int yalpha,
int uvalpha,
int y);
228 /**
229 * Write one line of horizontally scaled Y/U/V/A to packed-pixel YUV/RGB
230 * output by doing multi-point vertical scaling between input pixels.
231 *
232 * @param c SWS scaling context
233 * @param lumFilter vertical luma/alpha scaling coefficients, 12 bits [0,4096]
234 * @param lumSrc scaled luma (Y) source data, 15 bits for 8-10-bit output,
235 * 19 bits for 16-bit output (in int32_t)
236 * @param lumFilterSize number of vertical luma/alpha input lines to scale
237 * @param chrFilter vertical chroma scaling coefficients, 12 bits [0,4096]
238 * @param chrUSrc scaled chroma (U) source data, 15 bits for 8-10-bit output,
239 * 19 bits for 16-bit output (in int32_t)
240 * @param chrVSrc scaled chroma (V) source data, 15 bits for 8-10-bit output,
241 * 19 bits for 16-bit output (in int32_t)
242 * @param chrFilterSize number of vertical chroma input lines to scale
243 * @param alpSrc scaled alpha (A) source data, 15 bits for 8-10-bit output,
244 * 19 bits for 16-bit output (in int32_t)
245 * @param dest pointer to the output plane. For 16-bit output, this is
246 * uint16_t
247 * @param dstW width of lumSrc and alpSrc in pixels, number of pixels
248 * to write into dest[]
249 * @param y vertical line number for this output. This does not need
250 * to be used to calculate the offset in the destination,
251 * but can be used to generate comfort noise using dithering
252 * or some output formats.
253 */
255 const int16_t **lumSrc, int lumFilterSize,
256 const int16_t *chrFilter,
257 const int16_t **chrUSrc,
258 const int16_t **chrVSrc, int chrFilterSize,
259 const int16_t **alpSrc, uint8_t *dest,
261
262 /**
263 * Write one line of horizontally scaled Y/U/V/A to YUV/RGB
264 * output by doing multi-point vertical scaling between input pixels.
265 *
266 * @param c SWS scaling context
267 * @param lumFilter vertical luma/alpha scaling coefficients, 12 bits [0,4096]
268 * @param lumSrc scaled luma (Y) source data, 15 bits for 8-10-bit output,
269 * 19 bits for 16-bit output (in int32_t)
270 * @param lumFilterSize number of vertical luma/alpha input lines to scale
271 * @param chrFilter vertical chroma scaling coefficients, 12 bits [0,4096]
272 * @param chrUSrc scaled chroma (U) source data, 15 bits for 8-10-bit output,
273 * 19 bits for 16-bit output (in int32_t)
274 * @param chrVSrc scaled chroma (V) source data, 15 bits for 8-10-bit output,
275 * 19 bits for 16-bit output (in int32_t)
276 * @param chrFilterSize number of vertical chroma input lines to scale
277 * @param alpSrc scaled alpha (A) source data, 15 bits for 8-10-bit output,
278 * 19 bits for 16-bit output (in int32_t)
279 * @param dest pointer to the output planes. For 16-bit output, this is
280 * uint16_t
281 * @param dstW width of lumSrc and alpSrc in pixels, number of pixels
282 * to write into dest[]
283 * @param y vertical line number for this output. This does not need
284 * to be used to calculate the offset in the destination,
285 * but can be used to generate comfort noise using dithering
286 * or some output formats.
287 */
289 const int16_t **lumSrc, int lumFilterSize,
290 const int16_t *chrFilter,
291 const int16_t **chrUSrc,
292 const int16_t **chrVSrc, int chrFilterSize,
293 const int16_t **alpSrc, uint8_t **dest,
295
298
299 /* This struct should be aligned on at least a 32-byte boundary. */
301 /**
302 * info on struct for av_log
303 */
305
307
312
313 // values passed to current sws_receive_slice() call
316
317 /**
318 * Note that src, dst, srcStride, dstStride will be copied in the
319 * sws_scale() wrapper so they can be freely modified here.
320 */
322 int srcW;
///< Width of source luma/alpha planes.
323 int srcH;
///< Height of source luma/alpha planes.
324 int dstH;
///< Height of destination luma/alpha planes.
325 int chrSrcW;
///< Width of source chroma planes.
326 int chrSrcH;
///< Height of source chroma planes.
327 int chrDstW;
///< Width of destination chroma planes.
328 int chrDstH;
///< Height of destination chroma planes.
333 int dstFormatBpp;
///< Number of bits per pixel of the destination pixel format.
334 int srcFormatBpp;
///< Number of bits per pixel of the source pixel format.
336 int chrSrcHSubSample;
///< Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in source image.
337 int chrSrcVSubSample;
///< Binary logarithm of vertical subsampling factor between luma/alpha and chroma planes in source image.
338 int chrDstHSubSample;
///< Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in destination image.
339 int chrDstVSubSample;
///< Binary logarithm of vertical subsampling factor between luma/alpha and chroma planes in destination image.
340 int vChrDrop;
///< Binary logarithm of extra vertical subsampling factor in source image chroma planes specified by user.
341 int sliceDir;
///< Direction that slices are fed to the scaler (1 = top-to-bottom, -1 = bottom-to-top).
343 double param[2];
///< Input parameters for scaling algorithms that need them.
344
347
349
350 /* The cascaded_* fields allow spliting a scaler task into multiple
351 * sequential steps, this is for example used to limit the maximum
352 * downscaling factor that needs to be supported in one scaler.
353 */
360
366
372
375
377
378 /**
379 * @name Scaled horizontal lines ring buffer.
380 * The horizontal scaler keeps just enough scaled lines in a ring buffer
381 * so they may be passed to the vertical scaler. The pointers to the
382 * allocated buffers for each line are duplicated in sequence in the ring
383 * buffer to simplify indexing and avoid wrapping around between lines
384 * inside the vertical scaler code. The wrapping is done before the
385 * vertical scaler is called.
386 */
387 //@{
388 int lastInLumBuf;
///< Last scaled horizontal luma/alpha line from source in the ring buffer.
389 int lastInChrBuf;
///< Last scaled horizontal chroma line from source in the ring buffer.
390 //@}
391
394
395 /**
396 * @name Horizontal and vertical filters.
397 * To better understand the following fields, here is a pseudo-code of
398 * their usage in filtering a horizontal line:
399 * @code
400 * for (i = 0; i < width; i++) {
401 * dst[i] = 0;
402 * for (j = 0; j < filterSize; j++)
403 * dst[i] += src[ filterPos[i] + j ] * filter[ filterSize * i + j ];
404 * dst[i] >>= FRAC_BITS; // The actual implementation is fixed-point.
405 * }
406 * @endcode
407 */
408 //@{
409 int16_t *
hLumFilter;
///< Array of horizontal filter coefficients for luma/alpha planes.
410 int16_t *
hChrFilter;
///< Array of horizontal filter coefficients for chroma planes.
411 int16_t *
vLumFilter;
///< Array of vertical filter coefficients for luma/alpha planes.
412 int16_t *
vChrFilter;
///< Array of vertical filter coefficients for chroma planes.
413 int32_t *
hLumFilterPos;
///< Array of horizontal filter starting positions for each dst[i] for luma/alpha planes.
415 int32_t *
vLumFilterPos;
///< Array of vertical filter starting positions for each dst[i] for luma/alpha planes.
421 //@}
422
425 uint8_t *
lumMmxextFilterCode;
///< Runtime-generated MMXEXT horizontal fast bilinear scaler code for luma/alpha planes.
426 uint8_t *
chrMmxextFilterCode;
///< Runtime-generated MMXEXT horizontal fast bilinear scaler code for chroma planes.
427
430
431 int dstY;
///< Last destination vertical line output from last slice.
432 int flags;
///< Flags passed by the user to select scaler algorithm, optimizations, subsampling, etc...
433 void *
yuvTable;
// pointer to the yuv->rgb table start so it can be freed()
434 // alignment ensures the offset can be added in a single
435 // instruction on e.g. ARM
450 #define RGB2YUV_SHIFT 15
451
453
454 //Colorspace stuff
458 int srcRange;
///< 0 = MPG YUV range, 1 = JPG YUV range (source image).
459 int dstRange;
///< 0 = MPG YUV range, 1 = JPG YUV range (destination image).
474
475 #define RED_DITHER "0*8"
476 #define GREEN_DITHER "1*8"
477 #define BLUE_DITHER "2*8"
478 #define Y_COEFF "3*8"
479 #define VR_COEFF "4*8"
480 #define UB_COEFF "5*8"
481 #define VG_COEFF "6*8"
482 #define UG_COEFF "7*8"
483 #define Y_OFFSET "8*8"
484 #define U_OFFSET "9*8"
485 #define V_OFFSET "10*8"
486 #define LUM_MMX_FILTER_OFFSET "11*8"
487 #define CHR_MMX_FILTER_OFFSET "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)
488 #define DSTW_OFFSET "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2"
489 #define ESP_OFFSET "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+8"
490 #define VROUNDER_OFFSET "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+16"
491 #define U_TEMP "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+24"
492 #define V_TEMP "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+32"
493 #define Y_TEMP "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+40"
494 #define ALP_MMX_FILTER_OFFSET "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+48"
495 #define UV_OFF_PX "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*3+48"
496 #define UV_OFF_BYTE "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*3+56"
497 #define DITHER16 "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*3+64"
498 #define DITHER32 "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*3+80"
499 #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
500
504
515 int dstW;
///< Width of destination luma/alpha planes.
522 // alignment of these values is not necessary, but merely here
523 // to maintain the same offset across x8632 and x86-64. Once we
524 // use proper offset macros in the asm, they can be removed.
529
531
532 #if HAVE_ALTIVEC
533 vector
signed short CY;
534 vector signed short CRV;
535 vector signed short CBU;
536 vector signed short CGU;
537 vector signed short CGV;
538 vector signed short OY;
539 vector
unsigned short CSHIFT;
540 vector signed short *vYCoeffsBank, *vCCoeffsBank;
541 #endif
542
544
545 /* pre defined color-spaces gamma */
546 #define XYZ_GAMMA (2.6f)
547 #define RGB_GAMMA (2.2f)
554
555 /* function pointers for swscale() */
563
564 /// Unscaled conversion of luma plane to YV12 for horizontal scaler.
565 void (*
lumToYV12)(uint8_t *
dst,
const uint8_t *
src,
const uint8_t *src2,
const uint8_t *src3,
566 int width, uint32_t *pal);
567 /// Unscaled conversion of alpha plane to YV12 for horizontal scaler.
568 void (*
alpToYV12)(uint8_t *
dst,
const uint8_t *
src,
const uint8_t *src2,
const uint8_t *src3,
569 int width, uint32_t *pal);
570 /// Unscaled conversion of chroma planes to YV12 for horizontal scaler.
572 const uint8_t *
src1,
const uint8_t *src2,
const uint8_t *src3,
573 int width, uint32_t *pal);
574
575 /**
576 * Functions to read planar input, such as planar RGB, and convert
577 * internally to Y/UV/A.
578 */
579 /** @{ */
584 /** @} */
585
586 /**
587 * Scale one horizontal line of input data using a bilinear filter
588 * to produce one line of output data. Compared to SwsContext->hScale(),
589 * please take note of the following caveats when using these:
590 * - Scaling is done using only 7 bits instead of 14-bit coefficients.
591 * - You can use no more than 5 input pixels to produce 4 output
592 * pixels. Therefore, this filter should not be used for downscaling
593 * by more than ~20% in width (because that equals more than 5/4th
594 * downscaling and thus more than 5 pixels input per 4 pixels output).
595 * - In general, bilinear filters create artifacts during downscaling
596 * (even when <20%), because one output pixel will span more than one
597 * input pixel, and thus some pixels will need edges of both neighbor
598 * pixels to interpolate the output pixel. Since you can use at most
599 * two input pixels per output pixel in bilinear scaling, this is
600 * impossible and thus downscaling by any size will create artifacts.
601 * To enable this type of scaling, set SWS_FLAG_FAST_BILINEAR
602 * in SwsContext->flags.
603 */
604 /** @{ */
606 int16_t *dst, int dstWidth,
607 const uint8_t *
src,
int srcW,
int xInc);
609 int16_t *dst1, int16_t *dst2, int dstWidth,
610 const uint8_t *
src1,
const uint8_t *src2,
612 /** @} */
613
614 /**
615 * Scale one horizontal line of input data using a filter over the input
616 * lines, to produce one (differently sized) line of output data.
617 *
618 * @param dst pointer to destination buffer for horizontally scaled
619 * data. If the number of bits per component of one
620 * destination pixel (SwsContext->dstBpc) is <= 10, data
621 * will be 15 bpc in 16 bits (int16_t) width. Else (i.e.
622 * SwsContext->dstBpc == 16), data will be 19bpc in
623 * 32 bits (int32_t) width.
624 * @param dstW width of destination image
625 * @param src pointer to source data to be scaled. If the number of
626 * bits per component of a source pixel (SwsContext->srcBpc)
627 * is 8, this is 8bpc in 8 bits (uint8_t) width. Else
628 * (i.e. SwsContext->dstBpc > 8), this is native depth
629 * in 16 bits (uint16_t) width. In other words, for 9-bit
630 * YUV input, this is 9bpc, for 10-bit YUV input, this is
631 * 10bpc, and for 16-bit RGB or YUV, this is 16bpc.
632 * @param filter filter coefficients to be used per output pixel for
633 * scaling. This contains 14bpp filtering coefficients.
634 * Guaranteed to contain dstW * filterSize entries.
635 * @param filterPos position of the first input pixel to be used for
636 * each output pixel during scaling. Guaranteed to
637 * contain dstW entries.
638 * @param filterSize the number of input coefficients to be used (and
639 * thus the number of input pixels to be used) for
640 * creating a single output pixel. Is aligned to 4
641 * (and input coefficients thus padded with zeroes)
642 * to simplify creating SIMD code.
643 */
644 /** @{ */
646 const uint8_t *
src,
const int16_t *
filter,
647 const int32_t *filterPos,
int filterSize);
649 const uint8_t *
src,
const int16_t *
filter,
650 const int32_t *filterPos,
int filterSize);
651 /** @} */
652
653 /// Color range conversion function for luma plane if needed.
655 /// Color range conversion function for chroma planes if needed.
657
659
661
663
664 // scratch buffer for converting packed rgb0 sources
665 // filled with a copy of the input frame + fully opaque alpha,
666 // then passed as input to further conversion
669
670 // scratch buffer for converting XYZ sources
671 // filled with the input converted to rgb48
672 // then passed as input to further conversion
675
680 //FIXME check init (where 0)
681
688
690
692
695
697 {
700 return desc->comp[0].depth == 16;
701 }
702
704 {
707 return desc->comp[0].depth == 32;
708 }
709
711 {
714 return desc->comp[0].depth >= 9 &&
desc->comp[0].depth <= 14;
715 }
716
718 {
722 }
723
725 {
729 }
730
732 {
736 }
737
738 /*
739 * Identity semi-planar YUV formats. Specifically, those are YUV formats
740 * where the second and third components (U & V) are on the same plane.
741 */
743 {
747 }
748
750 {
754 }
755
757 {
762 desc->nb_components <= 2 &&
765 }
766
768 {
787 }
788
790 {
809 }
810
812 {
816 }
817
819 {
822 return desc->comp[1].depth == 8;
823 }
824
826 {
831 }
832
834 {
838 }
839
841 {
845 return 1;
847 }
848
850 {
856 }
857
859 {
863 }
864
866 {
870 }
871
873 {
878 }
879
881 {
889 return 1;
890 default:
891 return 0;
892 }
893 }
894
895 /*
896 * Identity formats where the data is in the high bits, and the low bits are shifted away.
897 */
899 {
904 return 0;
905 for (
i = 0;
i <
desc->nb_components;
i++) {
906 if (!
desc->comp[
i].shift)
907 return 0;
908 if ((
desc->comp[
i].shift +
desc->comp[
i].depth) & 0x7)
909 return 0;
910 }
911 return 1;
912 }
913
914 /*
915 * Identity formats where the chroma planes are swapped (CrCb order).
916 */
918 {
922 return 0;
924 return 0;
925 if (
desc->nb_components < 3)
926 return 0;
928 return desc->comp[1].offset >
desc->comp[2].offset;
929 else
930 return desc->comp[1].plane >
desc->comp[2].plane;
931 }
932
935
943
945
947
948 /**
949 * Set c->convert_unscaled to an unscaled converter if one exists for the
950 * specific source and destination formats, bit depths, flags, etc.
951 */
956
958
973
975 const uint8_t *
src,
int srcW,
int xInc);
977 int dstWidth,
const uint8_t *
src1,
978 const uint8_t *src2,
int srcW,
int xInc);
981 int numSplits);
983 int dstWidth,
const uint8_t *
src,
986 int dstWidth,
const uint8_t *
src1,
987 const uint8_t *src2,
int srcW,
int xInc);
988
989 /**
990 * Allocate and return an SwsContext.
991 * This is like sws_getContext() but does not perform the init step, allowing
992 * the user to set additional AVOptions.
993 *
994 * @see sws_getContext()
995 */
999
1001 int srcStride[],
int srcSliceY,
int srcSliceH,
1002 uint8_t *dst[], int dstStride[]);
1003
1005 int alpha,
int bits,
const int big_endian)
1006 {
1008 uint8_t *ptr = plane +
stride * y;
1011 #define FILL(wfunc) \
1012 for (j = 0; j < width; j++) {\
1013 wfunc(ptr+2*j, v);\
1014 }
1015 if (big_endian) {
1017 } else {
1019 }
1021 }
1022 #undef FILL
1023 }
1024
1026 int alpha,
int bits,
const int big_endian,
int is_float)
1027 {
1029 uint8_t *ptr = plane +
stride * y;
1030 uint32_t v;
1031 uint32_t onef32 = 0x3f800000;
1032 if (is_float)
1033 v =
alpha ? onef32 : 0;
1034 else
1036
1038 #define FILL(wfunc) \
1039 for (j = 0; j < width; j++) {\
1040 wfunc(ptr+4*j, v);\
1041 }
1042 if (big_endian) {
1044 } else {
1046 }
1048 }
1049 #undef FILL
1050 }
1051
1052
1053 #define MAX_SLICE_PLANES 4
1054
1055 /// Slice plane
1057 {
1062 uint8_t **
tmp;
///< Tmp line buffer used by mmx code
1064
1065 /**
1066 * Struct which defines a slice of an image to be scaled or an output for
1067 * a scaled slice.
1068 * A slice can also be used as intermediate ring buffer for scaling steps.
1069 */
1071 {
1075 int is_ring;
///< flag to identify if this slice is a ring buffer
1080
1081 /**
1082 * Struct which holds all necessary data for processing a slice.
1083 * A processing step can be a color conversion or horizontal/vertical scaling.
1084 */
1086 {
1089
1090 int alpha;
///< Flag for processing alpha channel
1092
1093 /// Function for processing input slice sliceH lines starting from line sliceY
1096
1097 // warp input lines in the form (src + width*i + j) to slice format (line[i][j])
1098 // relative=true means first line src[x][0] otherwise first line is src[x][lum/crh Y]
1100
1101 // Initialize scaler filter descriptor chain
1103
1104 // Free all filter data
1106
1107 /*
1108 function for applying ring buffer logic into slice s
1109 It checks if the slice can hold more @lum lines, if yes
1110 do nothing otherwise remove @lum least used lines.
1111 It applies the same procedure for @chr lines.
1112 */
1114
1115 /// initializes gamma conversion descriptor
1117
1118 /// initializes lum pixel format conversion descriptor
1120
1121 /// initializes lum horizontal scaling descriptor
1123
1124 /// initializes chr pixel format conversion descriptor
1126
1127 /// initializes chr horizontal scaling descriptor
1129
1131
1132 /// initializes vertical scaling descriptors
1134
1135 /// setup vertical scaler functions
1139
1141 int nb_jobs, int nb_threads);
1142
1143 //number of extra lines to process
1144 #define MAX_LINES_AHEAD 4
1145
1146 //shuffle filter and filterPos for hyScale and hcScale filters in avx2
1148 #endif /* SWSCALE_SWSCALE_INTERNAL_H */