56#include "nomlib/config.hpp"
57#include "nomlib/math/math_helpers.hpp"
59#define MASK_2 0x0000FF00
60#define MASK_13 0x00FF00FF
61#define MASK_RGB 0x00FFFFFF
62#define MASK_ALPHA 0xFF000000
64#define Ymask 0x00FF0000
65#define Umask 0x0000FF00
66#define Vmask 0x000000FF
75extern uint32 RGBtoYUV[16777216];
78static inline uint32 rgb_to_yuv(uint32 c)
81 return RGBtoYUV[MASK_RGB & c];
93static inline int yuv_diff(
int yuv1,
int yuv2) {
94 return (( abs((yuv1 & Ymask) - (yuv2 & Ymask)) > trY ) ||
95 ( abs((yuv1 & Umask) - (yuv2 & Umask)) > trU ) ||
96 ( abs((yuv1 & Vmask) - (yuv2 & Vmask)) > trV ) );
100static inline int32 Diff(uint32 c1, uint32 c2)
102 return yuv_diff(rgb_to_yuv(c1), rgb_to_yuv(c2));
107static inline uint32 Interpolate_2(uint32 c1,
int w1, uint32 c2, int32 w2, int32 s)
113 (((((c1 & MASK_ALPHA) >> 24) * w1 + ((c2 & MASK_ALPHA) >> 24) * w2) << (24-s)) & MASK_ALPHA) +
114 ((((c1 & MASK_2) * w1 + (c2 & MASK_2) * w2) >> s) & MASK_2) +
115 ((((c1 & MASK_13) * w1 + (c2 & MASK_13) * w2) >> s) & MASK_13);
119static inline uint32 Interpolate_3(uint32 c1, int32 w1, uint32 c2, int32 w2, uint32 c3, int32 w3, int32 s)
122 (((((c1 & MASK_ALPHA) >> 24) * w1 + ((c2 & MASK_ALPHA) >> 24) * w2 + ((c3 & MASK_ALPHA) >> 24) * w3) << (24-s)) & MASK_ALPHA) +
123 ((((c1 & MASK_2) * w1 + (c2 & MASK_2) * w2 + (c3 & MASK_2) * w3) >> s) & MASK_2) +
124 ((((c1 & MASK_13) * w1 + (c2 & MASK_13) * w2 + (c3 & MASK_13) * w3) >> s) & MASK_13);
128static inline uint32 Interp1(uint32 c1, uint32 c2)
131 return Interpolate_2(c1, 3, c2, 1, 2);
135static inline uint32 Interp2(uint32 c1, uint32 c2, uint32 c3)
138 return Interpolate_3(c1, 2, c2, 1, c3, 1, 2);
142static inline uint32 Interp3(uint32 c1, uint32 c2)
145 return Interpolate_2(c1, 7, c2, 1, 3);
149static inline uint32 Interp4(uint32 c1, uint32 c2, uint32 c3)
152 return Interpolate_3(c1, 2, c2, 7, c3, 7, 4);
156static inline uint32 Interp5(uint32 c1, uint32 c2)
159 return Interpolate_2(c1, 1, c2, 1, 1);
163static inline uint32 Interp6(uint32 c1, uint32 c2, uint32 c3)
166 return Interpolate_3(c1, 5, c2, 2, c3, 1, 3);
170static inline uint32 Interp7(uint32 c1, uint32 c2, uint32 c3)
173 return Interpolate_3(c1, 6, c2, 1, c3, 1, 3);
177static inline uint32 Interp8(uint32 c1, uint32 c2)
180 return Interpolate_2(c1, 5, c2, 3, 3);
184static inline uint32 Interp9(uint32 c1, uint32 c2, uint32 c3)
187 return Interpolate_3(c1, 2, c2, 3, c3, 3, 3);
191static inline uint32 Interp10(uint32 c1, uint32 c2, uint32 c3)
194 return Interpolate_3(c1, 14, c2, 1, c3, 1, 4);
199void hq2x_32_rb( uint32* sp, uint32 srb, uint32* dp, uint32 drb, int32 Xres, int32 Yres );
203void hq3x_32_rb( uint32* sp, uint32 srb, uint32* dp, uint32 drb, int32 Xres, int32 Yres );
207void hq4x_32_rb( uint32* sp, uint32 srb, uint32* dp, uint32 drb, int32 Xres, int32 Yres );
210NOM_EXPORT
void hqxInit (
void );
216void hq2x_32 ( uint32* src, uint32* dest, int32 width, int32 height );
222void hq3x_32 ( uint32* src, uint32* dest, int32 width, int32 height );
228void hq4x_32 ( uint32* src, uint32* dest, int32 width, int32 height );