[trunk] start using new functionalities from opj_inttypes in jpip code and main openjpeg

This commit is contained in:
Mathieu Malaterre 2012-03-19 11:18:24 +00:00
parent e07b265009
commit ff72dd8d2c
20 changed files with 64 additions and 62 deletions

View File

@ -31,6 +31,7 @@
#include <string.h>
#include "openjpeg.h"
#include "index.h"
#include "opj_inttypes.h"
/* ------------------------------------------------------------------------------------ */
@ -380,7 +381,7 @@ int write_index_file(opj_codestream_info_t *cstr_info, char *index) {
fprintf(stream, "%d\n", cstr_info->marknum);
fprintf(stream, "type\tstart_pos length\n");
for (x = 0; x < cstr_info->marknum; x++)
fprintf(stream, "%X\t%9d %9d\n", cstr_info->marker[x].type, cstr_info->marker[x].pos, cstr_info->marker[x].len);
fprintf(stream, "%X\t%9" PRId64 " %9d\n", cstr_info->marker[x].type, cstr_info->marker[x].pos, cstr_info->marker[x].len);
}
/* <<UniPG */
fclose(stream);

View File

@ -33,6 +33,7 @@
#include <stdlib.h>
#include <ctype.h>
#include "box_manager.h"
#include "opj_inttypes.h"
#ifdef SERVER
#include "fcgi_stdio.h"
@ -43,7 +44,7 @@
#define logstream stderr
#endif /*SERVER*/
boxlist_param_t * gene_boxlist()
boxlist_param_t * gene_boxlist(void)
{
boxlist_param_t *boxlist;
@ -86,7 +87,7 @@ box_param_t * gene_boxbyOffset( int fd, Byte8_t offset)
/* read LBox and TBox*/
if(!(data = fetch_bytes( fd, offset, 8))){
fprintf( FCGI_stderr, "Error: error in gene_boxbyOffset( %d, %lld)\n", fd, offset);
fprintf( FCGI_stderr, "Error: error in gene_boxbyOffset( %d, %" PRId64 ")\n", fd, offset);
return NULL;
}
@ -111,7 +112,7 @@ box_param_t * gene_boxbyOffset( int fd, Byte8_t offset)
free(data2);
}
else{
fprintf( FCGI_stderr, "Error: error in gene_boxbyOffset( %d, %lld)\n", fd, offset);
fprintf( FCGI_stderr, "Error: error in gene_boxbyOffset( %d, %" PRId64 ")\n", fd, offset);
free( data);
return NULL;
}
@ -193,7 +194,7 @@ box_param_t * gene_boxbyType( int fd, Byte8_t offset, Byte8_t length, const char
free(data2);
}
else{
fprintf( FCGI_stderr, "Error: error in gene_boxbyType( %d, %lld, %lld, %s)\n", fd, offset, length, TBox);
fprintf( FCGI_stderr, "Error: error in gene_boxbyType( %d, %" PRId64 ", %" PRId64 ", %s)\n", fd, offset, length, TBox);
return NULL;
}
}
@ -211,7 +212,7 @@ box_param_t * gene_boxbyType( int fd, Byte8_t offset, Byte8_t length, const char
free( data);
}
else{
fprintf( FCGI_stderr, "Error: error in gene_boxbyType( %d, %lld, %lld, %s)\n", fd, offset, length, TBox);
fprintf( FCGI_stderr, "Error: error in gene_boxbyType( %d, %" PRId64 ", %" PRId64 ", %s)\n", fd, offset, length, TBox);
return NULL;
}
pos+= boxlen;
@ -339,9 +340,10 @@ void print_box( box_param_t *box)
{
fprintf( logstream, "box info:\n"
"\t type: %.4s\n"
"\t offset: %lld %#llx\n"
"\t offset: %" PRId64 " %#" PRIx64 "\n"
"\t header length: %d\n"
"\t length: %lld %#llx\n", box->type, box->offset, box->offset, box->headlen, box->length, box->length);
"\t length: %" PRId64 " %#" PRIx64 "\n", box->type, box->offset,
box->offset, box->headlen, box->length, box->length);
}
void print_allbox( boxlist_param_t *boxlist)

