From 899439a9063e5bf0af9da001c6541568b3efda6a Mon Sep 17 00:00:00 2001 From: Francois-Olivier Devaux Date: Thu, 9 Sep 2004 13:34:20 +0000 Subject: [PATCH] Bug with tk->imagefile pointer fixed --- mj2/mj2.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/mj2/mj2.c b/mj2/mj2.c index 1d770679..dea20bb4 100644 --- a/mj2/mj2.c +++ b/mj2/mj2.c @@ -581,16 +581,14 @@ int mj2_read_mdat(mj2_movie_t * movie, unsigned char *src, char *outfile) fclose(f); for (track_nb = 0; track_nb < movie->next_tk_id - 1; track_nb++) { - if ((movie->tk->imagefile != (char *) 0xcdcdcdcd) - && (movie->tk->imagefile != NULL)) { + if (movie->tk[track_nb].imagefile != NULL) { fprintf(stderr, "%s", movie->tk[track_nb].imagefile); - f = fopen(movie->tk->imagefile, "w"); /* Erase content of file if it already exists */ + f = fopen(movie->tk[track_nb].imagefile, "w"); // Erase content of file if it already exists fclose(f); } } - for (track_nb = 0; track_nb < movie->num_htk + movie->num_stk + movie->num_vtk; track_nb++) { @@ -602,10 +600,11 @@ int mj2_read_mdat(mj2_movie_t * movie, unsigned char *src, char *outfile) fprintf(stderr, "Track %d: Width=%d Height=%d\n", track_nb, tk->w, tk->h); fprintf(stderr, "%d Samples\n", tk->num_samples); - if ((tk->imagefile == (char *) 0xcdcdcdcd) - || (movie->tk->imagefile == NULL)) { + + if (tk->imagefile == NULL) { tk->imagefile = outfile; } + for (i = 0; i < tk->num_samples; i++) { mj2_sample_t *sample = &tk->sample[i]; @@ -613,7 +612,7 @@ int mj2_read_mdat(mj2_movie_t * movie, unsigned char *src, char *outfile) j2k_cp_t cp; unsigned char *pos; - fprintf(stderr, "Frame %d: \n", i); + fprintf(stderr, "Frame %d / %d: \n", i+1, tk->num_samples); cio_init(src + sample->offset, 8); @@ -2813,6 +2812,9 @@ int mj2_read_moov(mj2_movie_t * movie, j2k_image_t * img) movie->tk = (mj2_tk_t *) malloc((movie->next_tk_id - 1) * sizeof(mj2_tk_t)); + for (i=0; i < (unsigned int)movie->next_tk_id - 1; i++) + movie->tk[i].imagefile = NULL; + for (i = 0; cio_tell() - box.init_pos < box.length; i++) { mj2_read_boxhdr(&box2); if (box2.type == MJ2_TRAK) {