remove span, eas3_bytes_used, eas3_init_stream

This commit is contained in:
Gregor Weiss 2024-10-18 11:06:52 +02:00
parent b8a1df1c11
commit a5d67f8470
Signed by: Gregor Weiss
GPG key ID: 61E170A8BBFE5756
2 changed files with 1 additions and 193 deletions

View file

@ -181,43 +181,6 @@
#define AUX_SIZE 0x8000
/************************************************************************************************************\
|| ___ _ _ ___ ____ ____ ||
|| | \_/ |__] |___ [__ ||
|| | | | |___ ___] ||
|| ||
\************************************************************************************************************/
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure is used to read/assemble a packed codestream during coding. The !
! byte buffer is flushed to the packed stream as soon as the a single byte has !
! been assembled. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct
{
//TODO: remove
uchar error; // Error flag used during streaming.
uint64 size;
uint64 position;
//TODO: remove
uint64 L; // Number of bytes written to/from stream.
//TODO: remove
uint64 Lmax; // Size of packed stream.
uint64 size_incr; // Size incrmnt used for stream assembly.
//TODO: remove
uint8 T; // Byte buffer.
int8 t; // Byte buffer counter.
uchar *access; // Pointer used to parse packed stream.
uchar *memory; // Memory handle for packed stream chunck.
} span;
/*----------------------------------------------------------------------------------------------------------*\
! STRUCT NAME: eas3_header !
! ----------- !

View file

@ -84,151 +84,6 @@
|| | | \ | \/ | | | |___ | |__| | \| |___ | | |__| | \| ___] ||
|| ||
\************************************************************************************************************/
/*----------------------------------------------------------------------------------------------------------*\
! FUNCTION NAME: uint32 eas3_bytes_used(bitstream *const stream) !
! -------------- !
! !
! DESCRIPTION: !
! ------------ !
! This function is used to evaluate the number of bytes that have already been !
! written to the allocated bitstream memory block. !
! !
! PARAMETERS: !
! ----------- !
! Variable Type Description !
! -------- ---- ----------- !
! stream bitstream* - Structure that !
! !
! RETURN VALUE: !
! ------------- !
! Type Description !
! ---- ----------- !
! unsigned int(32 bit) - Number of bites that have been written to the !
! bitstream. !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! 13.05.2019 Patrick Vogler B87D120 V 0.1.0 function created !
! !
\*----------------------------------------------------------------------------------------------------------*/
uint64
eas3_bytes_used(span const *const stream)
{
if(stream->T == 0xFF)
{
return stream->L + 1;
}
else
{
return stream->L;
}
}
/*----------------------------------------------------------------------------------------------------------*\
! FUNCTION NAME: span* bwc_init_stream(uchar* memory, uint32 size, char instr) !
! -------------- !
! !
! DESCRIPTION: !
! ------------ !
! This function is used to initialize a bwc bitstream. For encoding, a null pointer !
! is passed as a memory handle and the function will allocate a memory block with the !
! specified stream size. For decoding, a valid memory handle, passed by the function !
! caller, will be stored in the bitstream structure. The byte buffer counter t, !
! stream size Lmax and size increment are initialized with their appropriate values. !
! !
! PARAMETERS: !
! ----------- !
! Variable Type Description !
! -------- ---- ----------- !
! size unsigned int(32 bit) - Initial size of the bwc stream. !
! !
! memory unsigned char - Memory handle for the bwc stream memory !
! block. !
! !
! instr char - Constant used to instruct the field !
! initialization. !
! !
! RETURN VALUE: !
! ------------- !
! Type Description !
! ---- ----------- !
! bitstream* - Memory handle for the initialized bwc stream. !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! 19.06.2019 Patrick Vogler B87D120 V 0.1.0 function created !
! !
\*----------------------------------------------------------------------------------------------------------*/
span*
eas3_init_stream(uchar* memory, uint32 size, char instr)
{
/*-----------------------*\
! DEFINE STRUCTS: !
\*-----------------------*/
span *stream;
/*-----------------------*\
! DEFINE ASSERTIONS: !
\*-----------------------*/
assert(instr == 'c' || instr == 'd');
/*--------------------------------------------------------*\
! Allocate the bwc stream structure. !
\*--------------------------------------------------------*/
stream = calloc(1, sizeof(span));
if(!stream)
{
// memory allocation error
fprintf(stderr, MEMERROR);
return NULL;
}
/*--------------------------------------------------------*\
! Evaluate if a valid memory handle has been passed by the !
! function caller. !
\*--------------------------------------------------------*/
if(!memory)
{
/*--------------------------------------------------------*\
! If no valid memory handle has been passed, allocate a !
! memory block with the specifiec stream size. !
\*--------------------------------------------------------*/
stream->memory = calloc(size, sizeof(uchar));
if(!stream->memory)
{
// memory allocation error
fprintf(stderr, MEMERROR);
return NULL;
}
}
else
{
/*--------------------------------------------------------*\
! If a valid memory handle has been passed for decoding, !
! save the memory handle in the bwc stream structure. !
\*--------------------------------------------------------*/
stream->memory = memory;
}
/*--------------------------------------------------------*\
! Initialize the byte buffer counter, stream size and size !
! increment for the current stream. !
\*--------------------------------------------------------*/
stream->t = (instr == 'c') ? 8 : 0;
stream->Lmax = size;
stream->size_incr = (uint64)(size / 2);
/*--------------------------------------------------------*\
! Return the stream memory handle. !
\*--------------------------------------------------------*/
return stream;
}
/*----------------------------------------------------------------------------------------------------------*\
! !
@ -238,7 +93,6 @@ eas3_init_stream(uchar* memory, uint32 size, char instr)
! information. !
! !
\*----------------------------------------------------------------------------------------------------------*/
#define aux_enqueue(aux, aux_pos, aux_len, chunck, chunck_len) \
{ \
if (aux_pos + chunck_len > aux_len) \
@ -483,7 +337,6 @@ read_eas3_header(FILE *const fp, eas3_data *const data)
! DEFINE STRUCTS: !
\*-----------------------*/
bwc_gl_inf *info;
span *aux;
eas3_std_params *params;
/*-----------------------*\
@ -834,7 +687,6 @@ write_eas3_header(FILE *const fp, eas3_data *const data)
! DEFINE STRUCTS: !
\*-----------------------*/
bwc_gl_inf *info;
span *aux;
eas3_std_params *params;
eas3_param_names *param_names;
@ -853,11 +705,6 @@ write_eas3_header(FILE *const fp, eas3_data *const data)
return 1;
}
/*--------------------------------------------------------*\
! Initialize the auxiliary information stream. !
\*--------------------------------------------------------*/
aux = eas3_init_stream(data->uchar_aux, data->aux_len, 'd');
// Rewind aux
data->aux_pos = 0;
@ -1020,10 +867,8 @@ write_eas3_header(FILE *const fp, eas3_data *const data)
free(buffer_char);
/*--------------------------------------------------------*\
! Free the auxiliary information memory block stream and !
! params structure. !
! Free the params structure. !
\*--------------------------------------------------------*/
free(aux);
free(params);
return 0;