Debian Codegraph @

src/shaders/h264/ildb/TransposeNV12_16x16.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 //////////////////////////////////////////////////////////////////////////////////////////
40 // Module name: TransposeNV12_16x16.asm
41 //
42 // Transpose a 16x16 NV12 MB. The output is also in NV12
43 //
44 //----------------------------------------------------------------------------------------
45 // Symbols need to be defined before including this module
46 //
47 // Source region is :ub
48 // SRC_YB: SRC_YB Base=rxx ElementSize=1 SrcRegion=REGION(16,1) Type=ub // 8 GRFs
49 // SRC_UW: SRC_UW Base=rxx ElementSize=2 SrcRegion=REGION(8,1) Type=uw // 4 GRFs
50 //
51 // Temp buffer:
52 // BUF_B: BUF_B Base=rxx ElementSize=1 SrcRegion=REGION(16,1) Type=ub // 8 GRFs
53 // BUF_W: BUF_W Base=rxx ElementSize=2 SrcRegion=REGION(8,1) Type=uw // 4 GRFs
54 //
55 //////////////////////////////////////////////////////////////////////////////////////////
56
57 #if defined(_DEBUG)
58 mov (1) EntrySignatureC:w 0xDDDA:w
59 #endif
60
61
62 // Transpose Y (16x16 bytes)
63
64 // The first step
65 mov (16) BUF_B(0,0)<1> SRC_YB(0,0)<16;4,1>
66 mov (16) BUF_B(0,16)<1> SRC_YB(2,0)<16;4,1>
67 mov (16) BUF_B(1,0)<1> SRC_YB(4,0)<16;4,1>
68 mov (16) BUF_B(1,16)<1> SRC_YB(6,0)<16;4,1>
69
70 mov (16) BUF_B(2,0)<1> SRC_YB(0,4)<16;4,1>
71 mov (16) BUF_B(2,16)<1> SRC_YB(2,4)<16;4,1>
72 mov (16) BUF_B(3,0)<1> SRC_YB(4,4)<16;4,1>
73 mov (16) BUF_B(3,16)<1> SRC_YB(6,4)<16;4,1>
74
75 mov (16) BUF_B(4,0)<1> SRC_YB(0,8)<16;4,1>
76 mov (16) BUF_B(4,16)<1> SRC_YB(2,8)<16;4,1>
77 mov (16) BUF_B(5,0)<1> SRC_YB(4,8)<16;4,1>
78 mov (16) BUF_B(5,16)<1> SRC_YB(6,8)<16;4,1>
79
80 mov (16) BUF_B(6,0)<1> SRC_YB(0,12)<16;4,1>
81 mov (16) BUF_B(6,16)<1> SRC_YB(2,12)<16;4,1>
82 mov (16) BUF_B(7,0)<1> SRC_YB(4,12)<16;4,1>
83 mov (16) BUF_B(7,16)<1> SRC_YB(6,12)<16;4,1>
84
85 // The second step
86 mov (16) SRC_YB(0,0)<1> BUF_B(0,0)<32;8,4>
87 mov (16) SRC_YB(0,16)<1> BUF_B(0,1)<32;8,4>
88 mov (16) SRC_YB(1,0)<1> BUF_B(0,2)<32;8,4>
89 mov (16) SRC_YB(1,16)<1> BUF_B(0,3)<32;8,4>
90
91 mov (16) SRC_YB(2,0)<1> BUF_B(2,0)<32;8,4>
92 mov (16) SRC_YB(2,16)<1> BUF_B(2,1)<32;8,4>
93 mov (16) SRC_YB(3,0)<1> BUF_B(2,2)<32;8,4>
94 mov (16) SRC_YB(3,16)<1> BUF_B(2,3)<32;8,4>
95
96 mov (16) SRC_YB(4,0)<1> BUF_B(4,0)<32;8,4>
97 mov (16) SRC_YB(4,16)<1> BUF_B(4,1)<32;8,4>
98 mov (16) SRC_YB(5,0)<1> BUF_B(4,2)<32;8,4>
99 mov (16) SRC_YB(5,16)<1> BUF_B(4,3)<32;8,4>
100
101 mov (16) SRC_YB(6,0)<1> BUF_B(6,0)<32;8,4>
102 mov (16) SRC_YB(6,16)<1> BUF_B(6,1)<32;8,4>
103 mov (16) SRC_YB(7,0)<1> BUF_B(6,2)<32;8,4>
104 mov (16) SRC_YB(7,16)<1> BUF_B(6,3)<32;8,4>
105
106 // Y is transposed.
107
108
109 //////////////////////////////////////////////////////////////////////////////////////////////////////////
110
111 // Src U and V are mixed in NV12 format. U on even bytes, V on odd bytes.
112 // Transpose by treating UV pair as a word.
113
114
115 // Src U 8x8 and V 8x8 are mixed. (each pix is specified as yx)
116 // +-----------------------+-----------------------+-----------------------+-----------------------+
117 // |17 17 16 16 15 15 14 14 13 13 12 12 11 11 10 10 07 07 06 06 05 05 04 04 03 03 02 02 01 01 00 00|
118 // +-----------------------+-----------------------+-----------------------+-----------------------+
119 // |37 37 36 36 35 35 34 34 33 33 32 32 31 31 30 30 27 27 26 26 25 25 24 24 23 23 22 22 21 21 20 20|
120 // +-----------------------+-----------------------+-----------------------+-----------------------+
121 // |57 57 56 56 55 55 54 54 53 53 52 52 51 51 50 50 47 47 46 46 45 45 44 44 43 43 42 42 41 41 40 40|
122 // +-----------------------+-----------------------+-----------------------+-----------------------+
123 // |77 77 76 76 75 75 74 74 73 73 72 72 71 71 70 70 67 67 66 66 65 65 64 64 63 63 62 62 61 61 60 60|
124 // +-----------------------+-----------------------+-----------------------+-----------------------+
125
126 // First step (16) <1>:w <==== <8;4,1>:w
127 // +-----------------------+-----------------------+-----------------------+-----------------------+
128 // |33 33 32 32 31 31 30 30 23 23 22 22 21 21 20 20 13 13 12 12 11 11 10 10 03 03 02 02 01 01 00 00|
129 // +-----------------------+-----------------------+-----------------------+-----------------------+
130 // |73 73 72 72 71 71 70 70 63 63 62 62 61 61 60 60 53 53 52 52 51 51 50 50 43 43 42 42 41 41 40 40|
131 // +-----------------------+-----------------------+-----------------------+-----------------------+
132 // |37 37 36 36 35 35 34 34 27 27 26 26 25 25 24 24 17 17 16 16 15 15 14 14 07 07 06 06 05 05 04 04|
133 // +-----------------------+-----------------------+-----------------------+-----------------------+
134 // |77 77 76 76 75 75 74 74 67 67 66 66 65 65 64 64 57 57 56 56 55 55 54 54 47 47 46 46 45 45 44 44|
135 // +-----------------------+-----------------------+-----------------------+-----------------------+
136 //
137 // Transpose UV (8x8 words), The first step
138 mov (16) BUF_W(0,0)<1> SRC_UW(0,0)<8;4,1>
139 mov (16) BUF_W(1,0)<1> SRC_UW(2,0)<8;4,1>
140 mov (16) BUF_W(2,0)<1> SRC_UW(0,4)<8;4,1>
141 mov (16) BUF_W(3,0)<1> SRC_UW(2,4)<8;4,1>
142
143
144 // Second step (16) <1>:w <=== <16;4,4>:w
145 // +-----------------------+-----------------------+-----------------------+-----------------------+
146 // |71 71 61 61 51 51 41 41 31 31 21 21 11 11 01 01 70 70 60 60 50 50 40 40 30 30 20 20 10 10 00 00|
147 // +-----------------------+-----------------------+-----------------------+-----------------------+
148 // |73 73 63 63 53 53 43 43 33 33 23 23 13 13 03 03 72 72 62 62 52 52 42 42 32 32 22 22 12 12 02 02|
149 // +-----------------------+-----------------------+-----------------------+-----------------------+
150 // |75 75 65 65 55 55 45 45 35 35 25 25 15 15 05 05 74 74 64 64 54 54 44 44 34 34 24 24 14 14 04 04|
151 // +-----------------------+-----------------------+-----------------------+-----------------------+
152 // |77 77 67 67 57 57 47 47 37 37 27 27 17 17 07 07 76 76 66 66 56 56 46 46 36 36 26 26 16 16 06 06|
153 // +-----------------------+-----------------------+-----------------------+-----------------------+
154 //
155 // Transpose UV (8x8 words), The second step
156 mov (8) SRC_UW(0,0)<1> BUF_W(0,0)<16;4,4>
157 mov (8) SRC_UW(0,8)<1> BUF_W(0,1)<16;4,4>
158 mov (8) SRC_UW(1,0)<1> BUF_W(0,2)<16;4,4>
159 mov (8) SRC_UW(1,8)<1> BUF_W(0,3)<16;4,4>
160 mov (8) SRC_UW(2,0)<1> BUF_W(2,0)<16;4,4>
161 mov (8) SRC_UW(2,8)<1> BUF_W(2,1)<16;4,4>
162 mov (8) SRC_UW(3,0)<1> BUF_W(2,2)<16;4,4>
163 mov (8) SRC_UW(3,8)<1> BUF_W(2,3)<16;4,4>
164
165 // U and V are now transposed and separated.