Use a #define J2K_MAX_POCS 32 to avoid hard-coded constant (#349)

This commit is contained in:
Even Rouault 2017-09-20 00:55:22 +02:00
parent 9cba05762d
commit b8c4b450c4
2 changed files with 4 additions and 3 deletions

View File

@ -3502,11 +3502,10 @@ static OPJ_BOOL opj_j2k_read_poc(opj_j2k_t *p_j2k,
l_old_poc_nb = l_tcp->POC ? l_tcp->numpocs + 1 : 0;
l_current_poc_nb += l_old_poc_nb;
if (l_current_poc_nb >= 32) {
if (l_current_poc_nb >= J2K_MAX_POCS) {
opj_event_msg(p_manager, EVT_ERROR, "Too many POCs %d\n", l_current_poc_nb);
return OPJ_FALSE;
}
assert(l_current_poc_nb < 32);
/* now poc is in use.*/
l_tcp->POC = 1;

View File

@ -107,6 +107,8 @@ The functions in J2K.C have for goal to read/write the several parts of the code
#endif /* USE_JPSEC */
/* <<UniPG */
#define J2K_MAX_POCS 32 /**< Maximum number of POCs */
/* ----------------------------------------------------------------------- */
/**
@ -251,7 +253,7 @@ typedef struct opj_tcp {
/** number of progression order changes */
OPJ_UINT32 numpocs;
/** progression order changes */
opj_poc_t pocs[32];
opj_poc_t pocs[J2K_MAX_POCS];
/** number of ppt markers (reserved size) */
OPJ_UINT32 ppt_markers_count;