backport r882:893 to openjpeg-1.5 branch
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <sys/types.h>
|
||||
@@ -57,7 +58,7 @@
|
||||
#define MAINHEADER_MSG 6
|
||||
#define METADATA_MSG 8
|
||||
|
||||
msgqueue_param_t * gene_msgqueue( bool stateless, target_param_t *target)
|
||||
msgqueue_param_t * gene_msgqueue( bool stateless, cachemodel_param_t *cachemodel)
|
||||
{
|
||||
msgqueue_param_t *msgqueue;
|
||||
|
||||
@@ -67,7 +68,7 @@ msgqueue_param_t * gene_msgqueue( bool stateless, target_param_t *target)
|
||||
msgqueue->last = NULL;
|
||||
|
||||
msgqueue->stateless = stateless;
|
||||
msgqueue->target = target;
|
||||
msgqueue->cachemodel = cachemodel;
|
||||
|
||||
return msgqueue;
|
||||
}
|
||||
@@ -86,8 +87,8 @@ void delete_msgqueue( msgqueue_param_t **msgqueue)
|
||||
free( ptr);
|
||||
ptr = next;
|
||||
}
|
||||
if( (*msgqueue)->stateless && (*msgqueue)->target)
|
||||
delete_target( &((*msgqueue)->target));
|
||||
if( (*msgqueue)->stateless && (*msgqueue)->cachemodel)
|
||||
delete_cachemodel( &((*msgqueue)->cachemodel));
|
||||
|
||||
free(*msgqueue);
|
||||
}
|
||||
@@ -124,10 +125,12 @@ void enqueue_message( message_param_t *msg, msgqueue_param_t *msgqueue);
|
||||
|
||||
void enqueue_mainheader( msgqueue_param_t *msgqueue)
|
||||
{
|
||||
cachemodel_param_t *cachemodel;
|
||||
target_param_t *target;
|
||||
message_param_t *msg;
|
||||
|
||||
target = msgqueue->target;
|
||||
cachemodel = msgqueue->cachemodel;
|
||||
target = cachemodel->target;
|
||||
|
||||
msg = (message_param_t *)malloc( sizeof(message_param_t));
|
||||
|
||||
@@ -144,11 +147,12 @@ void enqueue_mainheader( msgqueue_param_t *msgqueue)
|
||||
|
||||
enqueue_message( msg, msgqueue);
|
||||
|
||||
target->codeidx->mhead_model = true;
|
||||
cachemodel->mhead_model = true;
|
||||
}
|
||||
|
||||
void enqueue_tile( int tile_id, int level, msgqueue_param_t *msgqueue)
|
||||
{
|
||||
cachemodel_param_t *cachemodel;
|
||||
target_param_t *target;
|
||||
bool *tp_model;
|
||||
Byte8_t numOftparts; // num of tile parts par tile
|
||||
@@ -159,7 +163,8 @@ void enqueue_tile( int tile_id, int level, msgqueue_param_t *msgqueue)
|
||||
Byte8_t binOffset, binLength;
|
||||
int i;
|
||||
|
||||
target = msgqueue->target;
|
||||
cachemodel = msgqueue->cachemodel;
|
||||
target = cachemodel->target;
|
||||
codeidx = target->codeidx;
|
||||
tilepart = codeidx->tilepart;
|
||||
|
||||
@@ -171,7 +176,7 @@ void enqueue_tile( int tile_id, int level, msgqueue_param_t *msgqueue)
|
||||
return;
|
||||
}
|
||||
|
||||
tp_model = &codeidx->tp_model[ tile_id*numOftparts];
|
||||
tp_model = &cachemodel->tp_model[ tile_id*numOftparts];
|
||||
|
||||
binOffset=0;
|
||||
for( i=0; i<numOftparts-level; i++){
|
||||
@@ -213,7 +218,7 @@ void enqueue_metadata( int meta_id, msgqueue_param_t *msgqueue)
|
||||
metadata_param_t *metadata;
|
||||
Byte8_t binOffset;
|
||||
|
||||
metadatalist = msgqueue->target->codeidx->metadatalist;
|
||||
metadatalist = msgqueue->cachemodel->target->codeidx->metadatalist;
|
||||
metadata = search_metadata( meta_id, metadatalist);
|
||||
|
||||
if( !metadata){
|
||||
@@ -243,7 +248,7 @@ void enqueue_box( int meta_id, boxlist_param_t *boxlist, msgqueue_param_t *msgqu
|
||||
|
||||
box = boxlist->first;
|
||||
while( box){
|
||||
msg = gene_metamsg( meta_id, *binOffset, box->length, box->offset, NULL, msgqueue->target->csn);
|
||||
msg = gene_metamsg( meta_id, *binOffset, box->length, box->offset, NULL, msgqueue->cachemodel->target->csn);
|
||||
enqueue_message( msg, msgqueue);
|
||||
|
||||
*binOffset += box->length;
|
||||
@@ -258,7 +263,7 @@ void enqueue_phld( int meta_id, placeholderlist_param_t *phldlist, msgqueue_para
|
||||
|
||||
phld = phldlist->first;
|
||||
while( phld){
|
||||
msg = gene_metamsg( meta_id, *binOffset, phld->LBox, 0, phld, msgqueue->target->csn);
|
||||
msg = gene_metamsg( meta_id, *binOffset, phld->LBox, 0, phld, msgqueue->cachemodel->target->csn);
|
||||
enqueue_message( msg, msgqueue);
|
||||
|
||||
*binOffset += phld->LBox;
|
||||
@@ -270,7 +275,7 @@ void enqueue_boxcontents( int meta_id, boxcontents_param_t *boxcontents, msgqueu
|
||||
{
|
||||
message_param_t *msg;
|
||||
|
||||
msg = gene_metamsg( meta_id, *binOffset, boxcontents->length, boxcontents->offset, NULL, msgqueue->target->csn);
|
||||
msg = gene_metamsg( meta_id, *binOffset, boxcontents->length, boxcontents->offset, NULL, msgqueue->cachemodel->target->csn);
|
||||
enqueue_message( msg, msgqueue);
|
||||
|
||||
*binOffset += boxcontents->length;
|
||||
@@ -357,7 +362,7 @@ void emit_stream_from_msgqueue( msgqueue_param_t *msgqueue)
|
||||
if( msg->phld)
|
||||
emit_placeholder( msg->phld);
|
||||
else
|
||||
emit_body( msg, msgqueue->target->fd);
|
||||
emit_body( msg, msgqueue->cachemodel->target->fd);
|
||||
|
||||
msg = msg->next;
|
||||
}
|
||||
@@ -738,31 +743,45 @@ Byte_t * recons_codestream( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte
|
||||
Byte_t *codestream = NULL;
|
||||
int last_tileID;
|
||||
int tileID;
|
||||
|
||||
bool found;
|
||||
Byte8_t binOffset;
|
||||
|
||||
*codelen = 0;
|
||||
|
||||
// main header first
|
||||
ptr = msgqueue->first;
|
||||
binOffset = 0;
|
||||
while(( ptr = search_message( MAINHEADER_MSG, -1, csn, ptr))!=NULL){
|
||||
codestream = add_msgstream( ptr, jpipstream, codestream, codelen);
|
||||
if( ptr->bin_offset == binOffset){
|
||||
codestream = add_msgstream( ptr, jpipstream, codestream, codelen);
|
||||
binOffset += ptr->length;
|
||||
}
|
||||
ptr = ptr->next;
|
||||
}
|
||||
|
||||
last_tileID = get_last_tileID( msgqueue, csn);
|
||||
|
||||
for( tileID=0; tileID <= last_tileID; tileID++){
|
||||
bool found = false;
|
||||
found = false;
|
||||
binOffset = 0;
|
||||
|
||||
ptr = msgqueue->first;
|
||||
while(( ptr = search_message( TILE_MSG, tileID, csn, ptr))!=NULL){
|
||||
found = true;
|
||||
codestream = add_msgstream( ptr, jpipstream, codestream, codelen);
|
||||
if( ptr->bin_offset == binOffset){
|
||||
found = true;
|
||||
codestream = add_msgstream( ptr, jpipstream, codestream, codelen);
|
||||
binOffset += ptr->length;
|
||||
}
|
||||
ptr = ptr->next;
|
||||
}
|
||||
ptr = msgqueue->first;
|
||||
while(( ptr = search_message( EXT_TILE_MSG, tileID, csn, ptr))!=NULL){
|
||||
if( ptr->aux >= minlev){
|
||||
found = true;
|
||||
codestream = add_msgstream( ptr, jpipstream, codestream, codelen);
|
||||
if( ptr->bin_offset == binOffset){
|
||||
found = true;
|
||||
codestream = add_msgstream( ptr, jpipstream, codestream, codelen);
|
||||
binOffset += ptr->length;
|
||||
}
|
||||
}
|
||||
ptr = ptr->next;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user