ecc-1968: Workaround for 24 bitsPerValue in complex packing

This commit is contained in:
Eugen Betke 2024-11-18 14:53:33 +01:00
parent 2772079955
commit ead34253cf
2 changed files with 10 additions and 3 deletions

View File

@ -808,6 +808,13 @@ int grib_accessor_data_g22order_packing_t::pack_double(const double* val, size_t
if ((err = grib_get_long_internal(gh, bits_per_value_, &bits_per_value)) != GRIB_SUCCESS)
return err;
// ECC-1968: For bits_per_value > 23, the complex packing algorithm may use more than 25 bits per value.
// However, this exceeds the maximum number of bits for the packing algorithm.
if (bits_per_value > 23) {
bits_per_value = 23;
}
if ((err = grib_get_long_internal(gh, decimal_scale_factor_, &decimal_scale_factor)) != GRIB_SUCCESS)
return err;
@ -1463,7 +1470,7 @@ template <typename T>
int grib_accessor_data_g22order_packing_t::unpack(T* val, size_t* len)
{
static_assert(std::is_floating_point<T>::value, "Requires floating points numbers");
grib_handle* gh = grib_handle_of_accessor(this);
grib_handle* gh = grib_handle_of_accessor(this);
size_t i = 0;
size_t j = 0;

View File

@ -188,8 +188,8 @@ static int notify_change(grib_action* a, grib_accessor* observer, grib_accessor*
#ifdef CHECK_LOOP
if (self->loop) {
printf("LOOP detected...\n");
printf("WHEN triggered by %s %ld\n", observed->name, lres);
grib_expression_print(observed->context, self->expression, 0, stderr);
printf("WHEN triggered by %s %ld\n", observed->name_, lres);
grib_expression_print(observed->context_, self->expression, 0, stderr);
fprintf(stderr, "\n");
return ret;
}