Debian Codegraph @

src/shaders/h264/ildb/AVC_ILDB_Chroma_Core_Mbaff.asm

raw
1 /*
2 * Copyright © <2010>, Intel Corporation.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sub license, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
14 * of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
20 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 *
24 * This file was originally licensed under the following license
25 *
26 * Licensed under the Apache License, Version 2.0 (the "License");
27 * you may not use this file except in compliance with the License.
28 * You may obtain a copy of the License at
29 *
30 * http://www.apache.org/licenses/LICENSE-2.0
31 *
32 * Unless required by applicable law or agreed to in writing, software
33 * distributed under the License is distributed on an "AS IS" BASIS,
34 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
35 * See the License for the specific language governing permissions and
36 * limitations under the License.
37 *
38 */
39 ////////// AVC ILDB Chroma Core Mbaff /////////////////////////////////////////////////////////////////////////////////
40 //
41 // This core performs AVC U or V ILDB filtering on one horizontal edge (8 pixels) of a MB.
42 // If data is transposed, it can also de-block a vertical edge.
43 //
44 // Bafore calling this subroutine, caller needs to set the following parameters.
45 //
46 // - EdgeCntlMap1 // Edge control map A
47 // - EdgeCntlMap2 // Edge control map B
48 // - P_AddrReg // Src and dest address register for P pixels
49 // - Q_AddrReg // Src and dest address register for Q pixels
50 // - alpha // alpha corresponding to the edge to be filtered
51 // - beta // beta corresponding to the edge to be filtered
52 // - tc0 // tc0 corresponding to the edge to be filtered
53 //
54 // U or V:
55 // +----+----+----+----+
56 // | P1 | p0 | q0 | q1 |
57 // +----+----+----+----+
58 //
59 // p1 = r[P_AddrReg, 0]<16;8,2>
60 // p0 = r[P_AddrReg, 16]<16;8,2>
61 // q0 = r[Q_AddrReg, 0]<16;8,2>
62 // q1 = r[Q_AddrReg, 16]<16;8,2>
63 //
64 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
65
66 // The region is both src and dest
67 // P0-P3 and Q0-Q3 should be only used if they have not been modified to new values
68 #undef P1
69 #undef P0
70 #undef Q0
71 #undef Q1
72
73 #define P1 r[P_AddrReg, 0]<16;8,2>:ub
74 #define P0 r[P_AddrReg, 16]<16;8,2>:ub
75 #define Q0 r[Q_AddrReg, 0]<16;8,2>:ub
76 #define Q1 r[Q_AddrReg, 16]<16;8,2>:ub
77
78 // New region as dest
79 #undef NewP0
80 #undef NewQ0
81
82 #define NewP0 r[P_AddrReg, 16]<2>:ub
83 #define NewQ0 r[Q_AddrReg, 0]<2>:ub
84
85 // Filter one chroma edge - mbaff
86 FILTER_UV_MBAFF:
87
88 #if defined(_DEBUG)
89 mov (1) EntrySignatureC:w 0x1112:w
90 #endif
91 //---------- Derive filterSampleflag in AVC spec, equition (8-469) ----------
92
93 //===== Assume f0.0 contains MaskA when entering this routine
94 // mov (1) f0.0:uw MaskA:uw
95
96 add (8) q0_p0(0)<1> Q0 -P0 // q0-p0
97 add (8) TempRow0(0)<1> P1 -P0 // p1-p0
98 add (8) TempRow1(0)<1> Q1 -Q0 // q1-q0
99
100 // Build FilterSampleFlag
101 // abs(q0-p0) < alpha
102 (f0.0) cmp.l.f0.0 (16) null:w (abs)q0_p0(0) Mbaff_ALPHA(0)
103 // abs(p1-p0) < Beta
104 (f0.0) cmp.l.f0.0 (16) null:w (abs)TempRow0(0) Mbaff_BETA(0)
105 // abs(q1-q0) < Beta
106 (f0.0) cmp.l.f0.0 (16) null:w (abs)TempRow1(0) Mbaff_BETA(0)
107
108 //-----------------------------------------------------------------------------------------
109
110 // if
111 (f0.0) if (8) MBAFF_UV_ENDIF1
112 // For channels whose edge control map1 = 1 ---> perform de-blocking
113
114 // mov (1) f0.1:w MaskB:w {NoMask} // Now check for which algorithm to apply
115
116 (f0.1) if (8) MBAFF_UV_ELSE2
117
118 // For channels whose edge control map2 = 1 ---> bS = 4 algorithm
119 // p0' = (2*p1 + P0 + q1 + 2) >> 2
120 // q0' = (2*q1 + q0 + p1 + 2) >> 2
121 //------------------------------------------------------------------------------------
122
123 // p0' = (2*p1 + p0 + q1 + 2) >> 2
124 add (8) acc0<1>:w Q1 2:w
125 mac (8) acc0<1>:w P1 2:w
126 add (8) acc0<1>:w acc0<8;8,1>:w P0
127 shr.sat (8) TempRow0B(0)<2> acc0<8;8,1>:w 2:w
128
129 // q0' = (2*q1 + q0 + p1 + 2) >> 2
130 add (8) acc0<1>:w P1 2:w
131 mac (8) acc0<1>:w Q1 2:w
132 add (8) acc0<1>:w acc0<8;8,1>:w Q0
133 shr.sat (8) TempRow1B(0)<2> acc0<8;8,1>:w 2:w
134
135 mov (8) NewP0 TempRow0B(0) // p0'
136 mov (8) NewQ0 TempRow1B(0) // q0'
137
138 MBAFF_UV_ELSE2:
139 else (8) MBAFF_UV_ENDIF2
140 // For channels whose edge control map2 = 0 ---> bS < 4 algorithm
141
142 // tc_exp = tc0_exp + 1
143 add (8) tc_exp(0)<1> Mbaff_TC0(0) 1:w
144
145 // delta = Clip3(-tc, tc, ((((q0 - p0)<<2) + (p1-q1) + 4) >> 3))
146 // 4 * (q0-p0) + p1 - q1 + 4
147 add (8) acc0<1>:w P1 4:w
148 mac (8) acc0<1>:w q0_p0(0) 4:w
149 add (8) acc0<1>:w acc0<8;8,1>:w -Q1
150 shr (8) TempRow0(0)<1> acc0<8;8,1>:w 3:w
151
152 // tc clip
153 cmp.g.f0.0 (8) null:w TempRow0(0) tc_exp(0) // Clip if > tc0
154 cmp.l.f0.1 (8) null:w TempRow0(0) -tc_exp(0) // Clip if < -tc0
155
156 (f0.0) mov (8) TempRow0(0)<1> tc_exp(0)
157 (f0.1) mov (8) TempRow0(0)<1> -tc_exp(0)
158
159 // p0' = Clip1(p0 + delta) = Clip3(0, 0xFF, p0 + delta)
160 add.sat (8) TempRow1B(0)<2> P0 TempRow0(0) // p0+delta
161
162 // q0' = Clip1(q0 - delta) = Clip3(0, 0xFF, q0 - delta)
163 add.sat (8) TempRow0B(0)<2> Q0 -TempRow0(0) // q0-delta
164
165 mov (8) NewP0 TempRow1B(0) // p0'
166 mov (8) NewQ0 TempRow0B(0) // q0'
167
168 endif
169 MBAFF_UV_ENDIF2:
170 MBAFF_UV_ENDIF1:
171 endif
172
173 RETURN
174
175
176