Debian Codegraph @

src/shaders/h264/mc/AVCMCInter.asm

raw
1 /*
2 * All inter-prediction macroblock kernels
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: AVCMCInter.asm
41
42 #ifdef INTERLABEL
43 #undef INTERLABEL
44 #endif
45
46 #if defined(MBAFF)
47 // < MBaff_Motion >
48 #define INTERLABEL(x) x##_##MBF
49 #elif defined(FIELD)
50 // < FieldMB_Motion >
51 #define INTERLABEL(x) x##_##FLD
52 #else // FRAME
53 // < FrameMB_Motion >
54 #define INTERLABEL(x) x##_##FRM
55 #endif
56 //
57 // Decoding an inter-prediction macroblock (conditional compile)
58 // -DMBAFF : MBAff picture MB
59 // -DFRAME : Frame picture MB
60 // -DFIELD : Field picture MB
61 // -DMBAFF -DMONO : MBAff mono picture MB
62 // -DFRAME -DMONO : Frame mono picture MB
63 // -DFIELD -DMONO : Field mono picture MB
64
65
66 //#if !defined(__AVCMCInter__) // Make sure this is only included once
67 //#define __AVCMCInter__
68
69
70 // TODO: header files need to be in sync with intra prediction
71 #include "header.inc"
72 #include "inter_Header.inc"
73
74 // TODO: Kernel names for mono cases
75 #if defined(MBAFF)
76 .kernel MBAff_Motion
77 MBAFF_MB:
78 #elif defined(FIELD)
79 .kernel FieldMB_Motion
80 FIELD_MB:
81 #else // Frame
82 .kernel FrameMB_Motion
83 FRAME_MB:
84 #endif
85
86 #ifdef _DEBUG
87 // WA for FULSIM so we'll know which kernel is being debugged
88 #if defined(MBAFF)
89 mov (1) acc0:ud 0x0aaa55a5:ud
90 #elif defined(FIELD)
91 mov (1) acc0:ud 0x0baa55a5:ud
92 #else // Frame
93 mov (1) acc0:ud 0x0caa55a5:ud
94 #endif
95 #endif
96
97
98 #ifdef SW_SCOREBOARD
99 CALL(scoreboard_start_inter,1)
100 #endif
101
102 mov (8) gMSGSRC<1>:ud r0.0<8;8,1>:ud // Initialize message header payload with R0
103
104 and (1) gwMBTYPE<1> gMBTYPE:ub nMBTYPE_MASK:w // MB type
105 shl (2) gX<1>:w gORIX<2;2,1>:ub 4:w // Convert MB origin to pixel unit
106
107 // #include "process_inter16x16.asm" // Handle B_L0_16x16 case with zero MVs and weighted pred off.
108 // In the case of B_L0_16x16 with zero MVs and weighted pred off, the kernel jumps to INTERLABEL(EXIT_LOOP).
109
110 INTERLABEL(INIT_MBPARA):
111 #include "initialize_MBPara.asm"
112
113
114 //========================= BEGIN - LOOP_SUBMB ===========================
115 mov (1) gLOOP_SUBMB:uw 0:uw // 0, 2, 4, 6
116 INTERLABEL(LOOP_SUBMB):
117
118 //========================== BEGIN - LOOP_DIR ============================
119 // Prediction flag (gPREDFLAG - 0:Pred_L0, 1:Pred_L1, 2:BiPred)
120 asr (1) gPREDFLAG:w gSUBMB_MODE:ub gLOOP_SUBMB:uw
121 mov (1) gLOOP_DIR:uw 1:uw // 1, 0
122 and (1) gPREDFLAG:w gPREDFLAG:w 0x3:w
123 INTERLABEL(LOOP_DIR):
124
125 cmp.e.f0.0 (1) null:w gLOOP_DIR:w gPREDFLAG:w
126 (f0.0) jmpi INTERLABEL(LOOP_DIR_CONTINUE)
127
128 // Get binding table index
129 // & reference picture parity (gREFPARITY - 0:top, 0x100:bottom, x:frame)
130 // & address of interpolation result
131 cmp.e.f0.1 (1) null:w gLOOP_DIR:w 1:w
132 (f0.1) mov (1) gpINTP:ud nOFFSET_INTP0:ud {NoDDClr} //
133 (f0.1) and (1) gBIDX:w r[pBIDX]:ub 0x7f:w {NoDDChk} //
134 (-f0.1) mov (1) gpINTP:ud nOFFSET_INTP1:ud {NoDDClr} //
135 (-f0.1) and (1) gBIDX:w r[pBIDX,4]:ub 0x7f:w {NoDDChk} //
136 #if defined(MBAFF) || defined(FIELD)
137 (f0.1) and (1) gREFPARITY:w r[pBIDX]:ub 0x80:w
138 (-f0.1) and (1) gREFPARITY:w r[pBIDX,4]:ub 0x80:w
139 shl (1) gREFPARITY:w gREFPARITY<0;1,0>:w 1:w
140 #endif
141
142 // Sub MB shape
143 asr (1) gSHAPETEMP:w gSUBMB_SHAPE:ub gLOOP_SUBMB:w
144
145 // Chroma MV adjustment & Set message descriptor for frame/field read
146 #if defined(MBAFF)
147 #include "chromaMVAdjust.asm"
148 and.nz.f0.0 (1) null:uw gFIELDMBFLAG:ub nFIELDMB_MASK:uw
149 (f0.0) add (1) gD0:ud gBIDX:uw nDWBRMSGDSC_SC_TF:ud
150 (-f0.0) add (1) gMSGDSC_R:ud gBIDX:uw nDWBRMSGDSC_SC:ud
151 (f0.0) add (1) gMSGDSC_R:ud gD0:ud gREFPARITY:uw
152 #elif defined(FIELD)
153 #include "chromaMVAdjust.asm"
154 add (1) gMSGDSC_R:ud gBIDX:uw nDWBRMSGDSC_SC_TF:ud
155 add (1) gMSGDSC_R:ud gMSGDSC_R:ud gREFPARITY:uw
156 #else // FRAME
157 add (1) gMSGDSC_R:ud gBIDX:uw nDWBRMSGDSC_SC:ud
158 #endif
159
160 and.nz.f0.1 (1) null:w gSHAPETEMP:w 3:w
161 (f0.1) jmpi INTERLABEL(PROCESS4x4)
162
163 //======================== BEGIN - PROCESS 8x8 ===========================
164
165 // Reference block load
166 #include "loadRef_Y_16x13.asm"
167 #ifndef MONO
168 #if defined(MBAFF) || defined(FIELD)
169 add (1) r[pMV,2]:w r[pMV,2]:w gCHRMVADJ:w
170 #endif
171 #include "loadRef_C_10x5.asm"
172 #endif
173
174 // Interpolation
175 //CALL_INTER(INTERLABEL(Interpolate_Y_8x8_Func), 1)
176 #include "interpolate_Y_8x8.asm"
177 #ifndef MONO
178 //CALL_INTER(INTERLABEL(Interpolate_C_4x4_Func), 1)
179 #include "interpolate_C_4x4.asm"
180 #endif
181
182 jmpi INTERLABEL(ROUND_SHIFT_C)
183 //========================= END - PROCESS 8x8 ============================
184
185 //======================== BEGIN - LOOP_SUBMBPT ==========================
186 INTERLABEL(PROCESS4x4):
187
188 mov (1) gLOOP_SUBMBPT:uw 4:uw // 4, 3, 2, 1
189 INTERLABEL(LOOP_SUBMBPT):
190
191 // Reference block load
192 #include "loadRef_Y_16x9.asm"
193 #ifndef MONO
194 #if defined(MBAFF) || defined(FIELD)
195 add (1) r[pMV,2]:w r[pMV,2]:w gCHRMVADJ:w
196 #endif
197 #include "loadRef_C_6x3.asm"
198 #endif
199
200 // Interpolation
201 #include "interpolate_Y_4x4.asm"
202 #ifndef MONO
203 #include "interpolate_C_2x2.asm"
204 #endif
205
206 cmp.e.f0.0 (1) null:w gLOOP_SUBMBPT:uw 3:w
207 add.z.f0.1 (1) gLOOP_SUBMBPT:uw gLOOP_SUBMBPT:uw -1:w
208 add (1) pMV:w pMV:w 8:w
209 (-f0.0) add (1) gpINTP:ud gpINTP:ud 0x00080008:ud // 8 & 8
210 (f0.0) add (1) gpINTP:ud gpINTP:ud 0x00180038:ud // 24 & 56
211 (-f0.1) jmpi INTERLABEL(LOOP_SUBMBPT)
212
213 cmp.e.f0.1 null:w gLOOP_DIR:w 1:w
214 add (1) pMV:w pMV:w -32:w
215 (f0.1) mov (1) gpINTP:ud nOFFSET_INTP0:ud
216 (-f0.1) mov (1) gpINTP:ud nOFFSET_INTP1:ud
217
218 mov (1) pRESULT:uw gpINTPC:uw
219
220 //========================= END - LOOP_SUBMBPT ===========================
221
222 INTERLABEL(ROUND_SHIFT_C):
223
224 #ifndef MONO
225 #include "roundShift_C_4x4.asm"
226 #endif
227
228 INTERLABEL(LOOP_DIR_CONTINUE):
229
230 add.nz.f0.1 (1) gLOOP_DIR:uw gLOOP_DIR:uw -1:w
231 add (1) pMV:w pMV:w 4:w
232 (-f0.1) jmpi INTERLABEL(LOOP_DIR)
233 //=========================== END - LOOP_DIR =============================
234
235 INTERLABEL(Weighted_Prediction):
236 #include "weightedPred.asm"
237
238 and.z.f0.1 (16) null<1>:w gLOOP_SUBMB<0;1,0>:uw 2:w
239
240 #include "recon_Y_8x8.asm"
241 #ifndef MONO
242 #include "recon_C_4x4.asm"
243
244 (-f0.1) add (1) pERRORC:w pERRORC:w 48:w
245 #endif
246
247 cmp.e.f0.1 (1) null:w gLOOP_SUBMB:uw 6:w
248 add (1) gLOOP_SUBMB:uw gLOOP_SUBMB:uw 2:w
249
250 add (1) pWGT_BIDX:ud pWGT_BIDX:ud 0x00100001:ud // 12 & 1
251 add (1) pMV:w pMV:w gMVSTEP:w
252
253 (-f0.1) jmpi INTERLABEL(LOOP_SUBMB)
254 //========================== END - LOOP_SUBMB ============================
255
256 INTERLABEL(EXIT_LOOP):
257 #include "writeRecon_YC.asm"
258
259 #ifdef SW_SCOREBOARD
260 wait n0:ud // Now wait for scoreboard to response
261 #include "Soreboard_update.asm" // scorboard update function
262 #else
263 // Check for write commit first if SW scoreboard is disabled
264 mov (1) gREG_WRITE_COMMIT_Y<1>:ud gREG_WRITE_COMMIT_Y<0;1,0>:ud // Make sure Y write is committed
265 mov (1) gREG_WRITE_COMMIT_UV<1>:ud gREG_WRITE_COMMIT_UV<0;1,0>:ud // Make sure U/V write is committed
266 #endif
267
268 // Terminate the thread
269 //
270 END_THREAD
271
272
273 //#include "Interpolate_Y_8x8_Func.asm"
274 //#include "Interpolate_C_4x4_Func.asm"
275 //#include "WeightedPred_Y_Func.asm"
276 //#include "WeightedPred_C_Func.asm"
277
278
279 .end_code
280
281 .end_kernel
282
283
284 //#endif // !defined(__AVCMCInter__)