Whew - hq4x now rendering colors properly. Not catching YUV threshold, tho.
This commit is contained in:
parent
ce0f602b6e
commit
7487c3b31b
5 changed files with 303 additions and 311 deletions
314
src/hq4x.c
314
src/hq4x.c
|
|
@ -28,168 +28,166 @@
|
|||
#include "hqxx.h"
|
||||
|
||||
|
||||
#define PIXEL00_0 Interp0(dest, x * 4 + 0, y * 4 + 0, c[5])
|
||||
#define PIXEL00_11 Interp1(dest, x * 4 + 0, y * 4 + 0, c[5], c[4])
|
||||
#define PIXEL00_12 Interp1(dest, x * 4 + 0, y * 4 + 0, c[5], c[2])
|
||||
#define PIXEL00_20 Interp2(dest, x * 4 + 0, y * 4 + 0, c[5], c[2], c[4])
|
||||
#define PIXEL00_50 Interp5(dest, x * 4 + 0, y * 4 + 0, c[2], c[4])
|
||||
#define PIXEL00_80 Interp8(dest, x * 4 + 0, y * 4 + 0, c[5], c[1])
|
||||
#define PIXEL00_81 Interp8(dest, x * 4 + 0, y * 4 + 0, c[5], c[4])
|
||||
#define PIXEL00_82 Interp8(dest, x * 4 + 0, y * 4 + 0, c[5], c[2])
|
||||
#define PIXEL01_0 Interp0(dest, x * 4 + 0, y * 4 + 0, c[5])
|
||||
#define PIXEL01_10 Interp1(dest, x * 4 + 1, y * 4 + 0, c[5], c[1])
|
||||
#define PIXEL01_12 Interp1(dest, x * 4 + 1, y * 4 + 0, c[5], c[2])
|
||||
#define PIXEL01_14 Interp1(dest, x * 4 + 1, y * 4 + 0, c[2], c[5])
|
||||
#define PIXEL01_21 Interp2(dest, x * 4 + 1, y * 4 + 0, c[2], c[5], c[4])
|
||||
#define PIXEL01_31 Interp3(dest, x * 4 + 1, y * 4 + 0, c[5], c[4])
|
||||
#define PIXEL01_50 Interp5(dest, x * 4 + 1, y * 4 + 0, c[2], c[5])
|
||||
#define PIXEL01_60 Interp6(dest, x * 4 + 1, y * 4 + 0, c[5], c[2], c[4])
|
||||
#define PIXEL01_61 Interp6(dest, x * 4 + 1, y * 4 + 0, c[5], c[2], c[1])
|
||||
#define PIXEL01_82 Interp8(dest, x * 4 + 1, y * 4 + 0, c[5], c[2])
|
||||
#define PIXEL01_83 Interp8(dest, x * 4 + 1, y * 4 + 0, c[2], c[4])
|
||||
#define PIXEL02_0 Interp0(dest, x * 4 + 2, y * 4 + 0, c[5])
|
||||
#define PIXEL02_10 Interp1(dest, x * 4 + 2, y * 4 + 0, c[5], c[3])
|
||||
#define PIXEL02_11 Interp1(dest, x * 4 + 2, y * 4 + 0, c[5], c[2])
|
||||
#define PIXEL02_13 Interp1(dest, x * 4 + 2, y * 4 + 0, c[2], c[5])
|
||||
#define PIXEL02_21 Interp2(dest, x * 4 + 2, y * 4 + 0, c[2], c[5], c[6])
|
||||
#define PIXEL02_32 Interp3(dest, x * 4 + 2, y * 4 + 0, c[5], c[6])
|
||||
#define PIXEL02_50 Interp5(dest, x * 4 + 2, y * 4 + 0, c[2], c[5])
|
||||
#define PIXEL02_60 Interp6(dest, x * 4 + 2, y * 4 + 0, c[5], c[2], c[6])
|
||||
#define PIXEL02_61 Interp6(dest, x * 4 + 2, y * 4 + 0, c[5], c[2], c[3])
|
||||
#define PIXEL02_81 Interp8(dest, x * 4 + 2, y * 4 + 0, c[5], c[2])
|
||||
#define PIXEL02_83 Interp8(dest, x * 4 + 2, y * 4 + 0, c[2], c[6])
|
||||
#define PIXEL03_0 Interp0(dest, x * 4 + 3, y * 4 + 0, c[5])
|
||||
#define PIXEL03_11 Interp1(dest, x * 4 + 3, y * 4 + 0, c[5], c[2])
|
||||
#define PIXEL03_12 Interp1(dest, x * 4 + 3, y * 4 + 0, c[5], c[6])
|
||||
#define PIXEL03_20 Interp2(dest, x * 4 + 3, y * 4 + 0, c[5], c[2], c[6])
|
||||
#define PIXEL03_50 Interp5(dest, x * 4 + 3, y * 4 + 0, c[2], c[6])
|
||||
#define PIXEL03_80 Interp8(dest, x * 4 + 3, y * 4 + 0, c[5], c[3])
|
||||
#define PIXEL03_81 Interp8(dest, x * 4 + 3, y * 4 + 0, c[5], c[2])
|
||||
#define PIXEL03_82 Interp8(dest, x * 4 + 3, y * 4 + 0, c[5], c[6])
|
||||
#define PIXEL10_0 Interp0(dest, x * 4 + 0, y * 4 + 1, c[5])
|
||||
#define PIXEL10_10 Interp1(dest, x * 4 + 0, y * 4 + 1, c[5], c[1])
|
||||
#define PIXEL10_11 Interp1(dest, x * 4 + 0, y * 4 + 1, c[5], c[4])
|
||||
#define PIXEL10_13 Interp1(dest, x * 4 + 0, y * 4 + 1, c[4], c[5])
|
||||
#define PIXEL10_21 Interp2(dest, x * 4 + 0, y * 4 + 1, c[4], c[5], c[2])
|
||||
#define PIXEL10_32 Interp3(dest, x * 4 + 0, y * 4 + 1, c[5], c[2])
|
||||
#define PIXEL10_50 Interp5(dest, x * 4 + 0, y * 4 + 1, c[4], c[5])
|
||||
#define PIXEL10_60 Interp6(dest, x * 4 + 0, y * 4 + 1, c[5], c[4], c[2])
|
||||
#define PIXEL10_61 Interp6(dest, x * 4 + 0, y * 4 + 1, c[5], c[4], c[1])
|
||||
#define PIXEL10_81 Interp8(dest, x * 4 + 0, y * 4 + 1, c[5], c[4])
|
||||
#define PIXEL10_83 Interp8(dest, x * 4 + 0, y * 4 + 1, c[4], c[2])
|
||||
#define PIXEL11_0 Interp0(dest, x * 4 + 1, y * 4 + 1, c[5])
|
||||
#define PIXEL11_30 Interp3(dest, x * 4 + 1, y * 4 + 1, c[5], c[1])
|
||||
#define PIXEL11_31 Interp3(dest, x * 4 + 1, y * 4 + 1, c[5], c[4])
|
||||
#define PIXEL11_32 Interp3(dest, x * 4 + 1, y * 4 + 1, c[5], c[2])
|
||||
#define PIXEL11_70 Interp7(dest, x * 4 + 1, y * 4 + 1, c[5], c[4], c[2])
|
||||
#define PIXEL12_0 Interp0(dest, x * 4 + 2, y * 4 + 1, c[5])
|
||||
#define PIXEL12_30 Interp3(dest, x * 4 + 2, y * 4 + 1, c[5], c[3])
|
||||
#define PIXEL12_31 Interp3(dest, x * 4 + 2, y * 4 + 1, c[5], c[2])
|
||||
#define PIXEL12_32 Interp3(dest, x * 4 + 2, y * 4 + 1, c[5], c[6])
|
||||
#define PIXEL12_70 Interp7(dest, x * 4 + 2, y * 4 + 1, c[5], c[6], c[2])
|
||||
#define PIXEL13_0 Interp0(dest, x * 4 + 3, y * 4 + 1, c[5])
|
||||
#define PIXEL13_10 Interp1(dest, x * 4 + 3, y * 4 + 1, c[5], c[3])
|
||||
#define PIXEL13_12 Interp1(dest, x * 4 + 3, y * 4 + 1, c[5], c[6])
|
||||
#define PIXEL13_14 Interp1(dest, x * 4 + 3, y * 4 + 1, c[6], c[5])
|
||||
#define PIXEL13_21 Interp2(dest, x * 4 + 3, y * 4 + 1, c[6], c[5], c[2])
|
||||
#define PIXEL13_31 Interp3(dest, x * 4 + 3, y * 4 + 1, c[5], c[2])
|
||||
#define PIXEL13_50 Interp5(dest, x * 4 + 3, y * 4 + 1, c[6], c[5])
|
||||
#define PIXEL13_60 Interp6(dest, x * 4 + 3, y * 4 + 1, c[5], c[6], c[2])
|
||||
#define PIXEL13_61 Interp6(dest, x * 4 + 3, y * 4 + 1, c[5], c[6], c[3])
|
||||
#define PIXEL13_82 Interp8(dest, x * 4 + 3, y * 4 + 1, c[5], c[6])
|
||||
#define PIXEL13_83 Interp8(dest, x * 4 + 3, y * 4 + 1, c[6], c[2])
|
||||
#define PIXEL20_0 Interp0(dest, x * 4 + 0, y * 4 + 2, c[5])
|
||||
#define PIXEL20_10 Interp1(dest, x * 4 + 0, y * 4 + 2, c[5], c[7])
|
||||
#define PIXEL20_12 Interp1(dest, x * 4 + 0, y * 4 + 2, c[5], c[4])
|
||||
#define PIXEL20_14 Interp1(dest, x * 4 + 0, y * 4 + 2, c[4], c[5])
|
||||
#define PIXEL20_21 Interp2(dest, x * 4 + 0, y * 4 + 2, c[4], c[5], c[8])
|
||||
#define PIXEL20_31 Interp3(dest, x * 4 + 0, y * 4 + 2, c[5], c[8])
|
||||
#define PIXEL20_50 Interp5(dest, x * 4 + 0, y * 4 + 2, c[4], c[5])
|
||||
#define PIXEL20_60 Interp6(dest, x * 4 + 0, y * 4 + 2, c[5], c[4], c[8])
|
||||
#define PIXEL20_61 Interp6(dest, x * 4 + 0, y * 4 + 2, c[5], c[4], c[7])
|
||||
#define PIXEL20_82 Interp8(dest, x * 4 + 0, y * 4 + 2, c[5], c[4])
|
||||
#define PIXEL20_83 Interp8(dest, x * 4 + 0, y * 4 + 2, c[4], c[8])
|
||||
#define PIXEL21_0 Interp0(dest, x * 4 + 1, y * 4 + 2, c[5])
|
||||
#define PIXEL21_30 Interp3(dest, x * 4 + 1, y * 4 + 2, c[5], c[7])
|
||||
#define PIXEL21_31 Interp3(dest, x * 4 + 1, y * 4 + 2, c[5], c[8])
|
||||
#define PIXEL21_32 Interp3(dest, x * 4 + 1, y * 4 + 2, c[5], c[4])
|
||||
#define PIXEL21_70 Interp7(dest, x * 4 + 1, y * 4 + 2, c[5], c[4], c[8])
|
||||
#define PIXEL22_0 Interp0(dest, x * 4 + 2, y * 4 + 2, c[5])
|
||||
#define PIXEL22_30 Interp3(dest, x * 4 + 2, y * 4 + 2, c[5], c[9])
|
||||
#define PIXEL22_31 Interp3(dest, x * 4 + 2, y * 4 + 2, c[5], c[6])
|
||||
#define PIXEL22_32 Interp3(dest, x * 4 + 2, y * 4 + 2, c[5], c[8])
|
||||
#define PIXEL22_70 Interp7(dest, x * 4 + 2, y * 4 + 2, c[5], c[6], c[8])
|
||||
#define PIXEL23_0 Interp0(dest, x * 4 + 3, y * 4 + 2, c[5])
|
||||
#define PIXEL23_10 Interp1(dest, x * 4 + 3, y * 4 + 2, c[5], c[9])
|
||||
#define PIXEL23_11 Interp1(dest, x * 4 + 3, y * 4 + 2, c[5], c[6])
|
||||
#define PIXEL23_13 Interp1(dest, x * 4 + 3, y * 4 + 2, c[6], c[5])
|
||||
#define PIXEL23_21 Interp2(dest, x * 4 + 3, y * 4 + 2, c[6], c[5], c[8])
|
||||
#define PIXEL23_32 Interp3(dest, x * 4 + 3, y * 4 + 2, c[5], c[8])
|
||||
#define PIXEL23_50 Interp5(dest, x * 4 + 3, y * 4 + 2, c[6], c[5])
|
||||
#define PIXEL23_60 Interp6(dest, x * 4 + 3, y * 4 + 2, c[5], c[6], c[8])
|
||||
#define PIXEL23_61 Interp6(dest, x * 4 + 3, y * 4 + 2, c[5], c[6], c[9])
|
||||
#define PIXEL23_81 Interp8(dest, x * 4 + 3, y * 4 + 2, c[5], c[6])
|
||||
#define PIXEL23_83 Interp8(dest, x * 4 + 3, y * 4 + 2, c[6], c[8])
|
||||
#define PIXEL30_0 Interp0(dest, x * 4 + 0, y * 4 + 3, c[5])
|
||||
#define PIXEL30_11 Interp1(dest, x * 4 + 0, y * 4 + 3, c[5], c[8])
|
||||
#define PIXEL30_12 Interp1(dest, x * 4 + 0, y * 4 + 3, c[5], c[4])
|
||||
#define PIXEL30_20 Interp2(dest, x * 4 + 0, y * 4 + 3, c[5], c[8], c[4])
|
||||
#define PIXEL30_50 Interp5(dest, x * 4 + 0, y * 4 + 3, c[8], c[4])
|
||||
#define PIXEL30_80 Interp8(dest, x * 4 + 0, y * 4 + 3, c[5], c[7])
|
||||
#define PIXEL30_81 Interp8(dest, x * 4 + 0, y * 4 + 3, c[5], c[8])
|
||||
#define PIXEL30_82 Interp8(dest, x * 4 + 0, y * 4 + 3, c[5], c[4])
|
||||
#define PIXEL31_0 Interp0(dest, x * 4 + 1, y * 4 + 3, c[5])
|
||||
#define PIXEL31_10 Interp1(dest, x * 4 + 1, y * 4 + 3, c[5], c[7])
|
||||
#define PIXEL31_11 Interp1(dest, x * 4 + 1, y * 4 + 3, c[5], c[8])
|
||||
#define PIXEL31_13 Interp1(dest, x * 4 + 1, y * 4 + 3, c[8], c[5])
|
||||
#define PIXEL31_21 Interp2(dest, x * 4 + 1, y * 4 + 3, c[8], c[5], c[4])
|
||||
#define PIXEL31_32 Interp3(dest, x * 4 + 1, y * 4 + 3, c[5], c[4])
|
||||
#define PIXEL31_50 Interp5(dest, x * 4 + 1, y * 4 + 3, c[8], c[5])
|
||||
#define PIXEL31_60 Interp6(dest, x * 4 + 1, y * 4 + 3, c[5], c[8], c[4])
|
||||
#define PIXEL31_61 Interp6(dest, x * 4 + 1, y * 4 + 3, c[5], c[8], c[7])
|
||||
#define PIXEL31_81 Interp8(dest, x * 4 + 1, y * 4 + 3, c[5], c[8])
|
||||
#define PIXEL31_83 Interp8(dest, x * 4 + 1, y * 4 + 3, c[8], c[4])
|
||||
#define PIXEL32_0 Interp0(dest, x * 4 + 2, y * 4 + 3, c[5])
|
||||
#define PIXEL32_10 Interp1(dest, x * 4 + 2, y * 4 + 3, c[5], c[9])
|
||||
#define PIXEL32_12 Interp1(dest, x * 4 + 2, y * 4 + 3, c[5], c[8])
|
||||
#define PIXEL32_14 Interp1(dest, x * 4 + 2, y * 4 + 3, c[8], c[5])
|
||||
#define PIXEL32_21 Interp2(dest, x * 4 + 2, y * 4 + 3, c[8], c[5], c[6])
|
||||
#define PIXEL32_31 Interp3(dest, x * 4 + 2, y * 4 + 3, c[5], c[6])
|
||||
#define PIXEL32_50 Interp5(dest, x * 4 + 2, y * 4 + 3, c[8], c[5])
|
||||
#define PIXEL32_60 Interp6(dest, x * 4 + 2, y * 4 + 3, c[5], c[8], c[6])
|
||||
#define PIXEL32_61 Interp6(dest, x * 4 + 2, y * 4 + 3, c[5], c[8], c[9])
|
||||
#define PIXEL32_82 Interp8(dest, x * 4 + 2, y * 4 + 3, c[5], c[8])
|
||||
#define PIXEL32_83 Interp8(dest, x * 4 + 2, y * 4 + 3, c[8], c[6])
|
||||
#define PIXEL33_0 Interp0(dest, x * 4 + 3, y * 4 + 3, c[5])
|
||||
#define PIXEL33_11 Interp1(dest, x * 4 + 3, y * 4 + 3, c[5], c[6])
|
||||
#define PIXEL33_12 Interp1(dest, x * 4 + 3, y * 4 + 3, c[5], c[8])
|
||||
#define PIXEL33_20 Interp2(dest, x * 4 + 3, y * 4 + 3, c[5], c[8], c[6])
|
||||
#define PIXEL33_50 Interp5(dest, x * 4 + 3, y * 4 + 3, c[8], c[6])
|
||||
#define PIXEL33_80 Interp8(dest, x * 4 + 3, y * 4 + 3, c[5], c[9])
|
||||
#define PIXEL33_81 Interp8(dest, x * 4 + 3, y * 4 + 3, c[5], c[6])
|
||||
#define PIXEL33_82 Interp8(dest, x * 4 + 3, y * 4 + 3, c[5], c[8])
|
||||
#define PIXEL00_0 Interp0(dest, x * 4 + 0, y * 4 + 0, w[5], a)
|
||||
#define PIXEL00_11 Interp1(dest, x * 4 + 0, y * 4 + 0, w[5], w[4], a)
|
||||
#define PIXEL00_12 Interp1(dest, x * 4 + 0, y * 4 + 0, w[5], w[2], a)
|
||||
#define PIXEL00_20 Interp2(dest, x * 4 + 0, y * 4 + 0, w[5], w[2], w[4], a)
|
||||
#define PIXEL00_50 Interp5(dest, x * 4 + 0, y * 4 + 0, w[2], w[4], a)
|
||||
#define PIXEL00_80 Interp8(dest, x * 4 + 0, y * 4 + 0, w[5], w[1], a)
|
||||
#define PIXEL00_81 Interp8(dest, x * 4 + 0, y * 4 + 0, w[5], w[4], a)
|
||||
#define PIXEL00_82 Interp8(dest, x * 4 + 0, y * 4 + 0, w[5], w[2], a)
|
||||
#define PIXEL01_0 Interp0(dest, x * 4 + 0, y * 4 + 0, w[5], a)
|
||||
#define PIXEL01_10 Interp1(dest, x * 4 + 1, y * 4 + 0, w[5], w[1], a)
|
||||
#define PIXEL01_12 Interp1(dest, x * 4 + 1, y * 4 + 0, w[5], w[2], a)
|
||||
#define PIXEL01_14 Interp1(dest, x * 4 + 1, y * 4 + 0, w[2], w[5], a)
|
||||
#define PIXEL01_21 Interp2(dest, x * 4 + 1, y * 4 + 0, w[2], w[5], w[4], a)
|
||||
#define PIXEL01_31 Interp3(dest, x * 4 + 1, y * 4 + 0, w[5], w[4], a)
|
||||
#define PIXEL01_50 Interp5(dest, x * 4 + 1, y * 4 + 0, w[2], w[5], a)
|
||||
#define PIXEL01_60 Interp6(dest, x * 4 + 1, y * 4 + 0, w[5], w[2], w[4], a)
|
||||
#define PIXEL01_61 Interp6(dest, x * 4 + 1, y * 4 + 0, w[5], w[2], w[1], a)
|
||||
#define PIXEL01_82 Interp8(dest, x * 4 + 1, y * 4 + 0, w[5], w[2], a)
|
||||
#define PIXEL01_83 Interp8(dest, x * 4 + 1, y * 4 + 0, w[2], w[4], a)
|
||||
#define PIXEL02_0 Interp0(dest, x * 4 + 2, y * 4 + 0, w[5], a)
|
||||
#define PIXEL02_10 Interp1(dest, x * 4 + 2, y * 4 + 0, w[5], w[3], a)
|
||||
#define PIXEL02_11 Interp1(dest, x * 4 + 2, y * 4 + 0, w[5], w[2], a)
|
||||
#define PIXEL02_13 Interp1(dest, x * 4 + 2, y * 4 + 0, w[2], w[5], a)
|
||||
#define PIXEL02_21 Interp2(dest, x * 4 + 2, y * 4 + 0, w[2], w[5], w[6], a)
|
||||
#define PIXEL02_32 Interp3(dest, x * 4 + 2, y * 4 + 0, w[5], w[6], a)
|
||||
#define PIXEL02_50 Interp5(dest, x * 4 + 2, y * 4 + 0, w[2], w[5], a)
|
||||
#define PIXEL02_60 Interp6(dest, x * 4 + 2, y * 4 + 0, w[5], w[2], w[6], a)
|
||||
#define PIXEL02_61 Interp6(dest, x * 4 + 2, y * 4 + 0, w[5], w[2], w[3], a)
|
||||
#define PIXEL02_81 Interp8(dest, x * 4 + 2, y * 4 + 0, w[5], w[2], a)
|
||||
#define PIXEL02_83 Interp8(dest, x * 4 + 2, y * 4 + 0, w[2], w[6], a)
|
||||
#define PIXEL03_0 Interp0(dest, x * 4 + 3, y * 4 + 0, w[5], a)
|
||||
#define PIXEL03_11 Interp1(dest, x * 4 + 3, y * 4 + 0, w[5], w[2], a)
|
||||
#define PIXEL03_12 Interp1(dest, x * 4 + 3, y * 4 + 0, w[5], w[6], a)
|
||||
#define PIXEL03_20 Interp2(dest, x * 4 + 3, y * 4 + 0, w[5], w[2], w[6], a)
|
||||
#define PIXEL03_50 Interp5(dest, x * 4 + 3, y * 4 + 0, w[2], w[6], a)
|
||||
#define PIXEL03_80 Interp8(dest, x * 4 + 3, y * 4 + 0, w[5], w[3], a)
|
||||
#define PIXEL03_81 Interp8(dest, x * 4 + 3, y * 4 + 0, w[5], w[2], a)
|
||||
#define PIXEL03_82 Interp8(dest, x * 4 + 3, y * 4 + 0, w[5], w[6], a)
|
||||
#define PIXEL10_0 Interp0(dest, x * 4 + 0, y * 4 + 1, w[5], a)
|
||||
#define PIXEL10_10 Interp1(dest, x * 4 + 0, y * 4 + 1, w[5], w[1], a)
|
||||
#define PIXEL10_11 Interp1(dest, x * 4 + 0, y * 4 + 1, w[5], w[4], a)
|
||||
#define PIXEL10_13 Interp1(dest, x * 4 + 0, y * 4 + 1, w[4], w[5], a)
|
||||
#define PIXEL10_21 Interp2(dest, x * 4 + 0, y * 4 + 1, w[4], w[5], w[2], a)
|
||||
#define PIXEL10_32 Interp3(dest, x * 4 + 0, y * 4 + 1, w[5], w[2], a)
|
||||
#define PIXEL10_50 Interp5(dest, x * 4 + 0, y * 4 + 1, w[4], w[5], a)
|
||||
#define PIXEL10_60 Interp6(dest, x * 4 + 0, y * 4 + 1, w[5], w[4], w[2], a)
|
||||
#define PIXEL10_61 Interp6(dest, x * 4 + 0, y * 4 + 1, w[5], w[4], w[1], a)
|
||||
#define PIXEL10_81 Interp8(dest, x * 4 + 0, y * 4 + 1, w[5], w[4], a)
|
||||
#define PIXEL10_83 Interp8(dest, x * 4 + 0, y * 4 + 1, w[4], w[2], a)
|
||||
#define PIXEL11_0 Interp0(dest, x * 4 + 1, y * 4 + 1, w[5], a)
|
||||
#define PIXEL11_30 Interp3(dest, x * 4 + 1, y * 4 + 1, w[5], w[1], a)
|
||||
#define PIXEL11_31 Interp3(dest, x * 4 + 1, y * 4 + 1, w[5], w[4], a)
|
||||
#define PIXEL11_32 Interp3(dest, x * 4 + 1, y * 4 + 1, w[5], w[2], a)
|
||||
#define PIXEL11_70 Interp7(dest, x * 4 + 1, y * 4 + 1, w[5], w[4], w[2], a)
|
||||
#define PIXEL12_0 Interp0(dest, x * 4 + 2, y * 4 + 1, w[5], a)
|
||||
#define PIXEL12_30 Interp3(dest, x * 4 + 2, y * 4 + 1, w[5], w[3], a)
|
||||
#define PIXEL12_31 Interp3(dest, x * 4 + 2, y * 4 + 1, w[5], w[2], a)
|
||||
#define PIXEL12_32 Interp3(dest, x * 4 + 2, y * 4 + 1, w[5], w[6], a)
|
||||
#define PIXEL12_70 Interp7(dest, x * 4 + 2, y * 4 + 1, w[5], w[6], w[2], a)
|
||||
#define PIXEL13_0 Interp0(dest, x * 4 + 3, y * 4 + 1, w[5], a)
|
||||
#define PIXEL13_10 Interp1(dest, x * 4 + 3, y * 4 + 1, w[5], w[3], a)
|
||||
#define PIXEL13_12 Interp1(dest, x * 4 + 3, y * 4 + 1, w[5], w[6], a)
|
||||
#define PIXEL13_14 Interp1(dest, x * 4 + 3, y * 4 + 1, w[6], w[5], a)
|
||||
#define PIXEL13_21 Interp2(dest, x * 4 + 3, y * 4 + 1, w[6], w[5], w[2], a)
|
||||
#define PIXEL13_31 Interp3(dest, x * 4 + 3, y * 4 + 1, w[5], w[2], a)
|
||||
#define PIXEL13_50 Interp5(dest, x * 4 + 3, y * 4 + 1, w[6], w[5], a)
|
||||
#define PIXEL13_60 Interp6(dest, x * 4 + 3, y * 4 + 1, w[5], w[6], w[2], a)
|
||||
#define PIXEL13_61 Interp6(dest, x * 4 + 3, y * 4 + 1, w[5], w[6], w[3], a)
|
||||
#define PIXEL13_82 Interp8(dest, x * 4 + 3, y * 4 + 1, w[5], w[6], a)
|
||||
#define PIXEL13_83 Interp8(dest, x * 4 + 3, y * 4 + 1, w[6], w[2], a)
|
||||
#define PIXEL20_0 Interp0(dest, x * 4 + 0, y * 4 + 2, w[5], a)
|
||||
#define PIXEL20_10 Interp1(dest, x * 4 + 0, y * 4 + 2, w[5], w[7], a)
|
||||
#define PIXEL20_12 Interp1(dest, x * 4 + 0, y * 4 + 2, w[5], w[4], a)
|
||||
#define PIXEL20_14 Interp1(dest, x * 4 + 0, y * 4 + 2, w[4], w[5], a)
|
||||
#define PIXEL20_21 Interp2(dest, x * 4 + 0, y * 4 + 2, w[4], w[5], w[8], a)
|
||||
#define PIXEL20_31 Interp3(dest, x * 4 + 0, y * 4 + 2, w[5], w[8], a)
|
||||
#define PIXEL20_50 Interp5(dest, x * 4 + 0, y * 4 + 2, w[4], w[5], a)
|
||||
#define PIXEL20_60 Interp6(dest, x * 4 + 0, y * 4 + 2, w[5], w[4], w[8], a)
|
||||
#define PIXEL20_61 Interp6(dest, x * 4 + 0, y * 4 + 2, w[5], w[4], w[7], a)
|
||||
#define PIXEL20_82 Interp8(dest, x * 4 + 0, y * 4 + 2, w[5], w[4], a)
|
||||
#define PIXEL20_83 Interp8(dest, x * 4 + 0, y * 4 + 2, w[4], w[8], a)
|
||||
#define PIXEL21_0 Interp0(dest, x * 4 + 1, y * 4 + 2, w[5], a)
|
||||
#define PIXEL21_30 Interp3(dest, x * 4 + 1, y * 4 + 2, w[5], w[7], a)
|
||||
#define PIXEL21_31 Interp3(dest, x * 4 + 1, y * 4 + 2, w[5], w[8], a)
|
||||
#define PIXEL21_32 Interp3(dest, x * 4 + 1, y * 4 + 2, w[5], w[4], a)
|
||||
#define PIXEL21_70 Interp7(dest, x * 4 + 1, y * 4 + 2, w[5], w[4], w[8], a)
|
||||
#define PIXEL22_0 Interp0(dest, x * 4 + 2, y * 4 + 2, w[5], a)
|
||||
#define PIXEL22_30 Interp3(dest, x * 4 + 2, y * 4 + 2, w[5], w[9], a)
|
||||
#define PIXEL22_31 Interp3(dest, x * 4 + 2, y * 4 + 2, w[5], w[6], a)
|
||||
#define PIXEL22_32 Interp3(dest, x * 4 + 2, y * 4 + 2, w[5], w[8], a)
|
||||
#define PIXEL22_70 Interp7(dest, x * 4 + 2, y * 4 + 2, w[5], w[6], w[8], a)
|
||||
#define PIXEL23_0 Interp0(dest, x * 4 + 3, y * 4 + 2, w[5], a)
|
||||
#define PIXEL23_10 Interp1(dest, x * 4 + 3, y * 4 + 2, w[5], w[9], a)
|
||||
#define PIXEL23_11 Interp1(dest, x * 4 + 3, y * 4 + 2, w[5], w[6], a)
|
||||
#define PIXEL23_13 Interp1(dest, x * 4 + 3, y * 4 + 2, w[6], w[5], a)
|
||||
#define PIXEL23_21 Interp2(dest, x * 4 + 3, y * 4 + 2, w[6], w[5], w[8], a)
|
||||
#define PIXEL23_32 Interp3(dest, x * 4 + 3, y * 4 + 2, w[5], w[8], a)
|
||||
#define PIXEL23_50 Interp5(dest, x * 4 + 3, y * 4 + 2, w[6], w[5], a)
|
||||
#define PIXEL23_60 Interp6(dest, x * 4 + 3, y * 4 + 2, w[5], w[6], w[8], a)
|
||||
#define PIXEL23_61 Interp6(dest, x * 4 + 3, y * 4 + 2, w[5], w[6], w[9], a)
|
||||
#define PIXEL23_81 Interp8(dest, x * 4 + 3, y * 4 + 2, w[5], w[6], a)
|
||||
#define PIXEL23_83 Interp8(dest, x * 4 + 3, y * 4 + 2, w[6], w[8], a)
|
||||
#define PIXEL30_0 Interp0(dest, x * 4 + 0, y * 4 + 3, w[5], a)
|
||||
#define PIXEL30_11 Interp1(dest, x * 4 + 0, y * 4 + 3, w[5], w[8], a)
|
||||
#define PIXEL30_12 Interp1(dest, x * 4 + 0, y * 4 + 3, w[5], w[4], a)
|
||||
#define PIXEL30_20 Interp2(dest, x * 4 + 0, y * 4 + 3, w[5], w[8], w[4], a)
|
||||
#define PIXEL30_50 Interp5(dest, x * 4 + 0, y * 4 + 3, w[8], w[4], a)
|
||||
#define PIXEL30_80 Interp8(dest, x * 4 + 0, y * 4 + 3, w[5], w[7], a)
|
||||
#define PIXEL30_81 Interp8(dest, x * 4 + 0, y * 4 + 3, w[5], w[8], a)
|
||||
#define PIXEL30_82 Interp8(dest, x * 4 + 0, y * 4 + 3, w[5], w[4], a)
|
||||
#define PIXEL31_0 Interp0(dest, x * 4 + 1, y * 4 + 3, w[5], a)
|
||||
#define PIXEL31_10 Interp1(dest, x * 4 + 1, y * 4 + 3, w[5], w[7], a)
|
||||
#define PIXEL31_11 Interp1(dest, x * 4 + 1, y * 4 + 3, w[5], w[8], a)
|
||||
#define PIXEL31_13 Interp1(dest, x * 4 + 1, y * 4 + 3, w[8], w[5], a)
|
||||
#define PIXEL31_21 Interp2(dest, x * 4 + 1, y * 4 + 3, w[8], w[5], w[4], a)
|
||||
#define PIXEL31_32 Interp3(dest, x * 4 + 1, y * 4 + 3, w[5], w[4], a)
|
||||
#define PIXEL31_50 Interp5(dest, x * 4 + 1, y * 4 + 3, w[8], w[5], a)
|
||||
#define PIXEL31_60 Interp6(dest, x * 4 + 1, y * 4 + 3, w[5], w[8], w[4], a)
|
||||
#define PIXEL31_61 Interp6(dest, x * 4 + 1, y * 4 + 3, w[5], w[8], w[7], a)
|
||||
#define PIXEL31_81 Interp8(dest, x * 4 + 1, y * 4 + 3, w[5], w[8], a)
|
||||
#define PIXEL31_83 Interp8(dest, x * 4 + 1, y * 4 + 3, w[8], w[4], a)
|
||||
#define PIXEL32_0 Interp0(dest, x * 4 + 2, y * 4 + 3, w[5], a)
|
||||
#define PIXEL32_10 Interp1(dest, x * 4 + 2, y * 4 + 3, w[5], w[9], a)
|
||||
#define PIXEL32_12 Interp1(dest, x * 4 + 2, y * 4 + 3, w[5], w[8], a)
|
||||
#define PIXEL32_14 Interp1(dest, x * 4 + 2, y * 4 + 3, w[8], w[5], a)
|
||||
#define PIXEL32_21 Interp2(dest, x * 4 + 2, y * 4 + 3, w[8], w[5], w[6], a)
|
||||
#define PIXEL32_31 Interp3(dest, x * 4 + 2, y * 4 + 3, w[5], w[6], a)
|
||||
#define PIXEL32_50 Interp5(dest, x * 4 + 2, y * 4 + 3, w[8], w[5], a)
|
||||
#define PIXEL32_60 Interp6(dest, x * 4 + 2, y * 4 + 3, w[5], w[8], w[6], a)
|
||||
#define PIXEL32_61 Interp6(dest, x * 4 + 2, y * 4 + 3, w[5], w[8], w[9], a)
|
||||
#define PIXEL32_82 Interp8(dest, x * 4 + 2, y * 4 + 3, w[5], w[8], a)
|
||||
#define PIXEL32_83 Interp8(dest, x * 4 + 2, y * 4 + 3, w[8], w[6], a)
|
||||
#define PIXEL33_0 Interp0(dest, x * 4 + 3, y * 4 + 3, w[5], a)
|
||||
#define PIXEL33_11 Interp1(dest, x * 4 + 3, y * 4 + 3, w[5], w[6], a)
|
||||
#define PIXEL33_12 Interp1(dest, x * 4 + 3, y * 4 + 3, w[5], w[8], a)
|
||||
#define PIXEL33_20 Interp2(dest, x * 4 + 3, y * 4 + 3, w[5], w[8], w[6], a)
|
||||
#define PIXEL33_50 Interp5(dest, x * 4 + 3, y * 4 + 3, w[8], w[6], a)
|
||||
#define PIXEL33_80 Interp8(dest, x * 4 + 3, y * 4 + 3, w[5], w[9], a)
|
||||
#define PIXEL33_81 Interp8(dest, x * 4 + 3, y * 4 + 3, w[5], w[6], a)
|
||||
#define PIXEL33_82 Interp8(dest, x * 4 + 3, y * 4 + 3, w[5], w[8], a)
|
||||
|
||||
|
||||
|
||||
void hq4x_32(SDL_Surface * src, SDL_Surface * dest,
|
||||
int LUT16to32[65536], int RGBtoYUV[65536])
|
||||
int RGBtoYUV[65536])
|
||||
{
|
||||
int x, y, k;
|
||||
int prevline, nextline;
|
||||
Uint32 w[10];
|
||||
Uint32 c[10];
|
||||
Uint16 w[10];
|
||||
Uint8 a;
|
||||
int pattern;
|
||||
int flag;
|
||||
|
||||
|
||||
/*
|
||||
+----+----+----+
|
||||
| | | |
|
||||
| w1 | w2 | w3 |
|
||||
+----+----+----+
|
||||
| | | |
|
||||
| w4 | w5 | w6 |
|
||||
+----+----+----+
|
||||
| | | |
|
||||
| w7 | w8 | w9 |
|
||||
+----+----+----+
|
||||
*/
|
||||
|
|
@ -218,15 +216,15 @@ void hq4x_32(SDL_Surface * src, SDL_Surface * dest,
|
|||
{
|
||||
/* Gather input pixels: */
|
||||
|
||||
w[2] = hqxx_getpixel(src, x, y + prevline);
|
||||
w[5] = hqxx_getpixel(src, x, y);
|
||||
w[8] = hqxx_getpixel(src, x, y + nextline);
|
||||
w[2] = hqxx_getpixel(src, x, y + prevline, NULL);
|
||||
w[5] = hqxx_getpixel(src, x, y, &a);
|
||||
w[8] = hqxx_getpixel(src, x, y + nextline, NULL);
|
||||
|
||||
if (x > 0)
|
||||
{
|
||||
w[1] = hqxx_getpixel(src, x - 1, y + prevline);
|
||||
w[4] = hqxx_getpixel(src, x - 1, y);
|
||||
w[7] = hqxx_getpixel(src, x - 1, y + nextline);
|
||||
w[1] = hqxx_getpixel(src, x - 1, y + prevline, NULL);
|
||||
w[4] = hqxx_getpixel(src, x - 1, y, NULL);
|
||||
w[7] = hqxx_getpixel(src, x - 1, y + nextline, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -237,9 +235,9 @@ void hq4x_32(SDL_Surface * src, SDL_Surface * dest,
|
|||
|
||||
if (x < (src->w) - 1)
|
||||
{
|
||||
w[3] = hqxx_getpixel(src, x + 1, y + prevline);
|
||||
w[6] = hqxx_getpixel(src, x + 1, y);
|
||||
w[9] = hqxx_getpixel(src, x + 1, y + nextline);
|
||||
w[3] = hqxx_getpixel(src, x + 1, y + prevline, NULL);
|
||||
w[6] = hqxx_getpixel(src, x + 1, y, NULL);
|
||||
w[9] = hqxx_getpixel(src, x + 1, y + nextline, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -289,12 +287,6 @@ void hq4x_32(SDL_Surface * src, SDL_Surface * dest,
|
|||
}
|
||||
|
||||
|
||||
/* Convert the cluster from 16bit to 32bit: */
|
||||
|
||||
for (k = 1; k <= 9; k++)
|
||||
c[k] = w[k]; //LUT16to32[w[k]];
|
||||
|
||||
|
||||
/* Depending on the pattern, set various destination pixels: */
|
||||
|
||||
switch (pattern)
|
||||
|
|
|
|||
|
|
@ -4,6 +4,6 @@
|
|||
#include "SDL.h"
|
||||
|
||||
void hq4x_32(SDL_Surface * src, SDL_Surface * dest,
|
||||
int LUT16to32[65536], int RGBtoYUV[65536]);
|
||||
int RGBtoYUV[65536]);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
253
src/hqxx.c
253
src/hqxx.c
|
|
@ -28,7 +28,7 @@
|
|||
#include "hqxx.h"
|
||||
|
||||
|
||||
Uint16 hqxx_getpixel(SDL_Surface * surface, int x, int y)
|
||||
Uint16 hqxx_getpixel(SDL_Surface * surface, int x, int y, Uint8 * alpha)
|
||||
{
|
||||
int bpp;
|
||||
Uint8 * p;
|
||||
|
|
@ -83,20 +83,35 @@ Uint16 hqxx_getpixel(SDL_Surface * surface, int x, int y)
|
|||
/* SDL_UnlockSurface(surface); */
|
||||
}
|
||||
|
||||
SDL_GetRGB(pixel, surface->format, &r, &g, &b);
|
||||
|
||||
pixel16 = ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3);
|
||||
if (alpha == NULL)
|
||||
SDL_GetRGB(pixel, surface->format, &r, &g, &b);
|
||||
else
|
||||
SDL_GetRGBA(pixel, surface->format, &r, &g, &b, alpha);
|
||||
|
||||
|
||||
pixel16 = ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);
|
||||
|
||||
return pixel16;
|
||||
}
|
||||
|
||||
|
||||
void hqxx_putpixel(SDL_Surface * surface, int x, int y, Uint32 pixel)
|
||||
void hqxx_putpixel(SDL_Surface * surface, int x, int y, Uint16 pixel, Uint8 alpha)
|
||||
{
|
||||
int bpp;
|
||||
Uint8 * p;
|
||||
Uint8 r, g, b;
|
||||
Uint32 sdlpixel;
|
||||
|
||||
|
||||
/* Convert the 16bpp RGB-565 to the current surface's format: */
|
||||
|
||||
r = (pixel & 0xF800) >> 8;
|
||||
g = ((pixel & 0x07E0) >> 5) << 2;
|
||||
b = (pixel & 0x001F) << 3;
|
||||
|
||||
|
||||
sdlpixel = SDL_MapRGBA(surface->format, r, g, b, alpha);
|
||||
|
||||
|
||||
/* Assuming the X/Y values are within the bounds of this surface... */
|
||||
|
||||
if (x >= 0 && y >= 0 && x < surface->w && y < surface->h)
|
||||
|
|
@ -121,27 +136,27 @@ void hqxx_putpixel(SDL_Surface * surface, int x, int y, Uint32 pixel)
|
|||
* to the pixel value sent in: */
|
||||
|
||||
if (bpp == 1)
|
||||
*p = pixel;
|
||||
*p = sdlpixel;
|
||||
else if (bpp == 2)
|
||||
*(Uint16 *)p = pixel;
|
||||
*(Uint16 *)p = sdlpixel;
|
||||
else if (bpp == 3)
|
||||
{
|
||||
if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
|
||||
{
|
||||
p[0] = (pixel >> 16) & 0xff;
|
||||
p[1] = (pixel >> 8) & 0xff;
|
||||
p[2] = pixel & 0xff;
|
||||
p[0] = (sdlpixel >> 16) & 0xff;
|
||||
p[1] = (sdlpixel >> 8) & 0xff;
|
||||
p[2] = sdlpixel & 0xff;
|
||||
}
|
||||
else
|
||||
{
|
||||
p[0] = pixel & 0xff;
|
||||
p[1] = (pixel >> 8) & 0xff;
|
||||
p[2] = (pixel >> 16) & 0xff;
|
||||
p[0] = sdlpixel & 0xff;
|
||||
p[1] = (sdlpixel >> 8) & 0xff;
|
||||
p[2] = (sdlpixel >> 16) & 0xff;
|
||||
}
|
||||
}
|
||||
else if (bpp == 4)
|
||||
{
|
||||
*(Uint32 *)p = pixel;
|
||||
*(Uint32 *)p = sdlpixel;
|
||||
}
|
||||
|
||||
/* SDL_UnlockSurface(surface); */
|
||||
|
|
@ -150,18 +165,11 @@ void hqxx_putpixel(SDL_Surface * surface, int x, int y, Uint32 pixel)
|
|||
|
||||
|
||||
|
||||
void InitLUTs(int * LUT16to32, int * RGBtoYUV)
|
||||
void InitLUTs(int * RGBtoYUV)
|
||||
{
|
||||
int i, j, k, r, g, b, Y, u, v;
|
||||
|
||||
for (i = 0; i < 65536; i++)
|
||||
{
|
||||
LUT16to32[i] = (((i & 0xF800) << 8) +
|
||||
((i & 0x07E0) << 5) +
|
||||
((i & 0x001F) << 3));
|
||||
}
|
||||
|
||||
for (i=0; i<32; i++)
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
for (j = 0; j < 64; j++)
|
||||
{
|
||||
|
|
@ -173,163 +181,152 @@ void InitLUTs(int * LUT16to32, int * RGBtoYUV)
|
|||
Y = (r + g + b) >> 2;
|
||||
u = 128 + ((r - b) >> 2);
|
||||
v = 128 + ((-r + 2 * g - b) >> 3);
|
||||
RGBtoYUV[(i << 11) + (j << 5) + k] = (Y<<16) + (u<<8) + v;
|
||||
RGBtoYUV[(i << 11) + (j << 5) + k] = (((Y & 0xF8) << 8) |
|
||||
((u & 0xFE) << 3) |
|
||||
(v >> 3));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline void Interp0(SDL_Surface * dest, int x, int y, int c)
|
||||
inline void Interp0(SDL_Surface * dest, int x, int y, Uint16 c, Uint8 alpha)
|
||||
{
|
||||
Uint8 r, g, b;
|
||||
|
||||
r = (c >> 11) & 0xFF;
|
||||
g = (c >> 5) & 0xFF;
|
||||
b = (c >> 0) & 0xFF;
|
||||
|
||||
hqxx_putpixel(dest, x, y, SDL_MapRGB(dest->format, r, g, b));
|
||||
hqxx_putpixel(dest, x, y, c, alpha);
|
||||
}
|
||||
|
||||
inline void Interp1(SDL_Surface * dest, int x, int y, int c1, int c2)
|
||||
inline void Interp1(SDL_Surface * dest, int x, int y, Uint16 c1, Uint16 c2, Uint8 alpha)
|
||||
{
|
||||
Uint8 r, g, b;
|
||||
Uint16 c;
|
||||
Uint32 c;
|
||||
|
||||
c = (c1 * 3 + c2) >> 2;
|
||||
// c = (c1 * 3 + c2) >> 2;
|
||||
|
||||
c = ((((c1 & 0x07E0) * 3 + (c2 & 0x07E0)) & (0x07E0 << 2)) +
|
||||
(((c1 & 0xF81F) * 3 + (c2 & 0xF81F)) & (0xF81F << 2))) >> 2;
|
||||
|
||||
r = (c >> 11) & 0xFF;
|
||||
g = (c >> 5) & 0xFF;
|
||||
b = (c >> 0) & 0xFF;
|
||||
|
||||
hqxx_putpixel(dest, x, y, SDL_MapRGB(dest->format, r, g, b));
|
||||
hqxx_putpixel(dest, x, y, c, alpha);
|
||||
}
|
||||
|
||||
inline void Interp2(SDL_Surface * dest, int x, int y, int c1, int c2, int c3)
|
||||
inline void Interp2(SDL_Surface * dest, int x, int y, Uint16 c1, Uint16 c2, Uint16 c3, Uint8 alpha)
|
||||
{
|
||||
Uint8 r, g, b;
|
||||
Uint16 c;
|
||||
Uint32 c;
|
||||
|
||||
c = (c1 * 2 + c2 + c3) >> 2;
|
||||
|
||||
r = (c >> 11) & 0xFF;
|
||||
g = (c >> 5) & 0xFF;
|
||||
b = (c >> 0) & 0xFF;
|
||||
/* FIXME? */
|
||||
|
||||
hqxx_putpixel(dest, x, y, SDL_MapRGB(dest->format, r, g, b));
|
||||
// c = (c1 * 2 + c2 + c3) >> 2;
|
||||
|
||||
c = ((((c1 & 0x07E0) * 2 + (c2 & 0x07E0) + (c3 & 0x07E0)) & (0x07E0 << 2)) +
|
||||
(((c1 & 0xF81F) * 2 + (c2 & 0xF81F) + (c3 & 0xF81F)) & (0xF81F << 2)))
|
||||
>> 2;
|
||||
|
||||
|
||||
hqxx_putpixel(dest, x, y, c, alpha);
|
||||
}
|
||||
|
||||
inline void Interp3(SDL_Surface * dest, int x, int y, int c1, int c2)
|
||||
inline void Interp3(SDL_Surface * dest, int x, int y, Uint16 c1, Uint16 c2, Uint8 alpha)
|
||||
{
|
||||
Uint8 r, g, b;
|
||||
Uint16 c;
|
||||
Uint32 c;
|
||||
|
||||
//c = (c1*7+c2)/8;
|
||||
//c = (c1 * 7 + c2) / 8;
|
||||
|
||||
c = ((((c1 & 0x00FF00) * 7 + (c2 & 0x00FF00)) & 0x0007F800) +
|
||||
(((c1 & 0xFF00FF) * 7 + (c2 & 0xFF00FF)) & 0x07F807F8)) >> 3;
|
||||
|
||||
r = (c >> 11) & 0xFF;
|
||||
g = (c >> 5) & 0xFF;
|
||||
b = (c >> 0) & 0xFF;
|
||||
//c = ((((c1 & 0x00FF00) * 7 + (c2 & 0x00FF00)) & 0x0007F800) +
|
||||
// (((c1 & 0xFF00FF) * 7 + (c2 & 0xFF00FF)) & 0x07F807F8)) >> 3;
|
||||
|
||||
hqxx_putpixel(dest, x, y, SDL_MapRGB(dest->format, r, g, b));
|
||||
c = ((((c1 & 0x07E0) * 7 + (c2 & 0x07E0)) & (0x07E0 << 3)) +
|
||||
(((c1 & 0xF81F) * 7 + (c2 & 0xF81F)) & (0xF81F << 3))) >> 3;
|
||||
|
||||
hqxx_putpixel(dest, x, y, c, alpha);
|
||||
}
|
||||
|
||||
inline void Interp4(SDL_Surface * dest, int x, int y, int c1, int c2, int c3)
|
||||
inline void Interp4(SDL_Surface * dest, int x, int y, Uint16 c1, Uint16 c2, Uint16 c3, Uint8 alpha)
|
||||
{
|
||||
Uint8 r, g, b;
|
||||
Uint16 c;
|
||||
Uint32 c;
|
||||
|
||||
//c = (c1*2+(c2+c3)*7)/16;
|
||||
//c = (c1 * 2 + (c2 + c3) * 7) / 16;
|
||||
|
||||
c = ((((c1 & 0x00FF00) * 2 +
|
||||
((c2 & 0x00FF00) +
|
||||
(c3 & 0x00FF00)) * 7) & 0x000FF000) +
|
||||
(((c1 & 0xFF00FF) * 2 +
|
||||
((c2 & 0xFF00FF) +
|
||||
(c3 & 0xFF00FF)) * 7) & 0x0FF00FF0)) >> 4;
|
||||
|
||||
r = (c >> 11) & 0xFF;
|
||||
g = (c >> 5) & 0xFF;
|
||||
b = (c >> 0) & 0xFF;
|
||||
//c = ((((c1 & 0x00FF00) * 2 +
|
||||
// ((c2 & 0x00FF00) +
|
||||
// (c3 & 0x00FF00)) * 7) & 0x000FF000) +
|
||||
// (((c1 & 0xFF00FF) * 2 +
|
||||
// ((c2 & 0xFF00FF) +
|
||||
// (c3 & 0xFF00FF)) * 7) & 0x0FF00FF0)) >> 4;
|
||||
|
||||
hqxx_putpixel(dest, x, y, SDL_MapRGB(dest->format, r, g, b));
|
||||
c = ((((c1 & 0x07E0) * 2 +
|
||||
((c2 & 0x07E0) +
|
||||
(c3 & 0x07E0)) * 7) & 0x7E00) +
|
||||
(((c1 & 0xF81F) * 2 +
|
||||
((c2 & 0xF81F) +
|
||||
(c3 & 0xF81F)) * 7) & 0xF81F0)) >> 4;
|
||||
|
||||
hqxx_putpixel(dest, x, y, c, alpha);
|
||||
}
|
||||
|
||||
inline void Interp5(SDL_Surface * dest, int x, int y, int c1, int c2)
|
||||
inline void Interp5(SDL_Surface * dest, int x, int y, Uint16 c1, Uint16 c2, Uint8 alpha)
|
||||
{
|
||||
Uint8 r, g, b;
|
||||
Uint16 c;
|
||||
Uint32 c;
|
||||
|
||||
c = (c1+c2) >> 1;
|
||||
// c = (c1 + c2) >> 1;
|
||||
|
||||
r = (c >> 11) & 0xFF;
|
||||
g = (c >> 5) & 0xFF;
|
||||
b = (c >> 0) & 0xFF;
|
||||
|
||||
hqxx_putpixel(dest, x, y, SDL_MapRGB(dest->format, r, g, b));
|
||||
c = ((((c1 & 0x07E0) + (c2 & 0x07E0)) & (0x07E0 << 1)) +
|
||||
(((c1 & 0xF81F) + (c2 & 0xF81F)) & (0xF81F << 1))) >> 1;
|
||||
|
||||
hqxx_putpixel(dest, x, y, c, alpha);
|
||||
}
|
||||
|
||||
inline void Interp6(SDL_Surface * dest, int x, int y, int c1, int c2, int c3)
|
||||
inline void Interp6(SDL_Surface * dest, int x, int y, Uint16 c1, Uint16 c2, Uint16 c3, Uint8 alpha)
|
||||
{
|
||||
Uint8 r, g, b;
|
||||
Uint16 c;
|
||||
Uint32 c;
|
||||
|
||||
//c = (c1*5+c2*2+c3)/8;
|
||||
// c = (c1 * 5 + c2 * 2 + c3) / 8;
|
||||
|
||||
c = ((((c1 & 0x00FF00) * 5 +
|
||||
(c2 & 0x00FF00) * 2 + (c3 & 0x00FF00)) & 0x0007F800) +
|
||||
(((c1 & 0xFF00FF) * 5 +
|
||||
(c2 & 0xFF00FF) * 2 + (c3 & 0xFF00FF)) & 0x07F807F8)) >> 3;
|
||||
// c = ((((c1 & 0x00FF00) * 5 +
|
||||
// (c2 & 0x00FF00) * 2 + (c3 & 0x00FF00)) & 0x0007F800) +
|
||||
// (((c1 & 0xFF00FF) * 5 +
|
||||
// (c2 & 0xFF00FF) * 2 + (c3 & 0xFF00FF)) & 0x07F807F8)) >> 3;
|
||||
|
||||
r = (c >> 11) & 0xFF;
|
||||
g = (c >> 5) & 0xFF;
|
||||
b = (c >> 0) & 0xFF;
|
||||
|
||||
hqxx_putpixel(dest, x, y, SDL_MapRGB(dest->format, r, g, b));
|
||||
c = ((((c1 & 0x07E0) * 5 +
|
||||
(c2 & 0x07E0) * 2 + (c3 & 0x07E0)) & (0x07E0 << 3)) +
|
||||
(((c1 & 0xF81F) * 5 +
|
||||
(c2 & 0xF81F) * 2 + (c3 & 0xF81F)) & (0xF81F << 3))) >> 3;
|
||||
|
||||
hqxx_putpixel(dest, x, y, c, alpha);
|
||||
}
|
||||
|
||||
inline void Interp7(SDL_Surface * dest, int x, int y, int c1, int c2, int c3)
|
||||
inline void Interp7(SDL_Surface * dest, int x, int y, Uint16 c1, Uint16 c2, Uint16 c3, Uint8 alpha)
|
||||
{
|
||||
Uint8 r, g, b;
|
||||
Uint16 c;
|
||||
Uint32 c;
|
||||
|
||||
//c = (c1 * 6 + c2 + c3) / 8;
|
||||
|
||||
//c = (c1*6+c2+c3)/8;
|
||||
|
||||
c = ((((c1 & 0x00FF00)*6 + (c2 & 0x00FF00) + (c3 & 0x00FF00)) & 0x0007F800) +
|
||||
(((c1 & 0xFF00FF)*6 + (c2 & 0xFF00FF) + (c3 & 0xFF00FF)) & 0x07F807F8))
|
||||
//c = ((((c1 & 0x00FF00)*6 + (c2 & 0x00FF00) + (c3 & 0x00FF00)) & 0x0007F800) +
|
||||
// (((c1 & 0xFF00FF)*6 + (c2 & 0xFF00FF) + (c3 & 0xFF00FF)) & 0x07F807F8))
|
||||
// >> 3;
|
||||
|
||||
c = ((((c1 & 0x07E0)*6 + (c2 & 0x07E0) + (c3 & 0x07E0)) & (0x07E0 << 3)) +
|
||||
(((c1 & 0xF81F)*6 + (c2 & 0xF81F) + (c3 & 0xF81F)) & (0xF81F << 3)))
|
||||
>> 3;
|
||||
|
||||
r = (c >> 11) & 0xFF;
|
||||
g = (c >> 5) & 0xFF;
|
||||
b = (c >> 0) & 0xFF;
|
||||
|
||||
hqxx_putpixel(dest, x, y, SDL_MapRGB(dest->format, r, g, b));
|
||||
hqxx_putpixel(dest, x, y, c, alpha);
|
||||
}
|
||||
|
||||
inline void Interp8(SDL_Surface * dest, int x, int y, int c1, int c2)
|
||||
inline void Interp8(SDL_Surface * dest, int x, int y, Uint16 c1, Uint16 c2, Uint8 alpha)
|
||||
{
|
||||
Uint8 r, g, b;
|
||||
Uint16 c;
|
||||
Uint32 c;
|
||||
|
||||
//c = (c1*5+c2*3)/8;
|
||||
|
||||
c = ((((c1 & 0x00FF00) * 5 + (c2 & 0x00FF00) * 3) & 0x0007F800) +
|
||||
(((c1 & 0xFF00FF) * 5 + (c2 & 0xFF00FF) * 3) & 0x07F807F8)) >> 3;
|
||||
|
||||
r = (c >> 11) & 0xFF;
|
||||
g = (c >> 5) & 0xFF;
|
||||
b = (c >> 0) & 0xFF;
|
||||
//c = (c1 * 5 + c2 * 3) / 8;
|
||||
|
||||
hqxx_putpixel(dest, x, y, SDL_MapRGB(dest->format, r, g, b));
|
||||
//c = ((((c1 & 0x00FF00) * 5 + (c2 & 0x00FF00) * 3) & 0x0007F800) +
|
||||
// (((c1 & 0xFF00FF) * 5 + (c2 & 0xFF00FF) * 3) & 0x07F807F8)) >> 3;
|
||||
|
||||
c = ((((c1 & 0x07E0) * 5 + (c2 & 0x07E0) * 3) & (0x07E0 << 3)) +
|
||||
(((c1 & 0xF81F) * 5 + (c2 & 0xF81F) * 3) & (0xF81F << 3))) >> 3;
|
||||
|
||||
hqxx_putpixel(dest, x, y, c, alpha);
|
||||
}
|
||||
|
||||
|
||||
inline int Diff(unsigned int w1, unsigned int w2)
|
||||
{
|
||||
YUV1 = w1; /* RGBtoYUV[w1]; */
|
||||
YUV2 = w2; /* RGBtoYUV[w2]; */
|
||||
return ((abs((YUV1 & Ymask) - (YUV2 & Ymask)) > trY) ||
|
||||
(abs((YUV1 & Umask) - (YUV2 & Umask)) > trU) ||
|
||||
(abs((YUV1 & Vmask) - (YUV2 & Vmask)) > trV));
|
||||
return ((abs((w1 & Ymask) - (w2 & Ymask)) > trY) ||
|
||||
(abs((w1 & Umask) - (w2 & Umask)) > trU) ||
|
||||
(abs((w1 & Vmask) - (w2 & Vmask)) > trV));
|
||||
}
|
||||
|
|
|
|||
38
src/hqxx.h
38
src/hqxx.h
|
|
@ -29,26 +29,30 @@
|
|||
|
||||
static int YUV1, YUV2;
|
||||
|
||||
#define Ymask 0x00FF0000
|
||||
#define Umask 0x0000FF00
|
||||
#define Vmask 0x000000FF
|
||||
#define Ymask 0xF800
|
||||
#define Umask 0x07E0
|
||||
#define Vmask 0x001F
|
||||
|
||||
#define trY 0x00300000
|
||||
#define trU 0x00000700
|
||||
#define trV 0x00000006
|
||||
//trY in 32 = 0x00300000
|
||||
//trU in 32 = 0x00000700
|
||||
//trV in 32 = 0x00000006
|
||||
|
||||
#define trY 0x3000
|
||||
#define trU 0x00C0
|
||||
#define trV 0x0006
|
||||
|
||||
|
||||
Uint16 hqxx_getpixel(SDL_Surface * surface, int x, int y);
|
||||
void InitLUTs(int * LUT16to32, int * RGBtoYUV);
|
||||
inline void Interp0(SDL_Surface * dest, int x, int y, int c);
|
||||
inline void Interp1(SDL_Surface * dest, int x, int y, int c1, int c2);
|
||||
inline void Interp2(SDL_Surface * dest, int x, int y, int c1, int c2, int c3);
|
||||
inline void Interp3(SDL_Surface * dest, int x, int y, int c1, int c2);
|
||||
inline void Interp4(SDL_Surface * dest, int x, int y, int c1, int c2, int c3);
|
||||
inline void Interp5(SDL_Surface * dest, int x, int y, int c1, int c2);
|
||||
inline void Interp6(SDL_Surface * dest, int x, int y, int c1, int c2, int c3);
|
||||
inline void Interp7(SDL_Surface * dest, int x, int y, int c1, int c2, int c3);
|
||||
inline void Interp8(SDL_Surface * dest, int x, int y, int c1, int c2);
|
||||
Uint16 hqxx_getpixel(SDL_Surface * surface, int x, int y, Uint8 * alpha);
|
||||
void InitLUTs(int * RGBtoYUV);
|
||||
inline void Interp0(SDL_Surface * dest, int x, int y, Uint16 c, Uint8 alpha);
|
||||
inline void Interp1(SDL_Surface * dest, int x, int y, Uint16 c1, Uint16 c2, Uint8 alpha);
|
||||
inline void Interp2(SDL_Surface * dest, int x, int y, Uint16 c1, Uint16 c2, Uint16 c3, Uint8 alpha);
|
||||
inline void Interp3(SDL_Surface * dest, int x, int y, Uint16 c1, Uint16 c2, Uint8 alpha);
|
||||
inline void Interp4(SDL_Surface * dest, int x, int y, Uint16 c1, Uint16 c2, Uint16 c3, Uint8 alpha);
|
||||
inline void Interp5(SDL_Surface * dest, int x, int y, Uint16 c1, Uint16 c2, Uint8 alpha);
|
||||
inline void Interp6(SDL_Surface * dest, int x, int y, Uint16 c1, Uint16 c2, Uint16 c3, Uint8 alpha);
|
||||
inline void Interp7(SDL_Surface * dest, int x, int y, Uint16 c1, Uint16 c2, Uint16 c3, Uint8 alpha);
|
||||
inline void Interp8(SDL_Surface * dest, int x, int y, Uint16 c1, Uint16 c2, Uint8 alpha);
|
||||
inline int Diff(unsigned int w1, unsigned int w2);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -510,7 +510,7 @@ SDL_Event scrolltimer_event;
|
|||
char * langstr;
|
||||
char * savedir;
|
||||
|
||||
int LUT16to32[65536], RGBtoYUV[65536];
|
||||
int RGBtoYUV[65536];
|
||||
|
||||
|
||||
/* Local function prototypes: */
|
||||
|
|
@ -3021,8 +3021,7 @@ void stamp_draw(int x, int y)
|
|||
}
|
||||
|
||||
|
||||
hq4x_32(img_stamps[cur_stamp], final_surf,
|
||||
LUT16to32, RGBtoYUV);
|
||||
hq4x_32(tmp_surf, final_surf, RGBtoYUV);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -4859,7 +4858,7 @@ void setup(int argc, char * argv[])
|
|||
|
||||
/* Init high quality scaling stuff: */
|
||||
|
||||
InitLUTs(LUT16to32, RGBtoYUV);
|
||||
InitLUTs(RGBtoYUV);
|
||||
|
||||
|
||||
/* Load other images: */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue