summaryrefslogtreecommitdiff
path: root/shell/scalers/scaler.c
diff options
context:
space:
mode:
Diffstat (limited to 'shell/scalers/scaler.c')
-rw-r--r--shell/scalers/scaler.c61
1 files changed, 53 insertions, 8 deletions
diff --git a/shell/scalers/scaler.c b/shell/scalers/scaler.c
index 8d85b8a..19c3cfd 100644
--- a/shell/scalers/scaler.c
+++ b/shell/scalers/scaler.c
@@ -27,6 +27,49 @@
// Halves
#define Weight1_1(A, B) (Half(A) + Half(B) + Corr1_1(A, B))
+#define AVERAGE16(c1, c2) (((c1) + (c2) + (((c1) ^ (c2)) & 0x0821))>>1) //More accurate
+
+void upscale_240x208_to_320x240(uint16_t *dst, uint16_t *src)
+{
+ int Eh = 0;
+ int dh = 8;
+ int width = 320;
+ int vf = 0;
+
+ for (int y = 0; y < 240; y++)
+ {
+ int source = dh * width + 8;
+ for (int x = 0; x < 320/4; x++)
+ {
+ register uint16_t a, b, c;
+
+ a = src[source];
+ b = src[source+1];
+ c = src[source+2];
+
+ if(vf == 1){
+ a = AVERAGE16(a, src[source+width]);
+ b = AVERAGE16(b, src[source+width+1]);
+ c = AVERAGE16(c, src[source+width+2]);
+ }
+ *dst++ = a;
+ *dst++ = (AVERAGE16(a,b) & 0b0000000000011111) | (b & 0b1111111111100000);
+ *dst++ = (b & 0b0000011111111111) | (AVERAGE16(b,c) & 0b1111100000000000);
+ *dst++ = c;
+ source+=3;
+
+ }
+ Eh += 208;
+ if(Eh >= 240) {
+ Eh -= 240;
+ dh++;
+ vf = 0;
+ }
+ else
+ vf = 1;
+ }
+}
+
void upscale_256x240_to_320x240_bilinearish(uint32_t* restrict dst, uint32_t* restrict src, uint_fast16_t width, uint_fast16_t height)
{
@@ -35,8 +78,10 @@ void upscale_256x240_to_320x240_bilinearish(uint32_t* restrict dst, uint32_t* re
// There are 64 blocks of 4 pixels horizontally, and 239 of 1 vertically.
// Each block of 4x1 becomes 5x1.
uint32_t BlockX, BlockY;
- uint16_t* BlockSrc;
- uint16_t* BlockDst;
+ register uint16_t _1,_2,_3,_4;
+ register uint16_t* BlockSrc;
+ register uint16_t* BlockDst;
+
for (BlockY = 0; BlockY < height; BlockY++)
{
BlockSrc = Src16 + BlockY * width * 1;
@@ -51,13 +96,13 @@ void upscale_256x240_to_320x240_bilinearish(uint32_t* restrict dst, uint32_t* re
*/
// -- Row 1 --
- uint16_t _1 = *(BlockSrc );
+ _1 = *(BlockSrc );
*(BlockDst ) = _1;
- uint16_t _2 = *(BlockSrc + 1);
+ _2 = *(BlockSrc + 1);
*(BlockDst + 1) = Weight1_3( _1, _2);
- uint16_t _3 = *(BlockSrc + 2);
+ _3 = *(BlockSrc + 2);
*(BlockDst + 2) = Weight1_1( _2, _3);
- uint16_t _4 = *(BlockSrc + 3);
+ _4 = *(BlockSrc + 3);
*(BlockDst + 3) = Weight3_1( _3, _4);
*(BlockDst + 4) = _4;
@@ -67,9 +112,9 @@ void upscale_256x240_to_320x240_bilinearish(uint32_t* restrict dst, uint32_t* re
}
}
-void upscale_256xXXX_to_320x240(uint32_t* restrict dst, uint32_t* restrict src, uint_fast16_t width, uint_fast16_t height)
+
+void upscale_256xXXX_to_320x240(uint32_t* restrict dst, uint32_t* restrict src, uint_fast16_t width, uint_fast16_t height, uint32_t midh)
{
- uint32_t midh = 240 / 2;
uint32_t Eh = 0;
uint32_t source;
uint32_t dh = 0;