Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/decimation #1384

Merged
merged 9 commits into from
Oct 27, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/bin/jp2/converttif.c
Original file line number Diff line number Diff line change
Expand Up @@ -1506,6 +1506,11 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
scale_component(&(image->comps[j]), 12);
}

} else if ((parameters->target_bitdepth > 0) &&
(parameters->target_bitdepth != tiBps)) {
for (j = 0; j < numcomps; ++j) {
scale_component(&(image->comps[j]), parameters->target_bitdepth);
}
}
return image;

Expand Down
19 changes: 18 additions & 1 deletion src/bin/jp2/opj_compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ static void encode_help_display(void)
fprintf(stdout,
" It corresponds to the number of DWT decompositions +1. \n");
fprintf(stdout, " Default: 6.\n");
fprintf(stdout, "-X <target bitdepth>\n");
rouault marked this conversation as resolved.
Show resolved Hide resolved
fprintf(stdout, " Target bitdepth.\n");
fprintf(stdout, " Number of bits per component to use from input image\n");
fprintf(stdout, " if all bits are unwanted. \n");
fprintf(stdout, "-b <cblk width>,<cblk height>\n");
fprintf(stdout,
" Code-block size. The dimension must respect the constraint \n");
Expand Down Expand Up @@ -623,7 +627,7 @@ static int parse_cmdline_encoder(int argc, char **argv,
};

/* parse the command line */
const char optlist[] = "i:o:r:q:n:b:c:t:p:s:SEM:x:R:d:T:If:P:C:F:u:JY:"
const char optlist[] = "i:o:r:q:n:b:c:t:p:s:SEM:x:R:d:T:If:P:C:F:u:JY:X:"
#ifdef USE_JPWL
"W:"
#endif /* USE_JPWL */
Expand Down Expand Up @@ -908,6 +912,19 @@ static int parse_cmdline_encoder(int argc, char **argv,
}
break;

/* ----------------------------------------------------- */
case 'X': { /* target bitdepth */
unsigned int target_bitdepth = 0;
char *s = opj_optarg;
sscanf(s, "%u", &target_bitdepth);
if (target_bitdepth == 0) {
fprintf(stderr, "Target bitdepth must be at least 1 bit.\n");
return 1;
}
parameters->target_bitdepth = target_bitdepth;
}
break;

/* ----------------------------------------------------- */

case 'n': { /* resolution */
Expand Down
1 change: 1 addition & 0 deletions src/lib/openjp2/openjpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,7 @@ void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t
parameters->tp_on = 0;
parameters->decod_format = -1;
parameters->cod_format = -1;
parameters->target_bitdepth = 0;
parameters->tcp_rates[0] = 0;
parameters->tcp_numlayers = 0;
parameters->cp_disto_alloc = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/lib/openjp2/openjpeg.h
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,8 @@ typedef struct opj_cparameters {
int decod_format;
/** output file format 0: J2K, 1: JP2, 2: JPT */
int cod_format;
/** desired bitdepth from input file */
unsigned int target_bitdepth;
rouault marked this conversation as resolved.
Show resolved Hide resolved
/*@}*/

/* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */
Expand Down