Debian Codegraph @

src/shaders/h264/mc/intra_Pred_4x4_Y_4.asm

raw
1 /*
2 * Intra predict 4 Intra_4x4 luma blocks
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 #if !defined(__INTRA_PRED_4X4_Y_4__) // Make sure this is only included once
41 #define __INTRA_PRED_4X4_Y_4__
42
43 // Module name: intra_Pred_4x4_Y_4.asm
44 //
45 // Intra predict 4 Intra_4x4 luma blocks
46 //
47 //--------------------------------------------------------------------------
48 // Input data:
49 //
50 // REF_TOP: Top reference data stored in BYTE with p[-1,-1] at REF_TOP(0,-1)
51 // REF_LEFT: Left reference data stored in BYTE with p[-1,0] at REF_LEFT(0,0)
52 // PRED_MODE: Intra prediction mode stored in 4 words (4 LSB)
53 // REG_INTRA_PRED_AVAIL: Top/Left available flag, (Bit0: Left, Bit1: Top)
54 //
55 //--------------------------------------------------------------------------
56
57 #undef INTRA_PRED_AVAIL
58 #undef INTRA_REF
59 #undef REF_LEFT_BACK
60 #undef REF_TMP
61 #undef REF_TMP1
62
63 #define INTRA_PRED_AVAIL REG_INTRA_TEMP_2.8
64 #define INTRA_REF REG_INTRA_TEMP_2
65 #define REF_LEFT_BACK REG_INTRA_TEMP_8
66 #define REF_TMP REG_INTRA_TEMP_3
67 #define REF_TMP1 REG_INTRA_TEMP_4
68
69 intra_Pred_4x4_Y_4:
70
71 mov (8) REF_LEFT_BACK<1>:ub REF_LEFT(0)REGION(8,1) // Store left referece data
72 // Set up pointers to each intra_4x4 prediction mode
73 //
74 and (4) PINTRA4X4_Y<1>:w PRED_MODE<4;4,1>:w 0x0F:w
75 add (4) INTRA_4X4_MODE(0) r[PINTRA4X4_Y, INTRA_4X4_OFFSET]<1,0>:ub INTRA_MODE<4;4,1>:ub
76
77 // Sub-block 0 *****************
78 mov (1) INTRA_PRED_AVAIL<1>:w REG_INTRA_PRED_AVAIL<0;1,0>:w // Top/Left neighbor available flags
79 CALL_1(INTRA_4X4_MODE(0),1)
80
81 // Add error data to predicted intra data
82 ADD_ERROR_SB0:
83 add.sat (8) r[PPREDBUF_Y,PREDSUBBLK0]<2>:ub r[PERROR,ERRBLK0]<8;4,1>:w REG_INTRA_4X4_PRED<8;8,1>:w // Too bad indexed src can't
84 add.sat (8) r[PPREDBUF_Y,PREDSUBBLK0+16]<2>:ub r[PERROR,ERRBLK0+32]<8;4,1>:w REG_INTRA_4X4_PRED.8<8;8,1>:w // cross 2 GRFs
85
86 // Sub-block 1 *****************
87 mov (16) REF_TOP0(0)<1> REF_TOP0(0,4)REGION(8,1) // Top reference data
88 mov (4) REF_LEFT(0)<1> r[PPREDBUF_Y,PREDSUBBLK0+6]<8;1,0>:ub // New left referece data from sub-block 0
89 or (1) INTRA_PRED_AVAIL<1>:w REG_INTRA_PRED_AVAIL<0;1,0>:w 1:w // Left neighbor is available
90 CALL_1(INTRA_4X4_MODE(0,1),1)
91
92 // Add error data to predicted intra data
93 ADD_ERROR_SB1:
94 add.sat (8) r[PPREDBUF_Y,PREDSUBBLK1]<2>:ub r[PERROR,ERRBLK1]<8;4,1>:w REG_INTRA_4X4_PRED<8;8,1>:w // Too bad indexed src can't
95 add.sat (8) r[PPREDBUF_Y,PREDSUBBLK1+16]<2>:ub r[PERROR,ERRBLK1+32]<8;4,1>:w REG_INTRA_4X4_PRED.8<8;8,1>:w // cross 2 GRFs
96
97 // Sub-block 2 *****************
98 mov (1) REF_TOP0(0,3)<1> REF_LEFT_BACK.3<0;1,0>:ub // Top-left reference data from stored left referece data
99 mov (4) REF_TOP0(0,4)<1> r[PPREDBUF_Y,PREDSUBBLK0+24]REGION(4,2):ub // Top reference data
100 mov (4) REF_TOP0(0,8)<1> r[PPREDBUF_Y,PREDSUBBLK0+24+32]REGION(4,2):ub // Too bad indexed src can't cross 2 GRFs
101 mov (4) REF_TOP0(0,12)<1> r[PPREDBUF_Y,PREDSUBBLK0+30+32]REGION(1,0):ub // Extended top-right reference data
102 mov (4) REF_LEFT(0)<1> REF_LEFT_BACK.4<4;4,1>:ub // From stored left referece data
103 or (1) INTRA_PRED_AVAIL<1>:w REG_INTRA_PRED_AVAIL<0;1,0>:w 2:w // Top neighbor is available
104 CALL_1(INTRA_4X4_MODE(0,2),1)
105
106 // Add error data to predicted intra data
107 ADD_ERROR_SB2:
108 add.sat (8) r[PPREDBUF_Y,PREDSUBBLK2]<2>:ub r[PERROR,ERRBLK2]<8;4,1>:w REG_INTRA_4X4_PRED<8;8,1>:w // Too bad indexed src can't
109 add.sat (8) r[PPREDBUF_Y,PREDSUBBLK2+16]<2>:ub r[PERROR,ERRBLK2+32]<8;4,1>:w REG_INTRA_4X4_PRED.8<8;8,1>:w // cross 2 GRFs
110
111 // Sub-block 3 *****************
112 mov (16) REF_TOP0(0)<1> REF_TOP0(0,4)REGION(8,1) // Top reference data
113 mov (8) REF_TOP0(0,8)<1> REF_TOP0(0,7)<0;1,0> // Extended top-right reference data
114 mov (4) REF_LEFT(0)<1> r[PPREDBUF_Y,PREDSUBBLK2+6]<8;1,0>:ub // Left referece data from sub-block 0
115 or (1) INTRA_PRED_AVAIL<1>:w REG_INTRA_PRED_AVAIL<0;1,0>:w 3:w // Top/Left neighbor are available
116 CALL_1(INTRA_4X4_MODE(0,3),1)
117
118 // Add error data to predicted intra data
119 ADD_ERROR_SB3:
120 add.sat (8) r[PPREDBUF_Y,PREDSUBBLK3]<2>:ub r[PERROR,ERRBLK3]<8;4,1>:w REG_INTRA_4X4_PRED<8;8,1>:w // Too bad indexed src can't
121 add.sat (8) r[PPREDBUF_Y,PREDSUBBLK3+16]<2>:ub r[PERROR,ERRBLK3+32]<8;4,1>:w REG_INTRA_4X4_PRED.8<8;8,1>:w // cross 2 GRFs
122
123 RETURN
124
125 //--------------------------------------------------------------------------
126 // Actual module that performs Intra_4x4 prediction and construction
127 //
128 // REF_TOP: Top reference data stored in BYTE with p[-1,-1] at REF_TOP(0,-1)
129 // REF_LEFT: Left reference data stored in BYTE with p[-1,0] at REF_LEFT(0,0)
130 // PINTRA4X4_Y: Intra prediction mode
131 // INTRA_PRED_AVAIL: Top/Left available flag, (Bit0: Left, Bit1: Top)
132 //
133 // Output data:
134 //
135 // REG_INTRA_4X4_PRED: Predicted 4x4 block data stored in 1 GRF register
136 //--------------------------------------------------------------------------
137 intra_Pred_4x4_Y:
138 // Mode 0
139 INTRA_4X4_VERTICAL:
140 mov (16) REG_INTRA_4X4_PRED<1>:w REF_TOP(0)<0;4,1>
141 RETURN_1
142
143 // Mode 1
144 INTRA_4X4_HORIZONTAL:
145 mov (16) REG_INTRA_4X4_PRED<1>:w REF_LEFT(0)<1;4,0>
146 RETURN_1
147
148 // Mode 2
149 INTRA_4X4_DC:
150 // Rearrange reference samples for unified DC prediction code
151 //
152 and.nz.f0.0 (16) NULLREG INTRA_PRED_AVAIL<0;1,0>:w 2:w {Compr}
153 and.nz.f0.1 (16) NULLREG INTRA_PRED_AVAIL<0;1,0>:w 1:w {Compr}
154 (-f0.0.any16h) mov (16) REF_TOP_W(0)<1> 0x8080:uw // Top macroblock not available for intra prediction
155 (-f0.1.any8h) mov (8) REF_LEFT(0)<1> REF_TOP(0)REGION(8,1) // Left macroblock not available for intra prediction
156 (-f0.0.any8h) mov (8) REF_TOP(0)<1> REF_LEFT(0)REGION(8,1) // Top macroblock not available for intra prediction
157 // Perform DC prediction
158 //
159 add (4) PRED_YW(15)<1> REF_TOP(0)REGION(4,1) REF_LEFT(0)REGION(4,1)
160 add (2) PRED_YW(15)<1> PRED_YW(15)REGION(2,1) PRED_YW(15,2)REGION(2,1)
161 add (16) acc0<1>:w PRED_YW(15)REGION(1,0) PRED_YW(15,1)REGION(1,0)
162 add (16) acc0<1>:w acc0:w 4:w
163 shr (16) REG_INTRA_4X4_PRED<1>:w acc0:w 3:w
164 RETURN_1
165
166 // Mode 3
167 INTRA_4X4_DIAG_DOWN_LEFT:
168 mov (8) INTRA_REF<1>:ub REF_TOP(0)REGION(8,1) // Keep REF_TOP untouched for future use
169 mov (4) INTRA_REF.8<1>:ub REF_TOP(0,7)REGION(4,1) // p[8,-1] = p[7,-1]
170 add (8) acc0<1>:w INTRA_REF.2<8;8,1> 2:w // p[x+2]+2
171 mac (8) acc0<1>:w INTRA_REF.1<8;8,1> 2:w // 2*p[x+1]+p[x+2]+2
172 mac (8) PRED_YW(15)<1> INTRA_REF.0<8;8,1> 1:w // p[x]+2*p[x+1]+p[x+2]+2
173
174 shr (16) REG_INTRA_4X4_PRED<1>:w PRED_YW(15)<1;4,1> 2:w // (p[x]+2*p[x+1]+p[x+2]+2)>>2
175 RETURN_1
176
177 // Mode 4
178 INTRA_4X4_DIAG_DOWN_RIGHT:
179
180 // Set inverse shift count
181 shl (4) REF_TMP<1>:ud REF_LEFT_D(0)REGION(1,0) INV_SHIFT<4;4,1>:b
182 mov (8) INTRA_REF.4<1>:ub REF_TOP(0,-1)REGION(8,1) // INTRA_REF holds all reference data
183 mov (4) INTRA_REF<1>:ub REF_TMP.3<16;4,4>:ub
184
185 add (8) acc0<1>:w INTRA_REF.2<8;8,1>:ub 2:w // p[x+2]+2
186 mac (8) acc0<1>:w INTRA_REF.1<8;8,1>:ub 2:w // 2*p[x+1]+p[x+2]+2
187 mac (8) INTRA_REF<1>:w INTRA_REF<8;8,1>:ub 1:w // p[x]+2*p[x+1]+p[x+2]+2
188
189 // Store data in reversed order
190 add (4) PBWDCOPY_4<1>:w INV_TRANS4<4;4,1>:b INTRA_TEMP_2*GRFWIB:w // Must match with INTRA_REF
191 shr (16) REG_INTRA_4X4_PRED<1>:w r[PBWDCOPY_4]<4,1>:w 2:w
192 RETURN_1
193
194 // Mode 5
195 INTRA_4X4_VERT_RIGHT:
196
197 // Set inverse shift count
198 shl (4) REF_TMP<1>:ud REF_LEFT_D(0)REGION(1,0) INV_SHIFT<4;4,1>:b
199 mov (8) INTRA_REF.4<1>:ub REF_TOP(0,-1)REGION(8,1) // INTRA_REF holds all reference data
200 mov (4) INTRA_REF<1>:ub REF_TMP.3<16;4,4>:ub
201
202 // Even rows
203 avg (8) PRED_YW(14)<1> INTRA_REF.4<8;8,1> INTRA_REF.5<8;8,1> // avg(p[x-1],p[x])
204 // Odd rows
205 add (8) acc0<1>:w INTRA_REF.3<8;8,1>:ub 2:w // p[x]+2
206 mac (8) acc0<1>:w INTRA_REF.2<8;8,1>:ub 2:w // 2*p[x-1]+p[x]+2
207 mac (8) acc0<1>:w INTRA_REF.1<8;8,1>:ub 1:w // p[x-2]+2*p[x-1]+p[x]+2
208 shr (8) INTRA_REF<1>:w acc0:w 2:w // (p[x-2]+2*p[x-1]+p[x]+2)>>2
209
210 mov (4) INTRA_REF.2<2>:w INTRA_REF.2<4;4,1>:w // Keep zVR = -2,-3 unchanged
211 mov (4) INTRA_REF.3<2>:w PRED_YW(14)REGION(4,1) // Combining even rows
212
213 add (4) PBWDCOPY_4<1>:w INV_TRANS4<4;4,1>:b INTRA_TEMP_2*GRFWIB:w // Must match with INTRA_REF
214 mov (16) REG_INTRA_4X4_PRED<1>:w r[PBWDCOPY_4]<4,2>:w
215 RETURN_1
216
217 // Mode 6
218 INTRA_4X4_HOR_DOWN:
219 // Set inverse shift count
220 shl (4) REF_TMP<1>:ud REF_LEFT_D(0)REGION(1,0) INV_SHIFT<4;4,1>:b
221 mov (8) INTRA_REF.4<1>:ub REF_TOP(0,-1)REGION(8,1) // INTRA_REF holds all reference data
222 mov (4) INTRA_REF<1>:ub REF_TMP.3<16;4,4>:ub
223
224 // Even pixels
225 avg (8) PRED_YW(14)<1> INTRA_REF<8;8,1> INTRA_REF.1<8;8,1> // avg(p[y-1],p[y])
226 // Odd pixels
227 add (8) acc0<1>:w INTRA_REF.2<8;8,1>:ub 2:w // p[y]+2
228 mac (8) acc0<1>:w INTRA_REF.1<8;8,1>:ub 2:w // 2*p[y-1]+p[y]+2
229 mac (8) REF_TMP<1>:w INTRA_REF.0<8;8,1>:ub 1:w // p[y-2]+2*p[y-1]+p[y]+2
230 shr (4) INTRA_REF.1<2>:w REF_TMP<4;4,1>:w 2:w // (p[y-2]+2*p[y-1]+p[y]+2)>>2
231
232 shr (2) INTRA_REF.8<1>:w REF_TMP.4<2;2,1>:w 2:w // Keep zVR = -2,-3 unchanged
233 mov (4) INTRA_REF.0<2>:w PRED_YW(14)REGION(4,1) // Combining even pixels
234
235 shl (4) PBWDCOPY_4<1>:w INV_TRANS4<4;4,1>:b 1:w // Convert to WORD offset
236 add (4) PBWDCOPY_4<1>:w PBWDCOPY_4<4;4,1>:w INTRA_TEMP_2*GRFWIB:w // Must match with INTRA_REF
237 mov (16) REG_INTRA_4X4_PRED<1>:w r[PBWDCOPY_4]<4,1>:w
238 RETURN_1
239
240 // Mode 7
241 INTRA_4X4_VERT_LEFT:
242 // Even rows
243 avg (8) PRED_YW(14)<2> REF_TOP(0)REGION(8,1) REF_TOP(0,1)REGION(8,1) // avg(p[x],p[x+1])
244 // Odd rows
245 add (8) acc0<1>:w REF_TOP(0,2)REGION(8,1) 2:w // p[x+2]+2
246 mac (8) acc0<1>:w REF_TOP(0,1)REGION(8,1) 2:w // 2*p[x+1]+p[x+2]+2
247 mac (8) PRED_YW(15)<1> REF_TOP(0)REGION(8,1) 1:w // p[x]+2*p[x+1]+p[x+2]+2
248 shr (8) PRED_YW(14,1)<2> PRED_YW(15)REGION(8,1) 2:w
249
250 mov (16) REG_INTRA_4X4_PRED<1>:w PRED_YW(14)<1;4,2>
251 RETURN_1
252
253 // Mode 8
254 INTRA_4X4_HOR_UP:
255 // Set extra left reference pixels for unified prediction
256 mov (8) REF_LEFT(0,4)<1> REF_LEFT(0,3)REGION(1,0) // Copy p[-1,3] to p[-1,y],y=4...7
257 // Even pixels
258 avg (8) PRED_YW(14)<2> REF_LEFT(0)REGION(8,1) REF_LEFT(0,1)REGION(8,1) // avg(p[y],p[y+1])
259 // Odd pixels
260 add (8) acc0<1>:w REF_LEFT(0,2)REGION(8,1) 2:w // p[y+2]+2
261 mac (8) acc0<1>:w REF_LEFT(0,1)REGION(8,1) 2:w // 2*p[y+1]+p[y+2]+2
262 mac (8) PRED_YW(15)<1> REF_LEFT(0)REGION(8,1) 1:w // p[y]+2*p[y+1]+p[y+2]+2
263 shr (8) PRED_YW(14,1)<2> PRED_YW(15)REGION(8,1) 2:w // (p[y]+2*p[y+1]+p[y+2]+2)>>2
264
265 mov (16) REG_INTRA_4X4_PRED<1>:w PRED_YW(14)<2;4,1>
266 RETURN_1
267
268 // End of intra_Pred_4x4_Y_4
269
270 #endif // !defined(__INTRA_PRED_4X4_Y_4__)