open and close header with new header structure
This commit is contained in:
parent
92a646b5e0
commit
12f937ecac
6 changed files with 127 additions and 14 deletions
|
@ -100,6 +100,10 @@
|
||||||
size_t assemble_codestream (bwc_codec *const codec,
|
size_t assemble_codestream (bwc_codec *const codec,
|
||||||
bwc_stream *const stream);
|
bwc_stream *const stream);
|
||||||
//==========|==========================|======================|======|======|=====================
|
//==========|==========================|======================|======|======|=====================
|
||||||
|
bwc_codec* parse_main_header (bwc_codec *const codec,
|
||||||
|
bwc_stream *const data,
|
||||||
|
bitstream *const stream);
|
||||||
|
//==========|==========================|======================|======|======|=====================
|
||||||
bwc_codec* parse_codestream (bwc_codec *const codec,
|
bwc_codec* parse_codestream (bwc_codec *const codec,
|
||||||
bwc_stream *const stream,
|
bwc_stream *const stream,
|
||||||
uint8 const layer);
|
uint8 const layer);
|
||||||
|
|
|
@ -142,6 +142,10 @@
|
||||||
uint64 const tilesTS,
|
uint64 const tilesTS,
|
||||||
bwc_tile_instr const instr);
|
bwc_tile_instr const instr);
|
||||||
//==========|==========================|======================|======|=======|====================
|
//==========|==========================|======================|======|=======|====================
|
||||||
|
bwc_header* bwc_open_header (void *const inpbuf);
|
||||||
|
//==========|==========================|======================|======|=======|====================
|
||||||
|
void bwc_close_header (bwc_header *const header);
|
||||||
|
//==========|==========================|======================|======|=======|====================
|
||||||
uchar bwc_create_compression (bwc_codec *const codec,
|
uchar bwc_create_compression (bwc_codec *const codec,
|
||||||
bwc_stream *const data,
|
bwc_stream *const data,
|
||||||
char *const rate_control);
|
char *const rate_control);
|
||||||
|
|
|
@ -659,6 +659,19 @@
|
||||||
bwc_prog_ord progression; // Packet progression order.
|
bwc_prog_ord progression; // Packet progression order.
|
||||||
} bwc_gl_ctrl;
|
} bwc_gl_ctrl;
|
||||||
|
|
||||||
|
/*================================================================================================*/
|
||||||
|
/**
|
||||||
|
* @details Structure that is used to probe header information from a compressed data set.
|
||||||
|
*/
|
||||||
|
/*================================================================================================*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
bwc_gl_inf info; // Global info structure
|
||||||
|
bwc_gl_ctrl control; // Global control structure
|
||||||
|
bwc_span aux; // Auxiliary info. codestream block.
|
||||||
|
bwc_span com; // Comment codestream block.
|
||||||
|
} bwc_header;
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------------------------*\
|
/*----------------------------------------------------------------------------------------------*\
|
||||||
! !
|
! !
|
||||||
! DESCRIPTION: !
|
! DESCRIPTION: !
|
||||||
|
|
|
@ -912,7 +912,7 @@ parse_main_header(bwc_codec *const codec, bwc_stream *const data, bitstream *con
|
||||||
data->codestream.com->memory = get_chunck(stream, Lcom - 2);
|
data->codestream.com->memory = get_chunck(stream, Lcom - 2);
|
||||||
data->codestream.com->size = Lcom -2;
|
data->codestream.com->size = Lcom -2;
|
||||||
|
|
||||||
status |= CODESTREAM_ERROR;
|
status |= CODESTREAM_COM_READ;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3350,6 +3350,98 @@ bwc_set_tiles(bwc_codec *const codec, uint64 tilesX, uint64 tilesY, uint64 tiles
|
||||||
control->CSsgc |= (0x01 << 9);
|
control->CSsgc |= (0x01 << 9);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*================================================================================================*/
|
||||||
|
/**
|
||||||
|
* @details This function opens the header of a compressed data set and parses it into an
|
||||||
|
* instance of type bwc_header.
|
||||||
|
*
|
||||||
|
* @param[in] inpbuf Pointer to compressed data set.
|
||||||
|
*
|
||||||
|
* @retval bwc_header*
|
||||||
|
*/
|
||||||
|
/*================================================================================================*/
|
||||||
|
bwc_header* bwc_open_header(void *const inpbuf)
|
||||||
|
{
|
||||||
|
/*-----------------------*\
|
||||||
|
! DEFINE STRUCTS: !
|
||||||
|
\*-----------------------*/
|
||||||
|
bwc_codec* codec;
|
||||||
|
bwc_stream* data;
|
||||||
|
bitstream* stream;
|
||||||
|
bwc_header* header;
|
||||||
|
|
||||||
|
/*--------------------------------------------------------*\
|
||||||
|
! Initialize a codec, stream, and bitstream for parsing. !
|
||||||
|
\*--------------------------------------------------------*/
|
||||||
|
data = bwc_init_stream(inpbuf, NULL, decomp);
|
||||||
|
codec = bwc_alloc_decoder();
|
||||||
|
stream = init_bitstream(data->inp, 10, 'd');
|
||||||
|
|
||||||
|
/*--------------------------------------------------------*\
|
||||||
|
! Parse the main header into the codec structure. !
|
||||||
|
\*--------------------------------------------------------*/
|
||||||
|
parse_main_header(codec, data, stream);
|
||||||
|
if(!codec)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*--------------------------------------------------------*\
|
||||||
|
! Allocate header and copy info and control structures. !
|
||||||
|
\*--------------------------------------------------------*/
|
||||||
|
header = calloc(1, sizeof(bwc_header));
|
||||||
|
header->info = codec->info;
|
||||||
|
header->control = codec->control;
|
||||||
|
|
||||||
|
/*--------------------------------------------------------*\
|
||||||
|
! Shallow copy aux data to span. !
|
||||||
|
\*--------------------------------------------------------*/
|
||||||
|
if (data->codestream.aux)
|
||||||
|
{
|
||||||
|
header->aux.memory = data->codestream.aux->memory;
|
||||||
|
header->aux.size = data->codestream.aux->size;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*--------------------------------------------------------*\
|
||||||
|
! Shallow copy com data to span. !
|
||||||
|
\*--------------------------------------------------------*/
|
||||||
|
if (data->codestream.com)
|
||||||
|
{
|
||||||
|
header->com.memory = data->codestream.com->memory;
|
||||||
|
header->com.size = data->codestream.com->size;
|
||||||
|
}
|
||||||
|
|
||||||
|
free(stream);
|
||||||
|
free(data);
|
||||||
|
free(codec);
|
||||||
|
|
||||||
|
return header;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*================================================================================================*/
|
||||||
|
/**
|
||||||
|
* @details This function closes the header information in the bwc_header pointer.
|
||||||
|
*
|
||||||
|
* @param[in] header Instance of type bwc_header.
|
||||||
|
*/
|
||||||
|
/*================================================================================================*/
|
||||||
|
void bwc_close_header(bwc_header *const header)
|
||||||
|
{
|
||||||
|
if (header)
|
||||||
|
{
|
||||||
|
if (header->aux.memory)
|
||||||
|
{
|
||||||
|
free(header->aux.memory);
|
||||||
|
}
|
||||||
|
if (header->com.memory)
|
||||||
|
{
|
||||||
|
free(header->com.memory);
|
||||||
|
}
|
||||||
|
free(header);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------------------------------------*\
|
/*----------------------------------------------------------------------------------------------------------*\
|
||||||
! FUNCTION NAME: void bwc_create_compression(bwc_codec *codec, char *rate_control) !
|
! FUNCTION NAME: void bwc_create_compression(bwc_codec *codec, char *rate_control) !
|
||||||
! -------------- !
|
! -------------- !
|
||||||
|
|
|
@ -134,18 +134,18 @@
|
||||||
* @details String containing the header used for the cli output.
|
* @details String containing the header used for the cli output.
|
||||||
*/
|
*/
|
||||||
/*================================================================================================*/
|
/*================================================================================================*/
|
||||||
static char bwc_header[] = "==============================================================\n"\
|
static char bwc_header_art[] = "==============================================================\n"\
|
||||||
" \n"\
|
" \n"\
|
||||||
" .:-------------: .:-------------: \n"\
|
" .:-------------: .:-------------: \n"\
|
||||||
" .+++++++++++++++= :+++++++++++++++- \n"\
|
" .+++++++++++++++= :+++++++++++++++- \n"\
|
||||||
" :+++. -++= -++= \n"\
|
" :+++. -++= -++= \n"\
|
||||||
" :+++. -++= -++= \n"\
|
" :+++. -++= -++= \n"\
|
||||||
" -++++++++++++++= -++= -++= \n"\
|
" -++++++++++++++= -++= -++= \n"\
|
||||||
" .=++---------=++= -++= -++= \n"\
|
" .=++---------=++= -++= -++= \n"\
|
||||||
" :+++ :++= -++= -++= \n"\
|
" :+++ :++= -++= -++= \n"\
|
||||||
" .+++=--------=+++---=+++---=+++------------: \n"\
|
" .+++=--------=+++---=+++---=+++------------: \n"\
|
||||||
" -=++++++++++++++++++++++++++++++++++++++++- \n"\
|
" -=++++++++++++++++++++++++++++++++++++++++- \n"\
|
||||||
" \n";
|
" \n";
|
||||||
|
|
||||||
/*================================================================================================*/
|
/*================================================================================================*/
|
||||||
/**
|
/**
|
||||||
|
@ -1153,7 +1153,7 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
if (arguments.verbose == true)
|
if (arguments.verbose == true)
|
||||||
{
|
{
|
||||||
strcat(cli_verbose, bwc_header);
|
strcat(cli_verbose, bwc_header_art);
|
||||||
strcat(cli_verbose, "--------------------------- I/O --------------------------\n\n");
|
strcat(cli_verbose, "--------------------------- I/O --------------------------\n\n");
|
||||||
|
|
||||||
sprintf(cli_buffer," Input: %s \n", arguments.in);
|
sprintf(cli_buffer," Input: %s \n", arguments.in);
|
||||||
|
|
Loading…
Reference in a new issue