2011-04-14 20:37:47 +02:00
|
|
|
/*
|
2011-05-09 20:11:40 +02:00
|
|
|
* $Id: msgqueue_manager.h 53 2011-05-09 16:55:39Z kaori $
|
2011-04-14 20:37:47 +02:00
|
|
|
*
|
|
|
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
|
|
|
* Copyright (c) 2002-2011, Professor Benoit Macq
|
2011-09-30 17:31:06 +02:00
|
|
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
|
|
|
* Copyright (c) 2011, Lucian Corlaciu, GSoC
|
2011-04-14 20:37:47 +02:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MSGQUEUE_MANAGER_H_
|
|
|
|
# define MSGQUEUE_MANAGER_H_
|
|
|
|
|
2011-05-09 20:11:40 +02:00
|
|
|
#include "bool.h"
|
2011-04-14 20:37:47 +02:00
|
|
|
#include "byte_manager.h"
|
2011-08-24 13:00:15 +02:00
|
|
|
#include "cachemodel_manager.h"
|
2011-04-14 20:37:47 +02:00
|
|
|
#include "placeholder_manager.h"
|
|
|
|
|
2011-09-30 17:31:06 +02:00
|
|
|
#define PRECINCT_MSG 0
|
|
|
|
#define EXT_PRECINCT_MSG 1
|
|
|
|
#define TILE_HEADER_MSG 2
|
|
|
|
#define TILE_MSG 4
|
|
|
|
#define EXT_TILE_MSG 5
|
|
|
|
#define MAINHEADER_MSG 6
|
|
|
|
#define METADATA_MSG 8
|
|
|
|
|
2012-03-02 12:09:16 +01:00
|
|
|
/** message parameters */
|
2011-04-14 20:37:47 +02:00
|
|
|
typedef struct message_param{
|
2012-03-02 12:09:16 +01:00
|
|
|
bool last_byte; /**< if message contains the last byte of the data-bin*/
|
|
|
|
Byte8_t in_class_id; /**< in-class identifier A.2.3*/
|
|
|
|
Byte8_t class_id; /**< class identifiers */
|
|
|
|
Byte8_t csn; /**< index of the codestream*/
|
|
|
|
Byte8_t bin_offset; /**< offset of the data in this message from the start of the data-bin*/
|
|
|
|
Byte8_t length; /**< message byte length*/
|
|
|
|
Byte8_t aux; /**<*/
|
2012-03-26 16:44:12 +02:00
|
|
|
OPJ_OFF_T res_offset; /**< offset in the resource*/
|
2012-03-02 12:09:16 +01:00
|
|
|
placeholder_param_t *phld; /**< placeholder pointer in index*/
|
|
|
|
struct message_param *next; /**< pointer to the next message*/
|
2011-04-14 20:37:47 +02:00
|
|
|
} message_param_t;
|
|
|
|
|
2012-03-02 12:09:16 +01:00
|
|
|
/** message queue parameters */
|
2011-04-14 20:37:47 +02:00
|
|
|
typedef struct msgqueue_param{
|
2012-03-02 12:09:16 +01:00
|
|
|
message_param_t *first; /**< first message pointer of the list*/
|
|
|
|
message_param_t *last; /**< last message pointer of the list*/
|
|
|
|
bool stateless; /**< if this is a stateless message queue*/
|
|
|
|
cachemodel_param_t *cachemodel; /**< reference cachemodel pointer*/
|
2011-04-14 20:37:47 +02:00
|
|
|
} msgqueue_param_t;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* generate message queue
|
|
|
|
*
|
2011-08-24 13:00:15 +02:00
|
|
|
* @param[in] stateless if this is a stateless message queue
|
|
|
|
* @param[in] cachemodel cachemodel pointer
|
|
|
|
* @return generated message queue pointer
|
2011-04-14 20:37:47 +02:00
|
|
|
*/
|
2011-08-24 13:00:15 +02:00
|
|
|
msgqueue_param_t * gene_msgqueue( bool stateless, cachemodel_param_t *cachemodel);
|
2011-04-14 20:37:47 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* delete message queue
|
|
|
|
*
|
|
|
|
* @param[in] msgqueue address of the message queue pointer
|
|
|
|
*/
|
|
|
|
void delete_msgqueue( msgqueue_param_t **msgqueue);
|
|
|
|
|
2011-09-30 17:31:06 +02:00
|
|
|
/**
|
|
|
|
* delete a message in msgqueue
|
|
|
|
*
|
|
|
|
* @param[in] message address of the deleting message pointer
|
|
|
|
* @param[in] msgqueue message queue pointer
|
|
|
|
*/
|
|
|
|
void delete_message_in_msgqueue( message_param_t **message, msgqueue_param_t *msgqueue);
|
|
|
|
|
2011-04-14 20:37:47 +02:00
|
|
|
/**
|
|
|
|
* print message queue
|
|
|
|
*
|
|
|
|
* @param[in] msgqueue message queue pointer
|
|
|
|
*/
|
|
|
|
void print_msgqueue( msgqueue_param_t *msgqueue);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* enqueue main header data-bin into message queue
|
|
|
|
*
|
|
|
|
* @param[in,out] msgqueue message queue pointer
|
|
|
|
*/
|
|
|
|
void enqueue_mainheader( msgqueue_param_t *msgqueue);
|
|
|
|
|
2011-09-30 17:31:06 +02:00
|
|
|
/**
|
|
|
|
* enqueue tile headers data-bin into message queue
|
|
|
|
*
|
|
|
|
* @param[in] tile_id tile id starting from 0
|
|
|
|
* @param[in,out] msgqueue message queue pointer
|
|
|
|
*/
|
|
|
|
void enqueue_tileheader( int tile_id, msgqueue_param_t *msgqueue);
|
|
|
|
|
2011-04-14 20:37:47 +02:00
|
|
|
/**
|
|
|
|
* enqueue tile data-bin into message queue
|
|
|
|
*
|
|
|
|
* @param[in] tile_id tile id starting from 0
|
|
|
|
* @param[in] level decomposition level
|
|
|
|
* @param[in,out] msgqueue message queue pointer
|
|
|
|
*/
|
2012-03-26 16:44:12 +02:00
|
|
|
void enqueue_tile( Byte4_t tile_id, int level, msgqueue_param_t *msgqueue);
|
2011-04-14 20:37:47 +02:00
|
|
|
|
2011-09-30 17:31:06 +02:00
|
|
|
/**
|
|
|
|
* enqueue precinct data-bin into message queue
|
|
|
|
*
|
|
|
|
* @param[in] seq_id precinct sequence number within its tile
|
|
|
|
* @param[in] tile_id tile index
|
|
|
|
* @param[in] comp_id component number
|
2011-10-12 15:25:53 +02:00
|
|
|
* @param[in] layers num of layers
|
2011-09-30 17:31:06 +02:00
|
|
|
* @param[in,out] msgqueue message queue
|
|
|
|
*/
|
2011-10-12 15:25:53 +02:00
|
|
|
void enqueue_precinct( int seq_id, int tile_id, int comp_id, int layers, msgqueue_param_t *msgqueue);
|
2011-09-30 17:31:06 +02:00
|
|
|
|
2011-04-14 20:37:47 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* enqueue Metadata-bin into message queue
|
|
|
|
*
|
|
|
|
* @param[in] meta_id metadata-bin id
|
|
|
|
* @param[in,out] msgqueue message queue pointer
|
|
|
|
*/
|
2012-03-26 17:37:04 +02:00
|
|
|
void enqueue_metadata( Byte8_t meta_id, msgqueue_param_t *msgqueue);
|
2011-04-14 20:37:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2012-03-02 11:46:04 +01:00
|
|
|
* reconstruct JPT/JPP-stream from message queue
|
2011-04-14 20:37:47 +02:00
|
|
|
*
|
|
|
|
* @param[in] msgqueue message queue pointer
|
2012-03-02 11:46:04 +01:00
|
|
|
* @param[in] tmpfd file discriptor to write JPT/JPP-stream
|
2011-04-14 20:37:47 +02:00
|
|
|
*/
|
2012-03-02 11:46:04 +01:00
|
|
|
void recons_stream_from_msgqueue( msgqueue_param_t *msgqueue, int tmpfd);
|
2011-04-14 20:37:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2011-07-05 01:00:21 +02:00
|
|
|
* parse JPT- JPP- stream to message queue
|
2011-04-14 20:37:47 +02:00
|
|
|
*
|
2011-07-05 01:00:21 +02:00
|
|
|
* @param[in] JPIPstream JPT- JPP- stream data pointer
|
|
|
|
* @param[in] streamlen JPIPstream length
|
|
|
|
* @param[in] offset offset of the stream from the whole beginning
|
2011-04-14 20:37:47 +02:00
|
|
|
* @param[in,out] msgqueue adding message queue pointer
|
|
|
|
*/
|
2012-03-26 18:42:52 +02:00
|
|
|
void parse_JPIPstream( Byte_t *JPIPstream, Byte8_t streamlen, OPJ_OFF_T offset, msgqueue_param_t *msgqueue);
|
2011-04-14 20:37:47 +02:00
|
|
|
|
|
|
|
/**
|
2011-07-05 01:00:21 +02:00
|
|
|
* parse JPT- JPP- stream to message queue
|
2011-04-14 20:37:47 +02:00
|
|
|
*
|
|
|
|
* @param[in] msgqueue reference message queue pointer
|
2011-07-05 01:00:21 +02:00
|
|
|
* @param[in] stream stream data pointer
|
|
|
|
* @param[in] streamlen stream length
|
2011-04-14 20:37:47 +02:00
|
|
|
* @param[in] metadatalist adding metadata list pointer
|
|
|
|
*/
|
2011-07-05 01:00:21 +02:00
|
|
|
void parse_metamsg( msgqueue_param_t *msgqueue, Byte_t *stream, Byte8_t streamlen, metadatalist_param_t *metadatalist);
|
2011-04-14 20:37:47 +02:00
|
|
|
|
|
|
|
/**
|
2011-09-30 17:31:06 +02:00
|
|
|
* compute precinct ID A.3.2.1
|
2011-04-14 20:37:47 +02:00
|
|
|
*
|
2011-09-30 17:31:06 +02:00
|
|
|
* @param[in] t tile index
|
|
|
|
* @param[in] c component index
|
|
|
|
* @param[in] s sequence number
|
|
|
|
* @param[in] num_components total number of components
|
|
|
|
* @param[in] num_tiles total number of tiles
|
|
|
|
* @return precicnt id
|
2011-04-14 20:37:47 +02:00
|
|
|
*/
|
2011-09-30 17:31:06 +02:00
|
|
|
Byte8_t comp_precinct_id( int t, int c, int s, int num_components, int num_tiles);
|
2011-04-14 20:37:47 +02:00
|
|
|
|
|
|
|
#endif /* !MSGQUEUE_MANAGER_H_ */
|