[1.5] Make sure openjpeg/mj2 can be compiled with gcc -std=c89

This commit is contained in:
Mathieu Malaterre 2012-05-29 17:42:17 +00:00
parent cd8896968d
commit b8fecbbc99
3 changed files with 42 additions and 42 deletions

View File

@ -698,7 +698,7 @@ int main(int argc, char **argv)
goto fin;
}
// One sample per chunk
/* One sample per chunk */
movie->tk[0].chunk = (mj2_chunk_t*)
malloc(movie->tk[0].num_samples * sizeof(mj2_chunk_t));
movie->tk[0].sample = (mj2_sample_t*)
@ -712,8 +712,8 @@ int main(int argc, char **argv)
goto fin;
}
// Writing JP, FTYP and MDAT boxes
// Assuming that the JP and FTYP boxes won't be longer than 300 bytes:
/* Writing JP, FTYP and MDAT boxes */
/* Assuming that the JP and FTYP boxes won't be longer than 300 bytes:*/
buf = (unsigned char*)
malloc (300 * sizeof(unsigned char));
if(buf == NULL) goto fin;
@ -810,7 +810,7 @@ int main(int argc, char **argv)
track->sample[sampleno].sample_size = len+8;
track->sample[sampleno].offset = offset;
track->chunk[sampleno].offset = offset; // There is one sample per chunk
track->chunk[sampleno].offset = offset; /* There is one sample per chunk */
fwrite(buf, 1, len+8, mj2file);
offset += len+8;

View File

