mirror of https://github.com/ecmwf/eccodes.git
GRIB-438: Error encoding values with mars formula (JPEG data)
This commit is contained in:
parent
4baa71d7eb
commit
4e97d036ee
|
@ -200,7 +200,6 @@ static void init(grib_accessor* a,const long v, grib_arguments* args)
|
|||
printf("GRIB JPEG dumping to %s\n",self->dump_jpg);
|
||||
first = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static long value_count(grib_accessor* a)
|
||||
|
@ -464,6 +463,15 @@ static int pack_double(grib_accessor* a, const double* cval, size_t *len)
|
|||
helper.jpeg_buffer = buf;
|
||||
helper.width = width;
|
||||
helper.height = height;
|
||||
|
||||
/* See GRIB-438 */
|
||||
if (bits_per_value == 0) {
|
||||
const long bits_per_value_adjusted = 1;
|
||||
grib_context_log(a->parent->h->context, GRIB_LOG_DEBUG,
|
||||
"grib_accessor_class_data_jpeg2000_packing(%s) : bits per value was zero, changed to %d",
|
||||
self->jpeg_lib==OPENJPEG_LIB ? "openjpeg" : "jasper", bits_per_value_adjusted);
|
||||
bits_per_value = bits_per_value_adjusted;
|
||||
}
|
||||
helper.bits_per_value = bits_per_value;
|
||||
|
||||
helper.buffer_size = simple_packing_size + EXTRA_BUFFER_SIZE;
|
||||
|
@ -504,7 +512,7 @@ static int pack_double(grib_accessor* a, const double* cval, size_t *len)
|
|||
|
||||
grib_buffer_replace(a, helper.jpeg_buffer, helper.jpeg_length, 1, 1);
|
||||
|
||||
cleanup:
|
||||
cleanup:
|
||||
|
||||
grib_context_free(a->parent->h->context,buf);
|
||||
|
||||
|
|
|
@ -57,7 +57,6 @@ int grib_jasper_decode(grib_context *c,unsigned char *buf, size_t *buflen, doubl
|
|||
|
||||
Assert(p->height_ * p->width_ == *no_values);
|
||||
|
||||
|
||||
k=0;
|
||||
for (i=0;i<p->height_;i++)
|
||||
for (j=0;j<p->width_;j++) {
|
||||
|
@ -118,11 +117,9 @@ int grib_jasper_encode(grib_context *c, j2k_encode_helper *helper) {
|
|||
cmpt.sgnd_ = 0;
|
||||
cmpt.cps_ = (helper->bits_per_value+7)/8;
|
||||
|
||||
|
||||
/* Simple packing encoding */
|
||||
|
||||
|
||||
bits8 = (helper->bits_per_value+7)/8*8;
|
||||
Assert(bits8 > 0);
|
||||
encoded = grib_context_malloc_clear(c,bits8/8*no_values);
|
||||
|
||||
if(!encoded) {
|
||||
|
@ -145,7 +142,6 @@ int grib_jasper_encode(grib_context *c, j2k_encode_helper *helper) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*jas_init();*/
|
||||
|
||||
opts[0] = 0;
|
||||
|
|
Loading…
Reference in New Issue