Code improvements using 'g++-4.4.0' to trace the code (v1.4). Thanks to Winfried for this patch.

This commit is contained in:
Francois-Olivier Devaux 2010-03-24 11:20:45 +00:00
parent 3ecae15da2
commit 54214fb65f
14 changed files with 55 additions and 44 deletions

View File

@ -5,6 +5,8 @@ What's New for OpenJPEG
! : changed ! : changed
+ : added + : added
March 24, 2010
* [FOD] Code improvements using 'g++-4.4.0' to trace the code. Thanks to Winfried for this patch.
March 7, 2010 March 7, 2010
* [FOD] Fixed small compatibility issues with win32 in codec (moved include <strings.h>) * [FOD] Fixed small compatibility issues with win32 in codec (moved include <strings.h>)

View File

@ -49,7 +49,7 @@ const char *optarg; /* argument associated with option */
typedef struct option typedef struct option
{ {
char *name; const char *name;
int has_arg; int has_arg;
int *flag; int *flag;
int val; int val;

View File

@ -5,7 +5,7 @@
typedef struct option typedef struct option
{ {
char *name; const char *name;
int has_arg; int has_arg;
int *flag; int *flag;
int val; int val;

View File

@ -1463,7 +1463,7 @@ int imagetotif(opj_image_t * image, const char *outfile) {
unsigned char *dat8; unsigned char *dat8;
int i, ssize; int i, ssize;
ssize = TIFFStripSize(tif); ssize = TIFFStripSize(tif);
dat8 = buf; dat8 = (unsigned char*)buf;
if (image->comps[0].prec == 8){ if (image->comps[0].prec == 8){
for (i=0; i<ssize-2; i+=3) { // 8 bits per pixel for (i=0; i<ssize-2; i+=3) { // 8 bits per pixel
int r = 0,g = 0,b = 0; int r = 0,g = 0,b = 0;
@ -1658,7 +1658,7 @@ int imagetotif(opj_image_t * image, const char *outfile) {
for (strip = 0; strip < TIFFNumberOfStrips(tif); strip++) { for (strip = 0; strip < TIFFNumberOfStrips(tif); strip++) {
unsigned char *dat8; unsigned char *dat8;
int i; int i;
dat8 = buf; dat8 = (unsigned char*)buf;
if (image->comps[0].prec == 8){ if (image->comps[0].prec == 8){
for (i=0; i<TIFFStripSize(tif); i+=1) { // 8 bits per pixel for (i=0; i<TIFFStripSize(tif); i+=1) { // 8 bits per pixel
if(index < imgsize){ if(index < imgsize){
@ -1799,7 +1799,7 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
unsigned char *dat8; unsigned char *dat8;
int i, ssize; int i, ssize;
ssize = TIFFReadEncodedStrip(tif, strip, buf, strip_size); ssize = TIFFReadEncodedStrip(tif, strip, buf, strip_size);
dat8 = buf; dat8 = (unsigned char*)buf;
if (Info.tiBps==12){ if (Info.tiBps==12){
for (i=0; i<ssize; i+=9) { /*12 bits per pixel*/ for (i=0; i<ssize; i+=9) { /*12 bits per pixel*/
@ -1895,7 +1895,7 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
unsigned char *dat8; unsigned char *dat8;
int i, ssize; int i, ssize;
ssize = TIFFReadEncodedStrip(tif, strip, buf, strip_size); ssize = TIFFReadEncodedStrip(tif, strip, buf, strip_size);
dat8 = buf; dat8 = (unsigned char*)buf;
if (Info.tiBps==12){ if (Info.tiBps==12){
for (i=0; i<ssize; i+=3) { /* 12 bits per pixel*/ for (i=0; i<ssize; i+=3) { /* 12 bits per pixel*/

View File

@ -910,7 +910,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
while (sscanf(s, "T%d=%d,%d,%d,%d,%d,%4s", &POC[numpocs].tile, while (sscanf(s, "T%d=%d,%d,%d,%d,%d,%4s", &POC[numpocs].tile,
&POC[numpocs].resno0, &POC[numpocs].compno0, &POC[numpocs].resno0, &POC[numpocs].compno0,
&POC[numpocs].layno1, &POC[numpocs].resno1, &POC[numpocs].layno1, &POC[numpocs].resno1,
&POC[numpocs].compno1, &POC[numpocs].progorder) == 7) { &POC[numpocs].compno1, POC[numpocs].progorder) == 7) {
POC[numpocs].prg1 = give_progression(POC[numpocs].progorder); POC[numpocs].prg1 = give_progression(POC[numpocs].progorder);
numpocs++; numpocs++;
while (*s && *s != '/') { while (*s && *s != '/') {

View File

@ -73,7 +73,7 @@ typedef struct img_folder{
/** The directory path of the folder containing input images*/ /** The directory path of the folder containing input images*/
char *imgdirpath; char *imgdirpath;
/** Output format*/ /** Output format*/
char *out_format; const char *out_format;
/** Enable option*/ /** Enable option*/
char set_imgdir; char set_imgdir;
/** Enable Cod Format for output*/ /** Enable Cod Format for output*/

View File

@ -864,7 +864,7 @@ void j2k_read_sot() {
if (partno >= tile->Cztile_parts) if (partno >= tile->Cztile_parts)
{ {
tilepart_tmp = (info_tile_part_t*)malloc((INCREMENT + tile->Cztile_parts) * sizeof(info_tile_part_t)); tilepart_tmp = (info_tile_part_t*)malloc((INCREMENT + tile->Cztile_parts) * sizeof(info_tile_part_t));
memcpy(tmp, tile->tile_parts, tile->Cztile_parts); memcpy(tilepart_tmp, tile->tile_parts, tile->Cztile_parts);
tile->Cztile_parts += INCREMENT; tile->Cztile_parts += INCREMENT;
free(tile->tile_parts); free(tile->tile_parts);
tile->tile_parts = tilepart_tmp; tile->tile_parts = tilepart_tmp;
@ -1008,7 +1008,7 @@ void j2k_read_unk() {
int j2k_index_JPIP(char *Idx_file, char *J2K_file, int len, int version){ int j2k_index_JPIP(char *Idx_file, char *J2K_file, int len, int version){
FILE *dest; FILE *dest;
char *index; unsigned char *index;
int pos_iptr, end_pos; int pos_iptr, end_pos;
int len_cidx, pos_cidx; int len_cidx, pos_cidx;
int len_jp2c, pos_jp2c; int len_jp2c, pos_jp2c;
@ -1021,7 +1021,7 @@ int j2k_index_JPIP(char *Idx_file, char *J2K_file, int len, int version){
} }
/* INDEX MODE JPIP */ /* INDEX MODE JPIP */
index = (char*)malloc(len); index = (unsigned char*)malloc(len);
cio_init(index, len); cio_init(index, len);
jp2_write_jp(); jp2_write_jp();
jp2_write_ftyp(); jp2_write_ftyp();
@ -1149,7 +1149,7 @@ int main(int argc, char **argv)
{ {
FILE *src; FILE *src;
int totlen; int totlen;
char *j2kfile; unsigned char *j2kfile;
j2k_image_t *imgg; j2k_image_t *imgg;
j2k_cp_t *cp; j2k_cp_t *cp;
int version; int version;
@ -1171,7 +1171,7 @@ int main(int argc, char **argv)
totlen = ftell(src); totlen = ftell(src);
fseek(src, 0, SEEK_SET); fseek(src, 0, SEEK_SET);
j2kfile = (char*)malloc(totlen); j2kfile = (unsigned char*)malloc(totlen);
fread(j2kfile, 1, totlen, src); fread(j2kfile, 1, totlen, src);
fclose(src); fclose(src);
@ -1197,6 +1197,7 @@ int main(int argc, char **argv)
if (!j2k_decode(j2kfile, totlen, &imgg, &cp)) { if (!j2k_decode(j2kfile, totlen, &imgg, &cp)) {
fprintf(stderr, "Index_creator: failed to decode image!\n"); fprintf(stderr, "Index_creator: failed to decode image!\n");
free(j2kfile);
return 1; return 1;
} }
free(j2kfile); free(j2kfile);

View File

@ -50,7 +50,8 @@
void jp2_write_url(char *Idx_file) void jp2_write_url(char *Idx_file)
{ {
int len, lenp, i; int len, lenp;
unsigned int i;
char str[256]; char str[256];
sprintf(str, "%s", Idx_file); sprintf(str, "%s", Idx_file);

View File

@ -245,7 +245,7 @@ j2k_prog_order_t j2k_prog_order_list[] = {
{PCRL, "PCRL"}, {PCRL, "PCRL"},
{RLCP, "RLCP"}, {RLCP, "RLCP"},
{RPCL, "RPCL"}, {RPCL, "RPCL"},
{-1, ""} {(OPJ_PROG_ORDER)-1, ""}
}; };
char *j2k_convert_progression_order(OPJ_PROG_ORDER prg_order){ char *j2k_convert_progression_order(OPJ_PROG_ORDER prg_order){

View File

@ -105,7 +105,7 @@ int main(int argc, char *argv[]) {
/* setup the decoder decoding parameters using user parameters */ /* setup the decoder decoding parameters using user parameters */
movie = (opj_mj2_t*) dinfo->mj2_handle; movie = (opj_mj2_t*) dinfo->mj2_handle;
mj2_setup_decoder(dinfo->mj2_handle, &parameters); mj2_setup_decoder((opj_mj2_t*)dinfo->mj2_handle, &parameters);
if (mj2_read_struct(file, movie)) // Creating the movie structure if (mj2_read_struct(file, movie)) // Creating the movie structure
return 1; return 1;

View File

@ -234,12 +234,12 @@ int main(int argc, char **argv)
opj_cparameters_t *j2k_parameters; /* J2K compression parameters */ opj_cparameters_t *j2k_parameters; /* J2K compression parameters */
opj_event_mgr_t event_mgr; /* event manager */ opj_event_mgr_t event_mgr; /* event manager */
opj_cio_t *cio; opj_cio_t *cio;
char value; int value;
opj_mj2_t *movie; opj_mj2_t *movie;
opj_image_t *img; opj_image_t *img;
int i, j; int i, j;
char *s, S1, S2, S3; char *s, S1, S2, S3;
char *buf; unsigned char *buf;
int x1, y1, len; int x1, y1, len;
long mdat_initpos, offset; long mdat_initpos, offset;
FILE *mj2file; FILE *mj2file;
@ -519,7 +519,7 @@ int main(int argc, char **argv)
while (sscanf(s, "T%d=%d,%d,%d,%d,%d,%4s", &POC[numpocs].tile, while (sscanf(s, "T%d=%d,%d,%d,%d,%d,%4s", &POC[numpocs].tile,
&POC[numpocs].resno0, &POC[numpocs].compno0, &POC[numpocs].resno0, &POC[numpocs].compno0,
&POC[numpocs].layno1, &POC[numpocs].resno1, &POC[numpocs].layno1, &POC[numpocs].resno1,
&POC[numpocs].compno1, &POC[numpocs].progorder) == 7) { &POC[numpocs].compno1, POC[numpocs].progorder) == 7) {
POC[numpocs].prg1 = give_progression(POC[numpocs].progorder); POC[numpocs].prg1 = give_progression(POC[numpocs].progorder);
numpocs++; numpocs++;
while (*s && *s != '/') { while (*s && *s != '/') {
@ -671,7 +671,7 @@ int main(int argc, char **argv)
/* get a MJ2 decompressor handle */ /* get a MJ2 decompressor handle */
cinfo = mj2_create_compress(); cinfo = mj2_create_compress();
movie = cinfo->mj2_handle; movie = (opj_mj2_t*)cinfo->mj2_handle;
/* catch events using our callbacks and give a local context */ /* catch events using our callbacks and give a local context */
opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stderr); opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stderr);
@ -694,7 +694,7 @@ int main(int argc, char **argv)
}; };
// Writing JP, FTYP and MDAT boxes // Writing JP, FTYP and MDAT boxes
buf = (char*) malloc (300 * sizeof(char)); // Assuming that the JP and FTYP buf = (unsigned char*) malloc (300 * sizeof(unsigned char)); // Assuming that the JP and FTYP
// boxes won't be longer than 300 bytes // boxes won't be longer than 300 bytes
cio = opj_cio_open((opj_common_ptr)movie->cinfo, buf, 300); cio = opj_cio_open((opj_common_ptr)movie->cinfo, buf, 300);
mj2_write_jp(cio); mj2_write_jp(cio);
@ -722,7 +722,7 @@ int main(int argc, char **argv)
img = mj2_image_create(tk, j2k_parameters); img = mj2_image_create(tk, j2k_parameters);
buflen = 2 * (tk->w * tk->h * 8); buflen = 2 * (tk->w * tk->h * 8);
buf = (char *) malloc(buflen*sizeof(char)); buf = (unsigned char *) malloc(buflen*sizeof(unsigned char));
for (sampleno = 0; sampleno < numframes; sampleno++) { for (sampleno = 0; sampleno < numframes; sampleno++) {
double init_time = opj_clock(); double init_time = opj_clock();
@ -771,7 +771,7 @@ int main(int argc, char **argv)
fseek(mj2file, mdat_initpos, SEEK_SET); fseek(mj2file, mdat_initpos, SEEK_SET);
buf = (char*) malloc(4*sizeof(char)); buf = (unsigned char*) malloc(4*sizeof(unsigned char));
// Init a cio to write box length variable in a little endian way // Init a cio to write box length variable in a little endian way
cio = opj_cio_open(NULL, buf, 4); cio = opj_cio_open(NULL, buf, 4);
@ -781,7 +781,7 @@ int main(int argc, char **argv)
free(buf); free(buf);
// Writing MOOV box // Writing MOOV box
buf = (char*) malloc ((TEMP_BUF+numframes*20) * sizeof(char)); buf = (unsigned char*) malloc ((TEMP_BUF+numframes*20) * sizeof(unsigned char));
cio = opj_cio_open(movie->cinfo, buf, (TEMP_BUF+numframes*20)); cio = opj_cio_open(movie->cinfo, buf, (TEMP_BUF+numframes*20));
mj2_write_moov(movie, cio); mj2_write_moov(movie, cio);
fwrite(buf,cio_tell(cio),1,mj2file); fwrite(buf,cio_tell(cio),1,mj2file);

View File

@ -42,8 +42,9 @@ Read box headers
@param box @param box
@return Returns true if successful, returns false otherwise @return Returns true if successful, returns false otherwise
*/ */
/*-- UNUSED
static bool jp2_read_boxhdr(opj_common_ptr cinfo, opj_cio_t *cio, opj_jp2_box_t *box); static bool jp2_read_boxhdr(opj_common_ptr cinfo, opj_cio_t *cio, opj_jp2_box_t *box);
--*/
/* /*
* *
* Read box headers * Read box headers
@ -269,7 +270,8 @@ void mj2_stsc_decompact(mj2_tk_t * tk)
tk->chunk[k].num_samples = tk->chunk[k].num_samples =
tk->sampletochunk[tk->num_samplestochunk - 1].samples_per_chunk; tk->sampletochunk[tk->num_samplestochunk - 1].samples_per_chunk;
} }
tk->chunk = opj_realloc(tk->chunk, tk->num_chunks * sizeof(mj2_chunk_t)); tk->chunk = (mj2_chunk_t*)
opj_realloc(tk->chunk, tk->num_chunks * sizeof(mj2_chunk_t));
} }
} }
@ -1163,7 +1165,7 @@ int mj2_read_smj2(opj_image_t * img, mj2_tk_t * tk, opj_cio_t *cio)
} }
tk->jp2_struct.comps = (opj_jp2_comps_t*) opj_malloc(tk->jp2_struct.numcomps * sizeof(opj_jp2_comps_t)); tk->jp2_struct.comps = (opj_jp2_comps_t*) opj_malloc(tk->jp2_struct.numcomps * sizeof(opj_jp2_comps_t));
tk->jp2_struct.cl = (int*) opj_malloc(sizeof(int)); tk->jp2_struct.cl = (unsigned int*) opj_malloc(sizeof(unsigned int));
tk->num_br = 0; tk->num_br = 0;
tk->num_jp2x = 0; tk->num_jp2x = 0;
@ -2604,13 +2606,13 @@ int mj2_read_moov(opj_mj2_t * movie, opj_image_t * img, opj_cio_t *cio)
int mj2_read_struct(FILE *file, opj_mj2_t *movie) { int mj2_read_struct(FILE *file, opj_mj2_t *movie) {
mj2_box_t box; mj2_box_t box;
opj_image_t img; opj_image_t img;
char * src; unsigned char * src;
int fsresult; int fsresult;
int foffset; int foffset;
opj_cio_t *cio; opj_cio_t *cio;
/* open a byte stream for reading */ /* open a byte stream for reading */
src = (char*) opj_malloc(300 * sizeof(char)); src = (unsigned char*) opj_malloc(300 * sizeof(unsigned char));
/* Assuming that jp and ftyp markers size do /* Assuming that jp and ftyp markers size do
not exceed 300 bytes */ not exceed 300 bytes */
@ -2694,7 +2696,7 @@ int mj2_read_struct(FILE *file, opj_mj2_t *movie) {
} }
fseek(file,foffset,SEEK_SET); fseek(file,foffset,SEEK_SET);
src = opj_realloc(src,box.length); src = (unsigned char*)opj_realloc(src,box.length);
fsresult = fread(src,box.length,1,file); fsresult = fread(src,box.length,1,file);
if (fsresult != 1) { if (fsresult != 1) {
opj_event_msg(cio->cinfo, EVT_ERROR, "End of file reached while trying to read MOOV box\n"); opj_event_msg(cio->cinfo, EVT_ERROR, "End of file reached while trying to read MOOV box\n");
@ -2738,7 +2740,8 @@ void mj2_setup_decoder(opj_mj2_t *movie, mj2_dparameters_t *mj2_parameters) {
movie->num_htk=0; movie->num_htk=0;
/* setup the J2K decoder parameters */ /* setup the J2K decoder parameters */
j2k_setup_decoder(movie->cinfo->j2k_handle, &mj2_parameters->j2k_parameters); j2k_setup_decoder((opj_j2k_t*)movie->cinfo->j2k_handle,
&mj2_parameters->j2k_parameters);
} }
@ -2846,7 +2849,7 @@ void mj2_setup_encoder(opj_mj2_t *movie, mj2_cparameters_t *parameters) {
jp2_struct->brand = JP2_JP2; /* BR */ jp2_struct->brand = JP2_JP2; /* BR */
jp2_struct->minversion = 0; /* MinV */ jp2_struct->minversion = 0; /* MinV */
jp2_struct->numcl = 1; jp2_struct->numcl = 1;
jp2_struct->cl = (unsigned int*) opj_malloc(jp2_struct->numcl * sizeof(int)); jp2_struct->cl = (unsigned int*) opj_malloc(jp2_struct->numcl * sizeof(unsigned int));
jp2_struct->cl[0] = JP2_JP2; /* CL0 : JP2 */ jp2_struct->cl[0] = JP2_JP2; /* CL0 : JP2 */
jp2_struct->C = 7; /* C : Always 7*/ jp2_struct->C = 7; /* C : Always 7*/
jp2_struct->UnkC = 0; /* UnkC, colorspace specified in colr box*/ jp2_struct->UnkC = 0; /* UnkC, colorspace specified in colr box*/

View File

@ -112,7 +112,7 @@ int main(int argc, char *argv[]) {
/* get a MJ2 decompressor handle */ /* get a MJ2 decompressor handle */
dinfo = mj2_create_decompress(); dinfo = mj2_create_decompress();
movie = dinfo->mj2_handle; movie = (opj_mj2_t*)dinfo->mj2_handle;
/* catch events using our callbacks and give a local context */ /* catch events using our callbacks and give a local context */
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr); opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
@ -121,7 +121,7 @@ int main(int argc, char *argv[]) {
opj_set_default_decoder_parameters(&mj2_parameters.j2k_parameters); opj_set_default_decoder_parameters(&mj2_parameters.j2k_parameters);
/* setup the decoder decoding parameters using user parameters */ /* setup the decoder decoding parameters using user parameters */
mj2_setup_decoder(dinfo->mj2_handle, &mj2_parameters); mj2_setup_decoder((opj_mj2_t*)dinfo->mj2_handle, &mj2_parameters);
if (mj2_read_struct(file, movie)) // Creating the movie structure if (mj2_read_struct(file, movie)) // Creating the movie structure
return 1; return 1;
@ -156,7 +156,8 @@ int main(int argc, char *argv[]) {
sample = &track->sample[snum]; sample = &track->sample[snum];
if (sample->sample_size-8 > max_codstrm_size) { if (sample->sample_size-8 > max_codstrm_size) {
max_codstrm_size = sample->sample_size-8; max_codstrm_size = sample->sample_size-8;
if ((frame_codestream = realloc(frame_codestream, max_codstrm_size)) == NULL) { if ((frame_codestream = (unsigned char*)
realloc(frame_codestream, max_codstrm_size)) == NULL) {
printf("Error reallocation memory\n"); printf("Error reallocation memory\n");
return 1; return 1;
}; };

View File

@ -78,7 +78,7 @@ static void read_siz_marker(FILE *file, opj_image_t *image)
{ {
int len,i; int len,i;
char buf, buf2[2]; char buf, buf2[2];
char *siz_buffer; unsigned char *siz_buffer;
opj_cio_t *cio; opj_cio_t *cio;
fseek(file, 0, SEEK_SET); fseek(file, 0, SEEK_SET);
@ -92,7 +92,7 @@ static void read_siz_marker(FILE *file, opj_image_t *image)
fread(buf2,2,1,file); /* Lsiz */ fread(buf2,2,1,file); /* Lsiz */
len = ((buf2[0])<<8) + buf2[1]; len = ((buf2[0])<<8) + buf2[1];
siz_buffer = (char*) malloc(len * sizeof(char)); siz_buffer = (unsigned char*) malloc(len * sizeof(unsigned char));
fread(siz_buffer,len, 1, file); fread(siz_buffer,len, 1, file);
cio = opj_cio_open(NULL, siz_buffer, len); cio = opj_cio_open(NULL, siz_buffer, len);
@ -119,6 +119,7 @@ static void read_siz_marker(FILE *file, opj_image_t *image)
} }
fseek(file, 0, SEEK_SET); fseek(file, 0, SEEK_SET);
opj_cio_close(cio); opj_cio_close(cio);
free(siz_buffer);
} }
static void setparams(opj_mj2_t *movie, opj_image_t *image) { static void setparams(opj_mj2_t *movie, opj_image_t *image) {
@ -213,7 +214,7 @@ int main(int argc, char *argv[]) {
unsigned char* frame_codestream; unsigned char* frame_codestream;
FILE *mj2file, *j2kfile; FILE *mj2file, *j2kfile;
char j2kfilename[50]; char j2kfilename[50];
char *buf; unsigned char *buf;
int offset, mdat_initpos; int offset, mdat_initpos;
opj_image_t img; opj_image_t img;
opj_cio_t *cio; opj_cio_t *cio;
@ -249,13 +250,13 @@ int main(int argc, char *argv[]) {
/* setup the decoder encoding parameters using user parameters */ /* setup the decoder encoding parameters using user parameters */
movie = (opj_mj2_t*) cinfo->mj2_handle; movie = (opj_mj2_t*) cinfo->mj2_handle;
mj2_setup_encoder(cinfo->mj2_handle, &parameters); mj2_setup_encoder((opj_mj2_t*)cinfo->mj2_handle, &parameters);
/* Writing JP, FTYP and MDAT boxes /* Writing JP, FTYP and MDAT boxes
Assuming that the JP and FTYP boxes won't be longer than 300 bytes */ Assuming that the JP and FTYP boxes won't be longer than 300 bytes */
buf = (char*) malloc (300 * sizeof(char)); buf = (unsigned char*) malloc (300 * sizeof(unsigned char));
cio = opj_cio_open(movie->cinfo, buf, 300); cio = opj_cio_open(movie->cinfo, buf, 300);
mj2_write_jp(cio); mj2_write_jp(cio);
mj2_write_ftyp(movie, cio); mj2_write_ftyp(movie, cio);
@ -312,14 +313,16 @@ int main(int argc, char *argv[]) {
// Ending loop // Ending loop
fclose(j2kfile); fclose(j2kfile);
snum++; snum++;
movie->tk[0].sample = realloc(movie->tk[0].sample, (snum+1) * sizeof(mj2_sample_t)); movie->tk[0].sample = (mj2_sample_t*)
movie->tk[0].chunk = realloc(movie->tk[0].chunk, (snum+1) * sizeof(mj2_chunk_t)); realloc(movie->tk[0].sample, (snum+1) * sizeof(mj2_sample_t));
movie->tk[0].chunk = (mj2_chunk_t*)
realloc(movie->tk[0].chunk, (snum+1) * sizeof(mj2_chunk_t));
free(frame_codestream); free(frame_codestream);
} }
// Writing the MDAT box length in header // Writing the MDAT box length in header
offset += cio_tell(cio); offset += cio_tell(cio);
buf = (char*) malloc (4 * sizeof(char)); buf = (unsigned char*) malloc (4 * sizeof(unsigned char));
cio = opj_cio_open(movie->cinfo, buf, 4); cio = opj_cio_open(movie->cinfo, buf, 4);
cio_write(cio,offset-mdat_initpos,4); cio_write(cio,offset-mdat_initpos,4);
fseek(mj2file,(long)mdat_initpos,SEEK_SET); fseek(mj2file,(long)mdat_initpos,SEEK_SET);
@ -333,7 +336,7 @@ int main(int argc, char *argv[]) {
setparams(movie, &img); setparams(movie, &img);
// Writing MOOV box // Writing MOOV box
buf = (char*) malloc ((TEMP_BUF+snum*20) * sizeof(char)); buf = (unsigned char*) malloc ((TEMP_BUF+snum*20) * sizeof(unsigned char));
cio = opj_cio_open(movie->cinfo, buf, (TEMP_BUF+snum*20)); cio = opj_cio_open(movie->cinfo, buf, (TEMP_BUF+snum*20));
mj2_write_moov(movie, cio); mj2_write_moov(movie, cio);
fwrite(buf,cio_tell(cio),1,mj2file); fwrite(buf,cio_tell(cio),1,mj2file);