@ -1236,10 +1236,10 @@ void mj2_write_stsd(mj2_tk_t * tk, opj_cio_t *cio)
if (tk->track_type == 0) {
mj2_write_smj2(tk, cio);
} else if (tk->track_type == 1) {
// Not implemented
/* Not implemented */
}
if (tk->track_type == 2) {
// Not implemented
/* Not implemented */
}
@ -1287,10 +1287,10 @@ int mj2_read_stsd(mj2_tk_t * tk, opj_image_t * img, opj_cio_t *cio)
return 1;
}
} else if (tk->track_type == 1) {
len_2skip = cio_read(cio, 4); // Not implemented -> skipping box
len_2skip = cio_read(cio, 4); /* Not implemented -> skipping box */
cio_skip(cio,len_2skip - 4);
} else if (tk->track_type == 2) {
len_2skip = cio_read(cio, 4); // Not implemented -> skipping box
len_2skip = cio_read(cio, 4); /* Not implemented -> skipping box */
cio_skip(cio,len_2skip - 4);
}
@ -2111,7 +2111,7 @@ int mj2_read_mdhd(mj2_tk_t * tk, opj_cio_t *cio)
mj2_box_t box;
mj2_read_boxhdr(&box, cio);
if (!(MJ2_MHDR == box.type || MJ2_MDHD == box.type)) { // Kakadu writes MHDR instead of MDHD
if (!(MJ2_MHDR == box.type || MJ2_MDHD == box.type)) { /* Kakadu writes MHDR instead of MDHD */
opj_event_msg(cio->cinfo, EVT_ERROR, "Error: Expected MDHD Marker\n");
return 1;
}
@ -2765,7 +2765,7 @@ void mj2_destroy_decompress(opj_mj2_t *movie) {
tk = &movie->tk[i];
if (tk->name_size != 0)
opj_free(tk->name);
if (tk->track_type == 0) {// Video track
if (tk->track_type == 0) {/* Video track */
if (tk->jp2_struct.comps != NULL)
opj_free(tk->jp2_struct.comps);
if (tk->jp2_struct.cl != NULL)
@ -2821,20 +2821,20 @@ void mj2_setup_encoder(opj_mj2_t *movie, mj2_cparameters_t *parameters) {
if(movie && parameters) {
opj_jp2_t *jp2_struct;
movie->num_htk = 0; // No hint tracks
movie->num_stk = 0; // No sound tracks
movie->num_vtk = 1; // One video track
movie->num_htk = 0; /* No hint tracks */
movie->num_stk = 0; /* No sound tracks */
movie->num_vtk = 1; /* One video track */
movie->brand = MJ2_MJ2; // One brand: MJ2
movie->num_cl = 2; // Two compatible brands: MJ2 and MJ2S
movie->brand = MJ2_MJ2; /* One brand: MJ2 */
movie->num_cl = 2; /* Two compatible brands: MJ2 and MJ2S */
movie->cl = (unsigned int*) opj_malloc(movie->num_cl * sizeof(unsigned int));
movie->cl[0] = MJ2_MJ2;
movie->cl[1] = MJ2_MJ2S;
movie->minversion = 0; // Minimum version: 0
movie->minversion = 0; /* Minimum version: 0 */
movie->tk = (mj2_tk_t*) opj_malloc(sizeof(mj2_tk_t)); //Memory allocation for the video track
movie->tk[0].track_ID = 1; // Track ID = 1
movie->tk[0].track_type = 0; // Video track
movie->tk = (mj2_tk_t*) opj_malloc(sizeof(mj2_tk_t)); /*Memory allocation for the video track*/
movie->tk[0].track_ID = 1; /* Track ID = 1 */
movie->tk[0].track_type = 0; /* Video track */
movie->tk[0].Dim[0] = parameters->Dim[0];
movie->tk[0].Dim[1] = parameters->Dim[1];
movie->tk[0].w = parameters->w;
@ -2848,7 +2848,7 @@ void mj2_setup_encoder(opj_mj2_t *movie, mj2_cparameters_t *parameters) {
movie->tk[0].depth = parameters->prec;
jp2_struct = &movie->tk[0].jp2_struct;
jp2_struct->numcomps = parameters->numcomps; // NC
jp2_struct->numcomps = parameters->numcomps; /* NC */
jp2_struct->comps = (opj_jp2_comps_t*) opj_malloc(jp2_struct->numcomps * sizeof(opj_jp2_comps_t));
jp2_struct->precedence = 0; /* PRECEDENCE*/
jp2_struct->approx = 0; /* APPROX*/
@ -2884,7 +2884,7 @@ void mj2_destroy_compress(opj_mj2_t *movie) {
tk = &movie->tk[i];
if (tk->name_size != 0)
opj_free(tk->name);
if (tk->track_type == 0) {// Video track
if (tk->track_type == 0) {/* Video track */
if (tk->jp2_struct.comps != NULL)
opj_free(tk->jp2_struct.comps);
if (tk->jp2_struct.cl != NULL)

View File

@ -67,12 +67,12 @@ unsigned int yuv_num_frames(mj2_tk_t * tk, char *infile)
return (unsigned int)(end_of_f / frame_size);
}
// -----------------------
//
//
// YUV to IMAGE
//
// -----------------------
/* -----------------------
YUV to IMAGE
-----------------------*/
opj_image_t *mj2_image_create(mj2_tk_t * tk, opj_cparameters_t *parameters)
{
@ -169,12 +169,12 @@ char yuvtoimage(mj2_tk_t * tk, opj_image_t * img, int frame_num, opj_cparameters
// -----------------------
//
//
// IMAGE to YUV
//
// -----------------------
/* -----------------------
IMAGE to YUV
-----------------------*/
opj_bool imagetoyuv(opj_image_t * img, char *outfile)
@ -263,12 +263,12 @@ opj_bool imagetoyuv(opj_image_t * img, char *outfile)
return OPJ_TRUE;
}
// -----------------------
//
//
// IMAGE to BMP
//
// -----------------------
/* -----------------------
IMAGE to BMP
-----------------------*/
int imagetobmp(opj_image_t * img, char *outfile) {
int w,wr,h,hr,i,pad;
@ -353,11 +353,11 @@ int imagetobmp(opj_image_t * img, char *outfile) {
for (i = 0; i < wr * hr; i++) {
unsigned char R, G, B;
/* a modifier */
// R = img->comps[0].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
/* R = img->comps[0].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];*/
R = img->comps[0].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)];
// G = img->comps[1].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
/* G = img->comps[1].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];*/
G = img->comps[1].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)];
// B = img->comps[2].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
/* B = img->comps[2].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];*/
B = img->comps[2].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)];
fprintf(f, "%c%c%c", B, G, R);