[1.5] Change the logic in byte_manager.h. Prefer the use of stdint.h when available. Default to compiler specific mecanism otherwise. Remove some c++ comments. Fix signed vs unsigned comparison

This commit is contained in:
Mathieu Malaterre 2012-03-02 16:51:10 +00:00
parent d1a1653f2a
commit dcf78f14f6
12 changed files with 68 additions and 55 deletions

View File

@ -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;

View File

@ -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
/**

View File

@ -40,9 +40,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 +68,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 +101,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;
}

View File

@ -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);
/**

View File

@ -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)
{

View File

@ -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;

View File

@ -125,7 +125,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); */
}
@ -190,7 +191,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){

View File

@ -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;

View File

@ -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)
{

View File

@ -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;

View File

@ -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;

View File

@ -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);
/**