ENH: Minor cleanup, mainly comment and line too long
This commit is contained in:
parent
d55af7fe7e
commit
190b4b7c9e
|
@ -1048,3 +1048,5 @@ int imagetopnm(opj_image_t * image, char *outfile) {
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -201,8 +201,12 @@ OPJ_PROG_ORDER give_progression(char progression[4]) {
|
||||||
|
|
||||||
int get_file_format(char *filename) {
|
int get_file_format(char *filename) {
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp", "j2k", "jp2" };
|
static const char *extension[] = {
|
||||||
static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, J2K_CFMT, JP2_CFMT };
|
"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;
|
char * ext = strrchr(filename, '.') + 1;
|
||||||
for(i = 0; i < sizeof(format)/sizeof(*format); i++) {
|
for(i = 0; i < sizeof(format)/sizeof(*format); i++) {
|
||||||
if(strnicmp(ext, extension[i], 3) == 0) {
|
if(strnicmp(ext, extension[i], 3) == 0) {
|
||||||
|
@ -213,7 +217,7 @@ int get_file_format(char *filename) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------ */
|
/* -------------------------------------------------------------------------*/
|
||||||
|
|
||||||
int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters) {
|
int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters) {
|
||||||
int i, j;
|
int i, j;
|
||||||
|
@ -236,7 +240,8 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,
|
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);
|
infile);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -372,7 +377,8 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
|
||||||
char *s = optarg;
|
char *s = optarg;
|
||||||
do {
|
do {
|
||||||
sep = 0;
|
sep = 0;
|
||||||
sscanf(s, "[%d,%d]%c", ¶meters->prcw_init[res_spec], ¶meters->prch_init[res_spec], &sep);
|
sscanf(s, "[%d,%d]%c", ¶meters->prcw_init[res_spec],
|
||||||
|
¶meters->prch_init[res_spec], &sep);
|
||||||
parameters->csty |= 0x01;
|
parameters->csty |= 0x01;
|
||||||
res_spec++;
|
res_spec++;
|
||||||
s = strpbrk(s, "]") + 2;
|
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
|
if (cblockw_init * cblockh_init > 4096 || cblockw_init > 1024
|
||||||
|| cblockw_init < 4 || cblockh_init > 1024 || cblockh_init < 4) {
|
|| cblockw_init < 4 || cblockh_init > 1024 || cblockh_init < 4) {
|
||||||
fprintf(stderr,
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
parameters->cblockw_init = cblockw_init;
|
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);
|
strncpy(progression, optarg, 4);
|
||||||
parameters->prog_order = give_progression(progression);
|
parameters->prog_order = give_progression(progression);
|
||||||
if (parameters->prog_order == -1) {
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -428,7 +436,8 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
|
||||||
|
|
||||||
case 's': /* subsampling factor */
|
case 's': /* subsampling factor */
|
||||||
{
|
{
|
||||||
if (sscanf(optarg, "%d,%d", ¶meters->subsampling_dx, ¶meters->subsampling_dy) != 2) {
|
if (sscanf(optarg, "%d,%d", ¶meters->subsampling_dx,
|
||||||
|
¶meters->subsampling_dy) != 2) {
|
||||||
fprintf(stderr, "'-s' sub-sampling argument error ! [-s dx,dy]\n");
|
fprintf(stderr, "'-s' sub-sampling argument error ! [-s dx,dy]\n");
|
||||||
return 1;
|
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 */
|
case 'd': /* coordonnate of the reference grid */
|
||||||
{
|
{
|
||||||
if (sscanf(optarg, "%d,%d", ¶meters->image_offset_x0, ¶meters->image_offset_y0) != 2) {
|
if (sscanf(optarg, "%d,%d", ¶meters->image_offset_x0,
|
||||||
fprintf(stderr, "-d 'coordonnate of the reference grid' argument error !! [-d x0,y0]\n");
|
¶meters->image_offset_y0) != 2) {
|
||||||
|
fprintf(stderr, "-d 'coordonnate of the reference grid' argument "
|
||||||
|
"error !! [-d x0,y0]\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -520,7 +531,8 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
|
||||||
|
|
||||||
case 'R': /* ROI */
|
case 'R': /* ROI */
|
||||||
{
|
{
|
||||||
if (sscanf(optarg, "OI:c=%d,U=%d", ¶meters->roi_compno, ¶meters->roi_shift) != 2) {
|
if (sscanf(optarg, "OI:c=%d,U=%d", ¶meters->roi_compno,
|
||||||
|
¶meters->roi_shift) != 2) {
|
||||||
fprintf(stderr, "ROI error !! [-ROI:c='compno',U='shift']\n");
|
fprintf(stderr, "ROI error !! [-ROI:c='compno',U='shift']\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -701,7 +713,7 @@ int main(int argc, char **argv) {
|
||||||
/* 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);
|
||||||
|
|
||||||
/* 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, ¶meters, image);
|
opj_setup_encoder(cinfo, ¶meters, image);
|
||||||
|
|
||||||
/* open a byte stream for writing */
|
/* open a byte stream for writing */
|
||||||
|
|
|
@ -301,7 +301,7 @@ int main(int argc, char **argv) {
|
||||||
/* 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);
|
||||||
|
|
||||||
/* 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, ¶meters);
|
opj_setup_decoder(dinfo, ¶meters);
|
||||||
|
|
||||||
/* open a byte stream */
|
/* open a byte stream */
|
||||||
|
|
Loading…
Reference in New Issue