[1.5] backport r1017, r1030:1032 from trunk + additional fix for cmake and autotools

This commit is contained in:
Antonin Descampe 2011-11-02 00:49:20 +00:00
parent 49a0f0db8f
commit 238b767917
84 changed files with 1359 additions and 1018 deletions

View File

@ -5,7 +5,21 @@ What's New for OpenJPIP
! : changed ! : changed
+ : added + : added
October 14, 2011 November 2, 2011
* [antonin] additional patches for autotools and cmake
October 26, 2011
* [kaori] additional patches for autotool are applied
October 25, 2011
* [kaori] patches for cmake and autotool are applied
* [kaori] fixed client viewer to be compatible with server response header both Content-type and Content-Type
October 20, 2011
+ [added] API style in openJPIP library
! [kaori] rearranged directories, applications are all under util/ directory, currently only 'make -f Makefile.nix' works
October 18, 2011
! [kaori] rearranged opj_server, opj_dec_server directory ! [kaori] rearranged opj_server, opj_dec_server directory
October 14, 2011 October 14, 2011

View File

@ -1,5 +1,3 @@
ADD_SUBDIRECTORY(libopenjpip) ADD_SUBDIRECTORY(libopenjpip)
ADD_SUBDIRECTORY(opj_server) ADD_SUBDIRECTORY(util)
ADD_SUBDIRECTORY(opj_client)
ADD_SUBDIRECTORY(tools)

View File

@ -1,3 +1,3 @@
MAINTAINERCLEANFILES = Makefile.in MAINTAINERCLEANFILES = Makefile.in
SUBDIRS = libopenjpip opj_server opj_client tools SUBDIRS = libopenjpip util

View File

@ -1,19 +1,11 @@
default: t_libopenjpip t_opj_server t_opj_dec_server t_tools default: t_libopenjpip t_util
t_libopenjpip: t_libopenjpip:
make -C libopenjpip -f Makefile.nix make -C libopenjpip -f Makefile.nix
t_opj_server: t_util:
make -C opj_server -f Makefile.nix make -C util -f Makefile.nix
t_opj_dec_server:
make -C opj_client/opj_dec_server -f Makefile.nix
t_tools:
make -C tools -f Makefile.nix
clean: clean:
make clean -C libopenjpip -f Makefile.nix make clean -C libopenjpip -f Makefile.nix
make clean -C opj_server -f Makefile.nix make clean -C util -f Makefile.nix
make clean -C opj_client/opj_dec_server -f Makefile.nix
make clean -C tools -f Makefile.nix

View File

@ -1,6 +1,7 @@
INCLUDE_REGULAR_EXPRESSION("^.*$") INCLUDE_REGULAR_EXPRESSION("^.*$")
INCLUDE_DIRECTORIES( INCLUDE_DIRECTORIES(
${OPENJPEG_SOURCE_DIR}/libopenjpeg
${FCGI_INCLUDE_DIRNAME} ${FCGI_INCLUDE_DIRNAME}
) )
@ -24,10 +25,24 @@ ${CMAKE_CURRENT_SOURCE_DIR}/target_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/cachemodel_manager.c ${CMAKE_CURRENT_SOURCE_DIR}/cachemodel_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/j2kheader_manager.c ${CMAKE_CURRENT_SOURCE_DIR}/j2kheader_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/jp2k_encoder.c ${CMAKE_CURRENT_SOURCE_DIR}/jp2k_encoder.c
${CMAKE_CURRENT_SOURCE_DIR}/openjpip.c
${CMAKE_CURRENT_SOURCE_DIR}/query_parser.c
${CMAKE_CURRENT_SOURCE_DIR}/channel_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/session_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/jpip_parser.c
)
SET(LOCAL_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/jp2k_decoder.c
${CMAKE_CURRENT_SOURCE_DIR}/imgsock_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/jpipstream_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/cache_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/dec_clientmsg_handler.c
) )
# Build the library # Build the library
ADD_LIBRARY(openjpip_local STATIC ${OPENJPIP_SRCS}) ADD_LIBRARY(openjpip_local STATIC ${OPENJPIP_SRCS} ${LOCAL_SRCS})
TARGET_LINK_LIBRARIES(openjpip_local ${OPENJPEG_LIBRARY_NAME})
ADD_LIBRARY(openjpip_server STATIC ${OPENJPIP_SRCS}) ADD_LIBRARY(openjpip_server STATIC ${OPENJPIP_SRCS})
TARGET_LINK_LIBRARIES(openjpip_server ${FCGI_LIBNAME}) TARGET_LINK_LIBRARIES(openjpip_server ${FCGI_LIBNAME})
@ -36,12 +51,12 @@ SET_TARGET_PROPERTIES(openjpip_server
# Install library # Install library
INSTALL(TARGETS openjpip_local INSTALL(TARGETS openjpip_local
EXPORT OpenJPEGTargets EXPORT OpenJPEGTargets
DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
) )
INSTALL(TARGETS openjpip_server INSTALL(TARGETS openjpip_server
EXPORT OpenJPEGTargets EXPORT OpenJPEGTargets
DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
) )

View File

@ -6,6 +6,11 @@ includes_HEADERS =
lib_LTLIBRARIES = libopenjpip_server.la libopenjpip_local.la lib_LTLIBRARIES = libopenjpip_server.la libopenjpip_local.la
JPIP_SRC = \ JPIP_SRC = \
openjpip.c \
query_parser.c \
channel_manager.c \
session_manager.c \
jpip_parser.c \
boxheader_manager.c \ boxheader_manager.c \
codestream_manager.c \ codestream_manager.c \
imgreg_manager.c \ imgreg_manager.c \
@ -42,7 +47,21 @@ placeholder_manager.h \
target_manager.h \ target_manager.h \
cachemodel_manager.h \ cachemodel_manager.h \
j2kheader_manager.h \ j2kheader_manager.h \
jp2k_encoder.h jp2k_encoder.h \
query_parser.h \
channel_manager.h \
session_manager.h \
jpip_parser.h
LOCAL_SRC = jp2k_decoder.c \
imgsock_manager.c \
jpipstream_manager.c \
cache_manager.c \
dec_clientmsg_handler.c \
imgsock_manager.h \
jpipstream_manager.h \
cache_manager.h \
dec_clientmsg_handler.h
libopenjpip_server_la_CPPFLAGS = \ libopenjpip_server_la_CPPFLAGS = \
-I. \ -I. \
@ -57,12 +76,14 @@ libopenjpip_server_la_SOURCES = $(JPIP_SRC)
libopenjpip_local_la_CPPFLAGS = \ libopenjpip_local_la_CPPFLAGS = \
-I. \ -I. \
-I$(top_srcdir)/libopenjpeg \
-I$(top_builddir)/libopenjpeg \
-I$(top_srcdir)/applications/jpip/libopenjpip \ -I$(top_srcdir)/applications/jpip/libopenjpip \
-I$(top_builddir)/applications/jpip/libopenjpip -I$(top_builddir)/applications/jpip/libopenjpip
libopenjpip_local_la_CFLAGS = libopenjpip_local_la_CFLAGS =
libopenjpip_local_la_LIBADD = -lm libopenjpip_local_la_LIBADD = $(top_builddir)/libopenjpeg/libopenjpeg.la -lm
libopenjpip_local_la_LDFLAGS = -no-undefined -version-info @lt_version@ libopenjpip_local_la_LDFLAGS = -no-undefined -version-info @lt_version@
libopenjpip_local_la_SOURCES = $(JPIP_SRC) libopenjpip_local_la_SOURCES = $(JPIP_SRC) $(LOCAL_SRC)
install-data-hook: install-data-hook:
@echo -e " (LA)\t$(libdir)/libopenjpip_server.la" >> $(top_builddir)/report.txt @echo -e " (LA)\t$(libdir)/libopenjpip_server.la" >> $(top_builddir)/report.txt

View File

@ -2,17 +2,28 @@ ifdef jpipserver
CFLAGS = -O3 -Wall -m32 -DSERVER CFLAGS = -O3 -Wall -m32 -DSERVER
LIBNAME = libopenjpip_server.a LIBNAME = libopenjpip_server.a
else else
CFLAGS = -O3 -Wall J2KINCDIR = ../../../libopenjpeg
CFLAGS = -O3 -Wall -I$(J2KINCDIR)
LIBNAME = libopenjpip_local.a LIBNAME = libopenjpip_local.a
endif endif
all: $(LIBNAME) all: $(LIBNAME)
$(LIBNAME): target_manager.o byte_manager.o box_manager.o boxheader_manager.o manfbox_manager.o \ ifdef jpipserver
$(LIBNAME): openjpip.o target_manager.o byte_manager.o box_manager.o boxheader_manager.o manfbox_manager.o \
mhixbox_manager.o marker_manager.o codestream_manager.o faixbox_manager.o index_manager.o \ mhixbox_manager.o marker_manager.o codestream_manager.o faixbox_manager.o index_manager.o \
msgqueue_manager.o metadata_manager.o placeholder_manager.o ihdrbox_manager.o imgreg_manager.o \ msgqueue_manager.o metadata_manager.o placeholder_manager.o ihdrbox_manager.o imgreg_manager.o \
cachemodel_manager.o j2kheader_manager.o jp2k_encoder.o cachemodel_manager.o j2kheader_manager.o jp2k_encoder.o query_parser.o channel_manager.o \
session_manager.o jpip_parser.o
ar r $@ $^ ar r $@ $^
else
$(LIBNAME): openjpip.o target_manager.o byte_manager.o box_manager.o boxheader_manager.o manfbox_manager.o \
mhixbox_manager.o marker_manager.o codestream_manager.o faixbox_manager.o index_manager.o \
msgqueue_manager.o metadata_manager.o placeholder_manager.o ihdrbox_manager.o imgreg_manager.o \
cachemodel_manager.o j2kheader_manager.o jp2k_encoder.o query_parser.o channel_manager.o \
session_manager.o jpip_parser.o jp2k_decoder.o imgsock_manager.o jpipstream_manager.o cache_manager.o \
dec_clientmsg_handler.o
ar r $@ $^
endif
clean: clean:
rm -f $(LIBNAME) *.o *~ rm -f $(LIBNAME) *.o *~

View File

@ -41,124 +41,6 @@
//! maximum length of channel identifier //! maximum length of channel identifier
#define MAX_LENOFCID 30 #define MAX_LENOFCID 30
/**
* handle JPT- JPP- stream message
*
* @param[in] connected_socket socket descriptor
* @param[in] cachelist cache list pointer
* @param[in,out] jpipstream address of JPT- JPP- stream pointer
* @param[in,out] streamlen address of stream length
* @param[in,out] msgqueue message queue pointer
*/
void handle_JPIPstreamMSG( SOCKET connected_socket, cachelist_param_t *cachelist, Byte_t **jpipstream, int *streamlen, msgqueue_param_t *msgqueue);
/**
* handle PNM request message
*
* @param[in] connected_socket socket descriptor
* @param[in] jpipstream jpipstream pointer
* @param[in] msgqueue message queue pointer
* @param[in] cachelist cache list pointer
*/
void handle_PNMreqMSG( SOCKET connected_socket, Byte_t *jpipstream, msgqueue_param_t *msgqueue, cachelist_param_t *cachelist);
/**
* handle XML request message
*
* @param[in] connected_socket socket descriptor
* @param[in] jpipstream address of caching jpipstream pointer
* @param[in] cachelist cache list pointer
*/
void handle_XMLreqMSG( SOCKET connected_socket, Byte_t *jpipstream, cachelist_param_t *cachelist);
/**
* handle TargetID request message
*
* @param[in] connected_socket socket descriptor
* @param[in] cachelist cache list pointer
*/
void handle_TIDreqMSG( SOCKET connected_socket, cachelist_param_t *cachelist);
/**
* handle ChannelID request message
*
* @param[in] connected_socket socket descriptor
* @param[in] cachelist cache list pointer
*/
void handle_CIDreqMSG( SOCKET connected_socket, cachelist_param_t *cachelist);
/**
* handle distroy ChannelID message
*
* @param[in] connected_socket socket descriptor
* @param[in,out] cachelist cache list pointer
*/
void handle_dstCIDreqMSG( SOCKET connected_socket, cachelist_param_t *cachelist);
/**
* handle saving JP2 file request message
*
* @param[in] connected_socket socket descriptor
* @param[in] cachelist cache list pointer
* @param[in] msgqueue message queue pointer
* @param[in] jpipstream address of caching jpipstream pointer
*/
void handle_JP2saveMSG( SOCKET connected_socket, cachelist_param_t *cachelist, msgqueue_param_t *msgqueue, Byte_t *jpipstream);
bool handle_clientmsg( SOCKET connected_socket, cachelist_param_t *cachelist, Byte_t **jpipstream, int *streamlen, msgqueue_param_t *msgqueue)
{
bool quit = false;
msgtype_t msgtype = identify_clientmsg( connected_socket);
switch( msgtype){
case JPIPSTREAM:
handle_JPIPstreamMSG( connected_socket, cachelist, jpipstream, streamlen, msgqueue);
break;
case PNMREQ:
handle_PNMreqMSG( connected_socket, *jpipstream, msgqueue, cachelist);
break;
case XMLREQ:
handle_XMLreqMSG( connected_socket, *jpipstream, cachelist);
break;
case TIDREQ:
handle_TIDreqMSG( connected_socket, cachelist);
break;
case CIDREQ:
handle_CIDreqMSG( connected_socket, cachelist);
break;
case CIDDST:
handle_dstCIDreqMSG( connected_socket, cachelist);
break;
case JP2SAVE:
handle_JP2saveMSG( connected_socket, cachelist, msgqueue, *jpipstream);
break;
case QUIT:
quit = true;
save_codestream( *jpipstream, *streamlen, "jpt");
break;
case MSGERROR:
break;
}
printf("\t end of the connection\n\n");
if( close_socket(connected_socket) != 0){
perror("close");
return false;
}
if( quit)
return false;
return true;
}
void handle_JPIPstreamMSG( SOCKET connected_socket, cachelist_param_t *cachelist, void handle_JPIPstreamMSG( SOCKET connected_socket, cachelist_param_t *cachelist,
Byte_t **jpipstream, int *streamlen, msgqueue_param_t *msgqueue) Byte_t **jpipstream, int *streamlen, msgqueue_param_t *msgqueue)
{ {

View File

@ -0,0 +1,105 @@
/*
* $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
* Copyright (c) 2011, Lucian Corlaciu, GSoC
* 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 DEC_CLIENTMSG_HANDLER_H_
# define DEC_CLIENTMSG_HANDLER_H_
#include "imgsock_manager.h"
#include "cache_manager.h"
#include "byte_manager.h"
#include "msgqueue_manager.h"
/**
* handle JPT- JPP- stream message
*
* @param[in] connected_socket socket descriptor
* @param[in] cachelist cache list pointer
* @param[in,out] jpipstream address of JPT- JPP- stream pointer
* @param[in,out] streamlen address of stream length
* @param[in,out] msgqueue message queue pointer
*/
void handle_JPIPstreamMSG( SOCKET connected_socket, cachelist_param_t *cachelist, Byte_t **jpipstream, int *streamlen, msgqueue_param_t *msgqueue);
/**
* handle PNM request message
*
* @param[in] connected_socket socket descriptor
* @param[in] jpipstream jpipstream pointer
* @param[in] msgqueue message queue pointer
* @param[in] cachelist cache list pointer
*/
void handle_PNMreqMSG( SOCKET connected_socket, Byte_t *jpipstream, msgqueue_param_t *msgqueue, cachelist_param_t *cachelist);
/**
* handle XML request message
*
* @param[in] connected_socket socket descriptor
* @param[in] jpipstream address of caching jpipstream pointer
* @param[in] cachelist cache list pointer
*/
void handle_XMLreqMSG( SOCKET connected_socket, Byte_t *jpipstream, cachelist_param_t *cachelist);
/**
* handle TargetID request message
*
* @param[in] connected_socket socket descriptor
* @param[in] cachelist cache list pointer
*/
void handle_TIDreqMSG( SOCKET connected_socket, cachelist_param_t *cachelist);
/**
* handle ChannelID request message
*
* @param[in] connected_socket socket descriptor
* @param[in] cachelist cache list pointer
*/
void handle_CIDreqMSG( SOCKET connected_socket, cachelist_param_t *cachelist);
/**
* handle distroy ChannelID message
*
* @param[in] connected_socket socket descriptor
* @param[in,out] cachelist cache list pointer
*/
void handle_dstCIDreqMSG( SOCKET connected_socket, cachelist_param_t *cachelist);
/**
* handle saving JP2 file request message
*
* @param[in] connected_socket socket descriptor
* @param[in] cachelist cache list pointer
* @param[in] msgqueue message queue pointer
* @param[in] jpipstream address of caching jpipstream pointer
*/
void handle_JP2saveMSG( SOCKET connected_socket, cachelist_param_t *cachelist, msgqueue_param_t *msgqueue, Byte_t *jpipstream);
#endif /* !DEC_CLIENTMSG_HANDLER_H_ */

View File

@ -74,8 +74,11 @@ Byte_t * j2k_to_pnm( Byte_t *j2kstream, Byte8_t j2klen, ihdrbox_param_t **ihdrbo
/* open a byte stream */ /* open a byte stream */
cio = opj_cio_open((opj_common_ptr)dinfo, j2kstream, j2klen); cio = opj_cio_open((opj_common_ptr)dinfo, j2kstream, j2klen);
fprintf( stderr, "opj_decode dinfo:%p cio:%p\n", dinfo, cio);
/* decode the stream and fill the image structure */ /* decode the stream and fill the image structure */
image = opj_decode(dinfo, cio); image = opj_decode(dinfo, cio);
fprintf( stderr, "done\n");
if(!image) { if(!image) {
fprintf(stderr, "ERROR -> jp2_to_image: failed to decode image!\n"); fprintf(stderr, "ERROR -> jp2_to_image: failed to decode image!\n");
opj_destroy_decompress(dinfo); opj_destroy_decompress(dinfo);
@ -95,6 +98,7 @@ Byte_t * j2k_to_pnm( Byte_t *j2kstream, Byte8_t j2klen, ihdrbox_param_t **ihdrbo
if(dinfo) { if(dinfo) {
opj_destroy_decompress(dinfo); opj_destroy_decompress(dinfo);
} }
/* free image data structure */ /* free image data structure */
opj_image_destroy(image); opj_image_destroy(image);

View File

@ -45,109 +45,6 @@
#define logstream stderr #define logstream stderr
#endif //SERVER #endif //SERVER
/**
* REQUEST: target identification by target or tid request
*
* @param[in] query_param structured query
* @param[in] targetlist target list pointer
* @param[out] target address of target pointer
* @return if succeeded (true) or failed (false)
*/
bool identify_target( query_param_t query_param, targetlist_param_t *targetlist, target_param_t **target);
/**
* REQUEST: channel association
* this must be processed before any process
*
* @param[in] query_param structured query
* @param[in] sessionlist session list pointer
* @param[out] cursession address of the associated session pointer
* @param[out] curchannel address of the associated channel pointer
* @return if succeeded (true) or failed (false)
*/
bool associate_channel( query_param_t query_param,
sessionlist_param_t *sessionlist,
session_param_t **cursession,
channel_param_t **curchannel);
/**
* REQUEST: new channel (cnew) assignment
*
* @param[in] query_param structured query
* @param[in] sessionlist session list pointer
* @param[in] target requested target pointer
* @param[in,out] cursession address of the associated/opened session pointer
* @param[in,out] curchannel address of the associated/opened channel pointer
* @return if succeeded (true) or failed (false)
*/
bool open_channel( query_param_t query_param,
sessionlist_param_t *sessionlist,
target_param_t *target,
session_param_t **cursession,
channel_param_t **curchannel);
/**
* REQUEST: channel close (cclose)
*
* @param[in] query_param structured query
* @param[in] sessionlist session list pointer
* @param[in,out] cursession address of the session pointer of deleting channel
* @param[in,out] curchannel address of the deleting channel pointer
* @return if succeeded (true) or failed (false)
*/
bool close_channel( query_param_t query_param,
sessionlist_param_t *sessionlist,
session_param_t **cursession,
channel_param_t **curchannel);
/**
* REQUEST: view-window (fsiz)
*
* @param[in] query_param structured query
* @param[in] target requested target pointer
* @param[in,out] cursession associated session pointer
* @param[in,out] curchannel associated channel pointer
* @param[out] msgqueue address of the message queue pointer
* @return if succeeded (true) or failed (false)
*/
bool gene_JPIPstream( query_param_t query_param,
target_param_t *target,
session_param_t *cursession,
channel_param_t *curchannel,
msgqueue_param_t **msgqueue);
bool parse_JPIPrequest( query_param_t query_param,
sessionlist_param_t *sessionlist,
targetlist_param_t *targetlist,
msgqueue_param_t **msgqueue)
{
target_param_t *target = NULL;
session_param_t *cursession = NULL;
channel_param_t *curchannel = NULL;
if( query_param.target[0] != '\0' || query_param.tid[0] != '\0'){
if( !identify_target( query_param, targetlist, &target))
return false;
}
if( query_param.cid[0] != '\0'){
if( !associate_channel( query_param, sessionlist, &cursession, &curchannel))
return false;
}
if( query_param.cnew){
if( !open_channel( query_param, sessionlist, target, &cursession, &curchannel))
return false;
}
if( query_param.cclose[0][0] != '\0')
if( !close_channel( query_param, sessionlist, &cursession, &curchannel))
return false;
if( (query_param.fx > 0 && query_param.fy > 0) || query_param.box_type[0][0] != 0)
if( !gene_JPIPstream( query_param, target, cursession, curchannel, msgqueue))
return false;
return true;
}
bool identify_target( query_param_t query_param, targetlist_param_t *targetlist, target_param_t **target) bool identify_target( query_param_t query_param, targetlist_param_t *targetlist, target_param_t **target)
{ {

View File

@ -0,0 +1,112 @@
/*
* $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
* Copyright (c) 2011, Lucian Corlaciu, GSoC
* 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 JPIP_PARSER_H_
# define JPIP_PARSER_H_
#include "bool.h"
#include "query_parser.h"
#include "session_manager.h"
#include "target_manager.h"
#include "msgqueue_manager.h"
#include "channel_manager.h"
/**
* REQUEST: target identification by target or tid request
*
* @param[in] query_param structured query
* @param[in] targetlist target list pointer
* @param[out] target address of target pointer
* @return if succeeded (true) or failed (false)
*/
bool identify_target( query_param_t query_param, targetlist_param_t *targetlist, target_param_t **target);
/**
* REQUEST: channel association
* this must be processed before any process
*
* @param[in] query_param structured query
* @param[in] sessionlist session list pointer
* @param[out] cursession address of the associated session pointer
* @param[out] curchannel address of the associated channel pointer
* @return if succeeded (true) or failed (false)
*/
bool associate_channel( query_param_t query_param,
sessionlist_param_t *sessionlist,
session_param_t **cursession,
channel_param_t **curchannel);
/**
* REQUEST: new channel (cnew) assignment
*
* @param[in] query_param structured query
* @param[in] sessionlist session list pointer
* @param[in] target requested target pointer
* @param[in,out] cursession address of the associated/opened session pointer
* @param[in,out] curchannel address of the associated/opened channel pointer
* @return if succeeded (true) or failed (false)
*/
bool open_channel( query_param_t query_param,
sessionlist_param_t *sessionlist,
target_param_t *target,
session_param_t **cursession,
channel_param_t **curchannel);
/**
* REQUEST: channel close (cclose)
*
* @param[in] query_param structured query
* @param[in] sessionlist session list pointer
* @param[in,out] cursession address of the session pointer of deleting channel
* @param[in,out] curchannel address of the deleting channel pointer
* @return if succeeded (true) or failed (false)
*/
bool close_channel( query_param_t query_param,
sessionlist_param_t *sessionlist,
session_param_t **cursession,
channel_param_t **curchannel);
/**
* REQUEST: view-window (fsiz)
*
* @param[in] query_param structured query
* @param[in] target requested target pointer
* @param[in,out] cursession associated session pointer
* @param[in,out] curchannel associated channel pointer
* @param[out] msgqueue address of the message queue pointer
* @return if succeeded (true) or failed (false)
*/
bool gene_JPIPstream( query_param_t query_param,
target_param_t *target,
session_param_t *cursession,
channel_param_t *curchannel,
msgqueue_param_t **msgqueue);
#endif /* !JPIP_PARSER_H_ */

View File

@ -75,8 +75,8 @@ Byte_t * jpipstream_to_pnm( Byte_t *jpipstream, msgqueue_param_t *msgqueue, Byte
Byte8_t j2klen; Byte8_t j2klen;
j2kstream = recons_j2k( msgqueue, jpipstream, csn, fw, fh, &j2klen); j2kstream = recons_j2k( msgqueue, jpipstream, csn, fw, fh, &j2klen);
pnmstream = j2k_to_pnm( j2kstream, j2klen, ihdrbox); pnmstream = j2k_to_pnm( j2kstream, j2klen, ihdrbox);
free( j2kstream); free( j2kstream);
return pnmstream; return pnmstream;

View File

@ -0,0 +1,378 @@
/*
* $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 <stdlib.h>
#include "openjpip.h"
#include "jpip_parser.h"
#include "channel_manager.h"
#include <stdio.h>
#include "dec_clientmsg_handler.h"
#include "jpipstream_manager.h"
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include "jp2k_encoder.h"
server_record_t * init_JPIPserver()
{
server_record_t *record = (server_record_t *)malloc( sizeof(server_record_t));
record->sessionlist = gene_sessionlist();
record->targetlist = gene_targetlist();
return record;
}
void terminate_JPIPserver( server_record_t **rec)
{
delete_sessionlist( &(*rec)->sessionlist);
delete_targetlist( &(*rec)->targetlist);
free( *rec);
}
QR_t * parse_querystring( char *query_string)
{
QR_t *qr;
qr = (QR_t *)malloc( sizeof(QR_t));
qr->query = parse_query( query_string);
qr->msgqueue = NULL;
return qr;
}
bool process_JPIPrequest( server_record_t *rec, QR_t *qr)
{
target_param_t *target = NULL;
session_param_t *cursession = NULL;
channel_param_t *curchannel = NULL;
if( qr->query->target[0] != '\0' || qr->query->tid[0] != '\0'){
if( !identify_target( *(qr->query), rec->targetlist, &target))
return false;
}
if( qr->query->cid[0] != '\0'){
if( !associate_channel( *(qr->query), rec->sessionlist, &cursession, &curchannel))
return false;
}
if( qr->query->cnew){
if( !open_channel( *(qr->query), rec->sessionlist, target, &cursession, &curchannel))
return false;
}
if( qr->query->cclose[0][0] != '\0')
if( !close_channel( *(qr->query), rec->sessionlist, &cursession, &curchannel))
return false;
if( (qr->query->fx > 0 && qr->query->fy > 0) || qr->query->box_type[0][0] != 0)
if( !gene_JPIPstream( *(qr->query), target, cursession, curchannel, &qr->msgqueue))
return false;
return true;
}
void send_responsedata( QR_t *qr)
{
// Currently HTTP support only, find a way for TCP, UDP case
emit_stream_from_msgqueue( qr->msgqueue);
}
void end_QRprocess( server_record_t *rec, QR_t **qr)
{
// TODO: record client preferences if necessary
delete_query( &((*qr)->query));
delete_msgqueue( &((*qr)->msgqueue));
free( *qr);
}
void local_log( bool query, bool messages, bool sessions, bool targets, QR_t *qr, server_record_t *rec)
{
if( query)
print_queryparam( *qr->query);
if( messages)
print_msgqueue( qr->msgqueue);
if( sessions)
print_allsession( rec->sessionlist);
if( targets)
print_alltarget( rec->targetlist);
}
#ifndef SERVER
dec_server_record_t * init_dec_server()
{
dec_server_record_t *record = (dec_server_record_t *)malloc( sizeof(dec_server_record_t));
record->cachelist = gene_cachelist();
record->jpipstream = NULL;
record->jpipstreamlen = 0;
record->msgqueue = gene_msgqueue( true, NULL);
record->listening_socket = open_listeningsocket();
return record;
}
void terminate_dec_server( dec_server_record_t **rec)
{
delete_cachelist( &(*rec)->cachelist);
free( (*rec)->jpipstream);
if( (*rec)->msgqueue)
delete_msgqueue( &((*rec)->msgqueue));
if( close_socket( (*rec)->listening_socket) != 0)
perror("close");
free( *rec);
}
client_t accept_connection( dec_server_record_t *rec)
{
client_t client;
client = accept_socket( rec->listening_socket);
if( client == -1)
fprintf( stderr, "error: failed to connect to client\n");
return client;
}
bool handle_clientreq( client_t client, dec_server_record_t *rec)
{
bool quit = false;
msgtype_t msgtype = identify_clientmsg( client);
switch( msgtype){
case JPIPSTREAM:
handle_JPIPstreamMSG( client, rec->cachelist, &rec->jpipstream, &rec->jpipstreamlen, rec->msgqueue);
break;
case PNMREQ:
handle_PNMreqMSG( client, rec->jpipstream, rec->msgqueue, rec->cachelist);
break;
case XMLREQ:
handle_XMLreqMSG( client, rec->jpipstream, rec->cachelist);
break;
case TIDREQ:
handle_TIDreqMSG( client, rec->cachelist);
break;
case CIDREQ:
handle_CIDreqMSG( client, rec->cachelist);
break;
case CIDDST:
handle_dstCIDreqMSG( client, rec->cachelist);
break;
case JP2SAVE:
handle_JP2saveMSG( client, rec->cachelist, rec->msgqueue, rec->jpipstream);
break;
case QUIT:
quit = true;
save_codestream( rec->jpipstream, rec->jpipstreamlen, "jpt");
break;
case MSGERROR:
break;
}
printf("\t end of the connection\n\n");
if( close_socket(client) != 0){
perror("close");
return false;
}
if( quit)
return false;
return true;
}
jpip_dec_param_t * init_jpipdecoder( bool jp2)
{
jpip_dec_param_t *dec;
dec = (jpip_dec_param_t *)calloc( 1, sizeof(jpip_dec_param_t));
dec->msgqueue = gene_msgqueue( true, NULL);
if( jp2)
dec->metadatalist = gene_metadatalist();
return dec;
}
bool fread_jpip( char fname[], jpip_dec_param_t *dec)
{
int infd;
struct stat sb;
if(( infd = open( fname, O_RDONLY)) == -1){
fprintf( stderr, "file %s not exist\n", fname);
return false;
}
if( fstat( infd, &sb) == -1){
fprintf( stderr, "input file stream is broken\n");
return false;
}
dec->jpiplen = (Byte8_t)sb.st_size;
dec->jpipstream = (Byte_t *)malloc( dec->jpiplen);
if( read( infd, dec->jpipstream, dec->jpiplen) != dec->jpiplen){
fprintf( stderr, "file reading error\n");
free( dec->jpipstream);
return false;
}
close(infd);
return true;
}
void decode_jpip( jpip_dec_param_t *dec)
{
parse_JPIPstream( dec->jpipstream, dec->jpiplen, 0, dec->msgqueue);
if( dec->metadatalist){ // JP2 encoding
parse_metamsg( dec->msgqueue, dec->jpipstream, dec->jpiplen, dec->metadatalist);
dec->ihdrbox = gene_ihdrbox( dec->metadatalist, dec->jpipstream);
dec->jp2kstream = recons_jp2( dec->msgqueue, dec->jpipstream, dec->msgqueue->first->csn, &dec->jp2klen);
}
else // J2k encoding
// Notice: arguments fw, fh need to be set for LRCP, PCRL, CPRL
dec->jp2kstream = recons_j2k( dec->msgqueue, dec->jpipstream, dec->msgqueue->first->csn, 0, 0, &dec->jp2klen);
}
bool fwrite_jp2k( char fname[], jpip_dec_param_t *dec)
{
int outfd;
#ifdef _WIN32
if(( outfd = open( fname, O_WRONLY|O_CREAT, _S_IREAD | _S_IWRITE)) == -1){
#else
if(( outfd = open( fname, O_WRONLY|O_CREAT, S_IRWXU|S_IRWXG)) == -1){
#endif
fprintf( stderr, "file %s open error\n", fname);
return false;
}
if( write( outfd, dec->jp2kstream, dec->jp2klen) != dec->jp2klen)
fprintf( stderr, "j2k file write error\n");
close(outfd);
return true;
}
void output_log( bool messages, bool metadata, bool ihdrbox, jpip_dec_param_t *dec)
{
if( messages)
print_msgqueue( dec->msgqueue);
if( metadata)
print_allmetadata( dec->metadatalist);
if( ihdrbox){
printf("W*H: %d*%d\n", dec->ihdrbox->height, dec->ihdrbox->width);
printf("NC: %d, bpc: %d\n", dec->ihdrbox->nc, dec->ihdrbox->bpc);
}
}
void destroy_jpipdecoder( jpip_dec_param_t **dec)
{
free( (*dec)->jpipstream);
delete_msgqueue( &(*dec)->msgqueue);
if( (*dec)->metadatalist){
delete_metadatalist( &(*dec)->metadatalist);
free( (*dec)->ihdrbox);
}
free( (*dec)->jp2kstream);
free( *dec);
}
index_t * get_index_from_JP2file( int fd)
{
char *data;
// Check resource is a JP family file.
if( lseek( fd, 0, SEEK_SET)==-1){
fprintf( stderr, "Error: File broken (lseek error)\n");
return NULL;
}
data = (char *)malloc( 12); // size of header
if( read( fd, data, 12) != 12){
free( data);
fprintf( stderr, "Error: File broken (read error)\n");
return NULL;
}
if( *data || *(data + 1) || *(data + 2) ||
*(data + 3) != 12 || strncmp (data + 4, "jP \r\n\x87\n", 8)){
free( data);
fprintf( stderr, "Error: No JPEG 2000 Signature box in this file\n");
return NULL;
}
free( data);
return parse_jp2file( fd);
}
void destroy_index( index_t **idx)
{
delete_index( idx);
}
void output_index( index_t *index)
{
print_index( *index);
}
#endif //SERVER

View File

@ -0,0 +1,296 @@
/*
* $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 OPENJPIP_H_
# define OPENJPIP_H_
#include "session_manager.h"
#include "target_manager.h"
#include "query_parser.h"
#include "msgqueue_manager.h"
#include "bool.h"
#include "cache_manager.h"
#include "byte_manager.h"
#include "imgsock_manager.h"
#include "metadata_manager.h"
#include "ihdrbox_manager.h"
#include "index_manager.h"
#ifdef SERVER
#include "fcgi_stdio.h"
#define logstream FCGI_stdout
#else
#define FCGI_stdout stdout
#define FCGI_stderr stderr
#define logstream stderr
#endif //SERVER
/*
*==========================================================
* JPIP server API
*==========================================================
*/
//! Server static records
typedef struct server_record{
sessionlist_param_t *sessionlist; //!< list of session records
targetlist_param_t *targetlist; //!< list of target records
} server_record_t;
//! Query/response data for each client
typedef struct QR{
query_param_t *query;
msgqueue_param_t *msgqueue;
} QR_t;
/**
* Initialize the JPIP server
*
* @return intialized server record pointer
*/
server_record_t * init_JPIPserver();
/**
* Terminate the JPIP server
*
* @param[in] rec address of deleting server static record pointer
*/
void terminate_JPIPserver( server_record_t **rec);
/**
* 1st process per client request; parse query string
*
* @param[in] query_string request query string
* @return initialized query/response data pointer
*/
QR_t * parse_querystring( char *query_string);
/**
* 2nd process; process JPIP request and construct message queue
*
* @param[in] rec server static record pointer
* @param[in] qr query/response data pointer
* @return true if succeed, otherwise false
*/
bool process_JPIPrequest( server_record_t *rec, QR_t *qr);
/**
* 3rd process; send response data JPT/JPP-stream
*
* @param[in] qr query/response data pointer
*/
void send_responsedata( QR_t *qr);
/**
* 4th (last) process;
*
* @param[in] rec server static record pinter
* @param[in] qr address of query/response data pointer
*/
void end_QRprocess( server_record_t *rec, QR_t **qr);
#ifndef SERVER
/**
* Option for local tests; print out parameter values to logstream (stderr)
*
* @param[in] query true if query parameters are to be printed out
* @param[in] messages true if queue of messages is to be printed out
* @param[in] sessions true if session list is to be printed out
* @param[in] targets true if target list is to be printed out
* @param[in] qr query/response data pointer
* @param[in] rec server static record pinter
*/
void local_log( bool query, bool messages, bool sessions, bool targets, QR_t *qr, server_record_t *rec);
#endif //SERVER
/*
*==========================================================
* JPIP decoding server API
*==========================================================
*/
#ifndef SERVER
//! Decoding server static records
typedef struct dec_server_record{
cachelist_param_t *cachelist; //!< cache list
Byte_t *jpipstream; //!< JPT/JPP stream
int jpipstreamlen; //!< length of jpipstream
msgqueue_param_t *msgqueue; //!< parsed message queue of jpipstream
SOCKET listening_socket; //!< listenning socket
} dec_server_record_t;
//! Client socket identifier
typedef SOCKET client_t;
/**
* Initialize the image decoding server
*
* @return intialized decoding server record pointer
*/
dec_server_record_t * init_dec_server();
/**
* Terminate the image decoding server
*
* @param[in] rec address of deleting decoding server static record pointer
*/
void terminate_dec_server( dec_server_record_t **rec);
/**
* Accept client connection
*
* @param[in] rec decoding server static record pointer
* @return client socket ID, -1 if failed
*/
client_t accept_connection( dec_server_record_t *rec);
/**
* Handle client request
*
* @param[in] client client socket ID
* @param[in] rec decoding server static record pointer
* @return true if succeed
*/
bool handle_clientreq( client_t client, dec_server_record_t *rec);
#endif //SERVER
/*
*==========================================================
* JPIP tool API
*==========================================================
*/
#ifndef SERVER
/*
* jpip to JP2 or J2K
*/
//! JPIP decoding parameters
typedef struct jpip_dec_param{
Byte_t *jpipstream; //!< JPT/JPP-stream
Byte8_t jpiplen; //!< length of jpipstream
msgqueue_param_t *msgqueue; //!< message queue
metadatalist_param_t *metadatalist; //!< metadata list going into JP2 file
ihdrbox_param_t *ihdrbox; //!< ihdr box going into JP2 file
Byte_t *jp2kstream; //!< J2K codestream or JP2 file codestream
Byte8_t jp2klen; //!< length of j2kstream or JP2 file
} jpip_dec_param_t;
/**
* Initialize jpip decoder
*
* @param[in] jp2 true in case of jp2 file encoding, else j2k file encoding
* @return JPIP decoding parameters pointer
*/
jpip_dec_param_t * init_jpipdecoder( bool jp2);
/**
* Destroy jpip decoding parameters
*
* @param[in] dec address of JPIP decoding parameters pointer
*/
void destroy_jpipdecoder( jpip_dec_param_t **dec);
/**
* Read jpip codestream from a file
*
* @param[in] fname file name
* @param[in] dec JPIP decoding parameters pointer
* @return true if succeed
*/
bool fread_jpip( char fname[], jpip_dec_param_t *dec);
/**
* Decode jpip codestream
*
* @param[in] dec JPIP decoding parameters pointer
*/
void decode_jpip( jpip_dec_param_t *dec);
/**
* Write J2K/JP2 codestream to a file
*
* @param[in] fname file name
* @param[in] dec JPIP decoding parameters pointer
* @return true if succeed
*/
bool fwrite_jp2k( char fname[], jpip_dec_param_t *dec);
/**
* Option; print out parameter values to stderr
*
* @param[in] messages true if queue of messages is to be printed out
* @param[in] metadata true if metadata is to be printed out
* @param[in] ihdrbox true if image header data is to be printed out
* @param[in] dec JPIP decoding parameters pointer
*/
void output_log( bool messages, bool metadata, bool ihdrbox, jpip_dec_param_t *dec);
/*
* test the format of index (cidx) box in JP2 file
*/
//! Redefinition of index parameters
typedef index_param_t index_t;
/**
* Parse JP2 file and get index information from cidx box inside
*
* @param[in] fd file descriptor of the JP2 file
* @return pointer to the generated structure of index parameters
*/
index_t * get_index_from_JP2file( int fd);
/**
* Destroy index parameters
*
* @param[in,out] idx addressof the index pointer
*/
void destroy_index( index_t **idx);
/**
* print index parameters
*
* @param[in] index index parameters
*/
void output_index( index_t *index);
#endif //SERVER
#endif /* !OPENJPIP_H_ */

View File

@ -53,11 +53,11 @@
/** /**
* initialize query parameters * Get initialized query parameters
* *
* @param[in,out] query_param query parameters * @return initial query parameters
*/ */
void init_queryparam( query_param_t *query_param); query_param_t * get_initquery();
/* /*
* get a pair of field name and value from the string starting fieldname=fieldval&... format * get a pair of field name and value from the string starting fieldname=fieldval&... format
@ -89,11 +89,12 @@ void parse_comps( char *field, query_param_t *query_param);
//! maximum length of field value //! maximum length of field value
#define MAX_LENOFFIELDVAL 128 #define MAX_LENOFFIELDVAL 128
void parse_query( char *query_string, query_param_t *query_param) query_param_t * parse_query( char *query_string)
{ {
query_param_t *query_param;
char *pquery, fieldname[MAX_LENOFFIELDNAME], fieldval[MAX_LENOFFIELDVAL]; char *pquery, fieldname[MAX_LENOFFIELDNAME], fieldval[MAX_LENOFFIELDVAL];
init_queryparam( query_param); query_param = get_initquery();
pquery = query_string; pquery = query_string;
@ -146,40 +147,46 @@ void parse_query( char *query_string, query_param_t *query_param)
sscanf( fieldval, "%d", &query_param->len); sscanf( fieldval, "%d", &query_param->len);
} }
} }
return query_param;
} }
void init_queryparam( query_param_t *query_param) query_param_t * get_initquery()
{ {
query_param_t *query;
int i; int i;
query_param->target[0] = '\0'; query = (query_param_t *)malloc( sizeof(query_param_t));
query_param->tid[0] = '\0';
query_param->fx = -1; query->target[0] = '\0';
query_param->fy = -1; query->tid[0] = '\0';
query_param->rx = -1; query->fx = -1;
query_param->ry = -1; query->fy = -1;
query_param->rw = -1; query->rx = -1;
query_param->rh = -1; query->ry = -1;
query_param->layers = -1; query->rw = -1;
query_param->lastcomp = -1; query->rh = -1;
query_param->comps = NULL; query->layers = -1;
query_param->cid[0] = '\0'; query->lastcomp = -1;
query_param->cnew = false; query->comps = NULL;
memset( query_param->cclose, 0, MAX_NUMOFCCLOSE*MAX_LENOFCID); query->cid[0] = '\0';
memset( query_param->box_type, 0, MAX_NUMOFBOX*4); query->cnew = false;
memset( query_param->limit, 0, MAX_NUMOFBOX*sizeof(int)); memset( query->cclose, 0, MAX_NUMOFCCLOSE*MAX_LENOFCID);
memset( query->box_type, 0, MAX_NUMOFBOX*4);
memset( query->limit, 0, MAX_NUMOFBOX*sizeof(int));
for( i=0; i<MAX_NUMOFBOX; i++){ for( i=0; i<MAX_NUMOFBOX; i++){
query_param->w[i] = false; query->w[i] = false;
query_param->s[i] = false; query->s[i] = false;
query_param->g[i] = false; query->g[i] = false;
query_param->a[i] = false; query->a[i] = false;
query_param->priority[i] = false; query->priority[i] = false;
} }
query_param->root_bin = 0; query->root_bin = 0;
query_param->max_depth = -1; query->max_depth = -1;
query_param->metadata_only = false; query->metadata_only = false;
query_param->return_type = UNKNOWN; query->return_type = UNKNOWN;
query_param->len = -1; query->len = -1;
return query;
} }
@ -376,3 +383,9 @@ void parse_comps( char *field, query_param_t *query_param)
if(aux!=-1) if(aux!=-1)
query_param->comps[aux] = true; query_param->comps[aux] = true;
} }
void delete_query( query_param_t **query)
{
free((*query)->comps);
free( *query);
}

View File

@ -60,7 +60,7 @@ typedef struct query_param{
int rx, ry, rw, rh; //!< roi region int rx, ry, rw, rh; //!< roi region
int layers; //!< quality layers int layers; //!< quality layers
int lastcomp; //!< last component number int lastcomp; //!< last component number
bool *comps; //!< components for jpp-stream, null means all components bool *comps; //!< components (dynamic array) for jpp-stream, null means all components
char cid[MAX_LENOFCID]; //!< channel identifier char cid[MAX_LENOFCID]; //!< channel identifier
bool cnew; //!< if there is new channel request(true) or not (false) bool cnew; //!< if there is new channel request(true) or not (false)
char cclose[MAX_NUMOFCCLOSE][MAX_LENOFCID]; //!< closing channel identifiers char cclose[MAX_NUMOFCCLOSE][MAX_LENOFCID]; //!< closing channel identifiers
@ -83,9 +83,9 @@ typedef struct query_param{
* parse query * parse query
* *
* @param[in] query_string request query string * @param[in] query_string request query string
* @param[out] query_param query parameters * @return pointer to query parameters
*/ */
void parse_query( char *query_string, query_param_t *query_param); query_param_t * parse_query( char *query_string);
/** /**
* print query parameters * print query parameters
@ -94,4 +94,12 @@ void parse_query( char *query_string, query_param_t *query_param);
*/ */
void print_queryparam( query_param_t query_param); void print_queryparam( query_param_t query_param);
/**
* delete query
*
* @param[in] query address of the deleting query pointer
*/
void delete_query( query_param_t **query);
#endif /* !QUERY_PARSER_H_ */ #endif /* !QUERY_PARSER_H_ */

View File

@ -1 +0,0 @@
ADD_SUBDIRECTORY(opj_dec_server)

View File

@ -1,3 +0,0 @@
MAINTAINERCLEANFILES = Makefile.in
SUBDIRS = opj_dec_server

View File

@ -1,29 +0,0 @@
SET(OPJ_DEC_SERVER_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/cache_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/opj_dec_server.c
${CMAKE_CURRENT_SOURCE_DIR}/jp2k_decoder.c
${CMAKE_CURRENT_SOURCE_DIR}/imgsock_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/jpipstream_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/dec_clientmsg_handler.c
)
INCLUDE_DIRECTORIES(
${OPENJPEG_SOURCE_DIR}/libopenjpeg
${OPENJPEG_SOURCE_DIR}/applications/jpip/libopenjpip
)
# Build executable
ADD_EXECUTABLE(opj_dec_server ${OPJ_DEC_SERVER_SRCS})
TARGET_LINK_LIBRARIES(opj_dec_server openjpip_local ${OPENJPEG_LIBRARY_NAME})
# On unix you need to link to the math library:
IF(UNIX)
TARGET_LINK_LIBRARIES(opj_dec_server m)
ENDIF(UNIX)
# Install exe
INSTALL(TARGETS opj_dec_server
EXPORT OpenJPEGTargets
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
)

View File

@ -1,32 +0,0 @@
MAINTAINERCLEANFILES = Makefile.in
bin_PROGRAMS = opj_dec_server
opj_dec_server_CPPFLAGS = \
-I. \
-I$(top_srcdir)/applications/jpip/opj_server \
-I$(top_builddir)/applications/jpip/opj_server \
-I$(top_srcdir)/applications/jpip/libopenjpip \
-I$(top_builddir)/applications/jpip/libopenjpip \
-I$(top_srcdir)/libopenjpeg \
-I$(top_builddir)/libopenjpeg \
@FCGI_CFLAGS@ \
-DSERVER
opj_dec_server_CFLAGS =
opj_dec_server_LDADD = $(top_builddir)/applications/jpip/libopenjpip/libopenjpip_server.la $(top_builddir)/libopenjpeg/libopenjpeg.la @FCGI_LIBS@ -lm
opj_dec_server_SOURCES = \
cache_manager.c \
cache_manager.h \
imgsock_manager.c \
imgsock_manager.h \
jp2k_decoder.c \
dec_clientmsg_handler.c \
dec_clientmsg_handler.h \
jp2k_decoder.h \
jpipstream_manager.c \
jpipstream_manager.h \
opj_dec_server.c
install-data-hook:
@echo -e " (B)\t$(bindir)/opj_dec_server$(EXEEXT)" >> $(top_builddir)/report.txt

View File

@ -1,17 +0,0 @@
J2KINCDIR = ../../../../libopenjpeg
J2KLIBDIR = $(J2KINCDIR)/.libs
JPIPLIBDIR = ../../libopenjpip
LIBFNAME = $(JPIPLIBDIR)/libopenjpip_local.a $(J2KLIBDIR)/libopenjpeg.a
CFLAGS = -O3 -Wall -I$(JPIPLIBDIR) -I$(J2KINCDIR)
LDFLAGS = -L$(JPIPLIBDIR) -L$(J2KLIBDIR) -lm -lopenjpip_local
#-lws2_32
ALL = opj_dec_server
all: $(ALL)
opj_dec_server: opj_dec_server.o jp2k_decoder.o imgsock_manager.o jpipstream_manager.o cache_manager.o dec_clientmsg_handler.o $(LIBFNAME)
$(CC) $(CFLAGS) $< jp2k_decoder.o imgsock_manager.o jpipstream_manager.o cache_manager.o dec_clientmsg_handler.o $(LDFLAGS) $(LIBFNAME) -o $@
clean:
rm -f $(ALL) *.o *~

View File

@ -1 +0,0 @@
opj_viewer-20111018.jar

View File

@ -1 +0,0 @@
opj_viewer_xerces-20111010.jar

View File

@ -1,30 +0,0 @@
# Headers file are located here:
INCLUDE_DIRECTORIES(
${OPENJPEG_SOURCE_DIR}/applications/jpip/libopenjpip
${FCGI_INCLUDE_DIRNAME}
)
SET(OPJ_SERVER_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/opj_server.c
${CMAKE_CURRENT_SOURCE_DIR}/query_parser.c
${CMAKE_CURRENT_SOURCE_DIR}/channel_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/session_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/jpip_parser.c
)
# Build executable
ADD_DEFINITIONS(-DSERVER)
ADD_EXECUTABLE(opj_server ${OPJ_SERVER_SRCS})
TARGET_LINK_LIBRARIES(opj_server openjpip_server ${FCGI_LIBNAME})
# On unix you need to link to the math library:
IF(UNIX)
TARGET_LINK_LIBRARIES(opj_server m)
ENDIF(UNIX)
# Install exe
INSTALL(TARGETS opj_server
EXPORT OpenJPEGTargets
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
)

View File

@ -1,28 +0,0 @@
MAINTAINERCLEANFILES = Makefile.in
bin_PROGRAMS = opj_server
opj_server_CPPFLAGS = \
-I. \
-I$(top_srcdir)/applications/jpip/opj_server \
-I$(top_builddir)/applications/jpip/opj_server \
-I$(top_srcdir)/applications/jpip/libopenjpip \
-I$(top_builddir)/applications/jpip/libopenjpip \
@FCGI_CFLAGS@ \
-DSERVER \
-DQUIT_SIGNAL=\"quitJPIP\"
opj_server_CFLAGS =
opj_server_LDADD = $(top_builddir)/applications/jpip/libopenjpip/libopenjpip_server.la @FCGI_LIBS@ -lm
opj_server_SOURCES = \
channel_manager.c \
opj_server.c \
query_parser.c \
session_manager.c \
jpip_parser.c \
channel_manager.h \
query_parser.h \
session_manager.h \
jpip_parser.h
install-data-hook:
@echo -e " (B)\t$(bindir)/opj_server$(EXEEXT)" >> $(top_builddir)/report.txt

View File

@ -1,15 +0,0 @@
LIBDIR = ../libopenjpip
LIBFNAME = $(LIBDIR)/libopenjpip_server.a
CFLAGS = -O3 -Wall -m32 -DSERVER -DQUIT_SIGNAL=\"quitJPIP\" -I$(LIBDIR)
LDFLAGS = -L$(LIBDIR) -lm -lfcgi -lopenjpip_server
ALL = opj_server
all: $(ALL)
opj_server: opj_server.o query_parser.o channel_manager.o session_manager.o jpip_parser.o $(LIBFNAME)
$(CC) $(CFLAGS) $< query_parser.o channel_manager.o session_manager.o jpip_parser.o $(LDFLAGS) -o $@
clean:
rm -f $(ALL) *.o *~

View File

@ -1,37 +0,0 @@
INCLUDE_DIRECTORIES(
../libopenjpip
)
ADD_EXECUTABLE(jpip_to_j2k jpip_to_j2k.c)
TARGET_LINK_LIBRARIES(jpip_to_j2k openjpip_local)
IF(UNIX)
TARGET_LINK_LIBRARIES(jpip_to_j2k m)
ENDIF(UNIX)
# Install exe
INSTALL(TARGETS jpip_to_j2k
EXPORT OpenJPEGTargets
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
)
ADD_EXECUTABLE(jpip_to_jp2 jpip_to_jp2.c)
TARGET_LINK_LIBRARIES(jpip_to_jp2 openjpip_local)
IF(UNIX)
TARGET_LINK_LIBRARIES(jpip_to_jp2 m)
ENDIF(UNIX)
# Install exe
INSTALL(TARGETS jpip_to_jp2
EXPORT OpenJPEGTargets
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
)
ADD_EXECUTABLE(test_index test_index.c)
TARGET_LINK_LIBRARIES(test_index openjpip_local)
IF(UNIX)
TARGET_LINK_LIBRARIES(test_index m)
ENDIF(UNIX)
# Install exe
INSTALL(TARGETS test_index
EXPORT OpenJPEGTargets
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
)

View File

@ -1,47 +0,0 @@
MAINTAINERCLEANFILES = Makefile.in
bin_PROGRAMS = jpip_to_jp2 jpip_to_j2k test_index addXMLinJP2
jpip_to_jp2_CPPFLAGS = \
-I. \
-I$(top_srcdir)/applications/jpip/libopenjpip \
-I$(top_builddir)/applications/jpip/libopenjpip \
-I$(top_srcdir)/applications/jpip/libopenjpip/tools \
-I$(top_builddir)/applications/jpip/libopenjpip/tools
jpip_to_jp2_CFLAGS =
jpip_to_jp2_LDADD = $(top_builddir)/applications/jpip/libopenjpip/libopenjpip_local.la
jpip_to_jp2_SOURCES = jpip_to_jp2.c
jpip_to_j2k_CPPFLAGS = \
-I. \
-I$(top_srcdir)/applications/jpip/libopenjpip \
-I$(top_builddir)/applications/jpip/libopenjpip \
-I$(top_srcdir)/applications/jpip/libopenjpip/tools \
-I$(top_builddir)/applications/jpip/libopenjpip/tools
jpip_to_j2k_CFLAGS =
jpip_to_j2k_LDADD = $(top_builddir)/applications/jpip/libopenjpip/libopenjpip_local.la
jpip_to_j2k_SOURCES = jpip_to_j2k.c
test_index_CPPFLAGS = \
-I. \
-I$(top_srcdir)/applications/jpip/libopenjpip \
-I$(top_builddir)/applications/jpip/libopenjpip \
-I$(top_srcdir)/applications/jpip/libopenjpip/tools \
-I$(top_builddir)/applications/jpip/libopenjpip/tools
test_index_CFLAGS =
test_index_LDADD = $(top_builddir)/applications/jpip/libopenjpip/libopenjpip_local.la
test_index_SOURCES = test_index.c
addXMLinJP2_CPPFLAGS = \
-I. \
-I$(top_srcdir)/applications/jpip/libopenjpip/tools \
-I$(top_builddir)/applications/jpip/libopenjpip/tools
addXMLinJP2_CFLAGS =
addXMLinJP2_LDADD = $(top_builddir)/applications/jpip/libopenjpip/libopenjpip_local.la
addXMLinJP2_SOURCES = addXMLinJP2.c
install-data-hook:
@echo -e " (B)\t$(bindir)/jpip_to_jp2$(EXEEXT)" >> $(top_builddir)/report.txt
@echo -e " (B)\t$(bindir)/jpip_to_j2k$(EXEEXT)" >> $(top_builddir)/report.txt
@echo -e " (B)\t$(bindir)/test_index$(EXEEXT)" >> $(top_builddir)/report.txt
@echo -e " (B)\t$(bindir)/addXMLinJP2$(EXEEXT)" >> $(top_builddir)/report.txt

View File

@ -1,20 +0,0 @@
LIBDIR = ../libopenjpip
LIBFNAME = $(LIBDIR)/libopenjpip_local.a
CFLAGS = -O3 -Wall -I$(LIBDIR)
LDFLAGS = -L$(LIBDIR) -lm -lopenjpip_local
ALL = jpip_to_jp2 jpip_to_j2k test_index addXMLinJP2
all: $(ALL)
jpip_to_jp2: jpip_to_jp2.o $(LIBFNAME)
$(CC) $(CFLAGS) $< $(LDFLAGS) -o $@
jpip_to_j2k: jpip_to_j2k.o $(LIBFNAME)
$(CC) $(CFLAGS) $< $(LDFLAGS) -o $@
test_index: test_index.o $(LIBFNAME)
$(CC) $(CFLAGS) $< $(LDFLAGS) -o $@
clean:
rm -f $(ALL) *.o *~

View File

@ -1,114 +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 jpip_to_j2k is a program to convert JPT- JPP- stream to J2K file
*
* \section impinst Implementing instructions
* This program takes two arguments. \n
* -# Input JPT or JPP file
* -# Output J2K file\n
* % ./jpip_to_j2k input.jpt output.j2k
* or
* % ./jpip_to_j2k input.jpp output.j2k
*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include "msgqueue_manager.h"
#include "jp2k_encoder.h"
int main(int argc,char *argv[])
{
msgqueue_param_t *msgqueue;
int infd, outfd;
Byte8_t jpiplen, j2klen;
struct stat sb;
Byte_t *jpipstream, *j2kstream;
if( argc < 3){
fprintf( stderr, "Too few arguments:\n");
fprintf( stderr, " - input jpt or jpp file\n");
fprintf( stderr, " - output j2k file\n");
return -1;
}
if(( infd = open( argv[1], O_RDONLY)) == -1){
fprintf( stderr, "file %s not exist\n", argv[1]);
return -1;
}
if( fstat( infd, &sb) == -1){
fprintf( stderr, "input file stream is broken\n");
return -1;
}
jpiplen = (Byte8_t)sb.st_size;
jpipstream = (Byte_t *)malloc( jpiplen);
if( read( infd, jpipstream, jpiplen) != jpiplen){
fprintf( stderr, "file reading error\n");
free( jpipstream);
return -1;
}
close(infd);
msgqueue = gene_msgqueue( true, NULL);
parse_JPIPstream( jpipstream, jpiplen, 0, msgqueue);
//print_msgqueue( msgqueue);
// arguments fw, fh need to be set for LRCP, PCRL, CPRL
j2kstream = recons_j2k( msgqueue, jpipstream, msgqueue->first->csn, 0, 0, &j2klen);
delete_msgqueue( &msgqueue);
free( jpipstream);
#ifdef _WIN32
if(( outfd = open( argv[2], O_WRONLY|O_CREAT, _S_IREAD | _S_IWRITE)) == -1){
#else
if(( outfd = open( argv[2], O_WRONLY|O_CREAT, S_IRWXU|S_IRWXG)) == -1){
#endif
fprintf( stderr, "file %s open error\n", argv[2]);
return -1;
}
if( write( outfd, j2kstream, j2klen) != j2klen)
fprintf( stderr, "j2k file write error\n");
free( j2kstream);
close(outfd);
return 0;
}

View File

@ -1,130 +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 jpip_to_jp2 is a program to convert JPT- JPP- stream to JP2 file
*
* \section impinst Implementing instructions
* This program takes two arguments. \n
* -# Input JPT or JPP file
* -# Output JP2 file\n
* % ./jpip_to_jp2 input.jpt output.jp2
* or
* % ./jpip_to_jp2 input.jpp output.jp2
*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include "msgqueue_manager.h"
#include "byte_manager.h"
#include "ihdrbox_manager.h"
#include "metadata_manager.h"
#include "jp2k_encoder.h"
int main(int argc,char *argv[])
{
msgqueue_param_t *msgqueue;
int infd, outfd;
Byte8_t jpiplen, jp2len;
struct stat sb;
Byte_t *jpipstream, *jp2stream;
metadatalist_param_t *metadatalist;
ihdrbox_param_t *ihdrbox;
if( argc < 3){
fprintf( stderr, "Too few arguments:\n");
fprintf( stderr, " - input jpt or jpp file\n");
fprintf( stderr, " - output jp2 file\n");
return -1;
}
if(( infd = open( argv[1], O_RDONLY)) == -1){
fprintf( stderr, "file %s not exist\n", argv[1]);
return -1;
}
if( fstat( infd, &sb) == -1){
fprintf( stderr, "input file stream is broken\n");
return -1;
}
jpiplen = (Byte8_t)sb.st_size;
jpipstream = (Byte_t *)malloc( jpiplen);
if( read( infd, jpipstream, jpiplen) != jpiplen){
fprintf( stderr, "file reading error\n");
free( jpipstream);
return -1;
}
close(infd);
metadatalist = gene_metadatalist();
msgqueue = gene_msgqueue( true, NULL);
parse_JPIPstream( jpipstream, jpiplen, 0, msgqueue);
parse_metamsg( msgqueue, jpipstream, jpiplen, metadatalist);
print_msgqueue( msgqueue);
//print_allmetadata( metadatalist);
ihdrbox = gene_ihdrbox( metadatalist, jpipstream);
printf("W*H: %d*%d\n", ihdrbox->height, ihdrbox->width);
printf("NC: %d, bpc: %d\n", ihdrbox->nc, ihdrbox->bpc);
jp2stream = recons_jp2( msgqueue, jpipstream, msgqueue->first->csn, &jp2len);
#ifdef _WIN32
if(( outfd = open( argv[2], O_WRONLY|O_CREAT, _S_IREAD | _S_IWRITE)) == -1){
#else
if(( outfd = open( argv[2], O_WRONLY|O_CREAT, S_IRWXU|S_IRWXG)) == -1){
#endif
fprintf( stderr, "file %s open error\n", argv[2]);
return -1;
}
if( write( outfd, jp2stream, jp2len) != jp2len)
fprintf( stderr, "jp2 file write error\n");
//print_msgqueue( msgqueue);
free( ihdrbox);
free( jp2stream);
close(outfd);
delete_msgqueue( &msgqueue);
delete_metadatalist( &metadatalist);
free( jpipstream);
return 0;
}

View File

@ -0,0 +1,38 @@
# Headers file are located here:
INCLUDE_DIRECTORIES(
${OPENJPEG_SOURCE_DIR}/applications/jpip/libopenjpip
${FCGI_INCLUDE_DIRNAME}
)
SET(OPJ_SERVER_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/opj_server.c
)
# Build executable
ADD_DEFINITIONS(-DSERVER -DQUIT_SIGNAL="quitJPIP")
#
ADD_EXECUTABLE(opj_server ${OPJ_SERVER_SRCS})
TARGET_LINK_LIBRARIES(opj_server openjpip_server ${FCGI_LIBNAME})
# On unix you need to link to the math library:
IF(UNIX)
TARGET_LINK_LIBRARIES(opj_server m)
ENDIF(UNIX)
# Install exe
INSTALL(TARGETS opj_server
EXPORT OpenJPEGTargets
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
)
#
REMOVE_DEFINITIONS(-DSERVER -DQUIT_SIGNAL="quitJPIP")
#
FOREACH(exe opj_dec_server jpip_to_jp2 jpip_to_j2k test_index)
#
ADD_EXECUTABLE(${exe} ${exe}.c)
TARGET_LINK_LIBRARIES(${exe} openjpip_local)
INSTALL(TARGETS ${exe}
EXPORT OpenJPEGTargets
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
)
ENDFOREACH(exe)

View File

@ -0,0 +1,59 @@
MAINTAINERCLEANFILES = Makefile.in
bin_PROGRAMS = opj_server opj_dec_server jpip_to_jp2 jpip_to_j2k test_index
opj_server_CPPFLAGS = \
@FCGI_CFLAGS@ \
-I. \
-I$(top_srcdir)/applications/jpip/libopenjpip \
-I$(top_builddir)/applications/jpip/libopenjpip
#
opj_server_CFLAGS = -DServer -DQUIT_SIGNAL=\"quitJPIP\"
#
opj_server_LDADD = $(top_builddir)/applications/jpip/libopenjpip/libopenjpip_server.la @FCGI_LIBS@ -lm
#
opj_server_SOURCES = \
opj_server.c
#-------------
opj_dec_server_CPPFLAGS = \
-I. \
-I$(top_srcdir)/applications/jpip/libopenjpip \
-I$(top_builddir)/applications/jpip/libopenjpip
#
opj_dec_server_CFLAGS =
opj_dec_server_LDADD = $(top_builddir)/applications/jpip/libopenjpip/libopenjpip_local.la
opj_dec_server_SOURCES = opj_dec_server.c
#-------------
jpip_to_jp2_CPPFLAGS = \
-I. \
-I$(top_srcdir)/applications/jpip/libopenjpip \
-I$(top_builddir)/applications/jpip/libopenjpip
#
jpip_to_jp2_CFLAGS =
jpip_to_jp2_LDADD = $(top_builddir)/applications/jpip/libopenjpip/libopenjpip_local.la
jpip_to_jp2_SOURCES = jpip_to_jp2.c
#-------------
jpip_to_j2k_CPPFLAGS = \
-I. \
-I$(top_srcdir)/applications/jpip/libopenjpip \
-I$(top_builddir)/applications/jpip/libopenjpip
#
jpip_to_j2k_CFLAGS =
jpip_to_j2k_LDADD = $(top_builddir)/applications/jpip/libopenjpip/libopenjpip_local.la
jpip_to_j2k_SOURCES = jpip_to_j2k.c
#-------------
test_index_CPPFLAGS = \
-I. \
-I$(top_srcdir)/applications/jpip/libopenjpip \
-I$(top_builddir)/applications/jpip/libopenjpip
#
test_index_CFLAGS =
test_index_LDADD = $(top_builddir)/applications/jpip/libopenjpip/libopenjpip_local.la
test_index_SOURCES = test_index.c
#-------------
install-data-hook:
@echo -e " (B)\t$(bindir)/opj_server$(EXEEXT)" >> $(top_builddir)/report.txt
@echo -e " (B)\t$(bindir)/opj_dec_server$(EXEEXT)" >> $(top_builddir)/report.txt
@echo -e " (B)\t$(bindir)/jpip_to_jp2$(EXEEXT)" >> $(top_builddir)/report.txt
@echo -e " (B)\t$(bindir)/jpip_to_j2k$(EXEEXT)" >> $(top_builddir)/report.txt
@echo -e " (B)\t$(bindir)/test_index$(EXEEXT)" >> $(top_builddir)/report.txt

View File

@ -0,0 +1,33 @@
JPIPLIBDIR = ../libopenjpip
SLIBFNAME = $(JPIPLIBDIR)/libopenjpip_server.a
SCFLAGS = -O3 -Wall -m32 -I$(JPIPLIBDIR) -DSERVER -DQUIT_SIGNAL=\"quitJPIP\"
SLDFLAGS = -L$(JPIPLIBDIR) -lm -lfcgi -lopenjpip_server
J2KINCDIR = ../../../libopenjpeg
J2KLIBDIR = $(J2KINCDIR)/.libs
LIBFNAME = $(JPIPLIBDIR)/libopenjpip_local.a $(J2KLIBDIR)/libopenjpeg.a
CFLAGS = -O3 -Wall -I$(JPIPLIBDIR)
LDFLAGS = -L$(JPIPLIBDIR) -L$(J2KLIBDIR) -lm -lopenjpip_local
ALL = opj_server opj_dec_server jpip_to_jp2 jpip_to_j2k test_index addXMLinJP2
all: $(ALL)
opj_server: opj_server.c $(SLIBFNAME)
$(CC) $(SCFLAGS) $< $(SLDFLAGS) $(SLIBFNAME) -o $@
opj_dec_server: opj_dec_server.c $(LIBFNAME)
$(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBFNAME) -o $@
jpip_to_jp2: jpip_to_jp2.c $(LIBFNAME)
$(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBFNAME) -o $@
jpip_to_j2k: jpip_to_j2k.c $(LIBFNAME)
$(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBFNAME) -o $@
test_index: test_index.c $(LIBFNAME)
$(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBFNAME) -o $@
clean:
rm -f $(ALL) *.o *~

View File

@ -4,7 +4,6 @@
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2011, Professor Benoit Macq * Copyright (c) 2002-2011, Professor Benoit Macq
* Copyright (c) 2010-2011, Kaori Hagihara * Copyright (c) 2010-2011, Kaori Hagihara
* Copyright (c) 2011, Lucian Corlaciu, GSoC
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -29,28 +28,45 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef JPIP_PARSER_H_ /*! \file
# define JPIP_PARSER_H_ * \brief jpip_to_j2k is a program to convert JPT- JPP- stream to J2K file
#include "bool.h"
#include "query_parser.h"
#include "session_manager.h"
#include "target_manager.h"
#include "msgqueue_manager.h"
/**
* parse JPIP request
* *
* @param[in] query_param structured query * \section impinst Implementing instructions
* @param[in] sessionlist session list pointer * This program takes two arguments. \n
* @param[in] targetlist target list pointer * -# Input JPT or JPP file
* @param[in,out] msgqueue address of the message queue pointer * -# Output J2K file\n
* @return if succeeded (true) or failed (false) * % ./jpip_to_j2k input.jpt output.j2k
* or
* % ./jpip_to_j2k input.jpp output.j2k
*/ */
bool parse_JPIPrequest( query_param_t query_param,
sessionlist_param_t *sessionlist,
targetlist_param_t *targetlist,
msgqueue_param_t **msgqueue);
#include <stdio.h>
#include "openjpip.h"
#endif /* !JPIP_PARSER_H_ */ int main(int argc,char *argv[])
{
jpip_dec_param_t *dec;
if( argc < 3){
fprintf( stderr, "Too few arguments:\n");
fprintf( stderr, " - input jpt or jpp file\n");
fprintf( stderr, " - output j2k file\n");
return -1;
}
dec = init_jpipdecoder( false);
if(!( fread_jpip( argv[1], dec)))
return -1;
decode_jpip( dec);
if(!( fwrite_jp2k( argv[2], dec)))
return -1;
output_log( true, false, false, dec);
destroy_jpipdecoder( &dec);
return 0;
}

View File

@ -4,7 +4,6 @@
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2011, Professor Benoit Macq * Copyright (c) 2002-2011, Professor Benoit Macq
* Copyright (c) 2010-2011, Kaori Hagihara * Copyright (c) 2010-2011, Kaori Hagihara
* Copyright (c) 2011, Lucian Corlaciu, GSoC
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -29,25 +28,45 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef DEC_CLIENTMSG_HANDLER_H_ /*! \file
# define DEC_CLIENTMSG_HANDLER_H_ * \brief jpip_to_jp2 is a program to convert JPT- JPP- stream to JP2 file
#include "bool.h"
#include "imgsock_manager.h"
#include "cache_manager.h"
#include "byte_manager.h"
#include "msgqueue_manager.h"
/**
* handle client message
* *
* @param[in] connected_socket socket descriptor * \section impinst Implementing instructions
* @param[in] cachelist cache list pointer * This program takes two arguments. \n
* @param[in,out] jpipstream address of JPT- JPP- stream pointer * -# Input JPT or JPP file
* @param[in,out] streamlen address of stream length * -# Output JP2 file\n
* @param[in,out] msgqueue message queue pointer * % ./jpip_to_jp2 input.jpt output.jp2
* or
* % ./jpip_to_jp2 input.jpp output.jp2
*/ */
bool handle_clientmsg( SOCKET connected_socket, cachelist_param_t *cachelist, Byte_t **jpipstream, int *streamlen, msgqueue_param_t *msgqueue);
#include <stdio.h>
#include "openjpip.h"
#endif /* !DEC_CLIENTMSG_HANDLER_H_ */ int main(int argc,char *argv[])
{
jpip_dec_param_t *dec;
if( argc < 3){
fprintf( stderr, "Too few arguments:\n");
fprintf( stderr, " - input jpt or jpp file\n");
fprintf( stderr, " - output jp2 file\n");
return -1;
}
dec = init_jpipdecoder( true);
if(!( fread_jpip( argv[1], dec)))
return -1;
decode_jpip( dec);
if(!(fwrite_jp2k( argv[2], dec)))
return -1;
output_log( true, false, true, dec);
destroy_jpipdecoder( &dec);
return 0;
}

View File

@ -45,13 +45,7 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include "openjpip.h"
#include "dec_clientmsg_handler.h"
#include "imgsock_manager.h"
#include "byte_manager.h"
#include "msgqueue_manager.h"
#include "cache_manager.h"
#ifdef _WIN32 #ifdef _WIN32
WSADATA initialisation_win32; WSADATA initialisation_win32;
@ -59,10 +53,8 @@ WSADATA initialisation_win32;
int main(int argc, char *argv[]){ int main(int argc, char *argv[]){
SOCKET connected_socket; dec_server_record_t *server_record;
Byte_t *jpipstream = NULL; client_t client;
int jpipstreamlen = 0;
msgqueue_param_t *msgqueue = gene_msgqueue( true, NULL);
#ifdef _WIN32 #ifdef _WIN32
int erreur = WSAStartup(MAKEWORD(2,2),&initialisation_win32); int erreur = WSAStartup(MAKEWORD(2,2),&initialisation_win32);
@ -72,25 +64,13 @@ int main(int argc, char *argv[]){
printf( "Initialisation Winsock\n"); printf( "Initialisation Winsock\n");
#endif //_WIN32 #endif //_WIN32
SOCKET listening_socket = open_listeningsocket(); server_record = init_dec_server();
cachelist_param_t *cachelist = gene_cachelist(); while(( client = accept_connection( server_record)) != -1 )
if(!handle_clientreq( client, server_record))
while(( connected_socket = accept_socket( listening_socket)) != -1 )
if(!(handle_clientmsg( connected_socket, cachelist, &jpipstream, &jpipstreamlen, msgqueue)))
break; break;
if( close_socket(listening_socket) != 0){ terminate_dec_server( &server_record);
perror("close");
return -1;
}
delete_cachelist( &cachelist);
if( msgqueue)
delete_msgqueue( &msgqueue);
free( jpipstream);
#ifdef _WIN32 #ifdef _WIN32
if( WSACleanup() != 0){ if( WSACleanup() != 0){

View File

@ -48,35 +48,17 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <math.h> #include "openjpip.h"
#include "query_parser.h"
#include "jpip_parser.h"
#include "session_manager.h"
#include "target_manager.h"
#include "msgqueue_manager.h"
#ifndef QUIT_SIGNAL #ifndef QUIT_SIGNAL
#define QUIT_SIGNAL "quitJPIP" #define QUIT_SIGNAL "quitJPIP"
#endif #endif
#ifdef SERVER
#include "fcgi_stdio.h"
#define logstream FCGI_stdout
#else
#define FCGI_stdout stdout
#define FCGI_stderr stderr
#define logstream stderr
#endif //SERVER
int main(void) int main(void)
{ {
sessionlist_param_t *sessionlist; server_record_t *server_record;
targetlist_param_t *targetlist;
bool parse_status;
sessionlist = gene_sessionlist(); server_record = init_JPIPserver();
targetlist = gene_targetlist();
#ifdef SERVER #ifdef SERVER
@ -96,36 +78,28 @@ int main(void)
if( strcmp( query_string, QUIT_SIGNAL) == 0) if( strcmp( query_string, QUIT_SIGNAL) == 0)
break; break;
query_param_t query_param; QR_t *qr;
msgqueue_param_t *msgqueue; bool parse_status;
parse_query( query_string, &query_param); qr = parse_querystring( query_string);
if( !(parse_status = process_JPIPrequest( server_record, qr)))
fprintf( FCGI_stderr, "Error: JPIP request failed\n");
#ifndef SERVER #ifndef SERVER
print_queryparam( query_param); local_log( true, true, parse_status, false, qr, server_record);
#endif #endif
msgqueue = NULL;
if( !(parse_status = parse_JPIPrequest( query_param, sessionlist, targetlist, &msgqueue)))
fprintf( FCGI_stderr, "Error: JPIP request failed\n");
fprintf( FCGI_stdout, "\r\n"); fprintf( FCGI_stdout, "\r\n");
#ifndef SERVER send_responsedata( qr);
// if( parse_status)
// print_allsession( sessionlist);
print_msgqueue( msgqueue);
#endif
emit_stream_from_msgqueue( msgqueue); end_QRprocess( server_record, &qr);
delete_msgqueue( &msgqueue);
} }
fprintf( FCGI_stderr, "JPIP server terminated by a client request\n"); fprintf( FCGI_stderr, "JPIP server terminated by a client request\n");
delete_sessionlist( &sessionlist); terminate_JPIPserver( &server_record);
delete_targetlist( &targetlist);
return 0; return 0;
} }

Binary file not shown.

View File

@ -0,0 +1 @@
opj_viewer-20111026.jar

View File

@ -178,7 +178,9 @@ public class JPIPHttpClient
if( !status.contains("OK")) if( !status.contains("OK"))
System.err.println( headers.get("Reason")); System.err.println( headers.get("Reason"));
hvalueline = headers.get("Content-type").get(0); if(( hvaluelist = headers.get("Content-type")) == null)
hvaluelist = headers.get("Content-Type");
hvalueline = hvaluelist.get(0);
System.err.println( hvalueline); System.err.println( hvalueline);
if( hvalueline.endsWith("jpt-stream")) if( hvalueline.endsWith("jpt-stream"))

View File

@ -0,0 +1 @@
opj_viewer_xerces-20111026.jar

View File

@ -42,87 +42,27 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include "openjpip.h"
#include <string.h>
#include "index_manager.h"
#ifdef SERVER
#include "fcgi_stdio.h"
#define logstream FCGI_stdout
#else
#define FCGI_stdout stdout
#define FCGI_stderr stderr
#define logstream stderr
#endif //SERVER
/**
* Open JP2 file with the check of JP2 header
*
* @param[in] filename file name string
* @return file descriptor
*/
int myopen_jp2file( char filename[]);
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
int fd; int fd;
index_param_t *jp2idx; index_t *jp2idx;
if((fd = myopen_jp2file( argv[1])) == -1){ if( (fd = open( argv[1], O_RDONLY)) == -1){
fprintf( stderr, "jp2 file open error\n"); fprintf( stderr, "Error: Target %s not found\n", argv[1]);
return -1; return -1;
} }
if( !(jp2idx = parse_jp2file( fd))){ if( !(jp2idx = get_index_from_JP2file( fd))){
fprintf( FCGI_stdout, "Status: 501\r\n"); fprintf( stderr, "JP2 file broken\n");
return -1; return -1;
} }
print_index( *jp2idx); output_index( jp2idx);
destroy_index( &jp2idx);
delete_index( &jp2idx); close(fd);
return 0; return 0;
} /* main */ } /* main */
int myopen_jp2file( char filename[])
{
int fd;
char *data;
if( (fd = open( filename, O_RDONLY)) == -1){
fprintf( FCGI_stdout, "Reason: Target %s not found\r\n", filename);
return -1;
}
// Check resource is a JP family file.
if( lseek( fd, 0, SEEK_SET)==-1){
close(fd);
fprintf( FCGI_stdout, "Reason: Target %s broken (lseek error)\r\n", filename);
return -1;
}
data = (char *)malloc( 12); // size of header
if( read( fd, data, 12) != 12){
free( data);
close(fd);
fprintf( FCGI_stdout, "Reason: Target %s broken (read error)\r\n", filename);
return -1;
}
if( *data || *(data + 1) || *(data + 2) ||
*(data + 3) != 12 || strncmp (data + 4, "jP \r\n\x87\n", 8)){
free( data);
close(fd);
fprintf( FCGI_stdout, "Reason: No JPEG 2000 Signature box in target %s\r\n", filename);
return -1;
}
free( data);
return fd;
}

View File

@ -411,10 +411,7 @@ applications/codec/Makefile
applications/mj2/Makefile applications/mj2/Makefile
applications/jpip/Makefile applications/jpip/Makefile
applications/jpip/libopenjpip/Makefile applications/jpip/libopenjpip/Makefile
applications/jpip/opj_server/Makefile applications/jpip/util/Makefile
applications/jpip/opj_client/Makefile
applications/jpip/opj_client/opj_dec_server/Makefile
applications/jpip/tools/Makefile
doc/Makefile doc/Makefile
]) ])

View File

@ -84,13 +84,11 @@ int write_phix( int coff, opj_codestream_info_t cstr_info, opj_bool EPHused, int
int write_phixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio) int write_phixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio)
{ {
int len, lenp; int len, lenp, tileno, version, i, nmax, size_of_coding; // 4 or 8
int size_of_coding; // 4 or 8
int version;
int tileno, resno, precno, layno, num_packet=0;
int i,nmax=0;
opj_tile_info_t *tile_Idx; opj_tile_info_t *tile_Idx;
opj_packet_info_t packet; opj_packet_info_t packet;
int resno, precno, layno, num_packet;
int numOfres, numOfprec, numOflayers;
if( j2klen > pow( 2, 32)){ if( j2klen > pow( 2, 32)){
size_of_coding = 8; size_of_coding = 8;
@ -106,6 +104,7 @@ int write_phixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_b
cio_write( cio, JPIP_FAIX, 4); /* FAIX */ cio_write( cio, JPIP_FAIX, 4); /* FAIX */
cio_write( cio, version,1); /* Version 0 = 4 bytes */ cio_write( cio, version,1); /* Version 0 = 4 bytes */
nmax = 0;
for( i=0; i<=cstr_info.numdecompos[compno]; i++) for( i=0; i<=cstr_info.numdecompos[compno]; i++)
nmax += cstr_info.tile[0].ph[i] * cstr_info.tile[0].pw[i] * cstr_info.numlayers; nmax += cstr_info.tile[0].ph[i] * cstr_info.tile[0].pw[i] * cstr_info.numlayers;
@ -113,15 +112,37 @@ int write_phixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_b
cio_write( cio, cstr_info.tw*cstr_info.th, size_of_coding); /* M */ cio_write( cio, cstr_info.tw*cstr_info.th, size_of_coding); /* M */
for( tileno=0; tileno<cstr_info.tw*cstr_info.th; tileno++){ for( tileno=0; tileno<cstr_info.tw*cstr_info.th; tileno++){
tile_Idx = &cstr_info.tile[ tileno]; tile_Idx = &cstr_info.tile[ tileno];
// int correction = EPHused ? 3 : 1;
num_packet = 0;
for( resno=0; resno<=cstr_info.numdecompos[compno]; resno++){ num_packet = 0;
for( precno=0; precno<tile_Idx->pw[resno]*tile_Idx->ph[resno]; precno++){ numOfres = cstr_info.numdecompos[compno] + 1;
for( layno=0; layno<cstr_info.numlayers; layno++){
packet = tile_Idx->packet[num_packet * cstr_info.numcomps + compno]; for( resno=0; resno<numOfres ; resno++){
numOfprec = tile_Idx->pw[resno]*tile_Idx->ph[resno];
for( precno=0; precno<numOfprec; precno++){
numOflayers = cstr_info.numlayers;
for( layno=0; layno<numOflayers; layno++){
switch ( cstr_info.prog){
case LRCP:
packet = tile_Idx->packet[ ((layno*numOfres+resno)*cstr_info.numcomps+compno)*numOfprec+precno];
break;
case RLCP:
packet = tile_Idx->packet[ ((resno*numOflayers+layno)*cstr_info.numcomps+compno)*numOfprec+precno];
break;
case RPCL:
packet = tile_Idx->packet[ ((resno*numOfprec+precno)*cstr_info.numcomps+compno)*numOflayers+layno];
break;
case PCRL:
packet = tile_Idx->packet[ ((precno*cstr_info.numcomps+compno)*numOfres+resno)*numOflayers + layno];
break;
case CPRL:
packet = tile_Idx->packet[ ((compno*numOfprec+precno)*numOfres+resno)*numOflayers + layno];
break;
default:
fprintf( stderr, "failed to ppix indexing\n");
}
cio_write( cio, packet.start_pos-coff, size_of_coding); /* start position */ cio_write( cio, packet.start_pos-coff, size_of_coding); /* start position */
cio_write( cio, packet.end_ph_pos-packet.start_pos+1, size_of_coding); /* length */ cio_write( cio, packet.end_ph_pos-packet.start_pos+1, size_of_coding); /* length */

View File

@ -87,13 +87,11 @@ int write_ppix( int coff, opj_codestream_info_t cstr_info, opj_bool EPHused, int
int write_ppixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio) int write_ppixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio)
{ {
int len, lenp; int len, lenp, tileno, version, i, nmax, size_of_coding; // 4 or 8
int tileno, resno, precno, layno, num_packet=0;
int size_of_coding; // 4 or 8
int version;
int i,nmax=0;
opj_tile_info_t *tile_Idx; opj_tile_info_t *tile_Idx;
opj_packet_info_t packet; opj_packet_info_t packet;
int resno, precno, layno, num_packet;
int numOfres, numOfprec, numOflayers;
if( j2klen > pow( 2, 32)){ if( j2klen > pow( 2, 32)){
size_of_coding = 8; size_of_coding = 8;
@ -109,6 +107,7 @@ int write_ppixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_b
cio_write( cio, JPIP_FAIX, 4); /* FAIX */ cio_write( cio, JPIP_FAIX, 4); /* FAIX */
cio_write( cio, version, 1); /* Version 0 = 4 bytes */ cio_write( cio, version, 1); /* Version 0 = 4 bytes */
nmax = 0;
for( i=0; i<=cstr_info.numdecompos[compno]; i++) for( i=0; i<=cstr_info.numdecompos[compno]; i++)
nmax += cstr_info.tile[0].ph[i] * cstr_info.tile[0].pw[i] * cstr_info.numlayers; nmax += cstr_info.tile[0].ph[i] * cstr_info.tile[0].pw[i] * cstr_info.numlayers;
@ -116,15 +115,37 @@ int write_ppixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_b
cio_write( cio, cstr_info.tw*cstr_info.th, size_of_coding); /* M */ cio_write( cio, cstr_info.tw*cstr_info.th, size_of_coding); /* M */
for( tileno=0; tileno<cstr_info.tw*cstr_info.th; tileno++){ for( tileno=0; tileno<cstr_info.tw*cstr_info.th; tileno++){
tile_Idx = &cstr_info.tile[ tileno]; tile_Idx = &cstr_info.tile[ tileno];
// int correction = EPHused ? 3 : 1;
num_packet=0;
for( resno=0; resno<=cstr_info.numdecompos[compno]; resno++){ num_packet=0;
for( precno=0; precno<tile_Idx->pw[resno]*tile_Idx->ph[resno]; precno++){ numOfres = cstr_info.numdecompos[compno] + 1;
for( layno=0; layno<cstr_info.numlayers; layno++){
packet = tile_Idx->packet[num_packet * cstr_info.numcomps + compno]; for( resno=0; resno<numOfres ; resno++){
numOfprec = tile_Idx->pw[resno]*tile_Idx->ph[resno];
for( precno=0; precno<numOfprec; precno++){
numOflayers = cstr_info.numlayers;
for( layno=0; layno<numOflayers; layno++){
switch ( cstr_info.prog){
case LRCP:
packet = tile_Idx->packet[ ((layno*numOfres+resno)*cstr_info.numcomps+compno)*numOfprec+precno];
break;
case RLCP:
packet = tile_Idx->packet[ ((resno*numOflayers+layno)*cstr_info.numcomps+compno)*numOfprec+precno];
break;
case RPCL:
packet = tile_Idx->packet[ ((resno*numOfprec+precno)*cstr_info.numcomps+compno)*numOflayers+layno];
break;
case PCRL:
packet = tile_Idx->packet[ ((precno*cstr_info.numcomps+compno)*numOfres+resno)*numOflayers + layno];
break;
case CPRL:
packet = tile_Idx->packet[ ((compno*numOfprec+precno)*numOfres+resno)*numOflayers + layno];
break;
default:
fprintf( stderr, "failed to ppix indexing\n");
}
cio_write( cio, packet.start_pos-coff, size_of_coding); /* start position */ cio_write( cio, packet.start_pos-coff, size_of_coding); /* start position */
cio_write( cio, packet.end_pos-packet.start_pos+1, size_of_coding); /* length */ cio_write( cio, packet.end_pos-packet.start_pos+1, size_of_coding); /* length */
@ -133,8 +154,7 @@ int write_ppixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_b
} }
} }
/* PADDING */ while( num_packet < nmax){ /* PADDING */
while( num_packet < nmax){
cio_write( cio, 0, size_of_coding); /* start position */ cio_write( cio, 0, size_of_coding); /* start position */
cio_write( cio, 0, size_of_coding); /* length */ cio_write( cio, 0, size_of_coding); /* length */
num_packet++; num_packet++;
@ -147,5 +167,4 @@ int write_ppixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_b
cio_seek( cio, lenp+len); cio_seek( cio, lenp+len);
return len; return len;
} }