[trunk]re-indenting convert.c

This commit is contained in:
Antonin Descampe 2014-02-12 14:56:49 +00:00
parent caf4e46e06
commit c81fb397bb

View File

@ -1641,7 +1641,7 @@ static void read_pnm_header(FILE *reader, struct pnm_header *ph)
} }
if(format == 2 || format == 3 || format == 5 || format == 6) if(format == 2 || format == 3 || format == 5 || format == 6)
{ {
/* P2, P3, P5, P6: */ /* P2, P3, P5, P6: */
s = skip_int(s, &ph->maxval); s = skip_int(s, &ph->maxval);
if(ph->maxval > 65535) return; if(ph->maxval > 65535) return;
@ -1776,7 +1776,7 @@ opj_image_t* pnmtoimage(const char *filename, opj_cparameters_t *parameters) {
if(!image) { fclose(fp); return NULL; } if(!image) { fclose(fp); return NULL; }
/* set image offset and reference grid */ /* set image offset and reference grid */
image->x0 = parameters->image_offset_x0; image->x0 = parameters->image_offset_x0;
image->y0 = parameters->image_offset_y0; image->y0 = parameters->image_offset_y0;
image->x1 = parameters->image_offset_x0 + (w - 1) * subsampling_dx + 1; image->x1 = parameters->image_offset_x0 + (w - 1) * subsampling_dx + 1;
@ -1823,7 +1823,7 @@ opj_image_t* pnmtoimage(const char *filename, opj_cparameters_t *parameters) {
{ {
if ( !fread(&c1, 1, 1, fp) ) if ( !fread(&c1, 1, 1, fp) )
fprintf(stderr, "\nError: fread return a number of element different from the expected.\n"); fprintf(stderr, "\nError: fread return a number of element different from the expected.\n");
/* netpbm: */ /* netpbm: */
image->comps[compno].data[i] = ((c0<<8) | c1); image->comps[compno].data[i] = ((c0<<8) | c1);
} }
} }
@ -1971,17 +1971,17 @@ int imagetopnm(opj_image_t * image, const char *outfile)
if(two) if(two)
{ {
v = *red + adjustR; ++red; v = *red + adjustR; ++red;
/* netpbm: */ /* netpbm: */
fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v); fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v);
if(triple) if(triple)
{ {
v = *green + adjustG; ++green; v = *green + adjustG; ++green;
/* netpbm: */ /* netpbm: */
fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v); fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v);
v = *blue + adjustB; ++blue; v = *blue + adjustB; ++blue;
/* netpbm: */ /* netpbm: */
fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v); fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v);
}/* if(triple) */ }/* if(triple) */
@ -1989,14 +1989,14 @@ int imagetopnm(opj_image_t * image, const char *outfile)
if(has_alpha) if(has_alpha)
{ {
v = *alpha + adjustA; ++alpha; v = *alpha + adjustA; ++alpha;
/* netpbm: */ /* netpbm: */
fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v); fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v);
} }
continue; continue;
} /* if(two) */ } /* if(two) */
/* prec <= 8: */ /* prec <= 8: */
fprintf(fdest, "%c", (unsigned char)*red++); fprintf(fdest, "%c", (unsigned char)*red++);
if(triple) if(triple)
@ -2010,7 +2010,7 @@ int imagetopnm(opj_image_t * image, const char *outfile)
fclose(fdest); return 0; fclose(fdest); return 0;
} }
/* YUV or MONO: */ /* YUV or MONO: */
if (image->numcomps > ncomp) if (image->numcomps > ncomp)
{ {
@ -2049,13 +2049,13 @@ int imagetopnm(opj_image_t * image, const char *outfile)
for (i = 0; i < wr * hr; i++) for (i = 0; i < wr * hr; i++)
{ {
v = *red + adjustR; ++red; v = *red + adjustR; ++red;
/* netpbm: */ /* netpbm: */
fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v); fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v);
if(has_alpha) if(has_alpha)
{ {
v = *alpha++; v = *alpha++;
/* netpbm: */ /* netpbm: */
fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v); fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v);
} }
}/* for(i */ }/* for(i */
@ -2340,7 +2340,7 @@ int imagetotif(opj_image_t * image, const char *outfile)
height = image->comps[0].h; height = image->comps[0].h;
imgsize = width * height; imgsize = width * height;
/* Set tags */ /* Set tags */
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width); TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width);
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, height); TIFFSetField(tif, TIFFTAG_IMAGELENGTH, height);
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1 + has_alpha); TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1 + has_alpha);
@ -2350,7 +2350,7 @@ int imagetotif(opj_image_t * image, const char *outfile)
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1); TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1);
/* Get a buffer for the data */ /* Get a buffer for the data */
strip_size = TIFFStripSize(tif); strip_size = TIFFStripSize(tif);
buf = _TIFFmalloc(strip_size); buf = _TIFFmalloc(strip_size);
index = 0; index = 0;
@ -2515,7 +2515,7 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
switch(sampleinfo[0]) switch(sampleinfo[0])
{ {
case EXTRASAMPLE_UNSPECIFIED: case EXTRASAMPLE_UNSPECIFIED:
/* Workaround for some images without correct info about alpha channel /* Workaround for some images without correct info about alpha channel
*/ */
if(tiSpp > 3) if(tiSpp > 3)
has_alpha = 1; has_alpha = 1;
@ -2531,7 +2531,7 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
if(tiSpp == 4 || tiSpp == 2) has_alpha = 1; if(tiSpp == 4 || tiSpp == 2) has_alpha = 1;
} }
/* initialize image components /* initialize image components
*/ */
memset(&cmptparm[0], 0, 4 * sizeof(opj_image_cmptparm_t)); memset(&cmptparm[0], 0, 4 * sizeof(opj_image_cmptparm_t));
@ -2540,7 +2540,7 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
numcomps = 3 + has_alpha; numcomps = 3 + has_alpha;
color_space = OPJ_CLRSPC_SRGB; color_space = OPJ_CLRSPC_SRGB;
/*#define USETILEMODE*/ /*#define USETILEMODE*/
for(j = 0; j < numcomps; j++) for(j = 0; j < numcomps; j++)
{ {
if(parameters->cp_cinema) if(parameters->cp_cinema)
@ -2574,7 +2574,7 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
TIFFClose(tif); TIFFClose(tif);
return NULL; return NULL;
} }
/* set image offset and reference grid /* set image offset and reference grid
*/ */
image->x0 = parameters->image_offset_x0; image->x0 = parameters->image_offset_x0;
image->y0 = parameters->image_offset_y0; image->y0 = parameters->image_offset_y0;
@ -2588,7 +2588,7 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
strip_size=TIFFStripSize(tif); strip_size=TIFFStripSize(tif);
index = 0; index = 0;
imgsize = image->comps[0].w * image->comps[0].h ; imgsize = image->comps[0].w * image->comps[0].h ;
/* Read the Image components /* Read the Image components
*/ */
for(strip = 0; strip < TIFFNumberOfStrips(tif); strip++) for(strip = 0; strip < TIFFNumberOfStrips(tif); strip++)
{ {
@ -2614,7 +2614,7 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
if(parameters->cp_cinema) if(parameters->cp_cinema)
{ {
/* Rounding 16 to 12 bits /* Rounding 16 to 12 bits
*/ */
image->comps[0].data[index] = image->comps[0].data[index] =
(image->comps[0].data[index] + 0x08) >> 4 ; (image->comps[0].data[index] + 0x08) >> 4 ;
@ -2651,7 +2651,7 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
if(parameters->cp_cinema) if(parameters->cp_cinema)
{ {
/* Rounding 8 to 12 bits /* Rounding 8 to 12 bits
*/ */
#ifndef USETILEMODE #ifndef USETILEMODE
image->comps[0].data[index] = image->comps[0].data[index] << 4 ; image->comps[0].data[index] = image->comps[0].data[index] << 4 ;
@ -2724,7 +2724,7 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
TIFFClose(tif); TIFFClose(tif);
return NULL; return NULL;
} }
/* set image offset and reference grid /* set image offset and reference grid
*/ */
image->x0 = parameters->image_offset_x0; image->x0 = parameters->image_offset_x0;
image->y0 = parameters->image_offset_y0; image->y0 = parameters->image_offset_y0;
@ -2738,7 +2738,7 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
strip_size = TIFFStripSize(tif); strip_size = TIFFStripSize(tif);
index = 0; index = 0;
imgsize = image->comps[0].w * image->comps[0].h ; imgsize = image->comps[0].w * image->comps[0].h ;
/* Read the Image components /* Read the Image components
*/ */
for(strip = 0; strip < TIFFNumberOfStrips(tif); strip++) for(strip = 0; strip < TIFFNumberOfStrips(tif); strip++)
{ {
@ -3105,7 +3105,7 @@ opj_image_t *pngtoimage(const char *read_idf, opj_cparameters_t * params)
unsigned char *s; unsigned char *s;
FILE *reader; FILE *reader;
unsigned char **rows; unsigned char **rows;
/* j2k: */ /* j2k: */
opj_image_t *image; opj_image_t *image;
opj_image_cmptparm_t cmptparm[4]; opj_image_cmptparm_t cmptparm[4];
int sub_dx, sub_dy; int sub_dx, sub_dy;
@ -3126,7 +3126,7 @@ opj_image_t *pngtoimage(const char *read_idf, opj_cparameters_t * params)
fprintf(stderr,"pngtoimage: %s is no valid PNG file\n",read_idf); fprintf(stderr,"pngtoimage: %s is no valid PNG file\n",read_idf);
goto fin; goto fin;
} }
/* libpng-VERSION/example.c: /* libpng-VERSION/example.c:
* PC : screen_gamma = 2.2; * PC : screen_gamma = 2.2;
* Mac: screen_gamma = 1.7 or 1.0; * Mac: screen_gamma = 1.7 or 1.0;
*/ */
@ -3151,7 +3151,7 @@ opj_image_t *pngtoimage(const char *read_idf, opj_cparameters_t * params)
&compression_type, &filter_type) == 0) &compression_type, &filter_type) == 0)
goto fin; goto fin;
/* png_set_expand(): /* png_set_expand():
* expand paletted images to RGB, expand grayscale images of * expand paletted images to RGB, expand grayscale images of
* less than 8-bit depth to 8-bit depth, and expand tRNS chunks * less than 8-bit depth to 8-bit depth, and expand tRNS chunks
* to alpha channels. * to alpha channels.
@ -3167,7 +3167,7 @@ opj_image_t *pngtoimage(const char *read_idf, opj_cparameters_t * params)
is16 = (bit_depth == 16); is16 = (bit_depth == 16);
/* GRAY => RGB; GRAY_ALPHA => RGBA /* GRAY => RGB; GRAY_ALPHA => RGBA
*/ */
if(color_type == PNG_COLOR_TYPE_GRAY if(color_type == PNG_COLOR_TYPE_GRAY
|| color_type == PNG_COLOR_TYPE_GRAY_ALPHA) || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
@ -3207,7 +3207,7 @@ opj_image_t *pngtoimage(const char *read_idf, opj_cparameters_t * params)
for(i = 0; i < nr_comp; ++i) for(i = 0; i < nr_comp; ++i)
{ {
cmptparm[i].prec = bit_depth; cmptparm[i].prec = bit_depth;
/* bits_per_pixel: 8 or 16 */ /* bits_per_pixel: 8 or 16 */
cmptparm[i].bpp = bit_depth; cmptparm[i].bpp = bit_depth;
cmptparm[i].sgnd = 0; cmptparm[i].sgnd = 0;
cmptparm[i].dx = sub_dx; cmptparm[i].dx = sub_dx;
@ -3310,7 +3310,7 @@ int imagetopng(opj_image_t * image, const char *write_idf)
info = NULL; has_alpha = 0; info = NULL; has_alpha = 0;
/* Create and initialize the png_struct with the desired error handler /* Create and initialize the png_struct with the desired error handler
* functions. If you want to use the default stderr and longjump method, * functions. If you want to use the default stderr and longjump method,
* you can supply NULL for the last three parameters. We also check that * you can supply NULL for the last three parameters. We also check that
* the library version is compatible with the one used at compile time, * the library version is compatible with the one used at compile time,
@ -3318,26 +3318,26 @@ int imagetopng(opj_image_t * image, const char *write_idf)
*/ */
png = png_create_write_struct(PNG_LIBPNG_VER_STRING, png = png_create_write_struct(PNG_LIBPNG_VER_STRING,
NULL, NULL, NULL); NULL, NULL, NULL);
/*png_voidp user_error_ptr, user_error_fn, user_warning_fn); */ /*png_voidp user_error_ptr, user_error_fn, user_warning_fn); */
if(png == NULL) goto fin; if(png == NULL) goto fin;
/* Allocate/initialize the image information data. REQUIRED /* Allocate/initialize the image information data. REQUIRED
*/ */
info = png_create_info_struct(png); info = png_create_info_struct(png);
if(info == NULL) goto fin; if(info == NULL) goto fin;
/* Set error handling. REQUIRED if you are not supplying your own /* Set error handling. REQUIRED if you are not supplying your own
* error handling functions in the png_create_write_struct() call. * error handling functions in the png_create_write_struct() call.
*/ */
if(setjmp(png_jmpbuf(png))) goto fin; if(setjmp(png_jmpbuf(png))) goto fin;
/* I/O initialization functions is REQUIRED /* I/O initialization functions is REQUIRED
*/ */
png_init_io(png, writer); png_init_io(png, writer);
/* Set the image information here. Width and height are up to 2^31, /* Set the image information here. Width and height are up to 2^31,
* bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on * bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on
* the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY, * the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY,
* PNG_COLOR_TYPE_GRAY_ALPHA, PNG_COLOR_TYPE_PALETTE, PNG_COLOR_TYPE_RGB, * PNG_COLOR_TYPE_GRAY_ALPHA, PNG_COLOR_TYPE_PALETTE, PNG_COLOR_TYPE_RGB,
@ -3411,9 +3411,9 @@ int imagetopng(opj_image_t * image, const char *write_idf)
png_set_gamma(png, 2.2, 1./2.2); png_set_gamma(png, 2.2, 1./2.2);
png_set_sRGB(png, info, PNG_sRGB_INTENT_PERCEPTUAL); png_set_sRGB(png, info, PNG_sRGB_INTENT_PERCEPTUAL);
/*=============================*/ /*=============================*/
png_write_info(png, info); png_write_info(png, info);
/*=============================*/ /*=============================*/
if(prec < 8) if(prec < 8)
{ {
png_set_packing(png); png_set_packing(png);
@ -3530,9 +3530,9 @@ int imagetopng(opj_image_t * image, const char *write_idf)
png_set_gamma(png, 2.2, 1./2.2); png_set_gamma(png, 2.2, 1./2.2);
png_set_sRGB(png, info, PNG_sRGB_INTENT_PERCEPTUAL); png_set_sRGB(png, info, PNG_sRGB_INTENT_PERCEPTUAL);
/*=============================*/ /*=============================*/
png_write_info(png, info); png_write_info(png, info);
/*=============================*/ /*=============================*/
adjustR = (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0); adjustR = (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
if(prec < 8) if(prec < 8)