mirror of https://github.com/ecmwf/eccodes.git
Clean up
This commit is contained in:
parent
d3f3c61ec0
commit
1354bd2516
|
@ -458,7 +458,7 @@ static size_t __expand(grib_accessor* a, bufr_descriptors_array* unexpanded, buf
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
bufr_descriptors_array* do_expand(grib_accessor* a,bufr_descriptors_array* unexpanded,change_coding_params* ccp,int *err)
|
static bufr_descriptors_array* do_expand(grib_accessor* a,bufr_descriptors_array* unexpanded,change_coding_params* ccp,int *err)
|
||||||
{
|
{
|
||||||
bufr_descriptors_array* expanded=NULL;
|
bufr_descriptors_array* expanded=NULL;
|
||||||
grib_context* c=a->context;
|
grib_context* c=a->context;
|
||||||
|
|
|
@ -74,7 +74,8 @@ int grib_decode_long_array(const unsigned char* p, long *bitp, long bitsPerValue
|
||||||
*/
|
*/
|
||||||
int grib_decode_double_array(const unsigned char* p, long *bitp, long bitsPerValue,
|
int grib_decode_double_array(const unsigned char* p, long *bitp, long bitsPerValue,
|
||||||
double reference_value,double s,double d,
|
double reference_value,double s,double d,
|
||||||
size_t n_vals,double* val) {
|
size_t n_vals,double* val)
|
||||||
|
{
|
||||||
long i=0;
|
long i=0;
|
||||||
unsigned long lvalue = 0;
|
unsigned long lvalue = 0;
|
||||||
double x;
|
double x;
|
||||||
|
@ -92,49 +93,49 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
unsigned long mask = BIT_MASK(bitsPerValue);
|
unsigned long mask = BIT_MASK(bitsPerValue);
|
||||||
|
|
||||||
/* pi: positin of bitp in p[]. >>3 == /8 */
|
/* pi: position of bitp in p[]. >>3 == /8 */
|
||||||
long pi = *bitp / 8;
|
long pi = *bitp / 8;
|
||||||
/* some bits might of the current byte at pi might be used */
|
/* some bits might of the current byte at pi might be used */
|
||||||
/* by the previous number usefulBitsInByte gives remaining unused bits */
|
/* by the previous number usefulBitsInByte gives remaining unused bits */
|
||||||
/* number of useful bits in current byte */
|
/* number of useful bits in current byte */
|
||||||
int usefulBitsInByte = 8-(*bitp & 7);
|
int usefulBitsInByte = 8-(*bitp & 7);
|
||||||
for(i=0;i < n_vals;i++) {
|
for(i=0;i < n_vals;i++) {
|
||||||
/* value read as long */
|
/* value read as long */
|
||||||
long bitsToRead = 0;
|
long bitsToRead = 0;
|
||||||
lvalue = 0;
|
lvalue = 0;
|
||||||
bitsToRead = bitsPerValue;
|
bitsToRead = bitsPerValue;
|
||||||
/* read one byte after the other to lvalue until >= bitsPerValue are read */
|
/* read one byte after the other to lvalue until >= bitsPerValue are read */
|
||||||
while (bitsToRead > 0) {
|
while (bitsToRead > 0) {
|
||||||
lvalue <<= 8;
|
lvalue <<= 8;
|
||||||
lvalue += p[pi];
|
lvalue += p[pi];
|
||||||
pi++;
|
pi++;
|
||||||
bitsToRead -= usefulBitsInByte;
|
bitsToRead -= usefulBitsInByte;
|
||||||
usefulBitsInByte = 8;
|
usefulBitsInByte = 8;
|
||||||
}
|
}
|
||||||
*bitp += bitsPerValue;
|
*bitp += bitsPerValue;
|
||||||
/* bitsToRead is now <= 0, remove the last bits */
|
/* bitsToRead is now <= 0, remove the last bits */
|
||||||
lvalue >>= -1*bitsToRead;
|
lvalue >>= -1*bitsToRead;
|
||||||
/* set leading bits to 0 - removing bits used for previous number */
|
/* set leading bits to 0 - removing bits used for previous number */
|
||||||
lvalue &= mask;
|
lvalue &= mask;
|
||||||
|
|
||||||
usefulBitsInByte = -1*bitsToRead; /* prepare for next round */
|
usefulBitsInByte = -1*bitsToRead; /* prepare for next round */
|
||||||
if (usefulBitsInByte > 0) {
|
if (usefulBitsInByte > 0) {
|
||||||
pi--; /* reread the current byte */
|
pi--; /* reread the current byte */
|
||||||
} else {
|
} else {
|
||||||
usefulBitsInByte = 8; /* start with next full byte */
|
usefulBitsInByte = 8; /* start with next full byte */
|
||||||
|
}
|
||||||
|
/* scaling and move value to output */
|
||||||
|
x=((lvalue*s)+reference_value)*d;
|
||||||
|
val[i] = (double)x;
|
||||||
}
|
}
|
||||||
/* scaling and move value to output */
|
return 0;
|
||||||
x=((lvalue*s)+reference_value)*d;
|
|
||||||
val[i] = (double)x;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int grib_decode_double_array_complex(const unsigned char* p, long *bitp, long nbits,double reference_value,double s,double* d,size_t size,double* val) {
|
int grib_decode_double_array_complex(const unsigned char* p, long *bitp, long nbits,double reference_value,double s,double* d,size_t size,double* val)
|
||||||
|
{
|
||||||
return GRIB_NOT_IMPLEMENTED;
|
return GRIB_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,7 +197,7 @@ int grib_encode_double_array(size_t n_vals,const double* val,long bits_per_value
|
||||||
}
|
}
|
||||||
|
|
||||||
int grib_encode_double_array_complex(size_t n_vals,double* val,long nbits,double reference_value,
|
int grib_encode_double_array_complex(size_t n_vals,double* val,long nbits,double reference_value,
|
||||||
double* scal,double d,double divisor,unsigned char* p,long *bitp) {
|
double* scal,double d,double divisor,unsigned char* p,long *bitp)
|
||||||
|
{
|
||||||
return GRIB_NOT_IMPLEMENTED;
|
return GRIB_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue