From d72886826392731a5d7bf203e2a2ba2e35b6610b Mon Sep 17 00:00:00 2001 From: Antonin Descampe Date: Mon, 10 Oct 2011 09:58:37 +0000 Subject: [PATCH] [1.5][JPIP]removed obsolete indexer utility --- applications/jpip/CHANGES | 1 + applications/jpip/tools/CMakeLists.txt | 4 +- applications/jpip/tools/Makefile.am | 2 - applications/jpip/tools/Makefile.nix | 5 +- .../jpip/tools/indexer/CMakeLists.txt | 32 -- applications/jpip/tools/indexer/Makefile.am | 32 -- applications/jpip/tools/indexer/Makefile.nix | 14 - .../jpip/tools/indexer/cidx_manager.c | 213 ------------ .../jpip/tools/indexer/cidx_manager.h | 56 ---- applications/jpip/tools/indexer/cio_ext.c | 62 ---- applications/jpip/tools/indexer/cio_ext.h | 52 --- .../jpip/tools/indexer/event_mgr_handler.c | 72 ----- .../jpip/tools/indexer/event_mgr_handler.h | 43 --- .../jpip/tools/indexer/idxjp2_manager.c | 306 ------------------ .../jpip/tools/indexer/indexbox_manager.h | 115 ------- applications/jpip/tools/indexer/j2k_decoder.c | 157 --------- .../jpip/tools/indexer/j2k_to_idxjp2.c | 108 ------- .../jpip/tools/indexer/j2k_to_idxjp2.h | 58 ---- .../jpip/tools/indexer/phix_manager.c | 142 -------- .../jpip/tools/indexer/ppix_manager.c | 147 --------- .../jpip/tools/indexer/thix_manager.c | 208 ------------ .../jpip/tools/indexer/tpix_manager.c | 154 --------- 22 files changed, 3 insertions(+), 1980 deletions(-) delete mode 100644 applications/jpip/tools/indexer/CMakeLists.txt delete mode 100644 applications/jpip/tools/indexer/Makefile.am delete mode 100644 applications/jpip/tools/indexer/Makefile.nix delete mode 100644 applications/jpip/tools/indexer/cidx_manager.c delete mode 100644 applications/jpip/tools/indexer/cidx_manager.h delete mode 100644 applications/jpip/tools/indexer/cio_ext.c delete mode 100644 applications/jpip/tools/indexer/cio_ext.h delete mode 100644 applications/jpip/tools/indexer/event_mgr_handler.c delete mode 100644 applications/jpip/tools/indexer/event_mgr_handler.h delete mode 100644 applications/jpip/tools/indexer/idxjp2_manager.c delete mode 100644 applications/jpip/tools/indexer/indexbox_manager.h delete mode 100644 applications/jpip/tools/indexer/j2k_decoder.c delete mode 100644 applications/jpip/tools/indexer/j2k_to_idxjp2.c delete mode 100644 applications/jpip/tools/indexer/j2k_to_idxjp2.h delete mode 100644 applications/jpip/tools/indexer/phix_manager.c delete mode 100644 applications/jpip/tools/indexer/ppix_manager.c delete mode 100644 applications/jpip/tools/indexer/thix_manager.c delete mode 100644 applications/jpip/tools/indexer/tpix_manager.c diff --git a/applications/jpip/CHANGES b/applications/jpip/CHANGES index 4b6d1cc9..b86a3451 100644 --- a/applications/jpip/CHANGES +++ b/applications/jpip/CHANGES @@ -6,6 +6,7 @@ What's New for OpenJPIP + : added October 10, 2011 +- [antonin] removed obsolete indexer utility + [antonin] enabled JPP-stream September 16, 2011 diff --git a/applications/jpip/tools/CMakeLists.txt b/applications/jpip/tools/CMakeLists.txt index 04411622..c04928d7 100644 --- a/applications/jpip/tools/CMakeLists.txt +++ b/applications/jpip/tools/CMakeLists.txt @@ -1,6 +1,4 @@ -ADD_SUBDIRECTORY(indexer) - INCLUDE_DIRECTORIES( ../libopenjpip ) @@ -36,4 +34,4 @@ ENDIF(UNIX) INSTALL(TARGETS test_index EXPORT OpenJPEGTargets DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications -) \ No newline at end of file +) diff --git a/applications/jpip/tools/Makefile.am b/applications/jpip/tools/Makefile.am index f67ad0f1..b9959723 100644 --- a/applications/jpip/tools/Makefile.am +++ b/applications/jpip/tools/Makefile.am @@ -1,7 +1,5 @@ MAINTAINERCLEANFILES = Makefile.in -SUBDIRS = indexer - bin_PROGRAMS = jpip_to_jp2 jpip_to_j2k test_index addXMLinJP2 jpip_to_jp2_CPPFLAGS = \ diff --git a/applications/jpip/tools/Makefile.nix b/applications/jpip/tools/Makefile.nix index 474854df..707f3f9e 100644 --- a/applications/jpip/tools/Makefile.nix +++ b/applications/jpip/tools/Makefile.nix @@ -5,10 +5,7 @@ LDFLAGS = -L$(LIBDIR) -lm -lopenjpip_local ALL = jpip_to_jp2 jpip_to_j2k test_index addXMLinJP2 -all: t_indexer $(ALL) - -t_indexer: - make -C indexer -f Makefile.nix +all: $(ALL) jpip_to_jp2: jpip_to_jp2.o $(LIBFNAME) $(CC) $(CFLAGS) $< $(LDFLAGS) -o $@ diff --git a/applications/jpip/tools/indexer/CMakeLists.txt b/applications/jpip/tools/indexer/CMakeLists.txt deleted file mode 100644 index b1b34b70..00000000 --- a/applications/jpip/tools/indexer/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -SET(INDEXER_SRCS -${CMAKE_CURRENT_SOURCE_DIR}/j2k_to_idxjp2.c -${CMAKE_CURRENT_SOURCE_DIR}/cidx_manager.c -${CMAKE_CURRENT_SOURCE_DIR}/cio_ext.c -${CMAKE_CURRENT_SOURCE_DIR}/event_mgr_handler.c -${CMAKE_CURRENT_SOURCE_DIR}/idxjp2_manager.c -${CMAKE_CURRENT_SOURCE_DIR}/j2k_decoder.c -${CMAKE_CURRENT_SOURCE_DIR}/phix_manager.c -${CMAKE_CURRENT_SOURCE_DIR}/ppix_manager.c -${CMAKE_CURRENT_SOURCE_DIR}/thix_manager.c -${CMAKE_CURRENT_SOURCE_DIR}/tpix_manager.c -) - -# Headers file are located here: -INCLUDE_DIRECTORIES( - ${OPENJPEG_SOURCE_DIR}/libopenjpeg - ) - -# Build executable - -ADD_EXECUTABLE(j2k_to_idxjp2 ${INDEXER_SRCS}) -TARGET_LINK_LIBRARIES(j2k_to_idxjp2 ${OPENJPEG_LIBRARY_NAME}) - -# On unix you need to link to the math library: -IF(UNIX) - TARGET_LINK_LIBRARIES(j2k_to_idxjp2 m) -ENDIF(UNIX) -# Install exe -INSTALL(TARGETS j2k_to_idxjp2 - EXPORT OpenJPEGTargets - DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications -) diff --git a/applications/jpip/tools/indexer/Makefile.am b/applications/jpip/tools/indexer/Makefile.am deleted file mode 100644 index efcb83b2..00000000 --- a/applications/jpip/tools/indexer/Makefile.am +++ /dev/null @@ -1,32 +0,0 @@ -MAINTAINERCLEANFILES = Makefile.in - -bin_PROGRAMS = j2k_to_idxjp2 - -j2k_to_idxjp2_CPPFLAGS = \ --I. \ --I$(top_srcdir)/applications/libopenjpip/tools/indexer \ --I$(top_builddir)/applications/libopenjpip/tools/indexer \ --I$(top_srcdir)/libopenjpeg \ --I$(top_builddir)/libopenjpeg -j2k_to_idxjp2_CFLAGS = -j2k_to_idxjp2_LDADD = $(top_builddir)/libopenjpeg/libopenjpeg.la -lm -j2k_to_idxjp2_SOURCES = \ -cidx_manager.c \ -cidx_manager.h \ -cio_ext.c \ -cio_ext.h \ -j2k_to_idxjp2.c \ -j2k_to_idxjp2.h \ -event_mgr_handler.c \ -event_mgr_handler.h \ -idxjp2_manager.c \ -j2k_decoder.c \ -indexbox_manager.h \ -phix_manager.c \ -ppix_manager.c \ -thix_manager.c \ -tpix_manager.c - -install-data-hook: - @echo -e " (B)\t$(bindir)/j2k_to_idxjp2$(EXEEXT)" >> $(top_builddir)/report.txt - diff --git a/applications/jpip/tools/indexer/Makefile.nix b/applications/jpip/tools/indexer/Makefile.nix deleted file mode 100644 index 4ea2b8c6..00000000 --- a/applications/jpip/tools/indexer/Makefile.nix +++ /dev/null @@ -1,14 +0,0 @@ -INCDIR = ../../../../libopenjpeg -LIBDIR = $(INCDIR)/.libs -LIBFNAME = $(LIBDIR)/libopenjpeg.a -CFLAGS = -O3 -Wall -I$(INCDIR) -LDFLAGS = -L$(LIBDIR) -lm - -ALL = j2k_to_idxjp2 - -all: $(ALL) - -j2k_to_idxjp2: j2k_to_idxjp2.o event_mgr_handler.o idxjp2_manager.o j2k_decoder.o cidx_manager.o cio_ext.o tpix_manager.o thix_manager.o ppix_manager.o phix_manager.o $(LIBFNAME) - $(CC) $(CFLAGS) $< event_mgr_handler.o idxjp2_manager.o j2k_decoder.o cidx_manager.o cio_ext.o tpix_manager.o thix_manager.o ppix_manager.o phix_manager.o $(LDFLAGS) $(LIBFNAME) -o $@ -clean: - rm -f $(ALL) *.o *~ diff --git a/applications/jpip/tools/indexer/cidx_manager.c b/applications/jpip/tools/indexer/cidx_manager.c deleted file mode 100644 index b8112da5..00000000 --- a/applications/jpip/tools/indexer/cidx_manager.c +++ /dev/null @@ -1,213 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium - * Copyright (c) 2002-2011, Professor Benoit Macq - * Copyright (c) 2003-2004, Yannick Verschueren - * Copyright (c) 2010-2011, Kaori Hagihara - * 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 -#include -#include "cidx_manager.h" -#include "indexbox_manager.h" -#include "cio_ext.h" -#include "cio.h" - - -/* - * Write CPTR Codestream finder box - * - * @param[in] coff offset of j2k codestream - * @param[in] clen length of j2k codestream - * @param[in] cio file output handle - */ -void write_cptr(int coff, int clen, opj_cio_t *cio); - - -/* - * Write main header index table (box) - * - * @param[in] cstr_info codestream information - * @param[in] cio file output handle - * @return length of mainmhix box - */ -int write_mainmhix( opj_codestream_info_t cstr_info, opj_cio_t *cio); - - -/* - * Check if EPH option is used - * - * @param[in] coff offset of j2k codestream - * @param[in] markers marker information - * @param[in] marknum number of markers - * @param[in] cio file output handle - * @return true if EPH is used - */ -opj_bool check_EPHuse( int coff, opj_marker_info_t *markers, int marknum, opj_cio_t *cio); - - -int write_cidx( int offset, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t cstr_info, int j2klen) -{ - int len, i, lenp; - opj_jp2_box_t *box; - int num_box = 0; - opj_bool EPHused; - - box = (opj_jp2_box_t *)calloc( 32, sizeof(opj_jp2_box_t)); - - for (i=0;i<2;i++){ - - if(i) - cio_seek( cio, lenp); - - lenp = cio_tell( cio); - - cio_skip( cio, 4); /* L [at the end] */ - cio_write( cio, JPIP_CIDX, 4); /* CIDX */ - write_cptr( offset, cstr_info.codestream_size, cio); - - write_manf( i, num_box, box, cio); - - num_box = 0; - box[num_box].length = write_mainmhix( cstr_info, cio); - box[num_box].type = JPIP_MHIX; - num_box++; - - box[num_box].length = write_tpix( cstr_info, j2klen, cio); - box[num_box].type = JPIP_TPIX; - num_box++; - - box[num_box].length = write_thix( offset, cstr_info, cio); - box[num_box].type = JPIP_THIX; - num_box++; - - EPHused = check_EPHuse( offset, cstr_info.marker, cstr_info.marknum, cio); - - box[num_box].length = write_ppix( cstr_info, EPHused, j2klen, cio); - box[num_box].type = JPIP_PPIX; - num_box++; - - box[num_box].length = write_phix( cstr_info, EPHused, j2klen, cio); - box[num_box].type = JPIP_PHIX; - num_box++; - - len = cio_tell( cio)-lenp; - cio_seek( cio, lenp); - cio_write( cio, len, 4); /* L */ - cio_seek( cio, lenp+len); - } - - free( box); - - return len; -} - -void write_cptr(int coff, int clen, opj_cio_t *cio) -{ - int len, lenp; - - lenp = cio_tell( cio); - cio_skip( cio, 4); /* L [at the end] */ - cio_write( cio, JPIP_CPTR, 4); /* T */ - cio_write( cio, 0, 2); /* DR A PRECISER !! */ - cio_write( cio, 0, 2); /* CONT */ - cio_ext_write( cio, coff, 8); /* COFF A PRECISER !! */ - cio_ext_write( cio, clen, 8); /* CLEN */ - len = cio_tell( cio) - lenp; - cio_seek( cio, lenp); - cio_write( cio, len, 4); /* L */ - cio_seek( cio, lenp+len); -} - -void write_manf(int second, int v, opj_jp2_box_t *box, opj_cio_t *cio) -{ - int len, lenp, i; - - lenp = cio_tell( cio); - cio_skip( cio, 4); /* L [at the end] */ - cio_write( cio, JPIP_MANF,4); /* T */ - - if (second){ /* Write only during the second pass */ - for( i=0; i> 2) & 1)) - EPHused = OPJ_TRUE; - cio_seek( cio, org_pos); - - break; - } - } - return EPHused; -} diff --git a/applications/jpip/tools/indexer/cidx_manager.h b/applications/jpip/tools/indexer/cidx_manager.h deleted file mode 100644 index f83a9802..00000000 --- a/applications/jpip/tools/indexer/cidx_manager.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium - * Copyright (c) 2002-2011, Professor Benoit Macq - * Copyright (c) 2003-2004, Yannick Verschueren - * Copyright (c) 2010-2011, Kaori Hagihara - * 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. - */ - -/*! \file - * \brief Modification of jpip.h from 2KAN indexer - */ - - -#ifndef CIDX_MANAGER_H_ -# define CIDX_MANAGER_H_ - -#include "openjpeg.h" - - -/* - * Write Codestream index box (superbox) - * - * @param[in] offset offset of j2k codestream - * @param[in] cio file output handle - * @param[in] image image data - * @param[in] cstr_info codestream information - * @param[in] j2klen length of j2k codestream - * @return length of cidx box - */ -int write_cidx( int offset, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t cstr_info, int j2klen); - - -#endif /* !CIDX_MANAGER_H_ */ diff --git a/applications/jpip/tools/indexer/cio_ext.c b/applications/jpip/tools/indexer/cio_ext.c deleted file mode 100644 index d507cc9f..00000000 --- a/applications/jpip/tools/indexer/cio_ext.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium - * Copyright (c) 2002-2011, Professor Benoit Macq - * Copyright (c) 2001-2003, David Janssens - * Copyright (c) 2002-2003, Yannick Verschueren - * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe - * Copyright (c) 2005, Herve Drolon, FreeImage Team - * Copyright (c) 2010-2011, Kaori Hagihara - * 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 "cio_ext.h" -#include "event.h" - - -/* - * Write a byte. - */ -opj_bool cio_ext_byteout(opj_cio_t *cio, unsigned char v); - -unsigned int cio_ext_write( opj_cio_t *cio, unsigned long long int v, int n) -{ - int i; - for (i = n - 1; i >= 0; i--) { - if( !cio_ext_byteout(cio, (unsigned char) ((v >> (i << 3)) & 0xff)) ) - return 0; - } - return n; -} - -opj_bool cio_ext_byteout(opj_cio_t *cio, unsigned char v) -{ - if (cio->bp >= cio->end) { - opj_event_msg(cio->cinfo, EVT_ERROR, "write error\n"); - return OPJ_FALSE; - } - *cio->bp++ = v; - return OPJ_TRUE; -} diff --git a/applications/jpip/tools/indexer/cio_ext.h b/applications/jpip/tools/indexer/cio_ext.h deleted file mode 100644 index 42f138df..00000000 --- a/applications/jpip/tools/indexer/cio_ext.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium - * Copyright (c) 2002-2011, Professor Benoit Macq - * Copyright (c) 2010-2011, Kaori Hagihara - * 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. - */ - -/*! \file - * \brief Additional functions to libopenjpeg/cio.h - */ - -#ifndef CIO_EXT_H_ -# define CIO_EXT_H_ - -#include "openjpeg.h" - - -/* - * Write byte codes with 5 bytes to 8 bytes length - * cio_write supports up to 4 bytes - * - * @param[in] cio file handler - * @param[in] v byte code - * @param[in] n byte length - * @return really writen byte length - */ -unsigned int cio_ext_write( opj_cio_t *cio, unsigned long long int v, int n); - -#endif /* !CIO_EXT_H_ */ diff --git a/applications/jpip/tools/indexer/event_mgr_handler.c b/applications/jpip/tools/indexer/event_mgr_handler.c deleted file mode 100644 index d6d57ba9..00000000 --- a/applications/jpip/tools/indexer/event_mgr_handler.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium - * Copyright (c) 2002-2011, Professor Benoit Macq - * Copyright (c) 2010-2011, Kaori Hagihara - * 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 -#include -#include "event_mgr_handler.h" - -void error_callback(const char *msg, void *client_data); -void warning_callback(const char *msg, void *client_data); -void info_callback(const char *msg, void *client_data); - -opj_event_mgr_t set_default_event_mgr() -{ - opj_event_mgr_t event_mgr; - - /* configure the event callbacks (not required) */ - memset(&event_mgr, 0, sizeof(opj_event_mgr_t)); - event_mgr.error_handler = error_callback; - event_mgr.warning_handler = warning_callback; - event_mgr.info_handler = info_callback; - - return event_mgr; -} - -/** - sample error callback expecting a FILE* client object -*/ -void error_callback(const char *msg, void *client_data) { - FILE *stream = (FILE*)client_data; - fprintf(stream, "[ERROR] %s", msg); -} -/** - sample warning callback expecting a FILE* client object -*/ -void warning_callback(const char *msg, void *client_data) { - FILE *stream = (FILE*)client_data; - fprintf(stream, "[WARNING] %s", msg); -} -/** - sample debug callback expecting no client object -*/ -void info_callback(const char *msg, void *client_data) { - (void)client_data; - // fprintf(stdout, "[INFO] %s", msg); -} diff --git a/applications/jpip/tools/indexer/event_mgr_handler.h b/applications/jpip/tools/indexer/event_mgr_handler.h deleted file mode 100644 index 1fd40f1c..00000000 --- a/applications/jpip/tools/indexer/event_mgr_handler.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium - * Copyright (c) 2002-2011, Professor Benoit Macq - * Copyright (c) 2010-2011, Kaori Hagihara - * 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 EVENT_MG_HANDLER_H_ -# define EVENT_MG_HANDLER_H_ - -#include "openjpeg.h" - -/* - * Set default event message handler - * - * @return event message handler - */ -opj_event_mgr_t set_default_event_mgr(); - -#endif /* !EVENT_MG_HANDLER_H_ */ diff --git a/applications/jpip/tools/indexer/idxjp2_manager.c b/applications/jpip/tools/indexer/idxjp2_manager.c deleted file mode 100644 index 08c9217b..00000000 --- a/applications/jpip/tools/indexer/idxjp2_manager.c +++ /dev/null @@ -1,306 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium - * Copyright (c) 2002-2011, Professor Benoit Macq - * Copyright (c) 2001-2003, David Janssens - * Copyright (c) 2002-2003, Yannick Verschueren - * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe - * Copyright (c) 2005, Herve Drolon, FreeImage Team - - * Copyright (c) 2010-2011, Kaori Hagihara - * 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. - */ - -/*! \file - * \brief Copy of some jp2.c functions, and modification of jpip.h from 2KAN indexer - */ - -#include -#include -#include -#include "event_mgr_handler.h" -#include "cio.h" -#include "cio_ext.h" -#include "j2k_to_idxjp2.h" -#include "cidx_manager.h" -#include "indexbox_manager.h" - -/* - * Encode JP2 stream with index box - * - * @param[in] jp2 jp2 handle - * @param[in] cio file output handle - * @param[in] j2kstream j2k codestream - * @param[in] j2klen length of j2k codestream - * @param[in] cstr_info codestream information - * @param[in] image image data - * @return true if succeed - */ -opj_bool idxjp2_encode( opj_jp2_t *jp2, opj_cio_t *cio, unsigned char *j2kstream, int j2klen, opj_codestream_info_t cstr_info, opj_image_t *image); - - -void fwrite_idxjp2( char filename[], unsigned char *j2kstream, int j2klen, opj_image_t *image, opj_codestream_info_t cstr_info) -{ - int codestream_length; - opj_cio_t *cio = NULL; - FILE *fp = NULL; - opj_cinfo_t *cinfo; - opj_cparameters_t parameters; /* compression parameters */ - opj_event_mgr_t event_mgr; - opj_bool encSuccess; - - /* set encoding parameters to default values */ - opj_set_default_encoder_parameters(¶meters); - - /* get a JP2 compressor handle */ - cinfo = opj_create_compress(CODEC_JP2); - - event_mgr = set_default_event_mgr(); - - /* catch events using our callbacks and give a local context */ - opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stderr); - - /* setup the encoder parameters using the current image and using user parameters */ - opj_setup_encoder(cinfo, ¶meters, image); - - /* open a byte stream for writing */ - /* allocate memory for all tiles */ - cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0); - - encSuccess = idxjp2_encode( (opj_jp2_t*)cinfo->jp2_handle, cio, j2kstream, j2klen, cstr_info, image); - - if (!encSuccess){ - opj_cio_close(cio); - fprintf(stderr, "failed to encode image\n"); - return; - } - codestream_length = cio_tell(cio); - - /* write the buffer to disk */ - fp = fopen( filename, "wb"); - if (!fp) { - fprintf(stderr, "failed to open %s for writing\n", filename); - return; - } - - fwrite(cio->buffer, 1, codestream_length, fp); - fclose(fp); - fprintf(stderr,"Generated outfile %s\n", filename); - /* close and free the byte stream */ - opj_cio_close(cio); - - /* free remaining compression structures */ - opj_destroy_compress(cinfo); - - opj_destroy_cstr_info(&cstr_info); -} - -/* - * Write JP box - * copy from jp2.c - * - * @param[in] cio file output handler - */ -void jp2_write_jp(opj_cio_t *cio); - -/* - * Write FTYP box - File type box - * copy from jp2.c - * - * @param[in] jp2 JP2 handle - * @param[in] cio file output handle - */ -void jp2_write_ftyp(opj_jp2_t *jp2, opj_cio_t *cio); - -/* - * Write file Index (superbox) - * - * @param[in] offset_jp2c offset of jp2c box - * @param[in] length_jp2c length of jp2c box - * @param[in] offset_idx offset of cidx box - * @param[in] length_idx length of cidx box - * @param[in] cio file output handle - * @return length of fidx box - */ -int write_fidx( int offset_jp2c, int length_jp2c, int offset_idx, int length_idx, opj_cio_t *cio); - -/* - * Write index Finder box - * - * @param[in] offset offset of fidx box - * @param[in] length length of fidx box - * @param[in] cio file output handle - */ -void write_iptr( int offset, int length, opj_cio_t *cio); - -opj_bool idxjp2_encode( opj_jp2_t *jp2, opj_cio_t *cio, unsigned char *j2kstream, int j2klen, opj_codestream_info_t cstr_info, opj_image_t *image) -{ - int pos_iptr, pos_cidx, pos_jp2c, end_pos, pos_fidx, len_fidx; - int i; - - /* JP2 encoding */ - - /* JPEG 2000 Signature box */ - jp2_write_jp(cio); - /* File Type box */ - jp2_write_ftyp(jp2, cio); - /* JP2 Header box */ - jp2_write_jp2h(jp2, cio); - - pos_iptr = cio_tell( cio); - cio_skip( cio, 24); /* IPTR further ! */ - - pos_jp2c = cio_tell( cio); - - cio_write( cio, j2klen+8, 4); // L NOTICE: modify for the extended box - cio_write( cio, JP2_JP2C, 4); // JP2C - - for( i=0; ibrand, 4); /* BR */ - cio_write(cio, jp2->minversion, 4); /* MinV */ - - for (i = 0; i < jp2->numcl; i++) { - cio_write(cio, jp2->cl[i], 4); /* CL */ - } - - box.length = cio_tell(cio) - box.init_pos; - cio_seek(cio, box.init_pos); - cio_write(cio, box.length, 4); /* L */ - cio_seek(cio, box.init_pos + box.length); -} - - -/* - * Write proxy box - * - * @param[in] offset_jp2c offset of jp2c box - * @param[in] length_jp2c length of jp2c box - * @param[in] offset_idx offset of cidx box - * @param[in] length_idx length of cidx box - * @param[in] cio file output handle - */ -void write_prxy( int offset_jp2c, int length_jp2c, int offset_idx, int length_idx, opj_cio_t *cio); - -int write_fidx( int offset_jp2c, int length_jp2c, int offset_idx, int length_idx, opj_cio_t *cio) -{ - int len, lenp; - - lenp = cio_tell( cio); - cio_skip( cio, 4); /* L [at the end] */ - cio_write( cio, JPIP_FIDX, 4); /* IPTR */ - - write_prxy( offset_jp2c, length_jp2c, offset_idx, offset_jp2c, cio); - - len = cio_tell( cio)-lenp; - cio_seek( cio, lenp); - cio_write( cio, len, 4); /* L */ - cio_seek( cio, lenp+len); - - return len; -} - -void write_prxy( int offset_jp2c, int length_jp2c, int offset_idx, int length_idx, opj_cio_t *cio) -{ - int len, lenp; - - lenp = cio_tell( cio); - cio_skip( cio, 4); /* L [at the end] */ - cio_write( cio, JPIP_PRXY, 4); /* IPTR */ - - cio_ext_write( cio, offset_jp2c, 8); /* OOFF */ - cio_write( cio, length_jp2c, 4); /* OBH part 1 */ - cio_write( cio, JP2_JP2C, 4); /* OBH part 2 */ - - cio_write( cio, 1,1); /* NI */ - - cio_ext_write( cio, offset_idx, 8); /* IOFF */ - cio_write( cio, length_idx, 4); /* IBH part 1 */ - cio_write( cio, JPIP_CIDX, 4); /* IBH part 2 */ - - len = cio_tell( cio)-lenp; - cio_seek( cio, lenp); - cio_write( cio, len, 4); /* L */ - cio_seek( cio, lenp+len); -} - -void write_iptr( int offset, int length, opj_cio_t *cio) -{ - int len, lenp; - - lenp = cio_tell( cio); - cio_skip( cio, 4); /* L [at the end] */ - cio_write( cio, JPIP_IPTR, 4); /* IPTR */ - - cio_ext_write( cio, offset, 8); - cio_ext_write( cio, length, 8); - - len = cio_tell( cio)-lenp; - cio_seek( cio, lenp); - cio_write( cio, len, 4); /* L */ - cio_seek( cio, lenp+len); -} diff --git a/applications/jpip/tools/indexer/indexbox_manager.h b/applications/jpip/tools/indexer/indexbox_manager.h deleted file mode 100644 index ea4f4933..00000000 --- a/applications/jpip/tools/indexer/indexbox_manager.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium - * Copyright (c) 2002-2011, Professor Benoit Macq - * Copyright (c) 2003-2004, Yannick Verschueren - * Copyright (c) 2010-2011, Kaori Hagihara - * 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. - */ - -/*! \file - * \brief Modification of jpip.c from 2KAN indexer - */ - -#ifndef INDEXBOX_MANAGER_H_ -# define INDEXBOX_MANAGER_H_ - -#include "openjpeg.h" -#include "j2k.h" // needed to use jp2.h -#include "jp2.h" - -#define JPIP_CIDX 0x63696478 /* Codestream index */ -#define JPIP_CPTR 0x63707472 /* Codestream Finder Box */ -#define JPIP_MANF 0x6d616e66 /* Manifest Box */ -#define JPIP_FAIX 0x66616978 /* Fragment array Index box */ -#define JPIP_MHIX 0x6d686978 /* Main Header Index Table */ -#define JPIP_TPIX 0x74706978 /* Tile-part Index Table box */ -#define JPIP_THIX 0x74686978 /* Tile header Index Table box */ -#define JPIP_PPIX 0x70706978 /* Precinct Packet Index Table box */ -#define JPIP_PHIX 0x70686978 /* Packet Header index Table */ -#define JPIP_FIDX 0x66696478 /* File Index */ -#define JPIP_FPTR 0x66707472 /* File Finder */ -#define JPIP_PRXY 0x70727879 /* Proxy boxes */ -#define JPIP_IPTR 0x69707472 /* Index finder box */ -#define JPIP_PHLD 0x70686c64 /* Place holder */ - - -/* - * Write tile-part Index table box (superbox) - * - * @param[in] cstr_info codestream information - * @param[in] j2klen length of j2k codestream - * @param[in] cio file output handle - * @return length of tpix box - */ -int write_tpix( opj_codestream_info_t cstr_info, int j2klen, opj_cio_t *cio); - - -/* - * Write tile header index table box (superbox) - * - * @param[in] coff offset of j2k codestream - * @param[in] cstr_info codestream information - * @param[in] cio file output handle - * @return length of thix box - */ -int write_thix( int coff, opj_codestream_info_t cstr_info, opj_cio_t *cio); - - -/* - * Write precinct packet index table box (superbox) - * - * @param[in] cstr_info codestream information - * @param[in] EPHused true if EPH option used - * @param[in] j2klen length of j2k codestream - * @param[in] cio file output handle - * @return length of ppix box - */ -int write_ppix( opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio); - - -/* - * Write packet header index table box (superbox) - * - * @param[in] cstr_info codestream information - * @param[in] EPHused true if EPH option used - * @param[in] j2klen length of j2k codestream - * @param[in] cio file output handle - * @return length of ppix box - */ -int write_phix( opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio); - -/* - * Wriet manifest box (box) - * - * @param[in] second number to be visited - * @param[in] v number of boxes - * @param[in] box box to be manifested - * @param[in] cio file output handle - */ -void write_manf(int second, int v, opj_jp2_box_t *box, opj_cio_t *cio); - - -#endif /* !INDEXBOX_MANAGER_H_ */ diff --git a/applications/jpip/tools/indexer/j2k_decoder.c b/applications/jpip/tools/indexer/j2k_decoder.c deleted file mode 100644 index 6e625035..00000000 --- a/applications/jpip/tools/indexer/j2k_decoder.c +++ /dev/null @@ -1,157 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium - * Copyright (c) 2002-2011, Professor Benoit Macq - * Copyright (c) 2010-2011, Kaori Hagihara - * 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 -#include -#include "j2k_to_idxjp2.h" -#include "event_mgr_handler.h" -#include "cio.h" -#include "j2k.h" - -/* - * Decode and Add main header marker information - * - * @param[in] cio file input handle - * @param[in,out] cstr_info codestream information - */ -void add_mainheader_marker_info( opj_cio_t *cio, opj_codestream_info_t *cstr_info); - -opj_image_t * decode_j2k( unsigned char *j2kstream, int j2klen, opj_codestream_info_t *cstr_info) -{ - opj_image_t *image; - opj_dparameters_t parameters; /* decompression parameters */ - opj_dinfo_t *dinfo; /* handle to a decompressor */ - opj_cio_t *cio; - opj_event_mgr_t event_mgr; /* event manager */ - - /* set decoding parameters to default values */ - opj_set_default_decoder_parameters(¶meters); - - /* decode the code-stream */ - /* ---------------------- */ - - /* JPEG-2000 codestream */ - /* get a decoder handle */ - dinfo = opj_create_decompress( CODEC_J2K); - - event_mgr = set_default_event_mgr(); - - /* catch events using our callbacks and give a local context */ - opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr); - - /* setup the decoder decoding parameters using user parameters */ - opj_setup_decoder(dinfo, ¶meters); - - /* open a byte stream */ - cio = opj_cio_open((opj_common_ptr)dinfo, j2kstream, j2klen); - - /* decode the stream and fill the image structure */ - image = opj_decode_with_info(dinfo, cio, cstr_info); - if(!image) { - fprintf(stderr, "ERROR -> jp2_to_image: failed to decode image!\n"); - opj_destroy_decompress(dinfo); - opj_cio_close(cio); - return NULL; - } - - if( cstr_info->marknum == 0) - add_mainheader_marker_info( cio, cstr_info); - - /* close the byte stream */ - opj_cio_close(cio); - - /* free remaining structures */ - if(dinfo) { - opj_destroy_decompress(dinfo); - } - - return image; -} - - -/* - * Get main headr marker size - * - * @param[in] type marker type - * @param[in] cstr_info codestream information - * @param[in] cio file input handle - * @return marker size - */ -unsigned short get_mh_markersize( unsigned short type, opj_codestream_info_t cstr_info, opj_cio_t *cio); - -void add_mainheader_marker_info( opj_cio_t *cio, opj_codestream_info_t *cstr_info) -{ - opj_marker_info_t marker; - int pos; - - cstr_info->marker = (opj_marker_info_t *)malloc( 100*sizeof(opj_marker_info_t)); // max 100 - - pos = cstr_info->main_head_start; - cio_seek( cio, pos); - - while( pos <= cstr_info->main_head_end){ - marker.type = cio_read( cio, 2); - marker.pos = cio_tell( cio); - marker.len = get_mh_markersize( marker.type, *cstr_info, cio); - cio_skip( cio, marker.len); - - cstr_info->marker[ cstr_info->marknum] = marker; - - cstr_info->marknum++; - pos = cio_tell( cio); - } -} - -unsigned short get_mh_markersize( unsigned short type, opj_codestream_info_t cstr_info, opj_cio_t *cio) -{ - unsigned short siz; - int pos; - - siz = 0; - - switch( type){ - case J2K_MS_SOC: - siz = 0; - break; - case J2K_MS_SIZ: - siz = 38+3*cstr_info.numcomps; - break; - case J2K_MS_COD: - case J2K_MS_QCD: - case J2K_MS_COM: - pos = cio_tell( cio); - siz = cio_read( cio, 2); - cio_seek( cio, pos); - break; - default: - fprintf( stderr, "marker %x length not defined yet!\n", type); - } - return siz; -} diff --git a/applications/jpip/tools/indexer/j2k_to_idxjp2.c b/applications/jpip/tools/indexer/j2k_to_idxjp2.c deleted file mode 100644 index 82394010..00000000 --- a/applications/jpip/tools/indexer/j2k_to_idxjp2.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium - * Copyright (c) 2002-2011, Professor Benoit Macq - * Copyright (c) 2010-2011, Kaori Hagihara - * 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. - */ - -/*! \file - * \brief j2k_to_idxjp2 is a program to make jp2 file with index box from j2k file - * - * \section impinst Implementing instructions - * This program takes two arguments. \n - * -# Input J2K image file\n - * -# Output JP2 file name\n - * % ./j2k_to_idxjp2 image.j2k image.jp2\n - */ - -#include -#include -#include -#include "openjpeg.h" -#include "j2k_to_idxjp2.h" - - -/* - * Read a binary file - * - * @param[in] filename file name - * @param[out] lenoffile pointer to feed file length - * @return byte code - */ -unsigned char * read_binaryfile( char filename[], int *lenoffile); - -int main(int argc, char **argv) -{ - opj_image_t *image = NULL; - opj_codestream_info_t cstr_info; /* Codestream information structure */ - unsigned char *j2kstream; - int j2klen; - - if (argc < 3){ - fprintf(stderr,"\nERROR in entry : j2k_to_idxjp2 J2K-file JP2-file\n"); - return 1; - } - - j2kstream = read_binaryfile( argv[1], &j2klen); - - image = decode_j2k( j2kstream, j2klen, &cstr_info); - if( !image){ - free(j2kstream); - return -1; - } - - fwrite_idxjp2( argv[2], j2kstream, j2klen, image, cstr_info); - - free(j2kstream); - - /* free image data structure */ - opj_image_destroy(image); - - return 0; -} - -unsigned char * read_binaryfile( char filename[], int *lenoffile) -{ - FILE *fp; - unsigned char *bytecode; - - fp = fopen( filename, "rb"); - if (!fp) { - fprintf(stderr, "Failed to open %s for reading !!\n", filename); - exit (-1); - } - - /* length of the codestream */ - fseek( fp, 0, SEEK_END); - *lenoffile = ftell(fp); - fseek( fp, 0, SEEK_SET); - - bytecode = (unsigned char*)malloc(*lenoffile); - fread( bytecode, *lenoffile, 1, fp); - fclose(fp); - - return bytecode; -} diff --git a/applications/jpip/tools/indexer/j2k_to_idxjp2.h b/applications/jpip/tools/indexer/j2k_to_idxjp2.h deleted file mode 100644 index 45a4a432..00000000 --- a/applications/jpip/tools/indexer/j2k_to_idxjp2.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium - * Copyright (c) 2002-2011, Professor Benoit Macq - * Copyright (c) 2010-2011, Kaori Hagihara - * 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_TO_IDXJP2_H_ -# define J2K_TO_IDXJP2_H_ - -#include "openjpeg.h" - -/* - * Decode j2k codestream - * - * @param[in] j2kstream j2k codestream - * @param[in] j2klen length of j2k codestream - * @param[out] cstr_info codestream information - * @return image data - */ -opj_image_t * decode_j2k( unsigned char *j2kstream, int j2klen, opj_codestream_info_t *cstr_info); - - -/* - * Write a JP2 file with index box - * - * @param[in] filename file name - * @param[in] j2kstream j2k codestream - * @param[in] j2klen length of j2k codestream - * @param[in] image image data - * @param[in] cstr_info codestream information - */ -void fwrite_idxjp2( char filename[], unsigned char *j2kstream, int j2klen, opj_image_t *image, opj_codestream_info_t cstr_info); - -#endif /* !J2K_TO_IDXJP2S_H_ */ diff --git a/applications/jpip/tools/indexer/phix_manager.c b/applications/jpip/tools/indexer/phix_manager.c deleted file mode 100644 index da7a6ae0..00000000 --- a/applications/jpip/tools/indexer/phix_manager.c +++ /dev/null @@ -1,142 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium - * Copyright (c) 2002-2011, Professor Benoit Macq - * Copyright (c) 2003-2004, Yannick Verschueren - * Copyright (c) 2010-2011, Kaori Hagihara - * 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. - */ - -/*! \file - * \brief Modification of jpip.c from 2KAN indexer - */ - -#include -#include -#include "indexbox_manager.h" -#include "cio_ext.h" -#include "cio.h" - -/* - * Write faix box of phix - * - * @param[in] compno component number - * @param[in] cstr_info codestream information - * @param[in] EPHused true if if EPH option used - * @param[in] j2klen length of j2k codestream - * @param[in] cio file output handle - * @return length of faix box - */ -int write_phixfaix( int compno, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio); - -int write_phix( opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio) -{ - int len, lenp=0, compno, i; - opj_jp2_box_t *box; - - box = (opj_jp2_box_t *)calloc( cstr_info.numcomps, sizeof(opj_jp2_box_t)); - - for( i=0;i<2;i++){ - if (i) cio_seek( cio, lenp); - - lenp = cio_tell( cio); - cio_skip( cio, 4); /* L [at the end] */ - cio_write( cio, JPIP_PHIX, 4); /* PHIX */ - - write_manf( i, cstr_info.numcomps, box, cio); - - for( compno=0; compno pow( 2, 32)){ - size_of_coding = 8; - version = 1; - } - else{ - size_of_coding = 4; - version = 0; - } - - lenp = cio_tell( cio); - cio_skip( cio, 4); /* L [at the end] */ - cio_write( cio, JPIP_FAIX, 4); /* FAIX */ - cio_write( cio, version,1); /* Version 0 = 4 bytes */ - - cio_ext_write( cio, cstr_info.packno, size_of_coding); /* NMAX */ - cio_ext_write( cio, cstr_info.tw*cstr_info.th, size_of_coding); /* M */ - - for( tileno=0; tilenopw[resno]*tile_Idx->ph[resno]; precno++){ - for( layno=0; laynopacket[num_packet]; - cio_ext_write( cio, packet.start_pos, size_of_coding); /* start position */ - cio_ext_write( cio, packet.end_ph_pos-packet.start_pos+1, size_of_coding); /* length */ - - num_packet++; - } - } - } - - /* PADDING */ - while( num_packet < cstr_info.packno){ - cio_ext_write( cio, 0, size_of_coding); /* start position */ - cio_ext_write( cio, 0, size_of_coding); /* length */ - num_packet++; - } - } - - len = cio_tell( cio)-lenp; - cio_seek( cio, lenp); - cio_write( cio, len, 4); /* L */ - cio_seek( cio, lenp+len); - - return len; -} diff --git a/applications/jpip/tools/indexer/ppix_manager.c b/applications/jpip/tools/indexer/ppix_manager.c deleted file mode 100644 index 4fd45f8f..00000000 --- a/applications/jpip/tools/indexer/ppix_manager.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium - * Copyright (c) 2002-2011, Professor Benoit Macq - * Copyright (c) 2003-2004, Yannick Verschueren - * Copyright (c) 2010-2011, Kaori Hagihara - * 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. - */ - -/*! \file - * \brief Modification of jpip.c from 2KAN indexer - */ - -#include -#include -#include -#include "indexbox_manager.h" -#include "cio_ext.h" -#include "cio.h" - -/* - * Write faix box of ppix - * - * @param[in] compno component number - * @param[in] cstr_info codestream information - * @param[in] EPHused true if if EPH option used - * @param[in] j2klen length of j2k codestream - * @param[in] cio file output handle - * @return length of faix box - */ -int write_ppixfaix( int compno, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio); - -int write_ppix( opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio) -{ - int len, lenp, compno, i; - opj_jp2_box_t *box; - - printf("cstr_info.packno %d\n", cstr_info.packno); //NMAX? - - box = (opj_jp2_box_t *)calloc( cstr_info.numcomps, sizeof(opj_jp2_box_t)); - - for (i=0;i<2;i++){ - if (i) cio_seek( cio, lenp); - - lenp = cio_tell( cio); - cio_skip( cio, 4); /* L [at the end] */ - cio_write( cio, JPIP_PPIX, 4); /* PPIX */ - - write_manf( i, cstr_info.numcomps, box, cio); - - for (compno=0; compno pow( 2, 32)){ - size_of_coding = 8; - version = 1; - } - else{ - size_of_coding = 4; - version = 0; - } - - lenp = cio_tell( cio); - cio_skip( cio, 4); /* L [at the end] */ - cio_write( cio, JPIP_FAIX, 4); /* FAIX */ - cio_write( cio, version, 1); /* Version 0 = 4 bytes */ - - cio_ext_write( cio, cstr_info.packno, size_of_coding); /* NMAX */ - cio_ext_write( cio, cstr_info.tw*cstr_info.th, size_of_coding); /* M */ - - for( tileno=0; tilenopw[resno]*tile_Idx->ph[resno]; precno++){ - for( layno=0; laynopacket[num_packet]; - cio_ext_write( cio, packet.start_pos, size_of_coding); /* start position */ - cio_ext_write( cio, packet.end_pos-packet.start_pos+1, size_of_coding); /* length */ - - num_packet++; - } - } - } - - /* PADDING */ - while( num_packet < cstr_info.packno){ - cio_ext_write( cio, 0, size_of_coding); /* start position */ - cio_ext_write( cio, 0, size_of_coding); /* length */ - num_packet++; - } - } - - len = cio_tell( cio)-lenp; - cio_seek( cio, lenp); - cio_write( cio, len, 4); /* L */ - cio_seek( cio, lenp+len); - - return len; - -} diff --git a/applications/jpip/tools/indexer/thix_manager.c b/applications/jpip/tools/indexer/thix_manager.c deleted file mode 100644 index dbe1b1b4..00000000 --- a/applications/jpip/tools/indexer/thix_manager.c +++ /dev/null @@ -1,208 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium - * Copyright (c) 2002-2011, Professor Benoit Macq - * Copyright (c) 2003-2004, Yannick Verschueren - * Copyright (c) 2010-2011, Kaori Hagihara - * 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. - */ - -/*! \file - * \brief Modification of jpip.c from 2KAN indexer - */ - -#include -#include -#include -#include "indexbox_manager.h" -#include "cio_ext.h" -#include "cio.h" - -/* - * Write tile-part headers mhix box - * - * @param[in] coff offset of j2k codestream - * @param[in] cstr_info codestream information - * @param[in] tileno tile number - * @param[in] cio file output handle - * @return length of mhix box - */ -int write_tilemhix( int coff, opj_codestream_info_t cstr_info, int tileno, opj_cio_t *cio); - -int write_thix( int coff, opj_codestream_info_t cstr_info, opj_cio_t *cio) -{ - int len, lenp, i; - int tileno; - opj_jp2_box_t *box; - - lenp = 0; - box = (opj_jp2_box_t *)calloc( cstr_info.tw*cstr_info.th, sizeof(opj_jp2_box_t)); - - for ( i = 0; i < 2 ; i++ ){ - if (i) - cio_seek( cio, lenp); - - lenp = cio_tell( cio); - cio_skip( cio, 4); /* L [at the end] */ - cio_write( cio, JPIP_THIX, 4); /* THIX */ - write_manf( i, cstr_info.tw*cstr_info.th, box, cio); - - for (tileno = 0; tileno < cstr_info.tw*cstr_info.th; tileno++){ - box[tileno].length = write_tilemhix( coff, cstr_info, tileno, cio); - box[tileno].type = JPIP_MHIX; - } - - len = cio_tell( cio)-lenp; - cio_seek( cio, lenp); - cio_write( cio, len, 4); /* L */ - cio_seek( cio, lenp+len); - } - - free(box); - - return len; -} - - -/* - * Find tile markers - * - * @param[in] coff offset of j2k codestream - * @param[in] startpos tile start byte position - * @param[in] endpos tile end position - * @param[in] cio file output handle - * @param[out] marknum pointer to number of markers - * @return found marker information array - */ -opj_marker_info_t * find_tile_markers( int coff, int startpos, int endpos, opj_cio_t *cio, int *marknum); - -int write_tilemhix( int coff, opj_codestream_info_t cstr_info, int tileno, opj_cio_t *cio) -{ - int i; - opj_tile_info_t tile; - opj_tp_info_t tp; - int marknum; - int len, lenp; - opj_marker_info_t *marker; - - lenp = cio_tell( cio); - cio_skip( cio, 4); /* L [at the end] */ - cio_write( cio, JPIP_MHIX, 4); /* MHIX */ - - tile = cstr_info.tile[tileno]; - tp = tile.tp[0]; - - cio_ext_write( cio, tp.tp_end_header-tp.tp_start_pos+1, 8); /* TLEN */ - - marker = find_tile_markers( coff, tile.start_pos, tile.end_header, cio, &marknum); - - for( i=0; i= max_num_of_markers){ - tmp = marker; - marker = (opj_marker_info_t *)malloc( (max_num_of_markers+100)*sizeof(opj_marker_info_t)); - memcpy( marker, tmp, max_num_of_markers*sizeof(opj_marker_info_t)); - free( tmp); - max_num_of_markers += 100; - } - - marker[*marknum].type = cio_read( cio, 2); - marker[*marknum].pos = cio_tell( cio)-coff; - marker[*marknum].len = get_tile_markersize( marker[*marknum].type, cio); - cio_skip( cio, marker[*marknum].len); - - (*marknum)++; - pos += 2+marker[*marknum].len; - } - - cio_seek( cio, org_pos); - - return marker; -} - -unsigned short get_tile_markersize( unsigned short type, opj_cio_t *cio) -{ - unsigned short siz; - int pos; - - siz = 0; - - switch( type){ - case J2K_MS_SOD: - case J2K_MS_EOC: - case J2K_MS_EPH: - siz = 0; - break; - default: - pos = cio_tell( cio); - siz = cio_read( cio, 2); - cio_seek( cio, pos); - break; - } - return siz; -} diff --git a/applications/jpip/tools/indexer/tpix_manager.c b/applications/jpip/tools/indexer/tpix_manager.c deleted file mode 100644 index 1f71ce6d..00000000 --- a/applications/jpip/tools/indexer/tpix_manager.c +++ /dev/null @@ -1,154 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium - * Copyright (c) 2002-2011, Professor Benoit Macq - * Copyright (c) 2003-2004, Yannick Verschueren - * Copyright (c) 2010-2011, Kaori Hagihara - * 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. - */ - -/*! \file - * \brief Modification of jpip.c from 2KAN indexer - */ - -#include -#include "indexbox_manager.h" -#include "cio_ext.h" -#include "cio.h" - -#define MAX(a,b) ((a)>(b)?(a):(b)) - - -/* - * Write faix box of tpix - * - * @param[in] compno component number - * @param[in] cstr_info codestream information - * @param[in] j2klen length of j2k codestream - * @param[in] cio file output handle - * @return length of faix box - */ -int write_tpixfaix( int compno, opj_codestream_info_t cstr_info, int j2klen, opj_cio_t *cio); - - -int write_tpix( opj_codestream_info_t cstr_info, int j2klen, opj_cio_t *cio) -{ - int len, lenp; - lenp = cio_tell( cio); - cio_skip( cio, 4); /* L [at the end] */ - cio_write( cio, JPIP_TPIX, 4); /* TPIX */ - - write_tpixfaix( 0, cstr_info, j2klen, cio); - - len = cio_tell( cio)-lenp; - cio_seek( cio, lenp); - cio_write( cio, len, 4); /* L */ - cio_seek( cio, lenp+len); - - return len; -} - - -/* - * Get number of maximum tile parts per tile - * - * @param[in] cstr_info codestream information - * @return number of maximum tile parts per tile - */ -int get_num_max_tile_parts( opj_codestream_info_t cstr_info); - -int write_tpixfaix( int compno, opj_codestream_info_t cstr_info, int j2klen, opj_cio_t *cio) -{ - int len, lenp; - int i, j; - int Aux; - int num_max_tile_parts; - int size_of_coding; // 4 or 8 - opj_tp_info_t tp; - int version; - - num_max_tile_parts = get_num_max_tile_parts( cstr_info); - - if( j2klen > pow( 2, 32)){ - size_of_coding = 8; - version = num_max_tile_parts == 1 ? 1:3; - } - else{ - size_of_coding = 4; - version = num_max_tile_parts == 1 ? 0:2; - } - - lenp = cio_tell( cio); - cio_skip( cio, 4); /* L [at the end] */ - cio_write( cio, JPIP_FAIX, 4); /* FAIX */ - cio_write( cio, version, 1); /* Version 0 = 4 bytes */ - - cio_ext_write( cio, num_max_tile_parts, size_of_coding); /* NMAX */ - cio_ext_write( cio, cstr_info.tw*cstr_info.th, size_of_coding); /* M */ - for (i = 0; i < cstr_info.tw*cstr_info.th; i++){ - for (j = 0; j < cstr_info.tile[i].num_tps; j++){ - tp = cstr_info.tile[i].tp[j]; - cio_ext_write( cio, tp.tp_start_pos, size_of_coding); /* start position */ - cio_ext_write( cio, tp.tp_end_pos-tp.tp_start_pos+1, size_of_coding); /* length */ - if (version & 0x02){ - if( cstr_info.tile[i].num_tps == 1 && cstr_info.numdecompos[compno] > 1) - Aux = cstr_info.numdecompos[compno] + 1; - else - Aux = j + 1; - - cio_write( cio, Aux,4); - //cio_write(img.tile[i].tile_parts[j].num_reso_AUX,4); /* Aux_i,j : Auxiliary value */ - // fprintf(stderr,"AUX value %d\n",Aux); - } - //cio_write(0,4); - } - /* PADDING */ - while (j < num_max_tile_parts){ - cio_ext_write( cio, 0, size_of_coding); /* start position */ - cio_ext_write( cio, 0, size_of_coding); /* length */ - if (version & 0x02) - cio_write( cio, 0,4); /* Aux_i,j : Auxiliary value */ - j++; - } - } - - len = cio_tell( cio)-lenp; - cio_seek( cio, lenp); - cio_write( cio, len, 4); /* L */ - cio_seek( cio, lenp+len); - - return len; - -} - -int get_num_max_tile_parts( opj_codestream_info_t cstr_info) -{ - int num_max_tp = 0, i; - - for( i=0; i