opj_j2k_setup_encoder(): validate code block width/height
This commit is contained in:
parent
84bbb4a874
commit
0a25dceca7
|
@ -6730,6 +6730,7 @@ OPJ_BOOL opj_j2k_setup_encoder(opj_j2k_t *p_j2k,
|
||||||
{
|
{
|
||||||
OPJ_UINT32 i, j, tileno, numpocs_tile;
|
OPJ_UINT32 i, j, tileno, numpocs_tile;
|
||||||
opj_cp_t *cp = 00;
|
opj_cp_t *cp = 00;
|
||||||
|
OPJ_UINT32 cblkw, cblkh;
|
||||||
|
|
||||||
if (!p_j2k || !parameters || ! image) {
|
if (!p_j2k || !parameters || ! image) {
|
||||||
return OPJ_FALSE;
|
return OPJ_FALSE;
|
||||||
|
@ -6743,6 +6744,38 @@ OPJ_BOOL opj_j2k_setup_encoder(opj_j2k_t *p_j2k,
|
||||||
return OPJ_FALSE;
|
return OPJ_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (parameters->cblockw_init < 4 || parameters->cblockw_init > 1024) {
|
||||||
|
opj_event_msg(p_manager, EVT_ERROR,
|
||||||
|
"Invalid value for cblockw_init: %d not a power of 2 in range [4,1024]\n",
|
||||||
|
parameters->cblockw_init);
|
||||||
|
return OPJ_FALSE;
|
||||||
|
}
|
||||||
|
if (parameters->cblockh_init < 4 || parameters->cblockh_init > 1024) {
|
||||||
|
opj_event_msg(p_manager, EVT_ERROR,
|
||||||
|
"Invalid value for cblockh_init: %d not a power of 2 not in range [4,1024]\n",
|
||||||
|
parameters->cblockh_init);
|
||||||
|
return OPJ_FALSE;
|
||||||
|
}
|
||||||
|
if (parameters->cblockw_init * parameters->cblockh_init > 4096) {
|
||||||
|
opj_event_msg(p_manager, EVT_ERROR,
|
||||||
|
"Invalid value for cblockw_init * cblockh_init: should be <= 4096\n");
|
||||||
|
return OPJ_FALSE;
|
||||||
|
}
|
||||||
|
cblkw = (OPJ_UINT32)opj_int_floorlog2(parameters->cblockw_init);
|
||||||
|
cblkh = (OPJ_UINT32)opj_int_floorlog2(parameters->cblockh_init);
|
||||||
|
if (parameters->cblockw_init != (1 << cblkw)) {
|
||||||
|
opj_event_msg(p_manager, EVT_ERROR,
|
||||||
|
"Invalid value for cblockw_init: %d not a power of 2 in range [4,1024]\n",
|
||||||
|
parameters->cblockw_init);
|
||||||
|
return OPJ_FALSE;
|
||||||
|
}
|
||||||
|
if (parameters->cblockh_init != (1 << cblkh)) {
|
||||||
|
opj_event_msg(p_manager, EVT_ERROR,
|
||||||
|
"Invalid value for cblockw_init: %d not a power of 2 in range [4,1024]\n",
|
||||||
|
parameters->cblockh_init);
|
||||||
|
return OPJ_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* keep a link to cp so that we can destroy it later in j2k_destroy_compress */
|
/* keep a link to cp so that we can destroy it later in j2k_destroy_compress */
|
||||||
cp = &(p_j2k->m_cp);
|
cp = &(p_j2k->m_cp);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue