Skip to content

Commit

Permalink
Use a #define J2K_MAX_POCS 32 to avoid hard-coded constant (#349)
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Sep 19, 2017
1 parent 9cba057 commit b8c4b45
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/lib/openjp2/j2k.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion src/lib/openjp2/j2k.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

/* ----------------------------------------------------------------------- */

/**
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit b8c4b45

Please sign in to comment.