changed parameter and file names regarding JPT-stream to JPIP-stream, which handles also JPP-stream

This commit is contained in:
Kaori Hagihara 2011-07-04 23:00:21 +00:00
parent a5130aebab
commit 826fda959c
9 changed files with 106 additions and 101 deletions

View File

@ -5,6 +5,9 @@ What's New for OpenJPIP
! : changed
+ : added
July 5, 2011
! [kaori] changed parameter and file names regarding JPT-stream to JPIP-stream, which handles also JPP-stream
May 26, 2011
! [antonin] changed Makefile to Makefile.nix to avoid having autotools overwrite them.

View File

@ -487,7 +487,7 @@ void print_binarycode( Byte8_t n, int segmentlen)
Byte_t * parse_bin_id_vbas( Byte_t *streamptr, Byte_t *bb, Byte_t *c, Byte8_t *in_class_id);
Byte_t * parse_vbas( Byte_t *streamptr, Byte8_t *elem);
void parse_stream( Byte_t *stream, Byte8_t jptlen, Byte8_t offset, msgqueue_param_t *msgqueue)
void parse_JPIPstream( Byte_t *JPIPstream, Byte8_t streamlen, Byte8_t offset, msgqueue_param_t *msgqueue)
{
Byte_t *ptr; // stream pointer
message_param_t *msg;
@ -496,8 +496,8 @@ void parse_stream( Byte_t *stream, Byte8_t jptlen, Byte8_t offset, msgqueue_para
class_id = -1; // dummy
csn = 0;
ptr = stream;
while( ptr-stream < jptlen){
ptr = JPIPstream;
while( ptr-JPIPstream < streamlen){
msg = (message_param_t *)malloc( sizeof(message_param_t));
ptr = parse_bin_id_vbas( ptr, &bb, &c, &msg->in_class_id);
@ -522,7 +522,7 @@ void parse_stream( Byte_t *stream, Byte8_t jptlen, Byte8_t offset, msgqueue_para
else
msg->aux = 0;
msg->res_offset = ptr-stream+offset;
msg->res_offset = ptr-JPIPstream+offset;
msg->phld = NULL;
msg->next = NULL;
@ -538,7 +538,7 @@ void parse_stream( Byte_t *stream, Byte8_t jptlen, Byte8_t offset, msgqueue_para
void parse_metadata( metadata_param_t *metadata, message_param_t *msg, Byte_t *stream);
void parse_metamsg( msgqueue_param_t *msgqueue, Byte_t *stream, Byte8_t jptlen, metadatalist_param_t *metadatalist)
void parse_metamsg( msgqueue_param_t *msgqueue, Byte_t *stream, Byte8_t streamlen, metadatalist_param_t *metadatalist)
{
message_param_t *msg;

View File

@ -119,24 +119,24 @@ void emit_stream_from_msgqueue( msgqueue_param_t *msgqueue);
/**
* parse JPT-stream to message queue
* parse JPT- JPP- stream to message queue
*
* @param[in] stream JPT-stream data pointer
* @param[in] jptlen JPT-stream length
* @param[in] offset offset of the JPT-stream from the whole beginning
* @param[in] JPIPstream JPT- JPP- stream data pointer
* @param[in] streamlen JPIPstream length
* @param[in] offset offset of the stream from the whole beginning
* @param[in,out] msgqueue adding message queue pointer
*/
void parse_stream( Byte_t *stream, Byte8_t jptlen, Byte8_t offset, msgqueue_param_t *msgqueue);
void parse_JPIPstream( Byte_t *JPIPstream, Byte8_t streamlen, Byte8_t offset, msgqueue_param_t *msgqueue);
/**
* parse JPT-stream to message queue
* parse JPT- JPP- stream to message queue
*
* @param[in] msgqueue reference message queue pointer
* @param[in] stream JPT-stream data pointer
* @param[in] jptlen JPT-stream length
* @param[in] stream stream data pointer
* @param[in] streamlen stream length
* @param[in] metadatalist adding metadata list pointer
*/
void parse_metamsg( msgqueue_param_t *msgqueue, Byte_t *stream, Byte8_t jptlen, metadatalist_param_t *metadatalist);
void parse_metamsg( msgqueue_param_t *msgqueue, Byte_t *stream, Byte8_t streamlen, metadatalist_param_t *metadatalist);
/**

View File

@ -8,7 +8,7 @@ ALL = opj_dec_server
all: $(ALL)
opj_dec_server: opj_dec_server.o jp2k_decoder.o imgsock_manager.o jptstream_manager.o cache_manager.o $(LIBFNAME)
$(CC) $(CFLAGS) $< jp2k_decoder.o imgsock_manager.o jptstream_manager.o cache_manager.o $(LDFLAGS) -o $@
opj_dec_server: opj_dec_server.o jp2k_decoder.o imgsock_manager.o jpipstream_manager.o cache_manager.o $(LIBFNAME)
$(CC) $(CFLAGS) $< jp2k_decoder.o imgsock_manager.o jpipstream_manager.o cache_manager.o $(LDFLAGS) -o $@
clean:
rm -f $(ALL) *.o *~

View File

@ -94,7 +94,7 @@ msgtype_t identify_clientmsg( SOCKET connected_socket)
{
int receive_size;
char buf[BUF_LEN];
char *magicid[] = { "JPT-stream", "PNM request", "XML request", "CID request", "CID destroy", "JP2 save", "QUIT"};
char *magicid[] = { "JPT-stream", "JPP-stream", "PNM request", "XML request", "CID request", "CID destroy", "JP2 save", "QUIT"};
int i;
receive_size = receive_line( connected_socket, buf);
@ -115,9 +115,9 @@ msgtype_t identify_clientmsg( SOCKET connected_socket)
return MSGERROR;
}
Byte_t * receive_JPTstream( SOCKET connected_socket, char *target, char *cid, int *streamlen)
Byte_t * receive_JPIPstream( SOCKET connected_socket, char *target, char *cid, int *streamlen)
{
Byte_t *jptstream=NULL, *ptr;
Byte_t *jpipstream=NULL, *ptr;
char buf[BUF_LEN], versionstring[] = "version 1.0";
int linelen, redlen, remlen;
@ -150,13 +150,13 @@ Byte_t * receive_JPTstream( SOCKET connected_socket, char *target, char *cid, in
fprintf( stderr, "Receiveing Data length: %d\n", *streamlen);
jptstream = (unsigned char *)malloc( (*streamlen));
ptr = jptstream;
jpipstream = (unsigned char *)malloc( (*streamlen));
ptr = jpipstream;
remlen = (*streamlen);
while( remlen > 0){
redlen = recv( connected_socket, ptr, remlen, 0);
if( redlen == -1){
fprintf( stderr, "receive jptstream error\n");
fprintf( stderr, "receive JPT- JPP- stream error\n");
break;
}
remlen -= redlen;
@ -164,7 +164,7 @@ Byte_t * receive_JPTstream( SOCKET connected_socket, char *target, char *cid, in
}
fprintf( stderr, " done\n");
return jptstream;
return jpipstream;
}
void send_stream( SOCKET connected_socket, void *stream, int length);

View File

@ -48,8 +48,8 @@ typedef int SOCKET;
*/
SOCKET open_listeningsocket();
#define NUM_OF_MSGTYPES 7
typedef enum eMSGTYPE{ JPTSTREAM, PNMREQ, XMLREQ, CIDREQ, CIDDST, JP2SAVE, QUIT, MSGERROR} msgtype_t;
#define NUM_OF_MSGTYPES 8
typedef enum eMSGTYPE{ JPTSTREAM, JPPSTREAM, PNMREQ, XMLREQ, CIDREQ, CIDDST, JP2SAVE, QUIT, MSGERROR} msgtype_t;
/**
* indeitify client message type
@ -60,15 +60,15 @@ typedef enum eMSGTYPE{ JPTSTREAM, PNMREQ, XMLREQ, CIDREQ, CIDDST, JP2SAVE, QUIT,
msgtype_t identify_clientmsg( SOCKET connected_socket);
/**
* receive JPT-stream from client
* receive a JPT- JPP- stream from client
*
* @param [in] connected_socket file descriptor of the connected socket
* @param [out] target received target file name (if not received, null string)
* @param [out] cid received channel identifier (if not received, null string)
* @param [out] streamlen length of the received codestream
* @return codestream
* @return JPT- JPP- codestream
*/
Byte_t * receive_JPTstream( SOCKET connected_socket, char *target, char *cid, int *streamlen);
Byte_t * receive_JPIPstream( SOCKET connected_socket, char *target, char *cid, int *streamlen);
/**
* send PGM/PPM image stream to the client

View File

@ -1,5 +1,5 @@
/*
* $Id: jptstream_manager.c 44 2011-02-15 12:32:29Z kaori $
* $Id$
*
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2011, Professor Benoit Macq
@ -32,45 +32,22 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "jptstream_manager.h"
#include "jpipstream_manager.h"
#include "jp2k_decoder.h"
#include "imgreg_manager.h"
Byte_t * update_JPTstream( Byte_t *newjptstream, int newjptlen, Byte_t *cache_jptstream, int *jptlen)
Byte_t * update_JPIPstream( Byte_t *newstream, int newstreamlen, Byte_t *cache_stream, int *streamlen)
{
Byte_t *jptstream = (Byte_t *)malloc( (*jptlen)+newjptlen);
if( *jptlen > 0)
memcpy( jptstream, cache_jptstream, *jptlen);
memcpy( jptstream+(*jptlen), newjptstream, newjptlen);
*jptlen += newjptlen;
Byte_t *stream = (Byte_t *)malloc( (*streamlen)+newstreamlen);
if( *streamlen > 0)
memcpy( stream, cache_stream, *streamlen);
memcpy( stream+(*streamlen), newstream, newstreamlen);
*streamlen += newstreamlen;
if(cache_jptstream)
free( cache_jptstream);
if(cache_stream)
free( cache_stream);
return jptstream;
}
Byte_t * jpt_to_pnm( Byte_t *jptstream, msgqueue_param_t *msgqueue, Byte8_t csn, int fw, int fh, ihdrbox_param_t **ihdrbox)
{
Byte_t *pnmstream;
Byte_t *j2kstream; // j2k or jp2 codestream
Byte8_t j2klen;
int level = 0;
if( *ihdrbox){
// infinit value is set for maxmum level
int fx = fw, fy = fh;
int xmin = 0, ymin = 0;
int xmax = (*ihdrbox)->width, ymax = (*ihdrbox)->height;
find_level( 1000, &level, &fx, &fy, &xmin, &ymin, &xmax, &ymax);
}
j2kstream = recons_j2k( msgqueue, jptstream, csn, level+1, &j2klen);
pnmstream = j2k_to_pnm( j2kstream, j2klen, ihdrbox);
free( j2kstream);
return pnmstream;
return stream;
}
void save_codestream( Byte_t *codestream, Byte8_t streamlen, char *fmt)
@ -89,3 +66,27 @@ void save_codestream( Byte_t *codestream, Byte8_t streamlen, char *fmt)
fwrite( codestream, streamlen, 1, fp);
fclose( fp);
}
Byte_t * jpipstream_to_pnm( Byte_t *jpipstream, msgqueue_param_t *msgqueue, Byte8_t csn, int fw, int fh, ihdrbox_param_t **ihdrbox)
{
Byte_t *pnmstream;
Byte_t *j2kstream; // j2k or jp2 codestream
Byte8_t j2klen;
int level = 0;
if( *ihdrbox){
// infinit value is set for maxmum level
int fx = fw, fy = fh;
int xmin = 0, ymin = 0;
int xmax = (*ihdrbox)->width, ymax = (*ihdrbox)->height;
find_level( 1000, &level, &fx, &fy, &xmin, &ymin, &xmax, &ymax);
}
j2kstream = recons_j2k( msgqueue, jpipstream, csn, level+1, &j2klen);
pnmstream = j2k_to_pnm( j2kstream, j2klen, ihdrbox);
free( j2kstream);
return pnmstream;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: jptstream_manager.h 44 2011-02-15 12:32:29Z kaori $
* $Id$
*
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2011, Professor Benoit Macq
@ -32,8 +32,8 @@
#include "msgqueue_manager.h"
#include "ihdrbox_manager.h"
Byte_t * update_JPTstream( Byte_t *newjptstream, int newjptlen, Byte_t *cache_jptstream, int *jptlen);
Byte_t * jpt_to_pnm( Byte_t *jptstream, msgqueue_param_t *msgqueue, Byte8_t csn, int fw, int fh, ihdrbox_param_t **ihdrbox);
Byte_t * update_JPIPstream( Byte_t *newstream, int newstreamlen, Byte_t *cache_stream, int *streamlen);
void save_codestream( Byte_t *codestream, Byte8_t streamlen, char *fmt);
Byte_t * jpipstream_to_pnm( Byte_t *jpipstream, msgqueue_param_t *msgqueue, Byte8_t csn, int fw, int fh, ihdrbox_param_t **ihdrbox);

View File

@ -52,7 +52,7 @@
#include "msgqueue_manager.h"
#include "ihdrbox_manager.h"
#include "imgsock_manager.h"
#include "jptstream_manager.h"
#include "jpipstream_manager.h"
#include "cache_manager.h"
#ifdef _WIN32
@ -70,34 +70,34 @@ WSADATA initialisation_win32;
#define MAX_LENOFCID 30
/**
* handle JPTstream message
* handle JPT- JPP- stream message
*
* @param[in] connected_socket socket descriptor
* @param[in] cachelist cache list pointer
* @param[in,out] jptstream address of jptstream pointer
* @param[in,out] jptlen address of jptstream length
* @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_JPTstreamMSG( SOCKET connected_socket, cachelist_param_t *cachelist, Byte_t **jptstream, int *jptlen, msgqueue_param_t *msgqueue);
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] jptstream jptstream pointer
* @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 *jptstream, msgqueue_param_t *msgqueue, cachelist_param_t *cachelist);
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] jptstream address of caching jptstream pointer
* @param[in] jpipstream address of caching jpipstream pointer
* @param[in] cachelist cache list pointer
*/
void handle_XMLreqMSG( SOCKET connected_socket, Byte_t *jptstream, cachelist_param_t *cachelist);
void handle_XMLreqMSG( SOCKET connected_socket, Byte_t *jpipstream, cachelist_param_t *cachelist);
/**
* handle ChannelID request message
@ -121,16 +121,16 @@ void handle_dstCIDreqMSG( SOCKET connected_socket, cachelist_param_t *cachelist)
* @param[in] connected_socket socket descriptor
* @param[in] cachelist cache list pointer
* @param[in] msgqueue message queue pointer
* @param[in] jptstream address of caching jptstream 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 *jptstream);
void handle_JP2saveMSG( SOCKET connected_socket, cachelist_param_t *cachelist, msgqueue_param_t *msgqueue, Byte_t *jpipstream);
int main(int argc, char *argv[]){
SOCKET connected_socket;
struct sockaddr_in peer_sin;
Byte_t *jptstream = NULL;
int jptlen = 0;
Byte_t *jpipstream = NULL;
int jpipstreamlen = 0;
msgqueue_param_t *msgqueue = gene_msgqueue( true, NULL);
bool quit = false;
@ -153,15 +153,16 @@ int main(int argc, char *argv[]){
switch( msgtype){
case JPTSTREAM:
handle_JPTstreamMSG( connected_socket, cachelist, &jptstream, &jptlen, msgqueue);
case JPPSTREAM:
handle_JPIPstreamMSG( connected_socket, cachelist, &jpipstream, &jpipstreamlen, msgqueue);
break;
case PNMREQ:
handle_PNMreqMSG( connected_socket, jptstream, msgqueue, cachelist);
handle_PNMreqMSG( connected_socket, jpipstream, msgqueue, cachelist);
break;
case XMLREQ:
handle_XMLreqMSG( connected_socket, jptstream, cachelist);
handle_XMLreqMSG( connected_socket, jpipstream, cachelist);
break;
case CIDREQ:
@ -173,7 +174,7 @@ int main(int argc, char *argv[]){
break;
case JP2SAVE:
handle_JP2saveMSG( connected_socket, cachelist, msgqueue, jptstream);
handle_JP2saveMSG( connected_socket, cachelist, msgqueue, jpipstream);
break;
case QUIT:
@ -201,8 +202,8 @@ int main(int argc, char *argv[]){
if( msgqueue)
delete_msgqueue( &msgqueue);
save_codestream( jptstream, jptlen, "jpt");
free( jptstream);
// save_codestream( jpipstream, jpipstreamlen, "jpt");
free( jpipstream);
#ifdef _WIN32
if( WSACleanup() != 0){
@ -215,24 +216,24 @@ int main(int argc, char *argv[]){
return 0;
}
void handle_JPTstreamMSG( SOCKET connected_socket, cachelist_param_t *cachelist,
Byte_t **jptstream, int *jptlen, msgqueue_param_t *msgqueue)
void handle_JPIPstreamMSG( SOCKET connected_socket, cachelist_param_t *cachelist,
Byte_t **jpipstream, int *streamlen, msgqueue_param_t *msgqueue)
{
Byte_t *newjptstream;
int newjptlen = 0;
Byte_t *newjpipstream;
int newstreamlen = 0;
cache_param_t *cache;
char target[MAX_LENOFTARGET], cid[MAX_LENOFCID];
metadatalist_param_t *metadatalist;
newjptstream = receive_JPTstream( connected_socket, target, cid, &newjptlen);
parse_stream( newjptstream, newjptlen, *jptlen, msgqueue);
newjpipstream = receive_JPIPstream( connected_socket, target, cid, &newstreamlen);
*jptstream = update_JPTstream( newjptstream, newjptlen, *jptstream, jptlen);
free( newjptstream);
parse_JPIPstream( newjpipstream, newstreamlen, *streamlen, msgqueue);
*jpipstream = update_JPIPstream( newjpipstream, newstreamlen, *jpipstream, streamlen);
free( newjpipstream);
metadatalist = gene_metadatalist();
parse_metamsg( msgqueue, *jptstream, *jptlen, metadatalist);
parse_metamsg( msgqueue, *jpipstream, *streamlen, metadatalist);
// cid registration
if( target[0] != 0 && cid[0] != 0){
@ -253,7 +254,7 @@ void handle_JPTstreamMSG( SOCKET connected_socket, cachelist_param_t *cachelist,
response_signal( connected_socket, true);
}
void handle_PNMreqMSG( SOCKET connected_socket, Byte_t *jptstream, msgqueue_param_t *msgqueue, cachelist_param_t *cachelist)
void handle_PNMreqMSG( SOCKET connected_socket, Byte_t *jpipstream, msgqueue_param_t *msgqueue, cachelist_param_t *cachelist)
{
Byte_t *pnmstream;
ihdrbox_param_t *ihdrbox;
@ -271,14 +272,14 @@ void handle_PNMreqMSG( SOCKET connected_socket, Byte_t *jptstream, msgqueue_para
receive_line( connected_socket, tmp);
fh = atoi( tmp);
pnmstream = jpt_to_pnm( jptstream, msgqueue, cache->csn, fw, fh, &cache->ihdrbox);
pnmstream = jpipstream_to_pnm( jpipstream, msgqueue, cache->csn, fw, fh, &cache->ihdrbox);
ihdrbox = cache->ihdrbox;
send_PNMstream( connected_socket, pnmstream, ihdrbox->width, ihdrbox->height, ihdrbox->nc, ihdrbox->bpc > 8 ? 255 : (1 << ihdrbox->bpc) - 1);
free( pnmstream);
}
void handle_XMLreqMSG( SOCKET connected_socket, Byte_t *jptstream, cachelist_param_t *cachelist)
void handle_XMLreqMSG( SOCKET connected_socket, Byte_t *jpipstream, cachelist_param_t *cachelist)
{
char cid[MAX_LENOFCID];
cache_param_t *cache;
@ -289,7 +290,7 @@ void handle_XMLreqMSG( SOCKET connected_socket, Byte_t *jptstream, cachelist_par
boxcontents_param_t *boxcontents = cache->metadatalist->last->boxcontents;
Byte_t *xmlstream = (Byte_t *)malloc( boxcontents->length);
memcpy( xmlstream, jptstream+boxcontents->offset, boxcontents->length);
memcpy( xmlstream, jpipstream+boxcontents->offset, boxcontents->length);
send_XMLstream( connected_socket, xmlstream, boxcontents->length);
free( xmlstream);
}
@ -321,7 +322,7 @@ void handle_dstCIDreqMSG( SOCKET connected_socket, cachelist_param_t *cachelist)
response_signal( connected_socket, true);
}
void handle_JP2saveMSG( SOCKET connected_socket, cachelist_param_t *cachelist, msgqueue_param_t *msgqueue, Byte_t *jptstream)
void handle_JP2saveMSG( SOCKET connected_socket, cachelist_param_t *cachelist, msgqueue_param_t *msgqueue, Byte_t *jpipstream)
{
char cid[MAX_LENOFCID];
cache_param_t *cache;
@ -332,7 +333,7 @@ void handle_JP2saveMSG( SOCKET connected_socket, cachelist_param_t *cachelist, m
if(!(cache = search_cacheBycid( cid, cachelist)))
return;
jp2stream = recons_jp2( msgqueue, jptstream, cache->csn, &jp2len);
jp2stream = recons_jp2( msgqueue, jpipstream, cache->csn, &jp2len);
if( jp2stream){
save_codestream( jp2stream, jp2len, "jp2");