Debian Codegraph @

src/shaders/post_processing/gen5_6/Common/YUV_to_RGBX_Coef.asm

raw
1 /*
2 * All Video Processing 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 * Authors:
40 * Halley Zhao <[email protected]>
41 */
42
43 // Module name: YUV_to_RGBX_Coef.asm
44 //----------------------------------------------------------------
45 #define ubDEST_RGBX ubTOP_Y // I'd like use them for color conversion
46
47 // is dst surface |R|G|B|X| layout? otherwise, it is |B|G|R|X| layout
48 and.nz.f0.1 (1) dNULLREG r1.2:ud 0xFF000000:ud
49 #ifdef FIX_POINT_CONVERSION
50 // ###### set up transformation coefficient
51 // R = clip(( 298 * C + 0 * D + 409 * E + 128) >> 8)
52 // R = clip((0x012A * C + 0 * D + 0x0199 * E + 128) >> 8)
53 (-f0.1) mov (1) REG2(r, nTEMP0, 0):ud 0x0000012A:ud
54 (-f0.1) mov (1) REG2(r, nTEMP0, 1):ud 0x00000199:ud
55 ( f0.1) mov (1) REG2(r, nTEMP0, 4):ud 0x0000012A:ud
56 ( f0.1) mov (1) REG2(r, nTEMP0, 5):ud 0x00000199:ud
57
58 // G = clip(( 298 * C - 100 * D - 208 * E + 128) >> 8)
59 // G = clip(( 0x012A * C - 0x64 * D - 0xD0 * E + 128) >> 8)
60 // G = clip(( 0x012A * C + 0xFF9C * D + 0xFF30 * E + 128) >> 8)
61 mov (1) REG2(r, nTEMP0, 2):ud 0xFF9C012A:ud
62 mov (1) REG2(r, nTEMP0, 3):ud 0x0000FF30:ud
63
64 // B = clip(( 298 * C + 516 * D + 0 * E + 128) >> 8)
65 // B = clip((0x012A* C + 0x0204 * D + 0 * E + 128) >> 8)
66 (-f0.1) mov (1) REG2(r, nTEMP0, 4):ud 0x0204012A:ud
67 (-f0.1) mov (1) REG2(r, nTEMP0, 5):ud 0x00000000:ud
68 ( f0.1) mov (1) REG2(r, nTEMP0, 0):ud 0x0204012A:ud
69 ( f0.1) mov (1) REG2(r, nTEMP0, 1):ud 0x00000000:ud
70
71 // asr.sat (24) REG2(r,nTEMP0,0)<1> REG2(r,nTEMP0,0)<0;24,1> 1:w
72 asr.sat (8) REG2(r,nTEMP0, 0)<1>:w REG2(r,nTEMP0, 0)<0;8,1>:w 1:w
73 asr.sat (4) REG2(r,nTEMP0,8)<1>:w REG2(r,nTEMP0,8)<0;4,1>:w 1:w
74
75 // C = Y' - 16 D = U - 128 E = V - 128
76 mov (1) REG2(r, nTEMP0, 6):ud 0x008080F0:ud
77
78 #define wYUV_to_RGB_CH2_Coef_Fix REG2(r, nTEMP0, 0)
79 #define wYUV_to_RGB_CH1_Coef_Fix REG2(r, nTEMP0, 4)
80 #define wYUV_to_RGB_CH0_Coef_Fix REG2(r, nTEMP0, 8)
81 #define bYUV_OFF REG2(r,nTEMP0,24)
82
83 // debug use
84 #define bYUV_to_RGB_CH2_Coef_Fix REG2(r, nTEMP0, 0)
85 #define bYUV_to_RGB_CH1_Coef_Fix REG2(r, nTEMP0, 8)
86 #define bYUV_to_RGB_CH0_Coef_Fix REG2(r, nTEMP0, 16)
87
88 #else
89 // R = Y + 1.13983*V
90 // R = clip( Y + 1.402*(Cr-128)) // ITU-R
91 (-f0.1) mov (1) REG2(r, nTEMP8, 3):f 0.000f // A coef
92 (-f0.1) mov (1) REG2(r, nTEMP8, 2):f 1.402f // V coef
93 (-f0.1) mov (1) REG2(r, nTEMP8, 1):f 0.0f // U coef
94 (-f0.1) mov (1) REG2(r, nTEMP8, 0):f 1.0f // Y coef
95
96 ( f0.1) mov (1) REG2(r, nTEMP10, 3):f 0.000f // A coef
97 ( f0.1) mov (1) REG2(r, nTEMP10, 2):f 1.402f // V coef
98 ( f0.1) mov (1) REG2(r, nTEMP10, 1):f 0.0f // U coef
99 ( f0.1) mov (1) REG2(r, nTEMP10, 0):f 1.0f // Y coef
100
101 // G = Y - 0.39465*U - 0.58060*V
102 // G = clip( Y - 0.344*(Cb-128) - 0.714*(Cr-128))
103 mov (1) REG2(r, nTEMP8, 7):f 0.000f // A coef
104 mov (1) REG2(r, nTEMP8, 6):f -0.714f // V coef
105 mov (1) REG2(r, nTEMP8, 5):f -0.344f // U coef
106 mov (1) REG2(r, nTEMP8, 4):f 1.0f // Y coef
107
108 // B = Y + 2.03211*U
109 // B = clip( Y + 1.772*(Cb-128))
110 (-f0.1) mov (1) REG2(r, nTEMP10, 3):f 0.000f // A coef
111 (-f0.1) mov (1) REG2(r, nTEMP10, 2):f 0.0f // V coef
112 (-f0.1) mov (1) REG2(r, nTEMP10, 1):f 1.772f // U coef
113 (-f0.1) mov (1) REG2(r, nTEMP10, 0):f 1.0f // Y coef
114
115 ( f0.1) mov (1) REG2(r, nTEMP8, 3):f 0.000f // A coef
116 ( f0.1) mov (1) REG2(r, nTEMP8, 2):f 0.0f // V coef
117 ( f0.1) mov (1) REG2(r, nTEMP8, 1):f 1.772f // U coef
118 ( f0.1) mov (1) REG2(r, nTEMP8, 0):f 1.0f // Y coef
119
120 mov (1) REG2(r, nTEMP10, 4):ud 0x008080F0:ud
121
122 #define fYUV_to_RGB_CH2_Coef_Float REG2(r, nTEMP8, 0)
123 #define fYUV_to_RGB_CH1_Coef_Float REG2(r, nTEMP8, 4)
124 #define fYUV_to_RGB_CH0_Coef_Float REG2(r, nTEMP10, 0)
125 #define bYUV_OFF REG2(r,nTEMP10,16)
126
127 .declare fROW_YUVA Base=REG(r,nTEMP0) ElementSize=4 SrcRegion=REGION(8,8) Type=f // r nTEMP0 - r nTEMP7
128
129 #endif