Debian Codegraph @

src/shaders/h264/mc/interpolate_Y_4x4.asm

raw
1 /*
2 * Interpolation kernel for luminance motion compensation
3 * Copyright © <2010>, Intel Corporation.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sub license, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
12 *
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial portions
15 * of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
20 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
21 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 *
25 * This file was originally licensed under the following license
26 *
27 * Licensed under the Apache License, Version 2.0 (the "License");
28 * you may not use this file except in compliance with the License.
29 * You may obtain a copy of the License at
30 *
31 * http://www.apache.org/licenses/LICENSE-2.0
32 *
33 * Unless required by applicable law or agreed to in writing, software
34 * distributed under the License is distributed on an "AS IS" BASIS,
35 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
36 * See the License for the specific language governing permissions and
37 * limitations under the License.
38 *
39 */
40 // Kernel name: Interpolate_Y_4x4.asm
41 //
42 // Interpolation kernel for luminance motion compensation
43 //
44 // $Revision: 10 $
45 // $Date: 10/09/06 4:00p $
46 //
47
48
49 // Compute the GRF address of the starting position of the reference area
50 #if 1
51 (-f0.1) mov (1) pREF:w nOFFSET_REF+2+nGRFWIB:w
52 (f0.1) mov (1) pREF:w nOFFSET_REF+2:w
53 mov (1) pRESULT:uw gpINTPY:uw
54 #else
55 mov (1) pREF:w nOFFSET_REF+2+nGRFWIB:w {NoDDClr}
56 mov (1) pRESULT:uw gpINTPY:uw {NoDDChk}
57 #endif
58
59 /*
60 * | |
61 * - - 0 1 2 3 + -
62 * 4 5 6 7
63 * 8 9 A B
64 * C D E F
65 * - - + - - - + -
66 * | |
67 */
68
69 // Case 0
70 or.z.f0.1 (16) null:w gMVY_FRAC<0;1,0>:w gMVX_FRAC<0;1,0>:w
71 (f0.1) mov (4) r[pRESULT]<1>:uw r[pREF0]<4;4,1>:ub
72 (f0.1) mov (4) r[pRESULT,16]<1>:uw r[pREF0,16]<4;4,1>:ub
73 (f0.1) mov (4) r[pRESULT,32]<1>:uw r[pREF0,32]<4;4,1>:ub
74 (f0.1) mov (4) r[pRESULT,48]<1>:uw r[pREF0,48]<4;4,1>:ub
75 (f0.1) jmpi INTERLABEL(Exit_Interpolate_Y_4x4)
76
77 // Store all address registers
78 mov (8) gpADDR<1>:w a0<8;8,1>:w
79
80 mul.z.f0.0 (1) gW4:w gMVY_FRAC:w gMVX_FRAC:w
81 and.nz.f0.1 (1) null gW4:w 1:w
82
83 add (1) pREF1:uw pREF0:uw nGRFWIB/2:uw
84 add (2) pREF2<1>:uw pREF0<2;2,1>:uw nGRFWIB:uw
85 mov (4) gW0<1>:uw pREF0<4;4,1>:uw
86
87 (f0.0) jmpi INTERLABEL(Interpolate_Y_H_4x4)
88 (f0.1) jmpi INTERLABEL(Interpolate_Y_H_4x4)
89
90 //-----------------------------------------------------------------------
91 // CASE: A69BE (H/V interpolation)
92 //-----------------------------------------------------------------------
93
94 // Compute interim horizontal intepolation
95 add (1) pREF0<1>:uw pREF0<0;1,0>:uw -34:w
96 add (1) pREF1<1>:uw pREF1<0;1,0>:uw -18:w {NoDDClr}
97 mov (1) pRESD:ud nOFFSET_INTERIM4x4_5:ud {NoDDChk} // Case 69be
98
99 // Check whether this position is 'A'
100 cmp.e.f0.0 (1) null gW4:w 4:w
101
102 $for(0;<2;1) {
103 add (16) acc0<1>:w r[pREF0,nGRFWIB*2*%1]<16;4,1>:ub r[pREF0,nGRFWIB*2*%1+5]<16;4,1>:ub {Compr}
104 mac (16) acc0<1>:w r[pREF0,nGRFWIB*2*%1+1]<16;4,1>:ub -5:w {Compr}
105 mac (16) acc0<1>:w r[pREF0,nGRFWIB*2*%1+2]<16;4,1>:ub 20:w {Compr}
106 mac (16) acc0<1>:w r[pREF0,nGRFWIB*2*%1+3]<16;4,1>:ub 20:w {Compr}
107 mac (16) r[pRES,nGRFWIB*%1]<1>:w r[pREF0,nGRFWIB*2*%1+4]<16;4,1>:ub -5:w {Compr}
108 }
109 // last line
110 add (4) acc0<1>:w r[pREF0,nGRFWIB*2*2]<4;4,1>:ub r[pREF0,nGRFWIB*2*2+5]<4;4,1>:ub
111 mac (4) acc0<1>:w r[pREF0,nGRFWIB*2*2+1]<4;4,1>:ub -5:w
112 mac (4) acc0<1>:w r[pREF0,nGRFWIB*2*2+2]<4;4,1>:ub 20:w
113 mac (4) acc0<1>:w r[pREF0,nGRFWIB*2*2+3]<4;4,1>:ub 20:w
114 mac (4) r[pRES,nGRFWIB*2]<1>:w r[pREF0,nGRFWIB*2*2+4]<4;4,1>:ub -5:w
115
116 // Compute interim/output vertical interpolation
117 mov (1) pREF6D:ud nOFFSET_INTERIM4x4_4:ud {NoDDClr}
118 mov (1) pREF0D:ud nOFFSET_INTERIM4x4_7:ud {NoDDChk,NoDDClr}
119 mov (1) pREF2D:ud nOFFSET_INTERIM4x4_8:ud {NoDDChk,NoDDClr}
120 mov (1) pREF4D:ud nOFFSET_INTERIM4x4_9:ud {NoDDChk}
121
122 add (16) acc0<1>:w gwINTERIM4x4_BUF(0)<16;16,1> 512:w
123 mac (16) acc0<1>:w gwINTERIM4x4_BUF(1)<16;16,1> -5:w
124 mac (16) acc0<1>:w r[pREF6,0]<8,1>:w 20:w
125
126 (f0.0) mov (1) pRES:uw nOFFSET_RES:uw // Case a
127 (-f0.0) mov (1) pRES:uw nOFFSET_INTERIM4x4:uw // Case 69be
128
129 mac (16) acc0<1>:w r[pREF0,0]<4,1>:w -5:w
130 mac (16) acc0<1>:w r[pREF0,nGRFWIB]<4,1>:w 1:w
131 mac (16) acc0<1>:w r[pREF2,0]<4,1>:w 20:w
132 asr.sat (16) r[pRES]<2>:ub acc0<16;16,1>:w 10:w
133
134 (f0.0) jmpi INTERLABEL(Return_Interpolate_Y_4x4)
135
136 INTERLABEL(Interpolate_Y_H_4x4):
137
138 cmp.e.f0.0 (1) null gMVX_FRAC:w 0:w
139 cmp.e.f0.1 (1) null gMVY_FRAC:w 2:w
140 (f0.0) jmpi INTERLABEL(Interpolate_Y_V_4x4)
141 (f0.1) jmpi INTERLABEL(Interpolate_Y_V_4x4)
142
143 //-----------------------------------------------------------------------
144 // CASE: 123567DEF (H interpolation)
145 //-----------------------------------------------------------------------
146
147 add (4) pREF0<1>:uw gW0<4;4,1>:uw -2:w
148 cmp.g.f0.0 (4) null:w gMVY_FRAC<0;1,0>:w 2:w
149 cmp.e.f0.1 (1) null gMVX_FRAC:w 2:w
150 (f0.0) add (4) pREF0<1>:uw pREF0<4;4,1>:uw nGRFWIB/2:uw
151
152 cmp.e.f0.0 (1) null:w gMVY_FRAC<0;1,0>:w 0:w
153
154 (f0.1) mov (1) pRESULT:uw nOFFSET_RES:uw // Case 26E
155 (-f0.1) mov (1) pRESULT:uw nOFFSET_INTERIM4x4:uw // Case 1357DF
156
157 // Compute interim/output horizontal interpolation
158 add (16) acc0<1>:w r[pREF0]<4,1>:ub 16:w
159 mac (16) acc0<1>:w r[pREF0,1]<4,1>:ub -5:w
160 mac (16) acc0<1>:w r[pREF0,2]<4,1>:ub 20:w
161 mac (16) acc0<1>:w r[pREF0,3]<4,1>:ub 20:w
162 mac (16) acc0<1>:w r[pREF0,4]<4,1>:ub -5:w
163 mac (16) acc0<1>:w r[pREF0,5]<4,1>:ub 1:w
164 asr.sat (16) r[pRESULT]<2>:ub acc0<16;16,1>:w 5:w
165
166 (-f0.1) jmpi INTERLABEL(Interpolate_Y_V_4x4)
167 (-f0.0) jmpi INTERLABEL(Average_4x4)
168
169 jmpi INTERLABEL(Return_Interpolate_Y_4x4)
170
171 INTERLABEL(Interpolate_Y_V_4x4):
172
173 cmp.e.f0.0 (1) null gMVY_FRAC:w 0:w
174 (f0.0) jmpi INTERLABEL(Interpolate_Y_I_4x4)
175
176 //-----------------------------------------------------------------------
177 // CASE: 48C59D7BF (V interpolation)
178 //-----------------------------------------------------------------------
179
180 cmp.g.f0.1 (8) null:w gMVX_FRAC<0;1,0>:w 2:w
181
182 mov (4) pREF0<1>:uw gW0<4;4,1>:uw {NoDDClr}
183 add (4) pREF4<1>:w gW0<4;4,1>:uw 16:w {NoDDChk}
184
185 (f0.1) add (8) pREF0<1>:uw pREF0<4;4,1>:uw 1:uw
186
187 cmp.e.f0.0 (1) null:w gMVX_FRAC<0;1,0>:w 0:w
188 cmp.e.f0.1 (1) null gMVY_FRAC:w 2:w
189
190 // Compute interim/output vertical interpolation
191 add (16) acc0<1>:w r[pREF0,-nGRFWIB]<4,1>:ub 16:w
192 mac (16) acc0<1>:w r[pREF0]<4,1>:ub 20:w
193 mac (16) acc0<1>:w r[pREF0,nGRFWIB]<4,1>:ub -5:w
194 mac (16) acc0<1>:w r[pREF4,-nGRFWIB]<4,1>:ub -5:w
195 mac (16) acc0<1>:w r[pREF4]<4,1>:ub 20:w
196 mac (16) acc0<1>:w r[pREF4,nGRFWIB]<4,1>:ub 1:w
197
198 mov (1) pRESULT:uw nOFFSET_RES:uw
199 (-f0.0) jmpi INTERLABEL(VFILTER_4x4)
200 (-f0.1) mov (1) pRESULT:uw nOFFSET_INTERIM4x4:uw
201
202 INTERLABEL(VFILTER_4x4):
203
204 asr.sat (16) r[pRESULT]<2>:ub acc0<16;16,1>:w 5:w
205
206 (-f0.0) jmpi INTERLABEL(Average_4x4)
207 (f0.1) jmpi INTERLABEL(Return_Interpolate_Y_4x4 )
208
209 INTERLABEL(Interpolate_Y_I_4x4):
210
211 //-----------------------------------------------------------------------
212 // CASE: 134C (Integer position)
213 //-----------------------------------------------------------------------
214
215 mov (4) pREF0<1>:uw gW0<4;4,1>:uw
216
217 cmp.e.f0.0 (4) null:w gMVX_FRAC<0;1,0>:w 3:w
218 cmp.e.f0.1 (4) null:w gMVY_FRAC<0;1,0>:w 3:w
219 (f0.0) add (4) pREF0<1>:uw pREF0<4;4,1>:uw 1:uw
220 (f0.1) add (4) pREF0<1>:uw pREF0<4;4,1>:uw nGRFWIB/2:uw
221
222 mov (16) guwINTERIM_BUF2(0)<1> r[pREF0]<4,1>:ub
223
224 INTERLABEL(Average_4x4):
225
226 //-----------------------------------------------------------------------
227 // CASE: 13456789BCDEF (Average)
228 //-----------------------------------------------------------------------
229
230 // Average two interim results
231 avg.sat (16) gubINTERIM_BUF2(0)<2> gubINTERIM_BUF2(0)<32;16,2> gINTERIM4x4<32;16,2>:ub
232
233 INTERLABEL(Return_Interpolate_Y_4x4):
234 // Move result
235 mov (1) pRES:uw gpINTPY:uw
236 mov (4) r[pRES,0]<2>:ub gubINTERIM_BUF2(0,0)
237 mov (4) r[pRES,16]<2>:ub gubINTERIM_BUF2(0,8)
238 mov (4) r[pRES,32]<2>:ub gubINTERIM_BUF2(0,16)
239 mov (4) r[pRES,48]<2>:ub gubINTERIM_BUF2(0,24)
240
241 // Restore all address registers
242 mov (8) a0<1>:w gpADDR<8;8,1>:w
243
244 INTERLABEL(Exit_Interpolate_Y_4x4):
245
246
247 // end of file