Fix crash on encoding if using opj_set_default_encoder_parameters() without defining tcp_numlayers
This commit is contained in:
parent
a4c938181d
commit
a316f36dfc
|
@ -1618,9 +1618,12 @@ static int parse_cmdline_encoder(int argc, char **argv,
|
|||
return 1;
|
||||
} /* mod fixed_quality */
|
||||
|
||||
|
||||
/* if no rate entered, lossless by default */
|
||||
/* Note: post v2.2.0, this is no longer necessary, but for released */
|
||||
/* versions at the time of writing, this is needed to avoid crashes */
|
||||
if (parameters->tcp_numlayers == 0) {
|
||||
parameters->tcp_rates[0] = 0; /* MOD antonin : losslessbug */
|
||||
parameters->tcp_rates[0] = 0;
|
||||
parameters->tcp_numlayers++;
|
||||
parameters->cp_disto_alloc = 1;
|
||||
}
|
||||
|
|
|
@ -6769,6 +6769,13 @@ OPJ_BOOL opj_j2k_setup_encoder(opj_j2k_t *p_j2k,
|
|||
}
|
||||
}
|
||||
|
||||
/* If no explicit layers are provided, use lossless settings */
|
||||
if (parameters->tcp_numlayers == 0) {
|
||||
parameters->tcp_numlayers = 1;
|
||||
parameters->cp_disto_alloc = 1;
|
||||
parameters->tcp_rates[0] = 0;
|
||||
}
|
||||
|
||||
/* see if max_codestream_size does limit input rate */
|
||||
if (parameters->max_cs_size <= 0) {
|
||||
if (parameters->tcp_rates[parameters->tcp_numlayers - 1] > 0) {
|
||||
|
|
Loading…
Reference in New Issue