BigWhoop/include/library/private/macros.h
2023-06-20 13:53:59 +02:00

235 lines
No EOL
20 KiB
C
Executable file

/*================================================================================================*\
|| ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ ||
|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ ||
|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ ||
|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ ||
|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ ||
|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ ||
|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ ||
|| /$$ \ $$ | $$ ||
|| | $$$$$$/ | $$ ||
|| \______/ |__/ ||
|| ||
|| DESCRIPTION: ||
|| ------------ ||
|| ||
|| This file defines simple macros that are used to make the code more readable. ||
|| ||
|| -------------------------------------------------------------------------------------------- ||
|| 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. ||
|| ||
\*================================================================================================*/
#ifndef BWC_MACROSS_H
#define BWC_MACROSS_H
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! These macros define flags used to indicate if a dataset is to be red from/ !
! written to a file or cleared in the bwc_file structure. !
! !
\*----------------------------------------------------------------------------------------------*/
#define DATA_CLR 0x00 // Data cleared
#define DATA_INI 0x01 // Data file has been initialized
#define DATA_IN 0x10 // Data set as input
#define DATA_OUT 0x20 // Data set as output
#define DATA_STR 0x40 // Data set to be streamed to/from file
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! These macros define flags used to indicate if a codestream is to be red from/ !
! written to a file or cleared in the bwc_file structure. !
! !
\*----------------------------------------------------------------------------------------------*/
#define CS_CLR 0x00 // Codestream cleared
#define CS_AUX 0x01 // Codestream contains aux. information
#define CS_COM 0x02 // Codestream contains com. information
#define CS_IN 0x10 // Codestream set as input
#define CS_OUT 0x20 // Codestream set as output
#define CS_STR 0x40 // Codestream to be streamed to/from file
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! These macros define flags used to indicate the state of the setup structure in !
! the bwc_field structure. !
! !
\*----------------------------------------------------------------------------------------------*/
#define SETUP_CLR 0x00 // Setup cleared
#define SETUP_CMP 0x01 // Setup defined for compression
#define SETUP_DCP 0x02 // Setup defined for decompression
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! These macros define flags used to indicate the state of the bwc_field structure. !
! !
\*----------------------------------------------------------------------------------------------*/
#define FIELD_CLR 0x00 // Field cleared and ready to be used
#define FIELD_USD 0x01 // Field setup up for (de)compression
#define FIELD_ERR 0x02 // Field encountered an error
#define FIELD_VRB 0x10 // Store miscallaneous information
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! These macros are used to identify the spatial and temporal dimensions. !
! !
\*----------------------------------------------------------------------------------------------*/
#define DIM_X 1 // 1st. spacial direction
#define DIM_Y 2 // 2nd. spacial direction
#define DIM_Z 4 // 3rd. spacial direction
#define DIM_TS 8 // temporal direction
#define DIM_ALL 15 // all dimensions
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! These Constants define codestream markers used to create the embedded codestream. !
! !
\*----------------------------------------------------------------------------------------------*/
#define SOC 0xFF50 // Start of codestream
#define SGI 0xFF51 // Global data-set information
#define SGC 0xFF52 // Global control parameters
#define SGR 0xFF53 // Global tile bitstream size information
#define SAX 0xFF54 // Auxiliary data-set information
#define TLM 0xFF55 // Packet lengths: main header
#define PLM 0xFF56 // Packet lengths: tile-part
#define PPM 0xFF57 // Quantization default
#define COM 0xFF58 // Comment
#define EOH 0xFF59 // End of header
#define PLT 0xFF60 // Packed packet headers: main header
#define PPT 0xFF61 // Packed packet headers: tile-part
#define SOT 0xFF90 // Start of tile
#define SOP 0xFF91 // Start of packet
#define EPH 0xFF92 // End of packet header
#define SOD 0xFF93 // Start of data
#define EOC 0xFFFF // End of code-stream
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! These macros define flags used for codestream parsing. !
! !
\*----------------------------------------------------------------------------------------------*/
#define CODESTREAM_OK 0x00 // No errors detected in Codestream
#define CODESTREAM_ERROR 0x80 // Error detexted in Codestream
#define CODESTREAM_SGI_READ 0x01 // Global data-set information read
#define CODESTREAM_SGC_READ 0x02 // Global control parameters read
#define CODESTREAM_SGR_READ 0x04 // Global register read
#define CODESTREAM_SAX_READ 0x08 // Auxiliary information block read
#define CODESTREAM_COM_READ 0x10 // Comment block read
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! These macros define simple mathematicall oprators. !
! !
\*----------------------------------------------------------------------------------------------*/
#define MAX(x, y) (((x) < (y))?(y):(x)) // Returns maximum between two values
#define MIN(x, y) (((x) > (y))?(y):(x)) // Returns minimum between two values
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! These macros define stream manipulation operations to rewind, forward, inquire !
! the availability and get access to the current memory position of a bwc_stream. !
! !
\*----------------------------------------------------------------------------------------------*/
#define REWIND(stream, delta) \
{ \
stream->L -= delta; \
}
#define FORWARD(stream, delta) \
{ \
stream->L += delta; \
}
#define CAN_READ(stream, length) \
{ \
((stream->L + length > stream->Lmax) ? FAILURE : SUCCESS) \
}
#define GET_ACCESS(stream) (uchar*)stream->memory + stream->L
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! These Constants define common error messages used throughout the bwc library. !
! !
\*----------------------------------------------------------------------------------------------*/
#define CSTERROR "o##########################################################o\n"\
"| ERROR: Invalid Codestream |\n"\
"o##########################################################o\n"
#define FRMERROR "o##########################################################o\n"\
"| ERROR: Invalid file format. |\n"\
"o##########################################################o\n"
#define INPERROR "o##########################################################o\n"\
"| ERROR: No Input Specified. |\n"\
"o##########################################################o\n"
#define MEMERROR "o##########################################################o\n"\
"| ERROR: Out of Memory |\n"\
"o##########################################################o\n"
#define PARERROR "o##########################################################o\n"\
"| ERROR: Invalid Parameter |\n"\
"o##########################################################o\n"
#define PRCERROR "o##########################################################o\n"\
"| ERROR: Invalid Parameter Precision |\n"\
"o##########################################################o\n"
#define RDERROR "o##########################################################o\n"\
"| ERROR: Invalid Number of Bytes Read from File. |\n"\
"o##########################################################o\n"
#define WRTERROR "o##########################################################o\n"\
"| ERROR: Invalid Number of Bytes Written to File. |\n"\
"o##########################################################o\n"
#endif