enable JPT-stream request from client viewer option

This commit is contained in:
Kaori Hagihara 2011-10-10 13:15:18 +00:00
parent 5d5adf7c7e
commit f20530dce2
25 changed files with 207 additions and 119 deletions

View File

@ -7,6 +7,7 @@ What's New for OpenJPIP
October 10, 2011 October 10, 2011
- [antonin] removed obsolete indexer utility - [antonin] removed obsolete indexer utility
+ [kaori] enable JPT-stream request from client viewer option
September 30, 2011 September 30, 2011
+ [kaori] enabled JPP-stream + [kaori] enabled JPP-stream

View File

@ -103,11 +103,12 @@ Client:
% ../opj_dec_server % ../opj_dec_server
2. Open image viewers (as many as needed) 2. Open image viewers (as many as needed)
% java -jar opj_viewer.jar http://hostname/myFCGI JP2_filename.jp2 [stateless] % java -jar opj_viewer.jar http://hostname/myFCGI JP2_filename.jp2 [stateless/session] [jptstream/jppstream]
( The arguments ( The arguments
- http://hostname/myFCGI is the HTTP server URI (myFCGI refers to opj_server by the server setting) - http://hostname/myFCGI is the HTTP server URI (myFCGI refers to opj_server by the server setting)
- JP2_filename.jp2 is the name of a JP2 file available on the server. - JP2_filename.jp2 is the name of a JP2 file available on the server.
- stateless if stateless request is desired, otherwise session request is implemented - request type stateless for no caching, session (default) for caching
- return media type, JPT-stream tile based stream, or JPP-stream (default) precinct based stream
Image viewer GUI instructions: Image viewer GUI instructions:
Scale up request: Enlarge the window Scale up request: Enlarge the window
ROI request: Select a region by mouse click and drag, then click inside the red frame of the selected region ROI request: Select a region by mouse click and drag, then click inside the red frame of the selected region
@ -125,7 +126,11 @@ Client:
---------- ----------
An example to encode a TIF image "copenhague1.tif" at resolution 4780x4050, 8bit/pixel, grayscale. An example to encode a TIF image "copenhague1.tif" at resolution 4780x4050, 8bit/pixel, grayscale.
% ./image_to_j2k -i copenhague1.tif -o copenhague1.jp2 -p RPCL -c [64,64] -t 640,480 -jpip % ./image_to_j2k -i copenhague1.tif -o copenhague1.jp2 -p RPCL -c [64,64] -t 640,480 -jpip -v R
options
-jpip : embed index table box into the output JP2 file (obligation for JPIP)
-v R : partition a tile into tile parts of different resolution levels (obligation for JPT-stream)
<Option> <Option>
3. Embed metadata into JP2 file 3. Embed metadata into JP2 file

View File

@ -55,7 +55,7 @@ cachemodellist_param_t * gene_cachemodellist()
return cachemodellist; return cachemodellist;
} }
cachemodel_param_t * gene_cachemodel( cachemodellist_param_t *cachemodellist, target_param_t *target) cachemodel_param_t * gene_cachemodel( cachemodellist_param_t *cachemodellist, target_param_t *target, bool reqJPP)
{ {
cachemodel_param_t *cachemodel; cachemodel_param_t *cachemodel;
faixbox_param_t *tilepart; faixbox_param_t *tilepart;
@ -67,6 +67,19 @@ cachemodel_param_t * gene_cachemodel( cachemodellist_param_t *cachemodellist, ta
cachemodel = (cachemodel_param_t *)malloc( sizeof(cachemodel_param_t)); cachemodel = (cachemodel_param_t *)malloc( sizeof(cachemodel_param_t));
refer_target( target, &cachemodel->target); refer_target( target, &cachemodel->target);
if( reqJPP){
if( target->jppstream)
cachemodel->jppstream = true;
else
cachemodel->jppstream = false;
} else{ // reqJPT
if( target->jptstream)
cachemodel->jppstream = false;
else
cachemodel->jppstream = true;
}
cachemodel->mhead_model = false; cachemodel->mhead_model = false;
tilepart = target->codeidx->tilepart; tilepart = target->codeidx->tilepart;

View File

@ -37,6 +37,7 @@
//! Cache model parameters //! Cache model parameters
typedef struct cachemodel_param{ typedef struct cachemodel_param{
target_param_t *target; //!< reference pointer to the target target_param_t *target; //!< reference pointer to the target
bool jppstream; //!< return type, true: JPP-stream, false: JPT-stream
bool mhead_model; //!< main header model, if sent, 1, else 0 bool mhead_model; //!< main header model, if sent, 1, else 0
bool *tp_model; //!< dynamic array pointer of tile part model, if sent, 1, else 0 bool *tp_model; //!< dynamic array pointer of tile part model, if sent, 1, else 0
bool *th_model; //!< dynamic array pointer of tile header model bool *th_model; //!< dynamic array pointer of tile header model
@ -59,13 +60,14 @@ typedef struct cachemodellist_param{
cachemodellist_param_t * gene_cachemodellist(); cachemodellist_param_t * gene_cachemodellist();
/** /**
* generate a session under the sesion list * generate a cache model under a list
* *
* @param[in] cachemodellist cachemodel list to insert the generated cache model * @param[in] cachemodellist cachemodel list to insert the generated cache model, NULL for stateless
* @param[in] target pointer the reference target * @param[in] target pointer the reference target
* @param[in] reqJPP if JPP-stream is desired true, JPT-stream false
* @return pointer to the generated cache model * @return pointer to the generated cache model
*/ */
cachemodel_param_t * gene_cachemodel( cachemodellist_param_t *cachemodellist, target_param_t *target); cachemodel_param_t * gene_cachemodel( cachemodellist_param_t *cachemodellist, target_param_t *target, bool reqJPP);
/** /**

View File

@ -706,3 +706,11 @@ Byte4_t min( Byte4_t n1, Byte4_t n2)
else else
return n2; return n2;
} }
bool isJPTfeasible( index_param_t index)
{
if( 1 < get_nmax( index.tilepart))
return true;
else
return false;
}

View File

@ -35,6 +35,7 @@
#include "faixbox_manager.h" #include "faixbox_manager.h"
#include "metadata_manager.h" #include "metadata_manager.h"
#include "mhixbox_manager.h" #include "mhixbox_manager.h"
#include "bool.h"
//! progression order //! progression order
typedef enum porder { typedef enum porder {
@ -166,4 +167,13 @@ range_param_t get_tile_Yrange( SIZmarker_param_t SIZ, Byte4_t tile_id, int level
Byte4_t get_tile_XSiz( SIZmarker_param_t SIZ, Byte4_t tile_id, int level); Byte4_t get_tile_XSiz( SIZmarker_param_t SIZ, Byte4_t tile_id, int level);
Byte4_t get_tile_YSiz( SIZmarker_param_t SIZ, Byte4_t tile_id, int level); Byte4_t get_tile_YSiz( SIZmarker_param_t SIZ, Byte4_t tile_id, int level);
/**
* answers if the target is feasible to JPT-stream
*
* @param[in] index index parameters
* @return true if JPT-stream is feasible
*/
bool isJPTfeasible( index_param_t index);
#endif /* !INDEX_MANAGER_H_ */ #endif /* !INDEX_MANAGER_H_ */

View File

@ -212,11 +212,16 @@ Byte2_t modify_CODmkrstream( CODmarker_param_t COD, int numOfdecomp, Byte_t *COD
return 0; return 0;
} }
newLcod = 13+numOfdecomp; if( COD.Scod & 0x01){
newLcod = 13+numOfdecomp;
*CODstream++ = (Byte_t)((Byte2_t)(newLcod & 0xff00) >> 8);
*CODstream++ = (Byte_t)(newLcod & 0x00ff);
*CODstream++ = (Byte_t)((Byte2_t)(newLcod & 0xff00) >> 8);
*CODstream++ = (Byte_t)(newLcod & 0x00ff);
}
else{
newLcod = COD.Lcod;
CODstream += 2;
}
CODstream += 5; // skip Scod & SGcod CODstream += 5; // skip Scod & SGcod
// SPcod // SPcod
@ -258,7 +263,7 @@ bool modify_tileheader( Byte_t *j2kstream, Byte8_t SOToffset, int numOfdecomp, B
thstream += ((thstream[0]<<8)+(thstream[1])); // marker length thstream += ((thstream[0]<<8)+(thstream[1])); // marker length
} }
if( (*j2klen)-SOToffset < Psot){ if( (*j2klen)-SOToffset != Psot){
Psot = (*j2klen)-SOToffset; Psot = (*j2klen)-SOToffset;
modify_4Bytecode( Psot, Psot_stream); modify_4Bytecode( Psot, Psot_stream);
} }

View File

@ -312,17 +312,23 @@ Byte_t * recons_RPCLbitstream( msgqueue_param_t *msgqueue, Byte_t *jpipstream, B
Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD, int mindeclev, Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD, int mindeclev,
int *max_reslev, Byte8_t *j2klen) int *max_reslev, Byte8_t *j2klen)
{ {
int r, p, c; int r, p, c, numOfprcts;
bool foundPrec; bool foundPrec;
Byte8_t binOffset, precID, seqID; Byte8_t binOffset, precID, seqID;
Byte4_t XTsiz, YTsiz; Byte4_t XTsiz, YTsiz;
message_param_t *ptr; message_param_t *ptr;
for( r=0, seqID=0; r<=(COD.numOfdecomp-mindeclev); r++){ for( r=0, seqID=0; r<=(COD.numOfdecomp-mindeclev); r++){
XTsiz = get_tile_XSiz( SIZ, tileID, COD.numOfdecomp-r);
YTsiz = get_tile_YSiz( SIZ, tileID, COD.numOfdecomp-r);
for( p=0; p<ceil((double)XTsiz/(double)COD.XPsiz[r])*ceil((double)YTsiz/(double)COD.YPsiz[r]); p++, seqID++){ if( COD.Scod & 0x01){
XTsiz = get_tile_XSiz( SIZ, tileID, COD.numOfdecomp-r);
YTsiz = get_tile_YSiz( SIZ, tileID, COD.numOfdecomp-r);
numOfprcts = ceil((double)XTsiz/(double)COD.XPsiz[r])*ceil((double)YTsiz/(double)COD.YPsiz[r]);
}
else
numOfprcts = 1;
for( p=0; p<numOfprcts; p++, seqID++){
for( c=0; c<SIZ.Csiz; c++){ for( c=0; c<SIZ.Csiz; c++){
precID = comp_precinct_id( tileID, c, seqID, SIZ.Csiz, SIZ.XTnum*SIZ.YTnum); precID = comp_precinct_id( tileID, c, seqID, SIZ.Csiz, SIZ.XTnum*SIZ.YTnum);
@ -341,7 +347,7 @@ Byte_t * recons_RPCLbitstream( msgqueue_param_t *msgqueue, Byte_t *jpipstream, B
} }
ptr = ptr->next; ptr = ptr->next;
} }
if(!foundPrec) if(!foundPrec && COD.Scod & 0x01)
j2kstream = add_padding( 1, j2kstream, j2klen); j2kstream = add_padding( 1, j2kstream, j2klen);
} }
} }

View File

@ -164,7 +164,7 @@ void enqueue_tileheader( int tile_id, msgqueue_param_t *msgqueue)
msg->bin_offset = 0; msg->bin_offset = 0;
msg->length = codeidx->tileheader[tile_id]->tlen; msg->length = codeidx->tileheader[tile_id]->tlen;
msg->aux = 0; // non exist msg->aux = 0; // non exist
msg->res_offset = codeidx->offset + get_elemOff( codeidx->tilepart, 0, tile_id); // Changed from Lucian's msg->res_offset = codeidx->offset + get_elemOff( codeidx->tilepart, 0, tile_id);
msg->phld = NULL; msg->phld = NULL;
msg->next = NULL; msg->next = NULL;
@ -183,7 +183,7 @@ void enqueue_tile( int tile_id, int level, msgqueue_param_t *msgqueue)
index_param_t *codeidx; index_param_t *codeidx;
faixbox_param_t *tilepart; faixbox_param_t *tilepart;
message_param_t *msg; message_param_t *msg;
Byte8_t binOffset, binLength; Byte8_t binOffset, binLength, class_id;
int i; int i;
cachemodel = msgqueue->cachemodel; cachemodel = msgqueue->cachemodel;
@ -194,6 +194,8 @@ void enqueue_tile( int tile_id, int level, msgqueue_param_t *msgqueue)
numOftparts = get_nmax( tilepart); numOftparts = get_nmax( tilepart);
numOftiles = get_m( tilepart); numOftiles = get_m( tilepart);
class_id = (numOftparts==1) ? TILE_MSG : EXT_TILE_MSG;
if( tile_id < 0 || numOftiles <= tile_id){ if( tile_id < 0 || numOftiles <= tile_id){
fprintf( FCGI_stderr, "Error, Invalid tile-id %d\n", tile_id); fprintf( FCGI_stderr, "Error, Invalid tile-id %d\n", tile_id);
return; return;
@ -210,11 +212,7 @@ void enqueue_tile( int tile_id, int level, msgqueue_param_t *msgqueue)
msg->last_byte = i==numOftparts-1? true : false; msg->last_byte = i==numOftparts-1? true : false;
msg->in_class_id = tile_id; msg->in_class_id = tile_id;
#if 0 msg->class_id = class_id;
msg->class_id = TILE_MSG;
#else
msg->class_id = EXT_TILE_MSG;
#endif
msg->csn = target->csn; msg->csn = target->csn;
msg->bin_offset = binOffset; msg->bin_offset = binOffset;
msg->length = binLength; msg->length = binLength;

View File

@ -106,7 +106,6 @@ void print_msgqueue( msgqueue_param_t *msgqueue);
*/ */
void enqueue_mainheader( msgqueue_param_t *msgqueue); void enqueue_mainheader( msgqueue_param_t *msgqueue);
/** /**
* enqueue tile headers data-bin into message queue * enqueue tile headers data-bin into message queue
* *
@ -115,7 +114,6 @@ void enqueue_mainheader( msgqueue_param_t *msgqueue);
*/ */
void enqueue_tileheader( int tile_id, msgqueue_param_t *msgqueue); void enqueue_tileheader( int tile_id, msgqueue_param_t *msgqueue);
/** /**
* enqueue tile data-bin into message queue * enqueue tile data-bin into message queue
* *

View File

@ -98,7 +98,8 @@ target_param_t * gene_target( targetlist_param_t *targetlist, char *targetname)
target->csn = last_csn++; target->csn = last_csn++;
target->codeidx = jp2idx; target->codeidx = jp2idx;
target->num_of_use = 0; target->num_of_use = 0;
target->jppstream = true;
target->jptstream = isJPTfeasible( *jp2idx);
target->next=NULL; target->next=NULL;
if( targetlist->first) // there are one or more entries if( targetlist->first) // there are one or more entries

View File

@ -31,6 +31,7 @@
#ifndef TARGET_MANAGER_H_ #ifndef TARGET_MANAGER_H_
# define TARGET_MANAGER_H_ # define TARGET_MANAGER_H_
#include "bool.h"
#include "index_manager.h" #include "index_manager.h"
//! maximum length of target identifier //! maximum length of target identifier
@ -47,6 +48,8 @@ typedef struct target_param{
int csn; //!< codestream number int csn; //!< codestream number
index_param_t *codeidx; //!< index information of codestream index_param_t *codeidx; //!< index information of codestream
int num_of_use; //!< numbers of sessions refering to this target int num_of_use; //!< numbers of sessions refering to this target
bool jppstream; //!< if this target can return JPP-stream
bool jptstream; //!< if this target can return JPP-stream
struct target_param *next; //!< pointer to the next target struct target_param *next; //!< pointer to the next target
} target_param_t; } target_param_t;

View File

@ -1 +1 @@
opj_viewer-20110930.jar opj_viewer-20111007.jar

View File

@ -43,25 +43,26 @@ public class ImageManager extends JPIPHttpClient
public int getOrigWidth(){ return pnmimage.get_width();} public int getOrigWidth(){ return pnmimage.get_width();}
public int getOrigHeight(){ return pnmimage.get_height();} public int getOrigHeight(){ return pnmimage.get_height();}
public Image getImage( String j2kfilename, int reqfw, int reqfh, boolean reqcnew) public Image getImage( String j2kfilename, int reqfw, int reqfh, boolean reqcnew, boolean reqJPP, boolean reqJPT)
{ {
System.err.println(); System.err.println();
String refcid = null; String refcid = null;
byte[] jpipstream; byte[] jpipstream;
// Todo: check if the cid is for the same stream type
if( reqcnew) if( reqcnew)
refcid = ImgdecClient.query_cid( j2kfilename); refcid = ImgdecClient.query_cid( j2kfilename);
if( refcid == null){ if( refcid == null){
String reftid = ImgdecClient.query_tid( j2kfilename); String reftid = ImgdecClient.query_tid( j2kfilename);
if( reftid == null) if( reftid == null)
jpipstream = super.requestViewWindow( j2kfilename, reqfw, reqfh, reqcnew); jpipstream = super.requestViewWindow( j2kfilename, reqfw, reqfh, reqcnew, reqJPP, reqJPT);
else else
jpipstream = super.requestViewWindow( j2kfilename, reftid, reqfw, reqfh, reqcnew); jpipstream = super.requestViewWindow( j2kfilename, reftid, reqfw, reqfh, reqcnew, reqJPP, reqJPT);
} }
else else
jpipstream = super.requestViewWindow( reqfw, reqfh, refcid, reqcnew); jpipstream = super.requestViewWindow( reqfw, reqfh, refcid, reqcnew, reqJPP, reqJPT);
System.err.println( "decoding to PNM image"); System.err.println( "decoding to PNM image");
if((pnmimage = ImgdecClient.decode_jpipstream( jpipstream, j2kfilename, tid, cid, fw, fh))!=null){ if((pnmimage = ImgdecClient.decode_jpipstream( jpipstream, j2kfilename, tid, cid, fw, fh))!=null){

View File

@ -53,7 +53,7 @@ public class ImageViewer extends JPanel
private Rectangle roirect[] = null; private Rectangle roirect[] = null;
private String roiname[] = null; private String roiname[] = null;
public ImageViewer( String j2kfilename, ImageManager manager, boolean session) public ImageViewer( String j2kfilename, ImageManager manager, boolean session, boolean jppstream)
{ {
String str; String str;
MML myMML; MML myMML;
@ -69,7 +69,7 @@ public class ImageViewer extends JPanel
imgmanager = manager; imgmanager = manager;
img = imgmanager.getImage( j2kfilename, vw, vh, session); img = imgmanager.getImage( j2kfilename, vw, vh, session, jppstream, !jppstream);
addMouseListener(myMML); addMouseListener(myMML);
addMouseMotionListener(myMML); addMouseMotionListener(myMML);

View File

@ -35,24 +35,20 @@ import java.awt.*;
public class ImageWindow extends JFrame public class ImageWindow extends JFrame
{ {
private ImageViewer imgviewer; private ImageViewer imgviewer;
// private OptionPanel optpanel;
private ImageManager imgmanager; private ImageManager imgmanager;
public ImageWindow( String uri, String j2kfilename, boolean session) public ImageWindow( String uri, String j2kfilename, boolean session, boolean jppstream)
{ {
super( j2kfilename); super( j2kfilename);
imgmanager = new ImageManager( uri); imgmanager = new ImageManager( uri);
imgviewer = new ImageViewer( j2kfilename, imgmanager, session); imgviewer = new ImageViewer( j2kfilename, imgmanager, session, jppstream);
imgviewer.setOpaque(true); //content panes must be opaque imgviewer.setOpaque(true); //content panes must be opaque
// optpanel = new OptionPanel( imgmanager, imgviewer);
JPanel panel = new JPanel(); JPanel panel = new JPanel();
panel.setLayout(new BorderLayout()); panel.setLayout(new BorderLayout());
panel.add( imgviewer, BorderLayout.CENTER); panel.add( imgviewer, BorderLayout.CENTER);
// panel.add( optpanel, BorderLayout.EAST);
setContentPane( panel); setContentPane( panel);
@ -71,21 +67,26 @@ public class ImageWindow extends JFrame
public static void main(String s[]) public static void main(String s[])
{ {
String j2kfilename, uri; String j2kfilename, uri;
boolean session; boolean session, jppstream;
if(s.length > 0){ if(s.length >= 2){
uri = s[0]; uri = s[0];
j2kfilename = s[1]; j2kfilename = s[1];
if( s.length > 2) if( s.length > 2)
session = !s[2].equalsIgnoreCase( "stateless"); session = !s[2].equalsIgnoreCase( "stateless");
else else
session = true; session = true;
if( s.length > 3)
jppstream = !s[3].equalsIgnoreCase( "JPT");
else
jppstream = true;
} }
else{ else{
System.out.println("Usage: java -jar opj_viewer.jar HTTP_server_URI imagefile.jp2 [stateless/session]"); System.out.println("Usage: java -jar opj_viewer.jar HTTP_server_URI imagefile.jp2 [stateless/session] [JPT/JPP]");
return; return;
} }
ImageWindow frame = new ImageWindow( uri, j2kfilename, session); ImageWindow frame = new ImageWindow( uri, j2kfilename, session, jppstream);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

View File

@ -41,6 +41,8 @@ public class JPIPHttpClient
protected int rw, rh; protected int rw, rh;
protected String cid; protected String cid;
protected String tid; protected String tid;
private boolean JPTstream;
private boolean JPPstream;
public JPIPHttpClient( String URI) public JPIPHttpClient( String URI)
{ {
@ -50,6 +52,8 @@ public class JPIPHttpClient
rw = rh = -1; rw = rh = -1;
cid = null; cid = null;
tid = null; tid = null;
JPTstream = false;
JPPstream = false;
} }
public int getFw(){ return fw;} public int getFw(){ return fw;}
@ -72,53 +76,52 @@ public class JPIPHttpClient
if( cid != null) if( cid != null)
return requestViewWindow( reqfw, reqfh, reqrx, reqry, reqrw, reqrh, cid); return requestViewWindow( reqfw, reqfh, reqrx, reqry, reqrw, reqrh, cid);
else else
// return null;
if( tid != null) if( tid != null)
return requestViewWindow( null, tid, reqfw, reqfh, reqrx, reqry, reqrw, reqrh, null, false); return requestViewWindow( null, tid, reqfw, reqfh, reqrx, reqry, reqrw, reqrh, null, false, false, false);
else else
return null; return null;
} }
public byte[] requestViewWindow( int reqfw, int reqfh, String reqcid) public byte[] requestViewWindow( int reqfw, int reqfh, String reqcid)
{ {
return requestViewWindow( null, null, reqfw, reqfh, -1, -1, -1, -1, reqcid, false); return requestViewWindow( null, null, reqfw, reqfh, -1, -1, -1, -1, reqcid, false, false, false);
} }
public byte[] requestViewWindow( int reqfw, int reqfh, int reqrx, int reqry, int reqrw, int reqrh, String reqcid) public byte[] requestViewWindow( int reqfw, int reqfh, int reqrx, int reqry, int reqrw, int reqrh, String reqcid)
{ {
return requestViewWindow( null, null, reqfw, reqfh, reqrx, reqry, reqrw, reqrh, reqcid, false); return requestViewWindow( null, null, reqfw, reqfh, reqrx, reqry, reqrw, reqrh, reqcid, false, false, false);
} }
public byte[] requestViewWindow( String target, int reqfw, int reqfh) public byte[] requestViewWindow( String target, int reqfw, int reqfh)
{ {
return requestViewWindow( target, null, reqfw, reqfh, -1, -1, -1, -1, null, false); return requestViewWindow( target, null, reqfw, reqfh, -1, -1, -1, -1, null, false, false, false);
} }
public byte[] requestViewWindow( String target, int reqfw, int reqfh, boolean reqcnew) public byte[] requestViewWindow( String target, int reqfw, int reqfh, boolean reqcnew, boolean reqJPP, boolean reqJPT)
{ {
if( cid == null) // 1 channel allocation only if( cid == null) // 1 channel allocation only
return requestViewWindow( target, null, reqfw, reqfh, -1, -1, -1, -1, null, reqcnew); return requestViewWindow( target, null, reqfw, reqfh, -1, -1, -1, -1, null, reqcnew, reqJPP, reqJPT);
else else
return null; return null;
} }
public byte[] requestViewWindow( String target, String reqtid, int reqfw, int reqfh, boolean reqcnew) public byte[] requestViewWindow( String target, String reqtid, int reqfw, int reqfh, boolean reqcnew, boolean reqJPP, boolean reqJPT)
{ {
if( cid == null) // 1 channel allocation only if( cid == null) // 1 channel allocation only
return requestViewWindow( target, reqtid, reqfw, reqfh, -1, -1, -1, -1, null, reqcnew); return requestViewWindow( target, reqtid, reqfw, reqfh, -1, -1, -1, -1, null, reqcnew, reqJPP, reqJPT);
else else
return null; return null;
} }
public byte[] requestViewWindow( String target, int reqfw, int reqfh, int reqrx, int reqry, int reqrw, int reqrh) public byte[] requestViewWindow( String target, int reqfw, int reqfh, int reqrx, int reqry, int reqrw, int reqrh)
{ {
return requestViewWindow( target, null, reqfw, reqfh, reqrx, reqry, reqrw, reqrh, null, false); return requestViewWindow( target, null, reqfw, reqfh, reqrx, reqry, reqrw, reqrh, null, false, false, false);
} }
public byte[] requestViewWindow( int reqfw, int reqfh, String reqcid, boolean reqcnew) public byte[] requestViewWindow( int reqfw, int reqfh, String reqcid, boolean reqcnew, boolean reqJPP, boolean reqJPT)
{ {
return requestViewWindow( null, null, reqfw, reqfh, -1, -1, -1, -1, reqcid, reqcnew); return requestViewWindow( null, null, reqfw, reqfh, -1, -1, -1, -1, reqcid, reqcnew, reqJPP, reqJPT);
} }
public byte[] requestViewWindow( String target, public byte[] requestViewWindow( String target,
@ -126,12 +129,12 @@ public class JPIPHttpClient
int reqfw, int reqfh, int reqfw, int reqfh,
int reqrx, int reqry, int reqrx, int reqry,
int reqrw, int reqrh, int reqrw, int reqrh,
String reqcid, boolean reqcnew) String reqcid, boolean reqcnew, boolean reqJPP, boolean reqJPT)
{ {
if( reqtid != null) if( reqtid != null)
tid = reqtid; tid = reqtid;
String urlstring = const_urlstring( target, reqtid, reqfw, reqfh, reqrx, reqry, reqrw, reqrh, reqcid, reqcnew); String urlstring = const_urlstring( target, reqtid, reqfw, reqfh, reqrx, reqry, reqrw, reqrh, reqcid, reqcnew, reqJPP, reqJPT);
return GETrequest( urlstring); return GETrequest( urlstring);
} }
@ -167,16 +170,24 @@ public class JPIPHttpClient
Map<String,java.util.List<String>> headers = urlconn.getHeaderFields(); Map<String,java.util.List<String>> headers = urlconn.getHeaderFields();
java.util.List<String> hvaluelist; java.util.List<String> hvaluelist;
String hvalueline;
String status = headers.get(null).get(0); String status = headers.get(null).get(0);
System.err.println( status); System.err.println( status);
if( !status.contains("OK")) if( !status.contains("OK"))
System.err.println( headers.get("Reason")); System.err.println( headers.get("Reason"));
System.err.println( headers.get("Content-type"));
hvalueline = headers.get("Content-type").get(0);
System.err.println( hvalueline);
if( hvalueline.endsWith("jpt-stream"))
JPTstream = true;
else if( hvalueline.endsWith("jpp-stream"))
JPPstream = true;
if(( hvaluelist = headers.get("JPIP-fsiz")) != null){ if(( hvaluelist = headers.get("JPIP-fsiz")) != null){
String hvalueline = hvaluelist.get(0); hvalueline = hvaluelist.get(0);
fw = Integer.valueOf( hvalueline.substring( 0, hvalueline.indexOf(','))).intValue(); fw = Integer.valueOf( hvalueline.substring( 0, hvalueline.indexOf(','))).intValue();
fh = Integer.valueOf( hvalueline.substring( hvalueline.indexOf(',')+1 )).intValue(); fh = Integer.valueOf( hvalueline.substring( hvalueline.indexOf(',')+1 )).intValue();
@ -184,27 +195,27 @@ public class JPIPHttpClient
} }
if(( hvaluelist = headers.get("JPIP-roff")) != null){ if(( hvaluelist = headers.get("JPIP-roff")) != null){
String hvalueline = hvaluelist.get(0); hvalueline = hvaluelist.get(0);
rx = Integer.valueOf( hvalueline.substring( 0, hvalueline.indexOf(','))).intValue(); rx = Integer.valueOf( hvalueline.substring( 0, hvalueline.indexOf(','))).intValue();
ry = Integer.valueOf( hvalueline.substring( hvalueline.indexOf(',')+1 )).intValue(); ry = Integer.valueOf( hvalueline.substring( hvalueline.indexOf(',')+1 )).intValue();
System.err.println("rx,ry: " + rx + "," + ry); System.err.println("rx,ry: " + rx + "," + ry);
} }
if(( hvaluelist = headers.get("JPIP-rsiz")) != null){ if(( hvaluelist = headers.get("JPIP-rsiz")) != null){
String hvalueline = hvaluelist.get(0); hvalueline = hvaluelist.get(0);
rw = Integer.valueOf( hvalueline.substring( 0, hvalueline.indexOf(','))).intValue(); rw = Integer.valueOf( hvalueline.substring( 0, hvalueline.indexOf(','))).intValue();
rh = Integer.valueOf( hvalueline.substring( hvalueline.indexOf(',')+1 )).intValue(); rh = Integer.valueOf( hvalueline.substring( hvalueline.indexOf(',')+1 )).intValue();
System.err.println("rw,rh: " + rw + "," + rh); System.err.println("rw,rh: " + rw + "," + rh);
} }
if(( hvaluelist = headers.get("JPIP-cnew")) != null){ if(( hvaluelist = headers.get("JPIP-cnew")) != null){
String hvalueline = hvaluelist.get(0); hvalueline = hvaluelist.get(0);
cid = hvalueline.substring( hvalueline.indexOf('=')+1, hvalueline.indexOf(',')); cid = hvalueline.substring( hvalueline.indexOf('=')+1, hvalueline.indexOf(','));
System.err.println("cid: " + cid); System.err.println("cid: " + cid);
} }
if(( hvaluelist = headers.get("JPIP-tid")) != null){ if(( hvaluelist = headers.get("JPIP-tid")) != null){
String hvalueline = hvaluelist.get(0); hvalueline = hvaluelist.get(0);
tid = hvalueline.substring( hvalueline.indexOf('=')+1); tid = hvalueline.substring( hvalueline.indexOf('=')+1);
System.err.println("tid: " + tid); System.err.println("tid: " + tid);
} }
@ -270,7 +281,7 @@ public class JPIPHttpClient
int reqfw, int reqfh, int reqfw, int reqfh,
int reqrx, int reqry, int reqrx, int reqry,
int reqrw, int reqrh, int reqrw, int reqrh,
String reqcid, boolean reqcnew) String reqcid, boolean reqcnew, boolean reqJPP, boolean reqJPT)
{ {
String urlstring = comURL; String urlstring = comURL;
@ -313,9 +324,24 @@ public class JPIPHttpClient
urlstring = urlstring.concat( "cnew=http"); urlstring = urlstring.concat( "cnew=http");
} }
if( !urlstring.endsWith("?")) if( reqJPP && !JPTstream){
urlstring = urlstring.concat( "&"); if( !urlstring.endsWith("?"))
urlstring = urlstring.concat( "type=jpp-stream"); urlstring = urlstring.concat( "&");
urlstring = urlstring.concat( "type=jpp-stream");
}
else if( reqJPT && !JPPstream){
if( !urlstring.endsWith("?"))
urlstring = urlstring.concat( "&");
urlstring = urlstring.concat( "type=jpt-stream");
}
else{ // remove this option later
if( !urlstring.endsWith("?"))
urlstring = urlstring.concat( "&");
if( JPTstream)
urlstring = urlstring.concat( "type=jpt-stream");
else if( JPPstream)
urlstring = urlstring.concat( "type=jpp-stream");
}
return urlstring; return urlstring;
} }

View File

@ -1 +1 @@
opj_viewer_xerces-20110930.jar opj_viewer_xerces-20111010.jar

View File

@ -40,8 +40,6 @@ import java.io.*;
public class ImageViewer extends JPanel public class ImageViewer extends JPanel
{ {
private MML myMML;
private ResizeListener myRL;
private ImageManager imgmanager; private ImageManager imgmanager;
private int vw, vh; private int vw, vh;
private int iw, ih; private int iw, ih;
@ -55,11 +53,12 @@ public class ImageViewer extends JPanel
private Rectangle roirect[] = null; private Rectangle roirect[] = null;
private String roiname[] = null; private String roiname[] = null;
public ImageViewer( String j2kfilename, ImageManager manager) public ImageViewer( String j2kfilename, ImageManager manager, boolean session, boolean jppstream)
{ {
String str; String str;
MML myMML;
this.setSize( 200, 200); this.setSize( 170, 170);
Dimension asz = this.getSize(); Dimension asz = this.getSize();
vw = asz.width; vw = asz.width;
@ -67,14 +66,14 @@ public class ImageViewer extends JPanel
setBackground(Color.black); setBackground(Color.black);
myMML = new MML(this); myMML = new MML(this);
myRL = new ResizeListener(this);
imgmanager = manager; imgmanager = manager;
img = imgmanager.getImage( j2kfilename, vw, vh);
img = imgmanager.getImage( j2kfilename, vw, vh, session, jppstream, !jppstream);
addMouseListener(myMML); addMouseListener(myMML);
addMouseMotionListener(myMML); addMouseMotionListener(myMML);
addComponentListener(myRL); addComponentListener( new ResizeListener(this));
} }
public Image getImage() public Image getImage()
@ -87,8 +86,8 @@ public class ImageViewer extends JPanel
roirect = null; roirect = null;
roiname = null; roiname = null;
double scalex = vw/(double)rect.width; double scalex = (double)vw/(double)rect.width;
double scaley = vh/(double)rect.height; double scaley = (double)vh/(double)rect.height;
int fw = (int)(imgmanager.getFw()*scalex); int fw = (int)(imgmanager.getFw()*scalex);
int fh = (int)(imgmanager.getFh()*scaley); int fh = (int)(imgmanager.getFh()*scaley);

View File

@ -38,13 +38,13 @@ public class ImageWindow extends JFrame
private OptionPanel optpanel; private OptionPanel optpanel;
private ImageManager imgmanager; private ImageManager imgmanager;
public ImageWindow( String uri, String j2kfilename) public ImageWindow( String uri, String j2kfilename, boolean session, boolean jppstream)
{ {
super( j2kfilename); super( j2kfilename);
imgmanager = new ImageManager( uri); imgmanager = new ImageManager( uri);
imgviewer = new ImageViewer( j2kfilename, imgmanager); imgviewer = new ImageViewer( j2kfilename, imgmanager, session, jppstream);
imgviewer.setOpaque(true); //content panes must be opaque imgviewer.setOpaque(true); //content panes must be opaque
optpanel = new OptionPanel( imgmanager, imgviewer); optpanel = new OptionPanel( imgmanager, imgviewer);
@ -71,16 +71,26 @@ public class ImageWindow extends JFrame
public static void main(String s[]) public static void main(String s[])
{ {
String j2kfilename, uri; String j2kfilename, uri;
boolean session, jppstream;
if(s.length > 0){ if(s.length >= 2){
uri = s[0]; uri = s[0];
j2kfilename = s[1]; j2kfilename = s[1];
if( s.length > 2)
session = !s[2].equalsIgnoreCase( "stateless");
else
session = true;
if( s.length > 3)
jppstream = !s[3].equalsIgnoreCase( "JPT");
else
jppstream = true;
} }
else{ else{
System.out.println("Usage: java -jar opj_viewer.jar HTTP_server_URI imagefile.jp2"); System.out.println("Usage: java -jar opj_viewer.jar HTTP_server_URI imagefile.jp2 [stateless/session] [JPT/JPP]");
return; return;
} }
ImageWindow frame = new ImageWindow( uri, j2kfilename); ImageWindow frame = new ImageWindow( uri, j2kfilename, session, jppstream);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

View File

@ -116,15 +116,6 @@ int main(void)
parse_query( query_string, &query_param); parse_query( query_string, &query_param);
switch( query_param.return_type){
case JPPstream:
fprintf( FCGI_stdout, "Content-type: image/jpp-stream\r\n");
break;
default:
fprintf( FCGI_stdout, "Content-type: image/jpt-stream\r\n");
break;
}
#ifndef SERVER #ifndef SERVER
print_queryparam( query_param); print_queryparam( query_param);
#endif #endif
@ -315,7 +306,7 @@ bool open_channel( query_param_t query_param,
if( !(*cursession)) if( !(*cursession))
*cursession = gene_session( sessionlist); *cursession = gene_session( sessionlist);
if( !( cachemodel = search_cachemodel( target, (*cursession)->cachemodellist))) if( !( cachemodel = search_cachemodel( target, (*cursession)->cachemodellist)))
if( !(cachemodel = gene_cachemodel( (*cursession)->cachemodellist, target))) if( !(cachemodel = gene_cachemodel( (*cursession)->cachemodellist, target, query_param.return_type==JPPstream)))
return false; return false;
} }
else else
@ -406,7 +397,7 @@ bool gene_JPIPstream( query_param_t query_param,
if( !cursession || !curchannel){ // stateless if( !cursession || !curchannel){ // stateless
if( !target) if( !target)
return false; return false;
if( !(cachemodel = gene_cachemodel( NULL, target))) if( !(cachemodel = gene_cachemodel( NULL, target, query_param.return_type==JPPstream)))
return false; return false;
*msgqueue = gene_msgqueue( true, cachemodel); *msgqueue = gene_msgqueue( true, cachemodel);
} }
@ -416,6 +407,11 @@ bool gene_JPIPstream( query_param_t query_param,
*msgqueue = gene_msgqueue( false, cachemodel); *msgqueue = gene_msgqueue( false, cachemodel);
} }
if( cachemodel->jppstream)
fprintf( FCGI_stdout, "Content-type: image/jpp-stream\r\n");
else
fprintf( FCGI_stdout, "Content-type: image/jpt-stream\r\n");
codeidx = target->codeidx; codeidx = target->codeidx;
//meta //meta
@ -467,13 +463,19 @@ void enqueue_imagedata( query_param_t query_param, msgqueue_param_t *msgqueue)
range_param_t tile_Xrange, tile_Yrange; range_param_t tile_Xrange, tile_Yrange;
int u, v, tile_id; int u, v, tile_id;
int xmin, xmax, ymin, ymax; int xmin, xmax, ymin, ymax;
int numOfreslev;
codeidx = msgqueue->cachemodel->target->codeidx; codeidx = msgqueue->cachemodel->target->codeidx;
if( !(msgqueue->cachemodel->jppstream) && get_nmax( codeidx->tilepart) == 1) // normally not the case
numOfreslev = 1;
else
numOfreslev = codeidx->COD.numOfdecomp+1;
imgreg = map_viewin2imgreg( query_param.fx, query_param.fy, imgreg = map_viewin2imgreg( query_param.fx, query_param.fy,
query_param.rx, query_param.ry, query_param.rw, query_param.rh, query_param.rx, query_param.ry, query_param.rw, query_param.rh,
codeidx->SIZ.XOsiz, codeidx->SIZ.YOsiz, codeidx->SIZ.Xsiz, codeidx->SIZ.Ysiz, codeidx->SIZ.XOsiz, codeidx->SIZ.YOsiz, codeidx->SIZ.Xsiz, codeidx->SIZ.Ysiz,
codeidx->COD.numOfdecomp+1); numOfreslev );
for( u=0, tile_id=0; u<codeidx->SIZ.YTnum; u++){ for( u=0, tile_id=0; u<codeidx->SIZ.YTnum; u++){
tile_Yrange = get_tile_Yrange( codeidx->SIZ, tile_id, imgreg.level); tile_Yrange = get_tile_Yrange( codeidx->SIZ, tile_id, imgreg.level);
@ -496,7 +498,7 @@ void enqueue_imagedata( query_param_t query_param, msgqueue_param_t *msgqueue)
// Tile completely contained within view-window // Tile completely contained within view-window
// high priority // high priority
//printf("Tile completely contained within view-window %d\n", tile_id); //printf("Tile completely contained within view-window %d\n", tile_id);
if( query_param.return_type == JPPstream){ if( msgqueue->cachemodel->jppstream){
enqueue_tileheader( tile_id, msgqueue); enqueue_tileheader( tile_id, msgqueue);
enqueue_allprecincts( tile_id, imgreg.level, query_param.lastcomp, query_param.comps, msgqueue); enqueue_allprecincts( tile_id, imgreg.level, query_param.lastcomp, query_param.comps, msgqueue);
} }
@ -507,8 +509,9 @@ void enqueue_imagedata( query_param_t query_param, msgqueue_param_t *msgqueue)
// Tile partially overlaps view-window // Tile partially overlaps view-window
// low priority // low priority
//printf("Tile partially overlaps view-window %d\n", tile_id); //printf("Tile partially overlaps view-window %d\n", tile_id);
if( query_param.return_type == JPPstream){ if( msgqueue->cachemodel->jppstream){
enqueue_tileheader( tile_id, msgqueue); enqueue_tileheader( tile_id, msgqueue);
xmin = tile_Xrange.minvalue >= imgreg.xosiz + imgreg.ox ? 0 : imgreg.xosiz + imgreg.ox - tile_Xrange.minvalue; xmin = tile_Xrange.minvalue >= imgreg.xosiz + imgreg.ox ? 0 : imgreg.xosiz + imgreg.ox - tile_Xrange.minvalue;
xmax = tile_Xrange.maxvalue <= imgreg.xosiz + imgreg.ox + imgreg.sx ? tile_Xrange.maxvalue - tile_Xrange.minvalue -1 : imgreg.xosiz + imgreg.ox + imgreg.sx - tile_Xrange.minvalue -1; xmax = tile_Xrange.maxvalue <= imgreg.xosiz + imgreg.ox + imgreg.sx ? tile_Xrange.maxvalue - tile_Xrange.minvalue -1 : imgreg.xosiz + imgreg.ox + imgreg.sx - tile_Xrange.minvalue -1;
ymin = tile_Yrange.minvalue >= imgreg.yosiz + imgreg.oy ? 0 : imgreg.yosiz + imgreg.oy - tile_Yrange.minvalue; ymin = tile_Yrange.minvalue >= imgreg.yosiz + imgreg.oy ? 0 : imgreg.yosiz + imgreg.oy - tile_Yrange.minvalue;
@ -543,8 +546,8 @@ void enqueue_precincts( int xmin, int xmax, int ymin, int ymax, int tile_id, int
XTsiz = get_tile_XSiz( codeidx->SIZ, tile_id, dec_lev); XTsiz = get_tile_XSiz( codeidx->SIZ, tile_id, dec_lev);
YTsiz = get_tile_YSiz( codeidx->SIZ, tile_id, dec_lev); YTsiz = get_tile_YSiz( codeidx->SIZ, tile_id, dec_lev);
XPsiz = codeidx->COD.XPsiz[ res_lev]; XPsiz = ( codeidx->COD.Scod & 0x01) ? codeidx->COD.XPsiz[ res_lev] : XTsiz;
YPsiz = codeidx->COD.YPsiz[ res_lev]; YPsiz = ( codeidx->COD.Scod & 0x01) ? codeidx->COD.YPsiz[ res_lev] : YTsiz;
for( u=0; u<ceil((double)YTsiz/(double)YPsiz); u++){ for( u=0; u<ceil((double)YTsiz/(double)YPsiz); u++){
yminP = u*YPsiz; yminP = u*YPsiz;
@ -595,12 +598,11 @@ void enqueue_allprecincts( int tile_id, int level, int lastcomp, bool *comps, ms
XTsiz = get_tile_XSiz( codeidx->SIZ, tile_id, dec_lev); XTsiz = get_tile_XSiz( codeidx->SIZ, tile_id, dec_lev);
YTsiz = get_tile_YSiz( codeidx->SIZ, tile_id, dec_lev); YTsiz = get_tile_YSiz( codeidx->SIZ, tile_id, dec_lev);
XPsiz = codeidx->COD.XPsiz[ res_lev]; XPsiz = ( codeidx->COD.Scod & 0x01) ? codeidx->COD.XPsiz[ res_lev] : XTsiz;
YPsiz = codeidx->COD.YPsiz[ res_lev]; YPsiz = ( codeidx->COD.Scod & 0x01) ? codeidx->COD.YPsiz[ res_lev] : YTsiz;
for( i=0; i<ceil((double)YTsiz/(double)YPsiz)*ceil((double)XTsiz/(double)XPsiz); i++, seq_id++){ for( i=0; i<ceil((double)YTsiz/(double)YPsiz)*ceil((double)XTsiz/(double)XPsiz); i++, seq_id++)
enqueue_precinct( seq_id, tile_id, c, msgqueue); enqueue_precinct( seq_id, tile_id, c, msgqueue);
}
} }
} }
} }

View File

@ -18,4 +18,3 @@ test_index: test_index.o $(LIBFNAME)
clean: clean:
rm -f $(ALL) *.o *~ rm -f $(ALL) *.o *~
make clean -C indexer -f Makefile.nix