blob: 4a6750a41c90670d20b4ee8c5aa5f5f54c7ebbe3 [file] [log] [blame]
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301/******************************************************************************
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 "ih264_typedefs.h"
22#include "ih264_macros.h"
23#include "ih264_platform_macros.h"
24#include "ih264d_structs.h"
25#include "ih264d_defs.h"
26#include "ih264d_deblocking.h"
27#include "string.h"
28#include "ih264d_debug.h"
29#include "ih264d_tables.h"
30
31UWORD16 ih264d_update_csbp_8x8(UWORD16 u2_luma_csbp)
32{
33 UWORD16 u2_mod_csbp;
34
35 u2_mod_csbp = u2_luma_csbp;
36
37 if(u2_mod_csbp & 0x0033)
38 {
39 u2_mod_csbp |= 0x0033;
40 }
41
42 if(u2_mod_csbp & 0x00CC)
43 {
44 u2_mod_csbp |= 0x00CC;
45 }
46
47 if(u2_mod_csbp & 0x3300)
48 {
49 u2_mod_csbp |= 0x3300;
50 }
51
52 if(u2_mod_csbp & 0xCC00)
53 {
54 u2_mod_csbp |= 0xCC00;
55 }
56
57 return u2_mod_csbp;
58}
59
60/*****************************************************************************/
61/* */
62/* Function Name : ih264d_fill_bs2_horz_vert */
63/* */
64/* Description : This function fills boundray strength (=2) for all horz */
65/* and vert edges of current mb based on coded sub block */
66/* pattern of current, top and left mb */
67/* Inputs : */
68/* pu4_bs : Base pointer of BS table which gets updated */
69/* u4_left_mb_csbp : left mb's coded sub block pattern */
70/* u4_top_mb_csbp : top mb's coded sub block pattern */
71/* u4_cur_mb_csbp : current mb's coded sub block pattern */
72/* */
73/* Globals : <Does it use any global variables?> */
74/* Processing : */
75/* */
76/* csbp for each 4x4 block in a mb is bit packet in reverse */
77/* raster scan order for each mb as shown below: */
78/* 15|14|13|12|11|10|9|8|7|6|5|4|3|2|1|0. */
79/* */
80/* BS=2 for a 4x4 edge if any of adjacent blocks forming edge */
81/* are coded. Keeping this in mind, bs=2 for all horz and vert */
82/* edges can be derived using a lookup table for each edge */
83/* after "ORing" the csbp values as follows: */
84/* (C means current Mb, T means top mb and L means left mb) */
85/* */
86/* All Horz edges: */
87/* 15C|14C|13C|12C|11C|10C|9C|8C|7C|6C|5C|4C|3C |2C |1C |0C */
88/* (or with) 11C|10C| 9C| 8C| 7C|6C |5C|4C|3C|2C|1C|0C|15T|14T|13T|12T */
89/* -----BS[3]-----|----BS[2]----|---BS[1]---|----BS[0]-----| */
90/* */
91/* All Vert edges: */
92/* 15C|14C|13C|12C|11C|10C|9C| 8C|7C|6C|5C|4C|3C |2C |1C |0C */
93/* (or with) 14C|13C|12C|15L|10C| 9C|8C|11L|6C|5C|4C|7L|2C |1C |0C |3L */
94/* Do 4x4 transpose of resulting pattern to get vertBS[4]-BS[7] */
95/* */
96/* Outputs : <What does the function produce?> */
97/* Returns : <What does the function return?> */
98/* */
99/* Issues : <List any issues or problems with this function> */
100/* */
101/* Revision History: */
102/* */
103/* DD MM YYYY Author(s) Changes (Describe the changes made) */
104/* 16 10 2008 Jay Draft */
105/* */
106/*****************************************************************************/
107#define CSBP_LEFT_BLOCK_MASK 0x1111
108#define CSBP_RIGHT_BLOCK_MASK 0x8888
109
110void ih264d_fill_bs2_horz_vert(UWORD32 *pu4_bs, /* Base pointer of BS table */
111 WORD32 u4_left_mb_csbp, /* csbp of left mb */
112 WORD32 u4_top_mb_csbp, /* csbp of top mb */
113 WORD32 u4_cur_mb_csbp, /* csbp of current mb */
114 const UWORD32 *pu4_packed_bs2, const UWORD16 *pu2_4x4_v2h_reorder)
115{
116 /*************************************************************************/
117 /*u4_nbr_horz_csbp=11C|10C|9C|8C|7C|6C|5C|4C|3C|2C|1C|0C|15T|14T|13T|12T */
118 /*************************************************************************/
119 UWORD32 u4_nbr_horz_csbp = (u4_cur_mb_csbp << 4) | (u4_top_mb_csbp >> 12);
120 UWORD32 u4_horz_bs2_dec = u4_cur_mb_csbp | u4_nbr_horz_csbp;
121
122 /*************************************************************************/
123 /*u4_left_mb_masked_csbp = 15L|0|0|0|11L|0|0|0|7L|0|0|0|3L|0|0|0 */
124 /*************************************************************************/
125 UWORD32 u4_left_mb_masked_csbp = u4_left_mb_csbp & CSBP_RIGHT_BLOCK_MASK;
126
127 /*************************************************************************/
128 /*u4_cur_mb_masked_csbp =14C|13C|12C|x|10C|9C|8C|x|6C|5C|4C|x|2C|1C|0C|x */
129 /*************************************************************************/
130 UWORD32 u4_cur_mb_masked_csbp = (u4_cur_mb_csbp << 1)
131 & (~CSBP_LEFT_BLOCK_MASK);
132
133 /*************************************************************************/
134 /*u4_nbr_vert_csbp=14C|13C|12C|15L|10C|9C|8C|11L|6C|5C|4C|7L|2C|1C|0C|3L */
135 /*************************************************************************/
136 UWORD32 u4_nbr_vert_csbp = (u4_cur_mb_masked_csbp)
137 | (u4_left_mb_masked_csbp >> 3);
138
139 UWORD32 u4_vert_bs2_dec = u4_cur_mb_csbp | u4_nbr_vert_csbp;
140
141 UWORD32 u4_reordered_vert_bs2_dec, u4_temp;
142
143 PROFILE_DISABLE_BOUNDARY_STRENGTH()
144
145 /*************************************************************************/
146 /* Fill horz edges (0,1,2,3) boundary strengths 2 using look up table */
147 /*************************************************************************/
148 pu4_bs[0] = pu4_packed_bs2[u4_horz_bs2_dec & 0xF];
149 pu4_bs[1] = pu4_packed_bs2[(u4_horz_bs2_dec >> 4) & 0xF];
150 pu4_bs[2] = pu4_packed_bs2[(u4_horz_bs2_dec >> 8) & 0xF];
151 pu4_bs[3] = pu4_packed_bs2[(u4_horz_bs2_dec >> 12) & 0xF];
152
153 /*************************************************************************/
154 /* Do 4x4 tranpose of u4_vert_bs2_dec by using look up table for reorder */
155 /*************************************************************************/
156 u4_reordered_vert_bs2_dec = pu2_4x4_v2h_reorder[u4_vert_bs2_dec & 0xF];
157 u4_temp = pu2_4x4_v2h_reorder[(u4_vert_bs2_dec >> 4) & 0xF];
158 u4_reordered_vert_bs2_dec |= (u4_temp << 1);
159 u4_temp = pu2_4x4_v2h_reorder[(u4_vert_bs2_dec >> 8) & 0xF];
160 u4_reordered_vert_bs2_dec |= (u4_temp << 2);
161 u4_temp = pu2_4x4_v2h_reorder[(u4_vert_bs2_dec >> 12) & 0xF];
162 u4_reordered_vert_bs2_dec |= (u4_temp << 3);
163
164 /*************************************************************************/
165 /* Fill vert edges (4,5,6,7) boundary strengths 2 using look up table */
166 /*************************************************************************/
167 pu4_bs[4] = pu4_packed_bs2[u4_reordered_vert_bs2_dec & 0xF];
168 pu4_bs[5] = pu4_packed_bs2[(u4_reordered_vert_bs2_dec >> 4) & 0xF];
169 pu4_bs[6] = pu4_packed_bs2[(u4_reordered_vert_bs2_dec >> 8) & 0xF];
170 pu4_bs[7] = pu4_packed_bs2[(u4_reordered_vert_bs2_dec >> 12) & 0xF];
171}
172
173/*****************************************************************************/
174/* */
175/* Function Name : ih264d_fill_bs1_16x16mb_pslice */
176/* */
177/* Description : This function fills boundray strength (=1) for those */
178/* horz and vert mb edges of 16x16mb which are set to 0 by */
179/* ih264d_fill_bs2_horz_vert. This function is used for p slices */
180/* */
181/* Inputs : <What inputs does the function take?> */
182/* Globals : <Does it use any global variables?> */
183/* Processing : If any motion vector component of adjacent 4x4 blocks */
184/* differs by more than 1 integer pel or if reference */
185/* pictures are different, Bs is set to 1. */
186/* */
187/* Outputs : <What does the function produce?> */
188/* Returns : <What does the function return?> */
189/* */
190/* Issues : <List any issues or problems with this function> */
191/* */
192/* Revision History: */
193/* */
194/* DD MM YYYY Author(s) Changes (Describe the changes made) */
195/* 16 10 2008 Jay Draft */
196/* */
197/*****************************************************************************/
198void ih264d_fill_bs1_16x16mb_pslice(mv_pred_t *ps_cur_mv_pred,
199 mv_pred_t *ps_top_mv_pred,
200 void **ppv_map_ref_idx_to_poc,
201 UWORD32 *pu4_bs_table, /* pointer to the BsTable array */
202 mv_pred_t *ps_leftmost_mv_pred,
203 neighbouradd_t *ps_left_addr,
204 void **u4_pic_addrress, /* picture address for BS calc */
205 WORD32 i4_ver_mvlimit)
206{
207 WORD16 i2_q_mv0, i2_q_mv1;
208 WORD16 i2_p_mv0, i2_p_mv1;
209 void *pv_cur_pic_addr0, *pv_cur_pic_addr1;
210 void *pv_nbr_pic_addr0, *pv_nbr_pic_addr1;
211 void **ppv_map_ref_idx_to_poc_l0; //,*ppv_map_ref_idx_to_poc_l1;
212 UWORD32 i;
213 UWORD32 u4_bs_horz = pu4_bs_table[0];
214 UWORD32 u4_bs_vert = pu4_bs_table[4];
215
216 PROFILE_DISABLE_BOUNDARY_STRENGTH()
217
218 ppv_map_ref_idx_to_poc_l0 = ppv_map_ref_idx_to_poc;
219
220 i2_q_mv0 = ps_cur_mv_pred->i2_mv[0];
221 i2_q_mv1 = ps_cur_mv_pred->i2_mv[1];
222 pv_cur_pic_addr0 = ppv_map_ref_idx_to_poc_l0[ps_cur_mv_pred->i1_ref_frame[0]];
223 pv_cur_pic_addr1 = 0;
224
225 /*********************************/
226 /* Computing Bs for the top edge */
227 /*********************************/
228 for(i = 0; i < 4; i++, ps_top_mv_pred++)
229 {
230 UWORD32 u4_idx = 24 - (i << 3);
231
232 /*********************************/
233 /* check if Bs is already set */
234 /*********************************/
235 if(!((u4_bs_horz >> u4_idx) & 0xf))
236 {
237 /************************************************************/
238 /* If Bs is not set, use left edge and current edge mvs and */
239 /* reference pictures addresses to evaluate Bs==1 */
240 /************************************************************/
241 UWORD32 u4_bs_temp1;
242 UWORD32 u4_bs;
243
244 /*********************************************************/
245 /* If any motion vector component differs by more than 1 */
246 /* integer pel or if reference pictures are different Bs */
247 /* is set to 1. Note that this condition shall be met for*/
248 /* both (fwd-fwd,bwd-bwd) and (fwd-bwd,bwd-fwd) direction*/
249 /*********************************************************/
250 i2_p_mv0 = ps_top_mv_pred->i2_mv[0];
251 i2_p_mv1 = ps_top_mv_pred->i2_mv[1];
252 pv_nbr_pic_addr0 = u4_pic_addrress[i & 2];
253 pv_nbr_pic_addr1 = u4_pic_addrress[1 + (i & 2)];
254
255 u4_bs_temp1 = ((ABS((i2_p_mv0 - i2_q_mv0)) >= 4) ||
256 (ABS((i2_p_mv1 - i2_q_mv1)) >= i4_ver_mvlimit));
257
258 u4_bs = ((pv_cur_pic_addr0 != pv_nbr_pic_addr0)
259 || (pv_cur_pic_addr1 != pv_nbr_pic_addr1)
260 || u4_bs_temp1);
261
262 u4_bs_horz |= (u4_bs << u4_idx);
263 }
264 }
265 pu4_bs_table[0] = u4_bs_horz;
266
267 /***********************************/
268 /* Computing Bs for the left edge */
269 /***********************************/
270 for(i = 0; i < 4; i++, ps_leftmost_mv_pred += 4)
271 {
272 UWORD32 u4_idx = 24 - (i << 3);
273
274 /*********************************/
275 /* check if Bs is already set */
276 /*********************************/
277 if(!((u4_bs_vert >> u4_idx) & 0xf))
278 {
279 /****************************************************/
280 /* If Bs is not set, evalaute conditions for Bs=1 */
281 /****************************************************/
282 UWORD32 u4_bs_temp1;
283 UWORD32 u4_bs;
284 /*********************************************************/
285 /* If any motion vector component differs by more than 1 */
286 /* integer pel or if reference pictures are different Bs */
287 /* is set to 1. Note that this condition shall be met for*/
288 /* both (fwd-fwd,bwd-bwd) and (fwd-bwd,bwd-fwd) direction*/
289 /*********************************************************/
290
291 i2_p_mv0 = ps_leftmost_mv_pred->i2_mv[0];
292 i2_p_mv1 = ps_leftmost_mv_pred->i2_mv[1];
293 pv_nbr_pic_addr0 = ps_left_addr->u4_add[i & 2];
294 pv_nbr_pic_addr1 = ps_left_addr->u4_add[1 + (i & 2)];
295
296 u4_bs_temp1 =
297 ((ABS((i2_p_mv0 - i2_q_mv0))
298 >= 4)
299 | (ABS((i2_p_mv1 - i2_q_mv1))
300 >= i4_ver_mvlimit));
301
302 u4_bs = ((pv_cur_pic_addr0 != pv_nbr_pic_addr0)
303 || (pv_cur_pic_addr1 != pv_nbr_pic_addr1)
304 || u4_bs_temp1);
305
306 u4_bs_vert |= (u4_bs << u4_idx);
307 }
308 }
309 pu4_bs_table[4] = u4_bs_vert;
310
311 return;
312}
313
314/*****************************************************************************/
315/* */
316/* Function Name : ih264d_fill_bs1_non16x16mb_pslice */
317/* */
318/* Description : This function fills boundray strength (=1) for those */
319/* horz and vert edges of non16x16mb which are set to 0 by */
320/* ih264d_fill_bs2_horz_vert. This function is used for p slices */
321/* */
322/* Inputs : <What inputs does the function take?> */
323/* Globals : <Does it use any global variables?> */
324/* Processing : If any motion vector component of adjacent 4x4 blocks */
325/* differs by more than 1 integer pel or if reference */
326/* pictures are different, Bs is set to 1. */
327/* */
328/* Outputs : <What does the function produce?> */
329/* Returns : <What does the function return?> */
330/* */
331/* Issues : <List any issues or problems with this function> */
332/* */
333/* Revision History: */
334/* */
335/* DD MM YYYY Author(s) Changes (Describe the changes made) */
336/* 16 10 2008 Jay Draft */
337/* */
338/*****************************************************************************/
339void ih264d_fill_bs1_non16x16mb_pslice(mv_pred_t *ps_cur_mv_pred,
340 mv_pred_t *ps_top_mv_pred,
341 void **ppv_map_ref_idx_to_poc,
342 UWORD32 *pu4_bs_table, /* pointer to the BsTable array */
343 mv_pred_t *ps_leftmost_mv_pred,
344 neighbouradd_t *ps_left_addr,
345 void **u4_pic_addrress,
346 WORD32 i4_ver_mvlimit)
347{
348 UWORD32 edge;
349 void **ppv_map_ref_idx_to_poc_l0; //,*ppv_map_ref_idx_to_poc_l1;
350
351 PROFILE_DISABLE_BOUNDARY_STRENGTH()
352
353 ppv_map_ref_idx_to_poc_l0 = ppv_map_ref_idx_to_poc;
354
355
356 for(edge = 0; edge < 4; edge++, ps_top_mv_pred = ps_cur_mv_pred - 4)
357 {
358 /*********************************************************************/
359 /* Each iteration of this loop fills the four BS values of one HORIZ */
360 /* edge and one BS value for each of the four VERT edges. */
361 /*********************************************************************/
362 WORD32 i;
363 UWORD32 u4_vert_idx = 24 - (edge << 3);
364 UWORD32 u4_bs_horz = pu4_bs_table[edge];
365 mv_pred_t *ps_left_mv_pred = ps_leftmost_mv_pred + (edge << 2);
366
367 for(i = 0; i < 4; i++, ps_top_mv_pred++, ps_cur_mv_pred++)
368 {
369 WORD16 i2_cur_mv0, i2_cur_mv1;
370 WORD8 i1_cur_ref0;
371 void *pv_cur_pic_addr0, *pv_cur_pic_addr1 = 0;
372 void *pv_nbr_pic_addr0, *pv_nbr_pic_addr1;
373
374 /******************************************************/
375 /* Each iteration of this inner loop computes a HORIZ */
376 /* and a VERT BS value for a 4x4 block */
377 /******************************************************/
378 UWORD32 u4_bs_vert = (pu4_bs_table[i + 4] >> u4_vert_idx) & 0xf;
379 UWORD32 u4_horz_idx = 24 - (i << 3);
380
381 /*****************************************************/
382 /* check if vert Bs for this block is already set */
383 /*****************************************************/
384 if(!u4_bs_vert)
385 {
386 WORD16 i2_left_mv0, i2_left_mv1;
387 /************************************************************/
388 /* If Bs is not set, use left edge and current edge mvs and */
389 /* reference pictures addresses to evaluate Bs==1 */
390 /************************************************************/
391 i2_left_mv0 = ps_left_mv_pred->i2_mv[0];
392 i2_left_mv1 = ps_left_mv_pred->i2_mv[1];
393
394 i2_cur_mv0 = ps_cur_mv_pred->i2_mv[0];
395 i2_cur_mv1 = ps_cur_mv_pred->i2_mv[1];
396
397 i1_cur_ref0 = ps_cur_mv_pred->i1_ref_frame[0];
398
399 pv_cur_pic_addr0 = ppv_map_ref_idx_to_poc_l0[i1_cur_ref0];
400 if(i)
401 {
402 WORD8 i1_left_ref0 = ps_left_mv_pred->i1_ref_frame[0];
403 pv_nbr_pic_addr0 = ppv_map_ref_idx_to_poc_l0[i1_left_ref0];
404 pv_nbr_pic_addr1 = 0;
405 }
406 else
407 {
408 pv_nbr_pic_addr0 = ps_left_addr->u4_add[edge & 2];
409 pv_nbr_pic_addr1 = ps_left_addr->u4_add[1 + (edge & 2)];
410 }
411
412 {
413 UWORD32 u4_bs_temp1;
414 /*********************************************************/
415 /* If any motion vector component differs by more than 1 */
416 /* integer pel or if reference pictures are different Bs */
417 /* is set to 1. Note that this condition shall be met for*/
418 /* both (fwd-fwd,bwd-bwd) and (fwd-bwd,bwd-fwd) direction*/
419 /*********************************************************/
420
421 u4_bs_temp1 =
422 ((ABS((i2_left_mv0 - i2_cur_mv0))
423 >= 4)
424 | (ABS((i2_left_mv1
425 - i2_cur_mv1))
426 >= i4_ver_mvlimit));
427
428 u4_bs_vert = ((pv_nbr_pic_addr0 != pv_cur_pic_addr0)
429 || (pv_nbr_pic_addr1 != pv_cur_pic_addr1)
430 || u4_bs_temp1);
431
432 pu4_bs_table[i + 4] |= (u4_bs_vert << u4_vert_idx);
433 }
434 }
435
436 /*****************************************************/
437 /* check if horz Bs for this block is already set */
438 /*****************************************************/
439 if(!((u4_bs_horz >> u4_horz_idx) & 0xf))
440 {
441 WORD16 i2_top_mv0, i2_top_mv1;
442 /************************************************************/
443 /* If Bs is not set, use top edge and current edge mvs and */
444 /* reference pictures addresses to evaluate Bs==1 */
445 /************************************************************/
446 i2_cur_mv0 = ps_cur_mv_pred->i2_mv[0];
447 i2_cur_mv1 = ps_cur_mv_pred->i2_mv[1];
448
449 i1_cur_ref0 = ps_cur_mv_pred->i1_ref_frame[0];
450
451 i2_top_mv0 = ps_top_mv_pred->i2_mv[0];
452 i2_top_mv1 = ps_top_mv_pred->i2_mv[1];
453
454 pv_cur_pic_addr0 = ppv_map_ref_idx_to_poc_l0[i1_cur_ref0];
455 if(edge)
456 {
457 WORD8 i1_top_ref0 = ps_top_mv_pred->i1_ref_frame[0];
458 pv_nbr_pic_addr0 = ppv_map_ref_idx_to_poc_l0[i1_top_ref0];
459 pv_nbr_pic_addr1 = 0;
460 }
461 else
462 {
463 pv_nbr_pic_addr0 = u4_pic_addrress[i & 2];
464 pv_nbr_pic_addr1 = u4_pic_addrress[1 + (i & 2)];
465 }
466
467 {
468 UWORD32 u4_bs_temp1;
469 UWORD32 u4_bs;
470 /*********************************************************/
471 /* If any motion vector component differs by more than 1 */
472 /* integer pel or if reference pictures are different Bs */
473 /* is set to 1. Note that this condition shall be met for*/
474 /* both (fwd-fwd,bwd-bwd) and (fwd-bwd,bwd-fwd) direction*/
475 /*********************************************************/
476
477 u4_bs_temp1 =
478 ((ABS((i2_top_mv0 - i2_cur_mv0))
479 >= 4)
480 | (ABS((i2_top_mv1
481 - i2_cur_mv1))
482 >= i4_ver_mvlimit));
483
484 u4_bs = ((pv_nbr_pic_addr0 != pv_cur_pic_addr0)
485 || (pv_nbr_pic_addr1 != pv_cur_pic_addr1)
486 || u4_bs_temp1);
487
488 u4_bs_horz |= (u4_bs << u4_horz_idx);
489 }
490 }
491
492 ps_left_mv_pred = ps_cur_mv_pred;
493 }
494
495 pu4_bs_table[edge] = u4_bs_horz;
496 }
497}
498
499/*****************************************************************************/
500/* */
501/* Function Name : ih264d_fill_bs1_16x16mb_bslice */
502/* */
503/* Description : This function fills boundray strength (=1) for those */
504/* horz and vert mb edges of 16x16mb which are set to 0 by */
505/* ih264d_fill_bs2_horz_vert. This function is used for b slices */
506/* */
507/* Inputs : <What inputs does the function take?> */
508/* Globals : <Does it use any global variables?> */
509/* Processing : If any motion vector component of adjacent 4x4 blocks */
510/* differs by more than 1 integer pel or if reference */
511/* pictures are different, Bs is set to 1. */
512/* */
513/* Outputs : <What does the function produce?> */
514/* Returns : <What does the function return?> */
515/* */
516/* Issues : <List any issues or problems with this function> */
517/* */
518/* Revision History: */
519/* */
520/* DD MM YYYY Author(s) Changes (Describe the changes made) */
521/* 16 10 2008 Jay Draft */
522/* */
523/*****************************************************************************/
524void ih264d_fill_bs1_16x16mb_bslice(mv_pred_t *ps_cur_mv_pred,
525 mv_pred_t *ps_top_mv_pred,
526 void **ppv_map_ref_idx_to_poc,
527 UWORD32 *pu4_bs_table, /* pointer to the BsTable array */
528 mv_pred_t *ps_leftmost_mv_pred,
529 neighbouradd_t *ps_left_addr,
530 void **u4_pic_addrress,
531 WORD32 i4_ver_mvlimit)
532{
533 WORD16 i2_q_mv0, i2_q_mv1, i2_q_mv2, i2_q_mv3;
534 WORD16 i2_p_mv0, i2_p_mv1, i2_p_mv2, i2_p_mv3;
535 void *pv_cur_pic_addr0, *pv_cur_pic_addr1;
536 void *pv_nbr_pic_addr0, *pv_nbr_pic_addr1;
537 void **ppv_map_ref_idx_to_poc_l0, **ppv_map_ref_idx_to_poc_l1;
538 UWORD32 i;
539 UWORD32 u4_bs_horz = pu4_bs_table[0];
540 UWORD32 u4_bs_vert = pu4_bs_table[4];
541
542 PROFILE_DISABLE_BOUNDARY_STRENGTH()
543
544 ppv_map_ref_idx_to_poc_l0 = ppv_map_ref_idx_to_poc;
545 ppv_map_ref_idx_to_poc_l1 = ppv_map_ref_idx_to_poc + POC_LIST_L0_TO_L1_DIFF;
546 i2_q_mv0 = ps_cur_mv_pred->i2_mv[0];
547 i2_q_mv1 = ps_cur_mv_pred->i2_mv[1];
548 i2_q_mv2 = ps_cur_mv_pred->i2_mv[2];
549 i2_q_mv3 = ps_cur_mv_pred->i2_mv[3];
550 pv_cur_pic_addr0 = ppv_map_ref_idx_to_poc_l0[ps_cur_mv_pred->i1_ref_frame[0]];
551 pv_cur_pic_addr1 = ppv_map_ref_idx_to_poc_l1[ps_cur_mv_pred->i1_ref_frame[1]];
552
553 /*********************************/
554 /* Computing Bs for the top edge */
555 /*********************************/
556 for(i = 0; i < 4; i++, ps_top_mv_pred++)
557 {
558 UWORD32 u4_idx = 24 - (i << 3);
559
560 /*********************************/
561 /* check if Bs is already set */
562 /*********************************/
563 if(!((u4_bs_horz >> u4_idx) & 0xf))
564 {
565 /************************************************************/
566 /* If Bs is not set, use left edge and current edge mvs and */
567 /* reference pictures addresses to evaluate Bs==1 */
568 /************************************************************/
569 UWORD32 u4_bs_temp1, u4_bs_temp2;
570 UWORD32 u4_bs;
571
572 /*********************************************************/
573 /* If any motion vector component differs by more than 1 */
574 /* integer pel or if reference pictures are different Bs */
575 /* is set to 1. Note that this condition shall be met for*/
576 /* both (fwd-fwd,bwd-bwd) and (fwd-bwd,bwd-fwd) direction*/
577 /*********************************************************/
578 i2_p_mv0 = ps_top_mv_pred->i2_mv[0];
579 i2_p_mv1 = ps_top_mv_pred->i2_mv[1];
580 i2_p_mv2 = ps_top_mv_pred->i2_mv[2];
581 i2_p_mv3 = ps_top_mv_pred->i2_mv[3];
582 pv_nbr_pic_addr0 = u4_pic_addrress[i & 2];
583 pv_nbr_pic_addr1 = u4_pic_addrress[1 + (i & 2)];
584
585 u4_bs_temp1 =
586 ((ABS((i2_p_mv0 - i2_q_mv0))
587 >= 4)
588 | (ABS((i2_p_mv1 - i2_q_mv1))
589 >= i4_ver_mvlimit)
590 | (ABS((i2_p_mv2 - i2_q_mv2))
591 >= 4)
592 | (ABS((i2_p_mv3 - i2_q_mv3))
593 >= i4_ver_mvlimit));
594
595 u4_bs_temp2 =
596 ((ABS((i2_p_mv0 - i2_q_mv2))
597 >= 4)
598 | (ABS((i2_p_mv1 - i2_q_mv3))
599 >= i4_ver_mvlimit)
600 | (ABS((i2_p_mv2 - i2_q_mv0))
601 >= 4)
602 | (ABS((i2_p_mv3 - i2_q_mv1))
603 >= i4_ver_mvlimit));
604
605 u4_bs = ((pv_cur_pic_addr0 != pv_nbr_pic_addr0)
606 || (pv_cur_pic_addr1 != pv_nbr_pic_addr1)
607 || u4_bs_temp1)
608 && ((pv_cur_pic_addr0 != pv_nbr_pic_addr1)
609 || (pv_cur_pic_addr1
610 != pv_nbr_pic_addr0)
611 || u4_bs_temp2);
612
613 u4_bs_horz |= (u4_bs << u4_idx);
614 }
615 }
616 pu4_bs_table[0] = u4_bs_horz;
617
618 /***********************************/
619 /* Computing Bs for the left edge */
620 /***********************************/
621 for(i = 0; i < 4; i++, ps_leftmost_mv_pred += 4)
622 {
623 UWORD32 u4_idx = 24 - (i << 3);
624
625 /*********************************/
626 /* check if Bs is already set */
627 /*********************************/
628 if(!((u4_bs_vert >> u4_idx) & 0xf))
629 {
630 /****************************************************/
631 /* If Bs is not set, evalaute conditions for Bs=1 */
632 /****************************************************/
633 UWORD32 u4_bs_temp1, u4_bs_temp2;
634 UWORD32 u4_bs;
635 /*********************************************************/
636 /* If any motion vector component differs by more than 1 */
637 /* integer pel or if reference pictures are different Bs */
638 /* is set to 1. Note that this condition shall be met for*/
639 /* both (fwd-fwd,bwd-bwd) and (fwd-bwd,bwd-fwd) direction*/
640 /*********************************************************/
641
642 i2_p_mv0 = ps_leftmost_mv_pred->i2_mv[0];
643 i2_p_mv1 = ps_leftmost_mv_pred->i2_mv[1];
644 i2_p_mv2 = ps_leftmost_mv_pred->i2_mv[2];
645 i2_p_mv3 = ps_leftmost_mv_pred->i2_mv[3];
646 pv_nbr_pic_addr0 = ps_left_addr->u4_add[i & 2];
647 pv_nbr_pic_addr1 = ps_left_addr->u4_add[1 + (i & 2)];
648
649 u4_bs_temp1 =
650 ((ABS((i2_p_mv0 - i2_q_mv0))
651 >= 4)
652 | (ABS((i2_p_mv1 - i2_q_mv1))
653 >= i4_ver_mvlimit)
654 | (ABS((i2_p_mv2 - i2_q_mv2))
655 >= 4)
656 | (ABS((i2_p_mv3 - i2_q_mv3))
657 >= i4_ver_mvlimit));
658
659 u4_bs_temp2 =
660 ((ABS((i2_p_mv0 - i2_q_mv2))
661 >= 4)
662 | (ABS((i2_p_mv1 - i2_q_mv3))
663 >= i4_ver_mvlimit)
664 | (ABS((i2_p_mv2 - i2_q_mv0))
665 >= 4)
666 | (ABS((i2_p_mv3 - i2_q_mv1))
667 >= i4_ver_mvlimit));
668
669 u4_bs = ((pv_cur_pic_addr0 != pv_nbr_pic_addr0)
670 || (pv_cur_pic_addr1 != pv_nbr_pic_addr1)
671 || u4_bs_temp1)
672 && ((pv_cur_pic_addr0 != pv_nbr_pic_addr1)
673 || (pv_cur_pic_addr1
674 != pv_nbr_pic_addr0)
675 || u4_bs_temp2);
676
677 u4_bs_vert |= (u4_bs << u4_idx);
678 }
679 }
680 pu4_bs_table[4] = u4_bs_vert;
681
682 return;
683}
684
685/*****************************************************************************/
686/* */
687/* Function Name : ih264d_fill_bs1_non16x16mb_bslice */
688/* */
689/* Description : This function fills boundray strength (=1) for those */
690/* horz and vert edges of non16x16mb which are set to 0 by */
691/* ih264d_fill_bs2_horz_vert. This function is used for b slices */
692/* */
693/* Inputs : <What inputs does the function take?> */
694/* Globals : <Does it use any global variables?> */
695/* Processing : If any motion vector component of adjacent 4x4 blocks */
696/* differs by more than 1 integer pel or if reference */
697/* pictures are different, Bs is set to 1. */
698/* */
699/* Outputs : <What does the function produce?> */
700/* Returns : <What does the function return?> */
701/* */
702/* Issues : <List any issues or problems with this function> */
703/* */
704/* Revision History: */
705/* */
706/* DD MM YYYY Author(s) Changes (Describe the changes made) */
707/* 16 10 2008 Jay Draft */
708/* */
709/*****************************************************************************/
710void ih264d_fill_bs1_non16x16mb_bslice(mv_pred_t *ps_cur_mv_pred,
711 mv_pred_t *ps_top_mv_pred,
712 void **ppv_map_ref_idx_to_poc,
713 UWORD32 *pu4_bs_table, /* pointer to the BsTable array */
714 mv_pred_t *ps_leftmost_mv_pred,
715 neighbouradd_t *ps_left_addr,
716 void **u4_pic_addrress,
717 WORD32 i4_ver_mvlimit)
718{
719 UWORD32 edge;
720 void **ppv_map_ref_idx_to_poc_l0, **ppv_map_ref_idx_to_poc_l1;
721 ppv_map_ref_idx_to_poc_l0 = ppv_map_ref_idx_to_poc;
722 ppv_map_ref_idx_to_poc_l1 = ppv_map_ref_idx_to_poc + POC_LIST_L0_TO_L1_DIFF;
723
724 PROFILE_DISABLE_BOUNDARY_STRENGTH()
725
726 for(edge = 0; edge < 4; edge++, ps_top_mv_pred = ps_cur_mv_pred - 4)
727 {
728 /*********************************************************************/
729 /* Each iteration of this loop fills the four BS values of one HORIZ */
730 /* edge and one BS value for each of the four VERT edges. */
731 /*********************************************************************/
732 WORD32 i;
733 UWORD32 u4_vert_idx = 24 - (edge << 3);
734 UWORD32 u4_bs_horz = pu4_bs_table[edge];
735 mv_pred_t *ps_left_mv_pred = ps_leftmost_mv_pred + (edge << 2);
736
737 for(i = 0; i < 4; i++, ps_top_mv_pred++, ps_cur_mv_pred++)
738 {
739 WORD16 i2_cur_mv0, i2_cur_mv1, i16_curMv2, i16_curMv3;
740 WORD8 i1_cur_ref0, i1_cur_ref1;
741 void *pv_cur_pic_addr0, *pv_cur_pic_addr1;
742 void *pv_nbr_pic_addr0, *pv_nbr_pic_addr1;
743
744 /******************************************************/
745 /* Each iteration of this inner loop computes a HORIZ */
746 /* and a VERT BS value for a 4x4 block */
747 /******************************************************/
748 UWORD32 u4_bs_vert = (pu4_bs_table[i + 4] >> u4_vert_idx) & 0xf;
749 UWORD32 u4_horz_idx = 24 - (i << 3);
750
751 /*****************************************************/
752 /* check if vert Bs for this block is already set */
753 /*****************************************************/
754 if(!u4_bs_vert)
755 {
756 WORD16 i2_left_mv0, i2_left_mv1, i2_left_mv2, i2_left_mv3;
757 /************************************************************/
758 /* If Bs is not set, use left edge and current edge mvs and */
759 /* reference pictures addresses to evaluate Bs==1 */
760 /************************************************************/
761 i2_left_mv0 = ps_left_mv_pred->i2_mv[0];
762 i2_left_mv1 = ps_left_mv_pred->i2_mv[1];
763 i2_left_mv2 = ps_left_mv_pred->i2_mv[2];
764 i2_left_mv3 = ps_left_mv_pred->i2_mv[3];
765
766 i2_cur_mv0 = ps_cur_mv_pred->i2_mv[0];
767 i2_cur_mv1 = ps_cur_mv_pred->i2_mv[1];
768 i16_curMv2 = ps_cur_mv_pred->i2_mv[2];
769 i16_curMv3 = ps_cur_mv_pred->i2_mv[3];
770 i1_cur_ref0 = ps_cur_mv_pred->i1_ref_frame[0];
771 i1_cur_ref1 = ps_cur_mv_pred->i1_ref_frame[1];
772 pv_cur_pic_addr0 = ppv_map_ref_idx_to_poc_l0[i1_cur_ref0];
773 pv_cur_pic_addr1 = ppv_map_ref_idx_to_poc_l1[i1_cur_ref1];
774
775 if(i)
776 {
777 WORD8 i1_left_ref0, i1_left_ref1;
778 i1_left_ref0 = ps_left_mv_pred->i1_ref_frame[0];
779 i1_left_ref1 = ps_left_mv_pred->i1_ref_frame[1];
780 pv_nbr_pic_addr0 = ppv_map_ref_idx_to_poc_l0[i1_left_ref0];
781 pv_nbr_pic_addr1 = ppv_map_ref_idx_to_poc_l1[i1_left_ref1];
782 }
783 else
784 {
785 pv_nbr_pic_addr0 = ps_left_addr->u4_add[edge & 2];
786 pv_nbr_pic_addr1 = ps_left_addr->u4_add[1 + (edge & 2)];
787 }
788
789 {
790 UWORD32 u4_bs_temp1, u4_bs_temp2;
791 /*********************************************************/
792 /* If any motion vector component differs by more than 1 */
793 /* integer pel or if reference pictures are different Bs */
794 /* is set to 1. Note that this condition shall be met for*/
795 /* both (fwd-fwd,bwd-bwd) and (fwd-bwd,bwd-fwd) direction*/
796 /*********************************************************/
797
798 u4_bs_temp1 =
799 ((ABS((i2_left_mv0 - i2_cur_mv0))
800 >= 4)
801 | (ABS((i2_left_mv1
802 - i2_cur_mv1))
803 >= i4_ver_mvlimit)
804 | (ABS((i2_left_mv2
805 - i16_curMv2))
806 >= 4)
807 | (ABS((i2_left_mv3
808 - i16_curMv3))
809 >= i4_ver_mvlimit));
810
811 u4_bs_temp2 =
812 ((ABS((i2_left_mv0 - i16_curMv2))
813 >= 4)
814 | (ABS((i2_left_mv1
815 - i16_curMv3))
816 >= i4_ver_mvlimit)
817 | (ABS((i2_left_mv2
818 - i2_cur_mv0))
819 >= 4)
820 | (ABS((i2_left_mv3
821 - i2_cur_mv1))
822 >= i4_ver_mvlimit));
823
824 u4_bs_vert =
825 ((pv_nbr_pic_addr0 != pv_cur_pic_addr0)
826 || (pv_nbr_pic_addr1
827 != pv_cur_pic_addr1)
828 || u4_bs_temp1)
829 && ((pv_nbr_pic_addr0
830 != pv_cur_pic_addr1)
831 || (pv_nbr_pic_addr1
832 != pv_cur_pic_addr0)
833 || u4_bs_temp2);
834
835 pu4_bs_table[i + 4] |= (u4_bs_vert << u4_vert_idx);
836 }
837 }
838
839 /*****************************************************/
840 /* check if horz Bs for this block is already set */
841 /*****************************************************/
842 if(!((u4_bs_horz >> u4_horz_idx) & 0xf))
843 {
844 WORD16 i2_top_mv0, i2_top_mv1, i16_topMv2, i16_topMv3;
845 /************************************************************/
846 /* If Bs is not set, use top edge and current edge mvs and */
847 /* reference pictures addresses to evaluate Bs==1 */
848 /************************************************************/
849 i2_cur_mv0 = ps_cur_mv_pred->i2_mv[0];
850 i2_cur_mv1 = ps_cur_mv_pred->i2_mv[1];
851 i16_curMv2 = ps_cur_mv_pred->i2_mv[2];
852 i16_curMv3 = ps_cur_mv_pred->i2_mv[3];
853 i1_cur_ref0 = ps_cur_mv_pred->i1_ref_frame[0];
854 i1_cur_ref1 = ps_cur_mv_pred->i1_ref_frame[1];
855
856 i2_top_mv0 = ps_top_mv_pred->i2_mv[0];
857 i2_top_mv1 = ps_top_mv_pred->i2_mv[1];
858 i16_topMv2 = ps_top_mv_pred->i2_mv[2];
859 i16_topMv3 = ps_top_mv_pred->i2_mv[3];
860 pv_cur_pic_addr0 = ppv_map_ref_idx_to_poc_l0[i1_cur_ref0];
861 pv_cur_pic_addr1 = ppv_map_ref_idx_to_poc_l1[i1_cur_ref1];
862 if(edge)
863 {
864 WORD8 i1_top_ref0, i1_top_ref1;
865 i1_top_ref0 = ps_top_mv_pred->i1_ref_frame[0];
866 i1_top_ref1 = ps_top_mv_pred->i1_ref_frame[1];
867 pv_nbr_pic_addr0 = ppv_map_ref_idx_to_poc_l0[i1_top_ref0];
868 pv_nbr_pic_addr1 = ppv_map_ref_idx_to_poc_l1[i1_top_ref1];
869 }
870 else
871 {
872 pv_nbr_pic_addr0 = u4_pic_addrress[i & 2];
873 pv_nbr_pic_addr1 = u4_pic_addrress[1 + (i & 2)];
874 }
875
876 {
877 UWORD32 u4_bs_temp1, u4_bs_temp2;
878 UWORD32 u4_bs;
879 /*********************************************************/
880 /* If any motion vector component differs by more than 1 */
881 /* integer pel or if reference pictures are different Bs */
882 /* is set to 1. Note that this condition shall be met for*/
883 /* both (fwd-fwd,bwd-bwd) and (fwd-bwd,bwd-fwd) direction*/
884 /*********************************************************/
885
886 u4_bs_temp1 =
887 ((ABS((i2_top_mv0 - i2_cur_mv0))
888 >= 4)
889 | (ABS((i2_top_mv1
890 - i2_cur_mv1))
891 >= i4_ver_mvlimit)
892 | (ABS((i16_topMv2
893 - i16_curMv2))
894 >= 4)
895 | (ABS((i16_topMv3
896 - i16_curMv3))
897 >= i4_ver_mvlimit));
898
899 u4_bs_temp2 =
900 ((ABS((i2_top_mv0 - i16_curMv2))
901 >= 4)
902 | (ABS((i2_top_mv1
903 - i16_curMv3))
904 >= i4_ver_mvlimit)
905 | (ABS((i16_topMv2
906 - i2_cur_mv0))
907 >= 4)
908 | (ABS((i16_topMv3
909 - i2_cur_mv1))
910 >= i4_ver_mvlimit));
911
912 u4_bs =
913 ((pv_nbr_pic_addr0 != pv_cur_pic_addr0)
914 || (pv_nbr_pic_addr1
915 != pv_cur_pic_addr1)
916 || u4_bs_temp1)
917 && ((pv_nbr_pic_addr0
918 != pv_cur_pic_addr1)
919 || (pv_nbr_pic_addr1
920 != pv_cur_pic_addr0)
921 || u4_bs_temp2);
922
923 u4_bs_horz |= (u4_bs << u4_horz_idx);
924 }
925 }
926
927 ps_left_mv_pred = ps_cur_mv_pred;
928 }
929
930 pu4_bs_table[edge] = u4_bs_horz;
931 }
932}
933
934/*****************************************************************************/
935/* */
936/* Function Name : ih264d_fill_bs_xtra_left_edge_cur_fld */
937/* */
938/* Description : This function fills boundray strength (= 2 or 1) for */
939/* xtra left mb edge when cur mb is field and left mb is */
940/* frame. */
941/* Inputs : */
942/* */
943/* Globals : <Does it use any global variables?> */
944/* Processing : */
945/* */
946/* */
947/* Outputs : <What does the function produce?> */
948/* Returns : <What does the function return?> */
949/* */
950/* Issues : <List any issues or problems with this function> */
951/* */
952/* Revision History: */
953/* */
954/* DD MM YYYY Author(s) Changes (Describe the changes made) */
955/* 16 10 2008 Jay Draft */
956/* */
957/*****************************************************************************/
958void ih264d_fill_bs_xtra_left_edge_cur_fld(UWORD32 *pu4_bs, /* Base pointer of BS table */
959 WORD32 u4_left_mb_t_csbp, /* left mbpair's top csbp */
960 WORD32 u4_left_mb_b_csbp, /* left mbpair's bottom csbp*/
961 WORD32 u4_cur_mb_csbp, /* csbp of current mb */
962 UWORD32 u4_cur_mb_top /* is top or bottom mb */
963
964 )
965{
966 const UWORD32 *pu4_packed_bs = (const UWORD32 *)gau4_ih264d_packed_bs2;
967 UWORD32 u4_cur, u4_left, u4_or;
968 UNUSED(u4_cur_mb_top);
969
970 PROFILE_DISABLE_BOUNDARY_STRENGTH()
971
972 u4_left_mb_t_csbp = ((u4_left_mb_t_csbp & 0x0008) >> 3)
973 + ((u4_left_mb_t_csbp & 0x0080) >> 6)
974 + ((u4_left_mb_t_csbp & 0x0800) >> 9)
975 + ((u4_left_mb_t_csbp & 0x8000) >> 12);
976
977 u4_left_mb_b_csbp = ((u4_left_mb_b_csbp & 0x0008) << 1)
978 + ((u4_left_mb_b_csbp & 0x0080) >> 2)
979 + ((u4_left_mb_b_csbp & 0x0800) >> 5)
980 + ((u4_left_mb_b_csbp & 0x8000) >> 8);
981
982 /*********************************************************************/
983 /* u4_cur = 0|0|0|0|0|0|0|0|12C|12C|8C|8C|4C|4C|0C|0C */
984 /*********************************************************************/
985 u4_cur = (u4_cur_mb_csbp & 0x0001) + ((u4_cur_mb_csbp & 0x0001) << 1)
986 + ((u4_cur_mb_csbp & 0x0010) >> 2)
987 + ((u4_cur_mb_csbp & 0x0010) >> 1)
988 + ((u4_cur_mb_csbp & 0x0100) >> 4)
989 + ((u4_cur_mb_csbp & 0x0100) >> 3)
990 + ((u4_cur_mb_csbp & 0x1000) >> 6)
991 + ((u4_cur_mb_csbp & 0x1000) >> 5);
992
993 /*********************************************************************/
994 /* u4_left =0|0|0|0|0|0|0|0|15Lb|11Lb|7Lb|3Lb|15Lt|11Lt|7Lt|3Lt */
995 /*********************************************************************/
996 u4_left = u4_left_mb_t_csbp + u4_left_mb_b_csbp;
997
998 u4_or = (u4_cur | u4_left);
999 /*********************************************************************/
1000 /* Fill vert edges (4,9) boundary strengths using look up table */
1001 /*********************************************************************/
1002 pu4_packed_bs += 16;
1003 pu4_bs[4] = pu4_packed_bs[u4_or & 0xF];
1004 pu4_bs[9] = pu4_packed_bs[(u4_or >> 4)];
1005}
1006
1007/*****************************************************************************/
1008/* */
1009/* Function Name : ih264d_fill_bs_xtra_left_edge_cur_frm */
1010/* */
1011/* Description : This function fills boundray strength (= 2 or 1) for */
1012/* xtra left mb edge when cur mb is frame and left mb is */
1013/* field. */
1014/* Inputs : */
1015/* */
1016/* Globals : <Does it use any global variables?> */
1017/* Processing : */
1018/* */
1019/* */
1020/* Outputs : <What does the function produce?> */
1021/* Returns : <What does the function return?> */
1022/* */
1023/* Issues : <List any issues or problems with this function> */
1024/* */
1025/* Revision History: */
1026/* */
1027/* DD MM YYYY Author(s) Changes (Describe the changes made) */
1028/* 16 10 2008 Jay Draft */
1029/* */
1030/*****************************************************************************/
1031void ih264d_fill_bs_xtra_left_edge_cur_frm(UWORD32 *pu4_bs, /* Base pointer of BS table */
1032 WORD32 u4_left_mb_t_csbp, /* left mbpair's top csbp */
1033 WORD32 u4_left_mb_b_csbp, /* left mbpair's bottom csbp*/
1034 WORD32 u4_cur_mb_csbp, /* csbp of current mb */
1035 UWORD32 u4_cur_mb_bot /* is top or bottom mb */
1036
1037 )
1038{
1039 const UWORD32 *pu4_packed_bs = (const UWORD32 *)gau4_ih264d_packed_bs2;
1040 UWORD32 u4_cur, u4_left, u4_or;
1041 UWORD32 u4_right_shift = (u4_cur_mb_bot << 3);
1042
1043 PROFILE_DISABLE_BOUNDARY_STRENGTH()
1044
1045 u4_left_mb_t_csbp >>= u4_right_shift;
1046 u4_left_mb_b_csbp >>= u4_right_shift;
1047
1048 u4_left_mb_t_csbp = ((u4_left_mb_t_csbp & 0x08) >> 3)
1049 + ((u4_left_mb_t_csbp & 0x08) >> 2)
1050 + ((u4_left_mb_t_csbp & 0x80) >> 5)
1051 + ((u4_left_mb_t_csbp & 0x80) >> 4);
1052
1053 u4_left_mb_b_csbp = ((u4_left_mb_b_csbp & 0x08) << 1)
1054 + ((u4_left_mb_b_csbp & 0x08) << 2)
1055 + ((u4_left_mb_b_csbp & 0x80) >> 1)
1056 + ((u4_left_mb_b_csbp & 0x80));
1057
1058 u4_cur = ((u4_cur_mb_csbp & 0x0001)) + ((u4_cur_mb_csbp & 0x0010) >> 3)
1059 + ((u4_cur_mb_csbp & 0x0100) >> 6)
1060 + ((u4_cur_mb_csbp & 0x1000) >> 9);
1061
1062 u4_cur += (u4_cur << 4);
1063
1064 u4_left = u4_left_mb_t_csbp + u4_left_mb_b_csbp;
1065
1066 u4_or = (u4_cur | u4_left);
1067 /*********************************************************************/
1068 /* Fill vert edges (4,9) boundary strengths using look up table */
1069 /*********************************************************************/
1070 pu4_packed_bs += 16;
1071 pu4_bs[4] = pu4_packed_bs[u4_or & 0xF];
1072 pu4_bs[9] = pu4_packed_bs[(u4_or >> 4)];
1073}
1074
1075/*****************************************************************************/
1076/* */
1077/* Function Name : ih264d_fill_bs_xtra_top_edge */
1078/* */
1079/* Description : This function fills boundray strength (= 2 or 1) for */
1080/* xtra top mb edge when cur mb is top mb of frame mb pair */
1081/* and top mbpair is field coded. */
1082/* Inputs : */
1083/* */
1084/* Globals : <Does it use any global variables?> */
1085/* Processing : */
1086/* */
1087/* */
1088/* Outputs : <What does the function produce?> */
1089/* Returns : <What does the function return?> */
1090/* */
1091/* Issues : <List any issues or problems with this function> */
1092/* */
1093/* Revision History: */
1094/* */
1095/* DD MM YYYY Author(s) Changes (Describe the changes made) */
1096/* 16 10 2008 Jay Draft */
1097/* */
1098/*****************************************************************************/
1099void ih264d_fill_bs_xtra_top_edge(UWORD32 *pu4_bs, /* Base pointer of BS table */
1100 WORD32 u4_topmb_t_csbp, /* top mbpair's top csbp */
1101 WORD32 u4_topmb_b_csbp, /* top mbpair's bottom csbp*/
1102 WORD32 u4_cur_mb_csbp /* csbp of current mb */
1103
1104 )
1105{
1106 const UWORD32 *pu4_packed_bs = (const UWORD32 *)gau4_ih264d_packed_bs2;
1107 UWORD32 u4_or;
1108
1109 u4_cur_mb_csbp &= 0xf;
1110 u4_topmb_t_csbp >>= 12;
1111 u4_topmb_b_csbp >>= 12;
1112
1113 u4_or = (u4_cur_mb_csbp | u4_topmb_t_csbp);
1114 /*********************************************************************/
1115 /* Fill vert edges (0,8) boundary strengths using look up table */
1116 /*********************************************************************/
1117 pu4_packed_bs += 16;
1118 pu4_bs[8] = pu4_packed_bs[u4_or];
1119
1120 u4_or = (u4_cur_mb_csbp | u4_topmb_b_csbp);
1121 pu4_bs[0] = pu4_packed_bs[u4_or];
1122}
1123
1124/*****************************************************************************/
1125/* */
1126/* Function Name : ih264d_compute_bs_non_mbaff */
1127/* */
1128/* Description : This function computes the pointers of left,top & current*/
1129/* : Nnz, MvPred & deblk_mb_t and supplies to FillBs function for*/
1130/* : Boundary Strength Calculation */
1131/* Inputs : <What inputs does the function take?> */
1132/* Processing : This functions calls deblock MB in the MB increment order*/
1133/* */
1134/* Outputs : Produces the Boundary Strength for Current Mb */
1135/* Returns : None */
1136/* */
1137/* Revision History: */
1138/* */
1139/* DD MM YYYY Author(s) Changes (Describe the changes made) */
1140/* ITTIAM */
1141/*****************************************************************************/
1142
1143void ih264d_compute_bs_non_mbaff(dec_struct_t * ps_dec,
1144 dec_mb_info_t * ps_cur_mb_info,
1145 const UWORD16 u2_mbxn_mb)
1146{
1147 /* Mvpred and Nnz for top and Courrent */
1148 mv_pred_t *ps_cur_mv_pred, *ps_top_mv_pred = NULL, *ps_left_mv_pred;
1149 /* deblk_mb_t Params */
1150 deblk_mb_t *ps_cur_mb_params; /*< Parameters of current MacroBlock */
1151 deblkmb_neighbour_t *ps_deblk_top_mb;
1152
1153 /* Reference Index to POC mapping*/
1154 void ** apv_map_ref_idx_to_poc;
1155 UWORD32 u4_leftmbtype;
1156
1157 UWORD16 u2_left_csbp, u2_top_csbp, u2_cur_csbp;
1158
1159 /* Set of flags */
1160 UWORD32 u4_cur_mb_intra, u1_top_mb_typ, u4_cur_mb_fld;
1161 UWORD32 u1_cur_mb_type;
1162 UWORD32 * pu4_bs_table;
1163
1164 /* Neighbour availability */
1165 /* Initialization */
1166 const UWORD32 u2_mbx = ps_cur_mb_info->u2_mbx;
1167 const UWORD32 u2_mby = ps_cur_mb_info->u2_mby;
1168 const UWORD32 u1_pingpong = u2_mbx & 0x01;
1169
1170 PROFILE_DISABLE_BOUNDARY_STRENGTH()
1171
1172 ps_deblk_top_mb = ps_dec->ps_deblk_top_mb + u2_mbx;
1173
1174
1175 /* Pointer assignment for Current DeblkMB, Current Mv Pred */
1176 ps_cur_mb_params = ps_dec->ps_deblk_mbn + u2_mbxn_mb;
1177 ps_cur_mv_pred = ps_dec->ps_mv_cur + (u2_mbxn_mb << 4);
1178
1179 apv_map_ref_idx_to_poc = ps_dec->ppv_map_ref_idx_to_poc + 1;
1180 u1_cur_mb_type = ps_cur_mb_params->u1_mb_type;
1181 u1_top_mb_typ = ps_deblk_top_mb->u1_mb_type;
1182 ps_deblk_top_mb->u1_mb_type = u1_cur_mb_type;
1183
1184 {
1185 UWORD8 mb_qp_temp;
1186
1187 ps_cur_mb_params->u1_topmb_qp = ps_deblk_top_mb->u1_mb_qp;
1188 ps_deblk_top_mb->u1_mb_qp = ps_cur_mb_params->u1_mb_qp;
1189
1190 ps_cur_mb_params->u1_left_mb_qp = ps_dec->deblk_left_mb[1].u1_mb_qp;
1191 ps_dec->deblk_left_mb[1].u1_mb_qp = ps_cur_mb_params->u1_mb_qp;
1192
1193 }
1194
1195 /* if no deblocking required for current Mb then continue */
1196 /* Check next Mbs in Mb group */
1197 if(ps_cur_mb_params->u1_deblocking_mode & MB_DISABLE_FILTERING)
1198 {
1199 void ** pu4_map_ref_idx_to_poc_l1 = apv_map_ref_idx_to_poc +
1200 POC_LIST_L0_TO_L1_DIFF;
1201 {
1202 /* Store Parameter for Top MvPred refernce frame Address */
1203
1204 void ** ppv_top_mv_pred_addr = ps_cur_mb_info->ps_curmb->u4_pic_addrress;
1205 WORD8 * p1_refTop0 = (ps_cur_mv_pred + 12)->i1_ref_frame;
1206 WORD8 * p1_refTop1 = (ps_cur_mv_pred + 14)->i1_ref_frame;
1207
1208 /* Store Left addresses for Next Mb */
1209 void ** ppv_left_mv_pred_addr =
1210 ps_dec->ps_left_mvpred_addr[!u1_pingpong][1].u4_add;
1211 WORD8 * p1_refleft0 = (ps_cur_mv_pred + 3)->i1_ref_frame;
1212
1213
1214 ppv_top_mv_pred_addr[0] = apv_map_ref_idx_to_poc[p1_refTop0[0]];
1215 ppv_top_mv_pred_addr[1] = pu4_map_ref_idx_to_poc_l1[p1_refTop0[1]];
1216
1217 ppv_left_mv_pred_addr[2] = apv_map_ref_idx_to_poc[p1_refTop1[0]];
1218 ppv_top_mv_pred_addr[2] = apv_map_ref_idx_to_poc[p1_refTop1[0]];
1219 ppv_left_mv_pred_addr[3] = pu4_map_ref_idx_to_poc_l1[p1_refTop1[1]];
1220 ppv_top_mv_pred_addr[3] = pu4_map_ref_idx_to_poc_l1[p1_refTop1[1]];
1221
1222 ppv_left_mv_pred_addr[0] = apv_map_ref_idx_to_poc[p1_refleft0[0]];
1223 ppv_left_mv_pred_addr[1] = pu4_map_ref_idx_to_poc_l1[p1_refleft0[1]];
1224 //}
1225 /* Storing the leftMbtype for next Mb */
1226 ps_dec->deblk_left_mb[1].u1_mb_type = ps_cur_mb_params->u1_mb_type;
1227 }
1228
1229 return;
1230 }
1231
1232 /* Flag for extra left Edge */
1233 ps_cur_mb_params->u1_single_call = 1;
1234
1235 /* Update the Left deblk_mb_t and Left MvPred Parameters */
1236 if(!u2_mbx)
1237 {
1238 u4_leftmbtype = 0;
1239
1240 /* Initialize the ps_left_mv_pred with Junk but Valid Location */
1241 /* to avoid invalid memory access */
1242 /* this is read only pointer */
1243 ps_left_mv_pred = ps_dec->ps_mv_cur + 3;
1244 }
1245 else
1246 {
1247 u4_leftmbtype = ps_dec->deblk_left_mb[1].u1_mb_type;
1248
1249 /* Come to Left Most Edge of the MB */
1250 ps_left_mv_pred = (u2_mbxn_mb) ?
1251 ps_dec->ps_mv_cur + ((u2_mbxn_mb - 1) << 4) + 3 :
1252 ps_dec->ps_mv_left + 3;
1253 }
1254
1255 if(!u2_mby)
1256 u1_top_mb_typ = 0;
1257
1258 /* MvPred Pointer Calculation */
1259 /* CHANGED CODE */
1260 ps_top_mv_pred = ps_cur_mv_pred - (ps_dec->u2_frm_wd_in_mbs << 4) + 12;
1261
1262 u4_cur_mb_intra = u1_cur_mb_type & D_INTRA_MB;
1263 u4_cur_mb_fld = !!(u1_cur_mb_type & D_FLD_MB);
1264 /* Compute BS function */
1265 pu4_bs_table = ps_cur_mb_params->u4_bs_table;
1266
1267 u2_cur_csbp = ps_cur_mb_info->ps_curmb->u2_luma_csbp;
1268 u2_left_csbp = ps_cur_mb_info->ps_left_mb->u2_luma_csbp;
1269 u2_top_csbp = ps_cur_mb_info->ps_top_mb->u2_luma_csbp;
1270 /* Compute BS function */
1271 if(ps_dec->ps_cur_sps->u1_profile_idc == HIGH_PROFILE_IDC)
1272 {
1273 if(ps_cur_mb_info->u1_tran_form8x8 == 1)
1274 {
1275 u2_cur_csbp = ih264d_update_csbp_8x8(
1276 ps_cur_mb_info->ps_curmb->u2_luma_csbp);
1277 }
1278
1279 if(ps_cur_mb_info->ps_left_mb->u1_tran_form8x8 == 1)
1280 {
1281 u2_left_csbp = ih264d_update_csbp_8x8(
1282 ps_cur_mb_info->ps_left_mb->u2_luma_csbp);
1283 }
1284
1285 if(ps_cur_mb_info->ps_top_mb->u1_tran_form8x8 == 1)
1286 {
1287 u2_top_csbp = ih264d_update_csbp_8x8(
1288 ps_cur_mb_info->ps_top_mb->u2_luma_csbp);
1289 }
1290 }
1291 if(u4_cur_mb_intra)
1292 {
1293
1294 pu4_bs_table[4] = 0x04040404;
1295 pu4_bs_table[0] = u4_cur_mb_fld ? 0x03030303 : 0x04040404;
1296 pu4_bs_table[1] = 0x03030303;
1297 pu4_bs_table[2] = 0x03030303;
1298 pu4_bs_table[3] = 0x03030303;
1299 pu4_bs_table[5] = 0x03030303;
1300 pu4_bs_table[6] = 0x03030303;
1301 pu4_bs_table[7] = 0x03030303;
1302 }
1303 else
1304 {
1305 UWORD32 u4_is_non16x16 = !!(u1_cur_mb_type & D_PRED_NON_16x16);
1306 UWORD32 u4_is_b = ps_dec->u1_B;
1307
1308 ih264d_fill_bs2_horz_vert(
1309 pu4_bs_table, u2_left_csbp, u2_top_csbp, u2_cur_csbp,
1310 (const UWORD32 *)(gau4_ih264d_packed_bs2),
1311 (const UWORD16 *)(gau2_ih264d_4x4_v2h_reorder));
1312
1313 if(u4_leftmbtype & D_INTRA_MB)
1314 pu4_bs_table[4] = 0x04040404;
1315
1316 if(u1_top_mb_typ & D_INTRA_MB)
1317 pu4_bs_table[0] = u4_cur_mb_fld ? 0x03030303 : 0x04040404;
1318
1319 ps_dec->pf_fill_bs1[u4_is_b][u4_is_non16x16](
1320 ps_cur_mv_pred, ps_top_mv_pred, apv_map_ref_idx_to_poc,
1321 pu4_bs_table, ps_left_mv_pred,
1322 &(ps_dec->ps_left_mvpred_addr[u1_pingpong][1]),
1323 ps_cur_mb_info->ps_top_mb->u4_pic_addrress,
1324 (4 >> u4_cur_mb_fld));
1325 }
1326
1327 {
1328 void ** pu4_map_ref_idx_to_poc_l1 = apv_map_ref_idx_to_poc +
1329 POC_LIST_L0_TO_L1_DIFF;
1330 {
1331 /* Store Parameter for Top MvPred refernce frame Address */
1332
1333 void ** ppv_top_mv_pred_addr = ps_cur_mb_info->ps_curmb->u4_pic_addrress;
1334 WORD8 * p1_refTop0 = (ps_cur_mv_pred + 12)->i1_ref_frame;
1335 WORD8 * p1_refTop1 = (ps_cur_mv_pred + 14)->i1_ref_frame;
1336
1337 /* Store Left addresses for Next Mb */
1338 void ** ppv_left_mv_pred_addr =
1339 ps_dec->ps_left_mvpred_addr[!u1_pingpong][1].u4_add;
1340 WORD8 * p1_refleft0 = (ps_cur_mv_pred + 3)->i1_ref_frame;
1341
1342 ppv_top_mv_pred_addr[0] = apv_map_ref_idx_to_poc[p1_refTop0[0]];
1343 ppv_top_mv_pred_addr[1] = pu4_map_ref_idx_to_poc_l1[p1_refTop0[1]];
1344
1345 ppv_left_mv_pred_addr[2] = apv_map_ref_idx_to_poc[p1_refTop1[0]];
1346 ppv_top_mv_pred_addr[2] = apv_map_ref_idx_to_poc[p1_refTop1[0]];
1347 ppv_left_mv_pred_addr[3] = pu4_map_ref_idx_to_poc_l1[p1_refTop1[1]];
1348 ppv_top_mv_pred_addr[3] = pu4_map_ref_idx_to_poc_l1[p1_refTop1[1]];
1349
1350 ppv_left_mv_pred_addr[0] = apv_map_ref_idx_to_poc[p1_refleft0[0]];
1351 ppv_left_mv_pred_addr[1] = pu4_map_ref_idx_to_poc_l1[p1_refleft0[1]];
1352
1353 /* Storing the leftMbtype for next Mb */
1354 ps_dec->deblk_left_mb[1].u1_mb_type = ps_cur_mb_params->u1_mb_type;
1355
1356 }
1357 }
1358
1359 /* For transform 8x8 disable deblocking of the intrernal edges of a 8x8 block */
1360 if(ps_cur_mb_info->u1_tran_form8x8)
1361 {
1362 pu4_bs_table[1] = 0;
1363 pu4_bs_table[3] = 0;
1364 pu4_bs_table[5] = 0;
1365 pu4_bs_table[7] = 0;
1366 }
1367}
1368
1369/*****************************************************************************/
1370/* */
1371/* Function Name : ih264d_compute_bs_mbaff */
1372/* */
1373/* Description : This function computes the pointers of left,top & current*/
1374/* : Nnz, MvPred & deblk_mb_t and supplies to FillBs function for*/
1375/* : Boundary Strength Calculation */
1376/* Inputs : <What inputs does the function take?> */
1377/* Processing : This functions calls deblock MB in the MB increment order*/
1378/* */
1379/* Outputs : Produces the Boundary Strength for Current Mb */
1380/* Returns : None */
1381/* */
1382/* Revision History: */
1383/* */
1384/* DD MM YYYY Author(s) Changes (Describe the changes made) */
1385/* ITTIAM */
1386/*****************************************************************************/
1387
1388void ih264d_compute_bs_mbaff(dec_struct_t * ps_dec,
1389 dec_mb_info_t * ps_cur_mb_info,
1390 const UWORD16 u2_mbxn_mb)
1391{
1392 /* Mvpred and Nnz for top and Courrent */
1393 mv_pred_t *ps_cur_mv_pred, *ps_top_mv_pred = NULL, *ps_left_mv_pred;
1394 /* deblk_mb_t Params */
1395 deblk_mb_t *ps_cur_mb_params; /*< Parameters of current MacroBlock */
1396 neighbouradd_t * ps_left_ngbr;
1397 deblkmb_neighbour_t *ps_deblk_top_mb;
1398 /* Reference Index to POC mapping*/
1399 void ** apv_map_ref_idx_to_poc;
1400
1401 UWORD32 u4_leftmbtype;
1402
1403
1404 UWORD16 u2_left_csbp, u2_top_csbp, u2_cur_csbp;
1405
1406 /* Set of flags */
1407 UWORD32 u4_cur_mb_intra, u4_cur_mb_fld, u4_top_mb_fld, u1_top_mb_typ, u4_left_mb_fld;
1408 UWORD32 u1_cur_mb_type;
1409 UWORD32 * pu4_bs_table;
1410 const UWORD32 u4_bot_mb = (1 - ps_cur_mb_info->u1_topmb);
1411 /* Initialization */
1412 const UWORD32 u2_mbx = ps_cur_mb_info->u2_mbx;
1413 const UWORD32 u2_mby = ps_cur_mb_info->u2_mby;
1414 /* Load From u1_pingpong and Store in !u1_pingpong */
1415 const UWORD32 u1_pingpong = u2_mbx & 0x01;
1416
1417 PROFILE_DISABLE_BOUNDARY_STRENGTH()
1418
1419 ps_deblk_top_mb = ps_dec->ps_deblk_top_mb + (u2_mbx << 1);
1420
1421
1422 /************************************************/
1423 /* Initialize the left Mb type */
1424 /* Left MvPred */
1425 /************************************************/
1426
1427 if(!u2_mbx)
1428 {
1429 /************************************************************/
1430 /* Initialize the ps_left_mv_pred with Junk but Valid Location */
1431 /* to avoid invalid memory access */
1432 /* this is read only pointer */
1433 /************************************************************/
1434 ps_left_mv_pred = ps_dec->ps_mv_cur + 16;
1435 }
1436 else
1437 {
1438 /* Come to Left Most Edge of the MB */
1439 ps_left_mv_pred = (u2_mbxn_mb) ?
1440 ps_dec->ps_mv_cur + ((u2_mbxn_mb - 1) << 5) + 3 :
1441 ps_dec->ps_mv_left + 3;
1442
1443 ps_left_mv_pred += (u4_bot_mb << 4);
1444 }
1445
1446 u4_leftmbtype = ps_dec->deblk_left_mb[u4_bot_mb].u1_mb_type;
1447
1448 ps_left_ngbr = &(ps_dec->ps_left_mvpred_addr[u1_pingpong][u4_bot_mb]);
1449
1450 /************************************************/
1451 /* Pointer Assignment for Current Mb Parameters */
1452 /* Pointer Assignment for Current MvPred */
1453 /************************************************/
1454 ps_cur_mb_params = ps_dec->ps_deblk_mbn + (u2_mbxn_mb << 1) + u4_bot_mb;
1455 u1_cur_mb_type = ps_cur_mb_params->u1_mb_type;
1456
1457 ps_cur_mv_pred = ps_dec->ps_mv_cur + (u2_mbxn_mb << 5);
1458 ps_cur_mv_pred += (u4_bot_mb << 4);
1459
1460 /********************************************/
1461 /* Pointer Assignment for Top Mb Parameters */
1462 /* Pointer Assignment for Top MvPred and */
1463 /* Pointer Assignment for Top Nnz */
1464 /********************************************/
1465
1466 /* CHANGED CODE */
1467 ps_top_mv_pred = ps_cur_mv_pred - (ps_dec->u2_frm_wd_in_mbs << 5) + 12;
1468
1469 u4_cur_mb_fld = !!(u1_cur_mb_type & D_FLD_MB);
1470 u4_left_mb_fld = !!(ps_dec->deblk_left_mb[0].u1_mb_type & D_FLD_MB);
1471
1472 if(u4_left_mb_fld != u4_cur_mb_fld)
1473 {
1474 /* Flag for extra left Edge */
1475 ps_cur_mb_params->u1_single_call = 0;
1476
1477 if(u4_bot_mb)
1478 {
1479 ps_left_ngbr--;
1480 ps_left_mv_pred -= 16;
1481 }
1482 }
1483 else
1484 ps_cur_mb_params->u1_single_call = 1;
1485
1486 apv_map_ref_idx_to_poc = ps_dec->ppv_map_ref_idx_to_poc + 1;
1487 if(u4_cur_mb_fld)
1488 {
1489 if(u4_bot_mb)
1490 {
1491 apv_map_ref_idx_to_poc += BOT_LIST_FLD_L0;
1492 }
1493 else
1494 {
1495 apv_map_ref_idx_to_poc += TOP_LIST_FLD_L0;
1496 }
1497 }
1498
1499 /**********************************************************/
1500 /* if no deblocking required for current Mb then continue */
1501 /**********************************************************/
1502 if(ps_cur_mb_params->u1_deblocking_mode & MB_DISABLE_FILTERING)
1503 {
1504 void ** pu4_map_ref_idx_to_poc_l1 = apv_map_ref_idx_to_poc +
1505 POC_LIST_L0_TO_L1_DIFF;
1506
1507 {
1508 /* Store Parameter for Top MvPred refernce frame Address */
1509
1510 void ** ppv_top_mv_pred_addr = ps_cur_mb_info->ps_curmb->u4_pic_addrress;
1511 void ** ppv_left_mv_pred_addr =
1512 ps_dec->ps_left_mvpred_addr[!u1_pingpong][u4_bot_mb].u4_add;
1513 WORD8 * p1_refTop0 = (ps_cur_mv_pred + 12)->i1_ref_frame;
1514 WORD8 * p1_refTop1 = (ps_cur_mv_pred + 14)->i1_ref_frame;
1515 WORD8 * p1_refLeft0 = (ps_cur_mv_pred + 3)->i1_ref_frame;
1516 ppv_top_mv_pred_addr[0] = apv_map_ref_idx_to_poc[p1_refTop0[0]];
1517 ppv_top_mv_pred_addr[1] = pu4_map_ref_idx_to_poc_l1[p1_refTop0[1]];
1518 ppv_left_mv_pred_addr[2] = apv_map_ref_idx_to_poc[p1_refTop1[0]];
1519 ppv_top_mv_pred_addr[2] = apv_map_ref_idx_to_poc[p1_refTop1[0]];
1520 ppv_left_mv_pred_addr[3] = pu4_map_ref_idx_to_poc_l1[p1_refTop1[1]];
1521 ppv_top_mv_pred_addr[3] = pu4_map_ref_idx_to_poc_l1[p1_refTop1[1]];
1522 ppv_left_mv_pred_addr[0] = apv_map_ref_idx_to_poc[p1_refLeft0[0]];
1523 ppv_left_mv_pred_addr[1] = pu4_map_ref_idx_to_poc_l1[p1_refLeft0[1]];
1524 }
1525 if(u4_bot_mb)
1526 {
1527 /* store The Left Mb Type*/
1528 ps_dec->deblk_left_mb[0].u1_mb_type =
1529 (ps_cur_mb_params - 1)->u1_mb_type;
1530 ps_dec->deblk_left_mb[1].u1_mb_type = ps_cur_mb_params->u1_mb_type;
1531
1532 }
1533 ps_deblk_top_mb[u4_bot_mb].u1_mb_type = u1_cur_mb_type;
1534 return;
1535 }
1536
1537 if(u2_mby)
1538 {
1539 u1_top_mb_typ = ps_deblk_top_mb[1].u1_mb_type;
1540 u4_top_mb_fld = !!(u1_top_mb_typ & D_FLD_MB);
1541
1542 if(!u4_bot_mb)
1543 {
1544 if(u4_top_mb_fld & u4_cur_mb_fld)
1545 u1_top_mb_typ = ps_deblk_top_mb[0].u1_mb_type;
1546 else
1547 {
1548 ps_top_mv_pred += 16;
1549 }
1550 }
1551 }
1552 else
1553 {
1554 u4_top_mb_fld = u4_cur_mb_fld;
1555 u1_top_mb_typ = 0;
1556 }
1557
1558 if(u4_bot_mb & !u4_cur_mb_fld)
1559 {
1560 u1_top_mb_typ = ps_deblk_top_mb[0].u1_mb_type;
1561 u4_top_mb_fld = u4_cur_mb_fld;
1562 ps_top_mv_pred = ps_cur_mv_pred - 4;
1563 }
1564
1565 pu4_bs_table = ps_cur_mb_params->u4_bs_table;
1566 u4_cur_mb_intra = u1_cur_mb_type & D_INTRA_MB;
1567
1568 u2_cur_csbp = ps_cur_mb_info->ps_curmb->u2_luma_csbp;
1569 u2_left_csbp = ps_cur_mb_info->ps_left_mb->u2_luma_csbp;
1570 u2_top_csbp = ps_cur_mb_info->ps_top_mb->u2_luma_csbp;
1571 /* Compute BS function */
1572 if(ps_dec->ps_cur_sps->u1_profile_idc == HIGH_PROFILE_IDC)
1573 {
1574
1575 if(ps_cur_mb_info->u1_tran_form8x8 == 1)
1576 {
1577 u2_cur_csbp = ih264d_update_csbp_8x8(
1578 ps_cur_mb_info->ps_curmb->u2_luma_csbp);
1579 }
1580
1581 if(ps_cur_mb_info->ps_left_mb->u1_tran_form8x8 == 1)
1582 {
1583 u2_left_csbp = ih264d_update_csbp_8x8(
1584 ps_cur_mb_info->ps_left_mb->u2_luma_csbp);
1585 }
1586
1587 if(ps_cur_mb_info->ps_top_mb->u1_tran_form8x8 == 1)
1588 {
1589 u2_top_csbp = ih264d_update_csbp_8x8(
1590 ps_cur_mb_info->ps_top_mb->u2_luma_csbp);
1591 }
1592 }
1593 if(u4_cur_mb_intra)
1594 {
1595
1596 pu4_bs_table[4] = 0x04040404;
1597 if((0 == u4_cur_mb_fld) && (0 == u4_top_mb_fld))
1598 {
1599 pu4_bs_table[0] = 0x04040404;
1600 }
1601 else
1602 {
1603 pu4_bs_table[0] = 0x03030303;
1604 }
1605
1606 pu4_bs_table[1] = 0x03030303;
1607 pu4_bs_table[2] = 0x03030303;
1608 pu4_bs_table[3] = 0x03030303;
1609 pu4_bs_table[5] = 0x03030303;
1610 pu4_bs_table[6] = 0x03030303;
1611 pu4_bs_table[7] = 0x03030303;
1612
1613 /*********************************************************************/
1614 /* Fill Bs of xtra top and left edge unconditionally to avoid checks */
1615 /*********************************************************************/
1616 pu4_bs_table[8] = 0x03030303;
1617 pu4_bs_table[9] = 0x04040404;
1618 }
1619 else
1620 {
1621 UWORD32 u4_is_non16x16 = !!(u1_cur_mb_type & D_PRED_NON_16x16);
1622 UWORD32 u4_is_b = ps_dec->u1_B;
1623
1624 ih264d_fill_bs2_horz_vert(
1625 pu4_bs_table, u2_left_csbp, u2_top_csbp, u2_cur_csbp,
1626 (const UWORD32 *)(gau4_ih264d_packed_bs2),
1627 (const UWORD16 *)(gau2_ih264d_4x4_v2h_reorder));
1628
1629 if(u4_leftmbtype & D_INTRA_MB)
1630 pu4_bs_table[4] = 0x04040404;
1631
1632 if(u1_top_mb_typ & D_INTRA_MB)
1633 pu4_bs_table[0] = u4_cur_mb_fld ? 0x03030303 : 0x04040404;
1634 else if(u4_cur_mb_fld != u4_top_mb_fld)
1635 {
1636 /****************************************************/
1637 /* Setting BS for mixed mode edge=1 when (Bs!=2) */
1638 /****************************************************/
1639 pu4_bs_table[0] = (pu4_bs_table[0] >> 1) + 0x01010101;
1640 }
1641
1642 {
1643 /* Call to Compute Boundary Strength for Extra Left Edge */
1644 if(u2_mbx
1645 && !(ps_cur_mb_params->u1_deblocking_mode
1646 & MB_DISABLE_LEFT_EDGE))
1647 {
1648 if(u4_cur_mb_fld != u4_left_mb_fld)
1649 {
1650 UWORD32 u4_left_mb_t_csbp =
1651 ps_cur_mb_info->ps_left_mb[0].u2_luma_csbp;
1652 UWORD32 u4_left_mb_b_csbp =
1653 ps_cur_mb_info->ps_left_mb[1].u2_luma_csbp;
1654 if(1 == ps_cur_mb_info->ps_left_mb[0].u1_tran_form8x8)
1655 {
1656 u4_left_mb_t_csbp = (UWORD32)ih264d_update_csbp_8x8(
1657 (UWORD16)u4_left_mb_t_csbp);
1658 }
1659
1660 if(1 == ps_cur_mb_info->ps_left_mb[1].u1_tran_form8x8)
1661 {
1662 u4_left_mb_b_csbp = (UWORD32)ih264d_update_csbp_8x8(
1663 (UWORD16)u4_left_mb_b_csbp);
1664 }
1665 ps_dec->pf_fill_bs_xtra_left_edge[u4_cur_mb_fld](
1666 pu4_bs_table, u4_left_mb_t_csbp,
1667 u4_left_mb_b_csbp, u2_cur_csbp, u4_bot_mb);
1668
1669 if(ps_dec->deblk_left_mb[0].u1_mb_type & D_INTRA_MB)
1670 pu4_bs_table[4] = 0x04040404;
1671
1672 if(ps_dec->deblk_left_mb[1].u1_mb_type & D_INTRA_MB)
1673 pu4_bs_table[9] = 0x04040404;
1674
1675 }
1676 }
1677 /* Call to Compute Boundary Strength for Extra Top Edge */
1678 if(u2_mby
1679 && !(ps_cur_mb_params->u1_deblocking_mode
1680 & MB_DISABLE_TOP_EDGE))
1681 {
1682 if((((!u4_bot_mb) & (!u4_cur_mb_fld)) && u4_top_mb_fld))
1683 {
1684 UWORD32 u4_topmb_t_csbp =
1685 ps_cur_mb_info->ps_top_mb[-1].u2_luma_csbp;
1686 UWORD32 u4_topmb_b_csbp =
1687 ps_cur_mb_info->ps_top_mb[0].u2_luma_csbp;
1688 if(1 == ps_cur_mb_info->ps_top_mb[-1].u1_tran_form8x8)
1689 {
1690 u4_topmb_t_csbp = (UWORD32)ih264d_update_csbp_8x8(
1691 (UWORD16)u4_topmb_t_csbp);
1692 }
1693
1694 if(1 == ps_cur_mb_info->ps_top_mb[0].u1_tran_form8x8)
1695 {
1696 u4_topmb_b_csbp = (UWORD32)ih264d_update_csbp_8x8(
1697 (UWORD16)u4_topmb_b_csbp);
1698 }
1699 ih264d_fill_bs_xtra_top_edge(pu4_bs_table, u4_topmb_t_csbp,
1700 u4_topmb_b_csbp, u2_cur_csbp);
1701
1702 if(ps_deblk_top_mb[0].u1_mb_type & D_INTRA_MB)
1703 pu4_bs_table[8] = 0x03030303;
1704
1705 if(ps_deblk_top_mb[1].u1_mb_type & D_INTRA_MB)
1706 pu4_bs_table[0] = 0x03030303;
1707 }
1708 }
1709 }
1710
1711 ps_dec->pf_fill_bs1[u4_is_b][u4_is_non16x16](
1712 ps_cur_mv_pred, ps_top_mv_pred, apv_map_ref_idx_to_poc,
1713 pu4_bs_table, ps_left_mv_pred, ps_left_ngbr,
1714 ps_cur_mb_info->ps_top_mb->u4_pic_addrress,
1715 (4 >> u4_cur_mb_fld));
1716 }
1717
1718 {
1719 void ** pu4_map_ref_idx_to_poc_l1 = apv_map_ref_idx_to_poc +
1720 POC_LIST_L0_TO_L1_DIFF;
1721
1722 {
1723 /* Store Parameter for Top MvPred refernce frame Address */
1724 void ** ppv_top_mv_pred_addr = ps_cur_mb_info->ps_curmb->u4_pic_addrress;
1725 void ** ppv_left_mv_pred_addr =
1726 ps_dec->ps_left_mvpred_addr[!u1_pingpong][u4_bot_mb].u4_add;
1727 WORD8 * p1_refTop0 = (ps_cur_mv_pred + 12)->i1_ref_frame;
1728 WORD8 * p1_refTop1 = (ps_cur_mv_pred + 14)->i1_ref_frame;
1729 WORD8 * p1_refLeft0 = (ps_cur_mv_pred + 3)->i1_ref_frame;
1730 ppv_top_mv_pred_addr[0] = apv_map_ref_idx_to_poc[p1_refTop0[0]];
1731 ppv_top_mv_pred_addr[1] = pu4_map_ref_idx_to_poc_l1[p1_refTop0[1]];
1732 ppv_left_mv_pred_addr[2] = apv_map_ref_idx_to_poc[p1_refTop1[0]];
1733 ppv_top_mv_pred_addr[2] = apv_map_ref_idx_to_poc[p1_refTop1[0]];
1734 ppv_left_mv_pred_addr[3] = pu4_map_ref_idx_to_poc_l1[p1_refTop1[1]];
1735 ppv_top_mv_pred_addr[3] = pu4_map_ref_idx_to_poc_l1[p1_refTop1[1]];
1736 ppv_left_mv_pred_addr[0] = apv_map_ref_idx_to_poc[p1_refLeft0[0]];
1737 ppv_left_mv_pred_addr[1] = pu4_map_ref_idx_to_poc_l1[p1_refLeft0[1]];
1738 }
1739 if(u4_bot_mb)
1740 {
1741 /* store The Left Mb Type*/
1742 ps_dec->deblk_left_mb[0].u1_mb_type =
1743 (ps_cur_mb_params - 1)->u1_mb_type;
1744 ps_dec->deblk_left_mb[1].u1_mb_type = ps_cur_mb_params->u1_mb_type;
1745
1746 }
1747 ps_deblk_top_mb[u4_bot_mb].u1_mb_type = u1_cur_mb_type;
1748 }
1749 /* For transform 8x8 disable deblocking of the intrernal edges of a 8x8 block */
1750 if(ps_cur_mb_info->u1_tran_form8x8)
1751 {
1752 pu4_bs_table[1] = 0;
1753 pu4_bs_table[3] = 0;
1754 pu4_bs_table[5] = 0;
1755 pu4_bs_table[7] = 0;
1756 }
1757
1758}
1759
1760
1761
1762/*!
1763 **************************************************************************
1764 * \if Function name : ih264d_fill_bs_for_mb \endif
1765 *
1766 * \brief
1767 * Determines the boundary strength (Bs), for the complete MB. Bs is
1768 * determined for each block boundary between two neighbouring 4x4
1769 * luma blocks, then packed in a UWORD32, first Bs placed in MSB and
1770 * so on. Such packed Bs values for all 8 edges are kept in an array.
1771 *
1772 * \return
1773 * Returns the packed boundary strength(Bs) MSB -> LSB Bs0|Bs1|Bs2|Bs3
1774 *
1775 **************************************************************************
1776 */
1777
1778void ih264d_fill_bs_for_mb(deblk_mb_t * ps_cur_mb_params,
1779 deblk_mb_t * ps_top_mb_params,
1780 deblk_mb_t * ps_left_mb_params,
1781 mv_pred_t *ps_cur_mv_pred,
1782 mv_pred_t *ps_top_mv_pred,
1783 UWORD8 *puc_cur_nnz,
1784 UWORD8 *puc_top_nnz,
1785 void **ppv_map_ref_idx_to_poc,
1786 UWORD32 ui_mbAff,
1787 UWORD32 ui_bs_table[], /* pointer to the BsTable array */
1788 mv_pred_t *ps_leftmost_mv_pred,
1789 neighbouradd_t *ps_left_addr,
1790 neighbouradd_t *ps_top_add)
1791{
1792 UWORD32 u4_bs_horz = 0;
1793 UWORD8 edge, u1_top_intra = 0, u1_left_intra = 0;
1794 mv_pred_t *ps_left_mv_pred;
1795 WORD16 i2_cur_mv0, i2_cur_mv1, i16_curMv2, i16_curMv3;
1796 WORD16 i2_left_mv0, i2_left_mv1, i2_left_mv2, i2_left_mv3;
1797 WORD16 i2_top_mv0, i2_top_mv1, i16_topMv2, i16_topMv3;
1798 WORD8 i1_cur_ref0, i1_cur_ref1, i1_left_ref0, i1_left_ref1, i1_top_ref0, i1_top_ref1;
1799 UWORD8 uc_cur_nnz, uc_left_nnz, uc_top_nnz, u1_mb_type, uc_Bslice;
1800 void **ppv_map_ref_idx_to_poc_l0, **ppv_map_ref_idx_to_poc_l1;
1801 UWORD8 uc_temp;
1802 UWORD8 uc_cur_mb_fld, uc_top_mb_fld;
1803 UWORD32 c_mv_limit;
1804
1805 u1_mb_type = ps_cur_mb_params->u1_mb_type;
1806 uc_Bslice = u1_mb_type & D_B_SLICE;
1807 ppv_map_ref_idx_to_poc_l0 = ppv_map_ref_idx_to_poc;
1808 ppv_map_ref_idx_to_poc_l1 = ppv_map_ref_idx_to_poc + POC_LIST_L0_TO_L1_DIFF;
1809
1810 ps_top_mb_params = ps_top_mb_params ? ps_top_mb_params : ps_cur_mb_params;
1811 u1_top_intra = ps_top_mb_params->u1_mb_type & D_INTRA_MB;
1812 u1_left_intra = ps_left_mb_params->u1_mb_type & D_INTRA_MB;
1813
1814 ui_bs_table[4] = 0x04040404; //Default for INTRA MB Boundary edges.
1815 uc_cur_mb_fld = (ps_cur_mb_params->u1_mb_type & D_FLD_MB) >> 7;
1816 uc_top_mb_fld = (ps_top_mb_params->u1_mb_type & D_FLD_MB) >> 7;
1817
1818 c_mv_limit = 4 >> uc_cur_mb_fld;
1819 if((0 == uc_cur_mb_fld) && (0 == uc_top_mb_fld))
1820 {
1821 ui_bs_table[0] = 0x04040404;
1822 }
1823 else
1824 {
1825 ui_bs_table[0] = 0x03030303;
1826 }
1827
1828 for(edge = 0; edge < 4;
1829 edge++, ps_top_mv_pred = ps_cur_mv_pred - 4, puc_top_nnz =
1830 puc_cur_nnz - 4)
1831 {
1832 //Each iteration of this loop fills the four BS values of one HORIZ edge and
1833 //one BS value for each of the four VERT edges.
1834 WORD8 i = 0;
1835 UWORD8 uc_bs_horiz, uc_bs_vert;
1836 UWORD32 ui_cnd;
1837 void *ui_ref_pic_addr[4];
1838 UWORD8 uc_mixed_mode_edge;
1839
1840 uc_mixed_mode_edge = 0;
1841
1842 uc_temp = (ui_mbAff << 4) + 13;
1843
1844 uc_cur_nnz = *(puc_cur_nnz - uc_temp);
1845 ps_left_mv_pred = ps_leftmost_mv_pred + (edge << 2);
1846
1847 for(i = 0; i < 4; i++, ps_top_mv_pred++, ps_cur_mv_pred++)
1848 {
1849 //Each iteration of this inner loop computes a HORIZ
1850 //and a VERT BS value for a 4x4 block
1851
1852 uc_left_nnz = uc_cur_nnz;
1853 uc_cur_nnz = *puc_cur_nnz++;
1854 uc_top_nnz = *puc_top_nnz++;
1855
1856 //VERT edge is assigned BS values first
1857 ui_cnd = !(uc_left_nnz || uc_cur_nnz);
1858 uc_bs_vert = 2;
1859
1860 if(ui_cnd)
1861 {
1862 i2_left_mv0 = ps_left_mv_pred->i2_mv[0];
1863 i2_left_mv1 = ps_left_mv_pred->i2_mv[1];
1864 i2_left_mv2 = ps_left_mv_pred->i2_mv[2];
1865 i2_left_mv3 = ps_left_mv_pred->i2_mv[3];
1866
1867 i2_cur_mv0 = ps_cur_mv_pred->i2_mv[0];
1868 i2_cur_mv1 = ps_cur_mv_pred->i2_mv[1];
1869 i16_curMv2 = ps_cur_mv_pred->i2_mv[2];
1870 i16_curMv3 = ps_cur_mv_pred->i2_mv[3];
1871 i1_cur_ref0 = ps_cur_mv_pred->i1_ref_frame[0];
1872 i1_cur_ref1 = ps_cur_mv_pred->i1_ref_frame[1];
1873 ui_ref_pic_addr[2] = ppv_map_ref_idx_to_poc_l0[i1_cur_ref0];
1874 ui_ref_pic_addr[3] = ppv_map_ref_idx_to_poc_l1[i1_cur_ref1];
1875
1876 if(i)
1877 {
1878 i1_left_ref0 = ps_left_mv_pred->i1_ref_frame[0];
1879 i1_left_ref1 = ps_left_mv_pred->i1_ref_frame[1];
1880 ui_ref_pic_addr[0] = ppv_map_ref_idx_to_poc_l0[i1_left_ref0];
1881 ui_ref_pic_addr[1] = ppv_map_ref_idx_to_poc_l1[i1_left_ref1];
1882 }
1883 else
1884 {
1885 ui_ref_pic_addr[0] = ps_left_addr->u4_add[edge & 2];
1886 ui_ref_pic_addr[1] = ps_left_addr->u4_add[1 + (edge & 2)];
1887 }
1888 if(!uc_Bslice)
1889 {
1890 uc_bs_vert =
1891 (ui_ref_pic_addr[0] != ui_ref_pic_addr[2])
1892 | (ABS((i2_left_mv0
1893 - i2_cur_mv0))
1894 >= 4)
1895 | (ABS((i2_left_mv1
1896 - i2_cur_mv1))
1897 >= (UWORD8)c_mv_limit);
1898 }
1899 else
1900 {
1901 UWORD8 uc_bs_temp1, uc_bs_temp2;
1902
1903 uc_bs_vert = 1;
1904
1905 uc_bs_temp1 =
1906 ((ABS((i2_left_mv0 - i2_cur_mv0))
1907 >= 4)
1908 | (ABS((i2_left_mv1
1909 - i2_cur_mv1))
1910 >= (UWORD8)c_mv_limit)
1911 | (ABS((i2_left_mv2
1912 - i16_curMv2))
1913 >= 4)
1914 | (ABS((i2_left_mv3
1915 - i16_curMv3))
1916 >= (UWORD8)c_mv_limit));
1917
1918 uc_bs_temp2 =
1919 ((ABS((i2_left_mv0 - i16_curMv2))
1920 >= 4)
1921 | (ABS((i2_left_mv1
1922 - i16_curMv3))
1923 >= (UWORD8)c_mv_limit)
1924 | (ABS((i2_left_mv2
1925 - i2_cur_mv0))
1926 >= 4)
1927 | (ABS((i2_left_mv3
1928 - i2_cur_mv1))
1929 >= (UWORD8)c_mv_limit));
1930
1931 uc_bs_vert =
1932 (((ui_ref_pic_addr[0] != ui_ref_pic_addr[2])
1933 || (ui_ref_pic_addr[1]
1934 != ui_ref_pic_addr[3]))
1935 || (uc_bs_temp1))
1936 && (((ui_ref_pic_addr[0]
1937 != ui_ref_pic_addr[3])
1938 || (ui_ref_pic_addr[1]
1939 != ui_ref_pic_addr[2]))
1940 || (uc_bs_temp2));
1941
1942 }
1943 }
1944 //Fill the VERT BS, only if valid i.e.,
1945 //if it is a non-edge OR it is an edge, which is not yet filled
1946 uc_bs_vert = (!i && u1_left_intra) ? 4 : uc_bs_vert;
1947 ui_bs_table[i + 4] = (ui_bs_table[i + 4] << 8) | uc_bs_vert;
1948
1949 //HORIZ edge is assigned BS values next
1950 ui_cnd = !(uc_top_nnz || uc_cur_nnz);
1951 uc_bs_horiz = 2;
1952
1953 if(ui_cnd)
1954 {
1955 uc_mixed_mode_edge =
1956 (0 == edge) ? (uc_top_mb_fld != uc_cur_mb_fld) : 0;
1957 ui_cnd = 1 - uc_mixed_mode_edge;
1958 uc_bs_horiz = uc_mixed_mode_edge;
1959 }
1960
1961 if(ui_cnd)
1962 {
1963 i2_cur_mv0 = ps_cur_mv_pred->i2_mv[0];
1964 i2_cur_mv1 = ps_cur_mv_pred->i2_mv[1];
1965 i16_curMv2 = ps_cur_mv_pred->i2_mv[2];
1966 i16_curMv3 = ps_cur_mv_pred->i2_mv[3];
1967 i1_cur_ref0 = ps_cur_mv_pred->i1_ref_frame[0];
1968 i1_cur_ref1 = ps_cur_mv_pred->i1_ref_frame[1];
1969
1970 i2_top_mv0 = ps_top_mv_pred->i2_mv[0];
1971 i2_top_mv1 = ps_top_mv_pred->i2_mv[1];
1972 i16_topMv2 = ps_top_mv_pred->i2_mv[2];
1973 i16_topMv3 = ps_top_mv_pred->i2_mv[3];
1974 ui_ref_pic_addr[2] = ppv_map_ref_idx_to_poc_l0[i1_cur_ref0];
1975 ui_ref_pic_addr[3] = ppv_map_ref_idx_to_poc_l1[i1_cur_ref1];
1976 if(edge)
1977 {
1978 i1_top_ref0 = ps_top_mv_pred->i1_ref_frame[0];
1979 i1_top_ref1 = ps_top_mv_pred->i1_ref_frame[1];
1980 ui_ref_pic_addr[0] = ppv_map_ref_idx_to_poc_l0[i1_top_ref0];
1981 ui_ref_pic_addr[1] = ppv_map_ref_idx_to_poc_l1[i1_top_ref1];
1982 }
1983 else
1984 {
1985 ui_ref_pic_addr[0] = ps_top_add->u4_add[i & 2];
1986 ui_ref_pic_addr[1] = ps_top_add->u4_add[1 + (i & 2)];
1987 }
1988 if(!uc_Bslice)
1989 {
1990 uc_bs_horiz =
1991 (ui_ref_pic_addr[0] != ui_ref_pic_addr[2])
1992 | (ABS((i2_top_mv0
1993 - i2_cur_mv0))
1994 >= 4)
1995 | (ABS((i2_top_mv1
1996 - i2_cur_mv1))
1997 >= (UWORD8)c_mv_limit);
1998 }
1999 else
2000 {
2001 UWORD8 uc_bs_temp1, uc_bs_temp2;
2002
2003 uc_bs_horiz = 1;
2004
2005 uc_bs_temp1 =
2006 ((ABS((i2_top_mv0 - i2_cur_mv0))
2007 >= 4)
2008 | (ABS((i2_top_mv1
2009 - i2_cur_mv1))
2010 >= (UWORD8)c_mv_limit)
2011 | (ABS((i16_topMv2
2012 - i16_curMv2))
2013 >= 4)
2014 | (ABS((i16_topMv3
2015 - i16_curMv3))
2016 >= (UWORD8)c_mv_limit));
2017
2018 uc_bs_temp2 =
2019 ((ABS((i2_top_mv0 - i16_curMv2))
2020 >= 4)
2021 | (ABS((i2_top_mv1
2022 - i16_curMv3))
2023 >= (UWORD8)c_mv_limit)
2024 | (ABS((i16_topMv2
2025 - i2_cur_mv0))
2026 >= 4)
2027 | (ABS((i16_topMv3
2028 - i2_cur_mv1))
2029 >= (UWORD8)c_mv_limit));
2030
2031 uc_bs_horiz =
2032 (((ui_ref_pic_addr[0] != ui_ref_pic_addr[2])
2033 || (ui_ref_pic_addr[1]
2034 != ui_ref_pic_addr[3]))
2035 || (uc_bs_temp1))
2036 && (((ui_ref_pic_addr[0]
2037 != ui_ref_pic_addr[3])
2038 || (ui_ref_pic_addr[1]
2039 != ui_ref_pic_addr[2]))
2040 || (uc_bs_temp2));
2041
2042 }
2043 }
2044 ps_left_mv_pred = ps_cur_mv_pred;
2045 u4_bs_horz = (u4_bs_horz << 8) + uc_bs_horiz;
2046 }
2047 //Fill the HORIZ BS, only if valid i.e.,
2048 //if it is a non-edge OR it is an edge, which is not yet filled
2049 if(edge || (!edge && !u1_top_intra))
2050 ui_bs_table[edge] = u4_bs_horz;
2051 }
2052}
2053
2054/*!
2055 **************************************************************************
2056 * \if Function name : ih264d_fill_bs_for_extra_left_edge \endif
2057 *
2058 * \brief
2059 * Fills the boundary strength (Bs), for the top extra edge. ock
2060 *
2061 * \return
2062 * Returns the packed boundary strength(Bs) MSB -> LSB Bs0|Bs1|Bs2|Bs3
2063 *
2064 **************************************************************************
2065 */
2066void ih264d_fill_bs_for_extra_left_edge(deblk_mb_t *ps_cur_deblk_mb,
2067 deblk_mb_t *ps_leftDeblkMb,
2068 UWORD8* puc_cur_nnz,
2069 UWORD8 uc_botMb)
2070{
2071 /* Set the Flag in uc_deblocking_mode variable of current MB*/
2072 /* for mixed mode edge*/
2073 ps_cur_deblk_mb->u1_single_call = 0;
2074
2075 if(ps_cur_deblk_mb->u1_mb_type & D_INTRA_MB)
2076 {
2077 ps_cur_deblk_mb->u4_bs_table[4] = 0x04040404;
2078 ps_cur_deblk_mb->u4_bs_table[9] = 0x04040404;
2079 }
2080 else if((ps_leftDeblkMb->u1_mb_type & D_INTRA_MB)
2081 && ((ps_leftDeblkMb + 1)->u1_mb_type & D_INTRA_MB))
2082 {
2083 ps_cur_deblk_mb->u4_bs_table[4] = 0x04040404;
2084 ps_cur_deblk_mb->u4_bs_table[9] = 0x04040404;
2085 }
2086 else
2087 {
2088 /* Get strengths of left MB edge */
2089 UWORD32 u4_bs;
2090 UWORD8 uc_Bs;
2091 WORD32 i;
2092 UWORD32 ui_curMbFld;
2093 UWORD8 *puc_left_nnz;
2094 UWORD32 ui_bs_left_edge[2];
2095
2096 ui_curMbFld = (ps_cur_deblk_mb->u1_mb_type & D_FLD_MB) >> 7;
2097
2098 puc_left_nnz = puc_cur_nnz - 29;
2099 if((ui_curMbFld == 0) && uc_botMb)
2100 {
2101 puc_left_nnz -= 8;
2102 }
2103 else if(ui_curMbFld && uc_botMb)
2104 {
2105 puc_left_nnz -= 16;
2106 }
2107
2108 if(ui_curMbFld)
2109 {
2110 if(ps_leftDeblkMb->u1_mb_type & D_INTRA_MB)
2111 {
2112 ui_bs_left_edge[0] = 0x04040404;
2113 puc_left_nnz += 16;
2114 puc_cur_nnz += 8;
2115 }
2116 else
2117 {
2118 u4_bs = 0;
2119 for(i = 4; i > 0; i--)
2120 {
2121 uc_Bs = ((*puc_cur_nnz || *puc_left_nnz)) ? 2 : 1;
2122 u4_bs = (u4_bs << 8) | uc_Bs;
2123 puc_left_nnz += 4;
2124 if(i & 0x01)
2125 puc_cur_nnz += 4;
2126 }
2127 ui_bs_left_edge[0] = u4_bs;
2128 }
2129
2130 if((ps_leftDeblkMb + 1)->u1_mb_type & D_INTRA_MB)
2131 {
2132 ui_bs_left_edge[1] = 0x04040404;
2133 }
2134 else
2135 {
2136 u4_bs = 0;
2137 for(i = 4; i > 0; i--)
2138 {
2139 uc_Bs = ((*puc_cur_nnz || *puc_left_nnz)) ? 2 : 1;
2140 u4_bs = (u4_bs << 8) | uc_Bs;
2141 puc_left_nnz += 4;
2142 if(i & 0x01)
2143 puc_cur_nnz += 4;
2144 }
2145 ui_bs_left_edge[1] = u4_bs;
2146 }
2147 }
2148 else
2149 {
2150 UWORD8 *puc_curNnzB, *puc_leftNnzB;
2151 puc_curNnzB = puc_cur_nnz;
2152 puc_leftNnzB = puc_left_nnz + 16;
2153 if(ps_leftDeblkMb->u1_mb_type & D_INTRA_MB)
2154 {
2155 ui_bs_left_edge[0] = 0x04040404;
2156 }
2157 else
2158 {
2159 u4_bs = 0;
2160 for(i = 4; i > 0; i--, puc_cur_nnz += 4)
2161 {
2162 uc_Bs = ((*puc_cur_nnz || *puc_left_nnz)) ? 2 : 1;
2163 u4_bs = (u4_bs << 8) | uc_Bs;
2164 if(i & 0x01)
2165 puc_left_nnz += 4;
2166 }
2167 ui_bs_left_edge[0] = u4_bs;
2168 }
2169
2170 if((ps_leftDeblkMb + 1)->u1_mb_type & D_INTRA_MB)
2171 {
2172 ui_bs_left_edge[1] = 0x04040404;
2173 }
2174 else
2175 {
2176 u4_bs = 0;
2177 for(i = 4; i > 0; i--, puc_curNnzB += 4)
2178 {
2179 uc_Bs = ((*puc_curNnzB || *puc_leftNnzB)) ? 2 : 1;
2180 u4_bs = (u4_bs << 8) | uc_Bs;
2181 if(i & 0x01)
2182 puc_leftNnzB += 4;
2183 }
2184 ui_bs_left_edge[1] = u4_bs;
2185 }
2186 }
2187 /* Copy The Values in Cur Deblk Mb Parameters */
2188 ps_cur_deblk_mb->u4_bs_table[4] = ui_bs_left_edge[0];
2189 ps_cur_deblk_mb->u4_bs_table[9] = ui_bs_left_edge[1];
2190 }
2191
2192}
2193
2194/*!
2195 **************************************************************************
2196 * \if Function name : ih264d_fill_bs_for_extra_top_edge \endif
2197 *
2198 * \brief
2199 * Fills the boundary strength (Bs), for the top extra edge. ock
2200 *
2201 * \return
2202 * Returns the packed boundary strength(Bs) MSB -> LSB Bs0|Bs1|Bs2|Bs3
2203 *
2204 **************************************************************************
2205 */
2206void ih264d_fill_bs_for_extra_top_edge(deblk_mb_t *ps_cur_mb_params,
2207 UWORD8 u1_Edge0_mb_typ,
2208 UWORD8 u1_Edge1_mb_typ,
2209 UWORD8 *pu1_curNnz,
2210 UWORD8 *pu1_topNnz)
2211{
2212 UWORD32 u4_bs;
2213 UWORD8 uc_Bs;
2214 WORD32 i;
2215 UWORD8 *pu1_cur_nnz_tmp;
2216 UWORD8 *pu1_top_nnz_tmp;
2217 UWORD8 u1_top_edge;
2218 UWORD8 u1_top_mb_type;
2219 for(u1_top_edge = 0; u1_top_edge < 2; u1_top_edge++)
2220 {
2221 u1_top_mb_type = u1_top_edge ? u1_Edge1_mb_typ : u1_Edge0_mb_typ;
2222 pu1_cur_nnz_tmp = pu1_curNnz;
2223 pu1_top_nnz_tmp = pu1_topNnz + (u1_top_edge << 2);
2224
2225 if((ps_cur_mb_params->u1_mb_type & D_INTRA_MB)
2226 + (u1_top_mb_type & D_INTRA_MB))
2227 {
2228 u4_bs = 0x03030303;
2229 }
2230 else
2231 {
2232 u4_bs = 0;
2233 for(i = 4; i > 0; i--, pu1_cur_nnz_tmp += 1, pu1_top_nnz_tmp += 1)
2234 {
2235 uc_Bs = ((*pu1_cur_nnz_tmp || *pu1_top_nnz_tmp)) ? 2 : 1;
2236 u4_bs = (u4_bs << 8) | uc_Bs;
2237 }
2238 }
2239 if(u1_top_edge)
2240 ps_cur_mb_params->u4_bs_table[0] = u4_bs;
2241 else
2242 ps_cur_mb_params->u4_bs_table[8] = u4_bs;
2243 }
2244}
2245
2246
2247void ih264d_fill_bs_mbedge_4(dec_struct_t * ps_dec,
2248 dec_mb_info_t * ps_cur_mb_info,
2249 const UWORD16 u2_mbxn_mb)
2250{
2251
2252 /* deblk_mb_t Params */
2253 deblk_mb_t *ps_cur_mb_params; /*< Parameters of current MacroBlock */
2254 deblkmb_neighbour_t *ps_deblk_top_mb;
2255 UWORD32 * pu4_bs_table;
2256 UWORD8 u1_cur_mb_type;
2257
2258 /* Neighbour availability */
2259 /* Initialization */
2260 const UWORD32 u2_mbx = ps_cur_mb_info->u2_mbx;
2261 const UWORD32 u2_mby = ps_cur_mb_info->u2_mby;
2262 const UWORD32 u1_pingpong = u2_mbx & 0x01;
2263 ps_deblk_top_mb = ps_dec->ps_deblk_top_mb + u2_mbx;
2264
2265
2266 /* Pointer assignment for Current DeblkMB, Current Mv Pred */
2267 ps_cur_mb_params = ps_dec->ps_deblk_mbn + u2_mbxn_mb;
2268
2269 u1_cur_mb_type = ps_cur_mb_params->u1_mb_type;
2270
2271 ps_deblk_top_mb->u1_mb_type = u1_cur_mb_type;
2272
2273 {
2274 UWORD8 mb_qp_temp;
2275
2276 ps_cur_mb_params->u1_topmb_qp = ps_deblk_top_mb->u1_mb_qp;
2277 ps_deblk_top_mb->u1_mb_qp = ps_cur_mb_params->u1_mb_qp;
2278
2279 ps_cur_mb_params->u1_left_mb_qp = ps_dec->deblk_left_mb[1].u1_mb_qp;
2280 ps_dec->deblk_left_mb[1].u1_mb_qp = ps_cur_mb_params->u1_mb_qp;
2281
2282 }
2283
2284 ps_cur_mb_params->u1_single_call = 1;
2285
2286 ps_dec->deblk_left_mb[1].u1_mb_type = ps_cur_mb_params->u1_mb_type;
2287 /* if no deblocking required for current Mb then continue */
2288 /* Check next Mbs in Mb group */
2289 if(ps_cur_mb_params->u1_deblocking_mode & MB_DISABLE_FILTERING)
2290 {
2291 /* Storing the leftMbtype for next Mb */
2292 return;
2293 }
2294
2295 /* Compute BS function */
2296 pu4_bs_table = ps_cur_mb_params->u4_bs_table;
2297
2298 pu4_bs_table[4] = 0x04040404;
2299 pu4_bs_table[0] = 0x04040404;
2300 pu4_bs_table[1] = 0;
2301 pu4_bs_table[2] = 0;
2302 pu4_bs_table[3] = 0;
2303 pu4_bs_table[5] = 0;
2304 pu4_bs_table[6] = 0;
2305 pu4_bs_table[7] = 0;
2306
2307}
2308
2309void ih264d_fill_bs_mbedge_2(dec_struct_t * ps_dec,
2310 dec_mb_info_t * ps_cur_mb_info,
2311 const UWORD16 u2_mbxn_mb)
2312{
2313
2314 /* deblk_mb_t Params */
2315 deblk_mb_t *ps_cur_mb_params; /*< Parameters of current MacroBlock */
2316 deblkmb_neighbour_t *ps_deblk_top_mb;
2317 UWORD32 * pu4_bs_table;
2318 UWORD8 u1_cur_mb_type;
2319
2320 /* Neighbour availability */
2321 /* Initialization */
2322 const UWORD32 u2_mbx = ps_cur_mb_info->u2_mbx;
2323 const UWORD32 u2_mby = ps_cur_mb_info->u2_mby;
2324 const UWORD32 u1_pingpong = u2_mbx & 0x01;
2325 ps_deblk_top_mb = ps_dec->ps_deblk_top_mb + u2_mbx;
2326
2327
2328 /* Pointer assignment for Current DeblkMB, Current Mv Pred */
2329 ps_cur_mb_params = ps_dec->ps_deblk_mbn + u2_mbxn_mb;
2330
2331 u1_cur_mb_type = ps_cur_mb_params->u1_mb_type;
2332
2333 ps_deblk_top_mb->u1_mb_type = u1_cur_mb_type;
2334
2335 {
2336 UWORD8 mb_qp_temp;
2337
2338 ps_cur_mb_params->u1_topmb_qp = ps_deblk_top_mb->u1_mb_qp;
2339 ps_deblk_top_mb->u1_mb_qp = ps_cur_mb_params->u1_mb_qp;
2340
2341 ps_cur_mb_params->u1_left_mb_qp = ps_dec->deblk_left_mb[1].u1_mb_qp;
2342 ps_dec->deblk_left_mb[1].u1_mb_qp = ps_cur_mb_params->u1_mb_qp;
2343
2344 }
2345
2346 ps_cur_mb_params->u1_single_call = 1;
2347
2348 ps_dec->deblk_left_mb[1].u1_mb_type = ps_cur_mb_params->u1_mb_type;
2349 /* if no deblocking required for current Mb then continue */
2350 /* Check next Mbs in Mb group */
2351 if(ps_cur_mb_params->u1_deblocking_mode & MB_DISABLE_FILTERING)
2352 {
2353 /* Storing the leftMbtype for next Mb */
2354 return;
2355 }
2356
2357 /* Compute BS function */
2358 pu4_bs_table = ps_cur_mb_params->u4_bs_table;
2359
2360 {
2361 UWORD32 top_mb_csbp, left_mb_csbp, cur_mb_csbp;
2362 UWORD32 top_edge, left_edge;
2363
2364 top_mb_csbp = ps_cur_mb_info->ps_top_mb->u2_luma_csbp;
2365 left_mb_csbp = ps_cur_mb_info->ps_left_mb->u2_luma_csbp;
2366 cur_mb_csbp = ps_cur_mb_info->ps_curmb->u2_luma_csbp;
2367
2368 top_mb_csbp = top_mb_csbp >> 12;
2369 top_edge = top_mb_csbp | (cur_mb_csbp & 0xf);
2370
2371 if(top_edge)
2372 pu4_bs_table[0] = 0x02020202;
2373 else
2374 pu4_bs_table[0] = 0;
2375
2376 cur_mb_csbp = cur_mb_csbp & CSBP_LEFT_BLOCK_MASK;
2377 left_mb_csbp = left_mb_csbp & CSBP_RIGHT_BLOCK_MASK;
2378
2379 left_edge = cur_mb_csbp | left_mb_csbp;
2380
2381 if(left_edge)
2382 pu4_bs_table[4] = 0x02020202;
2383 else
2384 pu4_bs_table[4] = 0;
2385
2386 pu4_bs_table[1] = 0;
2387 pu4_bs_table[2] = 0;
2388 pu4_bs_table[3] = 0;
2389 pu4_bs_table[5] = 0;
2390 pu4_bs_table[6] = 0;
2391 pu4_bs_table[7] = 0;
2392 }
2393
2394}