Index structure adpated for other progression orders than LRCP
(thanks to Stefano Pensa)
This commit is contained in:
parent
0ddef9b2db
commit
eb1b017ec7
|
@ -1,30 +1,30 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2002, David Janssens
|
* Copyright (c) 2001-2002, David Janssens
|
||||||
* Copyright (c) 2002-2004, Yannick Verschueren
|
* Copyright (c) 2002-2004, Yannick Verschueren
|
||||||
* Copyright (c) 2002-2004, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
* Copyright (c) 2002-2004, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -107,7 +107,7 @@ void j2k_dump_image(j2k_image_t * img)
|
||||||
int compno;
|
int compno;
|
||||||
fprintf(stdout, "image {\n");
|
fprintf(stdout, "image {\n");
|
||||||
fprintf(stdout, " x0=%d, y0=%d, x1=%d, y1=%d\n", img->x0, img->y0,
|
fprintf(stdout, " x0=%d, y0=%d, x1=%d, y1=%d\n", img->x0, img->y0,
|
||||||
img->x1, img->y1);
|
img->x1, img->y1);
|
||||||
fprintf(stdout, " numcomps=%d\n", img->numcomps);
|
fprintf(stdout, " numcomps=%d\n", img->numcomps);
|
||||||
for (compno = 0; compno < img->numcomps; compno++) {
|
for (compno = 0; compno < img->numcomps; compno++) {
|
||||||
j2k_comp_t *comp = &img->comps[compno];
|
j2k_comp_t *comp = &img->comps[compno];
|
||||||
|
@ -157,7 +157,7 @@ void j2k_dump_cp(j2k_image_t * img, j2k_cp_t * cp)
|
||||||
J2K_CCP_QNTSTY_SIQNT ? 1 : tccp->numresolutions * 3 - 2;
|
J2K_CCP_QNTSTY_SIQNT ? 1 : tccp->numresolutions * 3 - 2;
|
||||||
for (bandno = 0; bandno < numbands; bandno++) {
|
for (bandno = 0; bandno < numbands; bandno++) {
|
||||||
fprintf(stdout, "(%d,%d) ", tccp->stepsizes[bandno].mant,
|
fprintf(stdout, "(%d,%d) ", tccp->stepsizes[bandno].mant,
|
||||||
tccp->stepsizes[bandno].expn);
|
tccp->stepsizes[bandno].expn);
|
||||||
}
|
}
|
||||||
fprintf(stdout, "\n");
|
fprintf(stdout, "\n");
|
||||||
|
|
||||||
|
@ -479,8 +479,8 @@ void j2k_read_qcx(int compno, int len)
|
||||||
tccp->numgbits = tmp >> 5;
|
tccp->numgbits = tmp >> 5;
|
||||||
numbands =
|
numbands =
|
||||||
tccp->qntsty == J2K_CCP_QNTSTY_SIQNT ? 1 : (tccp->qntsty ==
|
tccp->qntsty == J2K_CCP_QNTSTY_SIQNT ? 1 : (tccp->qntsty ==
|
||||||
J2K_CCP_QNTSTY_NOQNT ?
|
J2K_CCP_QNTSTY_NOQNT ?
|
||||||
len - 1 : (len - 1) / 2);
|
len - 1 : (len - 1) / 2);
|
||||||
for (bandno = 0; bandno < numbands; bandno++) {
|
for (bandno = 0; bandno < numbands; bandno++) {
|
||||||
int expn, mant;
|
int expn, mant;
|
||||||
if (tccp->qntsty == J2K_CCP_QNTSTY_NOQNT) {
|
if (tccp->qntsty == J2K_CCP_QNTSTY_NOQNT) {
|
||||||
|
@ -507,7 +507,7 @@ void j2k_read_qcx(int compno, int len)
|
||||||
|
|
||||||
tccp->stepsizes[bandno].expn =
|
tccp->stepsizes[bandno].expn =
|
||||||
((tccp->stepsizes[0].expn) - ((bandno - 1) / 3) >
|
((tccp->stepsizes[0].expn) - ((bandno - 1) / 3) >
|
||||||
0) ? (tccp->stepsizes[0].expn) - ((bandno - 1) / 3) : 0;
|
0) ? (tccp->stepsizes[0].expn) - ((bandno - 1) / 3) : 0;
|
||||||
|
|
||||||
tccp->stepsizes[bandno].mant = tccp->stepsizes[0].mant;
|
tccp->stepsizes[bandno].mant = tccp->stepsizes[0].mant;
|
||||||
|
|
||||||
|
@ -724,9 +724,9 @@ void j2k_read_ppm()
|
||||||
} else { /* NON-first PPM marker */
|
} else { /* NON-first PPM marker */
|
||||||
j2k_cp->ppm_data =
|
j2k_cp->ppm_data =
|
||||||
(unsigned char *) realloc(j2k_cp->ppm_data,
|
(unsigned char *) realloc(j2k_cp->ppm_data,
|
||||||
(N_ppm +
|
(N_ppm +
|
||||||
j2k_cp->ppm_store) *
|
j2k_cp->ppm_store) *
|
||||||
sizeof(unsigned char));
|
sizeof(unsigned char));
|
||||||
|
|
||||||
j2k_cp->ppm_len = N_ppm + j2k_cp->ppm_store; //Add antonin : ppmbug1
|
j2k_cp->ppm_len = N_ppm + j2k_cp->ppm_store; //Add antonin : ppmbug1
|
||||||
|
|
||||||
|
@ -763,8 +763,8 @@ void j2k_read_ppt()
|
||||||
} else { /* NON-first PPT marker */
|
} else { /* NON-first PPT marker */
|
||||||
tcp->ppt_data =
|
tcp->ppt_data =
|
||||||
(unsigned char *) realloc(tcp->ppt_data,
|
(unsigned char *) realloc(tcp->ppt_data,
|
||||||
(len - 3 +
|
(len - 3 +
|
||||||
tcp->ppt_store) * sizeof(unsigned char));
|
tcp->ppt_store) * sizeof(unsigned char));
|
||||||
|
|
||||||
tcp->ppt_len = len - 3 + tcp->ppt_store; //Add antonin : ppmbug1
|
tcp->ppt_len = len - 3 + tcp->ppt_store; //Add antonin : ppmbug1
|
||||||
|
|
||||||
|
@ -867,8 +867,8 @@ void j2k_write_sod()
|
||||||
cio_tell() + pos_correction - 1;
|
cio_tell() + pos_correction - 1;
|
||||||
info_IM.tile[j2k_curtileno].packet =
|
info_IM.tile[j2k_curtileno].packet =
|
||||||
(info_packet *) calloc(info_IM.Comp * info_IM.Layer *
|
(info_packet *) calloc(info_IM.Comp * info_IM.Layer *
|
||||||
(info_IM.Decomposition + 1) * 100,
|
(info_IM.Decomposition + 1) * 100,
|
||||||
sizeof(info_packet));
|
sizeof(info_packet));
|
||||||
}
|
}
|
||||||
/* << INDEX */
|
/* << INDEX */
|
||||||
|
|
||||||
|
@ -880,10 +880,10 @@ void j2k_write_sod()
|
||||||
info_IM.num = 0;
|
info_IM.num = 0;
|
||||||
if (j2k_cp->image_type)
|
if (j2k_cp->image_type)
|
||||||
l = tcd_encode_tile_pxm(j2k_curtileno, cio_getbp(),
|
l = tcd_encode_tile_pxm(j2k_curtileno, cio_getbp(),
|
||||||
cio_numbytesleft() - 2, &info_IM);
|
cio_numbytesleft() - 2, &info_IM);
|
||||||
else
|
else
|
||||||
l = tcd_encode_tile_pgx(j2k_curtileno, cio_getbp(),
|
l = tcd_encode_tile_pgx(j2k_curtileno, cio_getbp(),
|
||||||
cio_numbytesleft() - 2, &info_IM);
|
cio_numbytesleft() - 2, &info_IM);
|
||||||
|
|
||||||
/* Writing Psot in SOT marker */
|
/* Writing Psot in SOT marker */
|
||||||
totlen = cio_tell() + l - j2k_sot_start;
|
totlen = cio_tell() + l - j2k_sot_start;
|
||||||
|
@ -903,7 +903,7 @@ void j2k_read_sod()
|
||||||
|
|
||||||
data =
|
data =
|
||||||
(unsigned char *) malloc((j2k_tile_len[j2k_curtileno] + len) *
|
(unsigned char *) malloc((j2k_tile_len[j2k_curtileno] + len) *
|
||||||
sizeof(unsigned char));
|
sizeof(unsigned char));
|
||||||
for (i = 0; i < j2k_tile_len[j2k_curtileno]; i++)
|
for (i = 0; i < j2k_tile_len[j2k_curtileno]; i++)
|
||||||
data[i] = j2k_tile_data[j2k_curtileno][i];
|
data[i] = j2k_tile_data[j2k_curtileno][i];
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
|
@ -976,7 +976,7 @@ LIBJ2K_API int
|
||||||
j2k_encode(j2k_image_t * img, j2k_cp_t * cp, char *output,
|
j2k_encode(j2k_image_t * img, j2k_cp_t * cp, char *output,
|
||||||
int len, char *index)
|
int len, char *index)
|
||||||
{
|
{
|
||||||
int tileno, compno, layno, resno, precno, pack_nb;
|
int tileno, compno, layno, resno, precno, pack_nb, x, y;
|
||||||
char *dest = NULL;
|
char *dest = NULL;
|
||||||
FILE *INDEX = NULL;
|
FILE *INDEX = NULL;
|
||||||
FILE *f = NULL;
|
FILE *f = NULL;
|
||||||
|
@ -1011,6 +1011,8 @@ j2k_encode(j2k_image_t * img, j2k_cp_t * cp, char *output,
|
||||||
info_IM.th = j2k_cp->th;
|
info_IM.th = j2k_cp->th;
|
||||||
info_IM.Tile_x = j2k_cp->tdx; /* new version parser */
|
info_IM.Tile_x = j2k_cp->tdx; /* new version parser */
|
||||||
info_IM.Tile_y = j2k_cp->tdy; /* new version parser */
|
info_IM.Tile_y = j2k_cp->tdy; /* new version parser */
|
||||||
|
info_IM.Tile_Ox = j2k_cp->tx0; /* new version parser */
|
||||||
|
info_IM.Tile_Oy = j2k_cp->ty0; /* new version parser */
|
||||||
info_IM.Comp = j2k_img->numcomps;
|
info_IM.Comp = j2k_img->numcomps;
|
||||||
info_IM.Layer = (&j2k_cp->tcps[0])->numlayers;
|
info_IM.Layer = (&j2k_cp->tcps[0])->numlayers;
|
||||||
info_IM.Decomposition = (&j2k_cp->tcps[0])->tccps->numresolutions - 1;
|
info_IM.Decomposition = (&j2k_cp->tcps[0])->tccps->numresolutions - 1;
|
||||||
|
@ -1086,23 +1088,23 @@ j2k_encode(j2k_image_t * img, j2k_cp_t * cp, char *output,
|
||||||
/* << INDEX */
|
/* << INDEX */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (tile->PPT) BAD PPT !!!
|
if (tile->PPT) BAD PPT !!!
|
||||||
{
|
{
|
||||||
FILE *PPT_file;
|
FILE *PPT_file;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
PPT_file=fopen("PPT","rb");
|
PPT_file=fopen("PPT","rb");
|
||||||
fprintf(stderr,"%c%c%c%c",255,97,tile->len_ppt/256,tile->len_ppt%256);
|
fprintf(stderr,"%c%c%c%c",255,97,tile->len_ppt/256,tile->len_ppt%256);
|
||||||
for (i=0;i<tile->len_ppt;i++)
|
for (i=0;i<tile->len_ppt;i++)
|
||||||
{
|
{
|
||||||
unsigned char elmt;
|
unsigned char elmt;
|
||||||
fread(&elmt, 1, 1, PPT_file);
|
fread(&elmt, 1, 1, PPT_file);
|
||||||
fwrite(&elmt,1,1,f);
|
fwrite(&elmt,1,1,f);
|
||||||
}
|
}
|
||||||
fclose(PPT_file);
|
fclose(PPT_file);
|
||||||
unlink("PPT");
|
unlink("PPT");
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if (cp->intermed_file == 1) {
|
if (cp->intermed_file == 1) {
|
||||||
fwrite(dest, 1, cio_tell(), f);
|
fwrite(dest, 1, cio_tell(), f);
|
||||||
pos_correction = cio_tell() + pos_correction;
|
pos_correction = cio_tell() + pos_correction;
|
||||||
|
@ -1144,8 +1146,6 @@ j2k_encode(j2k_image_t * img, j2k_cp_t * cp, char *output,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fprintf(INDEX, "%d %d\n", info_IM.Im_w, info_IM.Im_h);
|
fprintf(INDEX, "%d %d\n", info_IM.Im_w, info_IM.Im_h);
|
||||||
|
|
||||||
fprintf(INDEX, "%d\n", info_IM.Prog);
|
fprintf(INDEX, "%d\n", info_IM.Prog);
|
||||||
|
@ -1197,194 +1197,161 @@ j2k_encode(j2k_image_t * img, j2k_cp_t * cp, char *output,
|
||||||
"pkno tileno layerno resno compno precno start_pos end_pos deltaSE \n"); */
|
"pkno tileno layerno resno compno precno start_pos end_pos deltaSE \n"); */
|
||||||
|
|
||||||
if (info_IM.Prog == 0) { /* LRCP */
|
if (info_IM.Prog == 0) { /* LRCP */
|
||||||
|
//fprintf(INDEX, "pack_nb tileno layno resno compno precno start_pos end_pos disto");
|
||||||
for (layno = 0; layno < info_IM.Layer; layno++) {
|
for (layno = 0; layno < info_IM.Layer; layno++) {
|
||||||
|
|
||||||
for (resno = 0; resno < info_IM.Decomposition + 1; resno++) {
|
for (resno = 0; resno < info_IM.Decomposition + 1; resno++) {
|
||||||
|
|
||||||
for (compno = 0; compno < info_IM.Comp; compno++) {
|
for (compno = 0; compno < info_IM.Comp; compno++) {
|
||||||
|
|
||||||
for (precno = 0;
|
for (precno = 0;
|
||||||
precno <
|
precno <
|
||||||
info_IM.tile[tileno].pw[resno] *
|
info_IM.tile[tileno].pw[resno] * info_IM.tile[tileno].ph[resno];
|
||||||
info_IM.tile[tileno].ph[resno]; precno++) {
|
precno++) {
|
||||||
|
|
||||||
start_pos = info_IM.tile[tileno].packet[pack_nb].start_pos;
|
start_pos = info_IM.tile[tileno].packet[pack_nb].start_pos;
|
||||||
|
|
||||||
end_pos = info_IM.tile[tileno].packet[pack_nb].end_pos;
|
end_pos = info_IM.tile[tileno].packet[pack_nb].end_pos;
|
||||||
|
|
||||||
disto = info_IM.tile[tileno].packet[pack_nb].disto;
|
disto = info_IM.tile[tileno].packet[pack_nb].disto;
|
||||||
|
fprintf(INDEX, "%4d %6d %7d %5d %6d %6d %9d %9d %8e\n",
|
||||||
fprintf(INDEX,
|
pack_nb, tileno, layno, resno, compno, precno,
|
||||||
"%4d %6d %7d %5d %6d %6d %9d %9d %8e\n",
|
start_pos, end_pos, disto);
|
||||||
pack_nb, tileno, layno, resno, compno,
|
|
||||||
precno, start_pos, end_pos, disto);
|
|
||||||
|
|
||||||
DistoTotal += disto;
|
DistoTotal += disto;
|
||||||
|
|
||||||
pack_nb++;
|
pack_nb++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (info_IM.Prog == 1) { /* RLCP */
|
} else if (info_IM.Prog == 1) { /* RLCP */
|
||||||
|
//fprintf(INDEX, "pack_nb tileno resno layno compno precno start_pos end_pos disto");
|
||||||
for (resno = 0; resno < info_IM.Decomposition + 1; resno++) {
|
for (resno = 0; resno < info_IM.Decomposition + 1; resno++) {
|
||||||
|
|
||||||
for (layno = 0; layno < info_IM.Layer; layno++) {
|
for (layno = 0; layno < info_IM.Layer; layno++) {
|
||||||
|
|
||||||
for (compno = 0; compno < info_IM.Comp; compno++) {
|
for (compno = 0; compno < info_IM.Comp; compno++) {
|
||||||
|
for (precno = 0; precno < info_IM.tile[tileno].pw[resno] * info_IM.tile[tileno].ph[resno]; precno++) {
|
||||||
for (precno = 0;
|
|
||||||
precno <
|
|
||||||
info_IM.tile[tileno].pw[resno] *
|
|
||||||
info_IM.tile[tileno].ph[resno]; precno++) {
|
|
||||||
|
|
||||||
start_pos = info_IM.tile[tileno].packet[pack_nb].start_pos;
|
start_pos = info_IM.tile[tileno].packet[pack_nb].start_pos;
|
||||||
|
|
||||||
end_pos = info_IM.tile[tileno].packet[pack_nb].end_pos;
|
end_pos = info_IM.tile[tileno].packet[pack_nb].end_pos;
|
||||||
|
|
||||||
disto = info_IM.tile[tileno].packet[pack_nb].disto;
|
disto = info_IM.tile[tileno].packet[pack_nb].disto;
|
||||||
|
fprintf(INDEX, "%4d %6d %5d %7d %6d %6d %9d %9d %8e\n",
|
||||||
fprintf(INDEX,
|
pack_nb, tileno, resno, layno, compno, precno,
|
||||||
"%4d %6d %7d %5d %6d %6d %9d %9d %8e\n",
|
start_pos, end_pos, disto);
|
||||||
pack_nb, tileno, layno, resno, compno,
|
|
||||||
precno, start_pos, end_pos, disto);
|
|
||||||
|
|
||||||
DistoTotal += disto;
|
DistoTotal += disto;
|
||||||
|
|
||||||
pack_nb++;
|
pack_nb++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (info_IM.Prog == 2) { /* RPCL */
|
} else if (info_IM.Prog == 2) { /* RPCL */
|
||||||
|
//fprintf(INDEX, "\npack_nb tileno resno precno compno layno start_pos end_pos disto\n");
|
||||||
for (resno = 0; resno < info_IM.Decomposition + 1; resno++) {
|
for (resno = 0; resno < info_IM.Decomposition + 1; resno++) {
|
||||||
|
/* I suppose components have same XRsiz, YRsiz */
|
||||||
for (precno = 0;
|
int x0 = info_IM.Tile_Ox + tileno - (int)floor( tileno/info_IM.tw ) * info_IM.tw * info_IM.Tile_x;
|
||||||
precno <
|
int y0 = info_IM.Tile_Ox + (int)floor( tileno/info_IM.tw ) * info_IM.Tile_y;
|
||||||
info_IM.tile[tileno].pw[resno] *
|
int x1 = x0 + info_IM.Tile_x;
|
||||||
info_IM.tile[tileno].ph[resno]; precno++) {
|
int y1 = y0 + info_IM.Tile_y;
|
||||||
|
for (y=y0; y<y1; y++) {
|
||||||
for (compno = 0; compno < info_IM.Comp; compno++) {
|
for (x=x0; x<x1; x++) {
|
||||||
|
for (compno = 0; compno < info_IM.Comp; compno++) {
|
||||||
for (layno = 0; layno < info_IM.Layer; layno++) {
|
int prec_max = info_IM.tile[tileno].pw[resno] * info_IM.tile[tileno].ph[resno];
|
||||||
|
for (precno = 0; precno < prec_max; precno++) {
|
||||||
start_pos = info_IM.tile[tileno].packet[pack_nb].start_pos;
|
int pcnx = info_IM.tile[tileno].pw[resno];
|
||||||
|
int pcx = (int) pow( 2, info_IM.tile[tileno].pdx[resno] + info_IM.Decomposition - resno );
|
||||||
end_pos = info_IM.tile[tileno].packet[pack_nb].end_pos;
|
int pcy = (int) pow( 2, info_IM.tile[tileno].pdy[resno] + info_IM.Decomposition - resno );
|
||||||
|
int precno_x = precno - (int) floor( precno/pcnx ) * pcnx;
|
||||||
disto = info_IM.tile[tileno].packet[pack_nb].disto;
|
int precno_y = (int) floor( precno/pcnx );
|
||||||
|
if (precno_y*pcy == y ) {
|
||||||
fprintf(INDEX,
|
if (precno_x*pcx == x ) {
|
||||||
"%4d %6d %7d %5d %6d %6d %9d %9d %8e\n",
|
for (layno = 0; layno < info_IM.Layer; layno++) {
|
||||||
pack_nb, tileno, layno, resno, compno,
|
start_pos = info_IM.tile[tileno].packet[pack_nb].start_pos;
|
||||||
precno, start_pos, end_pos, disto);
|
end_pos = info_IM.tile[tileno].packet[pack_nb].end_pos;
|
||||||
|
disto = info_IM.tile[tileno].packet[pack_nb].disto;
|
||||||
DistoTotal += disto;
|
fprintf(INDEX, "%4d %6d %5d %6d %6d %7d %9d %9d %8e\n",
|
||||||
|
pack_nb, tileno, resno, precno, compno, layno,
|
||||||
pack_nb++;
|
start_pos, end_pos, disto);
|
||||||
|
DistoTotal += disto;
|
||||||
|
pack_nb++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (info_IM.Prog == 3) { /* PCRL */
|
} else if (info_IM.Prog == 3) { /* PCRL */
|
||||||
|
// I suppose components have same XRsiz, YRsiz
|
||||||
|
int x0 = info_IM.Tile_Ox + tileno - (int)floor( tileno/info_IM.tw ) * info_IM.tw * info_IM.Tile_x;
|
||||||
|
int y0 = info_IM.Tile_Ox + (int)floor( tileno/info_IM.tw ) * info_IM.Tile_y;
|
||||||
|
int x1 = x0 + info_IM.Tile_x;
|
||||||
|
int y1 = y0 + info_IM.Tile_y;
|
||||||
|
|
||||||
for (precno = 0;
|
//fprintf(INDEX, "\npack_nb tileno precno compno resno layno start_pos end_pos disto\n");
|
||||||
precno <
|
for (y=y0; y<y1; y++) {
|
||||||
info_IM.tile[tileno].pw[resno] *
|
for (x=x0; x<x1; x++) {
|
||||||
info_IM.tile[tileno].ph[resno]; precno++) {
|
for (compno = 0; compno < info_IM.Comp; compno++) {
|
||||||
|
for (resno = 0; resno < info_IM.Decomposition + 1; resno++) {
|
||||||
for (compno = 0; compno < info_IM.Comp; compno++) {
|
int prec_max = info_IM.tile[tileno].pw[resno] * info_IM.tile[tileno].ph[resno];
|
||||||
|
for (precno = 0; precno < prec_max; precno++) {
|
||||||
for (resno = 0; resno < info_IM.Decomposition + 1; resno++) {
|
int pcnx = info_IM.tile[tileno].pw[resno];
|
||||||
|
int pcx = (int) pow( 2, info_IM.tile[tileno].pdx[resno] + info_IM.Decomposition - resno );
|
||||||
for (layno = 0; layno < info_IM.Layer; layno++) {
|
int pcy = (int) pow( 2, info_IM.tile[tileno].pdy[resno] + info_IM.Decomposition - resno );
|
||||||
|
int precno_x = precno - (int) floor( precno/pcnx ) * pcnx;
|
||||||
start_pos = info_IM.tile[tileno].packet[pack_nb].start_pos;
|
int precno_y = (int) floor( precno/pcnx );
|
||||||
|
if (precno_y*pcy == y ) {
|
||||||
end_pos = info_IM.tile[tileno].packet[pack_nb].end_pos;
|
if (precno_x*pcx == x ) {
|
||||||
|
for (layno = 0; layno < info_IM.Layer; layno++) {
|
||||||
disto = info_IM.tile[tileno].packet[pack_nb].disto;
|
start_pos = info_IM.tile[tileno].packet[pack_nb].start_pos;
|
||||||
|
end_pos = info_IM.tile[tileno].packet[pack_nb].end_pos;
|
||||||
fprintf(INDEX,
|
disto = info_IM.tile[tileno].packet[pack_nb].disto;
|
||||||
"%4d %6d %7d %5d %6d %6d %9d %9d %8e\n",
|
fprintf(INDEX, "%4d %6d %6d %6d %5d %7d %9d %9d %8e\n",
|
||||||
pack_nb, tileno, layno, resno, compno,
|
pack_nb, tileno, precno, compno, resno, layno,
|
||||||
precno, start_pos, end_pos, disto);
|
start_pos, end_pos, disto);
|
||||||
|
DistoTotal += disto;
|
||||||
DistoTotal += disto;
|
pack_nb++;
|
||||||
|
}
|
||||||
pack_nb++;
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else { /* CPRL */
|
} else { /* CPRL */
|
||||||
|
//fprintf(INDEX, "\npack_nb tileno compno precno resno layno start_pos end_pos disto\n");
|
||||||
|
|
||||||
|
|
||||||
for (compno = 0; compno < info_IM.Comp; compno++) {
|
for (compno = 0; compno < info_IM.Comp; compno++) {
|
||||||
|
/* I suppose components have same XRsiz, YRsiz */
|
||||||
for (precno = 0;
|
int x0 = info_IM.Tile_Ox + tileno - (int)floor( tileno/info_IM.tw ) * info_IM.tw * info_IM.Tile_x;
|
||||||
precno <
|
int y0 = info_IM.Tile_Ox + (int)floor( tileno/info_IM.tw ) * info_IM.Tile_y;
|
||||||
info_IM.tile[tileno].pw[resno] *
|
int x1 = x0 + info_IM.Tile_x;
|
||||||
info_IM.tile[tileno].ph[resno]; precno++) {
|
int y1 = y0 + info_IM.Tile_y;
|
||||||
|
for (y=y0; y<y1; y++) {
|
||||||
for (resno = 0; resno < info_IM.Decomposition + 1; resno++) {
|
for (x=x0; x<x1; x++) {
|
||||||
|
for (resno = 0; resno < info_IM.Decomposition + 1; resno++) {
|
||||||
for (layno = 0; layno < info_IM.Layer; layno++) {
|
int prec_max = info_IM.tile[tileno].pw[resno] * info_IM.tile[tileno].ph[resno];
|
||||||
|
for (precno = 0; precno < prec_max; precno++) {
|
||||||
start_pos = info_IM.tile[tileno].packet[pack_nb].start_pos;
|
int pcnx = info_IM.tile[tileno].pw[resno];
|
||||||
|
int pcx = (int) pow( 2, info_IM.tile[tileno].pdx[resno] + info_IM.Decomposition - resno );
|
||||||
end_pos = info_IM.tile[tileno].packet[pack_nb].end_pos;
|
int pcy = (int) pow( 2, info_IM.tile[tileno].pdy[resno] + info_IM.Decomposition - resno );
|
||||||
|
int precno_x = precno - (int) floor( precno/pcnx ) * pcnx;
|
||||||
disto = info_IM.tile[tileno].packet[pack_nb].disto;
|
int precno_y = (int) floor( precno/pcnx );
|
||||||
|
if (precno_y*pcy == y ) {
|
||||||
fprintf(INDEX,
|
if (precno_x*pcx == x ) {
|
||||||
"%4d %6d %7d %5d %6d %6d %9d %9d %8e\n",
|
for (layno = 0; layno < info_IM.Layer; layno++) {
|
||||||
pack_nb, tileno, layno, resno, compno,
|
start_pos = info_IM.tile[tileno].packet[pack_nb].start_pos;
|
||||||
precno, start_pos, end_pos, disto);
|
end_pos = info_IM.tile[tileno].packet[pack_nb].end_pos;
|
||||||
|
disto = info_IM.tile[tileno].packet[pack_nb].disto;
|
||||||
DistoTotal += disto;
|
fprintf(INDEX, "%4d %6d %6d %6d %5d %7d %9d %9d %8e\n",
|
||||||
|
pack_nb, tileno, compno, precno, resno, layno, start_pos, end_pos, disto);
|
||||||
pack_nb++;
|
DistoTotal += disto;
|
||||||
|
pack_nb++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(INDEX, "SE max : %8e\n", info_IM.D_max);
|
fprintf(INDEX, "%8e\n", info_IM.D_max); //SE max
|
||||||
|
|
||||||
fprintf(INDEX, "SE total : %.8e\n", DistoTotal);
|
fprintf(INDEX, "%.8e\n", DistoTotal); // SE totale
|
||||||
|
|
||||||
fclose(INDEX);
|
fclose(INDEX);
|
||||||
|
|
||||||
|
@ -1464,7 +1431,7 @@ j2k_decode(unsigned char *src, int len, j2k_image_t * img, j2k_cp_t * cp)
|
||||||
int id = cio_read(2);
|
int id = cio_read(2);
|
||||||
if (id >> 8 != 0xff) {
|
if (id >> 8 != 0xff) {
|
||||||
fprintf(stderr, "%.8x: expected a marker instead of %x\n",
|
fprintf(stderr, "%.8x: expected a marker instead of %x\n",
|
||||||
cio_tell() - 2, id);
|
cio_tell() - 2, id);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
e = j2k_dec_mstab_lookup(id);
|
e = j2k_dec_mstab_lookup(id);
|
||||||
|
@ -1487,9 +1454,9 @@ j2k_decode(unsigned char *src, int len, j2k_image_t * img, j2k_cp_t * cp)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read a JPT-stream and decode file
|
* Read a JPT-stream and decode file
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
j2k_decode_jpt_stream(unsigned char *src, int len, j2k_image_t * img,
|
j2k_decode_jpt_stream(unsigned char *src, int len, j2k_image_t * img,
|
||||||
j2k_cp_t * cp)
|
j2k_cp_t * cp)
|
||||||
|
@ -1520,8 +1487,8 @@ j2k_decode_jpt_stream(unsigned char *src, int len, j2k_image_t * img,
|
||||||
position = cio_tell();
|
position = cio_tell();
|
||||||
if (header.Class_Id != 6) { /* 6 : Main header data-bin message */
|
if (header.Class_Id != 6) { /* 6 : Main header data-bin message */
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"[JPT-stream] : Expecting Main header first [class_Id %d] !\n",
|
"[JPT-stream] : Expecting Main header first [class_Id %d] !\n",
|
||||||
header.Class_Id);
|
header.Class_Id);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1546,7 +1513,7 @@ j2k_decode_jpt_stream(unsigned char *src, int len, j2k_image_t * img,
|
||||||
id = cio_read(2);
|
id = cio_read(2);
|
||||||
if (id >> 8 != 0xff) {
|
if (id >> 8 != 0xff) {
|
||||||
fprintf(stderr, "%.8x: expected a marker instead of %x\n",
|
fprintf(stderr, "%.8x: expected a marker instead of %x\n",
|
||||||
cio_tell() - 2, id);
|
cio_tell() - 2, id);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
e = j2k_dec_mstab_lookup(id);
|
e = j2k_dec_mstab_lookup(id);
|
||||||
|
|
|
@ -176,6 +176,7 @@ typedef struct {
|
||||||
int Im_w, Im_h; /* Image width and Height */
|
int Im_w, Im_h; /* Image width and Height */
|
||||||
int Prog; /* progression order */
|
int Prog; /* progression order */
|
||||||
int Tile_x, Tile_y; /* Tile size in x and y */
|
int Tile_x, Tile_y; /* Tile size in x and y */
|
||||||
|
int Tile_Ox, Tile_Oy;
|
||||||
int tw, th; /* Number of Tile in X and Y */
|
int tw, th; /* Number of Tile in X and Y */
|
||||||
int Comp; /* Component numbers */
|
int Comp; /* Component numbers */
|
||||||
int Layer; /* number of layer */
|
int Layer; /* number of layer */
|
||||||
|
|
Loading…
Reference in New Issue