/src/libavc/decoder/ih264d_deblocking.c
Line | Count | Source (jump to first uncovered line) |
1 | | /****************************************************************************** |
2 | | * |
3 | | * Copyright (C) 2015 The Android Open Source Project |
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 | | * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore |
19 | | */ |
20 | | |
21 | | #include <string.h> |
22 | | |
23 | | #include "ih264_typedefs.h" |
24 | | #include "iv.h" |
25 | | #include "ivd.h" |
26 | | #include "ih264_macros.h" |
27 | | #include "ih264_platform_macros.h" |
28 | | #include "ih264d_debug.h" |
29 | | #include "ih264d_defs.h" |
30 | | #include "ih264d_defs.h" |
31 | | #include "ih264d_structs.h" |
32 | | #include "ih264d_deblocking.h" |
33 | | #include "ih264d_mb_utils.h" |
34 | | #include "ih264d_error_handler.h" |
35 | | #include "ih264d_utils.h" |
36 | | |
37 | | |
38 | | #include "ih264d_defs.h" |
39 | | #include "ih264d_format_conv.h" |
40 | | #include "ih264d_deblocking.h" |
41 | | #include "ih264d_tables.h" |
42 | | |
43 | | /*! |
44 | | ************************************************************************* |
45 | | * \file ih264d_deblocking.c |
46 | | * |
47 | | * \brief |
48 | | * Decoder specific deblocking routines |
49 | | * |
50 | | * \author AI |
51 | | ************************************************************************* |
52 | | */ |
53 | | |
54 | | /*! |
55 | | ************************************************************************** |
56 | | * \if Function name : HorizonPad \endif |
57 | | * |
58 | | * \brief |
59 | | * Does the Horizontal padding on a whole pic. |
60 | | * |
61 | | * \return |
62 | | * None |
63 | | ************************************************************************** |
64 | | */ |
65 | | |
66 | | /*! |
67 | | ************************************************************************** |
68 | | * \if Function name : FilterBoundaryLeft \endif |
69 | | * |
70 | | * \brief |
71 | | * Filters MacroBlock Left Boundary egdes. |
72 | | * |
73 | | * \return |
74 | | * None |
75 | | ************************************************************************** |
76 | | */ |
77 | | void ih264d_filter_boundary_left_nonmbaff(dec_struct_t *ps_dec, |
78 | | tfr_ctxt_t * ps_tfr_cxt, |
79 | | WORD8 i1_cb_qp_idx_ofst, |
80 | | WORD8 i1_cr_qp_idx_ofst, |
81 | | deblk_mb_t * ps_cur_mb, |
82 | | WORD32 i4_strd_y, |
83 | | WORD32 i4_strd_uv, |
84 | | deblk_mb_t * ps_left_mb, |
85 | | UWORD32 pu4_bs_tab[], |
86 | | UWORD8 u1_cur_fld) |
87 | 11.9M | { |
88 | 11.9M | UWORD8 *pu1_y, *pu1_u, *pu1_v; |
89 | 11.9M | WORD32 uc_tmp, qp_avg; |
90 | 11.9M | WORD32 alpha_u = 0, beta_u = 0, alpha_v = 0, beta_v = 0; |
91 | 11.9M | WORD32 alpha_y = 0, beta_y = 0; |
92 | | |
93 | 11.9M | WORD32 idx_b_u, idx_a_u, idx_b_v, idx_a_v; |
94 | 11.9M | WORD32 idx_b_y, idx_a_y; |
95 | | |
96 | 11.9M | UWORD32 u4_bs_val; |
97 | | |
98 | 11.9M | UWORD8 *pu1_cliptab_u, *pu1_cliptab_v, *pu1_cliptab_y; |
99 | | |
100 | 11.9M | UWORD8 u1_double_cl = !ps_cur_mb->u1_single_call; |
101 | 11.9M | WORD32 ofst_a = ps_cur_mb->i1_slice_alpha_c0_offset; |
102 | 11.9M | WORD32 ofst_b = ps_cur_mb->i1_slice_beta_offset; |
103 | | |
104 | 11.9M | PROFILE_DISABLE_DEBLK() |
105 | | |
106 | 11.9M | pu1_y = ps_tfr_cxt->pu1_mb_y; |
107 | 11.9M | pu1_u = ps_tfr_cxt->pu1_mb_u; |
108 | 11.9M | pu1_v = ps_tfr_cxt->pu1_mb_v; |
109 | | |
110 | | /* LUMA values */ |
111 | | /* Deblock rounding change */ |
112 | 11.9M | qp_avg = |
113 | 11.9M | (UWORD8)((ps_cur_mb->u1_left_mb_qp + ps_cur_mb->u1_mb_qp + 1) |
114 | 11.9M | >> 1); |
115 | | |
116 | 11.9M | idx_a_y = qp_avg + ofst_a; |
117 | 11.9M | alpha_y = gau1_ih264d_alpha_table[12 + idx_a_y]; |
118 | 11.9M | idx_b_y = qp_avg + ofst_b; |
119 | 11.9M | beta_y = gau1_ih264d_beta_table[12 + idx_b_y]; |
120 | | |
121 | | /* Chroma cb values */ |
122 | 11.9M | { |
123 | 11.9M | WORD32 mb_qp1, mb_qp2; |
124 | 11.9M | mb_qp1 = (ps_cur_mb->u1_left_mb_qp + i1_cb_qp_idx_ofst); |
125 | 11.9M | mb_qp2 = (ps_cur_mb->u1_mb_qp + i1_cb_qp_idx_ofst); |
126 | 11.9M | qp_avg = (UWORD8)((gau1_ih264d_qp_scale_cr[12 + mb_qp1] |
127 | 11.9M | + gau1_ih264d_qp_scale_cr[12 + mb_qp2] + 1) >> 1); |
128 | 11.9M | } |
129 | 11.9M | idx_a_u = qp_avg + ofst_a; |
130 | 11.9M | alpha_u = gau1_ih264d_alpha_table[12 + idx_a_u]; |
131 | 11.9M | idx_b_u = qp_avg + ofst_b; |
132 | 11.9M | beta_u = gau1_ih264d_beta_table[12 + idx_b_u]; |
133 | | /* Chroma cr values */ |
134 | 11.9M | { |
135 | 11.9M | WORD32 mb_qp1, mb_qp2; |
136 | 11.9M | mb_qp1 = (ps_cur_mb->u1_left_mb_qp + i1_cr_qp_idx_ofst); |
137 | 11.9M | mb_qp2 = (ps_cur_mb->u1_mb_qp + i1_cr_qp_idx_ofst); |
138 | 11.9M | qp_avg = (UWORD8)((gau1_ih264d_qp_scale_cr[12 + mb_qp1] |
139 | 11.9M | + gau1_ih264d_qp_scale_cr[12 + mb_qp2] + 1) >> 1); |
140 | 11.9M | } |
141 | 11.9M | idx_a_v = qp_avg + ofst_a; |
142 | 11.9M | alpha_v = gau1_ih264d_alpha_table[12 + idx_a_v]; |
143 | 11.9M | idx_b_v = qp_avg + ofst_b; |
144 | 11.9M | beta_v = gau1_ih264d_beta_table[12 + idx_b_v]; |
145 | | |
146 | 11.9M | if(u1_double_cl == 0) |
147 | 11.9M | { |
148 | 11.9M | u4_bs_val = pu4_bs_tab[4]; |
149 | | |
150 | 11.9M | if(0x04040404 == u4_bs_val) |
151 | 763k | { |
152 | 763k | ps_dec->pf_deblk_luma_vert_bs4(pu1_y, i4_strd_y, alpha_y, beta_y); |
153 | 763k | ps_dec->pf_deblk_chroma_vert_bs4(pu1_u, i4_strd_uv, alpha_u, |
154 | 763k | beta_u, alpha_v, beta_v); |
155 | 763k | } |
156 | 11.1M | else |
157 | 11.1M | { |
158 | 11.1M | if(u4_bs_val) |
159 | 96.0k | { |
160 | | |
161 | 96.0k | pu1_cliptab_y = (UWORD8 *)&gau1_ih264d_clip_table[12 + idx_a_y]; |
162 | 96.0k | pu1_cliptab_u = (UWORD8 *)&gau1_ih264d_clip_table[12 + idx_a_u]; |
163 | 96.0k | pu1_cliptab_v = (UWORD8 *)&gau1_ih264d_clip_table[12 + idx_a_v]; |
164 | 96.0k | ps_dec->pf_deblk_luma_vert_bslt4(pu1_y, i4_strd_y, alpha_y, |
165 | 96.0k | beta_y, u4_bs_val, |
166 | 96.0k | pu1_cliptab_y); |
167 | 96.0k | ps_dec->pf_deblk_chroma_vert_bslt4(pu1_u, i4_strd_uv, alpha_u, |
168 | 96.0k | beta_u, alpha_v, beta_v, |
169 | 96.0k | u4_bs_val, pu1_cliptab_u, |
170 | 96.0k | pu1_cliptab_v); |
171 | | |
172 | 96.0k | } |
173 | 11.1M | } |
174 | | |
175 | 11.9M | } |
176 | 0 | else |
177 | 0 | { |
178 | |
|
179 | 0 | i4_strd_y <<= (!u1_cur_fld); |
180 | 0 | u4_bs_val = pu4_bs_tab[4]; |
181 | 0 | i4_strd_uv <<= (!u1_cur_fld); |
182 | |
|
183 | 0 | if(0x04040404 == u4_bs_val) |
184 | 0 | { |
185 | |
|
186 | 0 | ps_dec->pf_deblk_luma_vert_bs4_mbaff(pu1_y, i4_strd_y, alpha_y, |
187 | 0 | beta_y); |
188 | 0 | ps_dec->pf_deblk_chroma_vert_bs4_mbaff(pu1_u, i4_strd_uv, alpha_u, |
189 | 0 | beta_u, alpha_v, beta_v); |
190 | |
|
191 | 0 | } |
192 | 0 | else |
193 | 0 | { |
194 | 0 | if(u4_bs_val) |
195 | 0 | { |
196 | |
|
197 | 0 | pu1_cliptab_y = (UWORD8 *)&gau1_ih264d_clip_table[12 + idx_a_y]; |
198 | 0 | pu1_cliptab_u = (UWORD8 *)&gau1_ih264d_clip_table[12 + idx_a_u]; |
199 | 0 | pu1_cliptab_v = (UWORD8 *)&gau1_ih264d_clip_table[12 + idx_a_v]; |
200 | |
|
201 | 0 | ps_dec->pf_deblk_luma_vert_bslt4_mbaff(pu1_y, i4_strd_y, |
202 | 0 | alpha_y, beta_y, |
203 | 0 | u4_bs_val, |
204 | 0 | pu1_cliptab_y); |
205 | 0 | ps_dec->pf_deblk_chroma_vert_bslt4_mbaff(pu1_u, i4_strd_uv, |
206 | 0 | alpha_u, beta_u, |
207 | 0 | alpha_v, beta_v, |
208 | 0 | u4_bs_val, |
209 | 0 | pu1_cliptab_u, |
210 | 0 | pu1_cliptab_v); |
211 | 0 | } |
212 | 0 | } |
213 | |
|
214 | 0 | { |
215 | |
|
216 | 0 | UWORD16 u2_shift = (i4_strd_y >> 1) << (u1_cur_fld ? 4 : 0); |
217 | 0 | pu1_y += u2_shift; |
218 | 0 | u2_shift = (i4_strd_uv >> 1) << (u1_cur_fld ? 3 : 0); |
219 | 0 | pu1_u += u2_shift; |
220 | 0 | pu1_v += u2_shift; |
221 | 0 | } |
222 | |
|
223 | 0 | qp_avg = (((ps_left_mb + 1)->u1_mb_qp + ps_cur_mb->u1_mb_qp + 1) >> 1); |
224 | |
|
225 | 0 | idx_a_y = qp_avg + ofst_a; |
226 | 0 | alpha_y = gau1_ih264d_alpha_table[12 + idx_a_y]; |
227 | 0 | idx_b_y = qp_avg + ofst_b; |
228 | 0 | beta_y = gau1_ih264d_beta_table[12 + idx_b_y]; |
229 | 0 | u4_bs_val = pu4_bs_tab[9]; |
230 | |
|
231 | 0 | { |
232 | 0 | WORD32 mb_qp1, mb_qp2; |
233 | 0 | mb_qp1 = ((ps_left_mb + 1)->u1_mb_qp + i1_cb_qp_idx_ofst); |
234 | 0 | mb_qp2 = (ps_cur_mb->u1_mb_qp + i1_cb_qp_idx_ofst); |
235 | 0 | qp_avg = (UWORD8)((gau1_ih264d_qp_scale_cr[12 + mb_qp1] |
236 | 0 | + gau1_ih264d_qp_scale_cr[12 + mb_qp2] + 1) >> 1); |
237 | 0 | } |
238 | 0 | idx_a_u = qp_avg + ofst_a; |
239 | 0 | alpha_u = gau1_ih264d_alpha_table[12 + idx_a_u]; |
240 | 0 | idx_b_u = qp_avg + ofst_b; |
241 | 0 | beta_u = gau1_ih264d_beta_table[12 + idx_b_u]; |
242 | 0 | u4_bs_val = pu4_bs_tab[9]; |
243 | 0 | { |
244 | 0 | WORD32 mb_qp1, mb_qp2; |
245 | 0 | mb_qp1 = ((ps_left_mb + 1)->u1_mb_qp + i1_cr_qp_idx_ofst); |
246 | 0 | mb_qp2 = (ps_cur_mb->u1_mb_qp + i1_cr_qp_idx_ofst); |
247 | 0 | qp_avg = (UWORD8)((gau1_ih264d_qp_scale_cr[12 + mb_qp1] |
248 | 0 | + gau1_ih264d_qp_scale_cr[12 + mb_qp2] + 1) >> 1); |
249 | 0 | } |
250 | 0 | idx_a_v = qp_avg + ofst_a; |
251 | 0 | alpha_v = gau1_ih264d_alpha_table[12 + idx_a_v]; |
252 | 0 | idx_b_v = qp_avg + ofst_b; |
253 | 0 | beta_v = gau1_ih264d_beta_table[12 + idx_b_v]; |
254 | |
|
255 | 0 | if(0x04040404 == u4_bs_val) |
256 | 0 | { |
257 | 0 | ps_dec->pf_deblk_luma_vert_bs4_mbaff(pu1_y, i4_strd_y, alpha_y, |
258 | 0 | beta_y); |
259 | 0 | ps_dec->pf_deblk_chroma_vert_bs4_mbaff(pu1_u, i4_strd_uv, alpha_u, |
260 | 0 | beta_u, alpha_v, beta_v); |
261 | |
|
262 | 0 | } |
263 | 0 | else |
264 | 0 | { |
265 | 0 | if(u4_bs_val) |
266 | 0 | { |
267 | |
|
268 | 0 | pu1_cliptab_y = (UWORD8 *)&gau1_ih264d_clip_table[12 + idx_a_y]; |
269 | 0 | pu1_cliptab_u = (UWORD8 *)&gau1_ih264d_clip_table[12 + idx_a_u]; |
270 | 0 | pu1_cliptab_v = (UWORD8 *)&gau1_ih264d_clip_table[12 + idx_a_v]; |
271 | |
|
272 | 0 | ps_dec->pf_deblk_luma_vert_bslt4_mbaff(pu1_y, i4_strd_y, |
273 | 0 | alpha_y, beta_y, |
274 | 0 | u4_bs_val, |
275 | 0 | pu1_cliptab_y); |
276 | 0 | ps_dec->pf_deblk_chroma_vert_bslt4_mbaff(pu1_u, i4_strd_uv, |
277 | 0 | alpha_u, beta_u, |
278 | 0 | alpha_v, beta_v, |
279 | 0 | u4_bs_val, |
280 | 0 | pu1_cliptab_u, |
281 | 0 | pu1_cliptab_v); |
282 | |
|
283 | 0 | } |
284 | 0 | } |
285 | 0 | } |
286 | | |
287 | 11.9M | } |
288 | | |
289 | | /*! |
290 | | ************************************************************************** |
291 | | * \if Function name : FilterBoundaryTop \endif |
292 | | * |
293 | | * \brief |
294 | | * Filters MacroBlock Top Boundary egdes. |
295 | | * |
296 | | * \return |
297 | | * None |
298 | | ************************************************************************** |
299 | | */ |
300 | | |
301 | | void ih264d_filter_boundary_top_nonmbaff(dec_struct_t *ps_dec, |
302 | | tfr_ctxt_t * ps_tfr_cxt, |
303 | | WORD8 i1_cb_qp_idx_ofst, |
304 | | WORD8 i1_cr_qp_idx_ofst, |
305 | | deblk_mb_t * ps_cur_mb, |
306 | | WORD32 i4_strd_y, |
307 | | WORD32 i4_strd_uv, |
308 | | deblk_mb_t * ps_top_mb, |
309 | | UWORD32 u4_bs) |
310 | 11.8M | { |
311 | 11.8M | UWORD8 *pu1_y, *pu1_u; |
312 | 11.8M | WORD32 alpha_u = 0, beta_u = 0, alpha_v = 0, beta_v = 0; |
313 | 11.8M | WORD32 alpha_y = 0, beta_y = 0; |
314 | 11.8M | WORD32 qp_avg; |
315 | 11.8M | WORD32 idx_b_u, idx_a_u, idx_b_v, idx_a_v; |
316 | 11.8M | WORD32 idx_b_y, idx_a_y; |
317 | 11.8M | UWORD16 uc_tmp; |
318 | | |
319 | 11.8M | UWORD8 *pu1_cliptab_u, *pu1_cliptab_v, *pu1_cliptab_y; |
320 | 11.8M | WORD32 ofst_a = ps_cur_mb->i1_slice_alpha_c0_offset; |
321 | 11.8M | WORD32 ofst_b = ps_cur_mb->i1_slice_beta_offset; |
322 | | |
323 | 11.8M | UNUSED(ps_top_mb); |
324 | | /* LUMA values */ |
325 | | /* Deblock rounding change */ |
326 | 11.8M | uc_tmp = ((ps_cur_mb->u1_topmb_qp + ps_cur_mb->u1_mb_qp + 1) >> 1); |
327 | 11.8M | qp_avg = (UWORD8)uc_tmp; |
328 | 11.8M | idx_a_y = qp_avg + ofst_a; |
329 | 11.8M | alpha_y = gau1_ih264d_alpha_table[12 + idx_a_y]; |
330 | 11.8M | idx_b_y = qp_avg + ofst_b; |
331 | 11.8M | beta_y = gau1_ih264d_beta_table[12 + idx_b_y]; |
332 | 11.8M | pu1_y = ps_tfr_cxt->pu1_mb_y; |
333 | | |
334 | | /* CHROMA cb values */ |
335 | 11.8M | { |
336 | 11.8M | WORD32 mb_qp1, mb_qp2; |
337 | 11.8M | mb_qp1 = (ps_cur_mb->u1_topmb_qp + i1_cb_qp_idx_ofst); |
338 | 11.8M | mb_qp2 = (ps_cur_mb->u1_mb_qp + i1_cb_qp_idx_ofst); |
339 | 11.8M | qp_avg = (UWORD8)((gau1_ih264d_qp_scale_cr[12 + mb_qp1] |
340 | 11.8M | + gau1_ih264d_qp_scale_cr[12 + mb_qp2] + 1) >> 1); |
341 | 11.8M | } |
342 | | |
343 | 11.8M | idx_a_u = qp_avg + ofst_a; |
344 | 11.8M | alpha_u = gau1_ih264d_alpha_table[12 + idx_a_u]; |
345 | 11.8M | idx_b_u = qp_avg + ofst_b; |
346 | 11.8M | beta_u = gau1_ih264d_beta_table[12 + idx_b_u]; |
347 | | /* CHROMA cr values */ |
348 | 11.8M | { |
349 | 11.8M | WORD32 mb_qp1, mb_qp2; |
350 | 11.8M | mb_qp1 = (ps_cur_mb->u1_topmb_qp + i1_cr_qp_idx_ofst); |
351 | 11.8M | mb_qp2 = (ps_cur_mb->u1_mb_qp + i1_cr_qp_idx_ofst); |
352 | 11.8M | qp_avg = (UWORD8)((gau1_ih264d_qp_scale_cr[12 + mb_qp1] |
353 | 11.8M | + gau1_ih264d_qp_scale_cr[12 + mb_qp2] + 1) >> 1); |
354 | 11.8M | } |
355 | | |
356 | 11.8M | idx_a_v = qp_avg + ofst_a; |
357 | 11.8M | alpha_v = gau1_ih264d_alpha_table[12 + idx_a_v]; |
358 | 11.8M | idx_b_v = qp_avg + ofst_b; |
359 | 11.8M | beta_v = gau1_ih264d_beta_table[12 + idx_b_v]; |
360 | 11.8M | pu1_u = ps_tfr_cxt->pu1_mb_u; |
361 | | |
362 | 11.8M | if(u4_bs == 0x04040404) |
363 | 768k | { |
364 | | /* Code specific to the assembly module */ |
365 | | |
366 | 768k | ps_dec->pf_deblk_luma_horz_bs4(pu1_y, i4_strd_y, alpha_y, beta_y); |
367 | 768k | ps_dec->pf_deblk_chroma_horz_bs4(pu1_u, i4_strd_uv, alpha_u, beta_u, |
368 | 768k | alpha_v, beta_v); |
369 | 768k | } |
370 | 11.0M | else |
371 | 11.0M | { |
372 | 11.0M | if(u4_bs) |
373 | 185k | { |
374 | | |
375 | 185k | pu1_cliptab_y = (UWORD8 *)&gau1_ih264d_clip_table[12 + idx_a_y]; |
376 | 185k | pu1_cliptab_u = |
377 | 185k | (UWORD8 *)&gau1_ih264d_clip_table[12 + idx_a_u]; |
378 | 185k | pu1_cliptab_v = |
379 | 185k | (UWORD8 *)&gau1_ih264d_clip_table[12 + idx_a_v]; |
380 | | |
381 | 185k | ps_dec->pf_deblk_luma_horz_bslt4(pu1_y, i4_strd_y, alpha_y, beta_y, |
382 | 185k | u4_bs, pu1_cliptab_y); |
383 | 185k | ps_dec->pf_deblk_chroma_horz_bslt4(pu1_u, i4_strd_uv, alpha_u, |
384 | 185k | beta_u, alpha_v, beta_v, |
385 | 185k | u4_bs, pu1_cliptab_u, |
386 | 185k | pu1_cliptab_v); |
387 | | |
388 | 185k | } |
389 | 11.0M | } |
390 | | |
391 | 11.8M | } |
392 | | |
393 | | void ih264d_deblock_mb_nonmbaff(dec_struct_t *ps_dec, |
394 | | tfr_ctxt_t * ps_tfr_cxt, |
395 | | WORD8 i1_cb_qp_idx_ofst, |
396 | | WORD8 i1_cr_qp_idx_ofst, |
397 | | WORD32 i4_strd_y, |
398 | | WORD32 i4_strd_uv ) |
399 | 12.2M | { |
400 | 12.2M | UWORD8 *pu1_y, *pu1_u; |
401 | 12.2M | UWORD32 u4_bs; |
402 | | |
403 | 12.2M | WORD32 alpha, beta, alpha_u, beta_u, alpha_v, beta_v; |
404 | | |
405 | 12.2M | UWORD8 *pu1_cliptab_u; |
406 | 12.2M | UWORD8 *pu1_cliptab_v; |
407 | 12.2M | UWORD8 *pu1_cliptab_y; |
408 | | |
409 | 12.2M | UWORD32 * pu4_bs_tab; |
410 | 12.2M | WORD32 idx_a_y, idx_a_u, idx_a_v; |
411 | 12.2M | UWORD32 u4_deb_mode, u4_mbs_next; |
412 | 12.2M | UWORD32 u4_image_wd_mb; |
413 | 12.2M | deblk_mb_t *ps_top_mb,*ps_left_mb,*ps_cur_mb; |
414 | | |
415 | 12.2M | PROFILE_DISABLE_DEBLK() |
416 | | /* Return from here to switch off deblocking */ |
417 | | |
418 | 12.2M | u4_image_wd_mb = ps_dec->u2_frm_wd_in_mbs; |
419 | | |
420 | 12.2M | ps_cur_mb = ps_dec->ps_cur_deblk_mb; |
421 | 12.2M | pu4_bs_tab = ps_cur_mb->u4_bs_table; |
422 | 12.2M | u4_deb_mode = ps_cur_mb->u1_deblocking_mode; |
423 | 12.2M | if(!(u4_deb_mode & MB_DISABLE_FILTERING)) |
424 | 12.1M | { |
425 | | |
426 | 12.1M | if(ps_dec->u4_deblk_mb_x) |
427 | 11.9M | { |
428 | 11.9M | ps_left_mb = ps_cur_mb - 1; |
429 | | |
430 | 11.9M | } |
431 | 208k | else |
432 | 208k | { |
433 | 208k | ps_left_mb = NULL; |
434 | | |
435 | 208k | } |
436 | 12.1M | if(ps_dec->u4_deblk_mb_y != 0) |
437 | 11.8M | { |
438 | 11.8M | ps_top_mb = ps_cur_mb - (u4_image_wd_mb); |
439 | 11.8M | } |
440 | 364k | else |
441 | 364k | { |
442 | 364k | ps_top_mb = NULL; |
443 | 364k | } |
444 | | |
445 | 12.1M | if(u4_deb_mode & MB_DISABLE_LEFT_EDGE) |
446 | 4.51k | ps_left_mb = NULL; |
447 | 12.1M | if(u4_deb_mode & MB_DISABLE_TOP_EDGE) |
448 | 21.6k | ps_top_mb = NULL; |
449 | | |
450 | | /*---------------------------------------------------------------------*/ |
451 | | /* Filter wrt Left edge */ |
452 | | /* except */ |
453 | | /* - Left Egde is Picture Boundary */ |
454 | | /* - Left Egde is part of Slice Boundary and Deblocking */ |
455 | | /* parameters of slice disable Filtering of Slice Boundary Edges*/ |
456 | | /*---------------------------------------------------------------------*/ |
457 | 12.1M | if(ps_left_mb) |
458 | 11.9M | ih264d_filter_boundary_left_nonmbaff(ps_dec, ps_tfr_cxt, |
459 | 11.9M | i1_cb_qp_idx_ofst, |
460 | 11.9M | i1_cr_qp_idx_ofst, ps_cur_mb, |
461 | 11.9M | i4_strd_y, i4_strd_uv, ps_left_mb, |
462 | 11.9M | pu4_bs_tab, 0); |
463 | | |
464 | | /*--------------------------------------------------------------------*/ |
465 | | /* Filter wrt Other Vertical Edges */ |
466 | | /*--------------------------------------------------------------------*/ |
467 | 12.1M | { |
468 | 12.1M | WORD32 ofst_a, ofst_b, idx_b_y, idx_b_u, |
469 | 12.1M | idx_b_v; |
470 | 12.1M | WORD32 qp_avg, qp_avg_u, qp_avg_v; |
471 | 12.1M | ofst_a = ps_cur_mb->i1_slice_alpha_c0_offset; |
472 | 12.1M | ofst_b = ps_cur_mb->i1_slice_beta_offset; |
473 | | |
474 | 12.1M | qp_avg = ps_cur_mb->u1_mb_qp; |
475 | | |
476 | 12.1M | idx_a_y = qp_avg + ofst_a; |
477 | 12.1M | alpha = gau1_ih264d_alpha_table[12 + idx_a_y]; |
478 | 12.1M | idx_b_y = qp_avg + ofst_b; |
479 | 12.1M | beta = gau1_ih264d_beta_table[12 + idx_b_y]; |
480 | | |
481 | | /* CHROMA values */ |
482 | | /* CHROMA Cb values */ |
483 | 12.1M | qp_avg_u = (qp_avg + i1_cb_qp_idx_ofst); |
484 | 12.1M | qp_avg_u = gau1_ih264d_qp_scale_cr[12 + qp_avg_u]; |
485 | 12.1M | idx_a_u = qp_avg_u + ofst_a; |
486 | 12.1M | alpha_u = gau1_ih264d_alpha_table[12 + idx_a_u]; |
487 | 12.1M | idx_b_u = qp_avg_u + ofst_b; |
488 | 12.1M | beta_u = gau1_ih264d_beta_table[12 + idx_b_u]; |
489 | | /* CHROMA Cr values */ |
490 | 12.1M | qp_avg_v = (qp_avg + i1_cr_qp_idx_ofst); |
491 | 12.1M | qp_avg_v = gau1_ih264d_qp_scale_cr[12 + qp_avg_v]; |
492 | 12.1M | idx_a_v = qp_avg_v + ofst_a; |
493 | 12.1M | alpha_v = gau1_ih264d_alpha_table[12 + idx_a_v]; |
494 | 12.1M | idx_b_v = qp_avg_v + ofst_b; |
495 | 12.1M | beta_v = gau1_ih264d_beta_table[12 + idx_b_v]; |
496 | 12.1M | } |
497 | | |
498 | 12.1M | pu1_cliptab_y = (UWORD8 *)&gau1_ih264d_clip_table[12 + idx_a_y]; //this for Luma |
499 | 12.1M | pu1_cliptab_u = (UWORD8 *)&gau1_ih264d_clip_table[12 + idx_a_u]; //this for chroma |
500 | 12.1M | pu1_cliptab_v = (UWORD8 *)&gau1_ih264d_clip_table[12 + idx_a_v]; //this for chroma |
501 | | |
502 | | //edge=1 |
503 | | |
504 | | |
505 | 12.1M | u4_bs = pu4_bs_tab[5]; |
506 | 12.1M | pu1_y = ps_tfr_cxt->pu1_mb_y; |
507 | 12.1M | pu1_u = ps_tfr_cxt->pu1_mb_u; |
508 | | |
509 | 12.1M | if(u4_bs) |
510 | 739k | { |
511 | | |
512 | 739k | ps_dec->pf_deblk_luma_vert_bslt4(pu1_y + 4, i4_strd_y, alpha, beta, |
513 | 739k | u4_bs, pu1_cliptab_y); |
514 | | |
515 | 739k | } |
516 | | //edge=2 |
517 | | |
518 | 12.1M | u4_bs = pu4_bs_tab[6]; |
519 | 12.1M | if(u4_bs) |
520 | 810k | { |
521 | 810k | ps_dec->pf_deblk_luma_vert_bslt4(pu1_y + 8, i4_strd_y, alpha, beta, |
522 | 810k | u4_bs, pu1_cliptab_y); |
523 | 810k | ps_dec->pf_deblk_chroma_vert_bslt4(pu1_u + 4 * YUV420SP_FACTOR, |
524 | 810k | i4_strd_uv, alpha_u, beta_u, |
525 | 810k | alpha_v, beta_v, u4_bs, |
526 | 810k | pu1_cliptab_u, pu1_cliptab_v); |
527 | | |
528 | 810k | } |
529 | | //edge=3 |
530 | | |
531 | 12.1M | u4_bs = pu4_bs_tab[7]; |
532 | 12.1M | if(u4_bs) |
533 | 740k | { |
534 | 740k | ps_dec->pf_deblk_luma_vert_bslt4(pu1_y + 12, i4_strd_y, alpha, beta, |
535 | 740k | u4_bs, pu1_cliptab_y); |
536 | | |
537 | 740k | } |
538 | | |
539 | | /*--------------------------------------------------------------------*/ |
540 | | /* Filter wrt Top edge */ |
541 | | /* except */ |
542 | | /* - Top Egde is Picture Boundary */ |
543 | | /* - Top Egde is part of Slice Boundary and Deblocking */ |
544 | | /* parameters of slice disable Filtering of Slice Boundary Edges*/ |
545 | | /*--------------------------------------------------------------------*/ |
546 | 12.1M | if(ps_top_mb) |
547 | 11.8M | { |
548 | | /** if top MB and MB AFF and cur MB is frame and top is field then */ |
549 | | /* one extra top edge needs to be deblocked */ |
550 | | |
551 | 11.8M | ih264d_filter_boundary_top_nonmbaff(ps_dec, ps_tfr_cxt, |
552 | 11.8M | i1_cb_qp_idx_ofst, |
553 | 11.8M | i1_cr_qp_idx_ofst, ps_cur_mb, |
554 | 11.8M | i4_strd_y, i4_strd_uv, ps_top_mb, |
555 | 11.8M | pu4_bs_tab[0]); |
556 | | |
557 | 11.8M | } |
558 | | |
559 | | /*--------------------------------------------------------------------*/ |
560 | | /* Filter wrt Other Horizontal Edges */ |
561 | | /*--------------------------------------------------------------------*/ |
562 | | |
563 | | //edge1 |
564 | 12.1M | u4_bs = pu4_bs_tab[1]; |
565 | | |
566 | 12.1M | if(u4_bs) |
567 | 740k | { |
568 | 740k | ps_dec->pf_deblk_luma_horz_bslt4(pu1_y + (i4_strd_y << 2), i4_strd_y, |
569 | 740k | alpha, beta, u4_bs, pu1_cliptab_y); |
570 | | |
571 | 740k | } |
572 | | //edge2 |
573 | 12.1M | u4_bs = pu4_bs_tab[2]; |
574 | | |
575 | 12.1M | if(u4_bs) |
576 | 825k | { |
577 | | |
578 | 825k | ps_dec->pf_deblk_luma_horz_bslt4(pu1_y + (i4_strd_y << 3), i4_strd_y, |
579 | 825k | alpha, beta, u4_bs, pu1_cliptab_y); |
580 | 825k | ps_dec->pf_deblk_chroma_horz_bslt4(pu1_u + (i4_strd_uv << 2), |
581 | 825k | i4_strd_uv, alpha_u, beta_u, |
582 | 825k | alpha_v, beta_v, u4_bs, |
583 | 825k | pu1_cliptab_u, pu1_cliptab_v); |
584 | | |
585 | 825k | } |
586 | | //edge3 |
587 | 12.1M | u4_bs = pu4_bs_tab[3]; |
588 | 12.1M | if(u4_bs) |
589 | 741k | { |
590 | 741k | ps_dec->pf_deblk_luma_horz_bslt4( |
591 | 741k | (pu1_y + (i4_strd_y << 3) + (i4_strd_y << 2)), |
592 | 741k | i4_strd_y, alpha, beta, u4_bs, pu1_cliptab_y); |
593 | | |
594 | 741k | } |
595 | 12.1M | } |
596 | | |
597 | 12.2M | ps_dec->u4_deblk_mb_x++; |
598 | 12.2M | ps_dec->ps_cur_deblk_mb++; |
599 | 12.2M | ps_dec->u4_cur_deblk_mb_num++; |
600 | 12.2M | u4_mbs_next = u4_image_wd_mb - ps_dec->u4_deblk_mb_x; |
601 | | |
602 | 12.2M | ps_tfr_cxt->pu1_mb_y += 16; |
603 | 12.2M | ps_tfr_cxt->pu1_mb_u += 8 * YUV420SP_FACTOR; |
604 | 12.2M | ps_tfr_cxt->pu1_mb_v += 8; |
605 | | |
606 | 12.2M | if(!u4_mbs_next) |
607 | 212k | { |
608 | 212k | ps_tfr_cxt->pu1_mb_y += ps_tfr_cxt->u4_y_inc; |
609 | 212k | ps_tfr_cxt->pu1_mb_u += ps_tfr_cxt->u4_uv_inc; |
610 | 212k | ps_tfr_cxt->pu1_mb_v += ps_tfr_cxt->u4_uv_inc; |
611 | 212k | ps_dec->u4_deblk_mb_y++; |
612 | 212k | ps_dec->u4_deblk_mb_x = 0; |
613 | 212k | } |
614 | | |
615 | 12.2M | } |
616 | | |
617 | | /************************************************************************** |
618 | | * |
619 | | * Function Name : ih264d_init_deblk_tfr_ctxt |
620 | | * |
621 | | * Description : This function is called once per deblockpicture call |
622 | | * This sets up the transfer address contexts |
623 | | * |
624 | | * Revision History: |
625 | | * |
626 | | * DD MM YYYY Author(s) Changes (Describe the changes made) |
627 | | * 14 06 2005 SWRN Draft |
628 | | **************************************************************************/ |
629 | | void ih264d_init_deblk_tfr_ctxt(dec_struct_t * ps_dec, |
630 | | pad_mgr_t *ps_pad_mgr, |
631 | | tfr_ctxt_t *ps_tfr_cxt, |
632 | | UWORD16 u2_image_wd_mb, |
633 | | UWORD8 u1_mbaff) |
634 | 27.9k | { |
635 | | |
636 | 27.9k | UWORD32 i4_wd_y; |
637 | 27.9k | UWORD32 i4_wd_uv; |
638 | 27.9k | UWORD8 u1_field_pic_flag = ps_dec->ps_cur_slice->u1_field_pic_flag; /*< Field u4_flag */ |
639 | 27.9k | UNUSED(u2_image_wd_mb); |
640 | 27.9k | ps_tfr_cxt->pu1_src_y = ps_dec->s_cur_pic.pu1_buf1 - 4; |
641 | 27.9k | ps_tfr_cxt->pu1_src_u = ps_dec->s_cur_pic.pu1_buf2 - 4; |
642 | 27.9k | ps_tfr_cxt->pu1_src_v = ps_dec->s_cur_pic.pu1_buf3 - 4; |
643 | 27.9k | ps_tfr_cxt->pu1_dest_y = ps_tfr_cxt->pu1_src_y; |
644 | 27.9k | ps_tfr_cxt->pu1_dest_u = ps_tfr_cxt->pu1_src_u; |
645 | 27.9k | ps_tfr_cxt->pu1_dest_v = ps_tfr_cxt->pu1_src_v; |
646 | | |
647 | 27.9k | ps_tfr_cxt->pu1_mb_y = ps_tfr_cxt->pu1_src_y + 4; |
648 | 27.9k | ps_tfr_cxt->pu1_mb_u = ps_tfr_cxt->pu1_src_u + 4; |
649 | 27.9k | ps_tfr_cxt->pu1_mb_v = ps_tfr_cxt->pu1_src_v + 4; |
650 | | |
651 | 27.9k | i4_wd_y = ps_dec->u2_frm_wd_y << u1_field_pic_flag; |
652 | 27.9k | i4_wd_uv = ps_dec->u2_frm_wd_uv << u1_field_pic_flag; |
653 | 27.9k | ps_tfr_cxt->u4_y_inc = ((i4_wd_y << u1_mbaff) * 16 |
654 | 27.9k | - (ps_dec->u2_frm_wd_in_mbs << 4)); |
655 | | |
656 | 27.9k | ps_tfr_cxt->u4_uv_inc = (i4_wd_uv << u1_mbaff) * 8 |
657 | 27.9k | - (ps_dec->u2_frm_wd_in_mbs << 4); |
658 | | |
659 | | /* padding related initialisations */ |
660 | 27.9k | if(ps_dec->ps_cur_slice->u1_nal_ref_idc) |
661 | 21.2k | { |
662 | 21.2k | ps_pad_mgr->u1_vert_pad_top = !(ps_dec->ps_cur_slice->u1_field_pic_flag |
663 | 21.2k | && ps_dec->ps_cur_slice->u1_bottom_field_flag); |
664 | 21.2k | ps_pad_mgr->u1_vert_pad_bot = |
665 | 21.2k | ((!ps_dec->ps_cur_slice->u1_field_pic_flag) |
666 | 21.2k | || ps_dec->ps_cur_slice->u1_bottom_field_flag); |
667 | 21.2k | ps_pad_mgr->u1_horz_pad = 1; |
668 | 21.2k | } |
669 | 6.74k | else |
670 | 6.74k | { |
671 | 6.74k | ps_pad_mgr->u1_horz_pad = 0; |
672 | 6.74k | ps_pad_mgr->u1_vert_pad_top = 0; |
673 | 6.74k | ps_pad_mgr->u1_vert_pad_bot = 0; |
674 | 6.74k | } |
675 | 27.9k | } |
676 | | |
677 | | /*****************************************************************************/ |
678 | | /* */ |
679 | | /* Function Name : ih264d_deblock_picture_mbaff */ |
680 | | /* */ |
681 | | /* Description : This function carries out deblocking on a whole picture */ |
682 | | /* with MBAFF */ |
683 | | /* */ |
684 | | /* Inputs : <What inputs does the function take?> */ |
685 | | /* Processing : This functions calls deblock MB in the MB increment order*/ |
686 | | /* */ |
687 | | /* Outputs : Produces the deblocked picture */ |
688 | | /* Returns : None */ |
689 | | /* */ |
690 | | /* Revision History: */ |
691 | | /* */ |
692 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
693 | | /* 17 02 2005 NS Creation */ |
694 | | /* 14 06 2005 SWRN clean-up */ |
695 | | /*****************************************************************************/ |
696 | | |
697 | | void ih264d_deblock_picture_mbaff(dec_struct_t * ps_dec) |
698 | 3.10k | { |
699 | 3.10k | WORD16 i2_mb_x, i2_mb_y; |
700 | 3.10k | deblk_mb_t *ps_cur_mb; |
701 | 3.10k | deblk_mb_t *ps_top_mb; |
702 | 3.10k | deblk_mb_t *ps_left_mb; |
703 | | |
704 | 3.10k | UWORD8 u1_vert_pad_top = 1; |
705 | 3.10k | UWORD8 u1_cur_fld, u1_top_fld, u1_left_fld; |
706 | 3.10k | UWORD8 u1_first_row; |
707 | | |
708 | 3.10k | UWORD8 * pu1_deb_y, *pu1_deb_u, *pu1_deb_v; |
709 | 3.10k | UWORD8 u1_deb_mode, u1_extra_top_edge; |
710 | 3.10k | WORD32 i4_wd_y, i4_wd_uv; |
711 | | |
712 | 3.10k | UWORD8 u1_field_pic_flag = ps_dec->ps_cur_slice->u1_field_pic_flag; /*< Field u4_flag */ |
713 | 3.10k | UWORD8 u1_bottom_field_flag = ps_dec->ps_cur_slice->u1_bottom_field_flag; /*< Bottom field u4_flag*/ |
714 | | |
715 | | /**************************************************/ |
716 | | /* one time loads from ps_dec which will be used */ |
717 | | /* frequently throughout the deblocking procedure */ |
718 | | /**************************************************/ |
719 | 3.10k | pad_mgr_t * ps_pad_mgr = &ps_dec->s_pad_mgr; |
720 | 3.10k | tfr_ctxt_t s_tfr_ctxt; |
721 | 3.10k | tfr_ctxt_t * ps_tfr_cxt = &s_tfr_ctxt; |
722 | | |
723 | 3.10k | UWORD16 u2_image_wd_mb = ps_dec->u2_frm_wd_in_mbs; |
724 | 3.10k | UWORD16 u2_image_ht_mb = ps_dec->u2_frm_ht_in_mbs; |
725 | 3.10k | UWORD8 u1_mbaff = ps_dec->ps_cur_slice->u1_mbaff_frame_flag; |
726 | 3.10k | WORD8 i1_cb_qp_idx_ofst = ps_dec->ps_cur_pps->i1_chroma_qp_index_offset; |
727 | 3.10k | WORD8 i1_cr_qp_idx_ofst = |
728 | 3.10k | ps_dec->ps_cur_pps->i1_second_chroma_qp_index_offset; |
729 | | |
730 | | /* Set up Parameter for DMA transfer */ |
731 | 3.10k | ih264d_init_deblk_tfr_ctxt(ps_dec, ps_pad_mgr, ps_tfr_cxt, u2_image_wd_mb, |
732 | 3.10k | u1_mbaff); |
733 | | |
734 | | /* Pic level Initialisations */ |
735 | 3.10k | i2_mb_y = u2_image_ht_mb; |
736 | 3.10k | i2_mb_x = 0; |
737 | 3.10k | u1_extra_top_edge = 0; |
738 | | |
739 | 3.10k | u1_first_row = 1; |
740 | | |
741 | 3.10k | i4_wd_y = ps_dec->u2_frm_wd_y << u1_field_pic_flag; |
742 | 3.10k | i4_wd_uv = ps_dec->u2_frm_wd_uv << u1_field_pic_flag; |
743 | | /* Initial filling of the buffers with deblocking data */ |
744 | | |
745 | 3.10k | pu1_deb_y = ps_tfr_cxt->pu1_mb_y; |
746 | 3.10k | pu1_deb_u = ps_tfr_cxt->pu1_mb_u; |
747 | 3.10k | pu1_deb_v = ps_tfr_cxt->pu1_mb_v; |
748 | 3.10k | ps_cur_mb = ps_dec->ps_deblk_pic; |
749 | | |
750 | 3.10k | if(ps_dec->u4_app_disable_deblk_frm == 0) |
751 | 3.10k | { |
752 | 3.10k | { |
753 | | |
754 | 51.0k | while(i2_mb_y > 0) |
755 | 47.9k | { |
756 | 47.9k | do |
757 | 1.19M | { |
758 | | |
759 | 1.19M | u1_deb_mode = ps_cur_mb->u1_deblocking_mode; |
760 | 1.19M | if(!(u1_deb_mode & MB_DISABLE_FILTERING)) |
761 | 1.17M | { |
762 | 1.17M | ps_tfr_cxt->pu1_mb_y = pu1_deb_y; |
763 | 1.17M | ps_tfr_cxt->pu1_mb_u = pu1_deb_u; |
764 | 1.17M | ps_tfr_cxt->pu1_mb_v = pu1_deb_v; |
765 | | |
766 | 1.17M | u1_cur_fld = (ps_cur_mb->u1_mb_type & D_FLD_MB) >> 7; |
767 | 1.17M | u1_cur_fld &= 1; |
768 | 1.17M | if(i2_mb_x) |
769 | 1.12M | { |
770 | 1.12M | ps_left_mb = ps_cur_mb - 2; |
771 | 1.12M | } |
772 | 46.8k | else |
773 | 46.8k | { |
774 | 46.8k | ps_left_mb = NULL; |
775 | 46.8k | } |
776 | 1.17M | if(!u1_first_row) |
777 | 1.08M | { |
778 | 1.08M | ps_top_mb = ps_cur_mb - (u2_image_wd_mb << 1) + 1; |
779 | 1.08M | u1_top_fld = (ps_top_mb->u1_mb_type & D_FLD_MB) |
780 | 1.08M | >> 7; |
781 | 1.08M | } |
782 | 87.0k | else |
783 | 87.0k | { |
784 | 87.0k | ps_top_mb = NULL; |
785 | 87.0k | u1_top_fld = 0; |
786 | 87.0k | } |
787 | | |
788 | 1.17M | if((!u1_first_row) & u1_top_fld & u1_cur_fld) |
789 | 25.7k | ps_top_mb--; |
790 | | |
791 | | /********************************************************/ |
792 | | /* if top MB and MB AFF and cur MB is frame and top is */ |
793 | | /* field, then one extra top edge needs to be deblocked */ |
794 | | /********************************************************/ |
795 | 1.17M | u1_extra_top_edge = (!u1_cur_fld) & u1_top_fld; |
796 | | |
797 | 1.17M | if(u1_deb_mode & MB_DISABLE_LEFT_EDGE) |
798 | 1.17k | ps_left_mb = NULL; |
799 | 1.17M | if(u1_deb_mode & MB_DISABLE_TOP_EDGE) |
800 | 20.4k | ps_top_mb = NULL; |
801 | | |
802 | 1.17M | ih264d_deblock_mb_mbaff(ps_dec, ps_tfr_cxt, |
803 | 1.17M | i1_cb_qp_idx_ofst, |
804 | 1.17M | i1_cr_qp_idx_ofst, ps_cur_mb, |
805 | 1.17M | i4_wd_y, i4_wd_uv, ps_top_mb, |
806 | 1.17M | ps_left_mb, u1_cur_fld, |
807 | 1.17M | u1_extra_top_edge); |
808 | 1.17M | } |
809 | | |
810 | 1.19M | ps_cur_mb++; |
811 | | |
812 | 1.19M | u1_deb_mode = ps_cur_mb->u1_deblocking_mode; |
813 | 1.19M | if(!(u1_deb_mode & MB_DISABLE_FILTERING)) |
814 | 1.17M | { |
815 | 1.17M | ps_tfr_cxt->pu1_mb_y = pu1_deb_y; |
816 | 1.17M | ps_tfr_cxt->pu1_mb_u = pu1_deb_u; |
817 | 1.17M | ps_tfr_cxt->pu1_mb_v = pu1_deb_v; |
818 | | |
819 | 1.17M | u1_cur_fld = (ps_cur_mb->u1_mb_type & D_FLD_MB) >> 7; |
820 | 1.17M | u1_cur_fld &= 1; |
821 | 1.17M | if(i2_mb_x) |
822 | 1.12M | { |
823 | 1.12M | ps_left_mb = ps_cur_mb - 2; |
824 | 1.12M | u1_left_fld = (ps_left_mb->u1_mb_type & D_FLD_MB) |
825 | 1.12M | >> 7; |
826 | 1.12M | } |
827 | 46.8k | else |
828 | 46.8k | { |
829 | 46.8k | ps_left_mb = NULL; |
830 | 46.8k | u1_left_fld = u1_cur_fld; |
831 | 46.8k | } |
832 | 1.17M | if(!u1_first_row) |
833 | 1.08M | { |
834 | 1.08M | ps_top_mb = ps_cur_mb - (u2_image_wd_mb << 1); |
835 | 1.08M | } |
836 | 87.0k | else |
837 | 87.0k | { |
838 | 87.0k | ps_top_mb = NULL; |
839 | 87.0k | } |
840 | | |
841 | 1.17M | { |
842 | 1.17M | UWORD8 u1_row_shift_y = 0, u1_row_shift_uv = 0; |
843 | 1.17M | if(!u1_cur_fld) |
844 | 1.12M | { |
845 | 1.12M | ps_top_mb = ps_cur_mb - 1; |
846 | 1.12M | u1_top_fld = (ps_top_mb->u1_mb_type & D_FLD_MB) |
847 | 1.12M | >> 7; |
848 | 1.12M | u1_row_shift_y = 4; |
849 | 1.12M | u1_row_shift_uv = 3; |
850 | 1.12M | } |
851 | 1.17M | ps_tfr_cxt->pu1_mb_y += i4_wd_y << u1_row_shift_y; |
852 | 1.17M | ps_tfr_cxt->pu1_mb_u += |
853 | 1.17M | (i4_wd_uv << u1_row_shift_uv); |
854 | 1.17M | ps_tfr_cxt->pu1_mb_v += i4_wd_uv << u1_row_shift_uv; |
855 | 1.17M | } |
856 | | |
857 | | /* point to A if top else A+1 */ |
858 | 1.17M | if(u1_left_fld ^ u1_cur_fld) |
859 | 31.0k | ps_left_mb--; |
860 | | |
861 | | /********************************************************/ |
862 | | /* if top MB and MB AFF and cur MB is frame and top is */ |
863 | | /* field, then one extra top edge needs to be deblocked */ |
864 | | /********************************************************/ |
865 | 1.17M | u1_extra_top_edge = 0; |
866 | | |
867 | 1.17M | if(u1_deb_mode & MB_DISABLE_LEFT_EDGE) |
868 | 1.17k | ps_left_mb = NULL; |
869 | 1.17M | if(u1_deb_mode & MB_DISABLE_TOP_EDGE) |
870 | 4.57k | ps_top_mb = NULL; |
871 | | |
872 | 1.17M | ih264d_deblock_mb_mbaff(ps_dec, ps_tfr_cxt, |
873 | 1.17M | i1_cb_qp_idx_ofst, |
874 | 1.17M | i1_cr_qp_idx_ofst, ps_cur_mb, |
875 | 1.17M | i4_wd_y, i4_wd_uv, ps_top_mb, |
876 | 1.17M | ps_left_mb, u1_cur_fld, |
877 | 1.17M | u1_extra_top_edge); |
878 | 1.17M | } |
879 | | |
880 | 1.19M | ps_cur_mb++; |
881 | 1.19M | i2_mb_x++; |
882 | | |
883 | 1.19M | pu1_deb_y += 16; |
884 | 1.19M | pu1_deb_u += 8 * YUV420SP_FACTOR; |
885 | 1.19M | pu1_deb_v += 8; |
886 | | |
887 | 1.19M | } |
888 | 1.19M | while(u2_image_wd_mb > i2_mb_x); |
889 | | |
890 | 47.9k | pu1_deb_y += ps_tfr_cxt->u4_y_inc; |
891 | 47.9k | pu1_deb_u += ps_tfr_cxt->u4_uv_inc; |
892 | 47.9k | pu1_deb_v += ps_tfr_cxt->u4_uv_inc; |
893 | | |
894 | 47.9k | i2_mb_x = 0; |
895 | 47.9k | i2_mb_y -= 2; |
896 | | |
897 | 47.9k | u1_first_row = 0; |
898 | | |
899 | 47.9k | } |
900 | 3.10k | } |
901 | | |
902 | 3.10k | } |
903 | | //Padd the Picture |
904 | | //Horizontal Padd |
905 | | |
906 | 3.10k | if(ps_pad_mgr->u1_horz_pad) |
907 | 2.26k | { |
908 | 2.26k | UWORD32 u1_field_pic_flag = ps_dec->ps_cur_slice->u1_field_pic_flag; |
909 | 2.26k | ps_dec->pf_pad_left_luma(ps_tfr_cxt->pu1_src_y + 4, |
910 | 2.26k | ps_dec->u2_frm_wd_y << u1_field_pic_flag, |
911 | 2.26k | ps_dec->u2_pic_ht >> u1_field_pic_flag, |
912 | 2.26k | PAD_LEN_Y_H); |
913 | 2.26k | ps_dec->pf_pad_right_luma( |
914 | 2.26k | ps_tfr_cxt->pu1_src_y + 4 |
915 | 2.26k | + (ps_dec->u2_frm_wd_in_mbs << 4), |
916 | 2.26k | ps_dec->u2_frm_wd_y << u1_field_pic_flag, |
917 | 2.26k | ps_dec->u2_pic_ht >> u1_field_pic_flag, PAD_LEN_Y_H); |
918 | | |
919 | 2.26k | ps_dec->pf_pad_left_chroma(ps_tfr_cxt->pu1_src_u + 4, |
920 | 2.26k | ps_dec->u2_frm_wd_uv << u1_field_pic_flag, |
921 | 2.26k | (ps_dec->u2_pic_ht / 2) >> u1_field_pic_flag, |
922 | 2.26k | PAD_LEN_UV_H * YUV420SP_FACTOR); |
923 | 2.26k | ps_dec->pf_pad_right_chroma( |
924 | 2.26k | ps_tfr_cxt->pu1_src_u + 4 |
925 | 2.26k | + (ps_dec->u2_frm_wd_in_mbs << 4), |
926 | 2.26k | ps_dec->u2_frm_wd_uv << u1_field_pic_flag, |
927 | 2.26k | (ps_dec->u2_pic_ht / 2) >> u1_field_pic_flag, |
928 | 2.26k | PAD_LEN_UV_H * YUV420SP_FACTOR); |
929 | | |
930 | 2.26k | } |
931 | | |
932 | | //Vertical Padd Top |
933 | 3.10k | if(ps_pad_mgr->u1_vert_pad_top) |
934 | 2.26k | { |
935 | 2.26k | ps_dec->pf_pad_top(ps_dec->ps_cur_pic->pu1_buf1 - PAD_LEN_Y_H, |
936 | 2.26k | ps_dec->u2_frm_wd_y, ps_dec->u2_frm_wd_y, |
937 | 2.26k | ps_pad_mgr->u1_pad_len_y_v); |
938 | 2.26k | ps_dec->pf_pad_top( |
939 | 2.26k | ps_dec->ps_cur_pic->pu1_buf2 |
940 | 2.26k | - PAD_LEN_UV_H * YUV420SP_FACTOR, |
941 | 2.26k | ps_dec->u2_frm_wd_uv, ps_dec->u2_frm_wd_uv, |
942 | 2.26k | ps_pad_mgr->u1_pad_len_cr_v); |
943 | 2.26k | ps_pad_mgr->u1_vert_pad_top = 0; |
944 | 2.26k | } |
945 | | |
946 | | //Vertical Padd Bottom |
947 | 3.10k | if(ps_pad_mgr->u1_vert_pad_bot) |
948 | 2.26k | { |
949 | | |
950 | 2.26k | UWORD8 *pu1_buf; |
951 | 2.26k | pu1_buf = ps_dec->ps_cur_pic->pu1_buf1 - PAD_LEN_Y_H; |
952 | 2.26k | pu1_buf += ps_dec->u2_pic_ht * ps_dec->u2_frm_wd_y; |
953 | 2.26k | ps_dec->pf_pad_bottom(pu1_buf, ps_dec->u2_frm_wd_y, ps_dec->u2_frm_wd_y, |
954 | 2.26k | ps_pad_mgr->u1_pad_len_y_v); |
955 | 2.26k | pu1_buf = ps_dec->ps_cur_pic->pu1_buf2 - PAD_LEN_UV_H * YUV420SP_FACTOR; |
956 | 2.26k | pu1_buf += (ps_dec->u2_pic_ht >> 1) * ps_dec->u2_frm_wd_uv; |
957 | | |
958 | 2.26k | ps_dec->pf_pad_bottom(pu1_buf, ps_dec->u2_frm_wd_uv, |
959 | 2.26k | ps_dec->u2_frm_wd_uv, |
960 | 2.26k | ps_pad_mgr->u1_pad_len_cr_v); |
961 | | |
962 | 2.26k | } |
963 | 3.10k | } |
964 | | |
965 | | /*****************************************************************************/ |
966 | | /* */ |
967 | | /* Function Name : ih264d_deblock_picture_non_mbaff */ |
968 | | /* */ |
969 | | /* Description : This function carries out deblocking on a whole picture */ |
970 | | /* without MBAFF */ |
971 | | /* */ |
972 | | /* Inputs : <What inputs does the function take?> */ |
973 | | /* Processing : This functions calls deblock MB in the MB increment order*/ |
974 | | /* */ |
975 | | /* Outputs : Produces the deblocked picture */ |
976 | | /* Returns : None */ |
977 | | /* */ |
978 | | /* Revision History: */ |
979 | | /* */ |
980 | | /* DD MM YYYY Author(s) Changes (Describe the changes made) */ |
981 | | /* 17 02 2005 NS Creation */ |
982 | | /* 14 06 2005 SWRN clean-up */ |
983 | | /*****************************************************************************/ |
984 | | |
985 | | void ih264d_deblock_picture_non_mbaff(dec_struct_t * ps_dec) |
986 | 4.04k | { |
987 | 4.04k | deblk_mb_t *ps_cur_mb; |
988 | | |
989 | 4.04k | UWORD8 u1_vert_pad_top = 1; |
990 | | |
991 | 4.04k | UWORD8 u1_deb_mode; |
992 | 4.04k | WORD32 i4_wd_y, i4_wd_uv; |
993 | | |
994 | 4.04k | UWORD8 u1_field_pic_flag = ps_dec->ps_cur_slice->u1_field_pic_flag; /*< Field u4_flag */ |
995 | 4.04k | UWORD8 u1_bottom_field_flag = ps_dec->ps_cur_slice->u1_bottom_field_flag; /*< Bottom field u4_flag */ |
996 | | |
997 | | /**************************************************/ |
998 | | /* one time loads from ps_dec which will be used */ |
999 | | /* frequently throughout the deblocking procedure */ |
1000 | | /**************************************************/ |
1001 | 4.04k | pad_mgr_t * ps_pad_mgr = &ps_dec->s_pad_mgr; |
1002 | 4.04k | tfr_ctxt_t s_tfr_ctxt; |
1003 | 4.04k | tfr_ctxt_t * ps_tfr_cxt = &s_tfr_ctxt; // = &ps_dec->s_tran_addrecon; |
1004 | | |
1005 | 4.04k | UWORD16 u2_image_wd_mb = ps_dec->u2_frm_wd_in_mbs; |
1006 | 4.04k | UWORD16 u2_image_ht_mb = ps_dec->u2_frm_ht_in_mbs; |
1007 | 4.04k | WORD8 i1_cb_qp_idx_ofst = ps_dec->ps_cur_pps->i1_chroma_qp_index_offset; |
1008 | 4.04k | WORD8 i1_cr_qp_idx_ofst = |
1009 | 4.04k | ps_dec->ps_cur_pps->i1_second_chroma_qp_index_offset; |
1010 | | |
1011 | | /* Set up Parameter for DMA transfer */ |
1012 | 4.04k | ih264d_init_deblk_tfr_ctxt(ps_dec, ps_pad_mgr, ps_tfr_cxt, u2_image_wd_mb, |
1013 | 4.04k | 0); |
1014 | | |
1015 | | /* Pic level Initialisations */ |
1016 | | |
1017 | | |
1018 | | |
1019 | 4.04k | i4_wd_y = ps_dec->u2_frm_wd_y << u1_field_pic_flag; |
1020 | 4.04k | i4_wd_uv = ps_dec->u2_frm_wd_uv << u1_field_pic_flag; |
1021 | | /* Initial filling of the buffers with deblocking data */ |
1022 | | |
1023 | 4.04k | ps_cur_mb = ps_dec->ps_deblk_pic; |
1024 | | |
1025 | 4.04k | if(ps_dec->u4_app_disable_deblk_frm == 0) |
1026 | 4.04k | { |
1027 | 4.04k | if(ps_dec->ps_cur_sps->u1_mb_aff_flag == 1) |
1028 | 2.74k | { |
1029 | 742k | while( ps_dec->u4_deblk_mb_y < u2_image_ht_mb) |
1030 | 739k | { |
1031 | 739k | ih264d_deblock_mb_nonmbaff(ps_dec, ps_tfr_cxt, |
1032 | 739k | i1_cb_qp_idx_ofst, |
1033 | 739k | i1_cr_qp_idx_ofst, |
1034 | 739k | i4_wd_y, i4_wd_uv); |
1035 | 739k | ps_cur_mb++; |
1036 | 739k | } |
1037 | 2.74k | } |
1038 | | |
1039 | 4.04k | } |
1040 | | |
1041 | | //Padd the Picture |
1042 | | //Horizontal Padd |
1043 | 4.04k | if(ps_pad_mgr->u1_horz_pad) |
1044 | 2.96k | { |
1045 | 2.96k | UWORD32 u1_field_pic_flag = ps_dec->ps_cur_slice->u1_field_pic_flag; |
1046 | 2.96k | ps_dec->pf_pad_left_luma(ps_tfr_cxt->pu1_src_y + 4, |
1047 | 2.96k | ps_dec->u2_frm_wd_y << u1_field_pic_flag, |
1048 | 2.96k | ps_dec->u2_pic_ht >> u1_field_pic_flag, |
1049 | 2.96k | PAD_LEN_Y_H); |
1050 | 2.96k | ps_dec->pf_pad_right_luma( |
1051 | 2.96k | ps_tfr_cxt->pu1_src_y + 4 |
1052 | 2.96k | + (ps_dec->u2_frm_wd_in_mbs << 4), |
1053 | 2.96k | ps_dec->u2_frm_wd_y << u1_field_pic_flag, |
1054 | 2.96k | ps_dec->u2_pic_ht >> u1_field_pic_flag, PAD_LEN_Y_H); |
1055 | | |
1056 | 2.96k | ps_dec->pf_pad_left_chroma(ps_tfr_cxt->pu1_src_u + 4, |
1057 | 2.96k | ps_dec->u2_frm_wd_uv << u1_field_pic_flag, |
1058 | 2.96k | (ps_dec->u2_pic_ht / 2) >> u1_field_pic_flag, |
1059 | 2.96k | PAD_LEN_UV_H * YUV420SP_FACTOR); |
1060 | 2.96k | ps_dec->pf_pad_right_chroma( |
1061 | 2.96k | ps_tfr_cxt->pu1_src_u + 4 |
1062 | 2.96k | + (ps_dec->u2_frm_wd_in_mbs << 4), |
1063 | 2.96k | ps_dec->u2_frm_wd_uv << u1_field_pic_flag, |
1064 | 2.96k | (ps_dec->u2_pic_ht / 2) >> u1_field_pic_flag, |
1065 | 2.96k | PAD_LEN_UV_H * YUV420SP_FACTOR); |
1066 | | |
1067 | 2.96k | } |
1068 | | |
1069 | | //Vertical Padd Top |
1070 | 4.04k | if(ps_pad_mgr->u1_vert_pad_top) |
1071 | 1.42k | { |
1072 | 1.42k | ps_dec->pf_pad_top(ps_dec->ps_cur_pic->pu1_buf1 - PAD_LEN_Y_H, |
1073 | 1.42k | ps_dec->u2_frm_wd_y, ps_dec->u2_frm_wd_y, |
1074 | 1.42k | ps_pad_mgr->u1_pad_len_y_v); |
1075 | 1.42k | ps_dec->pf_pad_top( |
1076 | 1.42k | ps_dec->ps_cur_pic->pu1_buf2 |
1077 | 1.42k | - PAD_LEN_UV_H * YUV420SP_FACTOR, |
1078 | 1.42k | ps_dec->u2_frm_wd_uv, ps_dec->u2_frm_wd_uv, |
1079 | 1.42k | ps_pad_mgr->u1_pad_len_cr_v); |
1080 | 1.42k | ps_pad_mgr->u1_vert_pad_top = 0; |
1081 | 1.42k | } |
1082 | | |
1083 | | //Vertical Padd Bottom |
1084 | 4.04k | if(ps_pad_mgr->u1_vert_pad_bot) |
1085 | 1.54k | { |
1086 | | |
1087 | 1.54k | UWORD8 *pu1_buf; |
1088 | 1.54k | pu1_buf = ps_dec->ps_cur_pic->pu1_buf1 - PAD_LEN_Y_H; |
1089 | 1.54k | pu1_buf += ps_dec->u2_pic_ht * ps_dec->u2_frm_wd_y; |
1090 | 1.54k | ps_dec->pf_pad_bottom(pu1_buf, ps_dec->u2_frm_wd_y, ps_dec->u2_frm_wd_y, |
1091 | 1.54k | ps_pad_mgr->u1_pad_len_y_v); |
1092 | 1.54k | pu1_buf = ps_dec->ps_cur_pic->pu1_buf2 - PAD_LEN_UV_H * YUV420SP_FACTOR; |
1093 | 1.54k | pu1_buf += (ps_dec->u2_pic_ht >> 1) * ps_dec->u2_frm_wd_uv; |
1094 | | |
1095 | 1.54k | ps_dec->pf_pad_bottom(pu1_buf, ps_dec->u2_frm_wd_uv, |
1096 | 1.54k | ps_dec->u2_frm_wd_uv, |
1097 | 1.54k | ps_pad_mgr->u1_pad_len_cr_v); |
1098 | | |
1099 | 1.54k | } |
1100 | 4.04k | } |
1101 | | |
1102 | | void ih264d_deblock_picture_progressive(dec_struct_t * ps_dec) |
1103 | 5.18k | { |
1104 | 5.18k | deblk_mb_t *ps_cur_mb; |
1105 | | |
1106 | 5.18k | UWORD8 u1_vert_pad_top = 1; |
1107 | 5.18k | UWORD8 u1_mbs_next; |
1108 | 5.18k | UWORD8 u1_deb_mode; |
1109 | 5.18k | WORD32 i4_wd_y, i4_wd_uv; |
1110 | | |
1111 | | |
1112 | | /**************************************************/ |
1113 | | /* one time loads from ps_dec which will be used */ |
1114 | | /* frequently throughout the deblocking procedure */ |
1115 | | /**************************************************/ |
1116 | 5.18k | pad_mgr_t * ps_pad_mgr = &ps_dec->s_pad_mgr; |
1117 | | |
1118 | 5.18k | tfr_ctxt_t s_tfr_ctxt; |
1119 | 5.18k | tfr_ctxt_t * ps_tfr_cxt = &s_tfr_ctxt; // = &ps_dec->s_tran_addrecon; |
1120 | 5.18k | UWORD16 u2_image_wd_mb = ps_dec->u2_frm_wd_in_mbs; |
1121 | 5.18k | UWORD16 u2_image_ht_mb = ps_dec->u2_frm_ht_in_mbs; |
1122 | 5.18k | UWORD8 u1_mbaff = ps_dec->ps_cur_slice->u1_mbaff_frame_flag; |
1123 | | |
1124 | 5.18k | WORD8 i1_cb_qp_idx_ofst = ps_dec->ps_cur_pps->i1_chroma_qp_index_offset; |
1125 | 5.18k | WORD8 i1_cr_qp_idx_ofst = |
1126 | 5.18k | ps_dec->ps_cur_pps->i1_second_chroma_qp_index_offset; |
1127 | | |
1128 | | /* Set up Parameter for deblocking */ |
1129 | 5.18k | ih264d_init_deblk_tfr_ctxt(ps_dec, ps_pad_mgr, ps_tfr_cxt, u2_image_wd_mb, |
1130 | 5.18k | 0); |
1131 | | |
1132 | | /* Pic level Initialisations */ |
1133 | | |
1134 | 5.18k | i4_wd_y = ps_dec->u2_frm_wd_y; |
1135 | 5.18k | i4_wd_uv = ps_dec->u2_frm_wd_uv; |
1136 | | /* Initial filling of the buffers with deblocking data */ |
1137 | 5.18k | ps_cur_mb = ps_dec->ps_deblk_pic; |
1138 | | |
1139 | 5.18k | if(ps_dec->u4_app_disable_deblk_frm == 0) |
1140 | 5.18k | { |
1141 | 5.18k | if(ps_dec->ps_cur_sps->u1_mb_aff_flag == 1) |
1142 | 0 | { |
1143 | 0 | while( ps_dec->u4_deblk_mb_y < u2_image_ht_mb) |
1144 | 0 | { |
1145 | 0 | ih264d_deblock_mb_nonmbaff(ps_dec, ps_tfr_cxt, |
1146 | 0 | i1_cb_qp_idx_ofst, |
1147 | 0 | i1_cr_qp_idx_ofst, |
1148 | 0 | i4_wd_y, i4_wd_uv); |
1149 | 0 | ps_cur_mb++; |
1150 | 0 | } |
1151 | 0 | } |
1152 | | |
1153 | 5.18k | } |
1154 | | |
1155 | | //Padd the Picture |
1156 | | //Horizontal Padd |
1157 | 5.18k | if(ps_pad_mgr->u1_horz_pad) |
1158 | 3.35k | { |
1159 | 3.35k | UWORD32 u1_field_pic_flag = ps_dec->ps_cur_slice->u1_field_pic_flag; |
1160 | 3.35k | ps_dec->pf_pad_left_luma(ps_tfr_cxt->pu1_src_y + 4, |
1161 | 3.35k | ps_dec->u2_frm_wd_y << u1_field_pic_flag, |
1162 | 3.35k | ps_dec->u2_pic_ht >> u1_field_pic_flag, |
1163 | 3.35k | PAD_LEN_Y_H); |
1164 | 3.35k | ps_dec->pf_pad_right_luma( |
1165 | 3.35k | ps_tfr_cxt->pu1_src_y + 4 |
1166 | 3.35k | + (ps_dec->u2_frm_wd_in_mbs << 4), |
1167 | 3.35k | ps_dec->u2_frm_wd_y << u1_field_pic_flag, |
1168 | 3.35k | ps_dec->u2_pic_ht >> u1_field_pic_flag, PAD_LEN_Y_H); |
1169 | | |
1170 | 3.35k | ps_dec->pf_pad_left_chroma(ps_tfr_cxt->pu1_src_u + 4, |
1171 | 3.35k | ps_dec->u2_frm_wd_uv << u1_field_pic_flag, |
1172 | 3.35k | (ps_dec->u2_pic_ht / 2) >> u1_field_pic_flag, |
1173 | 3.35k | PAD_LEN_UV_H * YUV420SP_FACTOR); |
1174 | 3.35k | ps_dec->pf_pad_right_chroma( |
1175 | 3.35k | ps_tfr_cxt->pu1_src_u + 4 |
1176 | 3.35k | + (ps_dec->u2_frm_wd_in_mbs << 4), |
1177 | 3.35k | ps_dec->u2_frm_wd_uv << u1_field_pic_flag, |
1178 | 3.35k | (ps_dec->u2_pic_ht / 2) >> u1_field_pic_flag, |
1179 | 3.35k | PAD_LEN_UV_H * YUV420SP_FACTOR); |
1180 | | |
1181 | 3.35k | } |
1182 | | |
1183 | | //Vertical Padd Top |
1184 | 5.18k | if(ps_pad_mgr->u1_vert_pad_top) |
1185 | 3.35k | { |
1186 | 3.35k | ps_dec->pf_pad_top(ps_dec->ps_cur_pic->pu1_buf1 - PAD_LEN_Y_H, |
1187 | 3.35k | ps_dec->u2_frm_wd_y, ps_dec->u2_frm_wd_y, |
1188 | 3.35k | ps_pad_mgr->u1_pad_len_y_v); |
1189 | 3.35k | ps_dec->pf_pad_top( |
1190 | 3.35k | ps_dec->ps_cur_pic->pu1_buf2 |
1191 | 3.35k | - PAD_LEN_UV_H * YUV420SP_FACTOR, |
1192 | 3.35k | ps_dec->u2_frm_wd_uv, ps_dec->u2_frm_wd_uv, |
1193 | 3.35k | ps_pad_mgr->u1_pad_len_cr_v); |
1194 | | |
1195 | 3.35k | } |
1196 | | |
1197 | | //Vertical Padd Bottom |
1198 | 5.18k | if(ps_pad_mgr->u1_vert_pad_bot) |
1199 | 3.35k | { |
1200 | | |
1201 | 3.35k | UWORD8 *pu1_buf; |
1202 | 3.35k | pu1_buf = ps_dec->ps_cur_pic->pu1_buf1 - PAD_LEN_Y_H; |
1203 | 3.35k | pu1_buf += ps_dec->u2_pic_ht * ps_dec->u2_frm_wd_y; |
1204 | 3.35k | ps_dec->pf_pad_bottom(pu1_buf, ps_dec->u2_frm_wd_y, ps_dec->u2_frm_wd_y, |
1205 | 3.35k | ps_pad_mgr->u1_pad_len_y_v); |
1206 | 3.35k | pu1_buf = ps_dec->ps_cur_pic->pu1_buf2 - PAD_LEN_UV_H * YUV420SP_FACTOR; |
1207 | 3.35k | pu1_buf += (ps_dec->u2_pic_ht >> 1) * ps_dec->u2_frm_wd_uv; |
1208 | | |
1209 | 3.35k | ps_dec->pf_pad_bottom(pu1_buf, ps_dec->u2_frm_wd_uv, |
1210 | 3.35k | ps_dec->u2_frm_wd_uv, |
1211 | 3.35k | ps_pad_mgr->u1_pad_len_cr_v); |
1212 | | |
1213 | 3.35k | } |
1214 | 5.18k | } |
1215 | | |
1216 | | /*! |
1217 | | ************************************************************************** |
1218 | | * \if Function name : ih264d_set_deblocking_parameters \endif |
1219 | | * |
1220 | | * \brief |
1221 | | * Sets the deblocking parameters of the macroblock |
1222 | | * |
1223 | | * \return |
1224 | | * 0 on Success and Error code otherwise |
1225 | | * |
1226 | | * \note |
1227 | | * Given the neighbour availablity information, and the deblocking |
1228 | | * parameters of the slice,this function will set the deblocking |
1229 | | * mode of the macroblock. |
1230 | | ************************************************************************** |
1231 | | */ |
1232 | | |
1233 | | WORD8 ih264d_set_deblocking_parameters(deblk_mb_t * ps_cur_mb, |
1234 | | dec_slice_params_t * ps_slice, |
1235 | | UWORD8 u1_mb_ngbr_availablity, |
1236 | | UWORD8 u1_mb_field_decoding_flag) |
1237 | 14.6M | { |
1238 | | /*------------------------------------------------------------------*/ |
1239 | | /* Set the deblocking parameters */ |
1240 | | /*------------------------------------------------------------------*/ |
1241 | 14.6M | ps_cur_mb->i1_slice_alpha_c0_offset = ps_slice->i1_slice_alpha_c0_offset; |
1242 | 14.6M | ps_cur_mb->i1_slice_beta_offset = ps_slice->i1_slice_beta_offset; |
1243 | 14.6M | ps_cur_mb->u1_mb_type = (u1_mb_field_decoding_flag << 7); |
1244 | | |
1245 | 14.6M | switch(ps_slice->u1_disable_dblk_filter_idc) |
1246 | 14.6M | { |
1247 | 14.2M | case DBLK_ENABLED: |
1248 | 14.2M | ps_cur_mb->u1_deblocking_mode = MB_ENABLE_FILTERING; |
1249 | 14.2M | break; |
1250 | 142k | case DBLK_DISABLED: |
1251 | 142k | ps_cur_mb->u1_deblocking_mode = MB_DISABLE_FILTERING; |
1252 | 142k | break; |
1253 | 235k | case SLICE_BOUNDARY_DBLK_DISABLED: |
1254 | 235k | { |
1255 | 235k | ps_cur_mb->u1_deblocking_mode = MB_ENABLE_FILTERING; |
1256 | 235k | if(!(u1_mb_ngbr_availablity & LEFT_MB_AVAILABLE_MASK)) |
1257 | 6.96k | ps_cur_mb->u1_deblocking_mode |= MB_DISABLE_LEFT_EDGE; |
1258 | 235k | if(!(u1_mb_ngbr_availablity & TOP_MB_AVAILABLE_MASK)) |
1259 | 46.8k | ps_cur_mb->u1_deblocking_mode |= MB_DISABLE_TOP_EDGE; |
1260 | 235k | break; |
1261 | 0 | } |
1262 | 14.6M | } |
1263 | | |
1264 | 14.6M | return (0); |
1265 | 14.6M | } |
1266 | | |
1267 | | void ih264d_copy_intra_pred_line(dec_struct_t *ps_dec, |
1268 | | dec_mb_info_t *ps_cur_mb_info, |
1269 | | UWORD32 nmb_index) |
1270 | 11.5M | { |
1271 | 11.5M | UWORD8 *pu1_mb_last_row, u1_mb_field_decoding_flag; |
1272 | 11.5M | UWORD32 u4_recWidth, u4_recwidth_cr; |
1273 | | |
1274 | 11.5M | u1_mb_field_decoding_flag = ps_cur_mb_info->u1_mb_field_decodingflag; |
1275 | | |
1276 | 11.5M | u4_recWidth = ps_dec->u2_frm_wd_y << u1_mb_field_decoding_flag; |
1277 | 11.5M | u4_recwidth_cr = ps_dec->u2_frm_wd_uv << u1_mb_field_decoding_flag; |
1278 | | |
1279 | 11.5M | pu1_mb_last_row = ps_dec->ps_frame_buf_ip_recon->pu1_dest_y |
1280 | 11.5M | + (u4_recWidth * (MB_SIZE - 1)); |
1281 | 11.5M | pu1_mb_last_row += MB_SIZE * nmb_index; |
1282 | 11.5M | MEMCPY_16BYTES(ps_dec->pu1_cur_y_intra_pred_line, pu1_mb_last_row); |
1283 | | |
1284 | 11.5M | pu1_mb_last_row = ps_dec->ps_frame_buf_ip_recon->pu1_dest_u |
1285 | 11.5M | + (u4_recwidth_cr * (BLK8x8SIZE - 1)); |
1286 | 11.5M | pu1_mb_last_row += BLK8x8SIZE * nmb_index * YUV420SP_FACTOR; |
1287 | | |
1288 | 11.5M | MEMCPY_16BYTES(ps_dec->pu1_cur_u_intra_pred_line, pu1_mb_last_row); |
1289 | | |
1290 | 11.5M | ps_dec->pu1_cur_y_intra_pred_line = ps_dec->pu1_cur_y_intra_pred_line_base |
1291 | 11.5M | + (MB_SIZE * (ps_cur_mb_info->u2_mbx + 1)); |
1292 | 11.5M | ps_dec->pu1_cur_u_intra_pred_line = ps_dec->pu1_cur_u_intra_pred_line_base |
1293 | 11.5M | + (BLK8x8SIZE * (ps_cur_mb_info->u2_mbx + 1)) |
1294 | 11.5M | * YUV420SP_FACTOR; |
1295 | 11.5M | ps_dec->pu1_cur_v_intra_pred_line = ps_dec->pu1_cur_v_intra_pred_line_base |
1296 | 11.5M | + (BLK8x8SIZE * (ps_cur_mb_info->u2_mbx + 1)); |
1297 | | |
1298 | 11.5M | if(ps_cur_mb_info->u2_mbx == (ps_dec->u2_frm_wd_in_mbs - 1)) |
1299 | 188k | { |
1300 | 188k | UWORD8* pu1_temp; |
1301 | | |
1302 | 188k | ps_dec->pu1_cur_y_intra_pred_line = |
1303 | 188k | ps_dec->pu1_cur_y_intra_pred_line_base; |
1304 | 188k | ps_dec->pu1_cur_u_intra_pred_line = |
1305 | 188k | ps_dec->pu1_cur_u_intra_pred_line_base; |
1306 | 188k | ps_dec->pu1_cur_v_intra_pred_line = |
1307 | 188k | ps_dec->pu1_cur_v_intra_pred_line_base; |
1308 | | |
1309 | | /*swap current and previous rows*/ |
1310 | 188k | pu1_temp = ps_dec->pu1_cur_y_intra_pred_line; |
1311 | 188k | ps_dec->pu1_cur_y_intra_pred_line = ps_dec->pu1_prev_y_intra_pred_line; |
1312 | 188k | ps_dec->pu1_prev_y_intra_pred_line = pu1_temp; |
1313 | | |
1314 | 188k | pu1_temp = ps_dec->pu1_cur_u_intra_pred_line; |
1315 | 188k | ps_dec->pu1_cur_u_intra_pred_line = ps_dec->pu1_prev_u_intra_pred_line; |
1316 | 188k | ps_dec->pu1_prev_u_intra_pred_line = pu1_temp; |
1317 | | |
1318 | 188k | pu1_temp = ps_dec->pu1_cur_v_intra_pred_line; |
1319 | 188k | ps_dec->pu1_cur_v_intra_pred_line = ps_dec->pu1_prev_v_intra_pred_line; |
1320 | 188k | ps_dec->pu1_prev_v_intra_pred_line = pu1_temp; |
1321 | | |
1322 | 188k | ps_dec->pu1_cur_y_intra_pred_line_base = |
1323 | 188k | ps_dec->pu1_cur_y_intra_pred_line; |
1324 | 188k | ps_dec->pu1_cur_u_intra_pred_line_base = |
1325 | 188k | ps_dec->pu1_cur_u_intra_pred_line; |
1326 | 188k | ps_dec->pu1_cur_v_intra_pred_line_base = |
1327 | 188k | ps_dec->pu1_cur_v_intra_pred_line; |
1328 | | |
1329 | | |
1330 | | |
1331 | | |
1332 | | |
1333 | 188k | } |
1334 | | |
1335 | 11.5M | } |
1336 | | |
1337 | | |
1338 | | void ih264d_filter_boundary_left_mbaff(dec_struct_t *ps_dec, |
1339 | | tfr_ctxt_t * ps_tfr_cxt, |
1340 | | WORD8 i1_cb_qp_idx_ofst, |
1341 | | WORD8 i1_cr_qp_idx_ofst, |
1342 | | deblk_mb_t * ps_cur_mb, |
1343 | | WORD32 i4_strd_y, |
1344 | | WORD32 i4_strd_uv, |
1345 | | deblk_mb_t * ps_left_mb, /* Neighbouring MB parameters */ |
1346 | | UWORD32 pu4_bs_tab[], /* pointer to the BsTable array */ |
1347 | | UWORD8 u1_cur_fld) |
1348 | 2.25M | { |
1349 | 2.25M | UWORD8 *pu1_y, *pu1_u, *pu1_v; |
1350 | 2.25M | UWORD8 uc_tmp, qp_avg; |
1351 | 2.25M | WORD32 alpha_u = 0, beta_u = 0, alpha_v = 0, beta_v = 0; |
1352 | 2.25M | WORD32 alpha_y = 0, beta_y = 0; |
1353 | | |
1354 | 2.25M | WORD32 idx_b_u, idx_a_u, idx_b_v, idx_a_v; |
1355 | 2.25M | WORD32 idx_b_y, idx_a_y; |
1356 | | |
1357 | 2.25M | UWORD32 u4_bs_val; |
1358 | | |
1359 | 2.25M | UWORD8 *pu1_cliptab_u, *pu1_cliptab_v, *pu1_cliptab_y; |
1360 | | |
1361 | 2.25M | UWORD8 u1_double_cl = !ps_cur_mb->u1_single_call; |
1362 | 2.25M | WORD32 ofst_a = ps_cur_mb->i1_slice_alpha_c0_offset; |
1363 | 2.25M | WORD32 ofst_b = ps_cur_mb->i1_slice_beta_offset; |
1364 | | |
1365 | 2.25M | PROFILE_DISABLE_DEBLK() |
1366 | | |
1367 | 2.25M | pu1_y = ps_tfr_cxt->pu1_mb_y; |
1368 | 2.25M | pu1_u = ps_tfr_cxt->pu1_mb_u; |
1369 | 2.25M | pu1_v = ps_tfr_cxt->pu1_mb_v; |
1370 | | |
1371 | | /* LUMA values */ |
1372 | | /* Deblock rounding change */ |
1373 | 2.25M | uc_tmp = (UWORD8)((ps_left_mb->u1_mb_qp + ps_cur_mb->u1_mb_qp + 1) >> 1); |
1374 | 2.25M | qp_avg = uc_tmp; |
1375 | 2.25M | idx_a_y = qp_avg + ofst_a; |
1376 | 2.25M | alpha_y = gau1_ih264d_alpha_table[12 + idx_a_y]; |
1377 | 2.25M | idx_b_y = qp_avg + ofst_b; |
1378 | 2.25M | beta_y = gau1_ih264d_beta_table[12 + idx_b_y]; |
1379 | | |
1380 | | /* Chroma cb values */ |
1381 | 2.25M | { |
1382 | 2.25M | WORD32 mb_qp1, mb_qp2; |
1383 | 2.25M | mb_qp1 = (ps_left_mb->u1_mb_qp + i1_cb_qp_idx_ofst); |
1384 | 2.25M | mb_qp2 = (ps_cur_mb->u1_mb_qp + i1_cb_qp_idx_ofst); |
1385 | 2.25M | qp_avg = (UWORD8)((gau1_ih264d_qp_scale_cr[12 + mb_qp1] |
1386 | 2.25M | + gau1_ih264d_qp_scale_cr[12 + mb_qp2] + 1) >> 1); |
1387 | 2.25M | } |
1388 | 2.25M | idx_a_u = qp_avg + ofst_a; |
1389 | 2.25M | alpha_u = gau1_ih264d_alpha_table[12 + idx_a_u]; |
1390 | 2.25M | idx_b_u = qp_avg + ofst_b; |
1391 | 2.25M | beta_u = gau1_ih264d_beta_table[12 + idx_b_u]; |
1392 | | |
1393 | | /* Chroma cr values */ |
1394 | 2.25M | { |
1395 | 2.25M | WORD32 mb_qp1, mb_qp2; |
1396 | 2.25M | mb_qp1 = (ps_left_mb->u1_mb_qp + i1_cr_qp_idx_ofst); |
1397 | 2.25M | mb_qp2 = (ps_cur_mb->u1_mb_qp + i1_cr_qp_idx_ofst); |
1398 | 2.25M | qp_avg = (UWORD8)((gau1_ih264d_qp_scale_cr[12 + mb_qp1] |
1399 | 2.25M | + gau1_ih264d_qp_scale_cr[12 + mb_qp2] + 1) >> 1); |
1400 | 2.25M | } |
1401 | 2.25M | idx_a_v = qp_avg + ofst_a; |
1402 | 2.25M | alpha_v = gau1_ih264d_alpha_table[12 + idx_a_v]; |
1403 | 2.25M | idx_b_v = qp_avg + ofst_b; |
1404 | 2.25M | beta_v = gau1_ih264d_beta_table[12 + idx_b_v]; |
1405 | | |
1406 | 2.25M | if(u1_double_cl == 0) |
1407 | 2.19M | { |
1408 | 2.19M | u4_bs_val = pu4_bs_tab[4]; |
1409 | | |
1410 | 2.19M | if(0x04040404 == u4_bs_val) |
1411 | 91.0k | { |
1412 | 91.0k | ps_dec->pf_deblk_luma_vert_bs4(pu1_y, i4_strd_y, alpha_y, beta_y); |
1413 | 91.0k | ps_dec->pf_deblk_chroma_vert_bs4(pu1_u, i4_strd_uv, alpha_u, |
1414 | 91.0k | beta_u, alpha_v, beta_v); |
1415 | | |
1416 | 91.0k | } |
1417 | 2.10M | else |
1418 | 2.10M | { |
1419 | 2.10M | if(u4_bs_val) |
1420 | 29.1k | { |
1421 | | |
1422 | 29.1k | pu1_cliptab_y = (UWORD8 *)&gau1_ih264d_clip_table[12 |
1423 | 29.1k | + idx_a_y]; |
1424 | 29.1k | pu1_cliptab_u = (UWORD8 *)&gau1_ih264d_clip_table[12 |
1425 | 29.1k | + idx_a_u]; |
1426 | 29.1k | pu1_cliptab_v = (UWORD8 *)&gau1_ih264d_clip_table[12 |
1427 | 29.1k | + idx_a_v]; |
1428 | | |
1429 | 29.1k | ps_dec->pf_deblk_luma_vert_bslt4(pu1_y, i4_strd_y, alpha_y, |
1430 | 29.1k | beta_y, u4_bs_val, |
1431 | 29.1k | pu1_cliptab_y); |
1432 | 29.1k | ps_dec->pf_deblk_chroma_vert_bslt4(pu1_u, i4_strd_uv, alpha_u, |
1433 | 29.1k | beta_u, alpha_v, beta_v, |
1434 | 29.1k | u4_bs_val, pu1_cliptab_u, |
1435 | 29.1k | pu1_cliptab_v); |
1436 | | |
1437 | 29.1k | } |
1438 | 2.10M | } |
1439 | | |
1440 | 2.19M | } |
1441 | 61.9k | else |
1442 | 61.9k | { |
1443 | | |
1444 | 61.9k | i4_strd_y <<= (!u1_cur_fld); |
1445 | 61.9k | u4_bs_val = pu4_bs_tab[4]; |
1446 | 61.9k | i4_strd_uv <<= (!u1_cur_fld); |
1447 | | |
1448 | 61.9k | if(0x04040404 == u4_bs_val) |
1449 | 43.9k | { |
1450 | 43.9k | ps_dec->pf_deblk_luma_vert_bs4_mbaff(pu1_y, i4_strd_y, alpha_y, |
1451 | 43.9k | beta_y); |
1452 | 43.9k | ps_dec->pf_deblk_chroma_vert_bs4_mbaff(pu1_u, i4_strd_uv, alpha_u, |
1453 | 43.9k | beta_u, alpha_v, beta_v); |
1454 | 43.9k | } |
1455 | 18.0k | else |
1456 | 18.0k | { |
1457 | 18.0k | if(u4_bs_val) |
1458 | 18.0k | { |
1459 | | |
1460 | 18.0k | pu1_cliptab_y = (UWORD8 *)&gau1_ih264d_clip_table[12 + idx_a_y]; |
1461 | 18.0k | pu1_cliptab_u = (UWORD8 *)&gau1_ih264d_clip_table[12 + idx_a_u]; |
1462 | 18.0k | pu1_cliptab_v = (UWORD8 *)&gau1_ih264d_clip_table[12 + idx_a_v]; |
1463 | 18.0k | ps_dec->pf_deblk_luma_vert_bslt4_mbaff(pu1_y, i4_strd_y, |
1464 | 18.0k | alpha_y, beta_y, |
1465 | 18.0k | u4_bs_val, |
1466 | 18.0k | pu1_cliptab_y); |
1467 | 18.0k | ps_dec->pf_deblk_chroma_vert_bslt4_mbaff(pu1_u, i4_strd_uv, |
1468 | 18.0k | alpha_u, beta_u, |
1469 | 18.0k | alpha_v, beta_v, |
1470 | 18.0k | u4_bs_val, |
1471 | 18.0k | pu1_cliptab_u, |
1472 | 18.0k | pu1_cliptab_v); |
1473 | | |
1474 | 18.0k | } |
1475 | 18.0k | } |
1476 | | |
1477 | 61.9k | { |
1478 | | |
1479 | 61.9k | UWORD16 u2_shift = (i4_strd_y >> 1) << (u1_cur_fld ? 4 : 0); |
1480 | 61.9k | pu1_y += u2_shift; |
1481 | 61.9k | u2_shift = (i4_strd_uv >> 1) << (u1_cur_fld ? 3 : 0); |
1482 | 61.9k | pu1_u += u2_shift; |
1483 | 61.9k | pu1_v += u2_shift; |
1484 | 61.9k | } |
1485 | | |
1486 | 61.9k | uc_tmp = (((ps_left_mb + 1)->u1_mb_qp + ps_cur_mb->u1_mb_qp + 1) >> 1); |
1487 | 61.9k | qp_avg = uc_tmp; |
1488 | 61.9k | idx_a_y = qp_avg + ofst_a; |
1489 | 61.9k | alpha_y = gau1_ih264d_alpha_table[12 + idx_a_y]; |
1490 | 61.9k | idx_b_y = qp_avg + ofst_b; |
1491 | 61.9k | beta_y = gau1_ih264d_beta_table[12 + idx_b_y]; |
1492 | 61.9k | u4_bs_val = pu4_bs_tab[9]; |
1493 | | |
1494 | 61.9k | { |
1495 | 61.9k | WORD32 mb_qp1, mb_qp2; |
1496 | 61.9k | mb_qp1 = ((ps_left_mb + 1)->u1_mb_qp + i1_cb_qp_idx_ofst); |
1497 | 61.9k | mb_qp2 = (ps_cur_mb->u1_mb_qp + i1_cb_qp_idx_ofst); |
1498 | 61.9k | qp_avg = (UWORD8)((gau1_ih264d_qp_scale_cr[12 + mb_qp1] |
1499 | 61.9k | + gau1_ih264d_qp_scale_cr[12 + mb_qp2] + 1) >> 1); |
1500 | 61.9k | } |
1501 | 61.9k | idx_a_u = qp_avg + ofst_a; |
1502 | 61.9k | alpha_u = gau1_ih264d_alpha_table[12 + idx_a_u]; |
1503 | 61.9k | idx_b_u = qp_avg + ofst_b; |
1504 | 61.9k | beta_u = gau1_ih264d_beta_table[12 + idx_b_u]; |
1505 | 61.9k | u4_bs_val = pu4_bs_tab[9]; |
1506 | 61.9k | { |
1507 | 61.9k | WORD32 mb_qp1, mb_qp2; |
1508 | 61.9k | mb_qp1 = ((ps_left_mb + 1)->u1_mb_qp + i1_cr_qp_idx_ofst); |
1509 | 61.9k | mb_qp2 = (ps_cur_mb->u1_mb_qp + i1_cr_qp_idx_ofst); |
1510 | 61.9k | qp_avg = (UWORD8)((gau1_ih264d_qp_scale_cr[12 + mb_qp1] |
1511 | 61.9k | + gau1_ih264d_qp_scale_cr[12 + mb_qp2] + 1) >> 1); |
1512 | 61.9k | } |
1513 | 61.9k | idx_a_v = qp_avg + ofst_a; |
1514 | 61.9k | alpha_v = gau1_ih264d_alpha_table[12 + idx_a_v]; |
1515 | 61.9k | idx_b_v = qp_avg + ofst_b; |
1516 | 61.9k | beta_v = gau1_ih264d_beta_table[12 + idx_b_v]; |
1517 | | |
1518 | 61.9k | if(0x04040404 == u4_bs_val) |
1519 | 44.6k | { |
1520 | 44.6k | ps_dec->pf_deblk_luma_vert_bs4_mbaff(pu1_y, i4_strd_y, alpha_y, |
1521 | 44.6k | beta_y); |
1522 | 44.6k | ps_dec->pf_deblk_chroma_vert_bs4_mbaff(pu1_u, i4_strd_uv, alpha_u, |
1523 | 44.6k | beta_u, alpha_v, beta_v); |
1524 | | |
1525 | 44.6k | } |
1526 | 17.3k | else |
1527 | 17.3k | { |
1528 | 17.3k | if(u4_bs_val) |
1529 | 17.3k | { |
1530 | | |
1531 | 17.3k | pu1_cliptab_y = (UWORD8 *)&gau1_ih264d_clip_table[12 + idx_a_y]; |
1532 | 17.3k | pu1_cliptab_u = (UWORD8 *)&gau1_ih264d_clip_table[12 + idx_a_u]; |
1533 | 17.3k | pu1_cliptab_v = (UWORD8 *)&gau1_ih264d_clip_table[12 + idx_a_v]; |
1534 | | |
1535 | 17.3k | ps_dec->pf_deblk_luma_vert_bslt4_mbaff(pu1_y, i4_strd_y, |
1536 | 17.3k | alpha_y, beta_y, |
1537 | 17.3k | u4_bs_val, |
1538 | 17.3k | pu1_cliptab_y); |
1539 | 17.3k | ps_dec->pf_deblk_chroma_vert_bslt4_mbaff(pu1_u, i4_strd_uv, |
1540 | 17.3k | alpha_u, beta_u, |
1541 | 17.3k | alpha_v, beta_v, |
1542 | 17.3k | u4_bs_val, |
1543 | 17.3k | pu1_cliptab_u, |
1544 | 17.3k | pu1_cliptab_v); |
1545 | | |
1546 | 17.3k | } |
1547 | 17.3k | } |
1548 | 61.9k | } |
1549 | | |
1550 | 2.25M | } |
1551 | | |
1552 | | void ih264d_filter_boundary_topmbaff(dec_struct_t *ps_dec, |
1553 | | tfr_ctxt_t * ps_tfr_cxt, |
1554 | | WORD8 i1_cb_qp_idx_ofst, |
1555 | | WORD8 i1_cr_qp_idx_ofst, |
1556 | | deblk_mb_t * ps_cur_mb, |
1557 | | WORD32 i4_strd_y, |
1558 | | WORD32 i4_strd_uv, |
1559 | | deblk_mb_t * ps_top_mb, |
1560 | | UWORD32 u4_bs) |
1561 | 2.27M | { |
1562 | 2.27M | UWORD8 *pu1_y, *pu1_u; |
1563 | 2.27M | WORD32 alpha_u = 0, beta_u = 0, alpha_v = 0, beta_v = 0; |
1564 | 2.27M | WORD32 alpha_y = 0, beta_y = 0; |
1565 | 2.27M | WORD32 qp_avg; |
1566 | 2.27M | WORD32 idx_b_u, idx_a_u, idx_b_v, idx_a_v; |
1567 | 2.27M | WORD32 idx_b_y, idx_a_y; |
1568 | 2.27M | UWORD16 uc_tmp; |
1569 | | |
1570 | 2.27M | UWORD8 *pu1_cliptab_u, *pu1_cliptab_v, *pu1_cliptab_y; |
1571 | 2.27M | WORD32 ofst_a = ps_cur_mb->i1_slice_alpha_c0_offset; |
1572 | 2.27M | WORD32 ofst_b = ps_cur_mb->i1_slice_beta_offset; |
1573 | | |
1574 | | /* LUMA values */ |
1575 | | /* Deblock rounding change */ |
1576 | 2.27M | uc_tmp = ((ps_top_mb->u1_mb_qp + ps_cur_mb->u1_mb_qp + 1) >> 1); |
1577 | 2.27M | qp_avg = (UWORD8)uc_tmp; |
1578 | 2.27M | idx_a_y = qp_avg + ofst_a; |
1579 | 2.27M | alpha_y = gau1_ih264d_alpha_table[12 + idx_a_y]; |
1580 | 2.27M | idx_b_y = qp_avg + ofst_b; |
1581 | 2.27M | beta_y = gau1_ih264d_beta_table[12 + idx_b_y]; |
1582 | 2.27M | pu1_y = ps_tfr_cxt->pu1_mb_y; |
1583 | | |
1584 | | /* CHROMA cb values */ |
1585 | 2.27M | { |
1586 | 2.27M | WORD32 mb_qp1, mb_qp2; |
1587 | 2.27M | mb_qp1 = (ps_top_mb->u1_mb_qp + i1_cb_qp_idx_ofst); |
1588 | 2.27M | mb_qp2 = (ps_cur_mb->u1_mb_qp + i1_cb_qp_idx_ofst); |
1589 | 2.27M | qp_avg = (UWORD8)((gau1_ih264d_qp_scale_cr[12 + mb_qp1] |
1590 | 2.27M | + gau1_ih264d_qp_scale_cr[12 + mb_qp2] + 1) >> 1); |
1591 | 2.27M | } |
1592 | | |
1593 | 2.27M | idx_a_u = qp_avg + ofst_a; |
1594 | 2.27M | alpha_u = gau1_ih264d_alpha_table[12 + idx_a_u]; |
1595 | 2.27M | idx_b_u = qp_avg + ofst_b; |
1596 | 2.27M | beta_u = gau1_ih264d_beta_table[12 + idx_b_u]; |
1597 | | /* CHROMA cr values */ |
1598 | 2.27M | { |
1599 | 2.27M | WORD32 mb_qp1, mb_qp2; |
1600 | 2.27M | mb_qp1 = (ps_top_mb->u1_mb_qp + i1_cr_qp_idx_ofst); |
1601 | 2.27M | mb_qp2 = (ps_cur_mb->u1_mb_qp + i1_cr_qp_idx_ofst); |
1602 | 2.27M | qp_avg = (UWORD8)((gau1_ih264d_qp_scale_cr[12 + mb_qp1] |
1603 | 2.27M | + gau1_ih264d_qp_scale_cr[12 + mb_qp2] + 1) >> 1); |
1604 | 2.27M | } |
1605 | | |
1606 | 2.27M | idx_a_v = qp_avg + ofst_a; |
1607 | 2.27M | alpha_v = gau1_ih264d_alpha_table[12 + idx_a_v]; |
1608 | 2.27M | idx_b_v = qp_avg + ofst_b; |
1609 | 2.27M | beta_v = gau1_ih264d_beta_table[12 + idx_b_v]; |
1610 | 2.27M | pu1_u = ps_tfr_cxt->pu1_mb_u; |
1611 | | |
1612 | 2.27M | if(u4_bs == 0x04040404) |
1613 | 74.6k | { |
1614 | | /* Code specific to the assembly module */ |
1615 | 74.6k | ps_dec->pf_deblk_luma_horz_bs4(pu1_y, i4_strd_y, alpha_y, beta_y); |
1616 | 74.6k | ps_dec->pf_deblk_chroma_horz_bs4(pu1_u, i4_strd_uv, alpha_u, beta_u, |
1617 | 74.6k | alpha_v, beta_v); |
1618 | | |
1619 | 74.6k | } |
1620 | 2.19M | else |
1621 | 2.19M | { |
1622 | 2.19M | if(u4_bs) |
1623 | 127k | { |
1624 | | |
1625 | 127k | pu1_cliptab_y = (UWORD8 *)&gau1_ih264d_clip_table[12 + idx_a_y]; |
1626 | 127k | pu1_cliptab_u = |
1627 | 127k | (UWORD8 *)&gau1_ih264d_clip_table[12 + idx_a_u]; |
1628 | 127k | pu1_cliptab_v = |
1629 | 127k | (UWORD8 *)&gau1_ih264d_clip_table[12 + idx_a_v]; |
1630 | | |
1631 | 127k | ps_dec->pf_deblk_luma_horz_bslt4(pu1_y, i4_strd_y, alpha_y, beta_y, |
1632 | 127k | u4_bs, pu1_cliptab_y); |
1633 | 127k | ps_dec->pf_deblk_chroma_horz_bslt4(pu1_u, i4_strd_uv, alpha_u, |
1634 | 127k | beta_u, alpha_v, beta_v, |
1635 | 127k | u4_bs, pu1_cliptab_u, |
1636 | 127k | pu1_cliptab_v); |
1637 | | |
1638 | 127k | } |
1639 | 2.19M | } |
1640 | | |
1641 | 2.27M | } |
1642 | | |
1643 | | void ih264d_deblock_mb_mbaff(dec_struct_t *ps_dec, |
1644 | | tfr_ctxt_t * ps_tfr_cxt, |
1645 | | WORD8 i1_cb_qp_idx_ofst, |
1646 | | WORD8 i1_cr_qp_idx_ofst, |
1647 | | deblk_mb_t * ps_cur_mb, |
1648 | | WORD32 i4_strd_y, |
1649 | | WORD32 i4_strd_uv, |
1650 | | deblk_mb_t * ps_top_mb, |
1651 | | deblk_mb_t * ps_left_mb, |
1652 | | UWORD8 u1_cur_fld, |
1653 | | UWORD8 u1_extra_top_edge) |
1654 | 2.35M | { |
1655 | 2.35M | UWORD8 *pu1_y, *pu1_u; |
1656 | 2.35M | UWORD32 u4_bs; |
1657 | | // WORD8 edge; |
1658 | 2.35M | WORD32 alpha, beta, alpha_u, beta_u, alpha_v, beta_v; |
1659 | | |
1660 | 2.35M | UWORD8 *pu1_cliptab_u; |
1661 | 2.35M | UWORD8 *pu1_cliptab_v; |
1662 | 2.35M | UWORD8 *pu1_cliptab_y; |
1663 | | |
1664 | 2.35M | UWORD32 * pu4_bs_tab = ps_cur_mb->u4_bs_table; |
1665 | 2.35M | WORD32 idx_a_y, idx_a_u, idx_a_v; |
1666 | | /* Return from here to switch off deblocking */ |
1667 | 2.35M | PROFILE_DISABLE_DEBLK() |
1668 | | |
1669 | 2.35M | i4_strd_y <<= u1_cur_fld; |
1670 | 2.35M | i4_strd_uv <<= u1_cur_fld; |
1671 | | /*--------------------------------------------------------------------*/ |
1672 | | /* Filter wrt Left edge */ |
1673 | | /* except */ |
1674 | | /* - Left Egde is Picture Boundary */ |
1675 | | /* - Left Egde is part of Slice Boundary and Deblocking */ |
1676 | | /* parameters of slice disable Filtering of Slice Boundary Edges*/ |
1677 | | /*--------------------------------------------------------------------*/ |
1678 | 2.35M | if(ps_left_mb) |
1679 | 2.25M | ih264d_filter_boundary_left_mbaff(ps_dec, ps_tfr_cxt, i1_cb_qp_idx_ofst, |
1680 | 2.25M | i1_cr_qp_idx_ofst, ps_cur_mb, |
1681 | 2.25M | i4_strd_y, i4_strd_uv, ps_left_mb, |
1682 | 2.25M | pu4_bs_tab, u1_cur_fld); |
1683 | | |
1684 | | /*--------------------------------------------------------------------*/ |
1685 | | /* Filter wrt Other Vertical Edges */ |
1686 | | /*--------------------------------------------------------------------*/ |
1687 | 2.35M | { |
1688 | 2.35M | WORD32 ofst_a, ofst_b, idx_b_y, idx_b_u, |
1689 | 2.35M | idx_b_v; |
1690 | 2.35M | WORD32 qp_avg, qp_avg_u, qp_avg_v; |
1691 | 2.35M | ofst_a = ps_cur_mb->i1_slice_alpha_c0_offset; |
1692 | 2.35M | ofst_b = ps_cur_mb->i1_slice_beta_offset; |
1693 | 2.35M | qp_avg = ps_cur_mb->u1_mb_qp; |
1694 | 2.35M | idx_a_y = qp_avg + ofst_a; |
1695 | 2.35M | alpha = gau1_ih264d_alpha_table[12 + idx_a_y]; |
1696 | 2.35M | idx_b_y = qp_avg + ofst_b; |
1697 | 2.35M | beta = gau1_ih264d_beta_table[12 + idx_b_y]; |
1698 | | |
1699 | | /* CHROMA Cb values */ |
1700 | 2.35M | qp_avg_u = (qp_avg + i1_cb_qp_idx_ofst); |
1701 | 2.35M | qp_avg_u = gau1_ih264d_qp_scale_cr[12 + qp_avg_u]; |
1702 | 2.35M | idx_a_u = qp_avg_u + ofst_a; |
1703 | 2.35M | alpha_u = gau1_ih264d_alpha_table[12 + idx_a_u]; |
1704 | 2.35M | idx_b_u = qp_avg_u + ofst_b; |
1705 | 2.35M | beta_u = gau1_ih264d_beta_table[12 + idx_b_u]; |
1706 | | /* CHROMA Cr values */ |
1707 | 2.35M | qp_avg_v = (qp_avg + i1_cr_qp_idx_ofst); |
1708 | 2.35M | qp_avg_v = gau1_ih264d_qp_scale_cr[12 + qp_avg_v]; |
1709 | 2.35M | idx_a_v = qp_avg_v + ofst_a; |
1710 | 2.35M | alpha_v = gau1_ih264d_alpha_table[12 + idx_a_v]; |
1711 | 2.35M | idx_b_v = qp_avg_v + ofst_b; |
1712 | 2.35M | beta_v = gau1_ih264d_beta_table[12 + idx_b_v]; |
1713 | 2.35M | } |
1714 | | |
1715 | | //STARTL4_FILTER_VERT; |
1716 | | |
1717 | 2.35M | pu1_cliptab_y = (UWORD8 *)&gau1_ih264d_clip_table[12 + idx_a_y]; //this for Luma |
1718 | 2.35M | pu1_cliptab_u = (UWORD8 *)&gau1_ih264d_clip_table[12 + idx_a_u]; //this for chroma |
1719 | 2.35M | pu1_cliptab_v = (UWORD8 *)&gau1_ih264d_clip_table[12 + idx_a_v]; //this for chroma |
1720 | | |
1721 | | //edge=1 |
1722 | | |
1723 | | |
1724 | 2.35M | u4_bs = pu4_bs_tab[5]; |
1725 | 2.35M | pu1_y = ps_tfr_cxt->pu1_mb_y; |
1726 | 2.35M | pu1_u = ps_tfr_cxt->pu1_mb_u; |
1727 | | |
1728 | 2.35M | if(u4_bs) |
1729 | 74.8k | { |
1730 | | |
1731 | 74.8k | ps_dec->pf_deblk_luma_vert_bslt4(pu1_y + 4, i4_strd_y, alpha, beta, |
1732 | 74.8k | u4_bs, pu1_cliptab_y); |
1733 | | |
1734 | 74.8k | } |
1735 | | //edge=2 |
1736 | | |
1737 | 2.35M | u4_bs = pu4_bs_tab[6]; |
1738 | 2.35M | if(u4_bs) |
1739 | 131k | { |
1740 | | |
1741 | 131k | ps_dec->pf_deblk_luma_vert_bslt4(pu1_y + 8, i4_strd_y, alpha, beta, |
1742 | 131k | u4_bs, pu1_cliptab_y); |
1743 | 131k | ps_dec->pf_deblk_chroma_vert_bslt4(pu1_u + 4 * YUV420SP_FACTOR, |
1744 | 131k | i4_strd_uv, alpha_u, beta_u, |
1745 | 131k | alpha_v, beta_v, u4_bs, |
1746 | 131k | pu1_cliptab_u, pu1_cliptab_v); |
1747 | 131k | } |
1748 | | //edge=3 |
1749 | | |
1750 | 2.35M | u4_bs = pu4_bs_tab[7]; |
1751 | 2.35M | if(u4_bs) |
1752 | 73.7k | { |
1753 | | |
1754 | 73.7k | ps_dec->pf_deblk_luma_vert_bslt4(pu1_y + 12, i4_strd_y, alpha, beta, |
1755 | 73.7k | u4_bs, pu1_cliptab_y); |
1756 | | |
1757 | 73.7k | } |
1758 | | |
1759 | | /*--------------------------------------------------------------------*/ |
1760 | | /* Filter wrt Top edge */ |
1761 | | /* except */ |
1762 | | /* - Top Egde is Picture Boundary */ |
1763 | | /* - Top Egde is part of Slice Boundary and Deblocking */ |
1764 | | /* parameters of slice disable Filtering of Slice Boundary Edges*/ |
1765 | | /*--------------------------------------------------------------------*/ |
1766 | 2.35M | if(ps_top_mb) |
1767 | 2.25M | { |
1768 | | /** if top MB and MB AFF and cur MB is frame and top is field then */ |
1769 | | /* one extra top edge needs to be deblocked */ |
1770 | 2.25M | if(u1_extra_top_edge) |
1771 | 20.5k | { |
1772 | 20.5k | ih264d_filter_boundary_topmbaff(ps_dec, ps_tfr_cxt, |
1773 | 20.5k | i1_cb_qp_idx_ofst, |
1774 | 20.5k | i1_cr_qp_idx_ofst, ps_cur_mb, |
1775 | 20.5k | (UWORD16)(i4_strd_y << 1), |
1776 | 20.5k | (UWORD16)(i4_strd_uv << 1), |
1777 | 20.5k | ps_top_mb - 1, pu4_bs_tab[8]); |
1778 | 20.5k | ps_tfr_cxt->pu1_mb_y += i4_strd_y; |
1779 | 20.5k | ps_tfr_cxt->pu1_mb_u += i4_strd_uv; |
1780 | 20.5k | ps_tfr_cxt->pu1_mb_v += i4_strd_uv; |
1781 | | |
1782 | 20.5k | ih264d_filter_boundary_topmbaff(ps_dec, ps_tfr_cxt, |
1783 | 20.5k | i1_cb_qp_idx_ofst, |
1784 | 20.5k | i1_cr_qp_idx_ofst, ps_cur_mb, |
1785 | 20.5k | (UWORD16)(i4_strd_y << 1), |
1786 | 20.5k | (UWORD16)(i4_strd_uv << 1), |
1787 | 20.5k | ps_top_mb, pu4_bs_tab[0]); |
1788 | 20.5k | ps_tfr_cxt->pu1_mb_y -= i4_strd_y; |
1789 | 20.5k | ps_tfr_cxt->pu1_mb_u -= i4_strd_uv; |
1790 | 20.5k | ps_tfr_cxt->pu1_mb_v -= i4_strd_uv; |
1791 | 20.5k | } |
1792 | 2.23M | else |
1793 | 2.23M | { |
1794 | 2.23M | ih264d_filter_boundary_topmbaff(ps_dec, ps_tfr_cxt, |
1795 | 2.23M | i1_cb_qp_idx_ofst, |
1796 | 2.23M | i1_cr_qp_idx_ofst, ps_cur_mb, |
1797 | 2.23M | i4_strd_y, i4_strd_uv, ps_top_mb, |
1798 | 2.23M | pu4_bs_tab[0]); |
1799 | 2.23M | } |
1800 | 2.25M | } |
1801 | | |
1802 | | /*--------------------------------------------------------------------*/ |
1803 | | /* Filter wrt Other Horizontal Edges */ |
1804 | | /*--------------------------------------------------------------------*/ |
1805 | | |
1806 | | //edge1 |
1807 | 2.35M | u4_bs = pu4_bs_tab[1]; |
1808 | | |
1809 | 2.35M | if(u4_bs) |
1810 | 74.5k | { |
1811 | 74.5k | ps_dec->pf_deblk_luma_horz_bslt4(pu1_y + (i4_strd_y << 2), i4_strd_y, |
1812 | 74.5k | alpha, beta, u4_bs, pu1_cliptab_y); |
1813 | | |
1814 | 74.5k | } |
1815 | | //edge2 |
1816 | 2.35M | u4_bs = pu4_bs_tab[2]; |
1817 | | |
1818 | 2.35M | if(u4_bs) |
1819 | 137k | { |
1820 | | |
1821 | 137k | ps_dec->pf_deblk_luma_horz_bslt4(pu1_y + (i4_strd_y << 3), i4_strd_y, |
1822 | 137k | alpha, beta, u4_bs, pu1_cliptab_y); |
1823 | 137k | ps_dec->pf_deblk_chroma_horz_bslt4(pu1_u + (i4_strd_uv << 2), |
1824 | 137k | i4_strd_uv, alpha_u, beta_u, |
1825 | 137k | alpha_v, beta_v, u4_bs, |
1826 | 137k | pu1_cliptab_u, pu1_cliptab_v); |
1827 | | |
1828 | 137k | } |
1829 | | //edge3 |
1830 | 2.35M | u4_bs = pu4_bs_tab[3]; |
1831 | 2.35M | if(u4_bs) |
1832 | 73.8k | { |
1833 | | |
1834 | 73.8k | ps_dec->pf_deblk_luma_horz_bslt4( |
1835 | 73.8k | (pu1_y + (i4_strd_y << 3) + (i4_strd_y << 2)), |
1836 | 73.8k | i4_strd_y, alpha, beta, u4_bs, pu1_cliptab_y); |
1837 | | |
1838 | 73.8k | } |
1839 | | |
1840 | 2.35M | } |
1841 | | |