/src/libhevc/decoder/ihevcd_itrans_recon_dc.c
Line | Count | Source |
1 | | /****************************************************************************** |
2 | | * |
3 | | * Copyright (C) 2012 Ittiam Systems Pvt Ltd, Bangalore |
4 | | * |
5 | | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | | * you may not use this file except in compliance with the License. |
7 | | * You may obtain a copy of the License at: |
8 | | * |
9 | | * http://www.apache.org/licenses/LICENSE-2.0 |
10 | | * |
11 | | * Unless required by applicable law or agreed to in writing, software |
12 | | * distributed under the License is distributed on an "AS IS" BASIS, |
13 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14 | | * See the License for the specific language governing permissions and |
15 | | * limitations under the License. |
16 | | * |
17 | | ******************************************************************************/ |
18 | | /** |
19 | | ******************************************************************************* |
20 | | * @file |
21 | | * ihevcd_itrans_recon_dc.c |
22 | | * |
23 | | * @brief |
24 | | * Contains functions for DC inverse transform and reconstruction |
25 | | * |
26 | | * @author |
27 | | * Ittiam |
28 | | * |
29 | | * @par List of Functions: |
30 | | * - ihevcd_itrans_recon_dc_luma() |
31 | | * - ihevcd_itrans_recon_dc_chroma() |
32 | | * |
33 | | * @remarks |
34 | | * None |
35 | | * |
36 | | ******************************************************************************* |
37 | | */ |
38 | | /*****************************************************************************/ |
39 | | /* File Includes */ |
40 | | /*****************************************************************************/ |
41 | | #include <stdio.h> |
42 | | #include <stddef.h> |
43 | | #include <stdlib.h> |
44 | | #include <string.h> |
45 | | |
46 | | #include "ihevc_typedefs.h" |
47 | | #include "iv.h" |
48 | | #include "ivd.h" |
49 | | #include "ihevcd_cxa.h" |
50 | | |
51 | | #include "ihevc_defs.h" |
52 | | #include "ihevc_debug.h" |
53 | | #include "ihevc_structs.h" |
54 | | #include "ihevc_cabac_tables.h" |
55 | | #include "ihevc_macros.h" |
56 | | #include "ihevc_platform_macros.h" |
57 | | |
58 | | #include "ihevcd_defs.h" |
59 | | #include "ihevcd_function_selector.h" |
60 | | #include "ihevcd_structs.h" |
61 | | #include "ihevcd_error.h" |
62 | | #include "ihevcd_bitstream.h" |
63 | | #include "ihevc_common_tables.h" |
64 | | |
65 | | /* Intra pred includes */ |
66 | | #include "ihevc_intra_pred.h" |
67 | | |
68 | | /* Inverse transform common module includes */ |
69 | | #include "ihevc_trans_tables.h" |
70 | | #include "ihevc_trans_macros.h" |
71 | | #include "ihevc_itrans_recon.h" |
72 | | #include "ihevc_recon.h" |
73 | | #include "ihevc_chroma_itrans_recon.h" |
74 | | #include "ihevc_chroma_recon.h" |
75 | | |
76 | | /* Decoder includes */ |
77 | | #include "ihevcd_common_tables.h" |
78 | | #include "ihevcd_iquant_itrans_recon_ctb.h" |
79 | | #include "ihevcd_debug.h" |
80 | | #include "ihevcd_profile.h" |
81 | | #include "ihevcd_statistics.h" |
82 | | #include "ihevcd_itrans_recon_dc.h" |
83 | | |
84 | | |
85 | | |
86 | | void ihevcd_itrans_recon_dc_luma(UWORD8 *pu1_pred, |
87 | | UWORD8 *pu1_dst, |
88 | | WORD32 pred_strd, |
89 | | WORD32 dst_strd, |
90 | | WORD32 log2_trans_size, |
91 | | WORD16 i2_coeff_value) |
92 | 132k | { |
93 | 132k | WORD32 row, col; |
94 | 132k | WORD32 add, shift; |
95 | 132k | WORD32 dc_value, quant_out; |
96 | 132k | WORD32 trans_size; |
97 | | |
98 | 132k | trans_size = (1 << log2_trans_size); |
99 | | |
100 | 132k | quant_out = i2_coeff_value; |
101 | | |
102 | 132k | shift = IT_SHIFT_STAGE_1; |
103 | 132k | add = 1 << (shift - 1); |
104 | 132k | dc_value = CLIP_S16((quant_out * 64 + add) >> shift); |
105 | 132k | shift = IT_SHIFT_STAGE_2; |
106 | 132k | add = 1 << (shift - 1); |
107 | 132k | dc_value = CLIP_S16((dc_value * 64 + add) >> shift); |
108 | | |
109 | 2.09M | for(row = 0; row < trans_size; row++) |
110 | 39.6M | for(col = 0; col < trans_size; col++) |
111 | 37.6M | pu1_dst[row * dst_strd + col] = CLIP_U8((pu1_pred[row * pred_strd + col] + dc_value)); |
112 | | |
113 | 132k | } |
114 | | |
115 | | void ihevcd_hbd_itrans_recon_dc_luma(UWORD16 *pu2_pred, |
116 | | UWORD16 *pu2_dst, |
117 | | WORD32 pred_strd, |
118 | | WORD32 dst_strd, |
119 | | WORD32 log2_trans_size, |
120 | | WORD16 i2_coeff_value, |
121 | | WORD32 bit_depth) |
122 | 270k | { |
123 | 270k | WORD32 row, col; |
124 | 270k | WORD32 add, shift; |
125 | 270k | WORD32 dc_value, quant_out; |
126 | 270k | WORD32 trans_size; |
127 | | |
128 | 270k | trans_size = (1 << log2_trans_size); |
129 | | |
130 | 270k | quant_out = i2_coeff_value; |
131 | | |
132 | 270k | shift = IT_SHIFT_STAGE_1; |
133 | 270k | add = 1 << (shift - 1); |
134 | 270k | dc_value = CLIP_S16((quant_out * 64 + add) >> shift); |
135 | 270k | shift = 20 - bit_depth; |
136 | 270k | add = 1 << (shift - 1); |
137 | 270k | dc_value = CLIP_S16((dc_value * 64 + add) >> shift); |
138 | | |
139 | 4.28M | for(row = 0; row < trans_size; row++) |
140 | 86.9M | for(col = 0; col < trans_size; col++) |
141 | 82.9M | pu2_dst[row * dst_strd + col] = CLIP3((pu2_pred[row * pred_strd + col] + dc_value), |
142 | 270k | 0, ((1 << bit_depth) - 1)); |
143 | | |
144 | 270k | } |
145 | | |
146 | | void ihevcd_itrans_recon_dc_chroma(UWORD8 *pu1_pred, |
147 | | UWORD8 *pu1_dst, |
148 | | WORD32 pred_strd, |
149 | | WORD32 dst_strd, |
150 | | WORD32 log2_trans_size, |
151 | | WORD16 i2_coeff_value) |
152 | 113k | { |
153 | 113k | WORD32 row, col; |
154 | 113k | WORD32 add, shift; |
155 | 113k | WORD32 dc_value, quant_out; |
156 | 113k | WORD32 trans_size; |
157 | | |
158 | | |
159 | 113k | trans_size = (1 << log2_trans_size); |
160 | | |
161 | 113k | quant_out = i2_coeff_value; |
162 | | |
163 | 113k | shift = IT_SHIFT_STAGE_1; |
164 | 113k | add = 1 << (shift - 1); |
165 | 113k | dc_value = CLIP_S16((quant_out * 64 + add) >> shift); |
166 | 113k | shift = IT_SHIFT_STAGE_2; |
167 | 113k | add = 1 << (shift - 1); |
168 | 113k | dc_value = CLIP_S16((dc_value * 64 + add) >> shift); |
169 | | |
170 | 971k | for(row = 0; row < trans_size; row++) |
171 | 9.72M | for(col = 0; col < trans_size; col++) |
172 | 8.86M | pu1_dst[row * dst_strd + (col << 1)] = CLIP_U8((pu1_pred[row * pred_strd + (col << 1)] + dc_value)); |
173 | | |
174 | 113k | } |
175 | | |
176 | | void ihevcd_hbd_itrans_recon_dc_chroma(UWORD16 *pu2_pred, |
177 | | UWORD16 *pu2_dst, |
178 | | WORD32 pred_strd, |
179 | | WORD32 dst_strd, |
180 | | WORD32 log2_trans_size, |
181 | | WORD16 i2_coeff_value, |
182 | | WORD32 bit_depth) |
183 | 785k | { |
184 | 785k | WORD32 row, col; |
185 | 785k | WORD32 add, shift; |
186 | 785k | WORD32 dc_value, quant_out; |
187 | 785k | WORD32 trans_size; |
188 | | |
189 | 785k | trans_size = (1 << log2_trans_size); |
190 | | |
191 | 785k | quant_out = i2_coeff_value; |
192 | | |
193 | 785k | shift = IT_SHIFT_STAGE_1; |
194 | 785k | add = 1 << (shift - 1); |
195 | 785k | dc_value = CLIP_S16((quant_out * 64 + add) >> shift); |
196 | 785k | shift = 20 - bit_depth; |
197 | 785k | add = 1 << (shift - 1); |
198 | 785k | dc_value = CLIP_S16((dc_value * 64 + add) >> shift); |
199 | | |
200 | 5.45M | for(row = 0; row < trans_size; row++) |
201 | 43.6M | for(col = 0; col < trans_size; col++) |
202 | 38.9M | pu2_dst[row * dst_strd + (col << 1)] = CLIP3((pu2_pred[row * pred_strd + (col << 1)] + dc_value), |
203 | 785k | 0, ((1 << bit_depth) - 1)); |
204 | | |
205 | 785k | } |
206 | | |