Bug fixed by David Bruken. Fixed memory allocation issue in opj_malloc.h.

Possible errors in pi_create_encode handled
This commit is contained in:
Francois-Olivier Devaux 2007-12-21 10:19:01 +00:00
parent 847b082b64
commit 287fb0b8fd
5 changed files with 160 additions and 144 deletions

View File

@ -5,6 +5,10 @@ What's New for OpenJPEG
! : changed
+ : added
December 21, 2007
* [FOD] Bug fixed by David Bruken. Fixed memory allocation issue in opj_malloc.h
! [FOD] Possible errors in pi_create_encode handled
December 19, 2007
* [Antonin] changed variables names alpha, beta, gamma, delta in dwt.c to avoid re-declarations on Macosx
! [Parvatha] In pi.c, removed the Recursive function pi_check_next_level() and modified the code.

View File

@ -75,6 +75,9 @@ Allocate memory aligned to a 16 byte boundry
#else /* Not WIN32 */
#if defined(__sun)
#define HAVE_MEMALIGN
#elif defined(__GNUC__)
#define HAVE_MEMALIGN
#include <malloc.h>
/* Linux x86_64 and OSX always align allocations to 16 bytes */
#elif !defined(__amd64__) && !defined(__APPLE__)
/* FIXME: Yes, this is a big assumption */
@ -82,6 +85,8 @@ Allocate memory aligned to a 16 byte boundry
#endif
#endif
#define opj_aligned_malloc(size) malloc(size)
#define opj_aligned_free(m) free(m)

View File

@ -726,7 +726,7 @@ bool pi_next(opj_pi_iterator_t * pi) {
return false;
}
void pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode,int cur_totnum_tp){
bool pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode,int cur_totnum_tp){
char prog[4];
int i;
int incr_top=1,resetX=0;
@ -747,6 +747,8 @@ void pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,
break;
case RPCL: strncpy(prog, "RPCL",4);
break;
case PROG_UNKNOWN:
return true;
}
if(!(cp->tp_on && ((!cp->cinema && (t2_mode == FINAL_PASS)) || cp->cinema))){
@ -956,5 +958,6 @@ void pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,
}
}
}
return false;
}

View File

@ -118,8 +118,9 @@ Modify the packet iterator for enabling tile part generation
@param tpnum Tile part number of the current tile
@param tppos The position of the tile part flag in the progression order
@param cur_totnum_tp The total number of tile parts in the current tile
@return Returns true if an error is detected
*/
void pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode,int cur_totnum_tp);
bool pi_create_encode(opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode,int cur_totnum_tp);
/**
Create a packet iterator for Decoder
@param image Raw image for which the packets will be listed

View File

@ -612,7 +612,10 @@ int t2_encode_packets(opj_t2_t* t2,int tileno, opj_tcd_tile_t *tile, int maxlaye
for(poc = 0; poc < pocno ; poc++){
int comp_len = 0;
int tpnum = compno;
pi_create_encode(pi, cp,tileno,poc,tpnum,tppos,t2_mode,cur_totnum_tp);
if (pi_create_encode(pi, cp,tileno,poc,tpnum,tppos,t2_mode,cur_totnum_tp)) {
opj_event_msg(t2->cinfo, EVT_ERROR, "Error initializing Packet Iterator\n");
return -999;
}
while (pi_next(&pi[poc])) {
if (pi[poc].layno < maxlayers) {
e = t2_encode_packet(tile, &cp->tcps[tileno], &pi[poc], c, dest + len - c, cstr_info, tileno);