2 * Interpolation kernel for luminance motion compensation
\r
3 * Copyright © <2010>, Intel Corporation.
\r
5 * This program is licensed under the terms and conditions of the
\r
6 * Eclipse Public License (EPL), version 1.0. The full text of the EPL is at
\r
7 * http://www.opensource.org/licenses/eclipse-1.0.php.
\r
10 // Kernel name: Interpolate_Y_8x8.asm
\r
12 // Interpolation kernel for luminance motion compensation
\r
15 // $Date: 10/09/06 4:00p $
\r
19 //---------------------------------------------------------------
\r
20 // In: pMV => Source address of MV
\r
21 // In: gMVX_FRAC<2;2,1>:w => MV fractional components
\r
22 // In: f0.1 (1) => If 1, vertical MV is integer
\r
23 // In: gpINTPY:uw => Destination address for interpolated result
\r
24 // In: Reference area staring from R43
\r
25 // If horizontal/vertical MVs are all integer, 8x8 pixels are on R43~R44 (2 GRFs)
\r
26 // If only horz MV is integer, 8x13 pixels are on R43~R46 (4 GRFs)
\r
27 // If only vert MV is integer, 13x8 pixels are on R43~R46 (4 GRFs)
\r
28 // If no MVs are integer, 13x13 pixels are on R43~R49 (7 GRFs)
\r
29 //---------------------------------------------------------------
\r
32 INTERLABEL(Interpolate_Y_8x8_Func):
\r
36 // Check whether MVX is integer MV
\r
37 and.z.f0.0 (1) null:w r[pMV,0]<0;1,0>:w 0x3:w
\r
38 (-f0.0) jmpi (1) INTERLABEL(Interpolate_Y_8x8_Func2)
\r
40 // TODO: remove this back-to-back read - huge latency..
\r
41 mov (8) gubREF(6,2)<1> gubREF(3,0)<8;8,1>
\r
42 mov (8) gubREF(5,18)<1> gubREF(2,24)<8;8,1> {NoDDClr}
\r
43 mov (8) gubREF(5,2)<1> gubREF(2,16)<8;8,1> {NoDDChk}
\r
44 mov (8) gubREF(4,18)<1> gubREF(2,8)<8;8,1> {NoDDClr}
\r
45 mov (8) gubREF(4,2)<1> gubREF(2,0)<8;8,1> {NoDDChk}
\r
46 mov (8) gubREF(3,18)<1> gubREF(1,24)<8;8,1> {NoDDClr}
\r
47 mov (8) gubREF(3,2)<1> gubREF(1,16)<8;8,1> {NoDDChk}
\r
48 mov (8) gubREF(2,18)<1> gubREF(1,8)<8;8,1> {NoDDClr}
\r
49 mov (8) gubREF(2,2)<1> gubREF(1,0)<8;8,1> {NoDDChk}
\r
50 mov (8) gubREF(1,18)<1> gubREF(0,24)<8;8,1> {NoDDClr}
\r
51 mov (8) gubREF(1,2)<1> gubREF(0,16)<8;8,1> {NoDDChk}
\r
52 mov (8) gubREF(0,18)<1> gubREF(0,8)<8;8,1>
\r
53 mov (8) gubREF(0,2)<1> gubREF(0,0)<8;8,1>
\r
55 INTERLABEL(Interpolate_Y_8x8_Func2):
\r
57 // Compute the GRF address of the starting position of the reference area
\r
58 (-f0.1) mov (1) pREF:w nOFFSET_REF+2+nGRFWIB:w
\r
59 (f0.1) mov (1) pREF:w nOFFSET_REF+2:w
\r
60 mov (1) pRESULT:uw gpINTPY:uw
\r
73 or.z.f0.1 (16) null:w gMVY_FRAC<0;1,0>:w gMVX_FRAC<0;1,0>:w
\r
74 (f0.1) mov (16) r[pRESULT]<1>:uw r[pREF]<16;8,1>:ub
\r
75 (f0.1) mov (16) r[pRESULT,nGRFWIB]<1>:uw r[pREF,nGRFWIB]<16;8,1>:ub
\r
76 (f0.1) mov (16) r[pRESULT,nGRFWIB*2]<1>:uw r[pREF,nGRFWIB*2]<16;8,1>:ub
\r
77 (f0.1) mov (16) r[pRESULT,nGRFWIB*3]<1>:uw r[pREF,nGRFWIB*3]<16;8,1>:ub
\r
78 (f0.1) jmpi INTERLABEL(Exit_Interpolate_Y_8x8)
\r
80 // Store all address registers
\r
81 mov (8) gpADDR<1>:w a0<8;8,1>:w
\r
83 mul.z.f0.0 (1) gW4:w gMVY_FRAC:w gMVX_FRAC:w
\r
84 add (1) pREF1:uw pREF0:uw nGRFWIB/2:uw
\r
85 and.nz.f0.1 (1) null gW4:w 1:w
\r
86 add (2) pREF2<1>:uw pREF0<2;2,1>:uw nGRFWIB:uw
\r
87 mov (4) gW0<1>:uw pREF0<4;4,1>:uw
\r
89 (f0.0) jmpi INTERLABEL(Interpolate_Y_H_8x8)
\r
90 (f0.1) jmpi INTERLABEL(Interpolate_Y_H_8x8)
\r
92 //-----------------------------------------------------------------------
\r
93 // CASE: A69BE (H/V interpolation)
\r
94 //-----------------------------------------------------------------------
\r
96 // Compute interim horizontal intepolation of 12 lines (not 9 lines)
\r
97 // add (1) pREF0<1>:ud pREF0<0;1,0>:ud 0xffeeffde:ud // (-18<<16)|(-34)
\r
98 add (1) pREF0<1>:uw pREF0<0;1,0>:uw -34:w
\r
99 add (1) pREF1<1>:uw pREF1<0;1,0>:uw -18:w {NoDDClr}
\r
100 mov (1) pRESD:ud nOFFSET_INTERIM3:ud {NoDDChk}
\r
102 // Check whether this position is 'A'
\r
103 cmp.e.f0.0 (1) null gW4:w 4:w
\r
106 add (32) acc0<1>:w r[pREF,nGRFWIB*%1]<16;8,1>:ub r[pREF0,nGRFWIB*%1+5]<16;8,1>:ub {Compr}
\r
107 mac (32) acc0<1>:w r[pREF,nGRFWIB*%1+1]<16;8,1>:ub -5:w {Compr}
\r
108 mac (32) acc0<1>:w r[pREF,nGRFWIB*%1+2]<16;8,1>:ub 20:w {Compr}
\r
109 mac (32) acc0<1>:w r[pREF,nGRFWIB*%1+3]<16;8,1>:ub 20:w {Compr}
\r
110 mac (32) r[pRES,nGRFWIB*%1]<1>:w r[pREF,nGRFWIB*%1+4]<16;8,1>:ub -5:w {Compr}
\r
113 add (8) acc0<1>:w r[pREF,nGRFWIB*6]<8;8,1>:ub r[pREF,nGRFWIB*6+5]<8;8,1>:ub
\r
114 mac (8) acc0<1>:w r[pREF,nGRFWIB*6+1]<8;8,1>:ub -5:w
\r
115 mac (8) acc0<1>:w r[pREF,nGRFWIB*6+2]<8;8,1>:ub 20:w
\r
116 mac (8) acc0<1>:w r[pREF,nGRFWIB*6+3]<8;8,1>:ub 20:w
\r
117 mac (8) r[pRES,nGRFWIB*6]<1>:w r[pREF,nGRFWIB*6+4]<8;8,1>:ub -5:w
\r
119 // Compute interim/output vertical interpolation
\r
120 mov (1) pREF0:ud nOFFSET_INTERIM2:ud {NoDDClr} // set pREF0 and pREF1 at the same time
\r
121 mov (1) pREF2D:ud nOFFSET_INTERIM4:ud {NoDDChk,NoDDClr} // set pREF2 and pREF3 at the same time
\r
122 (f0.0) sel (1) pRES:uw gpINTPY:uw nOFFSET_INTERIM:uw {NoDDChk} // Case A vs. 69BE
\r
125 add (32) acc0<1>:w r[pREF0,nGRFWIB*%1]<16;16,1>:w 512:w {Compr}
\r
126 mac (16) acc0<1>:w r[pREF2,nGRFWIB*%1]<8,1>:w -5:w
\r
127 mac (16) acc1<1>:w r[pREF2,nGRFWIB*%1+nGRFWIB]<8,1>:w -5:w
\r
128 mac (32) acc0<1>:w r[pREF0,nGRFWIB*%1+nGRFWIB]<16;16,1>:w 20:w {Compr}
\r
129 mac (16) acc0<1>:w r[pREF2,nGRFWIB*%1+nGRFWIB]<8,1>:w 20:w
\r
130 mac (16) acc1<1>:w r[pREF2,nGRFWIB*%1+nGRFWIB+nGRFWIB]<8,1>:w 20:w
\r
131 mac (32) acc0<1>:w r[pREF0,(2+%1)*nGRFWIB]<16;16,1>:w -5:w {Compr}
\r
132 mac (16) acc0<1>:w r[pREF2,(2+%1)*nGRFWIB]<8,1>:w 1:w
\r
133 mac (16) acc1<1>:w r[pREF2,(2+%1)*nGRFWIB+nGRFWIB]<8,1>:w 1:w
\r
134 asr.sat (16) r[pRES,nGRFWIB*%1]<2>:ub acc0<16;16,1>:w 10:w
\r
135 asr.sat (16) r[pRES,nGRFWIB*%1+nGRFWIB]<2>:ub acc1<16;16,1>:w 10:w {SecHalf}
\r
138 (f0.0) jmpi INTERLABEL(Return_Interpolate_Y_8x8)
\r
140 INTERLABEL(Interpolate_Y_H_8x8):
\r
142 cmp.e.f0.0 (1) null gMVX_FRAC:w 0:w
\r
143 cmp.e.f0.1 (1) null gMVY_FRAC:w 2:w
\r
144 (f0.0) jmpi INTERLABEL(Interpolate_Y_V_8x8)
\r
145 (f0.1) jmpi INTERLABEL(Interpolate_Y_V_8x8)
\r
147 //-----------------------------------------------------------------------
\r
148 // CASE: 123567DEF (H interpolation)
\r
149 //-----------------------------------------------------------------------
\r
151 add (4) pREF0<1>:uw gW0<4;4,1>:uw -2:w
\r
152 cmp.g.f0.0 (4) null:w gMVY_FRAC<0;1,0>:w 2:w
\r
153 cmp.e.f0.1 (1) null gMVX_FRAC:w 2:w
\r
154 (f0.0) add (4) pREF0<1>:uw pREF0<4;4,1>:uw nGRFWIB/2:uw
\r
156 cmp.e.f0.0 (1) null:w gMVY_FRAC<0;1,0>:w 0:w
\r
158 (f0.1) sel (1) pRES:uw gpINTPY:uw nOFFSET_INTERIM:uw // Case 26E vs. 1357DF
\r
160 // Compute interim/output horizontal interpolation
\r
162 add (16) acc0<1>:w r[pREF0,nGRFWIB*%1]<8,1>:ub 16:w
\r
163 add (16) acc1<1>:w r[pREF0,nGRFWIB*%1+nGRFWIB]<8,1>:ub 16:w
\r
164 mac (16) acc0<1>:w r[pREF0,nGRFWIB*%1+1]<8,1>:ub -5:w
\r
165 mac (16) acc1<1>:w r[pREF0,nGRFWIB*%1+1+nGRFWIB]<8,1>:ub -5:w
\r
166 mac (16) acc0<1>:w r[pREF0,nGRFWIB*%1+2]<8,1>:ub 20:w
\r
167 mac (16) acc1<1>:w r[pREF0,nGRFWIB*%1+2+nGRFWIB]<8,1>:ub 20:w
\r
168 mac (16) acc0<1>:w r[pREF0,nGRFWIB*%1+3]<8,1>:ub 20:w
\r
169 mac (16) acc1<1>:w r[pREF0,nGRFWIB*%1+3+nGRFWIB]<8,1>:ub 20:w
\r
170 mac (16) acc0<1>:w r[pREF0,nGRFWIB*%1+4]<8,1>:ub -5:w
\r
171 mac (16) acc1<1>:w r[pREF0,nGRFWIB*%1+4+nGRFWIB]<8,1>:ub -5:w
\r
172 mac (16) acc0<1>:w r[pREF0,nGRFWIB*%1+5]<8,1>:ub 1:w
\r
173 mac (16) acc1<1>:w r[pREF0,nGRFWIB*%1+5+nGRFWIB]<8,1>:ub 1:w
\r
174 asr.sat (16) r[pRES,nGRFWIB*%1]<2>:ub acc0<16;16,1>:w 5:w
\r
175 asr.sat (16) r[pRES,nGRFWIB*%1+nGRFWIB]<2>:ub acc1<16;16,1>:w 5:w {SecHalf}
\r
178 (-f0.1) jmpi INTERLABEL(Interpolate_Y_V_8x8)
\r
179 (-f0.0) jmpi INTERLABEL(Average_8x8)
\r
181 jmpi INTERLABEL(Return_Interpolate_Y_8x8)
\r
183 INTERLABEL(Interpolate_Y_V_8x8):
\r
185 cmp.e.f0.0 (1) null gMVY_FRAC:w 0:w
\r
186 (f0.0) jmpi INTERLABEL(Interpolate_Y_I_8x8)
\r
188 //-----------------------------------------------------------------------
\r
189 // CASE: 48C59D7BF (V interpolation)
\r
190 //-----------------------------------------------------------------------
\r
192 mov (2) pREF0<1>:uw gW0<4;2,2>:uw {NoDDClr}
\r
193 mov (2) pREF2<1>:uw gW1<2;2,1>:uw {NoDDChk,NoDDClr}
\r
194 mov (1) pRES:uw gpINTPY:uw {NoDDChk}
\r
196 cmp.g.f0.1 (4) null:w gMVX_FRAC<0;1,0>:w 2:w
\r
197 cmp.e.f0.0 (1) null:w gMVX_FRAC<0;1,0>:w 0:w
\r
198 (f0.1) add (4) pREF0<1>:uw pREF0<4;4,1>:uw 1:uw
\r
200 cmp.e.f0.1 (1) null gMVY_FRAC:w 2:w
\r
201 (-f0.0) jmpi INTERLABEL(VFILTER_8x8)
\r
202 (-f0.1) mov (1) pRES:uw nOFFSET_INTERIM:uw
\r
204 INTERLABEL(VFILTER_8x8):
\r
206 // Compute interim/output vertical interpolation
\r
208 add (32) acc0<1>:w r[pREF0,nGRFWIB*%1-nGRFWIB]<16;8,1>:ub 16:w {Compr}
\r
209 mac (16) acc0<1>:w r[pREF2,nGRFWIB*%1-nGRFWIB]<8,1>:ub -5:w
\r
210 mac (16) acc1<1>:w r[pREF2,nGRFWIB*%1]<8,1>:ub -5:w
\r
211 mac (32) acc0<1>:w r[pREF0,nGRFWIB*%1]<16;8,1>:ub 20:w {Compr}
\r
212 mac (16) acc0<1>:w r[pREF2,nGRFWIB*%1]<8,1>:ub 20:w
\r
213 mac (16) acc1<1>:w r[pREF2,nGRFWIB*%1+nGRFWIB]<8,1>:ub 20:w
\r
214 mac (32) acc0<1>:w r[pREF0,nGRFWIB*%1+nGRFWIB]<16;8,1>:ub -5:w {Compr}
\r
215 mac (16) acc0<1>:w r[pREF2,nGRFWIB*%1+nGRFWIB]<8,1>:ub 1:w
\r
216 mac (16) acc1<1>:w r[pREF2,nGRFWIB*%1+nGRFWIB+nGRFWIB]<8,1>:ub 1:w
\r
217 asr.sat (16) r[pRES,nGRFWIB*%1]<2>:ub acc0<16;16,1>:w 5:w
\r
218 asr.sat (16) r[pRES,nGRFWIB*%1+nGRFWIB]<2>:ub acc1<16;16,1>:w 5:w {SecHalf}
\r
221 (-f0.0) jmpi INTERLABEL(Average_8x8)
\r
222 (f0.1) jmpi INTERLABEL(Return_Interpolate_Y_8x8)
\r
224 INTERLABEL(Interpolate_Y_I_8x8):
\r
226 //-----------------------------------------------------------------------
\r
227 // CASE: 134C (Integer position)
\r
228 //-----------------------------------------------------------------------
\r
230 mov (2) pREF0<1>:uw gW0<2;2,1>:uw {NoDDClr}
\r
232 mov (1) pRES:uw gpINTPY:uw {NoDDChk}
\r
234 cmp.e.f0.0 (2) null:w gMVX_FRAC<0;1,0>:w 3:w
\r
235 cmp.e.f0.1 (2) null:w gMVY_FRAC<0;1,0>:w 3:w
\r
236 (f0.0) add (2) pREF0<1>:uw pREF0<2;2,1>:uw 1:uw
\r
237 (f0.1) add (2) pREF0<1>:uw pREF0<2;2,1>:uw nGRFWIB/2:uw
\r
239 mov (16) r[pRES]<1>:uw r[pREF0]<8,1>:ub
\r
240 mov (16) r[pRES,nGRFWIB]<1>:uw r[pREF0,nGRFWIB]<8,1>:ub
\r
241 mov (16) r[pRES,nGRFWIB*2]<1>:uw r[pREF0,nGRFWIB*2]<8,1>:ub
\r
242 mov (16) r[pRES,nGRFWIB*3]<1>:uw r[pREF0,nGRFWIB*3]<8,1>:ub
\r
244 INTERLABEL(Average_8x8):
\r
246 //-----------------------------------------------------------------------
\r
247 // CASE: 13456789BCDEF (Average)
\r
248 //-----------------------------------------------------------------------
\r
250 // Average two interim results
\r
251 avg.sat (16) r[pRES,0]<2>:ub r[pRES,0]<32;16,2>:ub gubINTERIM_BUF(0)
\r
252 avg.sat (16) r[pRES,nGRFWIB]<2>:ub r[pRES,nGRFWIB]<32;16,2>:ub gubINTERIM_BUF(1)
\r
253 avg.sat (16) r[pRES,nGRFWIB*2]<2>:ub r[pRES,nGRFWIB*2]<32;16,2>:ub gubINTERIM_BUF(2)
\r
254 avg.sat (16) r[pRES,nGRFWIB*3]<2>:ub r[pRES,nGRFWIB*3]<32;16,2>:ub gubINTERIM_BUF(3)
\r
256 INTERLABEL(Return_Interpolate_Y_8x8):
\r
257 // Restore all address registers
\r
258 mov (8) a0<1>:w gpADDR<8;8,1>:w
\r
260 INTERLABEL(Exit_Interpolate_Y_8x8):
\r