1 /*
2 * Copyright (c) 2019, 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 "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 */
22 #include "MDF_FC_common_genx.h"
23
Compute_Lumakey_Buf0123(CURBE_INPUT_OUTPUT,GLOBAL_BUFFER_INPUT_OUTPUT)24 _GENX_MAIN_ void Compute_Lumakey_Buf0123(
25 CURBE_INPUT_OUTPUT,
26 GLOBAL_BUFFER_INPUT_OUTPUT)
27 {
28 ushort LowLuma = LumakeyLowThreshold << 8;
29 ushort HighLuma = LumakeyHighThreshold << 8;
30 vector<ushort, 16> Lumakey_mask;
31 ushort Temp_packed_mask;
32 matrix <ushort, 1, 16> Compare_temp;
33
34 #pragma unroll
35 for (int i = 0; i < 4; i++)
36 {
37 /*
38 Buffer layout after shuffle
39 _________________________________________________
40 |_______Block0__________|_______Block1__________|
41 |_______Block2__________|_______Block3__________|
42 |_______Block4__________|_______Block5__________|
43 |_______Block6__________|_______Block7__________|
44
45 Write back buffer layout correlate to the block number#, each box stands for 1 GRF
46 _______________________________________________
47 |____R0_________R1_____|____R2_________R3_____|
48 |____G0_________G1_____|____G2_________G3_____|
49 |____B0_________B1_____|____B2_________B3_____|
50 |____A0_________A1_____|____A2_________A3_____|
51 |____R4_________R5_____|____R6_________R7_____|
52 |____G4_________G5_____|____G6_________G7_____|
53 |____B4_________B5_____|____B6_________B7_____|
54 |____A4_________A5_____|____A6_________A7_____|
55 */
56
57 Compare_temp = DataBuffer.format<ushort, 96, 16>().select<1, 1, 16, 1>(16 * i + 2, 0) & 0xFF00;
58
59 Lumakey_mask = Compare_temp > HighLuma;
60 Lumakey_mask |= Compare_temp < LowLuma;
61
62 Temp_packed_mask = cm_pack_mask(Lumakey_mask);
63 TempMask0[0][4 * i] = Temp_packed_mask & TempMask0[0][4 * i];
64
65 Compare_temp = DataBuffer.format<ushort, 96, 16>().select<1, 1, 16, 1>(16 * i + 3, 0) & 0xFF00;
66
67 Lumakey_mask = Compare_temp > HighLuma;
68 Lumakey_mask |= Compare_temp < LowLuma;
69
70 Temp_packed_mask = cm_pack_mask(Lumakey_mask);
71 TempMask0[0][4 * i + 1] = Temp_packed_mask & TempMask0[0][4 * i + 1];
72
73 // U/V/A channels bottom half
74 Compare_temp = DataBuffer.format<ushort, 96, 16>().select<1, 1, 16, 1>(16 * i + 10, 0) & 0xFF00;
75
76 Lumakey_mask = Compare_temp > HighLuma;
77 Lumakey_mask |= Compare_temp < LowLuma;
78
79 Temp_packed_mask = cm_pack_mask(Lumakey_mask);
80 TempMask0[0][4 * i + 2] = Temp_packed_mask & TempMask0[0][4 * i + 2];
81
82 Compare_temp = DataBuffer.format<ushort, 96, 16>().select<1, 1, 16, 1>(16 * i + 11, 0) & 0xFF00;
83
84 Lumakey_mask = Compare_temp > HighLuma;
85 Lumakey_mask |= Compare_temp < LowLuma;
86
87 Temp_packed_mask = cm_pack_mask(Lumakey_mask);
88 TempMask0[0][4 * i + 3] = Temp_packed_mask & TempMask0[0][4 * i + 3];
89 }
90 }