Compare commits
No commits in common. "develop-gws" and "main" have entirely different histories.
develop-gw
...
main
16 changed files with 2016 additions and 1058 deletions
|
@ -92,7 +92,7 @@
|
|||
\************************************************************************************************/
|
||||
uint64 bytes_used (bitstream const *const stream);
|
||||
//==========|==========================|======================|======|======|=====================
|
||||
bitstream* init_bitstream (uchar *const memory,
|
||||
bitstream* init_stream (uchar *const memory,
|
||||
uint32 const size,
|
||||
char const instr);
|
||||
//==========|==========================|======================|======|======|=====================
|
||||
|
@ -117,10 +117,8 @@
|
|||
//==========|==========================|======================|======|======|=====================
|
||||
uchar get_bit (bitstream *const stream);
|
||||
//==========|==========================|======================|======|======|=====================
|
||||
uchar shrink_to_fit (bitstream *const stream);
|
||||
uchar terminate_stream (bitstream *stream,
|
||||
bwc_stream *const packed_stream);
|
||||
//==========|==========================|======================|======|======|=====================
|
||||
uchar transfer_to_span (bitstream *const stream,
|
||||
bwc_span *const span);
|
||||
//==========|==========================|======================|======|======|=====================
|
||||
void release_packed_stream (bwc_span *const stream);
|
||||
void release_packed_stream (bwc_stream *const stream);
|
||||
#endif
|
||||
|
|
|
@ -89,18 +89,16 @@
|
|||
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|
||||
|| ||
|
||||
\************************************************************************************************/
|
||||
uchar assemble_main_header (bwc_codec *const codec);
|
||||
uchar assemble_main_header (bwc_field *const field);
|
||||
//==========|==========================|======================|======|======|=====================
|
||||
uchar codestream_write_aux (bwc_span *const header,
|
||||
bwc_span *const aux);
|
||||
uchar codestream_write_aux (bwc_stream *const header,
|
||||
bwc_stream *const aux);
|
||||
//==========|==========================|======================|======|======|=====================
|
||||
uchar codestream_write_com (bwc_span *const header,
|
||||
bwc_span *const com);
|
||||
uchar codestream_write_com (bwc_stream *const header,
|
||||
bwc_stream *const com);
|
||||
//==========|==========================|======================|======|======|=====================
|
||||
size_t assemble_codestream (bwc_codec *const codec,
|
||||
bwc_stream *const stream);
|
||||
bwc_stream* assemble_codestream (bwc_field *const field);
|
||||
//==========|==========================|======================|======|======|=====================
|
||||
bwc_codec* parse_codestream (bwc_codec *const codec,
|
||||
bwc_stream *const stream,
|
||||
bwc_field* parse_codestream (bwc_data *const data,
|
||||
uint8 const layer);
|
||||
#endif
|
|
@ -114,14 +114,8 @@
|
|||
\*----------------------------------------------------------------------------------------------*/
|
||||
typedef enum
|
||||
{
|
||||
bwc_precision_half = 2,
|
||||
bwc_precision_single = 4,
|
||||
bwc_precision_double = 8,
|
||||
} bwc_precision;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
comp,
|
||||
decomp,
|
||||
} bwc_mode;
|
||||
bwc_type_half,
|
||||
bwc_type_single,
|
||||
bwc_type_double,
|
||||
} bwc_type;
|
||||
#endif
|
|
@ -157,13 +157,13 @@
|
|||
\************************************************************************************************/
|
||||
uchar initialize_gain_lut ();
|
||||
//==========|==========================|======================|======|=======|====================
|
||||
bwc_float get_dwt_energy_gain (bwc_codec *const codec,
|
||||
bwc_float get_dwt_energy_gain (bwc_field *const field,
|
||||
uchar const highband_flag,
|
||||
uint16 const level);
|
||||
//==========|==========================|======================|======|=======|====================
|
||||
uchar forward_wavelet_transform (bwc_codec *const codec,
|
||||
uchar forward_wavelet_transform (bwc_field *const field,
|
||||
bwc_parameter *const parameter);
|
||||
//==========|==========================|======================|======|=======|====================
|
||||
uchar inverse_wavelet_transform (bwc_codec *const codec,
|
||||
uchar inverse_wavelet_transform (bwc_field *const field,
|
||||
bwc_parameter *const parameter);
|
||||
#endif
|
|
@ -64,95 +64,92 @@
|
|||
|| ||
|
||||
\************************************************************************************************/
|
||||
//==========|==========================|======================|======|=======|====================
|
||||
bwc_stream* bwc_init_stream (void *const inpbuf,
|
||||
void *const outbuf,
|
||||
bwc_mode const mode);
|
||||
//==========|==========================|======================|======|=======|====================
|
||||
uchar bwc_set_com (bwc_stream *const stream,
|
||||
char const *const com,
|
||||
uint16 const size);
|
||||
//==========|==========================|======================|======|=======|====================
|
||||
uchar bwc_set_aux (bwc_stream *const stream,
|
||||
char const *const aux,
|
||||
uint32 const size);
|
||||
//==========|==========================|======================|======|=======|====================
|
||||
uchar create_codec (bwc_codec *const codec);
|
||||
//==========|==========================|======================|======|=======|====================
|
||||
bwc_codec* configure_codec (bwc_codec *const codec,
|
||||
bwc_data* bwc_initialize_data (double *const field,
|
||||
uint64 const nX,
|
||||
uint64 const nY,
|
||||
uint64 const nZ,
|
||||
uint64 const nTS,
|
||||
uint16 const nTS,
|
||||
uint8 const nPar,
|
||||
bwc_precision const prec);
|
||||
char *const file_extension);
|
||||
//==========|==========================|======================|======|=======|====================
|
||||
bwc_codec* bwc_alloc_coder (uint64 const nX,
|
||||
uint64 const nY,
|
||||
uint64 const nZ,
|
||||
uint64 const nTS,
|
||||
uint8 const nPar,
|
||||
bwc_precision const prec);
|
||||
uchar bwc_set_com (bwc_data *const data,
|
||||
char const *const com,
|
||||
uint16 const size);
|
||||
//==========|==========================|======================|======|=======|====================
|
||||
bwc_codec* bwc_alloc_decoder ();
|
||||
uchar bwc_set_aux (bwc_data *const data,
|
||||
char const *const aux,
|
||||
uint32 const size);
|
||||
//==========|==========================|======================|======|=======|====================
|
||||
void bwc_free_codec (bwc_codec *const codec);
|
||||
void bwc_add_param (bwc_data *const data,
|
||||
char *const name,
|
||||
uint8 const precision);
|
||||
//==========|==========================|======================|======|=======|====================
|
||||
void bwc_set_error_resilience (bwc_codec *const codec);
|
||||
void bwc_get_data (bwc_data *const data,
|
||||
uchar *const buffer,
|
||||
uint64 const size);
|
||||
//==========|==========================|======================|======|=======|====================
|
||||
void set_quant_style (bwc_codec *const codec,
|
||||
void bwc_free_data (bwc_data *const data);
|
||||
//==========|==========================|======================|======|=======|====================
|
||||
uchar create_field (bwc_field *const field);
|
||||
//==========|==========================|======================|======|=======|====================
|
||||
void bwc_kill_compression (bwc_field *const field);
|
||||
//==========|==========================|======================|======|=======|====================
|
||||
bwc_field* bwc_initialize_field (bwc_data *const data);
|
||||
//==========|==========================|======================|======|=======|====================
|
||||
void bwc_set_error_resilience (bwc_field *const field);
|
||||
//==========|==========================|======================|======|=======|====================
|
||||
void set_quant_style (bwc_field *const field,
|
||||
bwc_quant_st const quantization_style);
|
||||
//==========|==========================|======================|======|=======|====================
|
||||
void set_quant_step_size (bwc_codec *const codec,
|
||||
void set_quant_step_size (bwc_field *const field,
|
||||
double const delta);
|
||||
//==========|==========================|======================|======|=======|====================
|
||||
void set_progression (bwc_codec *const codec,
|
||||
void set_progression (bwc_field *const field,
|
||||
bwc_prog_ord const progression);
|
||||
//==========|==========================|======================|======|=======|====================
|
||||
void set_kernels (bwc_codec *const codec,
|
||||
void set_kernels (bwc_field *const field,
|
||||
bwc_dwt_filter const KernelX,
|
||||
bwc_dwt_filter const KernelY,
|
||||
bwc_dwt_filter const KernelZ,
|
||||
bwc_dwt_filter const KernelTS);
|
||||
//==========|==========================|======================|======|=======|====================
|
||||
void bwc_set_decomp (bwc_codec *const codec,
|
||||
void bwc_set_decomp (bwc_field *const field,
|
||||
uint8 const decompX,
|
||||
uint8 const decompY,
|
||||
uint8 const decompZ,
|
||||
uint8 const decompTS);
|
||||
//==========|==========================|======================|======|=======|====================
|
||||
void bwc_set_precincts (bwc_codec *const codec,
|
||||
void bwc_set_precincts (bwc_field *const field,
|
||||
uint8 const pX,
|
||||
uint8 const pY,
|
||||
uint8 const pZ,
|
||||
uint8 const pTS);
|
||||
//==========|==========================|======================|======|=======|====================
|
||||
void bwc_set_codeblocks (bwc_codec *const codec,
|
||||
void bwc_set_codeblocks (bwc_field *const field,
|
||||
uint8 const cbX,
|
||||
uint8 const cbY,
|
||||
uint8 const cbZ,
|
||||
uint8 const cbTS);
|
||||
//==========|==========================|======================|======|=======|====================
|
||||
void bwc_set_qm (bwc_codec *const codec,
|
||||
void bwc_set_qm (bwc_field *const field,
|
||||
uint8 const Qm);
|
||||
//==========|==========================|======================|======|=======|====================
|
||||
void bwc_set_tiles (bwc_codec *const codec,
|
||||
void bwc_set_tiles (bwc_field *const field,
|
||||
uint64 const tilesX,
|
||||
uint64 const tilesY,
|
||||
uint64 const tilesZ,
|
||||
uint64 const tilesTS,
|
||||
bwc_tile_instr const instr);
|
||||
//==========|==========================|======================|======|=======|====================
|
||||
uchar bwc_create_compression (bwc_codec *const codec,
|
||||
bwc_stream *const data,
|
||||
uchar bwc_create_compression (bwc_field *const field,
|
||||
char *const rate_control);
|
||||
//==========|==========================|======================|======|=======|====================
|
||||
size_t bwc_compress (bwc_codec *const codec,
|
||||
bwc_stream *const data);
|
||||
uchar bwc_compress (bwc_field *const field,
|
||||
bwc_data *const data);
|
||||
//==========|==========================|======================|======|=======|====================
|
||||
uchar bwc_create_decompression (bwc_codec *const codec,
|
||||
bwc_stream *const stream,
|
||||
bwc_field* bwc_create_decompression (bwc_data *const data,
|
||||
uint8 const layer);
|
||||
//==========|==========================|======================|======|=======|====================
|
||||
uchar bwc_decompress (bwc_codec *const codec,
|
||||
bwc_stream *const stream);
|
||||
#endif
|
||||
uchar bwc_decompress (bwc_field *const field,
|
||||
bwc_data *const data);
|
||||
#endif
|
|
@ -16,7 +16,7 @@
|
|||
|| ------------ ||
|
||||
|| ||
|
||||
|| This file describes a set of functions that can be used to de-/encode bwc ||
|
||||
|| codeblocks described by the bwc_codec structure according to the embedded block ||
|
||||
|| codeblocks described by the bwc_field structure according to the embedded block ||
|
||||
|| coding paradigm described by the JPEG 2000 standard. For more information please ||
|
||||
|| refere to JPEG2000 by D. S. Taubman and M. W. Marcellin. ||
|
||||
|| ||
|
||||
|
@ -156,11 +156,11 @@
|
|||
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|
||||
|| ||
|
||||
\************************************************************************************************/
|
||||
uchar t1_encode (bwc_codec *const codec,
|
||||
uchar t1_encode (bwc_field *const field,
|
||||
bwc_tile *const tile,
|
||||
bwc_parameter *const parameter);
|
||||
//==========|==========================|======================|======|=======|====================
|
||||
uchar t1_decode (bwc_codec *const codec,
|
||||
uchar t1_decode (bwc_field *const field,
|
||||
bwc_tile *const tile,
|
||||
bwc_parameter *const parameter);
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|| ------------ ||
|
||||
|| ||
|
||||
|| This file describes a set of functions that can be used to de-/encode bwc ||
|
||||
|| codeblocks described by the bwc_codec structure according to the embedded block ||
|
||||
|| codeblocks described by the bwc_field structure according to the embedded block ||
|
||||
|| coding paradigm described by the JPEG 2000 standard. For more information please ||
|
||||
|| refere to JPEG2000 by D. S. Taubman and M. W. Marcellin. ||
|
||||
|| ||
|
||||
|
@ -76,10 +76,10 @@
|
|||
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|
||||
|| ||
|
||||
\************************************************************************************************/
|
||||
uchar t2_encode (bwc_codec *const codec,
|
||||
uchar t2_encode (bwc_field *const field,
|
||||
bwc_tile *const tile);
|
||||
//==========|==========================|======================|======|=======|====================
|
||||
uchar parse_packet (bwc_codec *const codec,
|
||||
uchar parse_packet (bwc_field *const field,
|
||||
bwc_tile *const tile,
|
||||
bwc_packet *const packet,
|
||||
uint64 const body_size);
|
||||
|
|
|
@ -99,7 +99,7 @@
|
|||
|
||||
uchar *access; // Pointer used to parse packed stream.
|
||||
uchar *memory; // Memory handle for the packed stream.
|
||||
} bwc_span;
|
||||
} bwc_stream;
|
||||
|
||||
/*----------------------------------------------------------------------------------------------*\
|
||||
! !
|
||||
|
@ -138,6 +138,29 @@
|
|||
bwc_tagtree_node *nodes; // Pointer to the tagtree nodes.
|
||||
} bwc_tagtree;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------------------------*\
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
! ------------ !
|
||||
! !
|
||||
! This structure defines a linked list which stores the size, index, and bit pre- !
|
||||
! cision The string name is used to store the parameter name supplied by the !
|
||||
! function caller. !
|
||||
! !
|
||||
\*----------------------------------------------------------------------------------------------*/
|
||||
typedef struct opt
|
||||
{
|
||||
char name[24]; // Parameter name.
|
||||
uint8 id; // Parameter index.
|
||||
|
||||
uint64 size; // Parameter size after sub-sampling.
|
||||
uint8 precision; // Parameter precision.
|
||||
|
||||
struct opt *next; // Next element in linked-list.
|
||||
struct opt *root; // Linked-list root.
|
||||
} bwc_cmd_opts_ll;
|
||||
|
||||
/*----------------------------------------------------------------------------------------------*\
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
|
@ -155,8 +178,12 @@
|
|||
|
||||
uint8 nPar; // Number of parameters.
|
||||
|
||||
bwc_precision data_prec; // Data type of uncompressed field data.
|
||||
bwc_precision codec_prec; // Encoder/decoder bit precision.
|
||||
uint8 precision; // Flag defining codec precision.
|
||||
|
||||
uint8 codec_prec; // Encoder/decoder bit precision.
|
||||
char f_ext[20]; // Uncompressed data set file extension.
|
||||
|
||||
bwc_cmd_opts_ll *parameter; // Command options linked-list.
|
||||
} bwc_gl_inf;
|
||||
|
||||
/*----------------------------------------------------------------------------------------------*\
|
||||
|
@ -170,17 +197,22 @@
|
|||
\*----------------------------------------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
bwc_gl_inf info; // Gloabal info structure.
|
||||
FILE *fp; // File point to (un)compr. data-set.
|
||||
|
||||
struct codestream
|
||||
{
|
||||
bwc_span *aux; // Auxiliary info. codestream block.
|
||||
bwc_span *com; // Comment codestream block.
|
||||
bwc_stream *data; // Data codestream block.
|
||||
bwc_stream *aux; // Auxiliary info. codestream block.
|
||||
bwc_stream *com; // Comment codestream block.
|
||||
}codestream;
|
||||
|
||||
void *inp; // User managed buffer for input
|
||||
void *out; // User managed buffer for output
|
||||
|
||||
bwc_mode mode; // Flag to signal (de-)compression
|
||||
} bwc_stream;
|
||||
struct field
|
||||
{
|
||||
double *d; // Double precision numerical data-set.
|
||||
float *f; // Single precision numerical data-set.
|
||||
}field;
|
||||
} bwc_data;
|
||||
|
||||
/*----------------------------------------------------------------------------------------------*\
|
||||
! !
|
||||
|
@ -388,8 +420,8 @@
|
|||
\*----------------------------------------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
bwc_span header; // Packed stream header.
|
||||
bwc_span body; // Packed stream body.
|
||||
bwc_stream header; // Packed stream header.
|
||||
bwc_stream body; // Packed stream body.
|
||||
uint8 e; // Indicator for packet cb. contributions.
|
||||
|
||||
uint32 size; // Codestream packet size.
|
||||
|
@ -496,9 +528,14 @@
|
|||
\*----------------------------------------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uint64 size; // Parameter size.
|
||||
char *name; // Parameter name.
|
||||
|
||||
uint64 X0, Y0, Z0, TS0; // Tile parameter starting point.
|
||||
uint64 X1, Y1, Z1, TS1; // Tile parameter end point.
|
||||
|
||||
uint8 precision; // Tile parameter precision.
|
||||
|
||||
bwc_float parameter_min; // Min. value of tile parameter.
|
||||
bwc_float parameter_max; // Max. value of tile parameter.
|
||||
} bwc_param_inf;
|
||||
|
@ -673,11 +710,12 @@
|
|||
\*----------------------------------------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
bwc_gl_inf info; // Global info structure
|
||||
bwc_gl_inf *info; // Gloabal info structure
|
||||
bwc_gl_ctrl control; // Global control structure
|
||||
|
||||
bwc_tile *tile; // Structure defining bwc tile.
|
||||
|
||||
bwc_mode mode; // Flag to signal (de-)compression
|
||||
} bwc_codec;
|
||||
bwc_stream *aux; // Auxiliary info. codestream block.
|
||||
bwc_stream *com; // Comment codestream block.
|
||||
} bwc_field;
|
||||
#endif
|
|
@ -48,10 +48,10 @@ module bwc
|
|||
!| | | \| |___ |___ |__| |__/ |___ |!
|
||||
!| |!
|
||||
!************************************************************************************************!
|
||||
use, intrinsic :: iso_c_binding, only: c_ptr, c_int64_t, c_int32_t, c_int16_t, c_int8_t, &
|
||||
c_int, c_double, c_char, c_signed_char
|
||||
implicit none
|
||||
private
|
||||
use, intrinsic :: iso_c_binding, only: C_PTR, C_INT64_T, C_INT32_T, C_INT16_T, C_INT8_T, &
|
||||
C_INT, C_DOUBLE, C_CHAR, C_SIGNED_CHAR
|
||||
IMPLICIT NONE
|
||||
PRIVATE
|
||||
|
||||
!************************************************************************************************!
|
||||
!| ____ ____ _ _ ____ ___ ____ _ _ ___ ____ |!
|
||||
|
@ -59,25 +59,25 @@ module bwc
|
|||
!| |___ |__| | \| ___] | | | | \| | ___] |!
|
||||
!| |!
|
||||
!************************************************************************************************!
|
||||
enum, bind(c)
|
||||
ENUM, BIND(C)
|
||||
enumerator :: bwc_dwt_9_7 = 0, &
|
||||
bwc_dwt_5_3 = 1, &
|
||||
bwc_dwt_haar = 2
|
||||
end enum
|
||||
END ENUM
|
||||
!*==============================================================================================*!
|
||||
enum, bind(c)
|
||||
enumerator :: bwc_prog_lrcp = 0
|
||||
end enum
|
||||
ENUM, BIND(C)
|
||||
enumerator :: bwc_prog_LRCP = 0
|
||||
END ENUM
|
||||
!*==============================================================================================*!
|
||||
enum, bind(c)
|
||||
ENUM, BIND(C)
|
||||
enumerator :: bwc_qt_none = 0, &
|
||||
bwc_qt_derived = 1
|
||||
end enum
|
||||
END ENUM
|
||||
!*==============================================================================================*!
|
||||
enum, bind(c)
|
||||
ENUM, BIND(C)
|
||||
enumerator :: bwc_tile_sizeof = 0, &
|
||||
bwc_tile_numbof = 1
|
||||
end enum
|
||||
END ENUM
|
||||
|
||||
!************************************************************************************************!
|
||||
!| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ |!
|
||||
|
@ -86,113 +86,294 @@ module bwc
|
|||
!| |!
|
||||
!************************************************************************************************!
|
||||
interface
|
||||
function init_stream_f(inpbuf, outbuf, mode) result(stream) &
|
||||
bind(c, name="bwc_init_stream")
|
||||
import
|
||||
type(c_ptr) :: stream
|
||||
type(c_ptr), value :: inpbuf
|
||||
type(c_ptr), value :: outbuf
|
||||
integer(kind=c_int), value :: mode
|
||||
end function init_stream_f
|
||||
function initialize_data_f(field, nX, nY, nZ, nTS, nPar, file_extension) result(data) &
|
||||
BIND(C, NAME="bwc_initialize_data")
|
||||
IMPORT
|
||||
!*-----------------------*!
|
||||
! DEFINE POINTERS: !
|
||||
!*-----------------------*!
|
||||
TYPE(C_PTR), VALUE :: field
|
||||
TYPE(C_PTR) :: data
|
||||
|
||||
!*-----------------------*!
|
||||
! DEFINE INT VARIABLES: !
|
||||
!*-----------------------*!
|
||||
INTEGER(KIND=C_INT16_T), VALUE :: nX, nY, nZ
|
||||
INTEGER(KIND=C_INT8_T), VALUE :: nTS, nPar
|
||||
|
||||
!*-----------------------*!
|
||||
! DEFINE CHAR VARIABLES: !
|
||||
!*-----------------------*!
|
||||
CHARACTER(KIND=C_CHAR) :: file_extension(*)
|
||||
end function initialize_data_f
|
||||
!*============================================================================================*!
|
||||
function alloc_coder_f(nx, ny, nz, nts, npar, prec) result(codec) &
|
||||
bind(c, name="bwc_alloc_coder")
|
||||
import
|
||||
type(c_ptr) :: codec
|
||||
integer(kind=c_int64_t), value :: nx, ny, nz, nts
|
||||
integer(kind=c_int8_t), value :: npar
|
||||
integer(kind=c_int), value :: prec
|
||||
end function alloc_coder_f
|
||||
subroutine add_param_f(data, name, sample, dim, precision) &
|
||||
BIND(C, NAME="bwc_add_param")
|
||||
IMPORT
|
||||
!*-----------------------*!
|
||||
! DEFINE POINTERS: !
|
||||
!*-----------------------*!
|
||||
TYPE(C_PTR), VALUE :: data
|
||||
|
||||
!*-----------------------*!
|
||||
! DEFINE INT VARIABLES: !
|
||||
!*-----------------------*!
|
||||
INTEGER(KIND=C_INT16_T), VALUE :: sample
|
||||
INTEGER(KIND=C_INT8_T), VALUE :: precision
|
||||
INTEGER(KIND=C_SIGNED_CHAR), VALUE :: dim
|
||||
|
||||
!*-----------------------*!
|
||||
! DEFINE CHAR VARIABLES: !
|
||||
!*-----------------------*!
|
||||
CHARACTER(KIND=C_CHAR) :: name(*)
|
||||
end subroutine add_param_f
|
||||
!*============================================================================================*!
|
||||
function alloc_decoder_f() result(codec) &
|
||||
bind(c, name="bwc_alloc_decoder")
|
||||
import
|
||||
type(c_ptr) :: codec
|
||||
end function alloc_decoder_f
|
||||
subroutine get_data_f(data, buffer, size) &
|
||||
BIND(C, NAME="bwc_get_data")
|
||||
IMPORT
|
||||
!*-----------------------*!
|
||||
! DEFINE POINTERS: !
|
||||
!*-----------------------*!
|
||||
TYPE(C_PTR), VALUE :: data
|
||||
TYPE(C_PTR), VALUE :: buffer
|
||||
|
||||
!*-----------------------*!
|
||||
! DEFINE INT VARIABLES: !
|
||||
!*-----------------------*!
|
||||
INTEGER(KIND=C_INT64_T), Value :: size
|
||||
end subroutine get_data_f
|
||||
!*============================================================================================*!
|
||||
subroutine free_codec_f(codec) &
|
||||
bind(c, name="bwc_free_codec")
|
||||
import
|
||||
type(c_ptr), value :: codec
|
||||
end subroutine free_codec_f
|
||||
subroutine free_data_f(data) &
|
||||
BIND(C, NAME="bwc_free_data")
|
||||
IMPORT
|
||||
!*-----------------------*!
|
||||
! DEFINE POINTERS: !
|
||||
!*-----------------------*!
|
||||
TYPE(C_PTR), VALUE :: data
|
||||
end subroutine free_data_f
|
||||
!*============================================================================================*!
|
||||
subroutine set_error_resilience_f(codec) &
|
||||
bind(c, name="bwc_set_error_resilience")
|
||||
import
|
||||
type(c_ptr), value :: codec
|
||||
subroutine kill_compression_f(field) &
|
||||
BIND(C, NAME="bwc_kill_compression")
|
||||
IMPORT
|
||||
!*-----------------------*!
|
||||
! DEFINE POINTERS: !
|
||||
!*-----------------------*!
|
||||
TYPE(C_PTR), VALUE :: field
|
||||
end subroutine kill_compression_f
|
||||
!*============================================================================================*!
|
||||
function initialize_field_f(data) result(field) &
|
||||
BIND(C, NAME="bwc_initialize_field")
|
||||
IMPORT
|
||||
!*-----------------------*!
|
||||
! DEFINE POINTERS: !
|
||||
!*-----------------------*!
|
||||
TYPE(C_PTR), VALUE :: data
|
||||
TYPE(C_PTR) :: field
|
||||
end function initialize_field_f
|
||||
!*============================================================================================*!
|
||||
subroutine set_error_resilience_f(field) &
|
||||
BIND(C, NAME="bwc_set_error_resilience")
|
||||
IMPORT
|
||||
!*-----------------------*!
|
||||
! DEFINE POINTERS: !
|
||||
!*-----------------------*!
|
||||
TYPE(C_PTR), VALUE :: field
|
||||
end subroutine set_error_resilience_f
|
||||
!*============================================================================================*!
|
||||
subroutine set_decomp_f(codec, decompx, decompy, decompz, decompts) &
|
||||
bind(c, name="bwc_set_decomp")
|
||||
import
|
||||
type(c_ptr), value :: codec
|
||||
integer(kind=c_int8_t), value :: decompx, decompy
|
||||
integer(kind=c_int8_t), value :: decompz, decompts
|
||||
subroutine set_quantization_style_f(field, quantization_style) &
|
||||
BIND(C, NAME="bwc_set_quantization_style")
|
||||
IMPORT
|
||||
!*-----------------------*!
|
||||
! DEFINE POINTERS: !
|
||||
!*-----------------------*!
|
||||
TYPE(C_PTR), VALUE :: field
|
||||
|
||||
!*-----------------------*!
|
||||
! DEFINE INT VARIABLES: !
|
||||
!*-----------------------*!
|
||||
INTEGER(KIND=C_INT), VALUE :: quantization_style
|
||||
end subroutine set_quantization_style_f
|
||||
!*============================================================================================*!
|
||||
subroutine set_quantization_step_size_f(field, delta) &
|
||||
BIND(C, NAME="bwc_set_quantization_step_size")
|
||||
IMPORT
|
||||
!*-----------------------*!
|
||||
! DEFINE POINTERS: !
|
||||
!*-----------------------*!
|
||||
TYPE(C_PTR), VALUE :: field
|
||||
|
||||
!*-----------------------*!
|
||||
! DEFINE FLOAT VARIABLES: !
|
||||
!*-----------------------*!
|
||||
REAL(KIND=C_DOUBLE), VALUE :: delta
|
||||
end subroutine set_quantization_step_size_f
|
||||
!*============================================================================================*!
|
||||
subroutine set_progression_f(field, progression) &
|
||||
BIND(C, NAME="bwc_set_progression")
|
||||
IMPORT
|
||||
!*-----------------------*!
|
||||
! DEFINE POINTERS: !
|
||||
!*-----------------------*!
|
||||
TYPE(C_PTR), VALUE :: field
|
||||
|
||||
!*-----------------------*!
|
||||
! DEFINE INT VARIABLES: !
|
||||
!*-----------------------*!
|
||||
INTEGER(KIND=C_INT), VALUE :: progression
|
||||
end subroutine set_progression_f
|
||||
!*============================================================================================*!
|
||||
subroutine set_kernels_f(field, KernelX, KernelY, KernelZ, KernelTS) &
|
||||
BIND(C, NAME="bwc_set_kernels")
|
||||
IMPORT
|
||||
!*-----------------------*!
|
||||
! DEFINE POINTERS: !
|
||||
!*-----------------------*!
|
||||
TYPE(C_PTR), VALUE :: field
|
||||
|
||||
!*-----------------------*!
|
||||
! DEFINE INT VARIABLES: !
|
||||
!*-----------------------*!
|
||||
INTEGER(KIND=C_INT), VALUE :: KernelX, KernelY
|
||||
INTEGER(KIND=C_INT), VALUE :: KernelZ, KernelTS
|
||||
end subroutine set_kernels_f
|
||||
!*============================================================================================*!
|
||||
subroutine set_decomp_f(field, decompX, decompY, decompZ, decompTS) &
|
||||
BIND(C, NAME="bwc_set_decomp")
|
||||
IMPORT
|
||||
!*-----------------------*!
|
||||
! DEFINE POINTERS: !
|
||||
!*-----------------------*!
|
||||
TYPE(C_PTR), VALUE :: field
|
||||
|
||||
!*-----------------------*!
|
||||
! DEFINE INT VARIABLES: !
|
||||
!*-----------------------*!
|
||||
INTEGER(KIND=C_INT8_T), VALUE :: decompX, decompY
|
||||
INTEGER(KIND=C_INT8_T), VALUE :: decompZ, decompTS
|
||||
end subroutine set_decomp_f
|
||||
!*============================================================================================*!
|
||||
subroutine set_precincts_f(codec, px, py, pz, pts) &
|
||||
bind(c, name="bwc_set_precincts")
|
||||
import
|
||||
type(c_ptr), value :: codec
|
||||
integer(kind=c_int8_t), value :: px, py
|
||||
integer(kind=c_int8_t), value :: pz, pts
|
||||
subroutine set_precincts_f(field, pX, pY, pZ, pTS) &
|
||||
BIND(C, NAME="bwc_set_precincts")
|
||||
IMPORT
|
||||
!*-----------------------*!
|
||||
! DEFINE POINTERS: !
|
||||
!*-----------------------*!
|
||||
TYPE(C_PTR), VALUE :: field
|
||||
|
||||
!*-----------------------*!
|
||||
! DEFINE INT VARIABLES: !
|
||||
!*-----------------------*!
|
||||
INTEGER(KIND=C_INT8_T), VALUE :: pX, pY
|
||||
INTEGER(KIND=C_INT8_T), VALUE :: pZ, pTS
|
||||
end subroutine set_precincts_f
|
||||
!*============================================================================================*!
|
||||
subroutine set_codeblocks_f(codec, cbx, cby, cbz, cbts) &
|
||||
bind(c, name="bwc_set_codeblocks")
|
||||
import
|
||||
type(c_ptr), value :: codec
|
||||
integer(kind=c_int8_t), value :: cbx, cby
|
||||
integer(kind=c_int8_t), value :: cbz, cbts
|
||||
subroutine set_codeblocks_f(field, cbX, cbY, cbZ, cbTS) &
|
||||
BIND(C, NAME="bwc_set_codeblocks")
|
||||
IMPORT
|
||||
!*-----------------------*!
|
||||
! DEFINE POINTERS: !
|
||||
!*-----------------------*!
|
||||
TYPE(C_PTR), VALUE :: field
|
||||
|
||||
!*-----------------------*!
|
||||
! DEFINE INT VARIABLES: !
|
||||
!*-----------------------*!
|
||||
INTEGER(KIND=C_INT8_T), VALUE :: cbX, cbY
|
||||
INTEGER(KIND=C_INT8_T), VALUE :: cbZ, cbTS
|
||||
end subroutine set_codeblocks_f
|
||||
!*============================================================================================*!
|
||||
subroutine set_qm_f(codec, qm) &
|
||||
bind(c, name="bwc_set_qm")
|
||||
import
|
||||
type(c_ptr), value :: codec
|
||||
integer(kind=c_int8_t), value :: qm
|
||||
subroutine set_qm_f(field, Qm) &
|
||||
BIND(C, NAME="bwc_set_qm")
|
||||
IMPORT
|
||||
!*-----------------------*!
|
||||
! DEFINE POINTERS: !
|
||||
!*-----------------------*!
|
||||
TYPE(C_PTR), VALUE :: field
|
||||
|
||||
!*-----------------------*!
|
||||
! DEFINE INT VARIABLES: !
|
||||
!*-----------------------*!
|
||||
INTEGER(KIND=C_INT8_T), VALUE :: Qm
|
||||
end subroutine set_qm_f
|
||||
!*============================================================================================*!
|
||||
subroutine set_tiles_f(codec, tilesx, tilesy, tilesz, tilests, instr) &
|
||||
bind(c, name="bwc_set_tiles")
|
||||
import
|
||||
type(c_ptr), value :: codec
|
||||
integer(kind=c_int64_t), value :: tilesx, tilesy, tilesz, tilests
|
||||
integer(kind=c_int), value :: instr
|
||||
subroutine set_tiles_f(field, tilesX, tilesY, tilesZ, tilesTS, instr) &
|
||||
BIND(C, NAME="bwc_set_tiles")
|
||||
IMPORT
|
||||
!*-----------------------*!
|
||||
! DEFINE POINTERS: !
|
||||
!*-----------------------*!
|
||||
TYPE(C_PTR), VALUE :: field
|
||||
|
||||
!*-----------------------*!
|
||||
! DEFINE INT VARIABLES: !
|
||||
!*-----------------------*!
|
||||
INTEGER(KIND=C_INT64_T), VALUE :: tilesX, tilesY, tilesZ
|
||||
INTEGER(KIND=C_INT16_T), VALUE :: tilesTS
|
||||
INTEGER(KIND=C_INT), VALUE :: instr
|
||||
end subroutine set_tiles_f
|
||||
!*============================================================================================*!
|
||||
function create_compression_f(codec, stream, rate_control) result(error_flag) &
|
||||
bind(c, name="bwc_create_compression")
|
||||
import
|
||||
integer(kind=c_int8_t) :: error_flag
|
||||
type(c_ptr), value :: codec
|
||||
type(c_ptr), value :: stream
|
||||
character(kind=c_char) :: rate_control(*)
|
||||
function create_compression_f(field, rate_control) result(error_flag) &
|
||||
BIND(C, NAME="bwc_create_compression")
|
||||
IMPORT
|
||||
!*-----------------------*!
|
||||
! DEFINE POINTERS: !
|
||||
!*-----------------------*!
|
||||
TYPE(C_PTR), VALUE :: field
|
||||
|
||||
!*-----------------------*!
|
||||
! DEFINE INT VARIABLES: !
|
||||
!*-----------------------*!
|
||||
INTEGER(KIND=C_INT8_T) :: error_flag
|
||||
|
||||
!*-----------------------*!
|
||||
! DEFINE CHAR VARIABLES: !
|
||||
!*-----------------------*!
|
||||
CHARACTER(KIND=C_CHAR) :: rate_control(*)
|
||||
end function create_compression_f
|
||||
!*============================================================================================*!
|
||||
function compress_f(codec, stream) result(error_flag) &
|
||||
bind(c, name="bwc_compress")
|
||||
import
|
||||
integer(kind=c_int8_t) :: error_flag
|
||||
type(c_ptr), value :: codec
|
||||
type(c_ptr), value :: stream
|
||||
function compress_f(field, data) result(error_flag) &
|
||||
BIND(C, NAME="bwc_compress")
|
||||
IMPORT
|
||||
!*-----------------------*!
|
||||
! DEFINE POINTERS: !
|
||||
!*-----------------------*!
|
||||
TYPE(C_PTR), VALUE :: field
|
||||
TYPE(C_PTR), VALUE :: data
|
||||
|
||||
!*-----------------------*!
|
||||
! DEFINE INT VARIABLES: !
|
||||
!*-----------------------*!
|
||||
INTEGER(KIND=C_INT8_T) :: error_flag
|
||||
end function compress_f
|
||||
!*============================================================================================*!
|
||||
function create_decompression_f(codec, stream, layer) result(error_flag) &
|
||||
bind(c, name="bwc_create_decompression")
|
||||
import
|
||||
integer(kind=c_int8_t) :: error_flag
|
||||
type(c_ptr), value :: codec
|
||||
type(c_ptr), value :: stream
|
||||
integer(kind=c_int8_t), value :: layer
|
||||
function create_decompression_f(data, layer) result(field) &
|
||||
BIND(C, NAME="bwc_create_decompression")
|
||||
IMPORT
|
||||
!*-----------------------*!
|
||||
! DEFINE POINTERS: !
|
||||
!*-----------------------*!
|
||||
TYPE(C_PTR) :: field
|
||||
TYPE(C_PTR), VALUE :: data
|
||||
|
||||
!*-----------------------*!
|
||||
! DEFINE INT VARIABLES: !
|
||||
!*-----------------------*!
|
||||
INTEGER(KIND=C_INT8_T), VALUE :: layer
|
||||
end function create_decompression_f
|
||||
!*============================================================================================*!
|
||||
function decompress_f(codec, stream) result(error_flag) &
|
||||
bind(c, name="bwc_decompress")
|
||||
import
|
||||
integer(kind=c_int8_t) :: error_flag
|
||||
type(c_ptr), value :: codec
|
||||
type(c_ptr), value :: stream
|
||||
function decompress_f(field, data) result(error_flag) &
|
||||
BIND(C, NAME="bwc_decompress")
|
||||
IMPORT
|
||||
!*-----------------------*!
|
||||
! DEFINE POINTERS: !
|
||||
!*-----------------------*!
|
||||
TYPE(C_PTR), VALUE :: field
|
||||
TYPE(C_PTR), VALUE :: data
|
||||
|
||||
!*-----------------------*!
|
||||
! DEFINE INT VARIABLES: !
|
||||
!*-----------------------*!
|
||||
INTEGER(KIND=C_INT8_T) :: error_flag
|
||||
end function decompress_f
|
||||
end interface
|
||||
|
||||
|
@ -214,17 +395,24 @@ module bwc
|
|||
public :: bwc_tile_sizeof, &
|
||||
bwc_tile_numbof
|
||||
|
||||
public :: bwc_init_stream, &
|
||||
bwc_alloc_coder, &
|
||||
bwc_alloc_decoder, &
|
||||
bwc_free_codec
|
||||
public :: bwc_initialize_data, &
|
||||
bwc_get_data, &
|
||||
bwc_free_data
|
||||
|
||||
public :: bwc_initialize_field, &
|
||||
bwc_add_param, &
|
||||
bwc_kill_compression
|
||||
|
||||
public :: bwc_set_error_resilience, &
|
||||
bwc_set_quantization_style, &
|
||||
bwc_set_quantization_step_size, &
|
||||
bwc_set_progression, &
|
||||
bwc_set_kernels, &
|
||||
bwc_set_decomp, &
|
||||
bwc_set_precincts, &
|
||||
bwc_set_codeblocks, &
|
||||
bwc_set_qm, &
|
||||
bwc_set_tiles
|
||||
bwc_set_tiles,
|
||||
|
||||
public :: bwc_create_compression, &
|
||||
bwc_compress, &
|
||||
|
|
|
@ -84,37 +84,55 @@ const = _const()
|
|||
#| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] |#
|
||||
#| |#
|
||||
#**************************************************************************************************#
|
||||
def init_stream(inpbuf, outbuf, mode):
|
||||
fun = libbwc.bwc_init_stream
|
||||
fun.restype = ctypes.c_void_p
|
||||
fun.argtypes = [ndpointer(ctypes.c_double, flags="C_CONTIGUOUS"),
|
||||
ndpointer(ctypes.c_double, flags="C_CONTIGUOUS"),
|
||||
ctypes.c_char_p]
|
||||
return ctypes.c_void_p(fun(inpbuf, outbuf, mode.encode('utf-8')))
|
||||
#==================================================================================================#
|
||||
def alloc_coder(nX, nY, nZ, nTS, nPar, prec):
|
||||
fun = libbwc.bwc_alloc_coder
|
||||
fun.restype = ctypes.c_void_p
|
||||
fun.argtypes = [ctypes.c_uint64,
|
||||
ctypes.c_uint64,
|
||||
ctypes.c_uint64,
|
||||
ctypes.c_uint8,
|
||||
ctypes.c_char_p]
|
||||
return ctypes.c_void_p(fun(nX, nY, nZ, nTS, nPar, prec.encode('utf-8')))
|
||||
#==================================================================================================#
|
||||
def alloc_decoder():
|
||||
fun = libbwc.bwc_alloc_decoder
|
||||
fun.restype = ctypes.c_void_p
|
||||
fun.argtypes = []
|
||||
return ctypes.c_void_p(fun())
|
||||
#==================================================================================================#
|
||||
def free_codec(codec):
|
||||
fun = libbwc.bwc_free_codec
|
||||
def free_data(data):
|
||||
fun = libbwc.bwc_free_data
|
||||
fun.restype = None
|
||||
fun.argtypes = [ctypes.c_void_p]
|
||||
fun(codec)
|
||||
fun(data)
|
||||
#==================================================================================================#
|
||||
def set_codeblocks(codec, cbX, cbY, cbZ, cbTS):
|
||||
def initialize_data(data, nX, nY, nZ, nTS, nPar, file_extension):
|
||||
fun = libbwc.bwc_initialize_data
|
||||
fun.restype = ctypes.c_void_p
|
||||
fun.argtypes = [ndpointer(ctypes.c_double, flags="C_CONTIGUOUS"),
|
||||
ctypes.c_uint64,
|
||||
ctypes.c_uint64,
|
||||
ctypes.c_uint64,
|
||||
ctypes.c_uint16,
|
||||
ctypes.c_uint8,
|
||||
ctypes.c_char_p]
|
||||
return ctypes.c_void_p(fun(data, nX, nY, nZ, nTS, nPar, file_extension.encode('utf-8')))
|
||||
#==================================================================================================#
|
||||
def get_data(data, buffer, size):
|
||||
fun = libbwc.bwc_get_data
|
||||
fun.restype = None
|
||||
fun.argtypes = [ctypes.c_void_p,
|
||||
ndpointer(ctypes.c_double, flags="C_CONTIGUOUS"),
|
||||
ctypes.c_uint64]
|
||||
fun(data, buffer, size)
|
||||
#==================================================================================================#
|
||||
def add_param(data, name, sample, dim, precision):
|
||||
fun = libbwc.bwc_add_param
|
||||
fun.restype = None
|
||||
fun.argtypes = [ctypes.c_void_p,
|
||||
ctypes.c_char_p,
|
||||
ctypes.c_uint16,
|
||||
ctypes.c_uint8,
|
||||
ctypes.c_uint8]
|
||||
fun(data, name.encode('utf-8'), sample, dim, precision)
|
||||
#==================================================================================================#
|
||||
def kill_compression(field):
|
||||
fun = libbwc.bwc_kill_compression
|
||||
fun.restype = None
|
||||
fun.argtypes = [ctypes.c_void_p]
|
||||
fun(field)
|
||||
#==================================================================================================#
|
||||
def initialize_field(data):
|
||||
fun = libbwc.bwc_initialize_field
|
||||
fun.restype = ctypes.c_void_p
|
||||
fun.argtypes = [ctypes.c_void_p]
|
||||
return ctypes.c_void_p(fun(data))
|
||||
#==================================================================================================#
|
||||
def set_codeblocks(field, cbX, cbY, cbZ, cbTS):
|
||||
fun = libbwc.bwc_set_codeblocks
|
||||
fun.restype = None
|
||||
fun.argtypes = [ctypes.c_void_p,
|
||||
|
@ -122,9 +140,9 @@ def set_codeblocks(codec, cbX, cbY, cbZ, cbTS):
|
|||
ctypes.c_uint8,
|
||||
ctypes.c_uint8,
|
||||
ctypes.c_uint8]
|
||||
fun(codec, cbX, cbY, cbZ, cbTS)
|
||||
fun(field, cbX, cbY, cbZ, cbTS)
|
||||
#==================================================================================================#
|
||||
def set_decomp(codec, decompX, decompY, decompZ, decompTS):
|
||||
def set_decomp(field, decompX, decompY, decompZ, decompTS):
|
||||
fun = libbwc.bwc_set_decomp
|
||||
fun.restype = None
|
||||
fun.argtypes = [ctypes.c_void_p,
|
||||
|
@ -132,16 +150,16 @@ def set_decomp(codec, decompX, decompY, decompZ, decompTS):
|
|||
ctypes.c_uint8,
|
||||
ctypes.c_uint8,
|
||||
ctypes.c_uint8]
|
||||
fun(codec, decompX, decompY, decompZ, decompTS)
|
||||
fun(field, decompX, decompY, decompZ, decompTS)
|
||||
#==================================================================================================#
|
||||
def set_qm(codec, Qm):
|
||||
def set_qm(field, Qm):
|
||||
fun = libbwc.bwc_set_qm
|
||||
fun.restype = None
|
||||
fun.argtypes = [ctypes.c_void_p,
|
||||
ctypes.c_uint8]
|
||||
fun(codec, Qm)
|
||||
ctypes.c_int8]
|
||||
fun(field, Qm)
|
||||
#==================================================================================================#
|
||||
def set_tiles(codec, tilesX, tilesY, tilesZ, tilesTS, instr):
|
||||
def set_tiles(field, tilesX, tilesY, tilesZ, tilesTS, instr):
|
||||
fun = libbwc.bwc_set_tiles
|
||||
fun.restype = None
|
||||
fun.argtypes = [ctypes.c_void_p,
|
||||
|
@ -150,9 +168,9 @@ def set_tiles(codec, tilesX, tilesY, tilesZ, tilesTS, instr):
|
|||
ctypes.c_uint64,
|
||||
ctypes.c_uint64,
|
||||
ctypes.c_char_p]
|
||||
fun(codec, tilesX, tilesY, tilesZ, tilesTS, instr.encode('utf-8'))
|
||||
fun(field, tilesX, tilesY, tilesZ, tilesTS, instr.encode('utf-8'))
|
||||
#==================================================================================================#
|
||||
def set_precincts(codec, pX, pY, pZ, pTS):
|
||||
def set_precincts(field, pX, pY, pZ, pTS):
|
||||
fun = libbwc.bwc_set_precincts
|
||||
fun.restype = None
|
||||
fun.argtypes = [ctypes.c_void_p,
|
||||
|
@ -160,34 +178,32 @@ def set_precincts(codec, pX, pY, pZ, pTS):
|
|||
ctypes.c_uint8,
|
||||
ctypes.c_uint8,
|
||||
ctypes.c_uint8]
|
||||
fun(codec, pX, pY, pZ, pTS)
|
||||
fun(field, pX, pY, pZ, pTS)
|
||||
#==================================================================================================#
|
||||
def create_compression(codec, stream, rate_control):
|
||||
def create_compression(field, rate_control):
|
||||
fun = libbwc.bwc_create_compression
|
||||
fun.restype = ctypes.c_uchar
|
||||
fun.restype = None
|
||||
fun.argtypes = [ctypes.c_void_p,
|
||||
ctypes.c_void_p,
|
||||
ctypes.c_char_p]
|
||||
return ctypes.c_uchar(fun(codec, stream, rate_control.encode('utf-8')))
|
||||
fun(field, rate_control.encode('utf-8'))
|
||||
#==================================================================================================#
|
||||
def compress(codec, stream):
|
||||
def compress(field, data):
|
||||
fun = libbwc.bwc_compress
|
||||
fun.restype = ctypes.c_size_t
|
||||
fun.restype = None
|
||||
fun.argtypes = [ctypes.c_void_p,
|
||||
ctypes.c_void_p]
|
||||
return ctypes.c_size_t(fun(codec, stream))
|
||||
fun(field, data)
|
||||
#==================================================================================================#
|
||||
def create_decompression(codec, stream, layer):
|
||||
def create_decompression(field, data):
|
||||
fun = libbwc.bwc_create_decompression
|
||||
fun.restype = ctypes.c_uchar
|
||||
fun.restype = ctypes.c_void_p
|
||||
fun.argtypes = [ctypes.c_void_p,
|
||||
ctypes.c_void_p,
|
||||
ctypes.c_uint8]
|
||||
return ctypes.c_uchar(fun(codec, stream, layer))
|
||||
return ctypes.c_void_p(fun(field, data))
|
||||
#==================================================================================================#
|
||||
def decompress(codec, stream):
|
||||
def decompress(field, data):
|
||||
fun = libbwc.bwc_decompress
|
||||
fun.restype = ctypes.c_uchar
|
||||
fun.restype = None
|
||||
fun.argtypes = [ctypes.c_void_p,
|
||||
ctypes.c_void_p]
|
||||
return ctypes.c_uchar(fun(codec, stream))
|
||||
fun(field, data)
|
|
@ -107,6 +107,8 @@ bytes_used(bitstream const *const stream)
|
|||
}
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! FUNCTION NAME: bitstream* bwc_init_stream(uchar* memory, uint32 size, char instr) !
|
||||
! -------------- !
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
! ------------ !
|
||||
|
@ -143,7 +145,7 @@ bytes_used(bitstream const *const stream)
|
|||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
bitstream*
|
||||
init_bitstream(uchar* memory, uint32 size, char instr)
|
||||
init_stream(uchar* memory, uint32 size, char instr)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE STRUCTS: !
|
||||
|
@ -153,7 +155,6 @@ init_bitstream(uchar* memory, uint32 size, char instr)
|
|||
/*-----------------------*\
|
||||
! DEFINE ASSERTIONS: !
|
||||
\*-----------------------*/
|
||||
assert(memory);
|
||||
assert(instr == 'c' || instr == 'd');
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
|
@ -167,11 +168,37 @@ init_bitstream(uchar* memory, uint32 size, char instr)
|
|||
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->memory = memory;
|
||||
stream->t = (instr == 'c') ? 8 : 0;
|
||||
stream->Lmax = size;
|
||||
stream->size_incr = (uint64)(size / 2);
|
||||
|
@ -220,6 +247,11 @@ init_bitstream(uchar* memory, uint32 size, char instr)
|
|||
void
|
||||
emit_chunck(bitstream *const stream, const uchar* chunck, const uint64 size)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE INT VARIABLES: !
|
||||
\*-----------------------*/
|
||||
uint64 Lreq;
|
||||
|
||||
/*-----------------------*\
|
||||
! DEFINE ASSERTIONS: !
|
||||
\*-----------------------*/
|
||||
|
@ -227,30 +259,54 @@ emit_chunck(bitstream *const stream, const uchar* chunck, const uint64 size)
|
|||
assert(chunck);
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Check if an error was encountered in a previous writing !
|
||||
! operation !
|
||||
! Evaluate the memory block size if the current chunck of !
|
||||
! data is written to the stream. !
|
||||
\*--------------------------------------------------------*/
|
||||
if(!stream->error)
|
||||
Lreq = (bytes_used(stream) + size);
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Check if the enough memory has been allocated for the !
|
||||
! stream to store the additional data chunck. !
|
||||
\*--------------------------------------------------------*/
|
||||
if(Lreq > stream->Lmax)
|
||||
{
|
||||
/*--------------------------------------------------------*\
|
||||
! Check if the enough memory has been allocated for the !
|
||||
! stream to store the additional symbol. !
|
||||
! If the stream is not large enough, check if this is due !
|
||||
! to an error encountered in a previous writing operation !
|
||||
\*--------------------------------------------------------*/
|
||||
if((bytes_used(stream) + size) > stream->Lmax)
|
||||
if(!stream->error)
|
||||
{
|
||||
// memory allocation error
|
||||
stream->error |= 1;
|
||||
stream->Lmax = 0;
|
||||
/*--------------------------------------------------------*\
|
||||
! If the error flag is not set, increase the stream size !
|
||||
! until it is large enough to store the additional data !
|
||||
! chunck. !
|
||||
\*--------------------------------------------------------*/
|
||||
while(Lreq > stream->Lmax)
|
||||
{
|
||||
stream->Lmax += stream->size_incr + size;
|
||||
stream->size_incr = (uint64)(stream->Lmax / 2);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Reallocate the stream data block. !
|
||||
\*--------------------------------------------------------*/
|
||||
stream->memory = realloc(stream->memory, stream->Lmax);
|
||||
if(!stream->memory)
|
||||
{
|
||||
// memory allocation error
|
||||
stream->error |= 1;
|
||||
stream->Lmax = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*--------------------------------------------------------*\
|
||||
! Exit to function caller if error flag has been set. !
|
||||
\*--------------------------------------------------------*/
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*--------------------------------------------------------*\
|
||||
! Exit to function caller if error flag has been set. !
|
||||
\*--------------------------------------------------------*/
|
||||
return;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Copy the additional data to the stream memory block. !
|
||||
|
@ -314,30 +370,44 @@ emit_symbol(bitstream *const stream, const uint64 symbol, const uint8 size)
|
|||
assert(stream);
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Check if an error was encountered in a previous writing !
|
||||
! operation !
|
||||
! Check if the enough memory has been allocated for the !
|
||||
! stream to store the additional symbol. !
|
||||
\*--------------------------------------------------------*/
|
||||
if(!stream->error)
|
||||
if((bytes_used(stream) + size) > stream->Lmax)
|
||||
{
|
||||
/*--------------------------------------------------------*\
|
||||
! Check if the enough memory has been allocated for the !
|
||||
! stream to store the additional symbol. !
|
||||
! If the stream is not large enough, check if this is due !
|
||||
! to an error encountered in a previous writing operation !
|
||||
\*--------------------------------------------------------*/
|
||||
if((bytes_used(stream) + size) > stream->Lmax)
|
||||
if(!stream->error)
|
||||
{
|
||||
// memory allocation error
|
||||
stream->error |= 1;
|
||||
stream->Lmax = 0;
|
||||
/*--------------------------------------------------------*\
|
||||
! If the error flag is not set, increment the stream size !
|
||||
! to store the additional symbol. !
|
||||
\*--------------------------------------------------------*/
|
||||
stream->Lmax += stream->size_incr;
|
||||
stream->size_incr = (uint64)(stream->Lmax / 2);
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Reallocate the stream data block. !
|
||||
\*--------------------------------------------------------*/
|
||||
stream->memory = realloc(stream->memory, stream->Lmax);
|
||||
if(!stream->memory)
|
||||
{
|
||||
// memory allocation error
|
||||
stream->error |= 1;
|
||||
stream->Lmax = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*--------------------------------------------------------*\
|
||||
! Exit to function caller if error flag has been set. !
|
||||
\*--------------------------------------------------------*/
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*--------------------------------------------------------*\
|
||||
! Exit to function caller if error flag has been set. !
|
||||
\*--------------------------------------------------------*/
|
||||
return;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Copy the additional symbol to the stream memory block !
|
||||
|
@ -798,79 +868,76 @@ flush_stream(bitstream *const stream)
|
|||
}
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! FUNCTION NAME: void *test(void) !
|
||||
! -------------- !
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
! ------------ !
|
||||
! Shrinks the bitstream memory to the actually filled range. !
|
||||
! DESCRIPTION NEEDED !
|
||||
! !
|
||||
! PARAMETERS: !
|
||||
! ----------- !
|
||||
! Variable Type Description !
|
||||
! -------- ---- ----------- !
|
||||
! - - - !
|
||||
! !
|
||||
! RETURN VALUE: !
|
||||
! ------------- !
|
||||
! Returns 0 if successfull and 1 if memory could not be resized. !
|
||||
! Type Description !
|
||||
! ---- ----------- !
|
||||
! - - !
|
||||
! !
|
||||
! DEVELOPMENT HISTORY: !
|
||||
! -------------------- !
|
||||
! !
|
||||
! Date Author Change Id Release Description Of Change !
|
||||
! ---- ------ --------- ------- --------------------- !
|
||||
! - Patrick Vogler B87D120 V 0.1.0 function created !
|
||||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
uchar
|
||||
shrink_to_fit(bitstream *const stream)
|
||||
terminate_stream(bitstream *stream, bwc_stream *const packed_stream)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE ASSERTIONS: !
|
||||
\*-----------------------*/
|
||||
assert(stream);
|
||||
|
||||
if(stream->error)
|
||||
if(packed_stream)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if(stream->L > stream->Lmax)
|
||||
{
|
||||
stream->Lmax = stream->L;
|
||||
stream->memory = realloc(stream->memory, stream->Lmax);
|
||||
if(!stream->memory)
|
||||
if(stream->error)
|
||||
{
|
||||
// memory allocation error
|
||||
fprintf(stderr, MEMERROR);
|
||||
stream->Lmax = 0;
|
||||
return 1;
|
||||
}
|
||||
else if(stream->L != stream->Lmax)
|
||||
{
|
||||
stream->Lmax = stream->L;
|
||||
stream->memory = realloc(stream->memory, stream->Lmax);
|
||||
if(!stream->memory)
|
||||
{
|
||||
// memory allocation error
|
||||
fprintf(stderr, MEMERROR);
|
||||
stream->Lmax = 0;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
packed_stream->memory = stream->memory;
|
||||
packed_stream->access = stream->memory;
|
||||
packed_stream->size = stream->L;
|
||||
packed_stream->position = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! DESCRIPTION: !
|
||||
! ------------ !
|
||||
! Swap memory pointer and size to span. Invalidates stream pointers. !
|
||||
! !
|
||||
! RETURN VALUE: !
|
||||
! ------------- !
|
||||
! Returns 0 if successfull and 1 if stream had previous memory error. !
|
||||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
uchar
|
||||
transfer_to_span(bitstream *const stream, bwc_span *const span)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE ASSERTIONS: !
|
||||
\*-----------------------*/
|
||||
assert(stream);
|
||||
assert(span);
|
||||
|
||||
if(stream->error)
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
free(stream->memory);
|
||||
}
|
||||
|
||||
span->memory = stream->memory;
|
||||
span->access = stream->memory;
|
||||
span->size = stream->L;
|
||||
span->position = 0;
|
||||
|
||||
stream->memory = NULL;
|
||||
stream->L = 0;
|
||||
|
||||
|
||||
free(stream);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! FUNCTION NAME: void release_packed_stream(bwc_span *stream) !
|
||||
! FUNCTION NAME: void release_packed_stream(bwc_stream *stream) !
|
||||
! -------------- !
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
|
@ -882,7 +949,7 @@ transfer_to_span(bitstream *const stream, bwc_span *const span)
|
|||
! ----------- !
|
||||
! Variable Type Description !
|
||||
! -------- ---- ----------- !
|
||||
! stream bwc_span - Packed bitstream used to store parts of !
|
||||
! stream bwc_stream - Packed bitstream used to store parts of !
|
||||
! the bwc codestream. !
|
||||
! !
|
||||
! RETURN VALUE: !
|
||||
|
@ -900,7 +967,7 @@ transfer_to_span(bitstream *const stream, bwc_span *const span)
|
|||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
void
|
||||
release_packed_stream(bwc_span *stream)
|
||||
release_packed_stream(bwc_stream *stream)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE ASSERTIONS: !
|
||||
|
|
|
@ -104,7 +104,7 @@ can_read(bitstream *const stream, const uint64 length)
|
|||
}
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! FUNCTION NAME: void codestream_write_header(bitstream *const stream, bwc_codec *const codec) !
|
||||
! FUNCTION NAME: void codestream_write_header(bitstream *const stream, bwc_field *const field) !
|
||||
! -------------- !
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
|
@ -116,7 +116,7 @@ can_read(bitstream *const stream, const uint64 length)
|
|||
! ----------- !
|
||||
! Variable Type Description !
|
||||
! -------- ---- ----------- !
|
||||
! codec bwc_codec* - Structure defining the compression/ !
|
||||
! field bwc_field* - Structure defining the compression/ !
|
||||
! decompression stage. !
|
||||
! !
|
||||
! stream bitstream* - Structure used to assemble a bwc bit- !
|
||||
|
@ -138,8 +138,7 @@ can_read(bitstream *const stream, const uint64 length)
|
|||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
static void
|
||||
codestream_write_header(bitstream *const stream,
|
||||
bwc_codec *const codec,
|
||||
bwc_stream *const data)
|
||||
bwc_field *const field)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE INT VARIABLES: !
|
||||
|
@ -156,27 +155,33 @@ codestream_write_header(bitstream *const stream,
|
|||
\*-----------------------*/
|
||||
bwc_gl_ctrl *control;
|
||||
bwc_gl_inf *info;
|
||||
bwc_span *aux;
|
||||
bwc_span *com;
|
||||
bwc_tile *tile;
|
||||
bwc_parameter *parameter;
|
||||
bwc_stream *aux;
|
||||
bwc_stream *com;
|
||||
|
||||
/*-----------------------*\
|
||||
! DEFINE ASSERTIONS: !
|
||||
\*-----------------------*/
|
||||
assert(stream);
|
||||
assert(codec);
|
||||
assert(field);
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Save the global as well as the subband control and info !
|
||||
! structure to temporary variables to make the code more !
|
||||
! readable. !
|
||||
\*--------------------------------------------------------*/
|
||||
info = &codec->info;
|
||||
control = &codec->control;
|
||||
info = field->info;
|
||||
control = &field->control;
|
||||
|
||||
aux = data->codestream.aux;
|
||||
com = data->codestream.com;
|
||||
tile = &field->tile[0];
|
||||
|
||||
parameter = &tile->parameter[0];
|
||||
|
||||
aux = field->aux;
|
||||
com = field->com;
|
||||
|
||||
Linf = 31;
|
||||
Linf = 40 + info->nPar * 25;
|
||||
Lctr = 50 + control->nLayers * 4;
|
||||
Leoh = info->nPar * control->nTiles * 2 * PREC_BYTE;
|
||||
Lcss = control->codestreamSize;
|
||||
|
@ -188,10 +193,16 @@ codestream_write_header(bitstream *const stream,
|
|||
emit_symbol(stream, info->nX, 8);
|
||||
emit_symbol(stream, info->nY, 8);
|
||||
emit_symbol(stream, info->nZ, 8);
|
||||
emit_symbol(stream, info->nTS, 8);
|
||||
emit_symbol(stream, info->nTS, 2);
|
||||
emit_symbol(stream, info->nPar, 1);
|
||||
emit_symbol(stream, (uint8)info->data_prec, 1);
|
||||
emit_symbol(stream, (uint8)info->codec_prec, 1);
|
||||
emit_symbol(stream, info->precision, 1);
|
||||
emit_chunck(stream, (uchar*)info->f_ext, 10);
|
||||
|
||||
for(p = 0; p < info->nPar; ++p)
|
||||
{
|
||||
emit_chunck(stream, (uchar*)parameter[p].info.name, 24);
|
||||
emit_symbol(stream, parameter[p].info.precision, 1);
|
||||
}
|
||||
|
||||
emit_symbol(stream, SGC, 2);
|
||||
emit_symbol(stream, Lctr, 2);
|
||||
|
@ -228,7 +239,7 @@ codestream_write_header(bitstream *const stream,
|
|||
emit_symbol(stream, control->tileSizeX, 8);
|
||||
emit_symbol(stream, control->tileSizeY, 8);
|
||||
emit_symbol(stream, control->tileSizeZ, 8);
|
||||
emit_symbol(stream, control->tileSizeTS, 8);
|
||||
emit_symbol(stream, control->tileSizeTS, 2);
|
||||
|
||||
emit_symbol(stream, control->nLayers, 1);
|
||||
|
||||
|
@ -263,21 +274,21 @@ codestream_write_header(bitstream *const stream,
|
|||
for(p = 0; p < info->nPar; ++p)
|
||||
{
|
||||
|
||||
emit_symbol(stream, *(uint64 *)&codec->tile[t].
|
||||
emit_symbol(stream, *(uint64 *)&field->tile[t].
|
||||
parameter[p].info.
|
||||
parameter_min, PREC_BYTE);
|
||||
emit_symbol(stream, *(uint64 *)&codec->tile[t].
|
||||
emit_symbol(stream, *(uint64 *)&field->tile[t].
|
||||
parameter[p].info.
|
||||
parameter_max, PREC_BYTE);
|
||||
|
||||
codec->tile[t].parameter[p].info.parameter_max = -FLT_MAX;
|
||||
codec->tile[t].parameter[p].info.parameter_min = FLT_MAX;
|
||||
field->tile[t].parameter[p].info.parameter_max = -FLT_MAX;
|
||||
field->tile[t].parameter[p].info.parameter_min = FLT_MAX;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! FUNCTION NAME: uchar sequence_packets(bwc_codec *const codec, bwc_tile *const tile) !
|
||||
! FUNCTION NAME: uchar sequence_packets(bwc_field *const field, bwc_field *const field) !
|
||||
! -------------- !
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
|
@ -288,7 +299,7 @@ codestream_write_header(bitstream *const stream,
|
|||
! ----------- !
|
||||
! Variable Type Description !
|
||||
! -------- ---- ----------- !
|
||||
! codec bwc_codec* - Structure defining the compression/ !
|
||||
! field bwc_field* - Structure defining the compression/ !
|
||||
! decompression stage. !
|
||||
! !
|
||||
! tile bwc_tile* - Structure defining a bwc tile. !
|
||||
|
@ -308,7 +319,7 @@ codestream_write_header(bitstream *const stream,
|
|||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
static uchar
|
||||
sequence_packets(bwc_codec *const codec, bwc_tile *const tile)
|
||||
sequence_packets(bwc_field *const field, bwc_tile *const tile)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE INT VARIABLES: !
|
||||
|
@ -336,8 +347,8 @@ sequence_packets(bwc_codec *const codec, bwc_tile *const tile)
|
|||
! sequence structure to temporary variables to make the !
|
||||
! code more readable. !
|
||||
\*--------------------------------------------------------*/
|
||||
control = &codec->control;
|
||||
info = &codec->info;
|
||||
control = &field->control;
|
||||
info = field->info;
|
||||
|
||||
packet_sequence = tile->packet_sequence;
|
||||
|
||||
|
@ -479,7 +490,7 @@ sequence_packets(bwc_codec *const codec, bwc_tile *const tile)
|
|||
}
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! FUNCTION NAME: !
|
||||
! FUNCTION NAME: uchar sequence_packets(bwc_field *const field, bwc_field *const field) !
|
||||
! -------------- !
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
|
@ -490,11 +501,16 @@ sequence_packets(bwc_codec *const codec, bwc_tile *const tile)
|
|||
! ----------- !
|
||||
! Variable Type Description !
|
||||
! -------- ---- ----------- !
|
||||
! field bwc_field* - Structure defining the compression/ !
|
||||
! decompression stage. !
|
||||
! !
|
||||
! tile bwc_tile* - Structure defining a bwc tile. !
|
||||
! !
|
||||
! RETURN VALUE: !
|
||||
! ------------- !
|
||||
! Type Description !
|
||||
! ---- ----------- !
|
||||
! uchar - Returns an unsigned char for error handling. !
|
||||
! !
|
||||
! DEVELOPMENT HISTORY: !
|
||||
! -------------------- !
|
||||
|
@ -505,7 +521,7 @@ sequence_packets(bwc_codec *const codec, bwc_tile *const tile)
|
|||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
static void
|
||||
assemble_tile(bwc_codec *const codec, bwc_tile *const tile, bitstream *const stream)
|
||||
assemble_tile(bwc_field *const field, bwc_tile *const tile, bitstream *const stream)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE INT VARIABLES: !
|
||||
|
@ -521,7 +537,7 @@ assemble_tile(bwc_codec *const codec, bwc_tile *const tile, bitstream *const str
|
|||
/*-----------------------*\
|
||||
! DEFINE ASSERTIONS: !
|
||||
\*-----------------------*/
|
||||
assert(codec);
|
||||
assert(field);
|
||||
assert(tile);
|
||||
assert(stream);
|
||||
|
||||
|
@ -530,7 +546,7 @@ assemble_tile(bwc_codec *const codec, bwc_tile *const tile, bitstream *const str
|
|||
! sequence structure to temporary variables to make the !
|
||||
! code more readable. !
|
||||
\*--------------------------------------------------------*/
|
||||
control = &codec->control;
|
||||
control = &field->control;
|
||||
|
||||
emit_symbol(stream, SOT, 2);
|
||||
emit_symbol(stream, 14, 2);
|
||||
|
@ -597,14 +613,14 @@ assemble_tile(bwc_codec *const codec, bwc_tile *const tile, bitstream *const str
|
|||
! - Patrick Vogler B87D120 V 0.1.0 function created !
|
||||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
bwc_codec*
|
||||
parse_main_header(bwc_codec *const codec, bwc_stream *const data, bitstream *const stream)
|
||||
bwc_field*
|
||||
parse_main_header(bwc_data *const data,bitstream *const stream)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE INT VARIABLES: !
|
||||
\*-----------------------*/
|
||||
uint64 buff_long, buffX, buffY, buffZ, buffTS;
|
||||
uint64 nX, nY, nZ, nTS;
|
||||
uint64 nX, nY, nZ;
|
||||
uint32 buff;
|
||||
uint32 bitrate;
|
||||
uint32 Lsax;
|
||||
|
@ -613,34 +629,35 @@ parse_main_header(bwc_codec *const codec, bwc_stream *const data, bitstream *con
|
|||
uint16 CSsgc;
|
||||
uint16 Linf, Lctr, Lcom, Leoh, Lunk;
|
||||
uint16 marker;
|
||||
uint16 nTS;
|
||||
uint8 index, l;
|
||||
uint8 nPar, p;
|
||||
bwc_precision data_prec, codec_prec;
|
||||
uint8 codec_prec, precision;
|
||||
|
||||
/*-----------------------*\
|
||||
! DEFINE CHAR VARIABLES: !
|
||||
\*-----------------------*/
|
||||
char* buffer_char;
|
||||
char status;
|
||||
|
||||
/*-----------------------*\
|
||||
! DEFINE STRUCTS: !
|
||||
\*-----------------------*/
|
||||
bwc_field *field;
|
||||
bwc_gl_ctrl *control;
|
||||
bwc_gl_inf *info;
|
||||
|
||||
/*-----------------------*\
|
||||
! DEFINE ASSERTIONS: !
|
||||
\*-----------------------*/
|
||||
assert(codec);
|
||||
assert(data);
|
||||
assert(stream);
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Save the global control and info structure to temporary !
|
||||
! variables to make the code more readable. !
|
||||
! Save the data info structure to a temporary variable to !
|
||||
! make the code more readable. !
|
||||
\*--------------------------------------------------------*/
|
||||
info = &codec->info;
|
||||
control = &codec->control;
|
||||
info = &data->info;
|
||||
|
||||
status = CODESTREAM_OK;
|
||||
index = 0;
|
||||
|
@ -691,23 +708,41 @@ parse_main_header(bwc_codec *const codec, bwc_stream *const data, bitstream *con
|
|||
break;
|
||||
}
|
||||
|
||||
nX = get_symbol(stream, 8);
|
||||
nY = get_symbol(stream, 8);
|
||||
nZ = get_symbol(stream, 8);
|
||||
nTS = get_symbol(stream, 8);
|
||||
nPar = (uint8)get_symbol(stream, 1);
|
||||
data_prec = (bwc_precision)get_symbol(stream, 1);
|
||||
codec_prec = (bwc_precision)get_symbol(stream, 1);
|
||||
info->nX = nX = get_symbol(stream, 8);
|
||||
info->nY = nY = get_symbol(stream, 8);
|
||||
info->nZ = nZ = get_symbol(stream, 8);
|
||||
info->nTS = nTS = (uint16)get_symbol(stream, 2);
|
||||
info->nPar = nPar = (uint8)get_symbol(stream, 1);
|
||||
info->precision = codec_prec = (uint8)get_symbol(stream, 1);
|
||||
|
||||
info->codec_prec = codec_prec;
|
||||
buffer_char = (char*)get_chunck(stream, 10);
|
||||
strncpy(info->f_ext, buffer_char, sizeof(buffer_char)/sizeof(*buffer_char));
|
||||
free(buffer_char);
|
||||
|
||||
configure_codec(codec, nX, nY, nZ, nTS, nPar, data_prec);
|
||||
if(!codec)
|
||||
for(p = 0; p < nPar; ++p)
|
||||
{
|
||||
buffer_char = (char*)get_chunck(stream, 24);
|
||||
precision = (uint8)get_symbol(stream, 1);
|
||||
|
||||
bwc_add_param(data, buffer_char, precision);
|
||||
|
||||
free(buffer_char);
|
||||
}
|
||||
|
||||
field = bwc_initialize_field(data);
|
||||
if(!field)
|
||||
{
|
||||
status |= CODESTREAM_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Save the global control and info structure to temporary !
|
||||
! variables to make the code more readable. !
|
||||
\*--------------------------------------------------------*/
|
||||
info = field->info = &data->info;
|
||||
control = &field->control;
|
||||
|
||||
control->codestreamSize = stream->Lmax;
|
||||
|
||||
status |= CODESTREAM_SGI_READ;
|
||||
|
@ -720,7 +755,7 @@ parse_main_header(bwc_codec *const codec, bwc_stream *const data, bitstream *con
|
|||
{
|
||||
// Invalid Codestream
|
||||
fprintf(stderr, CSERROR);
|
||||
bwc_free_codec(codec);
|
||||
bwc_kill_compression(field);
|
||||
status |= CODESTREAM_ERROR;
|
||||
break;
|
||||
}
|
||||
|
@ -731,7 +766,7 @@ parse_main_header(bwc_codec *const codec, bwc_stream *const data, bitstream *con
|
|||
{
|
||||
// Invalid Codestream
|
||||
fprintf(stderr, CSERROR);
|
||||
bwc_free_codec(codec);
|
||||
bwc_kill_compression(field);
|
||||
status |= CODESTREAM_ERROR;
|
||||
break;
|
||||
}
|
||||
|
@ -742,14 +777,14 @@ parse_main_header(bwc_codec *const codec, bwc_stream *const data, bitstream *con
|
|||
buff_long = get_symbol(stream, 1);
|
||||
if(CSsgc & (0x01 << 0))
|
||||
{
|
||||
bwc_set_error_resilience(codec);
|
||||
bwc_set_error_resilience(field);
|
||||
}
|
||||
|
||||
buff_long = get_symbol(stream, 1);
|
||||
|
||||
if(CSsgc & (0x01 << 1))
|
||||
{
|
||||
set_quant_style(codec, (bwc_quant_st)buff_long);
|
||||
set_quant_style(field, (bwc_quant_st)buff_long);
|
||||
}
|
||||
|
||||
buff_long = get_symbol(stream, 1);
|
||||
|
@ -765,50 +800,50 @@ parse_main_header(bwc_codec *const codec, bwc_stream *const data, bitstream *con
|
|||
buff_long = get_symbol(stream, 1);
|
||||
if(CSsgc & (0x01 << 3))
|
||||
{
|
||||
set_progression(codec, (uint8)buff_long);
|
||||
set_progression(field, (uint8)buff_long);
|
||||
}
|
||||
|
||||
buff_long = get_symbol(stream, 1);
|
||||
if(CSsgc & (0x01 << 4))
|
||||
{
|
||||
set_kernels(codec, (uint8)(0x03 & (buff_long >> 6)), (uint8)(0x03 & (buff_long >> 4)),
|
||||
set_kernels(field, (uint8)(0x03 & (buff_long >> 6)), (uint8)(0x03 & (buff_long >> 4)),
|
||||
(uint8)(0x03 & (buff_long >> 2)), (uint8)(0x03 & buff_long));
|
||||
}
|
||||
|
||||
buff_long = get_symbol(stream, 4);
|
||||
if(CSsgc & (0x01 << 5))
|
||||
{
|
||||
bwc_set_decomp(codec, (uint8)(0xFF & (buff_long >> 24)), (uint8)(0xFF & (buff_long >> 16)),
|
||||
bwc_set_decomp(field, (uint8)(0xFF & (buff_long >> 24)), (uint8)(0xFF & (buff_long >> 16)),
|
||||
(uint8)(0xFF & (buff_long >> 8)), (uint8)(0xFF & buff_long));
|
||||
}
|
||||
|
||||
buff_long = get_symbol(stream, 2);
|
||||
if(CSsgc & (0x01 << 6))
|
||||
{
|
||||
bwc_set_precincts(codec, (uint8)(0x0F & (buff_long >> 8)), (uint8)(0x0F & (buff_long >> 12)),
|
||||
bwc_set_precincts(field, (uint8)(0x0F & (buff_long >> 8)), (uint8)(0x0F & (buff_long >> 12)),
|
||||
(uint8)(0x0F & buff_long), (uint8)(0x0F & (buff_long >> 4)));
|
||||
}
|
||||
|
||||
buff_long = get_symbol(stream, 4);
|
||||
if(CSsgc & (0x01 << 7))
|
||||
{
|
||||
bwc_set_codeblocks(codec, (uint8)(0xFF & (buff_long >> 24)), (uint8)(0xFF & (buff_long >> 16)),
|
||||
bwc_set_codeblocks(field, (uint8)(0xFF & (buff_long >> 24)), (uint8)(0xFF & (buff_long >> 16)),
|
||||
(uint8)(0xFF & (buff_long >> 8)), (uint8)(0xFF & buff_long));
|
||||
}
|
||||
|
||||
buff_long = get_symbol(stream, 1);
|
||||
if(CSsgc & (0x01 << 8))
|
||||
{
|
||||
bwc_set_qm(codec, (uint8)buff_long);
|
||||
bwc_set_qm(field, (uint8)buff_long);
|
||||
}
|
||||
|
||||
buffX = get_symbol(stream, 8);
|
||||
buffY = get_symbol(stream, 8);
|
||||
buffZ = get_symbol(stream, 8);
|
||||
buffTS = get_symbol(stream, 8);
|
||||
buffTS = get_symbol(stream, 2);
|
||||
if(CSsgc & (0x01 << 9))
|
||||
{
|
||||
bwc_set_tiles(codec, buffX, buffY, buffZ, buffTS, bwc_tile_sizeof);
|
||||
bwc_set_tiles(field, buffX, buffY, buffZ, (uint16)buffTS, bwc_tile_sizeof);
|
||||
}
|
||||
|
||||
control->nLayers = get_symbol(stream, 1);
|
||||
|
@ -817,7 +852,7 @@ parse_main_header(bwc_codec *const codec, bwc_stream *const data, bitstream *con
|
|||
{
|
||||
// memory allocation error
|
||||
fprintf(stderr, MEMERROR);
|
||||
bwc_free_codec(codec);
|
||||
bwc_kill_compression(field);
|
||||
status|= CODESTREAM_ERROR;
|
||||
break;
|
||||
}
|
||||
|
@ -828,10 +863,10 @@ parse_main_header(bwc_codec *const codec, bwc_stream *const data, bitstream *con
|
|||
control->bitrate[l] = *(float *)&bitrate;
|
||||
}
|
||||
|
||||
create_codec(codec);
|
||||
if(!codec)
|
||||
create_field(field);
|
||||
if(!field)
|
||||
{
|
||||
bwc_free_codec(codec);
|
||||
bwc_kill_compression(field);
|
||||
status |= CODESTREAM_ERROR;
|
||||
break;
|
||||
}
|
||||
|
@ -846,7 +881,7 @@ parse_main_header(bwc_codec *const codec, bwc_stream *const data, bitstream *con
|
|||
{
|
||||
// Invalid Codestream
|
||||
fprintf(stderr, CSERROR);
|
||||
bwc_free_codec(codec);
|
||||
bwc_kill_compression(field);
|
||||
status |= CODESTREAM_ERROR;
|
||||
break;
|
||||
}
|
||||
|
@ -856,17 +891,17 @@ parse_main_header(bwc_codec *const codec, bwc_stream *const data, bitstream *con
|
|||
{
|
||||
// Invalid Codestream
|
||||
fprintf(stderr, CSERROR);
|
||||
bwc_free_codec(codec);
|
||||
bwc_kill_compression(field);
|
||||
status |= CODESTREAM_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
data->codestream.aux = calloc(1, sizeof(bwc_span));
|
||||
data->codestream.aux = calloc(1, sizeof(bwc_stream));
|
||||
if(!data->codestream.aux)
|
||||
{
|
||||
// memory allocation error
|
||||
fprintf(stderr, MEMERROR);
|
||||
bwc_free_codec(codec);
|
||||
bwc_kill_compression(field);
|
||||
status |= CODESTREAM_ERROR;
|
||||
break;
|
||||
}
|
||||
|
@ -884,7 +919,7 @@ parse_main_header(bwc_codec *const codec, bwc_stream *const data, bitstream *con
|
|||
{
|
||||
// Invalid Codestream
|
||||
fprintf(stderr, CSERROR);
|
||||
bwc_free_codec(codec);
|
||||
bwc_kill_compression(field);
|
||||
status |= CODESTREAM_ERROR;
|
||||
break;
|
||||
}
|
||||
|
@ -894,17 +929,17 @@ parse_main_header(bwc_codec *const codec, bwc_stream *const data, bitstream *con
|
|||
{
|
||||
// Invalid Codestream
|
||||
fprintf(stderr, CSERROR);
|
||||
bwc_free_codec(codec);
|
||||
bwc_kill_compression(field);
|
||||
status |= CODESTREAM_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
data->codestream.com = calloc(1, sizeof(bwc_span));
|
||||
data->codestream.com = calloc(1, sizeof(bwc_stream));
|
||||
if(!data->codestream.com)
|
||||
{
|
||||
// memory allocation error
|
||||
fprintf(stderr, MEMERROR);
|
||||
bwc_free_codec(codec);
|
||||
bwc_kill_compression(field);
|
||||
status |= CODESTREAM_ERROR;
|
||||
break;
|
||||
}
|
||||
|
@ -924,7 +959,7 @@ parse_main_header(bwc_codec *const codec, bwc_stream *const data, bitstream *con
|
|||
{
|
||||
// Invalid Codestream
|
||||
fprintf(stderr, CSERROR);
|
||||
bwc_free_codec(codec);
|
||||
bwc_kill_compression(field);
|
||||
status |= CODESTREAM_ERROR;
|
||||
break;
|
||||
}
|
||||
|
@ -934,12 +969,12 @@ parse_main_header(bwc_codec *const codec, bwc_stream *const data, bitstream *con
|
|||
{
|
||||
// Invalid Codestream
|
||||
fprintf(stderr, CSERROR);
|
||||
bwc_free_codec(codec);
|
||||
bwc_kill_compression(field);
|
||||
status |= CODESTREAM_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
if(codec_prec == bwc_precision_double)
|
||||
if(codec_prec == 8)
|
||||
{
|
||||
/*--------------------------------------------------------*\
|
||||
! Loop through all tile parameters and... !
|
||||
|
@ -953,14 +988,14 @@ parse_main_header(bwc_codec *const codec, bwc_stream *const data, bitstream *con
|
|||
! header stream. !
|
||||
\*--------------------------------------------------------*/
|
||||
buff_long = get_symbol(stream, sizeof(double));
|
||||
codec->tile[t].parameter[p].info.parameter_min = (bwc_float)*(double*)&buff_long;
|
||||
field->tile[t].parameter[p].info.parameter_min = (bwc_float)*(double*)&buff_long;
|
||||
|
||||
buff_long = get_symbol(stream, sizeof(double));
|
||||
codec->tile[t].parameter[p].info.parameter_max = (bwc_float)*(double*)&buff_long;
|
||||
field->tile[t].parameter[p].info.parameter_max = (bwc_float)*(double*)&buff_long;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(codec_prec == bwc_precision_single)
|
||||
else if(codec_prec == 4)
|
||||
{
|
||||
/*--------------------------------------------------------*\
|
||||
! Loop through all tile parameters and... !
|
||||
|
@ -974,20 +1009,20 @@ parse_main_header(bwc_codec *const codec, bwc_stream *const data, bitstream *con
|
|||
! header stream. !
|
||||
\*--------------------------------------------------------*/
|
||||
buff = get_symbol(stream, sizeof(float));
|
||||
codec->tile[t].parameter[p].info.parameter_min = (bwc_float)*(float*)&buff;
|
||||
field->tile[t].parameter[p].info.parameter_min = (bwc_float)*(float*)&buff;
|
||||
|
||||
buff = get_symbol(stream, sizeof(float));
|
||||
codec->tile[t].parameter[p].info.parameter_max = (bwc_float)*(float*)&buff;
|
||||
field->tile[t].parameter[p].info.parameter_max = (bwc_float)*(float*)&buff;
|
||||
}
|
||||
}
|
||||
}
|
||||
return codec;
|
||||
return field;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Invalid Codestream
|
||||
fprintf(stderr, CSERROR);
|
||||
bwc_free_codec(codec);
|
||||
bwc_kill_compression(field);
|
||||
status |= CODESTREAM_ERROR;
|
||||
}
|
||||
break;
|
||||
|
@ -999,7 +1034,7 @@ parse_main_header(bwc_codec *const codec, bwc_stream *const data, bitstream *con
|
|||
{
|
||||
// Invalid Codestream
|
||||
fprintf(stderr, CSERROR);
|
||||
bwc_free_codec(codec);
|
||||
bwc_kill_compression(field);
|
||||
status |= CODESTREAM_ERROR;
|
||||
break;
|
||||
}
|
||||
|
@ -1009,7 +1044,7 @@ parse_main_header(bwc_codec *const codec, bwc_stream *const data, bitstream *con
|
|||
{
|
||||
// Invalid Codestream
|
||||
fprintf(stderr, CSERROR);
|
||||
bwc_free_codec(codec);
|
||||
bwc_kill_compression(field);
|
||||
status |= CODESTREAM_ERROR;
|
||||
break;
|
||||
}
|
||||
|
@ -1024,7 +1059,7 @@ parse_main_header(bwc_codec *const codec, bwc_stream *const data, bitstream *con
|
|||
}
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! FUNCTION NAME: !
|
||||
! FUNCTION NAME: uchar sequence_packets(bwc_field *const field, bwc_field *const field) !
|
||||
! -------------- !
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
|
@ -1035,11 +1070,16 @@ parse_main_header(bwc_codec *const codec, bwc_stream *const data, bitstream *con
|
|||
! ----------- !
|
||||
! Variable Type Description !
|
||||
! -------- ---- ----------- !
|
||||
! field bwc_field* - Structure defining the compression/ !
|
||||
! decompression stage. !
|
||||
! !
|
||||
! tile bwc_tile* - Structure defining a bwc tile. !
|
||||
! !
|
||||
! RETURN VALUE: !
|
||||
! ------------- !
|
||||
! Type Description !
|
||||
! ---- ----------- !
|
||||
! uchar - Returns an unsigned char for error handling. !
|
||||
! !
|
||||
! DEVELOPMENT HISTORY: !
|
||||
! -------------------- !
|
||||
|
@ -1050,7 +1090,7 @@ parse_main_header(bwc_codec *const codec, bwc_stream *const data, bitstream *con
|
|||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
static uchar
|
||||
parse_tile(bwc_codec *const codec, bitstream *const stream)
|
||||
parse_tile(bwc_field *const field, bitstream *const stream)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE INT VARIABLES: !
|
||||
|
@ -1070,7 +1110,7 @@ parse_tile(bwc_codec *const codec, bitstream *const stream)
|
|||
/*-----------------------*\
|
||||
! DEFINE ASSERTIONS: !
|
||||
\*-----------------------*/
|
||||
assert(codec);
|
||||
assert(field);
|
||||
assert(stream);
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
|
@ -1078,7 +1118,7 @@ parse_tile(bwc_codec *const codec, bitstream *const stream)
|
|||
! sequence structure to temporary variables to make the !
|
||||
! code more readable. !
|
||||
\*--------------------------------------------------------*/
|
||||
control = &codec->control;
|
||||
control = &field->control;
|
||||
|
||||
if(!can_read(stream, 2))
|
||||
{
|
||||
|
@ -1104,7 +1144,7 @@ parse_tile(bwc_codec *const codec, bitstream *const stream)
|
|||
return 1;
|
||||
}
|
||||
|
||||
tile = &codec->tile[buf];
|
||||
tile = &field->tile[buf];
|
||||
tile->control.body_size =
|
||||
body_size = (uint64)get_symbol(stream, 8);
|
||||
|
||||
|
@ -1120,7 +1160,7 @@ parse_tile(bwc_codec *const codec, bitstream *const stream)
|
|||
! Sequence the packets according to the user specified op- !
|
||||
! tion. !
|
||||
\*--------------------------------------------------------*/
|
||||
if(sequence_packets(codec, tile))
|
||||
if(sequence_packets(field, tile))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
@ -1158,7 +1198,7 @@ parse_tile(bwc_codec *const codec, bitstream *const stream)
|
|||
|
||||
packet->header.memory = get_access(stream);
|
||||
|
||||
if(parse_packet(codec, tile, packet, body_size))
|
||||
if(parse_packet(field, tile, packet, body_size))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
@ -1200,7 +1240,7 @@ parse_tile(bwc_codec *const codec, bitstream *const stream)
|
|||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
static uchar
|
||||
parse_body(bwc_codec *const codec, bitstream *const stream)
|
||||
parse_body(bwc_field *const field, bitstream *const stream)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE INT VARIABLES: !
|
||||
|
@ -1216,7 +1256,7 @@ parse_body(bwc_codec *const codec, bitstream *const stream)
|
|||
/*-----------------------*\
|
||||
! DEFINE ASSERTIONS: !
|
||||
\*-----------------------*/
|
||||
assert(codec);
|
||||
assert(field);
|
||||
|
||||
status = CODESTREAM_OK;
|
||||
|
||||
|
@ -1234,7 +1274,7 @@ parse_body(bwc_codec *const codec, bitstream *const stream)
|
|||
{
|
||||
case SOT:
|
||||
{
|
||||
if(parse_tile(codec, stream))
|
||||
if(parse_tile(field, stream))
|
||||
{
|
||||
status |= CODESTREAM_ERROR;
|
||||
}
|
||||
|
@ -1267,7 +1307,7 @@ parse_body(bwc_codec *const codec, bitstream *const stream)
|
|||
{
|
||||
// Invalid Codestream
|
||||
fprintf(stderr, CSERROR);
|
||||
bwc_free_codec(codec);
|
||||
bwc_kill_compression(field);
|
||||
status |= CODESTREAM_ERROR;
|
||||
break;
|
||||
}
|
||||
|
@ -1277,7 +1317,7 @@ parse_body(bwc_codec *const codec, bitstream *const stream)
|
|||
{
|
||||
// Invalid Codestream
|
||||
fprintf(stderr, CSERROR);
|
||||
bwc_free_codec(codec);
|
||||
bwc_kill_compression(field);
|
||||
status |= CODESTREAM_ERROR;
|
||||
break;
|
||||
}
|
||||
|
@ -1296,7 +1336,7 @@ parse_body(bwc_codec *const codec, bitstream *const stream)
|
|||
|| ||
|
||||
\************************************************************************************************************/
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! FUNCTION NAME: bwc_span* assemble_codestream(bwc_codec *const codec, bwc_stream *const data) !
|
||||
! FUNCTION NAME: bwc_stream* assemble_codestream(bwc_field *const field) !
|
||||
! -------------- !
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
|
@ -1307,14 +1347,14 @@ parse_body(bwc_codec *const codec, bitstream *const stream)
|
|||
! ----------- !
|
||||
! Variable Type Description !
|
||||
! -------- ---- ----------- !
|
||||
! codec bwc_codec* - Structure defining the compression/ !
|
||||
! field bwc_field* - Structure defining the compression/ !
|
||||
! decompression stage. !
|
||||
! !
|
||||
! RETURN VALUE: !
|
||||
! ------------- !
|
||||
! Type Description !
|
||||
! ---- ----------- !
|
||||
! bwc_span* - Packed stream containing the compressed data set. !
|
||||
! bwc_stream* - Packed stream containing the compressed data set. !
|
||||
! !
|
||||
! DEVELOPMENT HISTORY: !
|
||||
! -------------------- !
|
||||
|
@ -1324,13 +1364,12 @@ parse_body(bwc_codec *const codec, bitstream *const stream)
|
|||
! 13.06.2019 Patrick Vogler B87D120 V 0.1.0 function created !
|
||||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
size_t
|
||||
assemble_codestream(bwc_codec *const codec, bwc_stream *const data)
|
||||
bwc_stream*
|
||||
assemble_codestream(bwc_field *const field)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE INT VARIABLES: !
|
||||
\*-----------------------*/
|
||||
size_t compressed_size;
|
||||
uint64 i;
|
||||
|
||||
/*-----------------------*\
|
||||
|
@ -1339,12 +1378,12 @@ assemble_codestream(bwc_codec *const codec, bwc_stream *const data)
|
|||
bwc_gl_ctrl *control;
|
||||
bwc_tile *tile;
|
||||
bitstream *stream;
|
||||
bwc_stream *packed_stream;
|
||||
|
||||
/*-----------------------*\
|
||||
! DEFINE ASSERTIONS: !
|
||||
\*-----------------------*/
|
||||
assert(codec);
|
||||
assert(data);
|
||||
assert(field);
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Save the global control and info structure to temporary !
|
||||
|
@ -1352,7 +1391,7 @@ assemble_codestream(bwc_codec *const codec, bwc_stream *const data)
|
|||
! the final codestream size with the number of header !
|
||||
! bytes. !
|
||||
\*--------------------------------------------------------*/
|
||||
control = &codec->control;
|
||||
control = &field->control;
|
||||
|
||||
control->codestreamSize = control->headerSize + 2;
|
||||
|
||||
|
@ -1366,15 +1405,15 @@ assemble_codestream(bwc_codec *const codec, bwc_stream *const data)
|
|||
! Save the tile structure in a temporary variable to make !
|
||||
! the code more readable. !
|
||||
\*--------------------------------------------------------*/
|
||||
tile = &codec->tile[i];
|
||||
tile = &field->tile[i];
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Sequence the packets according to the user specified op- !
|
||||
! tion and iterate the size of the codestream. !
|
||||
\*--------------------------------------------------------*/
|
||||
if(sequence_packets(codec, tile))
|
||||
if(sequence_packets(field, tile))
|
||||
{
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
control->codestreamSize += tile->control.header_size +
|
||||
tile->control.body_size;
|
||||
|
@ -1384,8 +1423,8 @@ assemble_codestream(bwc_codec *const codec, bwc_stream *const data)
|
|||
! Initialize the final codestream and emit the header !
|
||||
! bytes. !
|
||||
\*--------------------------------------------------------*/
|
||||
stream = init_bitstream(data->out, control->codestreamSize, 'c');
|
||||
codestream_write_header(stream, codec, data);
|
||||
stream = init_stream(NULL, control->codestreamSize, 'c');
|
||||
codestream_write_header(stream, field);
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Walk through the tile structure and assemble the packed !
|
||||
|
@ -1398,21 +1437,33 @@ assemble_codestream(bwc_codec *const codec, bwc_stream *const data)
|
|||
! Save the tile structure in a temporary variable to make !
|
||||
! the code more readable. !
|
||||
\*--------------------------------------------------------*/
|
||||
tile = &codec->tile[i];
|
||||
tile = &field->tile[i];
|
||||
|
||||
assemble_tile(codec, tile, stream);
|
||||
assemble_tile(field, tile, stream);
|
||||
}
|
||||
|
||||
emit_symbol(stream, EOC, 2);
|
||||
|
||||
compressed_size = stream->L;
|
||||
free(stream);
|
||||
packed_stream = calloc(1, sizeof(bwc_stream));
|
||||
if(!packed_stream)
|
||||
{
|
||||
// memory allocation error
|
||||
fprintf(stderr, MEMERROR);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return compressed_size;
|
||||
if(terminate_stream(stream, packed_stream))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
return packed_stream;
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! FUNCTION NAME: uchar parse_codestream(bwc_codec *const codec, bitstream *const stream) !
|
||||
! FUNCTION NAME: uchar parse_codestream(bwc_field *const field, bitstream *const stream) !
|
||||
! -------------- !
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
|
@ -1423,7 +1474,7 @@ assemble_codestream(bwc_codec *const codec, bwc_stream *const data)
|
|||
! ----------- !
|
||||
! Variable Type Description !
|
||||
! -------- ---- ----------- !
|
||||
! codec bwc_codec* - Structure defining the compression/ !
|
||||
! field bwc_field* - Structure defining the compression/ !
|
||||
! decompression stage. !
|
||||
! !
|
||||
! stream bitstream* - Structure used to assemble a bwc bit- !
|
||||
|
@ -1443,32 +1494,32 @@ assemble_codestream(bwc_codec *const codec, bwc_stream *const data)
|
|||
! 05.08.2019 Patrick Vogler B87D120 V 0.1.0 function created !
|
||||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
bwc_codec*
|
||||
parse_codestream(bwc_codec *const codec, bwc_stream *const data, uint8 const layer)
|
||||
bwc_field*
|
||||
parse_codestream(bwc_data *const data, uint8 const layer)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE STRUCTS: !
|
||||
\*-----------------------*/
|
||||
bwc_field *field;
|
||||
bitstream *stream;
|
||||
|
||||
/*-----------------------*\
|
||||
! DEFINE ASSERTIONS: !
|
||||
\*-----------------------*/
|
||||
assert(data);
|
||||
assert(codec);
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Initialize a bitstream used to parse the packed code- !
|
||||
! stream. !
|
||||
\*--------------------------------------------------------*/
|
||||
stream = init_bitstream(data->inp, 10, 'd');
|
||||
stream = init_stream(data->codestream.data->memory, 10, 'd');
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Parse the main header and set up the codec structure for !
|
||||
! Parse the main header and set up the field structure for !
|
||||
! the current decompression run. !
|
||||
\*--------------------------------------------------------*/
|
||||
parse_main_header(codec, data, stream);
|
||||
if(!codec)
|
||||
field = parse_main_header(data, stream);
|
||||
if(!field)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1477,36 +1528,36 @@ parse_codestream(bwc_codec *const codec, bwc_stream *const data, uint8 const lay
|
|||
! Initialize the useLayer option to decompress the entire !
|
||||
! codestream. !
|
||||
\*--------------------------------------------------------*/
|
||||
codec->control.useLayer = codec->control.nLayers - 1;
|
||||
field->control.useLayer = field->control.nLayers - 1;
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Check if the layer index supplied by the function caller !
|
||||
! is valid. !
|
||||
\*--------------------------------------------------------*/
|
||||
if(layer < codec->control.nLayers && layer > 0)
|
||||
if(layer < field->control.nLayers && layer > 0)
|
||||
{
|
||||
/*--------------------------------------------------------*\
|
||||
! Amend the use layer variable in the global control struc-!
|
||||
! ture. !
|
||||
\*--------------------------------------------------------*/
|
||||
codec->control.useLayer = layer;
|
||||
field->control.useLayer = layer;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Parse the rest of the compressed codestream and load the !
|
||||
! body into the codec structure. !
|
||||
! body into the field structure. !
|
||||
\*--------------------------------------------------------*/
|
||||
if(parse_body(codec, stream))
|
||||
if(parse_body(field, stream))
|
||||
{
|
||||
bwc_free_codec(codec);
|
||||
bwc_kill_compression(field);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Free the bitstream used to parse the codestream and re- !
|
||||
! turn the codec structure to the function caller. !
|
||||
! turn the field structure to the function caller. !
|
||||
\*--------------------------------------------------------*/
|
||||
free(stream);
|
||||
|
||||
return codec;
|
||||
}
|
||||
return field;
|
||||
}
|
|
@ -1421,7 +1421,7 @@ initialize_gain_lut()
|
|||
}
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! FUNCTION NAME: bwc_float get_dwt_energy_gain(bwc_codec *const codec, uchar highband_flag, uint16 level) !
|
||||
! FUNCTION NAME: bwc_float get_dwt_energy_gain(bwc_field *const field, uchar highband_flag, uint16 level) !
|
||||
! -------------- !
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
|
@ -1434,7 +1434,7 @@ initialize_gain_lut()
|
|||
! ----------- !
|
||||
! Variable Type Description !
|
||||
! -------- ---- ----------- !
|
||||
! codec bwc_codec* - Structure defining the compression/ !
|
||||
! field bwc_field* - Structure defining the compression/ !
|
||||
! decompression stage. !
|
||||
! !
|
||||
! highband_flag uchar - Defines the subband for which Gb is !
|
||||
|
@ -1459,7 +1459,7 @@ initialize_gain_lut()
|
|||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
bwc_float
|
||||
get_dwt_energy_gain(bwc_codec *const codec, uchar highband_flag, uint16 level)
|
||||
get_dwt_energy_gain(bwc_field *const field, uchar highband_flag, uint16 level)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE INT VARIABLES: !
|
||||
|
@ -1480,15 +1480,15 @@ get_dwt_energy_gain(bwc_codec *const codec, uchar highband_flag, uint16 level)
|
|||
/*-----------------------*\
|
||||
! DEFINE ASSERTIONS: !
|
||||
\*-----------------------*/
|
||||
assert(codec);
|
||||
assert(level <= codec->control.nDecomp + 1);
|
||||
assert(field);
|
||||
assert(level <= field->control.nDecomp + 1);
|
||||
assert(highband_flag <= DIM_ALL);
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Save the global control structure to a temporary varia- !
|
||||
! ble to make the code more readable. !
|
||||
\*--------------------------------------------------------*/
|
||||
control = &codec->control;
|
||||
control = &field->control;
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Evaluate the number of decompositions in each temporal & !
|
||||
|
@ -1576,7 +1576,7 @@ get_dwt_energy_gain(bwc_codec *const codec, uchar highband_flag, uint16 level)
|
|||
}
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! FUNCTION NAME: uchar forward_discrete_wavelet_transform(bwc_codec *const codec, !
|
||||
! FUNCTION NAME: uchar forward_discrete_wavelet_transform(bwc_field *const field, !
|
||||
! -------------- bwc_parameter *const parameter) !
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
|
@ -1594,7 +1594,7 @@ get_dwt_energy_gain(bwc_codec *const codec, uchar highband_flag, uint16 level)
|
|||
! ----------- !
|
||||
! Variable Type Description !
|
||||
! -------- ---- ----------- !
|
||||
! codec bwc_codec* - Structure defining the compression/ !
|
||||
! field bwc_field* - Structure defining the compression/ !
|
||||
! decompression stage. !
|
||||
! !
|
||||
! parameter bwc_parameter* - Structure defining a bwc parameter. !
|
||||
|
@ -1614,22 +1614,28 @@ get_dwt_energy_gain(bwc_codec *const codec, uchar highband_flag, uint16 level)
|
|||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
uchar
|
||||
forward_wavelet_transform(bwc_codec *const codec, bwc_parameter *const parameter)
|
||||
forward_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE INT VARIABLES: !
|
||||
\*-----------------------*/
|
||||
uint64 incr_X, incr_Y, incr_Z, incr_TS;
|
||||
uint64 rX0, rY0, rZ0, rTS0;
|
||||
uint64 rX1, rY1, rZ1, rTS1;
|
||||
uint64 width, height, depth, dt;
|
||||
uint64 x, y, z, t;
|
||||
uint64 incr_X, incr_Y, incr_Z;
|
||||
uint64 rX0, rY0, rZ0;
|
||||
uint64 rX1, rY1, rZ1;
|
||||
uint64 width, height, depth;
|
||||
uint64 x, y, z;
|
||||
|
||||
int64 nThreads;
|
||||
int16 i;
|
||||
|
||||
uint32 buff_size;
|
||||
|
||||
uint16 incr_TS;
|
||||
uint16 rTS0;
|
||||
uint16 rTS1;
|
||||
uint16 dt;
|
||||
uint16 t;
|
||||
|
||||
uint8 id;
|
||||
uint8 filter_tapsX, filter_tapsY, filter_tapsZ;
|
||||
uint8 filter_tapsTS;
|
||||
|
@ -1646,7 +1652,7 @@ forward_wavelet_transform(bwc_codec *const codec, bwc_parameter *const parameter
|
|||
/*-----------------------*\
|
||||
! DEFINE ASSERTIONS: !
|
||||
\*-----------------------*/
|
||||
assert(codec);
|
||||
assert(field);
|
||||
assert(parameter);
|
||||
|
||||
/*-----------------------*\
|
||||
|
@ -1664,7 +1670,7 @@ forward_wavelet_transform(bwc_codec *const codec, bwc_parameter *const parameter
|
|||
! Save the global control and parameter info structure to !
|
||||
! temporary variables to make the code more readable. !
|
||||
\*--------------------------------------------------------*/
|
||||
control = &codec->control;
|
||||
control = &field->control;
|
||||
param_info = ¶meter->info;
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
|
@ -1771,8 +1777,8 @@ forward_wavelet_transform(bwc_codec *const codec, bwc_parameter *const parameter
|
|||
rY1 = (uint64)parameter->resolution[control->nDecomp - level].info.Y1;
|
||||
rZ0 = (uint64)parameter->resolution[control->nDecomp - level].info.Z0;
|
||||
rZ1 = (uint64)parameter->resolution[control->nDecomp - level].info.Z1;
|
||||
rTS0 = (uint64)parameter->resolution[control->nDecomp - level].info.TS0;
|
||||
rTS1 = (uint64)parameter->resolution[control->nDecomp - level].info.TS1;
|
||||
rTS0 = (uint16)parameter->resolution[control->nDecomp - level].info.TS0;
|
||||
rTS1 = (uint16)parameter->resolution[control->nDecomp - level].info.TS1;
|
||||
|
||||
if(level < control->decompX && (rX1 - rX0) > 1)
|
||||
{
|
||||
|
@ -2111,7 +2117,7 @@ forward_wavelet_transform(bwc_codec *const codec, bwc_parameter *const parameter
|
|||
}
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! FUNCTION NAME: uchar inverse_discrete_wavelet_transform(bwc_codec *const codec, !
|
||||
! FUNCTION NAME: uchar inverse_discrete_wavelet_transform(bwc_field *const field, !
|
||||
! -------------- bwc_parameter *const parameter) !
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
|
@ -2129,7 +2135,7 @@ forward_wavelet_transform(bwc_codec *const codec, bwc_parameter *const parameter
|
|||
! ----------- !
|
||||
! Variable Type Description !
|
||||
! -------- ---- ----------- !
|
||||
! codec bwc_codec* - Structure defining the compression/ !
|
||||
! field bwc_field* - Structure defining the compression/ !
|
||||
! decompression stage. !
|
||||
! !
|
||||
! parameter bwc_parameter* - Structure defining a bwc parameter. !
|
||||
|
@ -2149,22 +2155,28 @@ forward_wavelet_transform(bwc_codec *const codec, bwc_parameter *const parameter
|
|||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
uchar
|
||||
inverse_wavelet_transform(bwc_codec *const codec, bwc_parameter *const parameter)
|
||||
inverse_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE INT VARIABLES: !
|
||||
\*-----------------------*/
|
||||
uint64 incr_X, incr_Y, incr_Z, incr_TS;
|
||||
uint64 rX0, rY0, rZ0, rTS0;
|
||||
uint64 rX1, rY1, rZ1, rTS1;
|
||||
uint64 width, height, depth, dt;
|
||||
uint64 x, y, z, t;
|
||||
uint64 incr_X, incr_Y, incr_Z;
|
||||
uint64 rX0, rY0, rZ0;
|
||||
uint64 rX1, rY1, rZ1;
|
||||
uint64 width, height, depth;
|
||||
uint64 x, y, z;
|
||||
|
||||
int64 nThreads;
|
||||
int64 i;
|
||||
|
||||
uint32 buff_size;
|
||||
|
||||
uint16 incr_TS;
|
||||
uint16 rTS0;
|
||||
uint16 rTS1;
|
||||
uint16 dt;
|
||||
uint16 t;
|
||||
|
||||
uint8 id;
|
||||
uint8 filter_tapsX, filter_tapsY, filter_tapsZ;
|
||||
uint8 filter_tapsTS;
|
||||
|
@ -2181,7 +2193,7 @@ inverse_wavelet_transform(bwc_codec *const codec, bwc_parameter *const parameter
|
|||
/*-----------------------*\
|
||||
! DEFINE ASSERTIONS: !
|
||||
\*-----------------------*/
|
||||
assert(codec);
|
||||
assert(field);
|
||||
assert(parameter);
|
||||
|
||||
/*-----------------------*\
|
||||
|
@ -2199,7 +2211,7 @@ inverse_wavelet_transform(bwc_codec *const codec, bwc_parameter *const parameter
|
|||
! Save the global control and parameter info structure to !
|
||||
! temporary variables to make the code more readable. !
|
||||
\*--------------------------------------------------------*/
|
||||
control = &codec->control;
|
||||
control = &field->control;
|
||||
param_info = ¶meter->info;
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
|
@ -2306,8 +2318,8 @@ inverse_wavelet_transform(bwc_codec *const codec, bwc_parameter *const parameter
|
|||
rY1 = (uint64)parameter->resolution[control->nDecomp - level].info.Y1;
|
||||
rZ0 = (uint64)parameter->resolution[control->nDecomp - level].info.Z0;
|
||||
rZ1 = (uint64)parameter->resolution[control->nDecomp - level].info.Z1;
|
||||
rTS0 = (uint64)parameter->resolution[control->nDecomp - level].info.TS0;
|
||||
rTS1 = (uint64)parameter->resolution[control->nDecomp - level].info.TS1;
|
||||
rTS0 = (uint16)parameter->resolution[control->nDecomp - level].info.TS0;
|
||||
rTS1 = (uint16)parameter->resolution[control->nDecomp - level].info.TS1;
|
||||
|
||||
if(level < control->decompTS && (rTS1 - rTS0) > 1)
|
||||
{
|
||||
|
|
1072
src/library/libbwc.c
1072
src/library/libbwc.c
File diff suppressed because it is too large
Load diff
|
@ -16,7 +16,7 @@
|
|||
|| ------------ ||
|
||||
|| ||
|
||||
|| This file describes a set of functions that can be used to de-/encode bwc ||
|
||||
|| codeblocks described by the bwc_codec structure according to the embedded block ||
|
||||
|| codeblocks described by the bwc_field structure according to the embedded block ||
|
||||
|| coding paradigm described by the JPEG 2000 standard. For more information please ||
|
||||
|| refere to JPEG2000 by D. S. Taubman and M. W. Marcellin. ||
|
||||
|| ||
|
||||
|
@ -99,76 +99,6 @@
|
|||
mq_bit_encode(bitcoder, 0, CONTEXT_UNI); \
|
||||
}
|
||||
|
||||
#define calc_k_sig(stripe, bit_mask, k, l, k_h, k_v, k_d, k_sig) \
|
||||
{ \
|
||||
k_h = (stripe[k].stripe_l->sigma & bit_mask) + (stripe[k].stripe_r->sigma & bit_mask); \
|
||||
k_v = ((bit_mask & (stripe[k].sigma >> 1)) + (bit_mask & (stripe[k].sigma << 1))); \
|
||||
k_d = ((bit_mask & (stripe[k].stripe_l->sigma >> 1)) + (bit_mask & (stripe[k].stripe_l->sigma << 1)) + \
|
||||
(bit_mask & (stripe[k].stripe_r->sigma >> 1)) + (bit_mask & (stripe[k].stripe_r->sigma << 1))); \
|
||||
if(l == 3) \
|
||||
{ \
|
||||
k_v += ((0x01 & stripe[k].stripe_u->sigma) << 3); \
|
||||
k_d += ((0x01 & stripe[k].stripe_u->stripe_l->sigma) + \
|
||||
(0x01 & stripe[k].stripe_u->stripe_r->sigma)) << 3; \
|
||||
} \
|
||||
else if(l == 0) \
|
||||
{ \
|
||||
k_v += ((0x08 & stripe[k].stripe_d->sigma) >> 3); \
|
||||
k_d += ((0x08 & stripe[k].stripe_d->stripe_l->sigma) + \
|
||||
(0x08 & stripe[k].stripe_d->stripe_r->sigma)) >> 3; \
|
||||
} \
|
||||
k_sig = ((15 * k_h + 5 * k_v + k_d) >> l); \
|
||||
}
|
||||
|
||||
#define calc_xi(stripe, bit_mask, k, l, xi_h, xi_v, SIG2XI) \
|
||||
{ \
|
||||
xi_h = ((bit_mask & stripe[k].stripe_l->sigma) | ((bit_mask & stripe[k].stripe_l->xi) << 2) | \
|
||||
((bit_mask & stripe[k].stripe_r->sigma) << 1) | ((bit_mask & stripe[k].stripe_r->xi) << 3)) >> l; \
|
||||
xi_v = ((bit_mask & (stripe[k].sigma >> 1)) | ((bit_mask & (stripe[k].xi >> 1)) << 2) | \
|
||||
((bit_mask & (stripe[k].sigma << 1)) << 1) | ((bit_mask & (stripe[k].xi << 1)) << 3)) >> l; \
|
||||
if(l == 3) \
|
||||
{ \
|
||||
xi_v |= ((0x01 & stripe[k].stripe_u->sigma) | ((0x01 & stripe[k].stripe_u->xi) << 2)); \
|
||||
} \
|
||||
else if(l == 0) \
|
||||
{ \
|
||||
xi_v |= (((0x08 & stripe[k].stripe_d->sigma) >> 2) | (0x08 & stripe[k].stripe_d->xi)); \
|
||||
} \
|
||||
xi_h = SIG2XI[xi_h]; \
|
||||
xi_v = SIG2XI[xi_v]; \
|
||||
}
|
||||
|
||||
#define calc_k_mag(stripe, bit_mask, k, l, k_mag) \
|
||||
{ \
|
||||
k_mag = CONTEXT_MAG; \
|
||||
if(stripe[k].delta & bit_mask) \
|
||||
{ \
|
||||
k_mag += 2; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
if((bit_mask & (stripe[k].sigma >> 1)) || (bit_mask & (stripe[k].sigma << 1)) || \
|
||||
(stripe[k].stripe_l->sigma & bit_mask) || (stripe[k].stripe_r->sigma & bit_mask) || \
|
||||
(bit_mask & (stripe[k].stripe_l->sigma >> 1)) || (bit_mask & (stripe[k].stripe_l->sigma << 1)) || \
|
||||
(bit_mask & (stripe[k].stripe_r->sigma >> 1)) || (bit_mask & (stripe[k].stripe_r->sigma << 1))) \
|
||||
{ \
|
||||
k_mag += 1; \
|
||||
} \
|
||||
else if((l == 3) && ((0x08 & (stripe[k].stripe_u->sigma << 3)) \
|
||||
|| (0x08 & (stripe[k].stripe_u->stripe_l->sigma << 3)) \
|
||||
|| (0x08 & (stripe[k].stripe_u->stripe_r->sigma << 3)))) \
|
||||
{ \
|
||||
k_mag += 1; \
|
||||
} \
|
||||
else if((l == 0) && ((0x01 & (stripe[k].stripe_d->sigma >> 3)) \
|
||||
|| (0x01 & (stripe[k].stripe_d->stripe_l->sigma >> 3)) \
|
||||
|| (0x01 & (stripe[k].stripe_d->stripe_r->sigma >> 3)))) \
|
||||
{ \
|
||||
k_mag += 1; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
/************************************************************************************************************\
|
||||
|| ____ _ _ ___ ____ ____ _ _ ____ _ ____ ____ _ _ ____ ___ ____ _ _ ___ ____ ||
|
||||
|| |___ \/ | |___ |__/ |\ | |__| | | | | |\ | [__ | |__| |\ | | [__ ||
|
||||
|
@ -468,8 +398,9 @@ cblkreset_inv(bwc_coder_stripe *const cblk, const uint64 width, const uint64 hei
|
|||
uint64 i;
|
||||
uint64 limit;
|
||||
uint64 cblk_stripe;
|
||||
uint64 x, y, z, t;
|
||||
uint64 x, y, z;
|
||||
int64 idx_u, idx_r, idx_d, idx_l;
|
||||
uint16 t;
|
||||
uint8 s;
|
||||
|
||||
/*-----------------------*\
|
||||
|
@ -602,12 +533,15 @@ cblkcopy_forward(bwc_coder_stripe *const destination, bwc_sample *const source,
|
|||
\*-----------------------*/
|
||||
bwc_raw buff, sign_mask;
|
||||
uint64 bit_mask, limit;
|
||||
uint64 cblk_width, cblk_height, cblk_depth, cblk_dt, cblk_stripe;
|
||||
uint64 cblk_width, cblk_height, cblk_depth, cblk_stripe;
|
||||
uint64 incrX, incrY, incrZ;
|
||||
uint64 i, x, y, z, t;
|
||||
uint64 X0, Y0, Z0, TS0;
|
||||
uint64 X1, Y1, Z1, TS1;
|
||||
uint64 i, x, y, z;
|
||||
uint64 X0, Y0, Z0;
|
||||
uint64 X1, Y1, Z1;
|
||||
int64 idx_u, idx_r, idx_d, idx_l;
|
||||
uint16 TS0, TS1;
|
||||
uint16 cblk_dt;
|
||||
uint16 t;
|
||||
uint8 b, Kmax, s;
|
||||
|
||||
/*-----------------------*\
|
||||
|
@ -841,12 +775,15 @@ cblkcopy_inverse(bwc_coder_stripe *const source, bwc_sample *const destinat
|
|||
/*-----------------------*\
|
||||
! DEFINE INT VARIABLES: !
|
||||
\*-----------------------*/
|
||||
uint64 cblk_width, cblk_height, cblk_depth, cblk_dt, cblk_stripe;
|
||||
uint64 cblk_width, cblk_height, cblk_depth, cblk_stripe;
|
||||
uint64 bit_shift, buff, limit;
|
||||
uint64 incrX, incrY, incrZ;
|
||||
uint64 i, x, y, z, t;
|
||||
uint64 X0, Y0, Z0, TS0;
|
||||
uint64 X1, Y1, Z1, TS1;
|
||||
uint64 i, x, y, z;
|
||||
uint64 X0, Y0, Z0;
|
||||
uint64 X1, Y1, Z1;
|
||||
uint16 TS0, TS1;
|
||||
uint16 cblk_dt;
|
||||
uint16 t;
|
||||
uint8 bitplane;
|
||||
uint8 codingpass;
|
||||
uint8 s;
|
||||
|
@ -1074,7 +1011,27 @@ significance_propagation_enc_pass(bwc_coder *const coder, const int8 b)
|
|||
{
|
||||
if(!(stripe[k].sigma & bit_mask))
|
||||
{
|
||||
calc_k_sig(stripe, bit_mask, k, l, k_h, k_v, k_d, k_sig);
|
||||
k_h = (stripe[k].stripe_l->sigma & bit_mask) + (stripe[k].stripe_r->sigma & bit_mask);
|
||||
|
||||
k_v = ((bit_mask & (stripe[k].sigma >> 1)) + (bit_mask & (stripe[k].sigma << 1)));
|
||||
|
||||
k_d = ((bit_mask & (stripe[k].stripe_l->sigma >> 1)) + (bit_mask & (stripe[k].stripe_l->sigma << 1)) +
|
||||
(bit_mask & (stripe[k].stripe_r->sigma >> 1)) + (bit_mask & (stripe[k].stripe_r->sigma << 1)));
|
||||
|
||||
if(l == 3)
|
||||
{
|
||||
k_v += ((0x01 & stripe[k].stripe_u->sigma) << 3);
|
||||
k_d += ((0x01 & stripe[k].stripe_u->stripe_l->sigma) +
|
||||
(0x01 & stripe[k].stripe_u->stripe_r->sigma)) << 3;
|
||||
}
|
||||
else if(l == 0)
|
||||
{
|
||||
k_v += ((0x08 & stripe[k].stripe_d->sigma) >> 3);
|
||||
k_d += ((0x08 & stripe[k].stripe_d->stripe_l->sigma) +
|
||||
(0x08 & stripe[k].stripe_d->stripe_r->sigma)) >> 3;
|
||||
}
|
||||
|
||||
k_sig = ((15 * k_h + 5 * k_v + k_d) >> l);
|
||||
|
||||
if(k_sig)
|
||||
{
|
||||
|
@ -1082,7 +1039,24 @@ significance_propagation_enc_pass(bwc_coder *const coder, const int8 b)
|
|||
|
||||
if(bit & bit_mask)
|
||||
{
|
||||
calc_xi(stripe, bit_mask, k, l, xi_h, xi_v, SIG2XI);
|
||||
xi_h = ((bit_mask & stripe[k].stripe_l->sigma) | ((bit_mask & stripe[k].stripe_l->xi) << 2) |
|
||||
((bit_mask & stripe[k].stripe_r->sigma) << 1) | ((bit_mask & stripe[k].stripe_r->xi) << 3)) >> l;
|
||||
|
||||
xi_v = ((bit_mask & (stripe[k].sigma >> 1)) | ((bit_mask & (stripe[k].xi >> 1)) << 2) |
|
||||
((bit_mask & (stripe[k].sigma << 1)) << 1) | ((bit_mask & (stripe[k].xi << 1)) << 3)) >> l;
|
||||
|
||||
if(l == 3)
|
||||
{
|
||||
xi_v |= ((0x01 & stripe[k].stripe_u->sigma) | ((0x01 & stripe[k].stripe_u->xi) << 2));
|
||||
}
|
||||
else if(l == 0)
|
||||
{
|
||||
xi_v |= (((0x08 & stripe[k].stripe_d->sigma) >> 2) | (0x08 & stripe[k].stripe_d->xi));
|
||||
}
|
||||
|
||||
xi_h = SIG2XI[xi_h];
|
||||
xi_v = SIG2XI[xi_v];
|
||||
|
||||
mq_bit_encode(coder->bitcoder, (uchar)(((bit_mask & stripe[k].xi) >> l)^XI2CONT[(xi_h << 2) | xi_v][1]),
|
||||
XI2CONT[(xi_h << 2) | xi_v][0]);
|
||||
|
||||
|
@ -1116,7 +1090,21 @@ significance_propagation_enc_pass(bwc_coder *const coder, const int8 b)
|
|||
{
|
||||
if(!(stripe[k].sigma & bit_mask))
|
||||
{
|
||||
calc_k_sig(stripe, bit_mask, k, l, k_h, k_v, k_d, k_sig);
|
||||
k_h = (stripe[k].stripe_l->sigma & bit_mask) + (stripe[k].stripe_r->sigma & bit_mask);
|
||||
|
||||
k_v = ((bit_mask & (stripe[k].sigma >> 1)) + (bit_mask & (stripe[k].sigma << 1)));
|
||||
|
||||
k_d = ((bit_mask & (stripe[k].stripe_l->sigma >> 1)) + (bit_mask & (stripe[k].stripe_l->sigma << 1)) +
|
||||
(bit_mask & (stripe[k].stripe_r->sigma >> 1)) + (bit_mask & (stripe[k].stripe_r->sigma << 1)));
|
||||
|
||||
if(l == 3)
|
||||
{
|
||||
k_v += ((0x01 & stripe[k].stripe_u->sigma) << 3);
|
||||
k_d += ((0x01 & stripe[k].stripe_u->stripe_l->sigma) +
|
||||
(0x01 & stripe[k].stripe_u->stripe_r->sigma)) << 3;
|
||||
}
|
||||
|
||||
k_sig = ((15 * k_h + 5 * k_v + k_d) >> l);
|
||||
|
||||
if(k_sig && (stripe[k].sigma^bit_mask))
|
||||
{
|
||||
|
@ -1124,7 +1112,20 @@ significance_propagation_enc_pass(bwc_coder *const coder, const int8 b)
|
|||
|
||||
if(bit & bit_mask)
|
||||
{
|
||||
calc_xi(stripe, bit_mask, k, l, xi_h, xi_v, SIG2XI);
|
||||
xi_h = ((bit_mask & stripe[k].stripe_l->sigma) | ((bit_mask & stripe[k].stripe_l->xi) << 2) |
|
||||
((bit_mask & stripe[k].stripe_r->sigma) << 1) | ((bit_mask & stripe[k].stripe_r->xi) << 3)) >> l;
|
||||
|
||||
xi_v = ((bit_mask & (stripe[k].sigma >> 1)) | ((bit_mask & (stripe[k].xi >> 1)) << 2) |
|
||||
((bit_mask & (stripe[k].sigma << 1)) << 1) | ((bit_mask & (stripe[k].xi << 1)) << 3)) >> l;
|
||||
|
||||
if(l == 3)
|
||||
{
|
||||
xi_v |= ((0x01 & stripe[k].stripe_u->sigma) | ((0x01 & stripe[k].stripe_u->xi) << 2));
|
||||
}
|
||||
|
||||
xi_h = SIG2XI[xi_h];
|
||||
xi_v = SIG2XI[xi_v];
|
||||
|
||||
mq_bit_encode(coder->bitcoder, (uchar)(((bit_mask & stripe[k].xi) >> l)^XI2CONT[(xi_h << 2) | xi_v][1]),
|
||||
XI2CONT[(xi_h << 2) | xi_v][0]);
|
||||
|
||||
|
@ -1223,7 +1224,34 @@ magnitude_refinement_enc_pass(bwc_coder *const coder, const int8 b)
|
|||
{
|
||||
if(sig & bit_mask)
|
||||
{
|
||||
calc_k_mag(stripe, bit_mask, k, l, k_mag);
|
||||
k_mag = CONTEXT_MAG;
|
||||
|
||||
if(stripe[k].delta & bit_mask)
|
||||
{
|
||||
k_mag += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if((bit_mask & (stripe[k].sigma >> 1)) || (bit_mask & (stripe[k].sigma << 1)) ||
|
||||
(stripe[k].stripe_l->sigma & bit_mask) || (stripe[k].stripe_r->sigma & bit_mask) ||
|
||||
(bit_mask & (stripe[k].stripe_l->sigma >> 1)) || (bit_mask & (stripe[k].stripe_l->sigma << 1)) ||
|
||||
(bit_mask & (stripe[k].stripe_r->sigma >> 1)) || (bit_mask & (stripe[k].stripe_r->sigma << 1)))
|
||||
{
|
||||
k_mag += 1;
|
||||
}
|
||||
else if((l == 3) && ((0x08 & (stripe[k].stripe_u->sigma << 3))
|
||||
|| (0x08 & (stripe[k].stripe_u->stripe_l->sigma << 3))
|
||||
|| (0x08 & (stripe[k].stripe_u->stripe_r->sigma << 3))))
|
||||
{
|
||||
k_mag += 1;
|
||||
}
|
||||
else if((l == 0) && ((0x01 & (stripe[k].stripe_d->sigma >> 3))
|
||||
|| (0x01 & (stripe[k].stripe_d->stripe_l->sigma >> 3))
|
||||
|| (0x01 & (stripe[k].stripe_d->stripe_r->sigma >> 3))))
|
||||
{
|
||||
k_mag += 1;
|
||||
}
|
||||
}
|
||||
|
||||
mq_bit_encode(coder->bitcoder, (uchar)((bit >> l) & 0x01), k_mag);
|
||||
|
||||
|
@ -1244,7 +1272,28 @@ magnitude_refinement_enc_pass(bwc_coder *const coder, const int8 b)
|
|||
{
|
||||
if(sig & bit_mask)
|
||||
{
|
||||
calc_k_mag(stripe, bit_mask, k, l, k_mag);
|
||||
k_mag = CONTEXT_MAG;
|
||||
|
||||
if(stripe[k].delta & bit_mask)
|
||||
{
|
||||
k_mag += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if((bit_mask & (stripe[k].sigma >> 1)) || (bit_mask & (stripe[k].sigma << 1)) ||
|
||||
(stripe[k].stripe_l->sigma & bit_mask) || (stripe[k].stripe_r->sigma & bit_mask) ||
|
||||
(bit_mask & (stripe[k].stripe_l->sigma >> 1)) || (bit_mask & (stripe[k].stripe_l->sigma << 1)) ||
|
||||
(bit_mask & (stripe[k].stripe_r->sigma >> 1)) || (bit_mask & (stripe[k].stripe_r->sigma << 1)))
|
||||
{
|
||||
k_mag += 1;
|
||||
}
|
||||
else if((l == 3) && ((0x08 & (stripe[k].stripe_u->sigma << 3))
|
||||
|| (0x08 & (stripe[k].stripe_u->stripe_l->sigma << 3))
|
||||
|| (0x08 & (stripe[k].stripe_u->stripe_r->sigma << 3))))
|
||||
{
|
||||
k_mag += 1;
|
||||
}
|
||||
}
|
||||
|
||||
mq_bit_encode(coder->bitcoder, (uchar)((bit >> l) & 0x01), k_mag);
|
||||
|
||||
|
@ -1296,7 +1345,6 @@ cleanup_enc_pass(bwc_coder *const coder, const int8 b)
|
|||
uint64 k, x;
|
||||
int64 mse;
|
||||
uint16 k_h, k_v, k_d;
|
||||
uint16 k_sig;
|
||||
uint16 xi_h, xi_v;
|
||||
uint8 bit_mask, l;
|
||||
uint8 dist_shift, dist_corr;
|
||||
|
@ -1362,12 +1410,48 @@ cleanup_enc_pass(bwc_coder *const coder, const int8 b)
|
|||
}
|
||||
else
|
||||
{
|
||||
calc_k_sig(stripe, bit_mask, k, l, k_h, k_v, k_d, k_sig);
|
||||
mq_bit_encode(coder->bitcoder, (uchar)((bit >> l) & 0x01), coder->sig2context[k_sig]);
|
||||
k_h = (stripe[k].stripe_l->sigma & bit_mask) + (stripe[k].stripe_r->sigma & bit_mask);
|
||||
|
||||
k_v = ((bit_mask & (stripe[k].sigma >> 1)) + (bit_mask & (stripe[k].sigma << 1)));
|
||||
|
||||
k_d = ((bit_mask & (stripe[k].stripe_l->sigma >> 1)) + (bit_mask & (stripe[k].stripe_l->sigma << 1)) +
|
||||
(bit_mask & (stripe[k].stripe_r->sigma >> 1)) + (bit_mask & (stripe[k].stripe_r->sigma << 1)));
|
||||
|
||||
if(l == 3)
|
||||
{
|
||||
k_v += ((0x01 & stripe[k].stripe_u->sigma) << 3);
|
||||
k_d += ((0x01 & stripe[k].stripe_u->stripe_l->sigma) +
|
||||
(0x01 & stripe[k].stripe_u->stripe_r->sigma)) << 3;
|
||||
}
|
||||
else if(l == 0)
|
||||
{
|
||||
k_v += ((0x08 & stripe[k].stripe_d->sigma) >> 3);
|
||||
k_d += ((0x08 & stripe[k].stripe_d->stripe_l->sigma) +
|
||||
(0x08 & stripe[k].stripe_d->stripe_r->sigma)) >> 3;
|
||||
}
|
||||
|
||||
mq_bit_encode(coder->bitcoder, (uchar)((bit >> l) & 0x01), coder->sig2context[(15 * k_h + 5 * k_v + k_d) >> l]);
|
||||
}
|
||||
if(bit & bit_mask)
|
||||
{
|
||||
calc_xi(stripe, bit_mask, k, l, xi_h, xi_v, SIG2XI);
|
||||
xi_h = ((bit_mask & stripe[k].stripe_l->sigma) | ((bit_mask & stripe[k].stripe_l->xi) << 2) |
|
||||
((bit_mask & stripe[k].stripe_r->sigma) << 1) | ((bit_mask & stripe[k].stripe_r->xi) << 3)) >> l;
|
||||
|
||||
xi_v = ((bit_mask & (stripe[k].sigma >> 1)) | ((bit_mask & (stripe[k].xi >> 1)) << 2) |
|
||||
((bit_mask & (stripe[k].sigma << 1)) << 1) | ((bit_mask & (stripe[k].xi << 1)) << 3)) >> l;
|
||||
|
||||
if(l == 3)
|
||||
{
|
||||
xi_v |= ((0x01 & stripe[k].stripe_u->sigma) | ((0x01 & stripe[k].stripe_u->xi) << 2));
|
||||
}
|
||||
else if(l == 0)
|
||||
{
|
||||
xi_v |= (((0x08 & stripe[k].stripe_d->sigma) >> 2) | (0x08 & stripe[k].stripe_d->xi));
|
||||
}
|
||||
|
||||
xi_h = SIG2XI[xi_h];
|
||||
xi_v = SIG2XI[xi_v];
|
||||
|
||||
mq_bit_encode(coder->bitcoder, (uchar)(((bit_mask & stripe[k].xi) >> l)^XI2CONT[(xi_h << 2) | xi_v][1]),
|
||||
XI2CONT[(xi_h << 2) | xi_v][0]);
|
||||
|
||||
|
@ -1387,12 +1471,38 @@ cleanup_enc_pass(bwc_coder *const coder, const int8 b)
|
|||
{
|
||||
if(!(stripe[k].sigma & bit_mask) && !(stripe[k].pi & bit_mask))
|
||||
{
|
||||
calc_k_sig(stripe, bit_mask, k, l, k_h, k_v, k_d, k_sig);
|
||||
mq_bit_encode(coder->bitcoder, (uchar)((bit >> l) & 0x01), coder->sig2context[k_sig]);
|
||||
k_h = (stripe[k].stripe_l->sigma & bit_mask) + (stripe[k].stripe_r->sigma & bit_mask);
|
||||
|
||||
k_v = ((bit_mask & (stripe[k].sigma >> 1)) + (bit_mask & (stripe[k].sigma << 1)));
|
||||
|
||||
k_d = ((bit_mask & (stripe[k].stripe_l->sigma >> 1)) + (bit_mask & (stripe[k].stripe_l->sigma << 1)) +
|
||||
(bit_mask & (stripe[k].stripe_r->sigma >> 1)) + (bit_mask & (stripe[k].stripe_r->sigma << 1)));
|
||||
|
||||
if(l == 3)
|
||||
{
|
||||
k_v += ((0x01 & stripe[k].stripe_u->sigma) << 3);
|
||||
k_d += ((0x01 & stripe[k].stripe_u->stripe_l->sigma) +
|
||||
(0x01 & stripe[k].stripe_u->stripe_r->sigma)) << 3;
|
||||
}
|
||||
|
||||
mq_bit_encode(coder->bitcoder, (uchar)((bit >> l) & 0x01), coder->sig2context[(15 * k_h + 5 * k_v + k_d) >> l]);
|
||||
|
||||
if(bit & bit_mask)
|
||||
{
|
||||
calc_xi(stripe, bit_mask, k, l, xi_h, xi_v, SIG2XI);
|
||||
xi_h = ((bit_mask & stripe[k].stripe_l->sigma) | ((bit_mask & stripe[k].stripe_l->xi) << 2) |
|
||||
((bit_mask & stripe[k].stripe_r->sigma) << 1) | ((bit_mask & stripe[k].stripe_r->xi) << 3)) >> l;
|
||||
|
||||
xi_v = ((bit_mask & (stripe[k].sigma >> 1)) | ((bit_mask & (stripe[k].xi >> 1)) << 2) |
|
||||
((bit_mask & (stripe[k].sigma << 1)) << 1) | ((bit_mask & (stripe[k].xi << 1)) << 3)) >> l;
|
||||
|
||||
if(l == 3)
|
||||
{
|
||||
xi_v |= ((0x01 & stripe[k].stripe_u->sigma) | ((0x01 & stripe[k].stripe_u->xi) << 2));
|
||||
}
|
||||
|
||||
xi_h = SIG2XI[xi_h];
|
||||
xi_v = SIG2XI[xi_v];
|
||||
|
||||
mq_bit_encode(coder->bitcoder, (uchar)(((bit_mask & stripe[k].xi) >> l)^XI2CONT[(xi_h << 2) | xi_v][1]),
|
||||
XI2CONT[(xi_h << 2) | xi_v][0]);
|
||||
|
||||
|
@ -1478,7 +1588,27 @@ significance_propagation_dec_pass(bwc_coder *const coder, const int8 b)
|
|||
{
|
||||
if(!(stripe[k].sigma & bit_mask))
|
||||
{
|
||||
calc_k_sig(stripe, bit_mask, k, l, k_h, k_v, k_d, k_sig);
|
||||
k_h = (stripe[k].stripe_l->sigma & bit_mask) + (stripe[k].stripe_r->sigma & bit_mask);
|
||||
|
||||
k_v = ((bit_mask & (stripe[k].sigma >> 1)) + (bit_mask & (stripe[k].sigma << 1)));
|
||||
|
||||
k_d = ((bit_mask & (stripe[k].stripe_l->sigma >> 1)) + (bit_mask & (stripe[k].stripe_l->sigma << 1)) +
|
||||
(bit_mask & (stripe[k].stripe_r->sigma >> 1)) + (bit_mask & (stripe[k].stripe_r->sigma << 1)));
|
||||
|
||||
if(l == 3)
|
||||
{
|
||||
k_v += ((0x01 & stripe[k].stripe_u->sigma) << 3);
|
||||
k_d += ((0x01 & stripe[k].stripe_u->stripe_l->sigma) +
|
||||
(0x01 & stripe[k].stripe_u->stripe_r->sigma)) << 3;
|
||||
}
|
||||
else if(l == 0)
|
||||
{
|
||||
k_v += ((0x08 & stripe[k].stripe_d->sigma) >> 3);
|
||||
k_d += ((0x08 & stripe[k].stripe_d->stripe_l->sigma) +
|
||||
(0x08 & stripe[k].stripe_d->stripe_r->sigma)) >> 3;
|
||||
}
|
||||
|
||||
k_sig = ((15 * k_h + 5 * k_v + k_d) >> l);
|
||||
|
||||
if(k_sig)
|
||||
{
|
||||
|
@ -1488,7 +1618,23 @@ significance_propagation_dec_pass(bwc_coder *const coder, const int8 b)
|
|||
{
|
||||
stripe[k].bit[b] |= (bit << l);
|
||||
|
||||
calc_xi(stripe, bit_mask, k, l, xi_h, xi_v, SIG2XI);
|
||||
xi_h = ((bit_mask & stripe[k].stripe_l->sigma) | ((bit_mask & stripe[k].stripe_l->xi) << 2) |
|
||||
((bit_mask & stripe[k].stripe_r->sigma) << 1) | ((bit_mask & stripe[k].stripe_r->xi) << 3)) >> l;
|
||||
|
||||
xi_v = ((bit_mask & (stripe[k].sigma >> 1)) | ((bit_mask & (stripe[k].xi >> 1)) << 2) |
|
||||
((bit_mask & (stripe[k].sigma << 1)) << 1) | ((bit_mask & (stripe[k].xi << 1)) << 3)) >> l;
|
||||
|
||||
if(l == 3)
|
||||
{
|
||||
xi_v |= ((0x01 & stripe[k].stripe_u->sigma) | ((0x01 & stripe[k].stripe_u->xi) << 2));
|
||||
}
|
||||
else if(l == 0)
|
||||
{
|
||||
xi_v |= (((0x08 & stripe[k].stripe_d->sigma) >> 2) | (0x08 & stripe[k].stripe_d->xi));
|
||||
}
|
||||
|
||||
xi_h = SIG2XI[xi_h];
|
||||
xi_v = SIG2XI[xi_v];
|
||||
|
||||
stripe[k].xi |= ((XI2CONT[(xi_h << 2) | xi_v][1] ^ mq_bit_decode(coder->bitcoder, XI2CONT[(xi_h << 2) | xi_v][0])) << l);
|
||||
|
||||
|
@ -1521,7 +1667,21 @@ significance_propagation_dec_pass(bwc_coder *const coder, const int8 b)
|
|||
{
|
||||
if(!(stripe[k].sigma & bit_mask))
|
||||
{
|
||||
calc_k_sig(stripe, bit_mask, k, l, k_h, k_v, k_d, k_sig);
|
||||
k_h = (stripe[k].stripe_l->sigma & bit_mask) + (stripe[k].stripe_r->sigma & bit_mask);
|
||||
|
||||
k_v = ((bit_mask & (stripe[k].sigma >> 1)) + (bit_mask & (stripe[k].sigma << 1)));
|
||||
|
||||
k_d = ((bit_mask & (stripe[k].stripe_l->sigma >> 1)) + (bit_mask & (stripe[k].stripe_l->sigma << 1)) +
|
||||
(bit_mask & (stripe[k].stripe_r->sigma >> 1)) + (bit_mask & (stripe[k].stripe_r->sigma << 1)));
|
||||
|
||||
if(l == 3)
|
||||
{
|
||||
k_v += ((0x01 & stripe[k].stripe_u->sigma) << 3);
|
||||
k_d += ((0x01 & stripe[k].stripe_u->stripe_l->sigma) +
|
||||
(0x01 & stripe[k].stripe_u->stripe_r->sigma)) << 3;
|
||||
}
|
||||
|
||||
k_sig = ((15 * k_h + 5 * k_v + k_d) >> l);
|
||||
|
||||
if(k_sig && (stripe[k].sigma^bit_mask))
|
||||
{
|
||||
|
@ -1531,7 +1691,19 @@ significance_propagation_dec_pass(bwc_coder *const coder, const int8 b)
|
|||
{
|
||||
stripe[k].bit[b] |= (bit << l);
|
||||
|
||||
calc_xi(stripe, bit_mask, k, l, xi_h, xi_v, SIG2XI);
|
||||
xi_h = ((bit_mask & stripe[k].stripe_l->sigma) | ((bit_mask & stripe[k].stripe_l->xi) << 2) |
|
||||
((bit_mask & stripe[k].stripe_r->sigma) << 1) | ((bit_mask & stripe[k].stripe_r->xi) << 3)) >> l;
|
||||
|
||||
xi_v = ((bit_mask & (stripe[k].sigma >> 1)) | ((bit_mask & (stripe[k].xi >> 1)) << 2) |
|
||||
((bit_mask & (stripe[k].sigma << 1)) << 1) | ((bit_mask & (stripe[k].xi << 1)) << 3)) >> l;
|
||||
|
||||
if(l == 3)
|
||||
{
|
||||
xi_v |= ((0x01 & stripe[k].stripe_u->sigma) | ((0x01 & stripe[k].stripe_u->xi) << 2));
|
||||
}
|
||||
|
||||
xi_h = SIG2XI[xi_h];
|
||||
xi_v = SIG2XI[xi_v];
|
||||
|
||||
stripe[k].xi |= ((XI2CONT[(xi_h << 2) | xi_v][1] ^ mq_bit_decode(coder->bitcoder, XI2CONT[(xi_h << 2) | xi_v][0])) << l);
|
||||
|
||||
|
@ -1624,7 +1796,34 @@ magnitude_refinement_dec_pass(bwc_coder *const coder, const int8 b)
|
|||
{
|
||||
if(sig & bit_mask)
|
||||
{
|
||||
calc_k_mag(stripe, bit_mask, k, l, k_mag);
|
||||
k_mag = CONTEXT_MAG;
|
||||
|
||||
if(stripe[k].delta & bit_mask)
|
||||
{
|
||||
k_mag += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if((bit_mask & (stripe[k].sigma >> 1)) || (bit_mask & (stripe[k].sigma << 1)) ||
|
||||
(stripe[k].stripe_l->sigma & bit_mask) || (stripe[k].stripe_r->sigma & bit_mask) ||
|
||||
(bit_mask & (stripe[k].stripe_l->sigma >> 1)) || (bit_mask & (stripe[k].stripe_l->sigma << 1)) ||
|
||||
(bit_mask & (stripe[k].stripe_r->sigma >> 1)) || (bit_mask & (stripe[k].stripe_r->sigma << 1)))
|
||||
{
|
||||
k_mag += 1;
|
||||
}
|
||||
else if((l == 3) && ((0x08 & (stripe[k].stripe_u->sigma << 3))
|
||||
|| (0x08 & (stripe[k].stripe_u->stripe_l->sigma << 3))
|
||||
|| (0x08 & (stripe[k].stripe_u->stripe_r->sigma << 3))))
|
||||
{
|
||||
k_mag += 1;
|
||||
}
|
||||
else if((l == 0) && ((0x01 & (stripe[k].stripe_d->sigma >> 3))
|
||||
|| (0x01 & (stripe[k].stripe_d->stripe_l->sigma >> 3))
|
||||
|| (0x01 & (stripe[k].stripe_d->stripe_r->sigma >> 3))))
|
||||
{
|
||||
k_mag += 1;
|
||||
}
|
||||
}
|
||||
|
||||
stripe[k].bit[b] |= (mq_bit_decode(coder->bitcoder, k_mag) << l);
|
||||
|
||||
|
@ -1644,7 +1843,28 @@ magnitude_refinement_dec_pass(bwc_coder *const coder, const int8 b)
|
|||
{
|
||||
if(sig & bit_mask)
|
||||
{
|
||||
calc_k_mag(stripe, bit_mask, k, l, k_mag);
|
||||
k_mag = CONTEXT_MAG;
|
||||
|
||||
if(stripe[k].delta & bit_mask)
|
||||
{
|
||||
k_mag += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if((bit_mask & (stripe[k].sigma >> 1)) || (bit_mask & (stripe[k].sigma << 1)) ||
|
||||
(stripe[k].stripe_l->sigma & bit_mask) || (stripe[k].stripe_r->sigma & bit_mask) ||
|
||||
(bit_mask & (stripe[k].stripe_l->sigma >> 1)) || (bit_mask & (stripe[k].stripe_l->sigma << 1)) ||
|
||||
(bit_mask & (stripe[k].stripe_r->sigma >> 1)) || (bit_mask & (stripe[k].stripe_r->sigma << 1)))
|
||||
{
|
||||
k_mag += 1;
|
||||
}
|
||||
else if((l == 3) && ((0x08 & (stripe[k].stripe_u->sigma << 3))
|
||||
|| (0x08 & (stripe[k].stripe_u->stripe_l->sigma << 3))
|
||||
|| (0x08 & (stripe[k].stripe_u->stripe_r->sigma << 3))))
|
||||
{
|
||||
k_mag += 1;
|
||||
}
|
||||
}
|
||||
|
||||
stripe[k].bit[b] |= (mq_bit_decode(coder->bitcoder, k_mag) << l);
|
||||
|
||||
|
@ -1693,7 +1913,6 @@ cleanup_dec_pass(bwc_coder *const coder, const int8 b)
|
|||
uint64 i, j;
|
||||
uint64 k, x;
|
||||
uint16 k_h, k_v, k_d;
|
||||
uint16 k_sig;
|
||||
uint16 xi_h, xi_v;
|
||||
uint8 bit_mask, l;
|
||||
uint8 bit;
|
||||
|
@ -1750,12 +1969,47 @@ cleanup_dec_pass(bwc_coder *const coder, const int8 b)
|
|||
}
|
||||
else
|
||||
{
|
||||
calc_k_sig(stripe, bit_mask, k, l, k_h, k_v, k_d, k_sig);
|
||||
bit |= (mq_bit_decode(coder->bitcoder, coder->sig2context[k_sig]) << l);
|
||||
k_h = (stripe[k].stripe_l->sigma & bit_mask) + (stripe[k].stripe_r->sigma & bit_mask);
|
||||
|
||||
k_v = ((bit_mask & (stripe[k].sigma >> 1)) + (bit_mask & (stripe[k].sigma << 1)));
|
||||
|
||||
k_d = ((bit_mask & (stripe[k].stripe_l->sigma >> 1)) + (bit_mask & (stripe[k].stripe_l->sigma << 1)) +
|
||||
(bit_mask & (stripe[k].stripe_r->sigma >> 1)) + (bit_mask & (stripe[k].stripe_r->sigma << 1)));
|
||||
|
||||
if(l == 3)
|
||||
{
|
||||
k_v += ((0x01 & stripe[k].stripe_u->sigma) << 3);
|
||||
k_d += ((0x01 & stripe[k].stripe_u->stripe_l->sigma) +
|
||||
(0x01 & stripe[k].stripe_u->stripe_r->sigma)) << 3;
|
||||
}
|
||||
else if(l == 0)
|
||||
{
|
||||
k_v += ((0x08 & stripe[k].stripe_d->sigma) >> 3);
|
||||
k_d += ((0x08 & stripe[k].stripe_d->stripe_l->sigma) +
|
||||
(0x08 & stripe[k].stripe_d->stripe_r->sigma)) >> 3;
|
||||
}
|
||||
|
||||
bit |= (mq_bit_decode(coder->bitcoder, coder->sig2context[(15 * k_h + 5 * k_v + k_d) >> l]) << l);
|
||||
}
|
||||
if(bit & bit_mask)
|
||||
{
|
||||
calc_xi(stripe, bit_mask, k, l, xi_h, xi_v, SIG2XI);
|
||||
xi_h = ((bit_mask & stripe[k].stripe_l->sigma) | ((bit_mask & stripe[k].stripe_l->xi) << 2) |
|
||||
((bit_mask & stripe[k].stripe_r->sigma) << 1) | ((bit_mask & stripe[k].stripe_r->xi) << 3)) >> l;
|
||||
|
||||
xi_v = ((bit_mask & (stripe[k].sigma >> 1)) | ((bit_mask & (stripe[k].xi >> 1)) << 2) |
|
||||
((bit_mask & (stripe[k].sigma << 1)) << 1) | ((bit_mask & (stripe[k].xi << 1)) << 3)) >> l;
|
||||
|
||||
if(l == 3)
|
||||
{
|
||||
xi_v |= ((0x01 & stripe[k].stripe_u->sigma) | ((0x01 & stripe[k].stripe_u->xi) << 2));
|
||||
}
|
||||
else if(l == 0)
|
||||
{
|
||||
xi_v |= (((0x08 & stripe[k].stripe_d->sigma) >> 2) | (0x08 & stripe[k].stripe_d->xi));
|
||||
}
|
||||
|
||||
xi_h = SIG2XI[xi_h];
|
||||
xi_v = SIG2XI[xi_v];
|
||||
|
||||
stripe[k].xi |= ((XI2CONT[(xi_h << 2) | xi_v][1] ^ mq_bit_decode(coder->bitcoder, XI2CONT[(xi_h << 2) | xi_v][0])) << l);
|
||||
|
||||
|
@ -1777,12 +2031,37 @@ cleanup_dec_pass(bwc_coder *const coder, const int8 b)
|
|||
{
|
||||
if(!(stripe[k].sigma & bit_mask) && !(stripe[k].pi & bit_mask))
|
||||
{
|
||||
calc_k_sig(stripe, bit_mask, k, l, k_h, k_v, k_d, k_sig);
|
||||
bit |= (mq_bit_decode(coder->bitcoder, coder->sig2context[k_sig]) << l);
|
||||
k_h = (stripe[k].stripe_l->sigma & bit_mask) + (stripe[k].stripe_r->sigma & bit_mask);
|
||||
|
||||
k_v = ((bit_mask & (stripe[k].sigma >> 1)) + (bit_mask & (stripe[k].sigma << 1)));
|
||||
|
||||
k_d = ((bit_mask & (stripe[k].stripe_l->sigma >> 1)) + (bit_mask & (stripe[k].stripe_l->sigma << 1)) +
|
||||
(bit_mask & (stripe[k].stripe_r->sigma >> 1)) + (bit_mask & (stripe[k].stripe_r->sigma << 1)));
|
||||
|
||||
if(l == 3)
|
||||
{
|
||||
k_v += ((0x01 & stripe[k].stripe_u->sigma) << 3);
|
||||
k_d += ((0x01 & stripe[k].stripe_u->stripe_l->sigma) +
|
||||
(0x01 & stripe[k].stripe_u->stripe_r->sigma)) << 3;
|
||||
}
|
||||
|
||||
bit |= (mq_bit_decode(coder->bitcoder, coder->sig2context[(15 * k_h + 5 * k_v + k_d) >> l]) << l);
|
||||
|
||||
if(bit & bit_mask)
|
||||
{
|
||||
calc_xi(stripe, bit_mask, k, l, xi_h, xi_v, SIG2XI);
|
||||
xi_h = ((bit_mask & stripe[k].stripe_l->sigma) | ((bit_mask & stripe[k].stripe_l->xi) << 2) |
|
||||
((bit_mask & stripe[k].stripe_r->sigma) << 1) | ((bit_mask & stripe[k].stripe_r->xi) << 3)) >> l;
|
||||
|
||||
xi_v = ((bit_mask & (stripe[k].sigma >> 1)) | ((bit_mask & (stripe[k].xi >> 1)) << 2) |
|
||||
((bit_mask & (stripe[k].sigma << 1)) << 1) | ((bit_mask & (stripe[k].xi << 1)) << 3)) >> l;
|
||||
|
||||
if(l == 3)
|
||||
{
|
||||
xi_v |= ((0x01 & stripe[k].stripe_u->sigma) | ((0x01 & stripe[k].stripe_u->xi) << 2));
|
||||
}
|
||||
|
||||
xi_h = SIG2XI[xi_h];
|
||||
xi_v = SIG2XI[xi_v];
|
||||
|
||||
stripe[k].xi |= ((XI2CONT[(xi_h << 2) | xi_v][1] ^ mq_bit_decode(coder->bitcoder, XI2CONT[(xi_h << 2) | xi_v][0])) << l);
|
||||
|
||||
|
@ -1995,12 +2274,12 @@ compute_convex_hull(bwc_encoded_cblk *const encoded_codeblock, double *const mse
|
|||
}
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! FUNCTION NAME: void encode_codeblock(bwc_codec *const codec, bwc_cblk_access *const access, !
|
||||
! FUNCTION NAME: bwc_encoded_cblk* encode_codeblock(bwc_field *const field, bwc_cblk_access *const access, !
|
||||
! -------------- bwc_coder_stripe *const codeblock, !
|
||||
! const uint64 width, !
|
||||
! const uint64 height, !
|
||||
! const uint64 depth, !
|
||||
! const uint64 dt) !
|
||||
! const uint16 dt) !
|
||||
! !
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
|
@ -2028,12 +2307,12 @@ compute_convex_hull(bwc_encoded_cblk *const encoded_codeblock, double *const mse
|
|||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
static void
|
||||
encode_codeblock(bwc_codec *const codec, bwc_cblk_access *const access,
|
||||
encode_codeblock(bwc_field *const field, bwc_cblk_access *const access,
|
||||
bwc_coder_stripe *const codeblock,
|
||||
const uint64 width,
|
||||
const uint64 height,
|
||||
const uint64 depth,
|
||||
const uint64 dt)
|
||||
const uint16 dt)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE INT VARIABLES: !
|
||||
|
@ -2061,7 +2340,7 @@ encode_codeblock(bwc_codec *const codec, bwc_cblk_access *const access,
|
|||
/*-----------------------*\
|
||||
! DEFINE ASSERTIONS: !
|
||||
\*-----------------------*/
|
||||
assert(codec);
|
||||
assert(field);
|
||||
assert(access);
|
||||
assert(codeblock);
|
||||
assert(access->subband->control.highband_flag <= 15);
|
||||
|
@ -2080,7 +2359,7 @@ encode_codeblock(bwc_codec *const codec, bwc_cblk_access *const access,
|
|||
! info and encoded block structure to temporary variables !
|
||||
! to make the code more readable. !
|
||||
\*--------------------------------------------------------*/
|
||||
control = &codec->control;
|
||||
control = &field->control;
|
||||
|
||||
subb_ctrl = &access->subband->control;
|
||||
subb_inf = &access->subband->info;
|
||||
|
@ -2316,12 +2595,12 @@ encode_codeblock(bwc_codec *const codec, bwc_cblk_access *const access,
|
|||
}
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! FUNCTION NAME: void decode_codeblock(bwc_codec *const codec, bwc_cblk_access *const access, !
|
||||
! FUNCTION NAME: bwc_encoded_cblk* encode_codeblock(bwc_field *const field, bwc_cblk_access *const access, !
|
||||
! bwc_coder_stripe *const codeblock, !
|
||||
! const uint64 width, !
|
||||
! const uint64 height, !
|
||||
! const uint64 depth, !
|
||||
! const uint64 dt) !
|
||||
! const uint16 dt) !
|
||||
! -------------- !
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
|
@ -2349,12 +2628,12 @@ encode_codeblock(bwc_codec *const codec, bwc_cblk_access *const access,
|
|||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
static void
|
||||
decode_codeblock(bwc_codec *const codec, bwc_cblk_access *const access,
|
||||
decode_codeblock(bwc_field *const field, bwc_cblk_access *const access,
|
||||
bwc_coder_stripe *const codeblock,
|
||||
const uint64 width,
|
||||
const uint64 height,
|
||||
const uint64 depth,
|
||||
const uint64 dt)
|
||||
const uint16 dt)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE INT VARIABLES: !
|
||||
|
@ -2373,7 +2652,7 @@ decode_codeblock(bwc_codec *const codec, bwc_cblk_access *const access,
|
|||
/*-----------------------*\
|
||||
! DEFINE ASSERTIONS: !
|
||||
\*-----------------------*/
|
||||
assert(codec);
|
||||
assert(field);
|
||||
assert(access);
|
||||
assert(codeblock);
|
||||
assert(access->subband->control.highband_flag <= 15);
|
||||
|
@ -2392,7 +2671,7 @@ decode_codeblock(bwc_codec *const codec, bwc_cblk_access *const access,
|
|||
! structure to temporary variables to make the code more !
|
||||
! readable. !
|
||||
\*--------------------------------------------------------*/
|
||||
control = &codec->control;
|
||||
control = &field->control;
|
||||
|
||||
subb_ctrl = &access->subband->control;
|
||||
|
||||
|
@ -2549,19 +2828,20 @@ decode_codeblock(bwc_codec *const codec, bwc_cblk_access *const access,
|
|||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
uchar
|
||||
t1_encode(bwc_codec *const codec, bwc_tile *const tile, bwc_parameter *const parameter)
|
||||
t1_encode(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const parameter)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE INT VARIABLES: !
|
||||
\*-----------------------*/
|
||||
uint64 c;
|
||||
uint64 cbSizeX, cbSizeY, cbSizeZ, cbSizeTS;
|
||||
uint64 cbSizeX, cbSizeY, cbSizeZ;
|
||||
uint64 width, height, depth;
|
||||
|
||||
int64 buff_size;
|
||||
int64 i, j;
|
||||
int64 nThreads;
|
||||
|
||||
uint16 cbSizeTS;
|
||||
uint16 slope_max, slope_min;
|
||||
int16 z;
|
||||
|
||||
|
@ -2577,7 +2857,7 @@ t1_encode(bwc_codec *const codec, bwc_tile *const tile, bwc_parameter *const par
|
|||
/*-----------------------*\
|
||||
! DEFINE ASSERTIONS: !
|
||||
\*-----------------------*/
|
||||
assert(codec);
|
||||
assert(field);
|
||||
assert(tile);
|
||||
assert(parameter);
|
||||
|
||||
|
@ -2585,7 +2865,7 @@ t1_encode(bwc_codec *const codec, bwc_tile *const tile, bwc_parameter *const par
|
|||
! Save the global control structure to a temporary varia- !
|
||||
! ble to make the code more readable. !
|
||||
\*--------------------------------------------------------*/
|
||||
control = &codec->control;
|
||||
control = &field->control;
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Save the minimum and maximum slope values for the cur- !
|
||||
|
@ -2760,7 +3040,7 @@ t1_encode(bwc_codec *const codec, bwc_tile *const tile, bwc_parameter *const par
|
|||
! truncation points (L) and possible slope values (S) in !
|
||||
! the bwc_encoded_cblk structure. !
|
||||
\*--------------------------------------------------------*/
|
||||
encode_codeblock(codec, ¶meter->access[c], working_buffer,
|
||||
encode_codeblock(field, ¶meter->access[c], working_buffer,
|
||||
cbSizeX, cbSizeY,
|
||||
cbSizeZ, cbSizeTS);
|
||||
|
||||
|
@ -2851,19 +3131,21 @@ t1_encode(bwc_codec *const codec, bwc_tile *const tile, bwc_parameter *const par
|
|||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
uchar
|
||||
t1_decode(bwc_codec *const codec, bwc_tile *const tile, bwc_parameter *const parameter)
|
||||
t1_decode(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const parameter)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE INT VARIABLES: !
|
||||
\*-----------------------*/
|
||||
uint64 c;
|
||||
uint64 cbSizeX, cbSizeY, cbSizeZ, cbSizeTS;
|
||||
uint64 cbSizeX, cbSizeY, cbSizeZ;
|
||||
uint64 width, height, depth;
|
||||
|
||||
int64 buff_size;
|
||||
int64 i, j;
|
||||
int64 nThreads;
|
||||
|
||||
uint16 cbSizeTS;
|
||||
|
||||
/*-----------------------*\
|
||||
! DEFINE STRUCTS: !
|
||||
\*-----------------------*/
|
||||
|
@ -2877,7 +3159,7 @@ t1_decode(bwc_codec *const codec, bwc_tile *const tile, bwc_parameter *const par
|
|||
/*-----------------------*\
|
||||
! DEFINE ASSERTIONS: !
|
||||
\*-----------------------*/
|
||||
assert(codec);
|
||||
assert(field);
|
||||
assert(tile);
|
||||
assert(parameter);
|
||||
|
||||
|
@ -2885,7 +3167,7 @@ t1_decode(bwc_codec *const codec, bwc_tile *const tile, bwc_parameter *const par
|
|||
! Save the global control structure to a temporary varia- !
|
||||
! ble to make the code more readable. !
|
||||
\*--------------------------------------------------------*/
|
||||
control = &codec->control;
|
||||
control = &field->control;
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Evaluate the width, height and depth of the current !
|
||||
|
@ -3050,7 +3332,7 @@ t1_decode(bwc_codec *const codec, bwc_tile *const tile, bwc_parameter *const par
|
|||
|
||||
if(codeblock->encoded_block->Z > 0)
|
||||
{
|
||||
decode_codeblock(codec, ¶meter->access[c], working_buffer,
|
||||
decode_codeblock(field, ¶meter->access[c], working_buffer,
|
||||
cbSizeX, cbSizeY,
|
||||
cbSizeZ, cbSizeTS);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|| ------------ ||
|
||||
|| ||
|
||||
|| This file describes a set of functions that can be used to de-/encode bwc ||
|
||||
|| codeblocks described by the bwc_codec structure according to the embedded block ||
|
||||
|| codeblocks described by the bwc_field structure according to the embedded block ||
|
||||
|| coding paradigm described by the JPEG 2000 standard. For more information please ||
|
||||
|| refere to JPEG2000 by D. S. Taubman and M. W. Marcellin. ||
|
||||
|| ||
|
||||
|
@ -312,7 +312,7 @@ encode_length(bitstream *const header, bwc_codeblock *const codeblock,
|
|||
}
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! FUNCTION NAME: !
|
||||
! FUNCTION NAME: void create_quality_layers(bwc_field *const field, bwc_tile *const tile) !
|
||||
! -------------- !
|
||||
! !
|
||||
! !
|
||||
|
@ -385,10 +385,11 @@ decode_length(bitstream *const header, bwc_codeblock *const codeblock, int8 cons
|
|||
}
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! FUNCTION NAME: int64 create_packet(bwc_tile *const tile, bwc_resolution *const resolution, !
|
||||
! -------------- uint32 const prec_idx, !
|
||||
! int8 const q_layer, !
|
||||
! uchar const est) !
|
||||
! FUNCTION NAME: int64 create_packet(bwc_field *const field, bwc_tile *const tile, !
|
||||
! -------------- bwc_resolution *const resolution, !
|
||||
! uint32 const prec_idx, !
|
||||
! int8 const q_layer, !
|
||||
! uchar const est) !
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
! ------------ !
|
||||
|
@ -402,6 +403,9 @@ decode_length(bitstream *const header, bwc_codeblock *const codeblock, int8 cons
|
|||
! ----------- !
|
||||
! Variable Type Description !
|
||||
! -------- ---- ----------- !
|
||||
! field bwc_field* - Structure defining the compression/ !
|
||||
! decompression stage. !
|
||||
! !
|
||||
! tile bwc_tile* - Structure defining a bwc tile. !
|
||||
! !
|
||||
! resolution bwc_resolution* - Structure defining a bwc resolution !
|
||||
|
@ -431,10 +435,11 @@ decode_length(bitstream *const header, bwc_codeblock *const codeblock, int8 cons
|
|||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
static int32
|
||||
create_packet(bwc_tile *const tile, bwc_resolution *const resolution,
|
||||
uint32 const prec_idx,
|
||||
int16 const q_layer,
|
||||
uchar const est)
|
||||
create_packet(bwc_field *const field, bwc_tile *const tile,
|
||||
bwc_resolution *const resolution,
|
||||
uint32 const prec_idx,
|
||||
int16 const q_layer,
|
||||
uchar const est)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE INT VARIABLES: !
|
||||
|
@ -445,7 +450,6 @@ create_packet(bwc_tile *const tile, bwc_resolution *const resolution,
|
|||
int16 *cp_contr;
|
||||
int16 delta_z;
|
||||
int8 m;
|
||||
uchar *memory;
|
||||
|
||||
/*-----------------------*\
|
||||
! DEFINE STRUCTS: !
|
||||
|
@ -458,6 +462,7 @@ create_packet(bwc_tile *const tile, bwc_resolution *const resolution,
|
|||
/*-----------------------*\
|
||||
! DEFINE ASSERTIONS: !
|
||||
\*-----------------------*/
|
||||
assert(field);
|
||||
assert(tile);
|
||||
assert(resolution);
|
||||
|
||||
|
@ -477,14 +482,7 @@ create_packet(bwc_tile *const tile, bwc_resolution *const resolution,
|
|||
! Initialize the stream that is used to assemble the pack- !
|
||||
! et header. !
|
||||
\*--------------------------------------------------------*/
|
||||
memory = calloc(PACKET_HEADER_SIZE, sizeof(uchar));
|
||||
if(!memory)
|
||||
{
|
||||
// memory allocation error
|
||||
fprintf(stderr, MEMERROR);
|
||||
return -1;
|
||||
}
|
||||
header = init_bitstream(memory, PACKET_HEADER_SIZE, 'c');
|
||||
header = init_stream(NULL, PACKET_HEADER_SIZE, 'c');
|
||||
if(!header)
|
||||
{
|
||||
// memory allocation error
|
||||
|
@ -500,7 +498,7 @@ create_packet(bwc_tile *const tile, bwc_resolution *const resolution,
|
|||
if(!est)
|
||||
{
|
||||
packet->body.access =
|
||||
packet->body.memory = calloc(packet->body.size, sizeof(bwc_span));
|
||||
packet->body.memory = calloc(packet->body.size, sizeof(bwc_stream));
|
||||
if(!packet->body.memory)
|
||||
{
|
||||
// memory allocation error
|
||||
|
@ -646,8 +644,7 @@ create_packet(bwc_tile *const tile, bwc_resolution *const resolution,
|
|||
}
|
||||
|
||||
k = header->L;
|
||||
free(header->memory);
|
||||
free(header);
|
||||
terminate_stream(header, NULL);
|
||||
return k;
|
||||
}
|
||||
/*--------------------------------------------------------*\
|
||||
|
@ -658,13 +655,11 @@ create_packet(bwc_tile *const tile, bwc_resolution *const resolution,
|
|||
\*--------------------------------------------------------*/
|
||||
else
|
||||
{
|
||||
if(shrink_to_fit(header))
|
||||
if(terminate_stream(header, &packet->header))
|
||||
{
|
||||
// memory allocation error
|
||||
return -1;
|
||||
}
|
||||
transfer_to_span(header, &packet->header);
|
||||
free(header);
|
||||
|
||||
packet->size = packet->body.size + packet->header.size;
|
||||
|
||||
|
@ -711,7 +706,7 @@ create_packet(bwc_tile *const tile, bwc_resolution *const resolution,
|
|||
}
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! FUNCTION NAME: uchar create_packets(bwc_codec *const codec, bwc_tile *const tile) !
|
||||
! FUNCTION NAME: uchar create_packets(bwc_field *const field, bwc_tile *const tile) !
|
||||
! -------------- !
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
|
@ -728,7 +723,7 @@ create_packet(bwc_tile *const tile, bwc_resolution *const resolution,
|
|||
! ----------- !
|
||||
! Variable Type Description !
|
||||
! -------- ---- ----------- !
|
||||
! codec bwc_codec* - Structure defining the compression/ !
|
||||
! field bwc_field* - Structure defining the compression/ !
|
||||
! decompression stage. !
|
||||
! !
|
||||
! tile bwc_tile* - Structure defining a bwc tile. !
|
||||
|
@ -748,7 +743,7 @@ create_packet(bwc_tile *const tile, bwc_resolution *const resolution,
|
|||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
static uchar
|
||||
create_packets(bwc_codec *const codec, bwc_tile *const tile)
|
||||
create_packets(bwc_field *const field, bwc_tile *const tile)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE INT VARIABLES: !
|
||||
|
@ -769,15 +764,15 @@ create_packets(bwc_codec *const codec, bwc_tile *const tile)
|
|||
/*-----------------------*\
|
||||
! DEFINE ASSERTIONS: !
|
||||
\*-----------------------*/
|
||||
assert(codec);
|
||||
assert(field);
|
||||
assert(tile);
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Save the global control and info structure to temporary !
|
||||
! variables to make the code more readable. !
|
||||
\*--------------------------------------------------------*/
|
||||
control = &codec->control;
|
||||
info = &codec->info;
|
||||
control = &field->control;
|
||||
info = field->info;
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Iterate overall quality layers for every precinct in all !
|
||||
|
@ -804,7 +799,7 @@ create_packets(bwc_codec *const codec, bwc_tile *const tile)
|
|||
{
|
||||
for(l = 0; l < control->nLayers; ++l)
|
||||
{
|
||||
if(create_packet(tile, resolution, p, l, 0) < 0)
|
||||
if(create_packet(field, tile, resolution, p, l, 0) < 0)
|
||||
{
|
||||
// memory allocation error
|
||||
return 1;
|
||||
|
@ -850,7 +845,7 @@ create_packets(bwc_codec *const codec, bwc_tile *const tile)
|
|||
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! FUNCTION NAME: int64 create_quality_layer(bwc_codec *const codec, bwc_tile *const tile, !
|
||||
! FUNCTION NAME: int64 create_quality_layer(bwc_field *const field, bwc_tile *const tile, !
|
||||
! -------------- uint16 const threshold, !
|
||||
! int16 const q_layer, !
|
||||
! uchar const est) !
|
||||
|
@ -865,7 +860,7 @@ create_packets(bwc_codec *const codec, bwc_tile *const tile)
|
|||
! ----------- !
|
||||
! Variable Type Description !
|
||||
! -------- ---- ----------- !
|
||||
! codec bwc_codec* - Structure defining the compression/ !
|
||||
! field bwc_field* - Structure defining the compression/ !
|
||||
! decompression stage. !
|
||||
! !
|
||||
! tile bwc_tile* - Structure defining a bwc tile. !
|
||||
|
@ -893,7 +888,7 @@ create_packets(bwc_codec *const codec, bwc_tile *const tile)
|
|||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
static int64
|
||||
create_quality_layer(bwc_codec *const codec, bwc_tile *const tile,
|
||||
create_quality_layer(bwc_field *const field, bwc_tile *const tile,
|
||||
uint16 const threshold,
|
||||
int16 const q_layer,
|
||||
uchar const est)
|
||||
|
@ -921,15 +916,15 @@ create_quality_layer(bwc_codec *const codec, bwc_tile *const tile,
|
|||
/*-----------------------*\
|
||||
! DEFINE ASSERTIONS: !
|
||||
\*-----------------------*/
|
||||
assert(codec);
|
||||
assert(field);
|
||||
assert(tile);
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Save the global control and info structure to temporary !
|
||||
! variables to make the code more readable. !
|
||||
\*--------------------------------------------------------*/
|
||||
control = &codec->control;
|
||||
info = &codec->info;
|
||||
control = &field->control;
|
||||
info = field->info;
|
||||
|
||||
for(j = 0, estimated_ql_size = 0; j < info->nPar; ++j)
|
||||
{
|
||||
|
@ -1061,7 +1056,7 @@ create_quality_layer(bwc_codec *const codec, bwc_tile *const tile,
|
|||
|
||||
for(p = 0; p < resolution->control.number_of_precincts; ++p)
|
||||
{
|
||||
estimated_ph_size = create_packet(tile, resolution, p, q_layer, est + 1);
|
||||
estimated_ph_size = create_packet(field, tile, resolution, p, q_layer, est + 1);
|
||||
|
||||
if(estimated_ph_size < 0)
|
||||
{
|
||||
|
@ -1080,7 +1075,7 @@ create_quality_layer(bwc_codec *const codec, bwc_tile *const tile,
|
|||
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! FUNCTION NAME: void create_quality_layers(bwc_codec *const codec, bwc_tile *const tile) !
|
||||
! FUNCTION NAME: void create_quality_layers(bwc_field *const field, bwc_tile *const tile) !
|
||||
! -------------- !
|
||||
! !
|
||||
! !
|
||||
|
@ -1092,7 +1087,7 @@ create_quality_layer(bwc_codec *const codec, bwc_tile *const tile,
|
|||
! ----------- !
|
||||
! Variable Type Description !
|
||||
! -------- ---- ----------- !
|
||||
! codec bwc_codec* - Structure defining the compression/ !
|
||||
! field bwc_field* - Structure defining the compression/ !
|
||||
! decompression stage. !
|
||||
! !
|
||||
! tile bwc_tile* - Structure defining a bwc tile. !
|
||||
|
@ -1112,7 +1107,7 @@ create_quality_layer(bwc_codec *const codec, bwc_tile *const tile,
|
|||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
static uchar
|
||||
create_quality_layers(bwc_codec *const codec, bwc_tile *const tile)
|
||||
create_quality_layers(bwc_field *const field, bwc_tile *const tile)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE INT VARIABLES: !
|
||||
|
@ -1136,15 +1131,15 @@ create_quality_layers(bwc_codec *const codec, bwc_tile *const tile)
|
|||
/*-----------------------*\
|
||||
! DEFINE ASSERTIONS: !
|
||||
\*-----------------------*/
|
||||
assert(codec);
|
||||
assert(field);
|
||||
assert(tile);
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Save the global and tile control and info structure to !
|
||||
! temporary variables to make the code more readable. !
|
||||
\*--------------------------------------------------------*/
|
||||
control = &codec->control;
|
||||
info = &codec->info;
|
||||
control = &field->control;
|
||||
info = field->info;
|
||||
|
||||
tile_control = &tile->control;
|
||||
tile_info = &tile->info;
|
||||
|
@ -1194,7 +1189,7 @@ create_quality_layers(bwc_codec *const codec, bwc_tile *const tile)
|
|||
{
|
||||
slope = (slope_max + slope_min) >> 1;
|
||||
|
||||
estimated_ql_size = create_quality_layer(codec, tile, slope, l, 1);
|
||||
estimated_ql_size = create_quality_layer(field, tile, slope, l, 1);
|
||||
|
||||
if(estimated_ql_size >= 0)
|
||||
{
|
||||
|
@ -1239,7 +1234,7 @@ create_quality_layers(bwc_codec *const codec, bwc_tile *const tile)
|
|||
slope = 0;
|
||||
}
|
||||
|
||||
estimated_ql_size = create_quality_layer(codec, tile, slope, l, 0);
|
||||
estimated_ql_size = create_quality_layer(field, tile, slope, l, 0);
|
||||
|
||||
if(estimated_ql_size >= 0)
|
||||
{
|
||||
|
@ -1260,7 +1255,7 @@ create_quality_layers(bwc_codec *const codec, bwc_tile *const tile)
|
|||
|| ||
|
||||
\************************************************************************************************************/
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! FUNCTION NAME: uchar t2_encode(bwc_codec *const codec, bwc_tile *const tile) !
|
||||
! FUNCTION NAME: uchar t2_encode(bwc_field *const field, bwc_tile *const tile) !
|
||||
! -------------- !
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
|
@ -1274,7 +1269,7 @@ create_quality_layers(bwc_codec *const codec, bwc_tile *const tile)
|
|||
! ----------- !
|
||||
! Variable Type Description !
|
||||
! -------- ---- ----------- !
|
||||
! codec bwc_codec* - Structure defining the compression/ !
|
||||
! field bwc_field* - Structure defining the compression/ !
|
||||
! decompression stage. !
|
||||
! !
|
||||
! tile bwc_tile* - Structure defining a bwc tile. !
|
||||
|
@ -1294,19 +1289,19 @@ create_quality_layers(bwc_codec *const codec, bwc_tile *const tile)
|
|||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
uchar
|
||||
t2_encode(bwc_codec *const codec, bwc_tile *const tile)
|
||||
t2_encode(bwc_field *const field, bwc_tile *const tile)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE ASSERTIONS: !
|
||||
\*-----------------------*/
|
||||
assert(codec);
|
||||
assert(field);
|
||||
assert(tile);
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Create the quality layers according to the bitrate val- !
|
||||
! ues provided by the user. !
|
||||
\*--------------------------------------------------------*/
|
||||
if(create_quality_layers(codec, tile))
|
||||
if(create_quality_layers(field, tile))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
@ -1315,7 +1310,7 @@ t2_encode(bwc_codec *const codec, bwc_tile *const tile)
|
|||
! Create the data packets according to the quality layers !
|
||||
! evaluated in the previous step. !
|
||||
\*--------------------------------------------------------*/
|
||||
if(create_packets(codec, tile))
|
||||
if(create_packets(field, tile))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
@ -1324,7 +1319,7 @@ t2_encode(bwc_codec *const codec, bwc_tile *const tile)
|
|||
}
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! FUNCTION NAME: uchar parse_packet(bwc_codec *const codec, bwc_tile *const tile, !
|
||||
! FUNCTION NAME: uchar parse_packet(bwc_field *const field, bwc_tile *const tile, !
|
||||
! -------------- bwc_packet *const packet, !
|
||||
! uint64 const body_size) !
|
||||
! !
|
||||
|
@ -1337,7 +1332,7 @@ t2_encode(bwc_codec *const codec, bwc_tile *const tile)
|
|||
! ----------- !
|
||||
! Variable Type Description !
|
||||
! -------- ---- ----------- !
|
||||
! codec bwc_codec* - Structure defining the compression/ !
|
||||
! field bwc_field* - Structure defining the compression/ !
|
||||
! decompression stage. !
|
||||
! !
|
||||
! tile bwc_tile* - Structure defining a bwc tile. !
|
||||
|
@ -1361,7 +1356,7 @@ t2_encode(bwc_codec *const codec, bwc_tile *const tile)
|
|||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
uchar
|
||||
parse_packet(bwc_codec *const codec, bwc_tile *const tile,
|
||||
parse_packet(bwc_field *const field, bwc_tile *const tile,
|
||||
bwc_packet *const packet,
|
||||
uint64 const body_size)
|
||||
{
|
||||
|
@ -1387,7 +1382,7 @@ parse_packet(bwc_codec *const codec, bwc_tile *const tile,
|
|||
/*-----------------------*\
|
||||
! DEFINE ASSERTIONS: !
|
||||
\*-----------------------*/
|
||||
assert(codec);
|
||||
assert(field);
|
||||
assert(tile);
|
||||
assert(packet);
|
||||
|
||||
|
@ -1397,7 +1392,7 @@ parse_packet(bwc_codec *const codec, bwc_tile *const tile,
|
|||
! Initialize the stream that is used to parse the packet !
|
||||
! codestream. !
|
||||
\*--------------------------------------------------------*/
|
||||
header = init_bitstream(packet->header.memory, body_size, 'd');
|
||||
header = init_stream(packet->header.memory, body_size, 'd');
|
||||
if(!header)
|
||||
{
|
||||
// memory allocation error
|
||||
|
@ -1577,7 +1572,7 @@ parse_packet(bwc_codec *const codec, bwc_tile *const tile,
|
|||
! If the error resilience mode is active for the current !
|
||||
! codestream... !
|
||||
\*--------------------------------------------------------*/
|
||||
if(codec->control.error_resilience)
|
||||
if(field->control.error_resilience)
|
||||
{
|
||||
/*--------------------------------------------------------*\
|
||||
! check if the next symbol corresponds to the end of pack- !
|
||||
|
|
Loading…
Reference in a new issue