Optimize opj_t1_update_flags()

This commit is contained in:
Even Rouault 2017-06-01 19:42:03 +02:00
parent a0861855c1
commit 2ba861c37c
2 changed files with 11 additions and 38 deletions

View File

@ -306,58 +306,30 @@ static OPJ_INT16 opj_t1_getnmsedec_ref(OPJ_UINT32 x, OPJ_UINT32 bitpos)
static INLINE void opj_t1_update_flags(opj_flag_t *flagsp, OPJ_UINT32 ci, static INLINE void opj_t1_update_flags(opj_flag_t *flagsp, OPJ_UINT32 ci,
OPJ_UINT32 s, OPJ_UINT32 stride) OPJ_UINT32 s, OPJ_UINT32 stride)
{ {
/* set up to point to the north and south data points' flags words, if required */ /* east */
opj_flag_t* north; flagsp[-1] |= T1_SIGMA_5 << (3U * ci);
opj_flag_t* south;
/* mark target as significant */ /* mark target as significant */
*flagsp |= T1_SIGMA_4 << (3U * ci); *flagsp |= ((s << T1_CHI_1_I) | T1_SIGMA_4) << (3U * ci);
/* west */
flagsp[1] |= T1_SIGMA_3 << (3U * ci);
/* north-west, north, north-east */ /* north-west, north, north-east */
if (ci == 0U) { if (ci == 0U) {
north = flagsp - stride; opj_flag_t* north = flagsp - stride;
*north |= T1_SIGMA_16; *north |= (s << T1_CHI_5_I) | T1_SIGMA_16;
north[-1] |= T1_SIGMA_17; north[-1] |= T1_SIGMA_17;
north[1] |= T1_SIGMA_15; north[1] |= T1_SIGMA_15;
} }
/* south-west, south, south-east */ /* south-west, south, south-east */
if (ci == 3U) { if (ci == 3U) {
south = flagsp + stride; opj_flag_t* south = flagsp + stride;
*south |= T1_SIGMA_1; *south |= (s << T1_CHI_0_I) | T1_SIGMA_1;
south[-1] |= T1_SIGMA_2; south[-1] |= T1_SIGMA_2;
south[1] |= T1_SIGMA_0; south[1] |= T1_SIGMA_0;
} }
/* east */
flagsp[-1] |= T1_SIGMA_5 << (3U * ci);
/* west */
flagsp[1] |= T1_SIGMA_3 << (3U * ci);
if (s) {
switch (ci) {
case 0U: {
*flagsp |= T1_CHI_1;
north = flagsp - stride;
*north |= T1_CHI_5;
break;
}
case 1:
*flagsp |= T1_CHI_2;
break;
case 2:
*flagsp |= T1_CHI_3;
break;
case 3: {
*flagsp |= T1_CHI_4;
south = flagsp + stride;
*south |= T1_CHI_0;
break;
}
}
}
} }
/** /**

View File

@ -124,6 +124,7 @@ in T1.C are used by some function in TCD.C.
#define T1_MU_3 (1U << 29) #define T1_MU_3 (1U << 29)
#define T1_PI_3 (1U << 30) #define T1_PI_3 (1U << 30)
#define T1_CHI_5 (1U << 31) #define T1_CHI_5 (1U << 31)
#define T1_CHI_5_I 31
/** As an example, the bits T1_SIGMA_3, T1_SIGMA_4 and T1_SIGMA_5 /** As an example, the bits T1_SIGMA_3, T1_SIGMA_4 and T1_SIGMA_5
* indicate the significance state of the west neighbour of data point zero * indicate the significance state of the west neighbour of data point zero