Skip to content
Snippets Groups Projects
Commit 6e30bb63 authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Remove cases where pointy falls back to blocky.

parent 30a163fa
No related branches found
No related tags found
No related merge requests found
Pipeline #6883 passed
...@@ -11,12 +11,12 @@ ...@@ -11,12 +11,12 @@
#pragma warning(disable : 4244 4267 4018) #pragma warning(disable : 4244 4267 4018)
#endif #endif
static void pointy_scale3(uint32_t* src, uint32_t* dest, int width, int height); static void pointy_scale3(const uint32_t* src, uint32_t* dest, const int width, const int height);
static void pointy_scale5(uint32_t* src, uint32_t* dest, int width, int height); static void pointy_scale5(const uint32_t* src, uint32_t* dest, const int width, const int height);
static void pointy_scale_odd(uint32_t* src, uint32_t* dest, int width, int height, int mult); static void pointy_scale_odd(const uint32_t* src, uint32_t* dest, const int width, const int height, const int mult);
static void interpolate_height(uint32_t* src, uint32_t* dst, int width, int height, int newheight); static void interpolate_height(uint32_t const* src, uint32_t* dst, const int width, const int height, const int newheight);
static void interpolate_width(uint32_t* src, uint32_t* dst, int width, int height, int newwidth); static void interpolate_width(uint32_t const* src, uint32_t* dst, const int width, const int height, const int newwidth);
static void multiply_scale(uint32_t* src, uint32_t* dst, int width, int height, int xmult, int ymult); static void multiply_scale(uint32_t const* src, uint32_t* dst, const int width, const int height, const int xmult, const int ymult);
static struct graphics_buffer *free_list; static struct graphics_buffer *free_list;
...@@ -231,6 +231,7 @@ do_scale(struct rectlist* rect, int fwidth, int fheight) ...@@ -231,6 +231,7 @@ do_scale(struct rectlist* rect, int fwidth, int fheight)
int xmult = 1; int xmult = 1;
int total_xscaling = 1; int total_xscaling = 1;
int total_yscaling = 1; int total_yscaling = 1;
int minscale = 1;
struct graphics_buffer *ctarget; struct graphics_buffer *ctarget;
struct graphics_buffer *csrc; struct graphics_buffer *csrc;
uint32_t* nt; uint32_t* nt;
...@@ -249,44 +250,51 @@ do_scale(struct rectlist* rect, int fwidth, int fheight) ...@@ -249,44 +250,51 @@ do_scale(struct rectlist* rect, int fwidth, int fheight)
xscale = 1; xscale = 1;
total_yscaling = yscale; total_yscaling = yscale;
yscale = 1; yscale = 1;
if (total_xscaling < total_yscaling)
minscale = total_xscaling;
else
minscale = total_yscaling;
// If x/y scaling isn't a simple multiple, block scale everything... // If x/y scaling isn't a simple multiple, block scale everything...
if ((total_yscaling % total_xscaling) == 0) {
if (!(cio_api.options & CONIO_OPT_BLOCKY_SCALING)) { if (!(cio_api.options & CONIO_OPT_BLOCKY_SCALING)) {
if ((total_xscaling & 1) == 1 && total_xscaling > 5) { if ((minscale & 1) == 1 && minscale > 5) {
pointymult = total_xscaling; pointymult = total_xscaling;
total_xscaling /= pointymult; total_xscaling /= pointymult;
xscale *= pointymult; xscale *= pointymult;
total_yscaling /= pointymult; total_yscaling /= pointymult;
yscale *= pointymult; yscale *= pointymult;
minscale /= pointymult;
} }
while (total_xscaling > 1 && ((total_xscaling % 5) == 0) && ((total_yscaling % 5) == 0)) { while (minscale > 1 && ((minscale % 5) == 0) && ((minscale % 5) == 0)) {
pointy5++; pointy5++;
total_xscaling /= 5; total_xscaling /= 5;
xscale *= 5; xscale *= 5;
total_yscaling /= 5; total_yscaling /= 5;
yscale *= 5; yscale *= 5;
minscale /= 5;
} }
while (total_xscaling > 1 && ((total_xscaling % 3) == 0) && ((total_yscaling % 3) == 0)) { while (minscale > 1 && ((minscale % 3) == 0) && ((minscale % 3) == 0)) {
pointy3++; pointy3++;
total_xscaling /= 3; total_xscaling /= 3;
xscale *= 3; xscale *= 3;
total_yscaling /= 3; total_yscaling /= 3;
yscale *= 3; yscale *= 3;
minscale /= 3;
} }
while (total_xscaling > 1 && ((total_xscaling % 4) == 0) && ((total_yscaling % 4) == 0)) { while (minscale > 1 && ((minscale % 4) == 0) && ((minscale % 4) == 0)) {
xbr4++; xbr4++;
total_xscaling /= 4; total_xscaling /= 4;
xscale *= 4; xscale *= 4;
total_yscaling /= 4; total_yscaling /= 4;
yscale *= 4; yscale *= 4;
minscale /= 4;
} }
while (total_xscaling > 1 && ((total_xscaling % 2) == 0) && ((total_yscaling % 2) == 0)) { while (minscale > 1 && ((minscale % 2) == 0) && ((minscale % 2) == 0)) {
xbr2++; xbr2++;
total_xscaling /= 2; total_xscaling /= 2;
xscale *= 2; xscale *= 2;
total_yscaling /= 2; total_yscaling /= 2;
yscale *= 2; yscale *= 2;
} minscale /= 2;
} }
} }
...@@ -452,10 +460,10 @@ csrc->w, csrc->h, pointymult, pointy5, pointy3, xbr4, xbr2, xmult, ymult, csrc-> ...@@ -452,10 +460,10 @@ csrc->w, csrc->h, pointymult, pointy5, pointy3, xbr4, xbr2, xmult, ymult, csrc->
} }
static void static void
pointy_scale_odd(uint32_t* src, uint32_t* dest, int width, int height, int mult) pointy_scale_odd(const uint32_t* src, uint32_t* dest, const int width, const int height, const int mult)
{ {
int x, y; int x, y;
uint32_t* s; const uint32_t* s;
uint32_t* d; uint32_t* d;
int prevline, prevcol, nextline, nextcol; int prevline, prevcol, nextline, nextcol;
int i, j; int i, j;
...@@ -556,10 +564,10 @@ pointy_scale_odd(uint32_t* src, uint32_t* dest, int width, int height, int mult) ...@@ -556,10 +564,10 @@ pointy_scale_odd(uint32_t* src, uint32_t* dest, int width, int height, int mult)
} }
static void static void
pointy_scale5(uint32_t* src, uint32_t* dest, int width, int height) pointy_scale5(const uint32_t* src, uint32_t* dest, const int width, const int height)
{ {
int x, y; int x, y;
uint32_t* s; const uint32_t* s;
uint32_t* d; uint32_t* d;
int w5 = width * 5; int w5 = width * 5;
int w10 = width * 10; int w10 = width * 10;
...@@ -675,10 +683,10 @@ pointy_scale5(uint32_t* src, uint32_t* dest, int width, int height) ...@@ -675,10 +683,10 @@ pointy_scale5(uint32_t* src, uint32_t* dest, int width, int height)
} }
static void static void
pointy_scale3(uint32_t* src, uint32_t* dest, int width, int height) pointy_scale3(const uint32_t* src, uint32_t* dest, const int width, const int height)
{ {
int x, y; int x, y;
uint32_t* s; const uint32_t* s;
uint32_t* d; uint32_t* d;
int w3 = width * 3; int w3 = width * 3;
int w6 = width * 6; int w6 = width * 6;
...@@ -810,7 +818,7 @@ blend_YCoCg(const uint32_t c1, const uint32_t c2, const uint16_t weight) ...@@ -810,7 +818,7 @@ blend_YCoCg(const uint32_t c1, const uint32_t c2, const uint16_t weight)
* pixels. * pixels.
*/ */
static void static void
interpolate_width(uint32_t* src, uint32_t* dst, int width, int height, int newwidth) interpolate_width(uint32_t const* src, uint32_t* dst, const int width, const int height, const int newwidth)
{ {
int x, y; int x, y;
const double mult = (double)width / newwidth; const double mult = (double)width / newwidth;
...@@ -852,7 +860,7 @@ interpolate_width(uint32_t* src, uint32_t* dst, int width, int height, int newwi ...@@ -852,7 +860,7 @@ interpolate_width(uint32_t* src, uint32_t* dst, int width, int height, int newwi
* pixels. * pixels.
*/ */
static void static void
interpolate_height(uint32_t* src, uint32_t* dst, int width, int height, int newheight) interpolate_height(uint32_t const* src, uint32_t* dst, const int width, const int height, const int newheight)
{ {
int x, y; int x, y;
const double mult = (double)height / newheight; const double mult = (double)height / newheight;
...@@ -920,16 +928,16 @@ fail: ...@@ -920,16 +928,16 @@ fail:
tline = NULL; tline = NULL;
nsz = 0; nsz = 0;
tsz = 0; tsz = 0;
memcpy(src, dst, width * height * sizeof(*src)); memcpy(dst, src, width * height * sizeof(*src));
fprintf(stderr, "Allocation failure in interpolate_height()!"); fprintf(stderr, "Allocation failure in interpolate_height()!");
} }
static void static void
multiply_scale(uint32_t* src, uint32_t* dst, int width, int height, int xmult, int ymult) multiply_scale(uint32_t const* src, uint32_t* dst, const int width, const int height, const int xmult, const int ymult)
{ {
int x, y; int x, y;
int mx, my; int mx, my;
uint32_t* slstart; uint32_t const* slstart;
for (y = 0; y < height; y++) { for (y = 0; y < height; y++) {
slstart = src; slstart = src;
......
...@@ -61,7 +61,7 @@ RGB_to_YCoCg(const uint32_t RGB, struct YCoCg_data *YCoCg) ...@@ -61,7 +61,7 @@ RGB_to_YCoCg(const uint32_t RGB, struct YCoCg_data *YCoCg)
YCoCg->Y = tmp + (YCoCg->Cg >> 1); YCoCg->Y = tmp + (YCoCg->Cg >> 1);
} }
static uint32_t pixel_diff(uint32_t x, uint32_t y) static uint32_t pixel_diff(const uint32_t x, const uint32_t y)
{ {
struct YCoCg_data yccx; struct YCoCg_data yccx;
struct YCoCg_data yccy; struct YCoCg_data yccy;
...@@ -217,7 +217,7 @@ static uint32_t pixel_diff(uint32_t x, uint32_t y) ...@@ -217,7 +217,7 @@ static uint32_t pixel_diff(uint32_t x, uint32_t y)
} while(0) } while(0)
void void
xbr_filter(uint32_t *data, uint32_t *out, int width, int height, int n) xbr_filter(const uint32_t *data, uint32_t *out, const int width, const int height, const int n)
{ {
int x, y; int x, y;
const int nl = width * n; const int nl = width * n;
......
#include <inttypes.h> #include <inttypes.h>
void xbr_filter(uint32_t *data, uint32_t *out, int width, int height, int n); void xbr_filter(const uint32_t *data, uint32_t *out, const int width, const int height, const int n);
Version 1.2rc4
--------------
Fix pointy scaling to work even when interpolating both directions
Version 1.2rc3 Version 1.2rc3
-------------- --------------
Get Haiku support building again Get Haiku support building again
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment