mirror of https://github.com/ecmwf/eccodes.git
ECC-386: Slow-down of read routine. Fixed decoding
This commit is contained in:
parent
09a4f88014
commit
3dd428aa4f
|
@ -94,6 +94,30 @@ int grib_decode_double_array(const unsigned char* p, long *bitp, long bitsPerVal
|
||||||
val[i] = (double)x;
|
val[i] = (double)x;
|
||||||
}
|
}
|
||||||
#endif
|
#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);
|
unsigned long mask = BIT_MASK(bitsPerValue);
|
||||||
|
|
||||||
/* pi: position of bitp in p[]. >>3 == /8 */
|
/* 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;
|
x=((lvalue*s)+reference_value)*d;
|
||||||
val[i] = (double)x;
|
val[i] = (double)x;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue