ECC-386: Slow-down of read routine. Fixed decoding

This commit is contained in:
Shahram Najm 2016-12-05 14:51:30 +00:00
parent 09a4f88014
commit 3dd428aa4f
1 changed files with 57 additions and 32 deletions

View File

@ -94,6 +94,30 @@ int grib_decode_double_array(const unsigned char* p, long *bitp, long bitsPerVal
val[i] = (double)x;
}
#endif
if (bitsPerValue%8 == 0)
{
/* See ECC-386 */
int bc;
int l = bitsPerValue/8;
size_t o = 0;
for(i=0;i < n_vals;i++)
{
lvalue = 0;
lvalue <<= 8;
lvalue |= p[o++] ;
for ( bc=1; bc<l; bc++ )
{
lvalue <<= 8;
lvalue |= p[o++] ;
}
x=((lvalue*s)+reference_value)*d;
val[i] = (double)x;
}
}
else
{
unsigned long mask = BIT_MASK(bitsPerValue);
/* pi: position of bitp in p[]. >>3 == /8 */
@ -131,6 +155,7 @@ int grib_decode_double_array(const unsigned char* p, long *bitp, long bitsPerVal
x=((lvalue*s)+reference_value)*d;
val[i] = (double)x;
}
}
return 0;
}