diff options
author | neonloop | 2023-12-16 16:43:16 +0000 |
---|---|---|
committer | neonloop | 2023-12-16 16:43:16 +0000 |
commit | 9c5c2c803c54f2f2ebef4f9cb946117bc414a5fa (patch) | |
tree | a275011084470c838587a0980adbb7ca7c4fb958 | |
parent | a2910e9de26676553a3360dd1d7bdb75ac9b0487 (diff) | |
download | picoarch-main.tar.gz picoarch-main.tar.bz2 picoarch-main.zip |
Avoids entirely missing lines and pixels, improves downscale smoothness
-rw-r--r-- | scale.c | 20 |
1 files changed, 17 insertions, 3 deletions
@@ -186,7 +186,19 @@ static void scale_blend(unsigned w, unsigned h, size_t pitch, const void *src, v if (!lines) pnext -= (pitch / sizeof(uint16_t)); - if (dy > rat_dst_h - bh[0]) { + if (dy <= bh[0] && dy + rat_h > (rat_dst_h + rat_dst_h - bh[0])) { + /* Will miss next line, blend in instead */ + const uint32_t *src32 = (const uint32_t *)src; + const uint32_t *pnext32 = (const uint32_t *)pnext; + uint32_t *pblend32 = (uint32_t *)pblend; + int count = w / 2; + + while(count--) { + *pblend32++ = AVERAGE32(*src32, *pnext32); + src32++; + pnext32++; + } + } else if (dy > rat_dst_h - bh[0]) { pblend = pnext; } else if (dy <= bh[0]) { /* Drops const, won't get touched later though */ @@ -227,15 +239,17 @@ static void scale_blend(unsigned w, unsigned h, size_t pitch, const void *src, v while (dx < rat_dst_w) { if (a == b) { out = a; + } else if (dx <= bw[0] && dx + rat_w > (rat_dst_w + rat_dst_w - bw[0])) { + out = AVERAGE16_NOCHK(a, b); // will miss next pixel, blend in instead } else if (dx > rat_dst_w - bw[0]) { // top quintile, bbbb out = b; } else if (dx <= bw[0]) { // last quintile, aaaa out = a; } else { if (dx > rat_dst_w - bw[1]) { // 2nd quintile, abbb - a = AVERAGE16_NOCHK(a,b); + a = AVERAGE16_NOCHK(a, b); } else if (dx <= bw[1]) { // 4th quintile, aaab - b = AVERAGE16_NOCHK(a,b); + b = AVERAGE16_NOCHK(a, b); } out = AVERAGE16_NOCHK(a, b); // also 3rd quintile, aabb |