1 /*
2  * Copyright (C) 2003 Maxim Stepin ( maxst@hiend3d.com )
3  *
4  * Copyright (C) 2010 Cameron Zemek ( grom@zeminvaders.net)
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 
21 #include <stdint.h>
22 #include "hqx.h"
23 #include "common.h"
24 
25 #define PIXEL00_0     *dp = w[5];
26 #define PIXEL00_10    *dp = Interp1_16(w[5], w[1]);
27 #define PIXEL00_11    *dp = Interp1_16(w[5], w[4]);
28 #define PIXEL00_12    *dp = Interp1_16(w[5], w[2]);
29 #define PIXEL00_20    *dp = Interp2_16(w[5], w[4], w[2]);
30 #define PIXEL00_21    *dp = Interp2_16(w[5], w[1], w[2]);
31 #define PIXEL00_22    *dp = Interp2_16(w[5], w[1], w[4]);
32 #define PIXEL00_60    *dp = Interp6_16(w[5], w[2], w[4]);
33 #define PIXEL00_61    *dp = Interp6_16(w[5], w[4], w[2]);
34 #define PIXEL00_70    *dp = Interp7_16(w[5], w[4], w[2]);
35 #define PIXEL00_90    *dp = Interp9_16(w[5], w[4], w[2]);
36 #define PIXEL00_100   *dp = Interp10_16(w[5], w[4], w[2]);
37 #define PIXEL01_0     *(dp+1) = w[5];
38 #define PIXEL01_10    *(dp+1) = Interp1_16(w[5], w[3]);
39 #define PIXEL01_11    *(dp+1) = Interp1_16(w[5], w[2]);
40 #define PIXEL01_12    *(dp+1) = Interp1_16(w[5], w[6]);
41 #define PIXEL01_20    *(dp+1) = Interp2_16(w[5], w[2], w[6]);
42 #define PIXEL01_21    *(dp+1) = Interp2_16(w[5], w[3], w[6]);
43 #define PIXEL01_22    *(dp+1) = Interp2_16(w[5], w[3], w[2]);
44 #define PIXEL01_60    *(dp+1) = Interp6_16(w[5], w[6], w[2]);
45 #define PIXEL01_61    *(dp+1) = Interp6_16(w[5], w[2], w[6]);
46 #define PIXEL01_70    *(dp+1) = Interp7_16(w[5], w[2], w[6]);
47 #define PIXEL01_90    *(dp+1) = Interp9_16(w[5], w[2], w[6]);
48 #define PIXEL01_100   *(dp+1) = Interp10_16(w[5], w[2], w[6]);
49 #define PIXEL10_0     *(dp+dpL) = w[5];
50 #define PIXEL10_10    *(dp+dpL) = Interp1_16(w[5], w[7]);
51 #define PIXEL10_11    *(dp+dpL) = Interp1_16(w[5], w[8]);
52 #define PIXEL10_12    *(dp+dpL) = Interp1_16(w[5], w[4]);
53 #define PIXEL10_20    *(dp+dpL) = Interp2_16(w[5], w[8], w[4]);
54 #define PIXEL10_21    *(dp+dpL) = Interp2_16(w[5], w[7], w[4]);
55 #define PIXEL10_22    *(dp+dpL) = Interp2_16(w[5], w[7], w[8]);
56 #define PIXEL10_60    *(dp+dpL) = Interp6_16(w[5], w[4], w[8]);
57 #define PIXEL10_61    *(dp+dpL) = Interp6_16(w[5], w[8], w[4]);
58 #define PIXEL10_70    *(dp+dpL) = Interp7_16(w[5], w[8], w[4]);
59 #define PIXEL10_90    *(dp+dpL) = Interp9_16(w[5], w[8], w[4]);
60 #define PIXEL10_100   *(dp+dpL) = Interp10_16(w[5], w[8], w[4]);
61 #define PIXEL11_0     *(dp+dpL+1) = w[5];
62 #define PIXEL11_10    *(dp+dpL+1) = Interp1_16(w[5], w[9]);
63 #define PIXEL11_11    *(dp+dpL+1) = Interp1_16(w[5], w[6]);
64 #define PIXEL11_12    *(dp+dpL+1) = Interp1_16(w[5], w[8]);
65 #define PIXEL11_20    *(dp+dpL+1) = Interp2_16(w[5], w[6], w[8]);
66 #define PIXEL11_21    *(dp+dpL+1) = Interp2_16(w[5], w[9], w[8]);
67 #define PIXEL11_22    *(dp+dpL+1) = Interp2_16(w[5], w[9], w[6]);
68 #define PIXEL11_60    *(dp+dpL+1) = Interp6_16(w[5], w[8], w[6]);
69 #define PIXEL11_61    *(dp+dpL+1) = Interp6_16(w[5], w[6], w[8]);
70 #define PIXEL11_70    *(dp+dpL+1) = Interp7_16(w[5], w[6], w[8]);
71 #define PIXEL11_90    *(dp+dpL+1) = Interp9_16(w[5], w[6], w[8]);
72 #define PIXEL11_100   *(dp+dpL+1) = Interp10_16(w[5], w[6], w[8]);
73 
74 #define HQ2X_BITS 16
75 #define HQ2X_BYTES 2
76 #define HQ2X_TYPE uint16_t
77 #define HQ2X_CPY(to, from) (to) = (from)
78 
79 #define HQ2X_FUNC hq2x_16
80 #define HQ2X_RB_FUNC hq2x_16_rb
81 
82 #define RGB_TO_YUV_FUNC rgb16_to_yuv
83 #define DIFF_FUNC Diff16
84 
85 #include "hq2x-int.h"
86