[trunk] Backport diff from openjpeg 1.5 branch
This commit is contained in:
parent
ab7b5e48c4
commit
7f166eaee7
@ -46,7 +46,7 @@
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif //SERVER
|
||||
#endif /*SERVER */
|
||||
|
||||
auxtrans_param_t init_aux_transport( int tcp_auxport, int udp_auxport)
|
||||
{
|
||||
@ -61,7 +61,7 @@ auxtrans_param_t init_aux_transport( int tcp_auxport, int udp_auxport)
|
||||
auxtrans.tcplistensock = -1;
|
||||
|
||||
auxtrans.udplistensock = -1;
|
||||
// open listening socket for udp later
|
||||
/* open listening socket for udp later */
|
||||
|
||||
return auxtrans;
|
||||
}
|
||||
@ -78,15 +78,15 @@ void close_aux_transport( auxtrans_param_t auxtrans)
|
||||
}
|
||||
|
||||
|
||||
//!< auxiliary response parameters
|
||||
/*!< auxiliary response parameters */
|
||||
typedef struct aux_response_param{
|
||||
char *cid; //!< channel ID
|
||||
unsigned char *data; //!< sending data
|
||||
int datalen; //!< length of data
|
||||
int maxlenPerFrame; //!< maximum data length to send per frame
|
||||
SOCKET listensock; //!< listeing socket
|
||||
char *cid; /*!< channel ID */
|
||||
unsigned char *data; /*!< sending data */
|
||||
int datalen; /*!< length of data */
|
||||
int maxlenPerFrame; /*!< maximum data length to send per frame */
|
||||
SOCKET listensock; /*!< listeing socket */
|
||||
#ifdef _WIN32
|
||||
HANDLE hTh; //!< thread handle
|
||||
HANDLE hTh; /*!< thread handle */
|
||||
#endif
|
||||
} aux_response_param_t;
|
||||
|
||||
|
@ -29,19 +29,29 @@
|
||||
*/
|
||||
|
||||
#ifndef BYTE_MANAGER_H_
|
||||
# define BYTE_MANAGER_H_
|
||||
#define BYTE_MANAGER_H_
|
||||
|
||||
#include "opj_config.h"
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
typedef uint8_t Byte_t;
|
||||
typedef uint16_t Byte2_t;
|
||||
typedef uint32_t Byte4_t;
|
||||
typedef uint64_t Byte8_t;
|
||||
#else
|
||||
#if defined(_WIN32)
|
||||
/** 1Byte parameter type*/
|
||||
typedef unsigned char Byte_t;
|
||||
|
||||
typedef unsigned __int8 Byte_t;
|
||||
/** 2Byte parameter type*/
|
||||
typedef unsigned short int Byte2_t;
|
||||
|
||||
typedef unsigned __int16 Byte2_t;
|
||||
/** 4Byte parameter type*/
|
||||
typedef unsigned int Byte4_t; /* FIXME: Is this portable ? */
|
||||
|
||||
typedef unsigned __int32 Byte4_t;
|
||||
/** 8Byte parameter type*/
|
||||
typedef unsigned long long int Byte8_t;
|
||||
typedef unsigned __int64 Byte8_t;
|
||||
#else
|
||||
#error unsupported platform
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
|
@ -32,6 +32,9 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "channel_manager.h"
|
||||
#ifdef _WIN32
|
||||
#define snprintf _snprintf /* Visual Studio */
|
||||
#endif
|
||||
|
||||
#ifdef SERVER
|
||||
#include "fcgi_stdio.h"
|
||||
@ -40,9 +43,9 @@
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif //SERVER
|
||||
#endif /*SERVER */
|
||||
|
||||
channellist_param_t * gene_channellist()
|
||||
channellist_param_t * gene_channellist(void)
|
||||
{
|
||||
channellist_param_t *channellist;
|
||||
|
||||
@ -68,12 +71,12 @@ channel_param_t * gene_channel( query_param_t query_param, auxtrans_param_t auxt
|
||||
channel = (channel_param_t *)malloc( sizeof(channel_param_t));
|
||||
channel->cachemodel = cachemodel;
|
||||
|
||||
// set channel ID and get present time
|
||||
/* set channel ID and get present time */
|
||||
snprintf( channel->cid, MAX_LENOFCID, "%x%x", (unsigned int)time( &channel->start_tm), (unsigned int)rand());
|
||||
|
||||
channel->aux = query_param.cnew;
|
||||
|
||||
// only tcp implemented for now
|
||||
/* only tcp implemented for now */
|
||||
if( channel->aux == udp)
|
||||
channel->aux = tcp;
|
||||
|
||||
@ -101,7 +104,9 @@ channel_param_t * gene_channel( query_param_t query_param, auxtrans_param_t auxt
|
||||
|
||||
void set_channel_variable_param( query_param_t query_param, channel_param_t *channel)
|
||||
{
|
||||
// set roi information
|
||||
/* set roi information */
|
||||
(void)query_param;
|
||||
(void)channel;
|
||||
}
|
||||
|
||||
|
||||
|
@ -62,7 +62,7 @@ typedef struct channellist_param{
|
||||
*
|
||||
* @return pointer to the generated channel list
|
||||
*/
|
||||
channellist_param_t * gene_channellist();
|
||||
channellist_param_t * gene_channellist(void);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -38,7 +38,7 @@
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif //SERVER
|
||||
#endif /*SERVER */
|
||||
|
||||
codestream_param_t set_codestream( int fd, Byte8_t offset, Byte8_t length)
|
||||
{
|
||||
|
@ -42,7 +42,7 @@
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif //SERVER
|
||||
#endif /*SERVER */
|
||||
|
||||
|
||||
SIZmarker_param_t get_SIZmkrdata_from_j2kstream( Byte_t *SIZstream);
|
||||
@ -76,7 +76,7 @@ bool get_mainheader_from_j2kstream( Byte_t *j2kstream, SIZmarker_param_t *SIZ, C
|
||||
|
||||
SIZmarker_param_t get_SIZmkrdata_from_j2kstream( Byte_t *SIZstream)
|
||||
{
|
||||
SIZmarker_param_t SIZ ={0};
|
||||
SIZmarker_param_t SIZ = {0};
|
||||
int i;
|
||||
|
||||
if( *SIZstream++ != 0xff || *SIZstream++ != 0x51){
|
||||
@ -129,7 +129,7 @@ CODmarker_param_t get_CODmkrdata_from_j2kstream( Byte_t *CODstream)
|
||||
COD.YPsiz = (Byte4_t *)malloc( (COD.numOfdecomp+1)*sizeof(Byte4_t));
|
||||
|
||||
for( i=0; i<=COD.numOfdecomp; i++){
|
||||
//precinct size
|
||||
/*precinct size */
|
||||
COD.XPsiz[i] = pow( 2, *( CODstream+12+i) & 0x0F);
|
||||
COD.YPsiz[i] = pow( 2, (*( CODstream+12+i) & 0xF0) >> 4);
|
||||
}
|
||||
@ -188,7 +188,7 @@ bool modify_SIZmkrstream( SIZmarker_param_t SIZ, int difOfdecomplev, Byte_t *SIZ
|
||||
SIZ.YTOsiz = ceil( (double)SIZ.YTOsiz/2.0);
|
||||
}
|
||||
|
||||
SIZstream += 4; // skip Lsiz + Rsiz
|
||||
SIZstream += 4; /* skip Lsiz + Rsiz */
|
||||
|
||||
modify_4Bytecode( SIZ.Xsiz, SIZstream);
|
||||
modify_4Bytecode( SIZ.Ysiz, SIZstream+4);
|
||||
@ -222,9 +222,9 @@ Byte2_t modify_CODmkrstream( CODmarker_param_t COD, int numOfdecomp, Byte_t *COD
|
||||
CODstream += 2;
|
||||
}
|
||||
|
||||
CODstream += 5; // skip Scod & SGcod
|
||||
CODstream += 5; /* skip Scod & SGcod */
|
||||
|
||||
// SPcod
|
||||
/* SPcod */
|
||||
*CODstream++ = (Byte_t) numOfdecomp;
|
||||
|
||||
return newLcod;
|
||||
@ -234,7 +234,7 @@ bool modify_COCmkrstream( int numOfdecomp, Byte_t *COCstream, Byte2_t Csiz, Byte
|
||||
|
||||
bool modify_tileheader( Byte_t *j2kstream, Byte8_t SOToffset, int numOfdecomp, Byte2_t Csiz, Byte8_t *j2klen)
|
||||
{
|
||||
Byte4_t Psot; // tile part length ref A.4.2 Start of tile-part SOT
|
||||
Byte4_t Psot; /* tile part length ref A.4.2 Start of tile-part SOT */
|
||||
Byte_t *thstream, *SOTstream, *Psot_stream;
|
||||
Byte2_t oldLcoc, newLcoc;
|
||||
|
||||
@ -245,14 +245,14 @@ bool modify_tileheader( Byte_t *j2kstream, Byte8_t SOToffset, int numOfdecomp, B
|
||||
return false;
|
||||
}
|
||||
|
||||
SOTstream += 4; // skip Lsot & Isot
|
||||
SOTstream += 4; /* skip Lsot & Isot */
|
||||
Psot = (SOTstream[0]<<24)+(SOTstream[1]<<16)+(SOTstream[2]<<8)+(SOTstream[3]);
|
||||
Psot_stream = SOTstream;
|
||||
|
||||
thstream += 12; // move to next marker (SOT always 12bytes)
|
||||
thstream += 12; /* move to next marker (SOT always 12bytes) */
|
||||
|
||||
while( !( *thstream == 0xff && *(thstream+1) == 0x93)){ // search SOD
|
||||
if( numOfdecomp != -1 && *thstream == 0xff && *(thstream+1) == 0x53){ // COC
|
||||
while( !( *thstream == 0xff && *(thstream+1) == 0x93)){ /* search SOD */
|
||||
if( numOfdecomp != -1 && *thstream == 0xff && *(thstream+1) == 0x53){ /* COC */
|
||||
if( !modify_COCmkrstream( numOfdecomp, thstream, Csiz, &oldLcoc, &newLcoc))
|
||||
return false;
|
||||
|
||||
@ -260,7 +260,7 @@ bool modify_tileheader( Byte_t *j2kstream, Byte8_t SOToffset, int numOfdecomp, B
|
||||
*j2klen -= ( oldLcoc - newLcoc);
|
||||
}
|
||||
thstream += 2;
|
||||
thstream += ((thstream[0]<<8)+(thstream[1])); // marker length
|
||||
thstream += ((thstream[0]<<8)+(thstream[1])); /* marker length */
|
||||
}
|
||||
|
||||
if( (*j2klen)-SOToffset != Psot){
|
||||
@ -282,7 +282,7 @@ bool modify_COCmkrstream( int numOfdecomp, Byte_t *COCstream, Byte2_t Csiz, Byte
|
||||
*COCstream++ = (Byte_t)((Byte2_t)((*newLcoc) & 0xff00) >> 8);
|
||||
*COCstream++ = (Byte_t)((*newLcoc) & 0x00ff);
|
||||
|
||||
if( Csiz < 257) COCstream +=2; // skip Ccoc & Scoc
|
||||
if( Csiz < 257) COCstream +=2; /* skip Ccoc & Scoc */
|
||||
else COCstream += 3;
|
||||
|
||||
*COCstream = numOfdecomp;
|
||||
|
@ -60,7 +60,7 @@ Byte_t * j2k_to_pnm( FILE *fp, ihdrbox_param_t **ihdrbox)
|
||||
opj_set_default_decoder_parameters(¶meters);
|
||||
|
||||
/* Set default event mgr */
|
||||
opj_initialize_default_event_handler(&event_mgr, 1);
|
||||
opj_initialize_default_event_handler(&event_mgr, 1);
|
||||
|
||||
/* set a byte stream */
|
||||
cio = opj_stream_create_default_file_stream( fp, 1);
|
||||
@ -68,7 +68,7 @@ Byte_t * j2k_to_pnm( FILE *fp, ihdrbox_param_t **ihdrbox)
|
||||
fprintf(stderr, "ERROR -> failed to create the stream from the file\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* decode the code-stream */
|
||||
/* ---------------------- */
|
||||
|
||||
@ -90,7 +90,7 @@ Byte_t * j2k_to_pnm( FILE *fp, ihdrbox_param_t **ihdrbox)
|
||||
opj_image_destroy(image);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
#ifdef TODO //decode area could be set from j2k_to_pnm call, modify the protocol between JPIP viewer and opj_dec_server
|
||||
if (! opj_set_decode_area( dinfo, image, parameters.DA_x0, parameters.DA_y0, parameters.DA_x1, parameters.DA_y1)){
|
||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to set the decoded area\n");
|
||||
@ -151,7 +151,8 @@ void warning_callback(const char *msg, void *client_data) {
|
||||
*/
|
||||
void info_callback(const char *msg, void *client_data) {
|
||||
(void)client_data;
|
||||
// fprintf(stdout, "[INFO] %s", msg);
|
||||
(void)msg;
|
||||
/* fprintf(stdout, "[INFO] %s", msg); */
|
||||
}
|
||||
|
||||
|
||||
@ -216,7 +217,7 @@ Byte_t * imagetopnm(opj_image_t *image, ihdrbox_param_t **ihdrbox)
|
||||
r = image->comps[0].data[i];
|
||||
r += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
|
||||
|
||||
// if( adjustR > 0)
|
||||
/* if( adjustR > 0) */
|
||||
*(ptr++) = (Byte_t) ((r >> adjustR)+((r >> (adjustR-1))%2));
|
||||
|
||||
if( image->numcomps == 3){
|
||||
|
@ -40,14 +40,14 @@
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif //SERVER
|
||||
#endif /*SERVER */
|
||||
|
||||
manfbox_param_t * gene_manfbox( box_param_t *box)
|
||||
{
|
||||
manfbox_param_t *manf; // manifest parameters
|
||||
boxheader_param_t *bh; // current box pointer
|
||||
boxheader_param_t *last; // last boxheader pointer of the list
|
||||
int pos; // current position in manf_box contents;
|
||||
manfbox_param_t *manf; /* manifest parameters */
|
||||
boxheader_param_t *bh; /* current box pointer */
|
||||
boxheader_param_t *last; /* last boxheader pointer of the list */
|
||||
Byte8_t pos; /* current position in manf_box contents; */
|
||||
|
||||
manf = ( manfbox_param_t *)malloc( sizeof( manfbox_param_t));
|
||||
|
||||
@ -59,7 +59,7 @@ manfbox_param_t * gene_manfbox( box_param_t *box)
|
||||
bh = gene_childboxheader( box, pos);
|
||||
pos += bh->headlen;
|
||||
|
||||
// insert into the list
|
||||
/* insert into the list */
|
||||
if( manf->first)
|
||||
last->next = bh;
|
||||
else
|
||||
@ -77,7 +77,7 @@ void delete_manfbox( manfbox_param_t **manf)
|
||||
while( bhPtr != NULL){
|
||||
bhNext = bhPtr->next;
|
||||
#ifndef SERVER
|
||||
// fprintf( logstream, "local log: boxheader %.4s deleted!\n", bhPtr->type);
|
||||
/* fprintf( logstream, "local log: boxheader %.4s deleted!\n", bhPtr->type); */
|
||||
#endif
|
||||
free(bhPtr);
|
||||
bhPtr = bhNext;
|
||||
|
@ -37,7 +37,7 @@
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif //SERVER
|
||||
#endif /*SERVER */
|
||||
|
||||
marker_param_t set_marker( codestream_param_t cs, Byte2_t code, Byte8_t offset, Byte2_t length)
|
||||
{
|
||||
|
@ -40,14 +40,14 @@
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif //SERVER
|
||||
#endif /*SERVER */
|
||||
|
||||
|
||||
mhixbox_param_t * gene_mhixbox( box_param_t *box)
|
||||
{
|
||||
mhixbox_param_t *mhix;
|
||||
markeridx_param_t *mkridx, *lastmkidx;
|
||||
long pos = 0;
|
||||
Byte8_t pos = 0;
|
||||
|
||||
mhix = ( mhixbox_param_t *)malloc( sizeof( mhixbox_param_t));
|
||||
|
||||
@ -129,7 +129,7 @@ void delete_mhixbox( mhixbox_param_t **mhix)
|
||||
while( mkPtr != NULL){
|
||||
mkNext=mkPtr->next;
|
||||
#ifndef SERVER
|
||||
// fprintf( logstream, "local log: marker index %#x deleted!\n", mkPtr->code);
|
||||
/* fprintf( logstream, "local log: marker index %#x deleted!\n", mkPtr->code); */
|
||||
#endif
|
||||
free(mkPtr);
|
||||
mkPtr=mkNext;
|
||||
|
@ -41,10 +41,10 @@
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif //SERVER
|
||||
#endif /*SERVER */
|
||||
|
||||
|
||||
sessionlist_param_t * gene_sessionlist()
|
||||
sessionlist_param_t * gene_sessionlist(void)
|
||||
{
|
||||
sessionlist_param_t *sessionlist;
|
||||
|
||||
@ -67,9 +67,9 @@ session_param_t * gene_session( sessionlist_param_t *sessionlist)
|
||||
|
||||
session->next = NULL;
|
||||
|
||||
if( sessionlist->first) // there are one or more entries
|
||||
if( sessionlist->first) /* there are one or more entries */
|
||||
sessionlist->last->next = session;
|
||||
else // first entry
|
||||
else /* first entry */
|
||||
sessionlist->first = session;
|
||||
sessionlist->last = session;
|
||||
|
||||
|
@ -54,7 +54,7 @@ typedef struct sessionlist_param{
|
||||
*
|
||||
* @return pointer to the generated session list
|
||||
*/
|
||||
sessionlist_param_t * gene_sessionlist();
|
||||
sessionlist_param_t * gene_sessionlist(void);
|
||||
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user