* function getopt added to the decoder (to efficiently manage arguments

in command line)
* reduce_on, reduce_value grouped in a single variable reduce
* up-to-date usage display
* image_type renamed --> decod_format
* JPEG2000_format renamed -->  cod_format
This commit is contained in:
Antonin Descampe 2005-01-26 08:59:49 +00:00
parent ba1cf545df
commit 3b1bee0eec
6 changed files with 570 additions and 406 deletions

View File

@ -378,7 +378,7 @@ int main(int argc, char **argv)
if ((S1 == 'p' && S2 == 'g' && S3 == 'x')
|| (S1 == 'P' && S2 == 'G' && S3 == 'X')) {
cp.image_type = 0;
cp.decod_format = PGX_DFMT;
break;
}
@ -390,13 +390,13 @@ int main(int argc, char **argv)
|| (S1 == 'P' && S2 == 'P' && S3 == 'M') || (S1 == 'p'
&& S2 == 'p'
&& S3 == 'm')) {
cp.image_type = 1;
cp.decod_format = PXM_DFMT;
break;
}
if ((S1 == 'b' && S2 == 'm' && S3 == 'p')
|| (S1 == 'B' && S2 == 'M' && S3 == 'P')) {
cp.image_type = 2;
cp.decod_format = BMP_DFMT;
break;
}
fprintf(stderr,
@ -421,10 +421,10 @@ int main(int argc, char **argv)
if ((S1 == 'j' && S2 == '2' && S3 == 'k')
|| (S1 == 'J' && S2 == '2' && S3 == 'K'))
cp.JPEG2000_format = 0;
cp.cod_format = J2K_CFMT;
else if ((S1 == 'j' && S2 == 'p' && S3 == '2')
|| (S1 == 'J' && S2 == 'P' && S3 == '2'))
cp.JPEG2000_format = 1;
cp.cod_format = JP2_CFMT;
else {
fprintf(stderr,
"Unknown output format image *.%c%c%c [only *.j2k, *.jp2]!! \n",
@ -685,7 +685,7 @@ int main(int argc, char **argv)
}
}
switch (cp.image_type) {
switch (cp.decod_format) {
case 0:
if (Tile_arg) {
if (!pgxtoimage
@ -841,7 +841,7 @@ int main(int argc, char **argv)
if (cp.JPEG2000_format == 0) { /* J2K format output */
if (cp.cod_format == J2K_CFMT) { /* J2K format output */
if (cp.intermed_file == 1) { /* After the encoding of each tile, j2k_encode
stores the data in the file */
len = j2k_encode(&img, &cp, outfile, cp.tdx * cp.tdy * 2, index);
@ -955,7 +955,7 @@ int main(int argc, char **argv)
/* Remove the temporary files */
/* -------------------------- */
if (cp.image_type) { /* PNM PGM PPM */
if (cp.decod_format != PGX_CFMT) { /* PNM PGM PPM or BMP */
for (i = 0; i < img.numcomps; i++) {
char tmp;
sprintf(&tmp, "Compo%d", i);

File diff suppressed because it is too large Load Diff

View File

@ -345,6 +345,8 @@ void j2k_read_cox(int compno)
J2K_STATE_TPH ? &j2k_cp->tcps[j2k_curtileno] : &j2k_default_tcp;
tccp = &tcp->tccps[compno];
tccp->numresolutions = cio_read(1) + 1; /* SPcox (D) */
//Check the reduce value
j2k_cp->reduce=int_min((tccp->numresolutions)-1,j2k_cp->reduce);
tccp->cblkw = cio_read(1) + 2; /* SPcox (E) */
tccp->cblkh = cio_read(1) + 2; /* SPcox (F) */
tccp->cblksty = cio_read(1); /* SPcox (G) */
@ -878,7 +880,7 @@ void j2k_write_sod()
}
info_IM.num = 0;
if (j2k_cp->image_type)
if (j2k_cp->decod_format != PGX_DFMT)
l = tcd_encode_tile_pxm(j2k_curtileno, cio_getbp(),
cio_numbytesleft() - 2, &info_IM);
else

View File

@ -43,6 +43,13 @@
#define J2K_MAXRLVLS 33 /* Number of maximum resolution level authorized */
#define J2K_MAXBANDS (3*J2K_MAXRLVLS-2) /* Number of maximum sub-band linked to number of resolution level */
#define J2K_CFMT 0
#define JP2_CFMT 1
#define JPT_CFMT 2
#define MJ2_CFMT 3
#define PXM_DFMT 0
#define PGX_DFMT 1
#define BMP_DFMT 2
#define J2K_CP_CSTY_PRT 0x01
#define J2K_CP_CSTY_SOP 0x02
@ -125,14 +132,14 @@ typedef struct {
} j2k_tcp_t;
typedef struct {
int JPEG2000_format; /* 0: J2K 1:JP2 */
int intermed_file; /* 1: Store each encoded tile one by one in the output file (for mega-Images)*/
int image_type; /* 0: PNM, PGM, PPM 1: PGX */
int decod_format; /* 0: PGX, 1: PxM, 2: BMP */
int cod_format; /* 0: J2K, 1: JP2, 2: JPT */
int disto_alloc; /* Allocation by rate/distortion */
int fixed_alloc; /* Allocation by fixed layer */
int fixed_quality; /* add fixed_quality */
int reduce_on; /* option reduce is used if reduce = 1 */
int reduce_value; /* if option reduce is used -> original dimension divided by 2^value */
int reduce; /* if != 0, then original dimension divided by 2^(reduce); if == 0 or not used, image is decoded to the full resolution */
int layer; /* if != 0, then only the first "layer" layers are decoded; if == 0 or not used, all the quality layers are decoded */
int index_on; /* 0 = no index || 1 = index */
int tx0, ty0; /* XTOsiz, YTOsiz */
int tdx, tdy; /* XTsiz, YTsiz */

View File

@ -1488,7 +1488,7 @@ int tcd_decode_tile(unsigned char *src, int len, int tileno)
time = clock();
fprintf(stdout, "tile decoding time %d/%d: ", tileno + 1,
fprintf(stdout, "Tile %d of %d decoded in ", tileno + 1,
tcd_cp->tw * tcd_cp->th);
/*--------------TIER2------------------*/
@ -1508,9 +1508,9 @@ int tcd_decode_tile(unsigned char *src, int len, int tileno)
for (compno = 0; compno < tile->numcomps; compno++) {
tcd_tilecomp_t *tilec = &tile->comps[compno];
if (tcd_cp->reduce_on == 1) {
if (tcd_cp->reduce != 0) {
tcd_img->comps[compno].resno_decoded =
tile->comps[compno].numresolutions - tcd_cp->reduce_value - 1;
tile->comps[compno].numresolutions - tcd_cp->reduce - 1;
}
@ -1611,7 +1611,7 @@ int tcd_decode_tile(unsigned char *src, int len, int tileno)
}
time = clock() - time;
fprintf(stdout, "total: %ld.%.3ld s\n", time / CLOCKS_PER_SEC,
fprintf(stdout, "%ld.%.3ld s\n", time / CLOCKS_PER_SEC,
(time % CLOCKS_PER_SEC) * 1000 / CLOCKS_PER_SEC);

View File

@ -304,7 +304,6 @@ int main(int argc, char **argv)
int h; /* Height of YUV file */
int CbCr_subsampling_dx; /* Sample rate of YUV 4:4:4 4:2:2 or 4:2:0 */
int CbCr_subsampling_dy; /* Sample rate of YUV 4:4:4 4:2:2 or 4:2:0 */
int output_image_type = -1;
int frame_rate; /* Video Frame Rate */
int numcomps; /* In YUV files, numcomps always considered as 3 */
int prec; /* In YUV files, precision always considered as 8 */
@ -373,7 +372,7 @@ int main(int argc, char **argv)
if ((S1 == 'y' && S2 == 'u' && S3 == 'v')
|| (S1 == 'Y' && S2 == 'U' && S3 == 'V')) {
cp.image_type = 3;
cp.decod_format = YUV_DFMT;
break;
}
fprintf(stderr,
@ -398,7 +397,7 @@ int main(int argc, char **argv)
if ((S1 == 'm' && S2 == 'j' && S3 == '2')
|| (S1 == 'M' && S2 == 'J' && S3 == '2'))
cp.JPEG2000_format = 2;
cp.cod_format = MJ2_CFMT;
else {
fprintf(stderr,
"Unknown output format image *.%c%c%c [only *.mj2]!! \n",