ENH: Minor cleanup, mainly comment and line too long

This commit is contained in:
Mathieu Malaterre 2006-07-21 20:28:44 +00:00
parent d55af7fe7e
commit 190b4b7c9e
3 changed files with 89 additions and 75 deletions

View File

@ -1048,3 +1048,5 @@ int imagetopnm(opj_image_t * image, char *outfile) {
return 0;
}

View File

@ -201,8 +201,12 @@ OPJ_PROG_ORDER give_progression(char progression[4]) {
int get_file_format(char *filename) {
unsigned int i;
static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp", "j2k", "jp2" };
static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, J2K_CFMT, JP2_CFMT };
static const char *extension[] = {
"pgx", "pnm", "pgm", "ppm", "bmp", "j2k", "jp2"
};
static const int format[] = {
PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, J2K_CFMT, JP2_CFMT
};
char * ext = strrchr(filename, '.') + 1;
for(i = 0; i < sizeof(format)/sizeof(*format); i++) {
if(strnicmp(ext, extension[i], 3) == 0) {
@ -213,7 +217,7 @@ int get_file_format(char *filename) {
return -1;
}
/* ------------------------------------------------------------------------------------ */
/* -------------------------------------------------------------------------*/
int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters) {
int i, j;
@ -236,7 +240,8 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
break;
default:
fprintf(stderr,
"!! Unrecognized format for infile : %s [accept only *.pnm, *.pgm, *.ppm, *.pgx or *.bmp] !!\n\n",
"!! Unrecognized format for infile : %s "
"[accept only *.pnm, *.pgm, *.ppm, *.pgx or *.bmp] !!\n\n",
infile);
return 1;
}
@ -372,7 +377,8 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
char *s = optarg;
do {
sep = 0;
sscanf(s, "[%d,%d]%c", &parameters->prcw_init[res_spec], &parameters->prch_init[res_spec], &sep);
sscanf(s, "[%d,%d]%c", &parameters->prcw_init[res_spec],
&parameters->prch_init[res_spec], &sep);
parameters->csty |= 0x01;
res_spec++;
s = strpbrk(s, "]") + 2;
@ -391,7 +397,8 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
if (cblockw_init * cblockh_init > 4096 || cblockw_init > 1024
|| cblockw_init < 4 || cblockh_init > 1024 || cblockh_init < 4) {
fprintf(stderr,
"!! Size of code_block error (option -b) !!\n\nRestriction :\n * width*height<=4096\n * 4<=width,height<= 1024\n\n");
"!! Size of code_block error (option -b) !!\n\nRestriction :\n"
" * width*height<=4096\n * 4<=width,height<= 1024\n\n");
return 1;
}
parameters->cblockw_init = cblockw_init;
@ -418,7 +425,8 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
strncpy(progression, optarg, 4);
parameters->prog_order = give_progression(progression);
if (parameters->prog_order == -1) {
fprintf(stderr, "Unrecognized progression order [LRCP, RLCP, RPCL, PCRL, CPRL] !!\n");
fprintf(stderr, "Unrecognized progression order "
"[LRCP, RLCP, RPCL, PCRL, CPRL] !!\n");
return 1;
}
}
@ -428,7 +436,8 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
case 's': /* subsampling factor */
{
if (sscanf(optarg, "%d,%d", &parameters->subsampling_dx, &parameters->subsampling_dy) != 2) {
if (sscanf(optarg, "%d,%d", &parameters->subsampling_dx,
&parameters->subsampling_dy) != 2) {
fprintf(stderr, "'-s' sub-sampling argument error ! [-s dx,dy]\n");
return 1;
}
@ -439,8 +448,10 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
case 'd': /* coordonnate of the reference grid */
{
if (sscanf(optarg, "%d,%d", &parameters->image_offset_x0, &parameters->image_offset_y0) != 2) {
fprintf(stderr, "-d 'coordonnate of the reference grid' argument error !! [-d x0,y0]\n");
if (sscanf(optarg, "%d,%d", &parameters->image_offset_x0,
&parameters->image_offset_y0) != 2) {
fprintf(stderr, "-d 'coordonnate of the reference grid' argument "
"error !! [-d x0,y0]\n");
return 1;
}
}
@ -520,7 +531,8 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
case 'R': /* ROI */
{
if (sscanf(optarg, "OI:c=%d,U=%d", &parameters->roi_compno, &parameters->roi_shift) != 2) {
if (sscanf(optarg, "OI:c=%d,U=%d", &parameters->roi_compno,
&parameters->roi_shift) != 2) {
fprintf(stderr, "ROI error !! [-ROI:c='compno',U='shift']\n");
return 1;
}
@ -701,7 +713,7 @@ int main(int argc, char **argv) {
/* catch events using our callbacks and give a local context */
opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stderr);
/* setup the encoder parameters using the current image and using user parameters */
/* setup the encoder parameters using the current image and user parameters */
opj_setup_encoder(cinfo, &parameters, image);
/* open a byte stream for writing */

View File

@ -301,7 +301,7 @@ int main(int argc, char **argv) {
/* catch events using our callbacks and give a local context */
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
/* setup the decoder decoding parameters using the current image and using user parameters */
/* setup the decoder decoding parameters using the current image and user parameters */
opj_setup_decoder(dinfo, &parameters);
/* open a byte stream */