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 u24cpy(dp, w[5]); 26 #define PIXEL00_11 Interp1_24(dp, w[5], w[4]); 27 #define PIXEL00_12 Interp1_24(dp, w[5], w[2]); 28 #define PIXEL00_20 Interp2_24(dp, w[5], w[2], w[4]); 29 #define PIXEL00_50 Interp5_24(dp, w[2], w[4]); 30 #define PIXEL00_80 Interp8_24(dp, w[5], w[1]); 31 #define PIXEL00_81 Interp8_24(dp, w[5], w[4]); 32 #define PIXEL00_82 Interp8_24(dp, w[5], w[2]); 33 #define PIXEL01_0 u24cpy((dp+1), w[5]); 34 #define PIXEL01_10 Interp1_24((dp+1), w[5], w[1]); 35 #define PIXEL01_12 Interp1_24((dp+1), w[5], w[2]); 36 #define PIXEL01_14 Interp1_24((dp+1), w[2], w[5]); 37 #define PIXEL01_21 Interp2_24((dp+1), w[2], w[5], w[4]); 38 #define PIXEL01_31 Interp3_24((dp+1), w[5], w[4]); 39 #define PIXEL01_50 Interp5_24((dp+1), w[2], w[5]); 40 #define PIXEL01_60 Interp6_24((dp+1), w[5], w[2], w[4]); 41 #define PIXEL01_61 Interp6_24((dp+1), w[5], w[2], w[1]); 42 #define PIXEL01_82 Interp8_24((dp+1), w[5], w[2]); 43 #define PIXEL01_83 Interp8_24((dp+1), w[2], w[4]); 44 #define PIXEL02_0 u24cpy((dp+2), w[5]); 45 #define PIXEL02_10 Interp1_24((dp+2), w[5], w[3]); 46 #define PIXEL02_11 Interp1_24((dp+2), w[5], w[2]); 47 #define PIXEL02_13 Interp1_24((dp+2), w[2], w[5]); 48 #define PIXEL02_21 Interp2_24((dp+2), w[2], w[5], w[6]); 49 #define PIXEL02_32 Interp3_24((dp+2), w[5], w[6]); 50 #define PIXEL02_50 Interp5_24((dp+2), w[2], w[5]); 51 #define PIXEL02_60 Interp6_24((dp+2), w[5], w[2], w[6]); 52 #define PIXEL02_61 Interp6_24((dp+2), w[5], w[2], w[3]); 53 #define PIXEL02_81 Interp8_24((dp+2), w[5], w[2]); 54 #define PIXEL02_83 Interp8_24((dp+2), w[2], w[6]); 55 #define PIXEL03_0 u24cpy((dp+3), w[5]); 56 #define PIXEL03_11 Interp1_24((dp+3), w[5], w[2]); 57 #define PIXEL03_12 Interp1_24((dp+3), w[5], w[6]); 58 #define PIXEL03_20 Interp2_24((dp+3), w[5], w[2], w[6]); 59 #define PIXEL03_50 Interp5_24((dp+3), w[2], w[6]); 60 #define PIXEL03_80 Interp8_24((dp+3), w[5], w[3]); 61 #define PIXEL03_81 Interp8_24((dp+3), w[5], w[2]); 62 #define PIXEL03_82 Interp8_24((dp+3), w[5], w[6]); 63 #define PIXEL10_0 u24cpy((dp+dpL), w[5]); 64 #define PIXEL10_10 Interp1_24((dp+dpL), w[5], w[1]); 65 #define PIXEL10_11 Interp1_24((dp+dpL), w[5], w[4]); 66 #define PIXEL10_13 Interp1_24((dp+dpL), w[4], w[5]); 67 #define PIXEL10_21 Interp2_24((dp+dpL), w[4], w[5], w[2]); 68 #define PIXEL10_32 Interp3_24((dp+dpL), w[5], w[2]); 69 #define PIXEL10_50 Interp5_24((dp+dpL), w[4], w[5]); 70 #define PIXEL10_60 Interp6_24((dp+dpL), w[5], w[4], w[2]); 71 #define PIXEL10_61 Interp6_24((dp+dpL), w[5], w[4], w[1]); 72 #define PIXEL10_81 Interp8_24((dp+dpL), w[5], w[4]); 73 #define PIXEL10_83 Interp8_24((dp+dpL), w[4], w[2]); 74 #define PIXEL11_0 u24cpy((dp+dpL+1), w[5]); 75 #define PIXEL11_30 Interp3_24((dp+dpL+1), w[5], w[1]); 76 #define PIXEL11_31 Interp3_24((dp+dpL+1), w[5], w[4]); 77 #define PIXEL11_32 Interp3_24((dp+dpL+1), w[5], w[2]); 78 #define PIXEL11_70 Interp7_24((dp+dpL+1), w[5], w[4], w[2]); 79 #define PIXEL12_0 u24cpy((dp+dpL+2), w[5]); 80 #define PIXEL12_30 Interp3_24((dp+dpL+2), w[5], w[3]); 81 #define PIXEL12_31 Interp3_24((dp+dpL+2), w[5], w[2]); 82 #define PIXEL12_32 Interp3_24((dp+dpL+2), w[5], w[6]); 83 #define PIXEL12_70 Interp7_24((dp+dpL+2), w[5], w[6], w[2]); 84 #define PIXEL13_0 u24cpy((dp+dpL+3), w[5]); 85 #define PIXEL13_10 Interp1_24((dp+dpL+3), w[5], w[3]); 86 #define PIXEL13_12 Interp1_24((dp+dpL+3), w[5], w[6]); 87 #define PIXEL13_14 Interp1_24((dp+dpL+3), w[6], w[5]); 88 #define PIXEL13_21 Interp2_24((dp+dpL+3), w[6], w[5], w[2]); 89 #define PIXEL13_31 Interp3_24((dp+dpL+3), w[5], w[2]); 90 #define PIXEL13_50 Interp5_24((dp+dpL+3), w[6], w[5]); 91 #define PIXEL13_60 Interp6_24((dp+dpL+3), w[5], w[6], w[2]); 92 #define PIXEL13_61 Interp6_24((dp+dpL+3), w[5], w[6], w[3]); 93 #define PIXEL13_82 Interp8_24((dp+dpL+3), w[5], w[6]); 94 #define PIXEL13_83 Interp8_24((dp+dpL+3), w[6], w[2]); 95 #define PIXEL20_0 u24cpy((dp+dpL+dpL), w[5]); 96 #define PIXEL20_10 Interp1_24((dp+dpL+dpL), w[5], w[7]); 97 #define PIXEL20_12 Interp1_24((dp+dpL+dpL), w[5], w[4]); 98 #define PIXEL20_14 Interp1_24((dp+dpL+dpL), w[4], w[5]); 99 #define PIXEL20_21 Interp2_24((dp+dpL+dpL), w[4], w[5], w[8]); 100 #define PIXEL20_31 Interp3_24((dp+dpL+dpL), w[5], w[8]); 101 #define PIXEL20_50 Interp5_24((dp+dpL+dpL), w[4], w[5]); 102 #define PIXEL20_60 Interp6_24((dp+dpL+dpL), w[5], w[4], w[8]); 103 #define PIXEL20_61 Interp6_24((dp+dpL+dpL), w[5], w[4], w[7]); 104 #define PIXEL20_82 Interp8_24((dp+dpL+dpL), w[5], w[4]); 105 #define PIXEL20_83 Interp8_24((dp+dpL+dpL), w[4], w[8]); 106 #define PIXEL21_0 u24cpy((dp+dpL+dpL+1), w[5]); 107 #define PIXEL21_30 Interp3_24((dp+dpL+dpL+1), w[5], w[7]); 108 #define PIXEL21_31 Interp3_24((dp+dpL+dpL+1), w[5], w[8]); 109 #define PIXEL21_32 Interp3_24((dp+dpL+dpL+1), w[5], w[4]); 110 #define PIXEL21_70 Interp7_24((dp+dpL+dpL+1), w[5], w[4], w[8]); 111 #define PIXEL22_0 u24cpy((dp+dpL+dpL+2), w[5]); 112 #define PIXEL22_30 Interp3_24((dp+dpL+dpL+2), w[5], w[9]); 113 #define PIXEL22_31 Interp3_24((dp+dpL+dpL+2), w[5], w[6]); 114 #define PIXEL22_32 Interp3_24((dp+dpL+dpL+2), w[5], w[8]); 115 #define PIXEL22_70 Interp7_24((dp+dpL+dpL+2), w[5], w[6], w[8]); 116 #define PIXEL23_0 u24cpy((dp+dpL+dpL+3), w[5]); 117 #define PIXEL23_10 Interp1_24((dp+dpL+dpL+3), w[5], w[9]); 118 #define PIXEL23_11 Interp1_24((dp+dpL+dpL+3), w[5], w[6]); 119 #define PIXEL23_13 Interp1_24((dp+dpL+dpL+3), w[6], w[5]); 120 #define PIXEL23_21 Interp2_24((dp+dpL+dpL+3), w[6], w[5], w[8]); 121 #define PIXEL23_32 Interp3_24((dp+dpL+dpL+3), w[5], w[8]); 122 #define PIXEL23_50 Interp5_24((dp+dpL+dpL+3), w[6], w[5]); 123 #define PIXEL23_60 Interp6_24((dp+dpL+dpL+3), w[5], w[6], w[8]); 124 #define PIXEL23_61 Interp6_24((dp+dpL+dpL+3), w[5], w[6], w[9]); 125 #define PIXEL23_81 Interp8_24((dp+dpL+dpL+3), w[5], w[6]); 126 #define PIXEL23_83 Interp8_24((dp+dpL+dpL+3), w[6], w[8]); 127 #define PIXEL30_0 u24cpy((dp+dpL+dpL+dpL), w[5]); 128 #define PIXEL30_11 Interp1_24((dp+dpL+dpL+dpL), w[5], w[8]); 129 #define PIXEL30_12 Interp1_24((dp+dpL+dpL+dpL), w[5], w[4]); 130 #define PIXEL30_20 Interp2_24((dp+dpL+dpL+dpL), w[5], w[8], w[4]); 131 #define PIXEL30_50 Interp5_24((dp+dpL+dpL+dpL), w[8], w[4]); 132 #define PIXEL30_80 Interp8_24((dp+dpL+dpL+dpL), w[5], w[7]); 133 #define PIXEL30_81 Interp8_24((dp+dpL+dpL+dpL), w[5], w[8]); 134 #define PIXEL30_82 Interp8_24((dp+dpL+dpL+dpL), w[5], w[4]); 135 #define PIXEL31_0 u24cpy((dp+dpL+dpL+dpL+1), w[5]); 136 #define PIXEL31_10 Interp1_24((dp+dpL+dpL+dpL+1), w[5], w[7]); 137 #define PIXEL31_11 Interp1_24((dp+dpL+dpL+dpL+1), w[5], w[8]); 138 #define PIXEL31_13 Interp1_24((dp+dpL+dpL+dpL+1), w[8], w[5]); 139 #define PIXEL31_21 Interp2_24((dp+dpL+dpL+dpL+1), w[8], w[5], w[4]); 140 #define PIXEL31_32 Interp3_24((dp+dpL+dpL+dpL+1), w[5], w[4]); 141 #define PIXEL31_50 Interp5_24((dp+dpL+dpL+dpL+1), w[8], w[5]); 142 #define PIXEL31_60 Interp6_24((dp+dpL+dpL+dpL+1), w[5], w[8], w[4]); 143 #define PIXEL31_61 Interp6_24((dp+dpL+dpL+dpL+1), w[5], w[8], w[7]); 144 #define PIXEL31_81 Interp8_24((dp+dpL+dpL+dpL+1), w[5], w[8]); 145 #define PIXEL31_83 Interp8_24((dp+dpL+dpL+dpL+1), w[8], w[4]); 146 #define PIXEL32_0 u24cpy((dp+dpL+dpL+dpL+2), w[5]); 147 #define PIXEL32_10 Interp1_24((dp+dpL+dpL+dpL+2), w[5], w[9]); 148 #define PIXEL32_12 Interp1_24((dp+dpL+dpL+dpL+2), w[5], w[8]); 149 #define PIXEL32_14 Interp1_24((dp+dpL+dpL+dpL+2), w[8], w[5]); 150 #define PIXEL32_21 Interp2_24((dp+dpL+dpL+dpL+2), w[8], w[5], w[6]); 151 #define PIXEL32_31 Interp3_24((dp+dpL+dpL+dpL+2), w[5], w[6]); 152 #define PIXEL32_50 Interp5_24((dp+dpL+dpL+dpL+2), w[8], w[5]); 153 #define PIXEL32_60 Interp6_24((dp+dpL+dpL+dpL+2), w[5], w[8], w[6]); 154 #define PIXEL32_61 Interp6_24((dp+dpL+dpL+dpL+2), w[5], w[8], w[9]); 155 #define PIXEL32_82 Interp8_24((dp+dpL+dpL+dpL+2), w[5], w[8]); 156 #define PIXEL32_83 Interp8_24((dp+dpL+dpL+dpL+2), w[8], w[6]); 157 #define PIXEL33_0 u24cpy((dp+dpL+dpL+dpL+3), w[5]); 158 #define PIXEL33_11 Interp1_24((dp+dpL+dpL+dpL+3), w[5], w[6]); 159 #define PIXEL33_12 Interp1_24((dp+dpL+dpL+dpL+3), w[5], w[8]); 160 #define PIXEL33_20 Interp2_24((dp+dpL+dpL+dpL+3), w[5], w[8], w[6]); 161 #define PIXEL33_50 Interp5_24((dp+dpL+dpL+dpL+3), w[8], w[6]); 162 #define PIXEL33_80 Interp8_24((dp+dpL+dpL+dpL+3), w[5], w[9]); 163 #define PIXEL33_81 Interp8_24((dp+dpL+dpL+dpL+3), w[5], w[6]); 164 #define PIXEL33_82 Interp8_24((dp+dpL+dpL+dpL+3), w[5], w[8]); 165 166 #define HQ4X_BITS 24 167 #define HQ4X_BYTES 3 168 #define HQ4X_TYPE uint24_t 169 #define HQ4X_CPY(to, from) u24cpy(&(to), (from)) 170 171 #define HQ4X_FUNC hq4x_24 172 #define HQ4X_RB_FUNC hq4x_24_rb 173 174 #define RGB_TO_YUV_FUNC rgb24_to_yuv 175 #define DIFF_FUNC Diff24 176 177 #include "hq4x-int.h" 178