summaryrefslogtreecommitdiff
path: root/codec
diff options
context:
space:
mode:
Diffstat (limited to 'codec')
-rw-r--r--codec/CMakeLists.txt5
-rw-r--r--codec/Makefile4
-rw-r--r--codec/image_to_j2k.c277
-rw-r--r--codec/image_to_j2k.slnbin1506 -> 1506 bytes
-rw-r--r--codec/image_to_j2k.vcproj8
-rw-r--r--codec/index.c390
-rw-r--r--codec/index.h41
-rw-r--r--codec/j2k_to_image.c245
-rw-r--r--codec/j2k_to_image.vcproj8
9 files changed, 454 insertions, 524 deletions
diff --git a/codec/CMakeLists.txt b/codec/CMakeLists.txt
index ecc31bdd..26cd7eeb 100644
--- a/codec/CMakeLists.txt
+++ b/codec/CMakeLists.txt
@@ -3,7 +3,9 @@
# First thing define the common source:
SET(common_SRCS
convert.c
- )
+ index.c
+)
+
# Then check if getopt is present:
INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
SET(DONT_HAVE_GETOPT 1)
@@ -24,7 +26,6 @@ IF(DONT_HAVE_GETOPT)
)
ENDIF(DONT_HAVE_GETOPT)
-
# Headers file are located here:
INCLUDE_DIRECTORIES(
${OPENJPEG_SOURCE_DIR}/libopenjpeg
diff --git a/codec/Makefile b/codec/Makefile
index f38ff762..14487a5f 100644
--- a/codec/Makefile
+++ b/codec/Makefile
@@ -5,10 +5,10 @@ CFLAGS = -O3 -lstdc++ # -g -p -pg
all: j2k_to_image image_to_j2k
j2k_to_image: j2k_to_image.c ../libopenjpeg.a
- gcc $(CFLAGS) compat/getopt.c convert.c j2k_to_image.c -o j2k_to_image -L.. -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
+ gcc $(CFLAGS) compat/getopt.c index.c convert.c j2k_to_image.c -o j2k_to_image -L.. -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
image_to_j2k: image_to_j2k.c ../libopenjpeg.a
- gcc $(CFLAGS) compat/getopt.c convert.c image_to_j2k.c -o image_to_j2k -L.. -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
+ gcc $(CFLAGS) compat/getopt.c index.c convert.c image_to_j2k.c -o image_to_j2k -L.. -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
clean:
rm -f j2k_to_image image_to_j2k
diff --git a/codec/image_to_j2k.c b/codec/image_to_j2k.c
index 54ca14a1..f505e997 100644
--- a/codec/image_to_j2k.c
+++ b/codec/image_to_j2k.c
@@ -38,6 +38,7 @@
#include "compat/getopt.h"
#include "convert.h"
#include "dirent.h"
+#include "index.h"
#ifndef WIN32
#define stricmp strcasecmp
@@ -566,282 +567,6 @@ void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image, img_
/* ------------------------------------------------------------------------------------ */
-/**
-Create an index and write it to a file
-@param cstr_info Codestream information
-@param index Index filename
-@return Returns 0 if successful, returns 1 otherwise
-*/
-int write_index_file(opj_codestream_info_t *cstr_info, char *index) {
- int tileno, compno, layno, resno, precno, pack_nb, x, y;
- FILE *stream = NULL;
- double total_disto = 0;
-/* UniPG>> */
- int tilepartno;
-
-#ifdef USE_JPWL
- if (!strcmp(index, JPWL_PRIVATEINDEX_NAME))
- return 0;
-#endif /* USE_JPWL */
-/* <<UniPG */
-
- if (!cstr_info)
- return 1;
-
- stream = fopen(index, "w");
- if (!stream) {
- fprintf(stderr, "failed to open index file [%s] for writing\n", index);
- return 1;
- }
-
- fprintf(stream, "%d %d\n", cstr_info->image_w, cstr_info->image_h);
- fprintf(stream, "%d\n", cstr_info->prog);
- fprintf(stream, "%d %d\n", cstr_info->tile_x, cstr_info->tile_y);
- fprintf(stream, "%d %d\n", cstr_info->tw, cstr_info->th);
- fprintf(stream, "%d\n", cstr_info->numcomps);
- fprintf(stream, "%d\n", cstr_info->numlayers);
- fprintf(stream, "%d\n", cstr_info->numdecompos);
-
- for (resno = cstr_info->numdecompos[0]; resno >= 0; resno--) {
- fprintf(stream, "[%d,%d] ",
- (1 << cstr_info->tile[0].pdx[resno]), (1 << cstr_info->tile[0].pdx[resno])); /* based on tile 0 and component 0 */
- }
-
- fprintf(stream, "\n");
-/* UniPG>> */
- fprintf(stream, "%d\n", cstr_info->main_head_start);
-/* <<UniPG */
- fprintf(stream, "%d\n", cstr_info->main_head_end);
- fprintf(stream, "%d\n", cstr_info->codestream_size);
-
- fprintf(stream, "\nINFO ON TILES\n");
- fprintf(stream, "tileno start_pos end_hd end_tile nbparts disto nbpix disto/nbpix\n");
- for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
- fprintf(stream, "%4d %9d %9d %9d %9d %9e %9d %9e\n",
- cstr_info->tile[tileno].tileno,
- cstr_info->tile[tileno].start_pos,
- cstr_info->tile[tileno].end_header,
- cstr_info->tile[tileno].end_pos,
- cstr_info->tile[tileno].num_tps,
- cstr_info->tile[tileno].distotile, cstr_info->tile[tileno].numpix,
- cstr_info->tile[tileno].distotile / cstr_info->tile[tileno].numpix);
- }
-
- for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
- int start_pos, end_ph_pos, end_pos;
- double disto = 0;
- int max_numdecompos = 0;
- pack_nb = 0;
-
- for (compno = 0; compno < cstr_info->numcomps; compno++) {
- if (max_numdecompos < cstr_info->numdecompos[compno])
- max_numdecompos = cstr_info->numdecompos[compno];
- }
-
- fprintf(stream, "\nTILE %d DETAILS\n", tileno);
- fprintf(stream, "part_nb tileno start_pack num_packs start_pos end_tph_pos end_pos\n");
- for (tilepartno = 0; tilepartno < cstr_info->tile[tileno].num_tps; tilepartno++)
- fprintf(stream, "%4d %9d %9d %9d %9d %11d %9d\n",
- tilepartno, tileno,
- cstr_info->tile[tileno].tp[tilepartno].tp_start_pack,
- cstr_info->tile[tileno].tp[tilepartno].tp_numpacks,
- cstr_info->tile[tileno].tp[tilepartno].tp_start_pos,
- cstr_info->tile[tileno].tp[tilepartno].tp_end_header,
- cstr_info->tile[tileno].tp[tilepartno].tp_end_pos
- );
- if (cstr_info->prog == LRCP) { /* LRCP */
- fprintf(stream, "LRCP\npack_nb tileno layno resno compno precno start_pos end_ph_pos end_pos disto\n");
-
- for (layno = 0; layno < cstr_info->numlayers; layno++) {
- for (resno = 0; resno < max_numdecompos + 1; resno++) {
- for (compno = 0; compno < cstr_info->numcomps; compno++) {
- int prec_max;
- if (resno > cstr_info->numdecompos[compno])
- break;
- prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
- for (precno = 0; precno < prec_max; precno++) {
- start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
- end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
- end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
- disto = cstr_info->tile[tileno].packet[pack_nb].disto;
- fprintf(stream, "%4d %6d %7d %5d %6d %6d %6d %6d %7d %8e\n",
- pack_nb, tileno, layno, resno, compno, precno, start_pos, end_ph_pos, end_pos, disto);
- total_disto += disto;
- pack_nb++;
- }
- }
- }
- }
- } /* LRCP */
- else if (cstr_info->prog == RLCP) { /* RLCP */
-
- fprintf(stream, "RLCP\npack_nb tileno resno layno compno precno start_pos end_ph_pos end_pos disto\n");
-
- for (resno = 0; resno < max_numdecompos + 1; resno++) {
- for (layno = 0; layno < cstr_info->numlayers; layno++) {
- for (compno = 0; compno < cstr_info->numcomps; compno++) {
- int prec_max;
- if (resno > cstr_info->numdecompos[compno])
- break;
- prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
- for (precno = 0; precno < prec_max; precno++) {
- start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
- end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
- end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
- disto = cstr_info->tile[tileno].packet[pack_nb].disto;
- fprintf(stream, "%4d %6d %5d %7d %6d %6d %9d %9d %7d %8e\n",
- pack_nb, tileno, resno, layno, compno, precno, start_pos, end_ph_pos, end_pos, disto);
- total_disto += disto;
- pack_nb++;
- }
- }
- }
- }
- } /* RLCP */
- else if (cstr_info->prog == RPCL) { /* RPCL */
-
- fprintf(stream, "RPCL\npack_nb tileno resno precno compno layno start_pos end_ph_pos end_pos disto\n");
-
- for (resno = 0; resno < max_numdecompos + 1; resno++) {
- /* I suppose components have same XRsiz, YRsiz */
- int x0 = cstr_info->tile_Ox + tileno - (int)floor((float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
- int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
- int x1 = x0 + cstr_info->tile_x;
- int y1 = y0 + cstr_info->tile_y;
- for (compno = 0; compno < cstr_info->numcomps; compno++) {
- int prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
- if (resno > cstr_info->numdecompos[compno])
- break;
- for (precno = 0; precno < prec_max; precno++) {
- int pcnx = cstr_info->tile[tileno].pw[resno];
- int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
- int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
- int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
- int precno_y = (int) floor( (float)precno/(float)pcnx );
- for(y = y0; y < y1; y++) {
- if (precno_y*pcy == y ) {
- for (x = x0; x < x1; x++) {
- if (precno_x*pcx == x ) {
- for (layno = 0; layno < cstr_info->numlayers; layno++) {
- start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
- end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
- end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
- disto = cstr_info->tile[tileno].packet[pack_nb].disto;
- fprintf(stream, "%4d %6d %5d %6d %6d %7d %9d %9d %7d %8e\n",
- pack_nb, tileno, resno, precno, compno, layno, start_pos, end_ph_pos, end_pos, disto);
- total_disto += disto;
- pack_nb++;
- }
- }
- }/* x = x0..x1 */
- }
- } /* y = y0..y1 */
- } /* precno */
- } /* compno */
- } /* resno */
- } /* RPCL */
- else if (cstr_info->prog == PCRL) { /* PCRL */
- /* I suppose components have same XRsiz, YRsiz */
- int x0 = cstr_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
- int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
- int x1 = x0 + cstr_info->tile_x;
- int y1 = y0 + cstr_info->tile_y;
-
- fprintf(stream, "PCRL\npack_nb tileno precno compno resno layno start_pos end_ph_pos end_pos disto\n");
-
- for (compno = 0; compno < cstr_info->numcomps; compno++) {
- for (resno = 0; resno < cstr_info->numdecompos[compno] + 1; resno++) {
- int prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
- for (precno = 0; precno < prec_max; precno++) {
- int pcnx = cstr_info->tile[tileno].pw[resno];
- int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
- int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
- int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
- int precno_y = (int) floor( (float)precno/(float)pcnx );
- for(y = y0; y < y1; y++) {
- if (precno_y*pcy == y ) {
- for (x = x0; x < x1; x++) {
- if (precno_x*pcx == x ) {
- for (layno = 0; layno < cstr_info->numlayers; layno++) {
- start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
- end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
- end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
- disto = cstr_info->tile[tileno].packet[pack_nb].disto;
- fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d %9d %7d %8e\n",
- pack_nb, tileno, precno, compno, resno, layno, start_pos, end_ph_pos, end_pos, disto);
- total_disto += disto;
- pack_nb++;
- }
- }
- }/* x = x0..x1 */
- }
- } /* y = y0..y1 */
- } /* precno */
- } /* resno */
- } /* compno */
- } /* PCRL */
- else { /* CPRL */
-
- fprintf(stream, "CPRL\npack_nb tileno compno precno resno layno start_pos end_ph_pos end_pos disto\n");
-
- for (compno = 0; compno < cstr_info->numcomps; compno++) {
- /* I suppose components have same XRsiz, YRsiz */
- int x0 = cstr_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
- int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
- int x1 = x0 + cstr_info->tile_x;
- int y1 = y0 + cstr_info->tile_y;
-
- for (resno = 0; resno < cstr_info->numdecompos[compno] + 1; resno++) {
- int prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
- for (precno = 0; precno < prec_max; precno++) {
- int pcnx = cstr_info->tile[tileno].pw[resno];
- int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
- int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
- int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
- int precno_y = (int) floor( (float)precno/(float)pcnx );
- for(y = y0; y < y1; y++) {
- if (precno_y*pcy == y ) {
- for (x = x0; x < x1; x++) {
- if (precno_x*pcx == x ) {
- for (layno = 0; layno < cstr_info->numlayers; layno++) {
- start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
- end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
- end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
- disto = cstr_info->tile[tileno].packet[pack_nb].disto;
- fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d %9d %7d %8e\n",
- pack_nb, tileno, compno, precno, resno, layno, start_pos, end_ph_pos, end_pos, disto);
- total_disto += disto;
- pack_nb++;
- }
- }
- }/* x = x0..x1 */
- }
- } /* y = y0..y1 */
- } /* precno */
- } /* resno */
- } /* compno */
- } /* CPRL */
- } /* tileno */
-
- fprintf(stream, "%8e\n", cstr_info->D_max); /* SE max */
- fprintf(stream, "%.8e\n", total_disto); /* SE totale */
-/* UniPG>> */
- /* print the markers' list */
- fprintf(stream, "\nMARKER LIST\n");
- fprintf(stream, "%d\n", cstr_info->marknum);
- fprintf(stream, "type\tstart_pos length\n");
- for (x = 0; x < cstr_info->marknum; x++)
- fprintf(stream, "%X\t%9d %9d\n", cstr_info->marker[x].type, cstr_info->marker[x].pos, cstr_info->marker[x].len);
-/* <<UniPG */
- fclose(stream);
-
- fprintf(stderr,"Generated index file %s\n", index);
-
- return 0;
-}
-
-/* ------------------------------------------------------------------------------------ */
-
int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
img_fol_t *img_fol, raw_cparameters_t *raw_cp, char *indexfilename) {
int i, j,totlen;
diff --git a/codec/image_to_j2k.sln b/codec/image_to_j2k.sln
index 196e53c6..de773c8d 100644
--- a/codec/image_to_j2k.sln
+++ b/codec/image_to_j2k.sln
Binary files differ
diff --git a/codec/image_to_j2k.vcproj b/codec/image_to_j2k.vcproj
index f98df893..8968eb4b 100644
--- a/codec/image_to_j2k.vcproj
+++ b/codec/image_to_j2k.vcproj
@@ -278,6 +278,14 @@
/>
</FileConfiguration>
</File>
+ <File
+ RelativePath=".\index.c"
+ >
+ </File>
+ <File
+ RelativePath=".\index.h"
+ >
+ </File>
</Files>
<Globals>
</Globals>
diff --git a/codec/index.c b/codec/index.c
new file mode 100644
index 00000000..985c18a0
--- /dev/null
+++ b/codec/index.c
@@ -0,0 +1,390 @@
+/*
+ * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2007, Professor Benoit Macq
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * 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
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <math.h>
+#include "openjpeg.h"
+#include "index.h"
+
+/* ------------------------------------------------------------------------------------ */
+
+/**
+Write a structured index to a file
+@param cstr_info Codestream information
+@param index Index filename
+@return Returns 0 if successful, returns 1 otherwise
+*/
+int write_index_file(opj_codestream_info_t *cstr_info, char *index) {
+ int tileno, compno, layno, resno, precno, pack_nb, x, y;
+ FILE *stream = NULL;
+ double total_disto = 0;
+/* UniPG>> */
+ int tilepartno;
+ char disto_on, numpix_on;
+
+#ifdef USE_JPWL
+ if (!strcmp(index, JPWL_PRIVATEINDEX_NAME))
+ return 0;
+#endif /* USE_JPWL */
+/* <<UniPG */
+
+ if (!cstr_info)
+ return 1;
+
+ stream = fopen(index, "w");
+ if (!stream) {
+ fprintf(stderr, "failed to open index file [%s] for writing\n", index);
+ return 1;
+ }
+
+ if (cstr_info->tile[0].distotile)
+ disto_on = 1;
+ else
+ disto_on = 0;
+
+ if (cstr_info->tile[0].numpix)
+ numpix_on = 1;
+ else
+ numpix_on = 0;
+
+ fprintf(stream, "%d %d\n", cstr_info->image_w, cstr_info->image_h);
+ fprintf(stream, "%d\n", cstr_info->prog);
+ fprintf(stream, "%d %d\n", cstr_info->tile_x, cstr_info->tile_y);
+ fprintf(stream, "%d %d\n", cstr_info->tw, cstr_info->th);
+ fprintf(stream, "%d\n", cstr_info->numcomps);
+ fprintf(stream, "%d\n", cstr_info->numlayers);
+ fprintf(stream, "%d\n", cstr_info->numdecompos);
+
+ for (resno = cstr_info->numdecompos[0]; resno >= 0; resno--) {
+ fprintf(stream, "[%d,%d] ",
+ (1 << cstr_info->tile[0].pdx[resno]), (1 << cstr_info->tile[0].pdx[resno])); /* based on tile 0 and component 0 */
+ }
+
+ fprintf(stream, "\n");
+/* UniPG>> */
+ fprintf(stream, "%d\n", cstr_info->main_head_start);
+/* <<UniPG */
+ fprintf(stream, "%d\n", cstr_info->main_head_end);
+ fprintf(stream, "%d\n", cstr_info->codestream_size);
+
+ fprintf(stream, "\nINFO ON TILES\n");
+ fprintf(stream, "tileno start_pos end_hd end_tile nbparts");
+ if (disto_on)
+ fprintf(stream," disto");
+ if (numpix_on)
+ fprintf(stream," nbpix");
+ if (disto_on && numpix_on)
+ fprintf(stream," disto/nbpix");
+ fprintf(stream, "\n");
+
+ for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
+ fprintf(stream, "%4d %9d %9d %9d %9d",
+ cstr_info->tile[tileno].tileno,
+ cstr_info->tile[tileno].start_pos,
+ cstr_info->tile[tileno].end_header,
+ cstr_info->tile[tileno].end_pos,
+ cstr_info->tile[tileno].num_tps);
+ if (disto_on)
+ fprintf(stream," %9e", cstr_info->tile[tileno].distotile);
+ if (numpix_on)
+ fprintf(stream," %9d", cstr_info->tile[tileno].numpix);
+ if (disto_on && numpix_on)
+ fprintf(stream," %9e", cstr_info->tile[tileno].distotile / cstr_info->tile[tileno].numpix);
+ fprintf(stream, "\n");
+ }
+
+ for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
+ int start_pos, end_ph_pos, end_pos;
+ double disto = 0;
+ int max_numdecompos = 0;
+ pack_nb = 0;
+
+ for (compno = 0; compno < cstr_info->numcomps; compno++) {
+ if (max_numdecompos < cstr_info->numdecompos[compno])
+ max_numdecompos = cstr_info->numdecompos[compno];
+ }
+
+ fprintf(stream, "\nTILE %d DETAILS\n", tileno);
+ fprintf(stream, "part_nb tileno start_pack num_packs start_pos end_tph_pos end_pos\n");
+ for (tilepartno = 0; tilepartno < cstr_info->tile[tileno].num_tps; tilepartno++)
+ fprintf(stream, "%4d %9d %9d %9d %9d %11d %9d\n",
+ tilepartno, tileno,
+ cstr_info->tile[tileno].tp[tilepartno].tp_start_pack,
+ cstr_info->tile[tileno].tp[tilepartno].tp_numpacks,
+ cstr_info->tile[tileno].tp[tilepartno].tp_start_pos,
+ cstr_info->tile[tileno].tp[tilepartno].tp_end_header,
+ cstr_info->tile[tileno].tp[tilepartno].tp_end_pos
+ );
+
+ if (cstr_info->prog == LRCP) { /* LRCP */
+ fprintf(stream, "LRCP\npack_nb tileno layno resno compno precno start_pos end_ph_pos end_pos");
+ if (disto_on)
+ fprintf(stream, " disto");
+ fprintf(stream,"\n");
+
+ for (layno = 0; layno < cstr_info->numlayers; layno++) {
+ for (resno = 0; resno < max_numdecompos + 1; resno++) {
+ for (compno = 0; compno < cstr_info->numcomps; compno++) {
+ int prec_max;
+ if (resno > cstr_info->numdecompos[compno])
+ break;
+ prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
+ for (precno = 0; precno < prec_max; precno++) {
+ start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
+ end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
+ end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
+ disto = cstr_info->tile[tileno].packet[pack_nb].disto;
+ fprintf(stream, "%4d %6d %7d %5d %6d %6d %6d %6d %7d",
+ pack_nb, tileno, layno, resno, compno, precno, start_pos, end_ph_pos, end_pos);
+ if (disto_on)
+ fprintf(stream, " %8e", disto);
+ fprintf(stream, "\n");
+ total_disto += disto;
+ pack_nb++;
+ }
+ }
+ }
+ }
+ } /* LRCP */
+
+ else if (cstr_info->prog == RLCP) { /* RLCP */
+ fprintf(stream, "RLCP\npack_nb tileno resno layno compno precno start_pos end_ph_pos end_pos\n");
+ if (disto_on)
+ fprintf(stream, " disto");
+ fprintf(stream,"\n");
+
+ for (resno = 0; resno < max_numdecompos + 1; resno++) {
+ for (layno = 0; layno < cstr_info->numlayers; layno++) {
+ for (compno = 0; compno < cstr_info->numcomps; compno++) {
+ int prec_max;
+ if (resno > cstr_info->numdecompos[compno])
+ break;
+ prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
+ for (precno = 0; precno < prec_max; precno++) {
+ start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
+ end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
+ end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
+ disto = cstr_info->tile[tileno].packet[pack_nb].disto;
+ fprintf(stream, "%4d %6d %5d %7d %6d %6d %9d %9d %7d",
+ pack_nb, tileno, resno, layno, compno, precno, start_pos, end_ph_pos, end_pos);
+ if (disto_on)
+ fprintf(stream, " %8e", disto);
+ fprintf(stream, "\n");
+ total_disto += disto;
+ pack_nb++;
+ }
+ }
+ }
+ }
+ } /* RLCP */
+
+ else if (cstr_info->prog == RPCL) { /* RPCL */
+
+ fprintf(stream, "RPCL\npack_nb tileno resno precno compno layno start_pos end_ph_pos end_pos");
+ if (disto_on)
+ fprintf(stream, " disto");
+ fprintf(stream,"\n");
+
+ for (resno = 0; resno < max_numdecompos + 1; resno++) {
+ int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
+ for (precno = 0; precno < numprec; precno++) {
+ /* I suppose components have same XRsiz, YRsiz */
+ int x0 = cstr_info->tile_Ox + tileno - (int)floor((float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
+ int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
+ int x1 = x0 + cstr_info->tile_x;
+ int y1 = y0 + cstr_info->tile_y;
+ for (compno = 0; compno < cstr_info->numcomps; compno++) {
+ int pcnx = cstr_info->tile[tileno].pw[resno];
+ int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
+ int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
+ int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
+ int precno_y = (int) floor( (float)precno/(float)pcnx );
+ if (resno > cstr_info->numdecompos[compno])
+ break;
+ for(y = y0; y < y1; y++) {
+ if (precno_y*pcy == y ) {
+ for (x = x0; x < x1; x++) {
+ if (precno_x*pcx == x ) {
+ for (layno = 0; layno < cstr_info->numlayers; layno++) {
+ start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
+ end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
+ end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
+ disto = cstr_info->tile[tileno].packet[pack_nb].disto;
+ fprintf(stream, "%4d %6d %5d %6d %6d %7d %9d %9d %7d",
+ pack_nb, tileno, resno, precno, compno, layno, start_pos, end_ph_pos, end_pos);
+ if (disto_on)
+ fprintf(stream, " %8e", disto);
+ fprintf(stream, "\n");
+ total_disto += disto;
+ pack_nb++;
+ }
+ }
+ }/* x = x0..x1 */
+ }
+ } /* y = y0..y1 */
+ } /* precno */
+ } /* compno */
+ } /* resno */
+ } /* RPCL */
+
+ else if (cstr_info->prog == PCRL) { /* PCRL */
+ /* I suppose components have same XRsiz, YRsiz */
+ int x0 = cstr_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
+ int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
+ int x1 = x0 + cstr_info->tile_x;
+ int y1 = y0 + cstr_info->tile_y;
+
+ // Count the maximum number of precincts
+ int max_numprec = 0;
+ for (resno = 0; resno < max_numdecompos + 1; resno++) {
+ int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
+ if (numprec > max_numprec)
+ max_numprec = numprec;
+ }
+
+ fprintf(stream, "PCRL\npack_nb tileno precno compno resno layno start_pos end_ph_pos end_pos");
+ if (disto_on)
+ fprintf(stream, " disto");
+ fprintf(stream,"\n");
+
+ for (precno = 0; precno < max_numprec; precno++) {
+ for (compno = 0; compno < cstr_info->numcomps; compno++) {
+ for (resno = 0; resno < cstr_info->numdecompos[compno] + 1; resno++) {
+ int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
+ int pcnx = cstr_info->tile[tileno].pw[resno];
+ int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
+ int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
+ int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
+ int precno_y = (int) floor( (float)precno/(float)pcnx );
+ if (precno >= numprec)
+ continue;
+ for(y = y0; y < y1; y++) {
+ if (precno_y*pcy == y ) {
+ for (x = x0; x < x1; x++) {
+ if (precno_x*pcx == x ) {
+ for (layno = 0; layno < cstr_info->numlayers; layno++) {
+ start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
+ end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
+ end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
+ disto = cstr_info->tile[tileno].packet[pack_nb].disto;
+ fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d %9d %7d",
+ pack_nb, tileno, precno, compno, resno, layno, start_pos, end_ph_pos, end_pos);
+ if (disto_on)
+ fprintf(stream, " %8e", disto);
+ fprintf(stream, "\n");
+ total_disto += disto;
+ pack_nb++;
+ }
+ }
+ }/* x = x0..x1 */
+ }
+ } /* y = y0..y1 */
+ } /* resno */
+ } /* compno */
+ } /* precno */
+ } /* PCRL */
+
+ else { /* CPRL */
+ // Count the maximum number of precincts
+ int max_numprec = 0;
+ for (resno = 0; resno < max_numdecompos + 1; resno++) {
+ int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
+ if (numprec > max_numprec)
+ max_numprec = numprec;
+ }
+
+ fprintf(stream, "CPRL\npack_nb tileno compno precno resno layno start_pos end_ph_pos end_pos");
+ if (disto_on)
+ fprintf(stream, " disto");
+ fprintf(stream,"\n");
+
+ for (compno = 0; compno < cstr_info->numcomps; compno++) {
+ /* I suppose components have same XRsiz, YRsiz */
+ int x0 = cstr_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
+ int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
+ int x1 = x0 + cstr_info->tile_x;
+ int y1 = y0 + cstr_info->tile_y;
+
+ for (precno = 0; precno < max_numprec; precno++) {
+ for (resno = 0; resno < cstr_info->numdecompos[compno] + 1; resno++) {
+ int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
+ int pcnx = cstr_info->tile[tileno].pw[resno];
+ int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
+ int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
+ int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
+ int precno_y = (int) floor( (float)precno/(float)pcnx );
+ if (precno >= numprec)
+ continue;
+
+ for(y = y0; y < y1; y++) {
+ if (precno_y*pcy == y ) {
+ for (x = x0; x < x1; x++) {
+ if (precno_x*pcx == x ) {
+ for (layno = 0; layno < cstr_info->numlayers; layno++) {
+ start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
+ end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
+ end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
+ disto = cstr_info->tile[tileno].packet[pack_nb].disto;
+ fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d %9d %7d",
+ pack_nb, tileno, compno, precno, resno, layno, start_pos, end_ph_pos, end_pos);
+ if (disto_on)
+ fprintf(stream, " %8e", disto);
+ fprintf(stream, "\n");
+ total_disto += disto;
+ pack_nb++;
+ }
+ }
+ }/* x = x0..x1 */
+ }
+ } /* y = y0..y1 */
+ } /* resno */
+ } /* precno */
+ } /* compno */
+ } /* CPRL */
+ } /* tileno */
+
+ if (disto_on) {
+ fprintf(stream, "%8e\n", cstr_info->D_max); /* SE max */
+ fprintf(stream, "%.8e\n", total_disto); /* SE totale */
+ }
+/* UniPG>> */
+ /* print the markers' list */
+ if (cstr_info->marknum) {
+ fprintf(stream, "\nMARKER LIST\n");
+ fprintf(stream, "%d\n", cstr_info->marknum);
+ fprintf(stream, "type\tstart_pos length\n");
+ for (x = 0; x < cstr_info->marknum; x++)
+ fprintf(stream, "%X\t%9d %9d\n", cstr_info->marker[x].type, cstr_info->marker[x].pos, cstr_info->marker[x].len);
+ }
+/* <<UniPG */
+ fclose(stream);
+
+ fprintf(stderr,"Generated index file %s\n", index);
+
+ return 0;
+}
diff --git a/codec/index.h b/codec/index.h
new file mode 100644
index 00000000..aed61e62
--- /dev/null
+++ b/codec/index.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2007, Professor Benoit Macq
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * 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
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __J2K_INDEX_H
+#define __J2K_INDEX_H
+
+/**
+Write a structured index to a file
+@param cstr_info Codestream information
+@param index Index filename
+@return Returns 0 if successful, returns 1 otherwise
+*/
+int write_index_file(opj_codestream_info_t *cstr_info, char *index);
+
+#endif /* __J2K_INDEX_H */
+
diff --git a/codec/j2k_to_image.c b/codec/j2k_to_image.c
index f265894e..feee30a0 100644
--- a/codec/j2k_to_image.c
+++ b/codec/j2k_to_image.c
@@ -38,6 +38,7 @@
#include "compat/getopt.h"
#include "convert.h"
#include "dirent.h"
+#include "index.h"
#ifndef WIN32
#define stricmp strcasecmp
@@ -229,250 +230,6 @@ char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparamet
return 0;
}
-/* ------------------------------------------------------------------------------------ */
-
-/**
-Create an index and write it to a file
-@param cstr_info Codestream information
-@param index Index filename
-@return Returns 0 if successful, returns 1 otherwise
-*/
-int write_index_file(opj_codestream_info_t *cstr_info, char *index) {
- int tileno, compno, layno, resno, precno, pack_nb, x, y;
- FILE *stream = NULL;
- int tilepartno;
-
- if (!cstr_info)
- return 1;
-
- stream = fopen(index, "w");
- if (!stream) {
- fprintf(stderr, "failed to open index file [%s] for writing\n", index);
- return 1;
- }
-
- fprintf(stream, "%d %d\n", cstr_info->image_w, cstr_info->image_h);
- fprintf(stream, "%d\n", cstr_info->prog);
- fprintf(stream, "%d %d\n", cstr_info->tile_x, cstr_info->tile_y);
- fprintf(stream, "%d %d\n", cstr_info->tw, cstr_info->th);
- fprintf(stream, "%d\n", cstr_info->numcomps);
- fprintf(stream, "%d\n", cstr_info->numlayers);
- fprintf(stream, "%d\n", cstr_info->numdecompos);
-
- for (resno = cstr_info->numdecompos[0]; resno >= 0; resno--) {
- fprintf(stream, "[%d,%d] ",
- (1 << cstr_info->tile[0].pdx[resno]), (1 << cstr_info->tile[0].pdx[resno])); /* based on tile 0 and component 0*/
- }
- fprintf(stream, "\n");
- fprintf(stream, "%d\n", cstr_info->main_head_start);
- fprintf(stream, "%d\n", cstr_info->main_head_end);
- fprintf(stream, "%d\n", cstr_info->codestream_size);
-
- fprintf(stream, "\nINFO ON TILES\n");
- fprintf(stream, "tileno start_pos end_hd end_tile nbparts\n");
- for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
- fprintf(stream, "%4d %9d %9d %9d %9d\n",
- cstr_info->tile[tileno].tileno,
- cstr_info->tile[tileno].start_pos,
- cstr_info->tile[tileno].end_header,
- cstr_info->tile[tileno].end_pos,
- cstr_info->tile[tileno].num_tps);
- }
-
- for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
- int start_pos, end_ph_pos, end_pos;
- int max_numdecompos = 0;
- pack_nb = 0;
-
- for (compno = 0; compno < cstr_info->numcomps; compno++) {
- if (max_numdecompos < cstr_info->numdecompos[compno])
- max_numdecompos = cstr_info->numdecompos[compno];
- }
-
- fprintf(stream, "\nTILE %d DETAILS\n", tileno);
- fprintf(stream, "part_nb tileno num_packs start_pos end_tph_pos end_pos\n");
- for (tilepartno = 0; tilepartno < cstr_info->tile[tileno].num_tps; tilepartno++)
- fprintf(stream, "%4d %9d %9d %9d %11d %9d\n",
- tilepartno, tileno,
- cstr_info->tile[tileno].tp[tilepartno].tp_numpacks,
- cstr_info->tile[tileno].tp[tilepartno].tp_start_pos,
- cstr_info->tile[tileno].tp[tilepartno].tp_end_header,
- cstr_info->tile[tileno].tp[tilepartno].tp_end_pos
- );
- if (cstr_info->prog == LRCP) { /* LRCP */
- fprintf(stream, "LRCP\npack_nb tileno layno resno compno precno start_pos end_ph_pos end_pos\n");
-
- for (layno = 0; layno < cstr_info->numlayers; layno++) {
- for (resno = 0; resno < max_numdecompos + 1; resno++) {
- for (compno = 0; compno < cstr_info->numcomps; compno++) {
- int prec_max;
- if (resno > cstr_info->numdecompos[compno])
- break;
- prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
- for (precno = 0; precno < prec_max; precno++) {
- start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
- end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
- end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
- fprintf(stream, "%4d %6d %7d %5d %6d %6d %6d %6d %7d\n",
- pack_nb, tileno, layno, resno, compno, precno, start_pos, end_ph_pos, end_pos);
- pack_nb++;
- }
- }
- }
- }
- } /* LRCP */
- else if (cstr_info->prog == RLCP) { /* RLCP */
-
- fprintf(stream, "RLCP\npack_nb tileno resno layno compno precno start_pos end_ph_pos end_pos\n");
-
- for (resno = 0; resno < max_numdecompos + 1; resno++) {
- for (layno = 0; layno < cstr_info->numlayers; layno++) {
- for (compno = 0; compno < cstr_info->numcomps; compno++) {
- int prec_max;
- if (resno > cstr_info->numdecompos[compno])
- break;
- prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
- for (precno = 0; precno < prec_max; precno++) {
- start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
- end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
- end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
- fprintf(stream, "%4d %6d %5d %7d %6d %6d %9d %9d %7d\n",
- pack_nb, tileno, resno, layno, compno, precno, start_pos, end_ph_pos, end_pos);
- pack_nb++;
- }
- }
- }
- }
- } /* RLCP */
- else if (cstr_info->prog == RPCL) { /* RPCL */
-
- fprintf(stream, "RPCL\npack_nb tileno resno precno compno layno start_pos end_ph_pos end_pos\n");
-
- for (resno = 0; resno < max_numdecompos + 1; resno++) {
- /* I suppose components have same XRsiz, YRsiz */
- int x0 = cstr_info->tile_Ox + tileno - (int)floor((float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
- int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
- int x1 = x0 + cstr_info->tile_x;
- int y1 = y0 + cstr_info->tile_y;
- for (compno = 0; compno < cstr_info->numcomps; compno++) {
- int prec_max;
- if (resno > cstr_info->numdecompos[compno])
- break;
- prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
- for (precno = 0; precno < prec_max; precno++) {
- int pcnx = cstr_info->tile[tileno].pw[resno];
- int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
- int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
- int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
- int precno_y = (int) floor( (float)precno/(float)pcnx );
- for(y = y0; y < y1; y++) {
- if (precno_y*pcy == y ) {
- for (x = x0; x < x1; x++) {
- if (precno_x*pcx == x ) {
- for (layno = 0; layno < cstr_info->numlayers; layno++) {
- start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
- end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
- end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
- fprintf(stream, "%4d %6d %5d %6d %6d %7d %9d %9d %7d\n",
- pack_nb, tileno, resno, precno, compno, layno, start_pos, end_ph_pos, end_pos);
- pack_nb++;
- }
- }
- }/* x = x0..x1 */
- }
- } /* y = y0..y1 */
- } /* precno */
- } /* compno */
- } /* resno */
- } /* RPCL */
- else if (cstr_info->prog == PCRL) { /* PCRL */
- /* I suppose components have same XRsiz, YRsiz */
- int x0 = cstr_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
- int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
- int x1 = x0 + cstr_info->tile_x;
- int y1 = y0 + cstr_info->tile_y;
-
- fprintf(stream, "PCRL\npack_nb tileno precno compno resno layno start_pos end_ph_pos end_pos\n");
-
- for (compno = 0; compno < cstr_info->numcomps; compno++) {
- for (resno = 0; resno < cstr_info->numdecompos[compno] + 1; resno++) {
- int prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
- for (precno = 0; precno < prec_max; precno++) {
- int pcnx = cstr_info->tile[tileno].pw[resno];
- int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
- int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
- int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
- int precno_y = (int) floor( (float)precno/(float)pcnx );
- for(y = y0; y < y1; y++) {
- if (precno_y*pcy == y ) {
- for (x = x0; x < x1; x++) {
- if (precno_x*pcx == x ) {
- for (layno = 0; layno < cstr_info->numlayers; layno++) {
- start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
- end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
- end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
- fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d %9d %7d\n",
- pack_nb, tileno, precno, compno, resno, layno, start_pos, end_ph_pos, end_pos);
- pack_nb++;
- }
- }
- }/* x = x0..x1 */
- }
- } /* y = y0..y1 */
- } /* precno */
- } /* resno */
- } /* compno */
- } /* PCRL */
- else { /* CPRL */
-
- fprintf(stream, "CPRL\npack_nb tileno compno precno resno layno start_pos end_ph_pos end_pos\n");
-
- for (compno = 0; compno < cstr_info->numcomps; compno++) {
- /* I suppose components have same XRsiz, YRsiz */
- int x0 = cstr_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
- int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
- int x1 = x0 + cstr_info->tile_x;
- int y1 = y0 + cstr_info->tile_y;
-
- for (resno = 0; resno < cstr_info->numdecompos[compno] + 1; resno++) {
- int prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
- for (precno = 0; precno < prec_max; precno++) {
- int pcnx = cstr_info->tile[tileno].pw[resno];
- int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
- int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
- int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
- int precno_y = (int) floor( (float)precno/(float)pcnx );
- for(y = y0; y < y1; y++) {
- if (precno_y*pcy == y ) {
- for (x = x0; x < x1; x++) {
- if (precno_x*pcx == x ) {
- for (layno = 0; layno < cstr_info->numlayers; layno++) {
- start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
- end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
- end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
- fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d %9d %7d\n",
- pack_nb, tileno, compno, precno, resno, layno, start_pos, end_ph_pos, end_pos);
- pack_nb++;
- }
- }
- }/* x = x0..x1 */
- }
- } /* y = y0..y1 */
- } /* precno */
- } /* resno */
- } /* compno */
- } /* CPRL */
- } /* tileno */
-
- fclose(stream);
-
- fprintf(stderr,"Generated index file %s\n", index);
-
- return 0;
-}
-
-/* ------------------------------------------------------------------------------------ */
-
/* -------------------------------------------------------------------------- */
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol, char *indexfilename) {
/* parse the command line */
diff --git a/codec/j2k_to_image.vcproj b/codec/j2k_to_image.vcproj
index eef2ae33..efed8858 100644
--- a/codec/j2k_to_image.vcproj
+++ b/codec/j2k_to_image.vcproj
@@ -256,6 +256,14 @@
>
</File>
<File
+ RelativePath=".\index.c"
+ >
+ </File>
+ <File
+ RelativePath=".\index.h"
+ >
+ </File>
+ <File
RelativePath="j2k_to_image.c"
>
<FileConfiguration