Decoder: Fix Integer Sanitizer issues in ih264d_process_bslice
Bug: 118445723 Test: vendor Change-Id: Ib5d8f72be016330beafa6e7996976eeff1b23c39
This commit is contained in:
parent
fb23fbfa68
commit
fc7139a53e
6 changed files with 50 additions and 15 deletions
|
|
@ -62,6 +62,18 @@ static __inline WORD32 CLIP_S10(WORD32 x)
|
|||
return x;
|
||||
}
|
||||
|
||||
static __inline WORD32 CLIP_U11(WORD32 x)
|
||||
{
|
||||
asm("usat %0, #11, %1" : "=r"(x) : "r"(x));
|
||||
return x;
|
||||
}
|
||||
|
||||
static __inline WORD32 CLIP_S11(WORD32 x)
|
||||
{
|
||||
asm("ssat %0, #11, %1" : "=r"(x) : "r"(x));
|
||||
return x;
|
||||
}
|
||||
|
||||
static __inline WORD32 CLIP_U12(WORD32 x)
|
||||
{
|
||||
asm("usat %0, #12, %1" : "=r"(x) : "r"(x));
|
||||
|
|
@ -101,6 +113,9 @@ static __inline UWORD32 ITT_BIG_ENDIAN(UWORD32 x)
|
|||
#define CLIP_U10(x) CLIP3(0, 1023, (x))
|
||||
#define CLIP_S10(x) CLIP3(-512, 511, (x))
|
||||
|
||||
#define CLIP_U11(x) CLIP3(0, 2047, (x))
|
||||
#define CLIP_S11(x) CLIP3(-1024, 1023, (x))
|
||||
|
||||
#define CLIP_U12(x) CLIP3(0, 4095, (x))
|
||||
#define CLIP_S12(x) CLIP3(-2048, 2047, (x))
|
||||
|
||||
|
|
|
|||
|
|
@ -62,6 +62,18 @@ static __inline WORD32 CLIP_S10(WORD32 x)
|
|||
return x;
|
||||
}
|
||||
|
||||
static __inline WORD32 CLIP_U11(WORD32 x)
|
||||
{
|
||||
asm("usat %0, #11, %1" : "=r"(x) : "r"(x));
|
||||
return x;
|
||||
}
|
||||
|
||||
static __inline WORD32 CLIP_S11(WORD32 x)
|
||||
{
|
||||
asm("ssat %0, #11, %1" : "=r"(x) : "r"(x));
|
||||
return x;
|
||||
}
|
||||
|
||||
static __inline WORD32 CLIP_U12(WORD32 x)
|
||||
{
|
||||
asm("usat %0, #12, %1" : "=r"(x) : "r"(x));
|
||||
|
|
@ -101,6 +113,9 @@ static __inline UWORD32 ITT_BIG_ENDIAN(UWORD32 x)
|
|||
#define CLIP_U10(x) CLIP3(0, 1023, (x))
|
||||
#define CLIP_S10(x) CLIP3(-512, 511, (x))
|
||||
|
||||
#define CLIP_U11(x) CLIP3(0, 2047, (x))
|
||||
#define CLIP_S11(x) CLIP3(-1024, 1023, (x))
|
||||
|
||||
#define CLIP_U12(x) CLIP3(0, 4095, (x))
|
||||
#define CLIP_S12(x) CLIP3(-2048, 2047, (x))
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,9 @@
|
|||
#define CLIP_U10(x) CLIP3(0, 1023, (x))
|
||||
#define CLIP_S10(x) CLIP3(-512, 511, (x))
|
||||
|
||||
#define CLIP_U11(x) CLIP3(0, 2047, (x))
|
||||
#define CLIP_S11(x) CLIP3(-1024, 1023, (x))
|
||||
|
||||
#define CLIP_U12(x) CLIP3(0, 4095, (x))
|
||||
#define CLIP_S12(x) CLIP3(-2048, 2047, (x))
|
||||
|
||||
|
|
|
|||
|
|
@ -47,6 +47,9 @@
|
|||
#define CLIP_U10(x) CLIP3(0, 1023, (x))
|
||||
#define CLIP_S10(x) CLIP3(-512, 511, (x))
|
||||
|
||||
#define CLIP_U11(x) CLIP3(0, 2047, (x))
|
||||
#define CLIP_S11(x) CLIP3(-1024, 1023, (x))
|
||||
|
||||
#define CLIP_U12(x) CLIP3(0, 4095, (x))
|
||||
#define CLIP_S12(x) CLIP3(-2048, 2047, (x))
|
||||
|
||||
|
|
|
|||
|
|
@ -1220,11 +1220,11 @@ void ih264d_get_implicit_weights(dec_struct_t *ps_dec)
|
|||
if(i4_poc1 != i4_poc0)
|
||||
{
|
||||
i4_tb = ps_dec->ps_cur_pic->i4_poc - i4_poc0;
|
||||
i16_tb = CLIP3(-128, 127, i4_tb);
|
||||
i16_tb = CLIP_S8(i4_tb);
|
||||
i4_td = i4_poc1 - i4_poc0;
|
||||
i16_td = CLIP3(-128, 127, i4_td);
|
||||
i16_td = CLIP_S8(i4_td);
|
||||
i16_tx = (16384 + ABS(SIGN_POW2_DIV(i16_td, 1))) / i16_td;
|
||||
i2_dist_scale_factor = CLIP3(-1024, 1023,
|
||||
i2_dist_scale_factor = CLIP_S11(
|
||||
(((i16_tb * i16_tx) + 32) >> 6));
|
||||
|
||||
if(/*((u4_poc1 - u4_poc0) == 0) ||*/
|
||||
|
|
@ -1290,14 +1290,13 @@ void ih264d_get_implicit_weights(dec_struct_t *ps_dec)
|
|||
if(i4_poc1 != i4_poc0)
|
||||
{
|
||||
i4_tb = i4_cur_poc - i4_poc0;
|
||||
i16_tb = CLIP3(-128, 127, i4_tb);
|
||||
i16_tb = CLIP_S8(i4_tb);
|
||||
i4_td = i4_poc1 - i4_poc0;
|
||||
i16_td = CLIP3(-128, 127, i4_td);
|
||||
i16_td = CLIP_S8(i4_td);
|
||||
i16_tx = (16384 + ABS(SIGN_POW2_DIV(i16_td, 1)))
|
||||
/ i16_td;
|
||||
i2_dist_scale_factor = CLIP3(
|
||||
-1024, 1023,
|
||||
(((i16_tb * i16_tx) + 32) >> 6));
|
||||
i2_dist_scale_factor = CLIP_S11(
|
||||
(((i16_tb * i16_tx) + 32) >> 6));
|
||||
|
||||
if(/*((u4_poc1 - u4_poc0) == 0) ||*/
|
||||
(!(ps_pic_buff1->u1_is_short && ps_pic_buff0->u1_is_short))
|
||||
|
|
|
|||
|
|
@ -597,7 +597,7 @@ WORD32 ih264d_decode_temporal_direct(dec_struct_t * ps_dec,
|
|||
const UWORD8 *pu1_mb_partw = (const UWORD8 *)gau1_ih264d_mb_partw;
|
||||
WORD8 c_refFrm0, c_refFrm1;
|
||||
UWORD8 u1_ref_idx0, u1_is_cur_mb_fld;
|
||||
UWORD32 pic0_poc, pic1_poc, cur_poc;
|
||||
WORD32 pic0_poc, pic1_poc, cur_poc;
|
||||
WORD32 ret = 0;
|
||||
|
||||
u1_is_cur_mb_fld = ps_cur_mb_info->u1_mb_field_decodingflag;
|
||||
|
|
@ -756,7 +756,7 @@ WORD32 ih264d_decode_temporal_direct(dec_struct_t * ps_dec,
|
|||
}
|
||||
{
|
||||
WORD16 i16_td;
|
||||
|
||||
WORD32 diff;
|
||||
if(c_refFrm0 >= 0)
|
||||
{
|
||||
i2_mv_x0 = ps_mv->i2_mv[0];
|
||||
|
|
@ -782,7 +782,8 @@ WORD32 ih264d_decode_temporal_direct(dec_struct_t * ps_dec,
|
|||
i2_mv_y0 *= 2;
|
||||
}
|
||||
|
||||
i16_td = pic1_poc - pic0_poc;
|
||||
diff = pic1_poc - pic0_poc;
|
||||
i16_td = CLIP_S8(diff);
|
||||
if((ps_pic_buff0->u1_is_short == 0) || (i16_td == 0))
|
||||
{
|
||||
i2_mv_x1 = 0;
|
||||
|
|
@ -792,12 +793,11 @@ WORD32 ih264d_decode_temporal_direct(dec_struct_t * ps_dec,
|
|||
{
|
||||
WORD16 i16_tb, i16_tx, i2_dist_scale_factor, i16_temp;
|
||||
|
||||
i16_td = CLIP3(-128, 127, i16_td);
|
||||
i16_tb = cur_poc - pic0_poc;
|
||||
i16_tb = CLIP3(-128, 127, i16_tb);
|
||||
diff = cur_poc - pic0_poc;
|
||||
i16_tb = CLIP_S8(diff);
|
||||
|
||||
i16_tx = (16384 + ABS(SIGN_POW2_DIV(i16_td, 1))) / i16_td;
|
||||
i2_dist_scale_factor = CLIP3(-1024, 1023,
|
||||
i2_dist_scale_factor = CLIP_S11(
|
||||
(((i16_tb * i16_tx) + 32) >> 6));
|
||||
i16_temp = (i2_mv_x0 * i2_dist_scale_factor + 128) >> 8;
|
||||
i2_mv_x1 = i16_temp - i2_mv_x0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue