refactor to not use opj_cparameters_t
This commit is contained in:
parent
4a1e327415
commit
ae566ad713
|
@ -95,7 +95,8 @@ opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters);
|
||||||
int imagetobmp(opj_image_t *image, const char *outfile);
|
int imagetobmp(opj_image_t *image, const char *outfile);
|
||||||
|
|
||||||
/* TIFF conversion*/
|
/* TIFF conversion*/
|
||||||
opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters);
|
opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters,
|
||||||
|
const unsigned int target_bitdepth);
|
||||||
int imagetotif(opj_image_t *image, const char *outfile);
|
int imagetotif(opj_image_t *image, const char *outfile);
|
||||||
/**
|
/**
|
||||||
Load a single image component encoded in PGX file format
|
Load a single image component encoded in PGX file format
|
||||||
|
|
|
@ -1247,7 +1247,8 @@ static void tif_16uto32s(const OPJ_UINT16* pSrc, OPJ_INT32* pDst,
|
||||||
* libtiff/tif_getimage.c : 1,2,4,8,16 bitspersample accepted
|
* libtiff/tif_getimage.c : 1,2,4,8,16 bitspersample accepted
|
||||||
* CINEMA : 12 bit precision
|
* CINEMA : 12 bit precision
|
||||||
*/
|
*/
|
||||||
opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
|
opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters,
|
||||||
|
const unsigned int target_bitdepth)
|
||||||
{
|
{
|
||||||
int subsampling_dx = parameters->subsampling_dx;
|
int subsampling_dx = parameters->subsampling_dx;
|
||||||
int subsampling_dy = parameters->subsampling_dy;
|
int subsampling_dy = parameters->subsampling_dy;
|
||||||
|
@ -1506,10 +1507,9 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
|
||||||
scale_component(&(image->comps[j]), 12);
|
scale_component(&(image->comps[j]), 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if ((parameters->target_bitdepth > 0) &&
|
} else if ((target_bitdepth > 0) && (target_bitdepth != tiBps)) {
|
||||||
(parameters->target_bitdepth != tiBps)) {
|
|
||||||
for (j = 0; j < numcomps; ++j) {
|
for (j = 0; j < numcomps; ++j) {
|
||||||
scale_component(&(image->comps[j]), parameters->target_bitdepth);
|
scale_component(&(image->comps[j]), target_bitdepth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return image;
|
return image;
|
||||||
|
|
|
@ -190,6 +190,7 @@ static void encode_help_display(void)
|
||||||
fprintf(stdout, " Target bitdepth.\n");
|
fprintf(stdout, " Target bitdepth.\n");
|
||||||
fprintf(stdout, " Number of bits per component to use from input image\n");
|
fprintf(stdout, " Number of bits per component to use from input image\n");
|
||||||
fprintf(stdout, " if all bits are unwanted.\n");
|
fprintf(stdout, " if all bits are unwanted.\n");
|
||||||
|
fprintf(stdout, " (Currently only implemented for TIF.)\n");
|
||||||
fprintf(stdout, "-b <cblk width>,<cblk height>\n");
|
fprintf(stdout, "-b <cblk width>,<cblk height>\n");
|
||||||
fprintf(stdout,
|
fprintf(stdout,
|
||||||
" Code-block size. The dimension must respect the constraint \n");
|
" Code-block size. The dimension must respect the constraint \n");
|
||||||
|
@ -604,7 +605,8 @@ static int parse_cmdline_encoder(int argc, char **argv,
|
||||||
int* pOutFramerate,
|
int* pOutFramerate,
|
||||||
OPJ_BOOL* pOutPLT,
|
OPJ_BOOL* pOutPLT,
|
||||||
OPJ_BOOL* pOutTLM,
|
OPJ_BOOL* pOutTLM,
|
||||||
int* pOutNumThreads)
|
int* pOutNumThreads,
|
||||||
|
unsigned int* pTarget_bitdepth)
|
||||||
{
|
{
|
||||||
OPJ_UINT32 i, j;
|
OPJ_UINT32 i, j;
|
||||||
int totlen, c;
|
int totlen, c;
|
||||||
|
@ -914,14 +916,12 @@ static int parse_cmdline_encoder(int argc, char **argv,
|
||||||
|
|
||||||
/* ----------------------------------------------------- */
|
/* ----------------------------------------------------- */
|
||||||
case 'X': { /* target bitdepth */
|
case 'X': { /* target bitdepth */
|
||||||
unsigned int target_bitdepth = 0;
|
|
||||||
char *s = opj_optarg;
|
char *s = opj_optarg;
|
||||||
sscanf(s, "%u", &target_bitdepth);
|
sscanf(s, "%u", pTarget_bitdepth);
|
||||||
if (target_bitdepth == 0) {
|
if (*pTarget_bitdepth == 0) {
|
||||||
fprintf(stderr, "Target bitdepth must be at least 1 bit.\n");
|
fprintf(stderr, "Target bitdepth must be at least 1 bit.\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
parameters->target_bitdepth = target_bitdepth;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1925,6 +1925,9 @@ int main(int argc, char **argv)
|
||||||
OPJ_BOOL TLM = OPJ_FALSE;
|
OPJ_BOOL TLM = OPJ_FALSE;
|
||||||
int num_threads = 0;
|
int num_threads = 0;
|
||||||
|
|
||||||
|
/** desired bitdepth from input file */
|
||||||
|
unsigned int target_bitdepth = 0;
|
||||||
|
|
||||||
/* set encoding parameters to default values */
|
/* set encoding parameters to default values */
|
||||||
opj_set_default_encoder_parameters(¶meters);
|
opj_set_default_encoder_parameters(¶meters);
|
||||||
|
|
||||||
|
@ -1945,7 +1948,7 @@ int main(int argc, char **argv)
|
||||||
255; /* This will be set later according to the input image or the provided option */
|
255; /* This will be set later according to the input image or the provided option */
|
||||||
if (parse_cmdline_encoder(argc, argv, ¶meters, &img_fol, &raw_cp,
|
if (parse_cmdline_encoder(argc, argv, ¶meters, &img_fol, &raw_cp,
|
||||||
indexfilename, sizeof(indexfilename), &framerate, &PLT, &TLM,
|
indexfilename, sizeof(indexfilename), &framerate, &PLT, &TLM,
|
||||||
&num_threads) == 1) {
|
&num_threads, &target_bitdepth) == 1) {
|
||||||
ret = 1;
|
ret = 1;
|
||||||
goto fin;
|
goto fin;
|
||||||
}
|
}
|
||||||
|
@ -2038,7 +2041,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
#ifdef OPJ_HAVE_LIBTIFF
|
#ifdef OPJ_HAVE_LIBTIFF
|
||||||
case TIF_DFMT:
|
case TIF_DFMT:
|
||||||
image = tiftoimage(parameters.infile, ¶meters);
|
image = tiftoimage(parameters.infile, ¶meters, target_bitdepth);
|
||||||
if (!image) {
|
if (!image) {
|
||||||
fprintf(stderr, "Unable to load tif(f) file\n");
|
fprintf(stderr, "Unable to load tif(f) file\n");
|
||||||
ret = 1;
|
ret = 1;
|
||||||
|
|
|
@ -756,7 +756,6 @@ void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t
|
||||||
parameters->tp_on = 0;
|
parameters->tp_on = 0;
|
||||||
parameters->decod_format = -1;
|
parameters->decod_format = -1;
|
||||||
parameters->cod_format = -1;
|
parameters->cod_format = -1;
|
||||||
parameters->target_bitdepth = 0;
|
|
||||||
parameters->tcp_rates[0] = 0;
|
parameters->tcp_rates[0] = 0;
|
||||||
parameters->tcp_numlayers = 0;
|
parameters->tcp_numlayers = 0;
|
||||||
parameters->cp_disto_alloc = 0;
|
parameters->cp_disto_alloc = 0;
|
||||||
|
|
|
@ -471,8 +471,6 @@ typedef struct opj_cparameters {
|
||||||
int decod_format;
|
int decod_format;
|
||||||
/** output file format 0: J2K, 1: JP2, 2: JPT */
|
/** output file format 0: J2K, 1: JP2, 2: JPT */
|
||||||
int cod_format;
|
int cod_format;
|
||||||
/** desired bitdepth from input file */
|
|
||||||
unsigned int target_bitdepth;
|
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
|
||||||
/* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */
|
/* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */
|
||||||
|
|
Loading…
Reference in New Issue