From dd6e02df630fb9921bd8c692b7c9ffbedb1b7984 Mon Sep 17 00:00:00 2001 From: Sylvain Becker Date: Thu, 28 Jan 2021 11:03:45 +0100 Subject: [PATCH] SDL_stretch: remove un-used vars, same notation as blit functions --- src/video/SDL_stretch.c | 135 ++++++++++++++++++++-------------------- 1 file changed, 66 insertions(+), 69 deletions(-) diff --git a/src/video/SDL_stretch.c b/src/video/SDL_stretch.c index 7db638eb5..eec1cc62d 100644 --- a/src/video/SDL_stretch.c +++ b/src/video/SDL_stretch.c @@ -137,29 +137,14 @@ SDL_UpperSoftStretch(SDL_Surface * src, const SDL_Rect * srcrect, same in NEON probably */ #define PRECISION 7 -#define FIXED_POINT(i) ((uint32_t)(i) << 16) -#define SRC_INDEX(fp) ((uint32_t)(fp) >> 16) -#define INTEGER(fp) ((uint32_t)(fp) >> PRECISION) -#define FRAC(fp) ((uint32_t)(fp >> (16 - PRECISION)) & ((1<> 16) +#define INTEGER(fp) ((Uint32)(fp) >> PRECISION) +#define FRAC(fp) ((Uint32)(fp >> (16 - PRECISION)) & ((1<> 16); \ + src_h0 = (const Uint32 *)((const Uint8 *)src_ptr + srcy * src_pitch); \ + posy += incy; \ + posx = 0; \ + n = dst_w; + static int -scale_mat_nearest_1(const Uint32 *src, int src_w, int src_h, int src_pitch, +scale_mat_nearest_1(const Uint32 *src_ptr, int src_w, int src_h, int src_pitch, Uint32 *dst, int dst_w, int dst_h, int dst_pitch) { - const int bpp = 1; - NEAREST___START + Uint32 bpp = 1; + SDL_SCALE_NEAREST__START for (i = 0; i < dst_h; i++) { - BILINEAR___HEIGHT - while (middle--) { - const Uint32 *s_00_01; - int index_w = bpp * SRC_INDEX(fp_sum_w); - fp_sum_w += fp_step_w; - s_00_01 = (const Uint32 *)((const Uint8 *)src_h0 + index_w); - *(Uint8*)dst = *(Uint8*)s_00_01; + SDL_SCALE_NEAREST__HEIGHT + while (n--) { + const Uint8 *src; + int srcx = bpp * (posx >> 16); + posx += incx; + src = (const Uint8 *)src_h0 + srcx; + *(Uint8*)dst = *src; dst = (Uint32 *)((Uint8*)dst + bpp); } dst = (Uint32 *)((Uint8 *)dst + dst_gap); @@ -887,19 +884,19 @@ scale_mat_nearest_1(const Uint32 *src, int src_w, int src_h, int src_pitch, } static int -scale_mat_nearest_2(const Uint32 *src, int src_w, int src_h, int src_pitch, +scale_mat_nearest_2(const Uint32 *src_ptr, int src_w, int src_h, int src_pitch, Uint32 *dst, int dst_w, int dst_h, int dst_pitch) { - const int bpp = 2; - NEAREST___START + Uint32 bpp = 2; + SDL_SCALE_NEAREST__START for (i = 0; i < dst_h; i++) { - BILINEAR___HEIGHT - while (middle--) { - const Uint32 *s_00_01; - int index_w = bpp * SRC_INDEX(fp_sum_w); - fp_sum_w += fp_step_w; - s_00_01 = (const Uint32 *)((const Uint8 *)src_h0 + index_w); - *(Uint16*)dst = *(Uint16*)s_00_01; + SDL_SCALE_NEAREST__HEIGHT + while (n--) { + const Uint16 *src; + int srcx = bpp * (posx >> 16); + posx += incx; + src = (const Uint16 *)((const Uint8 *)src_h0 + srcx); + *(Uint16*)dst = *src; dst = (Uint32 *)((Uint8*)dst + bpp); } dst = (Uint32 *)((Uint8 *)dst + dst_gap); @@ -908,21 +905,21 @@ scale_mat_nearest_2(const Uint32 *src, int src_w, int src_h, int src_pitch, } static int -scale_mat_nearest_3(const Uint32 *src, int src_w, int src_h, int src_pitch, +scale_mat_nearest_3(const Uint32 *src_ptr, int src_w, int src_h, int src_pitch, Uint32 *dst, int dst_w, int dst_h, int dst_pitch) { - const int bpp = 3; - NEAREST___START + Uint32 bpp = 3; + SDL_SCALE_NEAREST__START for (i = 0; i < dst_h; i++) { - BILINEAR___HEIGHT - while (middle--) { - const Uint32 *s_00_01; - int index_w = bpp * SRC_INDEX(fp_sum_w); - fp_sum_w += fp_step_w; - s_00_01 = (const Uint32 *)((const Uint8 *)src_h0 + index_w); - ((Uint8*)dst)[0] = ((Uint8*)s_00_01)[0]; - ((Uint8*)dst)[1] = ((Uint8*)s_00_01)[1]; - ((Uint8*)dst)[2] = ((Uint8*)s_00_01)[2]; + SDL_SCALE_NEAREST__HEIGHT + while (n--) { + const Uint8 *src; + int srcx = bpp * (posx >> 16); + posx += incx; + src = (const Uint8 *)src_h0 + srcx; + ((Uint8*)dst)[0] = src[0]; + ((Uint8*)dst)[1] = src[1]; + ((Uint8*)dst)[2] = src[2]; dst = (Uint32 *)((Uint8*)dst + bpp); } dst = (Uint32 *)((Uint8 *)dst + dst_gap); @@ -931,19 +928,19 @@ scale_mat_nearest_3(const Uint32 *src, int src_w, int src_h, int src_pitch, } static int -scale_mat_nearest_4(const Uint32 *src, int src_w, int src_h, int src_pitch, +scale_mat_nearest_4(const Uint32 *src_ptr, int src_w, int src_h, int src_pitch, Uint32 *dst, int dst_w, int dst_h, int dst_pitch) { - int bpp = 4; - NEAREST___START + Uint32 bpp = 4; + SDL_SCALE_NEAREST__START for (i = 0; i < dst_h; i++) { - BILINEAR___HEIGHT - while (middle--) { - const Uint32 *s_00_01; - int index_w = bpp * SRC_INDEX(fp_sum_w); - fp_sum_w += fp_step_w; - s_00_01 = (const Uint32 *)((const Uint8 *)src_h0 + index_w); - *dst = *s_00_01; + SDL_SCALE_NEAREST__HEIGHT + while (n--) { + const Uint32 *src; + int srcx = bpp * (posx >> 16); + posx += incx; + src = (const Uint32 *)((const Uint8 *)src_h0 + srcx); + *dst = *src; dst = (Uint32 *)((Uint8*)dst + bpp); } dst = (Uint32 *)((Uint8 *)dst + dst_gap);