View File

@ -56,7 +56,7 @@ typedef struct boxlist_param{
*
* @return pointer to the generated box list
*/
boxlist_param_t * gene_boxlist();
boxlist_param_t * gene_boxlist(void);
/**
* get box structure of JP2 file

View File

@ -33,6 +33,7 @@
#include <string.h>
#include <stdlib.h>
#include "boxheader_manager.h"
#include "opj_inttypes.h"
#ifdef SERVER
#include "fcgi_stdio.h"
@ -79,5 +80,5 @@ void print_boxheader( boxheader_param_t *boxheader)
{
fprintf( logstream, "boxheader info:\n"
"\t type: %.4s\n"
"\t length:%lld %#llx\n", boxheader->type, boxheader->length, boxheader->length);
"\t length:%" PRId64 " %#" PRIx64 "\n", boxheader->type, boxheader->length, boxheader->length);
}

View File

@ -31,28 +31,11 @@
#ifndef BYTE_MANAGER_H_
#define BYTE_MANAGER_H_
#include "opj_config.h"
#ifdef HAVE_STDINT_H
#include <stdint.h>
#include "opj_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 __int8 Byte_t;
/** 2Byte parameter type*/
typedef unsigned __int16 Byte2_t;
/** 4Byte parameter type*/
typedef unsigned __int32 Byte4_t;
/** 8Byte parameter type*/
typedef unsigned __int64 Byte8_t;
#else
#error unsupported platform
#endif
#endif
/**
* fetch bytes of data in file stream

View File

@ -33,7 +33,7 @@
#include <string.h>
#include "cache_manager.h"
cachelist_param_t * gene_cachelist()
cachelist_param_t * gene_cachelist(void)
{
cachelist_param_t *cachelist;

View File

@ -58,7 +58,7 @@ typedef struct cachelist_param{
*
* @return pointer to the generated cache list
*/
cachelist_param_t * gene_cachelist();
cachelist_param_t * gene_cachelist(void);
/**
* delete cache list

View File

@ -32,6 +32,7 @@
#include <stdlib.h>
#include "cachemodel_manager.h"
#include "faixbox_manager.h"
#include "opj_inttypes.h"
#ifdef SERVER
#include "fcgi_stdio.h"
@ -136,9 +137,9 @@ void print_cachemodel( cachemodel_param_t cachemodel)
fprintf( logstream, "\t tile header and precinct packet model:\n");
for( i=0; i<target->codeidx->SIZ.XTnum*target->codeidx->SIZ.YTnum; i++){
fprintf( logstream, "\t tile.%llud %d\n", i, cachemodel.th_model[i]);
fprintf( logstream, "\t tile.%" PRIu64 " %d\n", i, cachemodel.th_model[i]);
for( j=0; j<target->codeidx->SIZ.Csiz; j++){
fprintf( logstream, "\t compo.%llud: ", j);
fprintf( logstream, "\t compo.%" PRIu64 ": ", j);
Pmax = get_nmax( target->codeidx->precpacket[j]);
for( k=0; k<Pmax; k++)
fprintf( logstream, "%d", cachemodel.pp_model[j][i*Pmax+k]);

View File

@ -30,6 +30,7 @@
#include <stdio.h>
#include "codestream_manager.h"
#include "opj_inttypes.h"
#ifdef SERVER
#include "fcgi_stdio.h"
@ -75,6 +76,6 @@ void print_codestream( codestream_param_t cs)
{
fprintf( logstream, "codestream info:\n"
"\t fd: %d\n"
"\t offset: %#llx\n"
"\t length: %#llx\n", cs.fd, cs.offset, cs.length);
"\t offset: %#" PRIx64 "\n"
"\t length: %#" PRIx64 "\n", cs.fd, cs.offset, cs.length);
}

View File

@ -31,6 +31,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "faixbox_manager.h"
#include "opj_inttypes.h"
#ifdef SERVER
#include "fcgi_stdio.h"
@ -115,12 +116,12 @@ void print_faixbox( faixbox_param_t *faix)
fprintf( logstream, "faix box info\n");
fprintf( logstream, "\tversion: %d\n", faix->version);
fprintf( logstream, "\t nmax: %#llx = %lld\n", get_nmax( faix), get_nmax( faix));
fprintf( logstream, "\t m: %#llx = %lld\n", get_m( faix), get_m( faix));
fprintf( logstream, "\t nmax: %#" PRIx64 " = %" PRId64 "\n", get_nmax( faix), get_nmax( faix));
fprintf( logstream, "\t m: %#" PRIx64 " = %" PRId64 "\n", get_m( faix), get_m( faix));
for( i=0; i<get_m( faix); i++){
for( j=0; j<get_nmax( faix); j++){
fprintf( logstream, "\t off = %#llx, len = %#llx", get_elemOff( faix, j, i), get_elemLen( faix, j, i));
fprintf( logstream, "\t off = %#" PRIx64 ", len = %#" PRIx64 "", get_elemOff( faix, j, i), get_elemLen( faix, j, i));
if( 2 <= faix->version)
fprintf( logstream, ", aux = %#x", get_elemAux( faix, j, i));
fprintf( logstream, "\n");

View File

@ -34,6 +34,7 @@
#include <string.h>
#include "bool.h"
#include "opj_inttypes.h"
#include "index_manager.h"
#include "box_manager.h"
#include "manfbox_manager.h"
@ -123,9 +124,9 @@ void print_index( index_param_t index)
int i;
fprintf( logstream, "index info:\n");
fprintf( logstream, "\tCodestream Offset: %#llx\n", index.offset);
fprintf( logstream, "\t Length: %#llx\n", index.length);
fprintf( logstream, "\tMain header Length: %#llx\n", index.mhead_length);
fprintf( logstream, "\tCodestream Offset: %#" PRIx64 "\n", index.offset);
fprintf( logstream, "\t Length: %#" PRIx64 "\n", index.length);
fprintf( logstream, "\tMain header Length: %#" PRIx64 "\n", index.mhead_length);
print_SIZ( index.SIZ);
print_COD( index.COD);

View File

@ -91,7 +91,7 @@ Byte_t * j2k_to_pnm( FILE *fp, ihdrbox_param_t **ihdrbox)
return NULL;
}
#ifdef TODO //decode area could be set from j2k_to_pnm call, modify the protocol between JPIP viewer and opj_dec_server
#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");
opj_stream_destroy(cio);
@ -99,7 +99,7 @@ Byte_t * j2k_to_pnm( FILE *fp, ihdrbox_param_t **ihdrbox)
opj_image_destroy(image);
return NULL;
}
#endif //TODO
#endif /*TODO*/
/* Get the decoded image */
if ( !( opj_decode_v2(dinfo, cio, image) && opj_end_decompress(dinfo,cio) ) ) {
@ -161,7 +161,7 @@ Byte_t * imagetopnm(opj_image_t *image, ihdrbox_param_t **ihdrbox)
int adjustR, adjustG=0, adjustB=0;
int datasize;
Byte_t *pix=NULL, *ptr=NULL;
int i;
OPJ_UINT32 i;
if(*ihdrbox){
if( (*ihdrbox)->nc != image->numcomps)

View File

@ -36,6 +36,7 @@
#include "jp2k_encoder.h"
#include "j2kheader_manager.h"
#include "imgreg_manager.h"
#include "opj_inttypes.h"
#ifdef SERVER
@ -156,7 +157,7 @@ bool isJPPstream( Byte8_t csn, msgqueue_param_t *msgqueue)
msg = msg->next;
}
fprintf( FCGI_stderr, "Error, message of csn %lld not found\n", csn);
fprintf( FCGI_stderr, "Error, message of csn %" PRId64 " not found\n", csn);
return false;
}

View File

@ -347,7 +347,6 @@ void enqueue_imagedata( query_param_t query_param, msgqueue_param_t *msgqueue)
}
/* MM: shouldnt xmin/xmax be Byte4_t instead ? */
void enqueue_precincts( int xmin, int xmax, int ymin, int ymax, int tile_id, int level, int lastcomp, bool *comps, int layers, msgqueue_param_t *msgqueue)
{
index_param_t *codeidx;
@ -358,6 +357,9 @@ void enqueue_precincts( int xmin, int xmax, int ymin, int ymax, int tile_id, int
Byte4_t xminP, xmaxP, yminP, ymaxP;
codeidx = msgqueue->cachemodel->target->codeidx;
/* MM: shouldnt xmin/xmax be Byte4_t instead ? */
if( xmin < 0 || xmax < 0 || ymin < 0 || ymax < 0)
return;
for( c=0; c<codeidx->SIZ.Csiz; c++)
if( lastcomp == -1 /*all*/ || ( c<=lastcomp && comps[c])){
@ -382,10 +384,10 @@ void enqueue_precincts( int xmin, int xmax, int ymin, int ymax, int tile_id, int
if( XTsiz <= xmaxP)
xmaxP = XTsiz-1;
if( xmaxP < xmin || xminP > xmax || ymaxP < ymin || yminP > ymax){
if( xmaxP < (Byte4_t)xmin || xminP > (Byte4_t)xmax || ymaxP < (Byte4_t)ymin || yminP > (Byte4_t)ymax){
/* Precinct completely excluded from view-window */
}
else if( xminP >= xmin && xmaxP <= xmax && yminP >= ymin && ymaxP <= ymax){
else if( xminP >= (Byte4_t)xmin && xmaxP <= (Byte4_t)xmax && yminP >= (Byte4_t)ymin && ymaxP <= (Byte4_t)ymax){
/* Precinct completely contained within view-window
high priority */
enqueue_precinct( seq_id, tile_id, c, (dec_lev>level)?-1:layers, msgqueue);

View File

@ -29,6 +29,7 @@
*/
#include "metadata_manager.h"
#include "opj_inttypes.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -164,8 +165,9 @@ void print_metadata( metadata_param_t *metadata)
boxcont = metadata->boxcontents;
if( boxcont)
fprintf( logstream, "box contents:\n"
"\t offset: %lld %#llx\n"
"\t length: %lld %#llx\n", boxcont->offset, boxcont->offset, boxcont->length, boxcont->length);
"\t offset: %" PRId64 " %#" PRIx64 "\n"
"\t length: %" PRId64 " %#" PRIx64 "\n", boxcont->offset,
boxcont->offset, boxcont->length, boxcont->length);
}
void print_allmetadata( metadatalist_param_t *list)

View File

@ -32,6 +32,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "mhixbox_manager.h"
#include "opj_inttypes.h"
#ifdef SERVER
#include "fcgi_stdio.h"
@ -97,14 +98,14 @@ void print_mhixbox( mhixbox_param_t *mhix)
markeridx_param_t *ptr;
fprintf( logstream, "mhix box info:\n");
fprintf( logstream, "\t tlen: %#llx\n", mhix->tlen);
fprintf( logstream, "\t tlen: %#" PRIx64 "\n", mhix->tlen);
ptr = mhix->first;
while( ptr != NULL){
fprintf( logstream, "marker index info:\n"
"\t code: %#x\n"
"\t num_remain: %#x\n"
"\t offset: %#llx\n"
"\t offset: %#" PRIx64 "\n"
"\t length: %#x\n", ptr->code, ptr->num_remain, ptr->offset, ptr->length);
ptr=ptr->next;
}
@ -116,7 +117,7 @@ void print_markeridx( markeridx_param_t *markeridx)
fprintf( logstream, "marker index info:\n"
"\t code: %#x\n"
"\t num_remain: %#x\n"
"\t offset: %#llx\n"
"\t offset: %#" PRIx64 "\n"
"\t length: %#x\n", markeridx->code, markeridx->num_remain, markeridx->offset, markeridx->length);
}

View File

@ -43,6 +43,7 @@
#include "msgqueue_manager.h"
#include "metadata_manager.h"
#include "index_manager.h"
#include "opj_inttypes.h"
#ifdef SERVER
#include "fcgi_stdio.h"
@ -91,7 +92,8 @@ void delete_msgqueue( msgqueue_param_t **msgqueue)
void print_msgqueue( msgqueue_param_t *msgqueue)
{
message_param_t *ptr;
char *message_class[] = { "Precinct", "Ext-Prec", "TileHead", "non", "Tile", "Ext-Tile", "Main", "non", "Meta"};
static const char *message_class[] = { "Precinct", "Ext-Prec", "TileHead", "non",
"Tile", "Ext-Tile", "Main", "non", "Meta"};
if( !msgqueue)
return;
@ -100,18 +102,18 @@ void print_msgqueue( msgqueue_param_t *msgqueue)
ptr = msgqueue->first;
while( ptr){
fprintf( logstream, "\t class_id: %lld %s\n", ptr->class_id, message_class[ptr->class_id]);
fprintf( logstream, "\t in_class_id: %lld\n", ptr->in_class_id );
fprintf( logstream, "\t csn: %lld\n", ptr->csn );
fprintf( logstream, "\t bin_offset: %#llx\n", ptr->bin_offset );
fprintf( logstream, "\t length: %#llx\n", ptr->length );
fprintf( logstream, "\t class_id: %" PRId64 " %s\n", ptr->class_id, message_class[ptr->class_id]);
fprintf( logstream, "\t in_class_id: %" PRId64 "\n", ptr->in_class_id );
fprintf( logstream, "\t csn: %" PRId64 "\n", ptr->csn );
fprintf( logstream, "\t bin_offset: %#" PRIx64 "\n", ptr->bin_offset );
fprintf( logstream, "\t length: %#" PRIx64 "\n", ptr->length );
if( ptr->class_id%2)
fprintf( logstream, "\t aux: %lld\n", ptr->aux );
fprintf( logstream, "\t aux: %" PRId64 "\n", ptr->aux );
fprintf( logstream, "\t last_byte: %d\n", ptr->last_byte );
if( ptr->phld)
print_placeholder( ptr->phld);
else
fprintf( logstream, "\t res_offset: %#llx\n", ptr->res_offset );
fprintf( logstream, "\t res_offset: %#" PRIx64 "\n", ptr->res_offset );
fprintf( logstream, "\n");
ptr = ptr->next;

View File

@ -32,7 +32,7 @@
#include <stdlib.h>
#include <string.h>
#include "placeholder_manager.h"
#include "opj_inttypes.h"
#ifdef SERVER
#include "fcgi_stdio.h"
@ -115,7 +115,7 @@ void print_placeholder( placeholder_param_t *phld)
fprintf( logstream, "\t LBox: %d %#x\n", phld->LBox, phld->LBox);
fprintf( logstream, "\t TBox: %.4s\n", phld->TBox);
fprintf( logstream, "\t Flags: %#x %#x\n", phld->Flags, phld->Flags);
fprintf( logstream, "\t OrigID: %lld\n", phld->OrigID);
fprintf( logstream, "\t OrigID: %" PRId64 "\n", phld->OrigID);
fprintf( logstream, "\t OrigBH: ");
for( i=0; i< phld->OrigBHlen; i++)

View File

@ -1,5 +1,6 @@
# Headers file are located here:
INCLUDE_DIRECTORIES(
${OPENJPEG_SOURCE_DIR}/libopenjpeg
${OPENJPEG_SOURCE_DIR}/applications/jpip/libopenjpip
${FCGI_INCLUDE_DIRS}
)

View File

@ -32,6 +32,8 @@
#else
#if defined(_WIN32)
#define PRIi64 "I64i"
#define PRIu64 "I64u"
#define PRIx64 "I64x"
#else
#error unsupported platform
#endif