2024-02-22 10:27:40 +00:00
|
|
|
/*================================================================================================*\
|
|
|
|
|| ||
|
|
|
|
|| /$$$$$$$ /$$ /$$ /$$ /$$ ||
|
|
|
|
|| | $$__ $$|__/ | $$ /$ | $$| $$ ||
|
|
|
|
|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ ||
|
|
|
|
|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ ||
|
|
|
|
|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ ||
|
|
|
|
|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ ||
|
|
|
|
|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ ||
|
|
|
|
|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ ||
|
|
|
|
|| /$$ \ $$ | $$ ||
|
|
|
|
|| | $$$$$$/ | $$ ||
|
|
|
|
|| \______/ |__/ ||
|
|
|
|
|| ||
|
|
|
|
|| DESCRIPTION: ||
|
|
|
|
|| ------------ ||
|
|
|
|
|| ||
|
|
|
|
|| This header defines a the bit coder and its context states used during the ||
|
|
|
|
|| entropy encoding stage of the BigWhoop compression library. ||
|
|
|
|
|| ||
|
|
|
|
|| -------------------------------------------------------------------------------------------- ||
|
|
|
|
|| Copyright (c) 2023, High Performance Computing Center - University of Stuttgart ||
|
|
|
|
|| ||
|
|
|
|
|| Redistribution and use in source and binary forms, with or without modification, are ||
|
|
|
|
|| permitted provided that the following conditions are met: ||
|
|
|
|
|| ||
|
|
|
|
|| (1) Redistributions of source code must retain the above copyright notice, this list of ||
|
|
|
|
|| conditions and the following disclaimer. ||
|
|
|
|
|| ||
|
|
|
|
|| (2) Redistributions in binary form must reproduce the above copyright notice, this list ||
|
|
|
|
|| of conditions and the following disclaimer in the documentation and/or other ||
|
|
|
|
|| materials provided with the distribution. ||
|
|
|
|
|| ||
|
|
|
|
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS ||
|
|
|
|
|| OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|
|
|
|
|| MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|
|
|
|
|| COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|
|
|
|
|| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|
|
|
|
|| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|
|
|
|
|| HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ||
|
|
|
|
|| TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ||
|
|
|
|
|| EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ||
|
|
|
|
|| ||
|
|
|
|
\*================================================================================================*/
|
2023-06-20 11:43:33 +00:00
|
|
|
#ifndef MQ_TYPES_H
|
|
|
|
#define MQ_TYPES_H
|
2024-02-22 10:27:40 +00:00
|
|
|
/************************************************************************************************\
|
|
|
|
|| _ _ _ ____ _ _ _ ___ ____ ||
|
|
|
|
|| | |\ | | | | | | \ |___ ||
|
|
|
|
|| | | \| |___ |___ |__| |__/ |___ ||
|
|
|
|
|| ||
|
|
|
|
\************************************************************************************************/
|
|
|
|
#include <stdint.h>
|
2023-06-20 11:43:33 +00:00
|
|
|
|
2024-02-22 10:27:40 +00:00
|
|
|
/************************************************************************************************\
|
|
|
|
|| ___ ____ ____ ____ _ _ _ ____ ___ ___ _ _ ___ ____ ____ ||
|
|
|
|
|| | \ |___ |__/ |__/ | | | |___ | \ | \_/ |__] |___ [__ ||
|
|
|
|
|| |__/ |___ | \ | \ | \/ |___ |__/ | | | |___ ___] ||
|
|
|
|
|| ||
|
|
|
|
\************************************************************************************************/
|
|
|
|
/*----------------------------------------------------------------------------------------------*\
|
|
|
|
! !
|
|
|
|
! DESCRIPTION: !
|
|
|
|
! ------------ !
|
|
|
|
! !
|
|
|
|
! This structure is used to directly access the parameter codeblocks during !
|
|
|
|
! entropy (de-)encoding to facilitate shared memory parallelization. !
|
|
|
|
! !
|
|
|
|
\*----------------------------------------------------------------------------------------------*/
|
|
|
|
typedef struct context
|
|
|
|
{
|
|
|
|
uint16_t p; // LPS probability estimate
|
|
|
|
uint8_t sk; // Most probable symbol
|
2023-06-20 11:43:33 +00:00
|
|
|
|
2024-02-22 10:27:40 +00:00
|
|
|
const struct context *const MPS; // New context for Most Probable Symbol
|
|
|
|
const struct context *const LPS; // New context for Least Probable Symbol
|
|
|
|
} bwc_context_state;
|
2023-06-20 11:43:33 +00:00
|
|
|
|
2024-02-22 10:27:40 +00:00
|
|
|
/*----------------------------------------------------------------------------------------------*\
|
|
|
|
! !
|
|
|
|
! DESCRIPTION: !
|
|
|
|
! ------------ !
|
|
|
|
! !
|
|
|
|
! DESCRIPTION NEEDED !
|
|
|
|
! | | !
|
|
|
|
! !
|
|
|
|
\*----------------------------------------------------------------------------------------------*/
|
|
|
|
typedef struct state
|
|
|
|
{
|
|
|
|
int64_t L; // Number of bytes generated so far
|
|
|
|
uint32_t C; // Register def. lower bound of coding int
|
|
|
|
uint16_t A; // Register def. upper bound of coding int
|
|
|
|
int8_t t; // Counter evaluating when moving C into b
|
2023-06-20 11:43:33 +00:00
|
|
|
|
2024-02-22 10:27:40 +00:00
|
|
|
unsigned char *b; // Byte buffer
|
|
|
|
unsigned char T; // Temporary byte buffer
|
|
|
|
|
|
|
|
struct state *next; // State of the next coding phase
|
|
|
|
struct state *prev; // State of the previous coding phase
|
|
|
|
} bwc_coder_state;
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------------------------*\
|
|
|
|
! !
|
|
|
|
! DESCRIPTION: !
|
|
|
|
! ------------ !
|
|
|
|
! !
|
|
|
|
! DESCRIPTION NEEDED !
|
|
|
|
! | | !
|
|
|
|
! !
|
|
|
|
\*----------------------------------------------------------------------------------------------*/
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int64_t Lmax; // Number of code bytes (used by decoder)
|
|
|
|
uint8_t nContext; // No. tracked context states
|
|
|
|
|
|
|
|
unsigned char *b; // Temporary byte buffer
|
|
|
|
|
|
|
|
bwc_coder_state *state; // State for the current coding pass
|
|
|
|
bwc_context_state const **context; // States for the current coding pass
|
|
|
|
} bwc_bit_coder;
|
2023-06-20 11:43:33 +00:00
|
|
|
#endif
|