diff --git a/src/conio/scale.c b/src/conio/scale.c index bcd60d83bb334e42d3b591a1f363d65541d766d3..afddfa3a2acdb14d1ae8f80d141241e7eaa5c927 100644 --- a/src/conio/scale.c +++ b/src/conio/scale.c @@ -352,15 +352,15 @@ do_scale(struct rectlist* rect, int fwidth, int fheight) #if 0 fprintf(stderr, "Plan:\n" -"start: %dx%d\n" +"start: %zux%zu\n" "pointymulti: %d\n" "pointy5: %d\n" "pointy3: %d\n" "xBR4: %d\n" "xBR2: %d\n" "Multiply: %dx%d\n" -"hinterp: %zu -> %zu\n" -"winterp: %zu -> %zu\n", +"hinterp: %zu -> %d\n" +"winterp: %zu -> %d\n", csrc->w, csrc->h, pointymult, pointy5, pointy3, xbr4, xbr2, xmult, ymult, csrc->h * yscale, fheight, csrc->w * xscale, fwidth); #endif // And scale... @@ -762,7 +762,7 @@ struct YCoCg_data { signed Cg; }; -static void +static inline void RGB_to_YCoCg(const uint32_t RGB, struct YCoCg_data *YCoCg) { signed R, G, B, tmp; @@ -777,7 +777,7 @@ RGB_to_YCoCg(const uint32_t RGB, struct YCoCg_data *YCoCg) YCoCg->Y = tmp + (YCoCg->Cg >> 1); } -static uint32_t +static inline uint32_t YCoCg_to_RGB(struct YCoCg_data *YCoCg) { signed Ri, Gi, Bi, tmp; @@ -793,7 +793,7 @@ YCoCg_to_RGB(struct YCoCg_data *YCoCg) return (R << 16) | (G << 8) | B; } -static uint32_t +static inline uint32_t blend_YCoCg(const uint32_t c1, const uint32_t c2, const uint16_t weight) { const uint16_t iw = 65535 - weight; @@ -823,34 +823,41 @@ interpolate_width(uint32_t const* src, uint32_t* dst, const int width, const int int x, y; const double mult = (double)width / newwidth; uint32_t *s = dst; + const int wm1 = width - 1; - for (x = 0; x < newwidth; x++) { - // First, calculate which two pixels this is between. - const double xpos = mult * x; - const int xposi = xpos; - const uint16_t weight = xpos * 65536; - dst = &s[x]; - for (y = 0; y < height; y++) { + int srow_start = 0; + int drow_start = 0; + for (y = 0; y < height; y++) { + double xpos = 0.0; + dst = &s[drow_start]; + for (x = 0; x < newwidth; x++) { + // First, calculate which two pixels this is between. + const int xposi = xpos; + const uint16_t weight = xpos * 65536; + const int yposi = srow_start + xposi; if (weight == 0) { // Exact match! - *dst = src[width * y + xposi]; + *dst = src[yposi]; } else { // Now pick the two pixels - const uint32_t pix1 = src[y * width + xposi]; + const uint32_t pix1 = src[yposi]; uint32_t pix2; - if (xposi < width - 1) - pix2 = src[y * width + xposi + 1]; + if (xposi < wm1) + pix2 = src[yposi + 1]; else - pix2 = src[y * width + xposi]; + pix2 = src[yposi]; if (pix1 == pix2) *dst = pix1; else { *dst = blend_YCoCg(pix1, pix2, weight); } } - dst += newwidth; + xpos += mult; + dst++; } + srow_start += width; + drow_start += newwidth; } } diff --git a/src/conio/xbr.c b/src/conio/xbr.c index 1c4b02e625147c63ba82bf9b16becb2ab567adb3..b817e0385a12f1a79cd5ea07359476e671151cfb 100644 --- a/src/conio/xbr.c +++ b/src/conio/xbr.c @@ -30,7 +30,6 @@ #include <inttypes.h> #include <stdlib.h> -#include "scale.h" #define LB_MASK 0x00FEFEFE #define RED_BLUE_MASK 0x00FF00FF @@ -46,7 +45,7 @@ struct YCoCg_data { signed Cg; }; -static void +static inline void RGB_to_YCoCg(const uint32_t RGB, struct YCoCg_data *YCoCg) { int R, G, B, tmp; @@ -61,7 +60,7 @@ RGB_to_YCoCg(const uint32_t RGB, struct YCoCg_data *YCoCg) YCoCg->Y = tmp + (YCoCg->Cg >> 1); } -static uint32_t pixel_diff(const uint32_t x, const uint32_t y) +static inline uint32_t pixel_diff(const uint32_t x, const uint32_t y) { struct YCoCg_data yccx; struct YCoCg_data yccy; @@ -71,9 +70,9 @@ static uint32_t pixel_diff(const uint32_t x, const uint32_t y) RGB_to_YCoCg(x, &yccx); RGB_to_YCoCg(y, &yccy); - return (ABSDIFF(yccx.Y, yccy.Y)) + - (ABSDIFF(yccx.Co, yccy.Co) >> 1) + - (ABSDIFF(yccx.Cg, yccy.Cg) >> 1); + return (ABSDIFF(yccx.Y, yccy.Y)) + + (ABSDIFF(yccx.Co, yccy.Co) >> 1) + + (ABSDIFF(yccx.Cg, yccy.Cg) >> 1); } #define ALPHA_BLEND_128_W(a, b) ((((a) & LB_MASK) >> 1) + (((b) & LB_MASK) >> 1)) diff --git a/src/syncterm/syncterm.c b/src/syncterm/syncterm.c index c10fad142f53a4227df600912a137bb646e27aba..51469c7b94158bd8483ea22c200578e37acfc794 100644 --- a/src/syncterm/syncterm.c +++ b/src/syncterm/syncterm.c @@ -82,7 +82,6 @@ enum { #include "ssh.h" #endif #include "fonts.h" -#include "scale.h" #include "syncterm.h" #include "term.h" #include "uifcinit.h"