[trunk] fix compilation on windows where getopt is not available
This commit is contained in:
parent
de33ba029b
commit
b2bebcf5ce
|
@ -8,6 +8,7 @@ SET(common_SRCS
|
||||||
|
|
||||||
# Headers file are located here:
|
# Headers file are located here:
|
||||||
include_directories(
|
include_directories(
|
||||||
|
${OPENJPEG_BINARY_DIR}/src/lib/openjp2 # opj_config.h
|
||||||
${OPENJPEG_SOURCE_DIR}/src/lib/openjp3d
|
${OPENJPEG_SOURCE_DIR}/src/lib/openjp3d
|
||||||
${LCMS_INCLUDE_DIRNAME}
|
${LCMS_INCLUDE_DIRNAME}
|
||||||
${OPENJPEG_SOURCE_DIR}/src/bin/common
|
${OPENJPEG_SOURCE_DIR}/src/bin/common
|
||||||
|
|
|
@ -32,8 +32,9 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "opj_config.h"
|
||||||
#include "openjp3d.h"
|
#include "openjp3d.h"
|
||||||
#include "getopt.h"
|
#include "opj_getopt.h"
|
||||||
#include "convert.h"
|
#include "convert.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -238,13 +239,13 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
|
||||||
/* parse the command line */
|
/* parse the command line */
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int c = getopt(argc, argv, "i:m:o:r:q:f:t:n:c:b:x:p:s:d:hP:S:E:M:D:R:l:T:C:A:I");
|
int c = opj_getopt(argc, argv, "i:m:o:r:q:f:t:n:c:b:x:p:s:d:hP:S:E:M:D:R:l:T:C:A:I");
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'i': /* input file */
|
case 'i': /* input file */
|
||||||
{
|
{
|
||||||
char *infile = optarg;
|
char *infile = opj_optarg;
|
||||||
parameters->decod_format = get_file_format(infile);
|
parameters->decod_format = get_file_format(infile);
|
||||||
switch(parameters->decod_format) {
|
switch(parameters->decod_format) {
|
||||||
case PGX_DFMT:
|
case PGX_DFMT:
|
||||||
|
@ -265,7 +266,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
|
||||||
/* ----------------------------------------------------- */
|
/* ----------------------------------------------------- */
|
||||||
case 'm': /* input IMG file */
|
case 'm': /* input IMG file */
|
||||||
{
|
{
|
||||||
char *imgfile = optarg;
|
char *imgfile = opj_optarg;
|
||||||
int imgformat = get_file_format(imgfile);
|
int imgformat = get_file_format(imgfile);
|
||||||
switch(imgformat) {
|
switch(imgformat) {
|
||||||
case IMG_DFMT:
|
case IMG_DFMT:
|
||||||
|
@ -283,7 +284,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
|
||||||
/* ----------------------------------------------------- */
|
/* ----------------------------------------------------- */
|
||||||
case 'o': /* output file */
|
case 'o': /* output file */
|
||||||
{
|
{
|
||||||
char *outfile = optarg;
|
char *outfile = opj_optarg;
|
||||||
parameters->cod_format = get_file_format(outfile);
|
parameters->cod_format = get_file_format(outfile);
|
||||||
switch(parameters->cod_format) {
|
switch(parameters->cod_format) {
|
||||||
case J3D_CFMT:
|
case J3D_CFMT:
|
||||||
|
@ -304,7 +305,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
|
||||||
|
|
||||||
case 'r': /* define compression rates for each layer */
|
case 'r': /* define compression rates for each layer */
|
||||||
{
|
{
|
||||||
char *s = optarg;
|
char *s = opj_optarg;
|
||||||
while (sscanf(s, "%f", ¶meters->tcp_rates[parameters->tcp_numlayers]) == 1) {
|
while (sscanf(s, "%f", ¶meters->tcp_rates[parameters->tcp_numlayers]) == 1) {
|
||||||
parameters->tcp_numlayers++;
|
parameters->tcp_numlayers++;
|
||||||
while (*s && *s != ',') {
|
while (*s && *s != ',') {
|
||||||
|
@ -322,7 +323,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
|
||||||
|
|
||||||
case 'q': /* define distorsion (PSNR) for each layer */
|
case 'q': /* define distorsion (PSNR) for each layer */
|
||||||
{
|
{
|
||||||
char *s = optarg;
|
char *s = opj_optarg;
|
||||||
while (sscanf(s, "%f", ¶meters->tcp_distoratio[parameters->tcp_numlayers]) == 1) {
|
while (sscanf(s, "%f", ¶meters->tcp_distoratio[parameters->tcp_numlayers]) == 1) {
|
||||||
parameters->tcp_numlayers++;
|
parameters->tcp_numlayers++;
|
||||||
while (*s && *s != ',') {
|
while (*s && *s != ',') {
|
||||||
|
@ -346,7 +347,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
|
||||||
/*int *row = NULL, *col = NULL;
|
/*int *row = NULL, *col = NULL;
|
||||||
int numlayers = 0, matrix_width = 0;
|
int numlayers = 0, matrix_width = 0;
|
||||||
|
|
||||||
char *s = optarg;
|
char *s = opj_optarg;
|
||||||
sscanf(s, "%d", &numlayers);
|
sscanf(s, "%d", &numlayers);
|
||||||
s++;
|
s++;
|
||||||
if (numlayers > 9)
|
if (numlayers > 9)
|
||||||
|
@ -389,7 +390,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
|
||||||
|
|
||||||
case 't': /* tiles */
|
case 't': /* tiles */
|
||||||
{
|
{
|
||||||
if (sscanf(optarg, "%d,%d,%d", ¶meters->cp_tdx, ¶meters->cp_tdy, ¶meters->cp_tdz) !=3) {
|
if (sscanf(opj_optarg, "%d,%d,%d", ¶meters->cp_tdx, ¶meters->cp_tdy, ¶meters->cp_tdz) !=3) {
|
||||||
fprintf(stdout, "[ERROR] '-t' 'dimensions of tiles' argument error ! [-t tdx,tdy,tdz]\n");
|
fprintf(stdout, "[ERROR] '-t' 'dimensions of tiles' argument error ! [-t tdx,tdy,tdz]\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -402,7 +403,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
|
||||||
case 'n': /* resolution */
|
case 'n': /* resolution */
|
||||||
{
|
{
|
||||||
int aux;
|
int aux;
|
||||||
aux = sscanf(optarg, "%d,%d,%d", ¶meters->numresolution[0], ¶meters->numresolution[1], ¶meters->numresolution[2]);
|
aux = sscanf(opj_optarg, "%d,%d,%d", ¶meters->numresolution[0], ¶meters->numresolution[1], ¶meters->numresolution[2]);
|
||||||
if (aux == 2)
|
if (aux == 2)
|
||||||
parameters->numresolution[2] = 1;
|
parameters->numresolution[2] = 1;
|
||||||
else if (aux == 1) {
|
else if (aux == 1) {
|
||||||
|
@ -422,7 +423,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
|
||||||
char sep;
|
char sep;
|
||||||
int res_spec = 0;
|
int res_spec = 0;
|
||||||
int aux;
|
int aux;
|
||||||
char *s = optarg;
|
char *s = opj_optarg;
|
||||||
do {
|
do {
|
||||||
sep = 0;
|
sep = 0;
|
||||||
aux = sscanf(s, "[%d,%d,%d]%c", ¶meters->prct_init[0][res_spec], ¶meters->prct_init[1][res_spec], ¶meters->prct_init[2][res_spec], &sep);
|
aux = sscanf(s, "[%d,%d,%d]%c", ¶meters->prct_init[0][res_spec], ¶meters->prct_init[1][res_spec], ¶meters->prct_init[2][res_spec], &sep);
|
||||||
|
@ -444,7 +445,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
|
||||||
case 'b': /* code-block dimension */
|
case 'b': /* code-block dimension */
|
||||||
{
|
{
|
||||||
int cblockw_init = 0, cblockh_init = 0, cblockl_init = 0;
|
int cblockw_init = 0, cblockh_init = 0, cblockl_init = 0;
|
||||||
if (sscanf(optarg, "%d,%d,%d", &cblockw_init, &cblockh_init, &cblockl_init) != 3) {
|
if (sscanf(opj_optarg, "%d,%d,%d", &cblockw_init, &cblockh_init, &cblockl_init) != 3) {
|
||||||
fprintf(stdout, "[ERROR] '-b' 'dimensions of codeblocks' argument error ! [-b cblkx,cblky,cblkz]\n");
|
fprintf(stdout, "[ERROR] '-b' 'dimensions of codeblocks' argument error ! [-b cblkx,cblky,cblkz]\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -462,7 +463,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
|
||||||
|
|
||||||
case 'x': /* creation of index file */
|
case 'x': /* creation of index file */
|
||||||
{
|
{
|
||||||
char *index = optarg;
|
char *index = opj_optarg;
|
||||||
strncpy(parameters->index, index, MAX_PATH);
|
strncpy(parameters->index, index, MAX_PATH);
|
||||||
parameters->index_on = 1;
|
parameters->index_on = 1;
|
||||||
}
|
}
|
||||||
|
@ -474,7 +475,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
|
||||||
{
|
{
|
||||||
char progression[4];
|
char progression[4];
|
||||||
|
|
||||||
strncpy(progression, optarg, 4);
|
strncpy(progression, opj_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(stdout, "[ERROR] Unrecognized progression order [LRCP, RLCP, RPCL, PCRL, CPRL] !!\n");
|
fprintf(stdout, "[ERROR] Unrecognized progression order [LRCP, RLCP, RPCL, PCRL, CPRL] !!\n");
|
||||||
|
@ -487,7 +488,7 @@ 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,%d", ¶meters->subsampling_dx, ¶meters->subsampling_dy, ¶meters->subsampling_dz) != 2) {
|
if (sscanf(opj_optarg, "%d,%d,%d", ¶meters->subsampling_dx, ¶meters->subsampling_dy, ¶meters->subsampling_dz) != 2) {
|
||||||
fprintf(stdout, "[ERROR] '-s' sub-sampling argument error ! [-s dx,dy,dz]\n");
|
fprintf(stdout, "[ERROR] '-s' sub-sampling argument error ! [-s dx,dy,dz]\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -498,7 +499,7 @@ 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,%d", ¶meters->volume_offset_x0, ¶meters->volume_offset_y0, ¶meters->volume_offset_z0) != 3) {
|
if (sscanf(opj_optarg, "%d,%d,%d", ¶meters->volume_offset_x0, ¶meters->volume_offset_y0, ¶meters->volume_offset_z0) != 3) {
|
||||||
fprintf(stdout, "[ERROR] -d 'coordonnate of the reference grid' argument error !! [-d x0,y0,z0]\n");
|
fprintf(stdout, "[ERROR] -d 'coordonnate of the reference grid' argument error !! [-d x0,y0,z0]\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -521,7 +522,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
|
||||||
int numpocs = 0; /* number of progression order change (POC) default 0 */
|
int numpocs = 0; /* number of progression order change (POC) default 0 */
|
||||||
opj_poc_t *POC = NULL; /* POC : used in case of Progression order change */
|
opj_poc_t *POC = NULL; /* POC : used in case of Progression order change */
|
||||||
|
|
||||||
char *s = optarg;
|
char *s = opj_optarg;
|
||||||
POC = parameters->POC;
|
POC = parameters->POC;
|
||||||
|
|
||||||
fprintf(stdout, "/----------------------------------\\\n");
|
fprintf(stdout, "/----------------------------------\\\n");
|
||||||
|
@ -569,7 +570,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
|
||||||
{
|
{
|
||||||
fprintf(stdout, "[INFO] Mode switch option not fully tested !!\n");
|
fprintf(stdout, "[INFO] Mode switch option not fully tested !!\n");
|
||||||
value = 0;
|
value = 0;
|
||||||
if (sscanf(optarg, "%d", &value) == 1) {
|
if (sscanf(opj_optarg, "%d", &value) == 1) {
|
||||||
for (i = 0; i <= 6; i++) {
|
for (i = 0; i <= 6; i++) {
|
||||||
int cache = value & (1 << i);
|
int cache = value & (1 << i);
|
||||||
if (cache)
|
if (cache)
|
||||||
|
@ -583,7 +584,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
|
||||||
|
|
||||||
case 'D': /* DCO */
|
case 'D': /* DCO */
|
||||||
{
|
{
|
||||||
if (sscanf(optarg, "%d", ¶meters->dcoffset) != 1) {
|
if (sscanf(opj_optarg, "%d", ¶meters->dcoffset) != 1) {
|
||||||
fprintf(stdout, "[ERROR] DC offset error !! [-D %d]\n",parameters->dcoffset);
|
fprintf(stdout, "[ERROR] DC offset error !! [-D %d]\n",parameters->dcoffset);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -594,7 +595,7 @@ 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(opj_optarg, "OI:c=%d,U=%d", ¶meters->roi_compno, ¶meters->roi_shift) != 2) {
|
||||||
fprintf(stdout, "[ERROR] ROI error !! [-ROI:c='compno',U='shift']\n");
|
fprintf(stdout, "[ERROR] ROI error !! [-ROI:c='compno',U='shift']\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -605,7 +606,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
|
||||||
|
|
||||||
case 'l': /* Tile offset */
|
case 'l': /* Tile offset */
|
||||||
{
|
{
|
||||||
if (sscanf(optarg, "%d,%d,%d", ¶meters->cp_tx0, ¶meters->cp_ty0, ¶meters->cp_tz0) != 3) {
|
if (sscanf(opj_optarg, "%d,%d,%d", ¶meters->cp_tx0, ¶meters->cp_ty0, ¶meters->cp_tz0) != 3) {
|
||||||
fprintf(stdout, "[ERROR] -l 'tile offset' argument error !! [-l X0,Y0,Z0]");
|
fprintf(stdout, "[ERROR] -l 'tile offset' argument error !! [-l X0,Y0,Z0]");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -618,7 +619,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
|
||||||
{
|
{
|
||||||
char transform[4];
|
char transform[4];
|
||||||
|
|
||||||
strncpy(transform, optarg, 4);
|
strncpy(transform, opj_optarg, 4);
|
||||||
parameters->transform_format = give_transform(transform);
|
parameters->transform_format = give_transform(transform);
|
||||||
if (parameters->transform_format == -1) {
|
if (parameters->transform_format == -1) {
|
||||||
fprintf(stdout, "[ERROR] -T 'Transform domain' argument error !! [-T 2DWT, 3DWT, 3RLS or 3LSE only]");
|
fprintf(stdout, "[ERROR] -T 'Transform domain' argument error !! [-T 2DWT, 3DWT, 3RLS or 3LSE only]");
|
||||||
|
@ -633,7 +634,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
|
||||||
{
|
{
|
||||||
char coding[3];
|
char coding[3];
|
||||||
|
|
||||||
strncpy(coding, optarg, 3);
|
strncpy(coding, opj_optarg, 3);
|
||||||
parameters->encoding_format = give_coding(coding);
|
parameters->encoding_format = give_coding(coding);
|
||||||
if (parameters->encoding_format == -1) {
|
if (parameters->encoding_format == -1) {
|
||||||
fprintf(stdout, "[ERROR] -C 'Coding algorithm' argument error !! [-C 2EB, 3EB, 2GR, 3GR or GRI only]");
|
fprintf(stdout, "[ERROR] -C 'Coding algorithm' argument error !! [-C 2EB, 3EB, 2GR, 3GR or GRI only]");
|
||||||
|
@ -651,7 +652,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stdout, "[ERROR] This option is not valid \"-%c %s\"\n", c, optarg);
|
fprintf(stdout, "[ERROR] This option is not valid \"-%c %s\"\n", c, opj_optarg);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,8 +33,9 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "opj_config.h"
|
||||||
#include "openjp3d.h"
|
#include "openjp3d.h"
|
||||||
#include "getopt.h"
|
#include "opj_getopt.h"
|
||||||
#include "convert.h"
|
#include "convert.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -87,7 +88,7 @@ static double calc_PSNR(opj_volume_t *original, opj_volume_t *decoded)
|
||||||
return -1.0;
|
return -1.0;
|
||||||
|
|
||||||
return total;
|
return total;
|
||||||
//return 20 * log10((max - 1) / sqrt(sum));
|
/*return 20 * log10((max - 1) / sqrt(sum));*/
|
||||||
}
|
}
|
||||||
|
|
||||||
static double calc_SSIM(opj_volume_t *original, opj_volume_t *decoded)
|
static double calc_SSIM(opj_volume_t *original, opj_volume_t *decoded)
|
||||||
|
@ -95,29 +96,29 @@ static double calc_SSIM(opj_volume_t *original, opj_volume_t *decoded)
|
||||||
int max, i, compno = 0, size, sizeM;
|
int max, i, compno = 0, size, sizeM;
|
||||||
double sum;
|
double sum;
|
||||||
double mux = 0.0, muy = 0.0, sigmax = 0.0, sigmay = 0.0,
|
double mux = 0.0, muy = 0.0, sigmax = 0.0, sigmay = 0.0,
|
||||||
sigmaxy = 0.0, structx = 0.0, structy = 0.0;
|
sigmaxy = 0.0/*, structx = 0.0, structy = 0.0*/;
|
||||||
double lcomp,ccomp,scomp;
|
double lcomp,ccomp,scomp;
|
||||||
double C1,C2,C3;
|
double C1,C2,C3;
|
||||||
|
|
||||||
max = (original->comps[compno].prec <= 8) ? 255 : (1 << original->comps[compno].prec) - 1;
|
max = (original->comps[compno].prec <= 8) ? 255 : (1 << original->comps[compno].prec) - 1;
|
||||||
size = (original->x1 - original->x0) * (original->y1 - original->y0) * (original->z1 - original->z0);
|
size = (original->x1 - original->x0) * (original->y1 - original->y0) * (original->z1 - original->z0);
|
||||||
|
|
||||||
//MSSIM
|
/*MSSIM*/
|
||||||
|
|
||||||
// sizeM = size / (original->z1 - original->z0);
|
/* sizeM = size / (original->z1 - original->z0);*/
|
||||||
|
|
||||||
sizeM = size;
|
sizeM = size;
|
||||||
for(sum = 0, i = 0; i < sizeM; ++i) {
|
for(sum = 0, i = 0; i < sizeM; ++i) {
|
||||||
// First, the luminance of each signal is compared.
|
/* First, the luminance of each signal is compared.*/
|
||||||
mux += original->comps[compno].data[i];
|
mux += original->comps[compno].data[i];
|
||||||
muy += decoded->comps[compno].data[i];
|
muy += decoded->comps[compno].data[i];
|
||||||
}
|
}
|
||||||
mux /= sizeM;
|
mux /= sizeM;
|
||||||
muy /= sizeM;
|
muy /= sizeM;
|
||||||
|
|
||||||
//We use the standard deviation (the square root of variance) as an estimate of the signal contrast.
|
/*We use the standard deviation (the square root of variance) as an estimate of the signal contrast.*/
|
||||||
for(sum = 0, i = 0; i < sizeM; ++i) {
|
for(sum = 0, i = 0; i < sizeM; ++i) {
|
||||||
// First, the luminance of each signal is compared.
|
/* First, the luminance of each signal is compared.*/
|
||||||
sigmax += (original->comps[compno].data[i] - mux) * (original->comps[compno].data[i] - mux);
|
sigmax += (original->comps[compno].data[i] - mux) * (original->comps[compno].data[i] - mux);
|
||||||
sigmay += (decoded->comps[compno].data[i] - muy) * (decoded->comps[compno].data[i] - muy);
|
sigmay += (decoded->comps[compno].data[i] - muy) * (decoded->comps[compno].data[i] - muy);
|
||||||
sigmaxy += (original->comps[compno].data[i] - mux) * (decoded->comps[compno].data[i] - muy);
|
sigmaxy += (original->comps[compno].data[i] - mux) * (decoded->comps[compno].data[i] - muy);
|
||||||
|
@ -130,19 +131,19 @@ static double calc_SSIM(opj_volume_t *original, opj_volume_t *decoded)
|
||||||
sigmay = sqrt(sigmay);
|
sigmay = sqrt(sigmay);
|
||||||
sigmaxy = sqrt(sigmaxy);
|
sigmaxy = sqrt(sigmaxy);
|
||||||
|
|
||||||
//Third, the signal is normalized (divided) by its own standard deviation,
|
/*Third, the signal is normalized (divided) by its own standard deviation, */
|
||||||
//so that the two signals being compared have unit standard deviation.
|
/*so that the two signals being compared have unit standard deviation.*/
|
||||||
|
|
||||||
//Luminance comparison
|
/*Luminance comparison*/
|
||||||
C1 = (0.01 * max) * (0.01 * max);
|
C1 = (0.01 * max) * (0.01 * max);
|
||||||
lcomp = ((2 * mux * muy) + C1)/((mux*mux) + (muy*mux) + C1);
|
lcomp = ((2 * mux * muy) + C1)/((mux*mux) + (muy*mux) + C1);
|
||||||
//Constrast comparison
|
/*Constrast comparison*/
|
||||||
C2 = (0.03 * max) * (0.03 * max);
|
C2 = (0.03 * max) * (0.03 * max);
|
||||||
ccomp = ((2 * sigmax * sigmay) + C2)/((sigmax*sigmax) + (sigmay*sigmay) + C2);
|
ccomp = ((2 * sigmax * sigmay) + C2)/((sigmax*sigmax) + (sigmay*sigmay) + C2);
|
||||||
//Structure comparison
|
/*Structure comparison*/
|
||||||
C3 = C2 / 2;
|
C3 = C2 / 2;
|
||||||
scomp = (sigmaxy + C3) / (sigmax * sigmay + C3);
|
scomp = (sigmaxy + C3) / (sigmax * sigmay + C3);
|
||||||
//Similarity measure
|
/*Similarity measure*/
|
||||||
|
|
||||||
sum = lcomp * ccomp * scomp;
|
sum = lcomp * ccomp * scomp;
|
||||||
return sum;
|
return sum;
|
||||||
|
@ -217,13 +218,13 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters)
|
||||||
/* parse the command line */
|
/* parse the command line */
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int c = getopt(argc, argv, "i:o:O:r:l:B:m:h");
|
int c = opj_getopt(argc, argv, "i:o:O:r:l:B:m:h");
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'i': /* input file */
|
case 'i': /* input file */
|
||||||
{
|
{
|
||||||
char *infile = optarg;
|
char *infile = opj_optarg;
|
||||||
parameters->decod_format = get_file_format(infile);
|
parameters->decod_format = get_file_format(infile);
|
||||||
switch(parameters->decod_format) {
|
switch(parameters->decod_format) {
|
||||||
case J3D_CFMT:
|
case J3D_CFMT:
|
||||||
|
@ -242,7 +243,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters)
|
||||||
|
|
||||||
case 'm': /* img file */
|
case 'm': /* img file */
|
||||||
{
|
{
|
||||||
char *imgfile = optarg;
|
char *imgfile = opj_optarg;
|
||||||
int imgformat = get_file_format(imgfile);
|
int imgformat = get_file_format(imgfile);
|
||||||
switch(imgformat) {
|
switch(imgformat) {
|
||||||
case IMG_DFMT:
|
case IMG_DFMT:
|
||||||
|
@ -261,7 +262,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters)
|
||||||
|
|
||||||
case 'o': /* output file */
|
case 'o': /* output file */
|
||||||
{
|
{
|
||||||
char *outfile = optarg;
|
char *outfile = opj_optarg;
|
||||||
parameters->cod_format = get_file_format(outfile);
|
parameters->cod_format = get_file_format(outfile);
|
||||||
switch(parameters->cod_format) {
|
switch(parameters->cod_format) {
|
||||||
case PGX_DFMT:
|
case PGX_DFMT:
|
||||||
|
@ -282,7 +283,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters)
|
||||||
|
|
||||||
case 'O': /* Original image for PSNR computing */
|
case 'O': /* Original image for PSNR computing */
|
||||||
{
|
{
|
||||||
char *original = optarg;
|
char *original = opj_optarg;
|
||||||
parameters->orig_format = get_file_format(original);
|
parameters->orig_format = get_file_format(original);
|
||||||
switch(parameters->orig_format) {
|
switch(parameters->orig_format) {
|
||||||
case PGX_DFMT:
|
case PGX_DFMT:
|
||||||
|
@ -302,9 +303,9 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters)
|
||||||
|
|
||||||
case 'r': /* reduce option */
|
case 'r': /* reduce option */
|
||||||
{
|
{
|
||||||
//sscanf(optarg, "%d, %d, %d", ¶meters->cp_reduce[0], ¶meters->cp_reduce[1], ¶meters->cp_reduce[2]);
|
/*sscanf(opj_optarg, "%d, %d, %d", ¶meters->cp_reduce[0], ¶meters->cp_reduce[1], ¶meters->cp_reduce[2]);*/
|
||||||
int aux;
|
int aux;
|
||||||
aux = sscanf(optarg, "%d,%d,%d", ¶meters->cp_reduce[0], ¶meters->cp_reduce[1], ¶meters->cp_reduce[2]);
|
aux = sscanf(opj_optarg, "%d,%d,%d", ¶meters->cp_reduce[0], ¶meters->cp_reduce[1], ¶meters->cp_reduce[2]);
|
||||||
if (aux == 2)
|
if (aux == 2)
|
||||||
parameters->cp_reduce[2] = 0;
|
parameters->cp_reduce[2] = 0;
|
||||||
else if (aux == 1) {
|
else if (aux == 1) {
|
||||||
|
@ -322,7 +323,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters)
|
||||||
|
|
||||||
case 'l': /* layering option */
|
case 'l': /* layering option */
|
||||||
{
|
{
|
||||||
sscanf(optarg, "%d", ¶meters->cp_layer);
|
sscanf(opj_optarg, "%d", ¶meters->cp_layer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -354,7 +355,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters)
|
||||||
/* ----------------------------------------------------- */
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stdout,"[WARNING] This option is not valid \"-%c %s\"\n",c, optarg);
|
fprintf(stdout,"[WARNING] This option is not valid \"-%c %s\"\n",c, opj_optarg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue