rtxBitEncode.h File Reference
Bit encode functions. More...
#include "rtxsrc/rtxContext.h"
Go to the source code of this file.
Defines | |
#define | rtxEncByteAlignPattern(pctxt, pattern) |
This macro will byte-align the context buffer by encoding according to the given pattern. | |
Functions | |
EXTERNRT int | rtxEncBitsPattern (OSCTXT *pctxt, OSUINT8 pattern, size_t nbits) |
This function encodes the given number of bits using a repeating bit pattern. | |
EXTERNRT int | rtxEncBit (OSCTXT *pctxt, OSBOOL value) |
This function will set the bit at the current encode bit cursor position to 1 or 0 and advance the cursor pointer. | |
EXTERNRT int | rtxEncBits (OSCTXT *pctxt, OSUINT32 value, size_t nbits) |
This function will encode a series of bits (up to 32) from an unsigned integer value. | |
EXTERNRT int | rtxEncBitsFromByteArray (OSCTXT *pctxt, const OSOCTET *pvalue, size_t nbits) |
This function will encode a series of bits from an octet array. | |
EXTERNRT int | rtxCopyBits (OSCTXT *pctxt, const OSOCTET *pvalue, size_t nbits, OSUINT32 bitOffset) |
This function will encode a series of bits from an octet array. | |
EXTERNRT int | rtxMergeBits (OSCTXT *pctxt, OSUINT32 value, OSSIZE nbits) |
This function will merge a series of bits (up to 32) from an unsigned integer value into an existing encoded data buffer. |
Detailed Description
Bit encode functions.
Definition in file rtxBitEncode.h.
Define Documentation
#define rtxEncByteAlignPattern | ( | pctxt, | |||
pattern | ) |
if ((pctxt)->buffer.bitOffset != 8) { \ rtxEncBits(pctxt, pattern, (pctxt)->buffer.bitOffset); }
This macro will byte-align the context buffer by encoding according to the given pattern.
If the buffer is not aligned, the lowest bits of the current byte, which have not be written already, will be set to the corresponding lowest bites of the pattern.
Definition at line 44 of file rtxBitEncode.h.
Function Documentation
EXTERNRT int rtxCopyBits | ( | OSCTXT * | pctxt, | |
const OSOCTET * | pvalue, | |||
size_t | nbits, | |||
OSUINT32 | bitOffset | |||
) |
This function will encode a series of bits from an octet array.
Encoding started from specified bit offset.
- Parameters:
-
pctxt Pointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls. pvalue Pointer to bit string to be encoded. nbits Number of bits from the value to encode. bitOffset Starting bit offset.
- Returns:
- Status of the operation. Zero if successful; a negative status code if failed.
EXTERNRT int rtxEncBit | ( | OSCTXT * | pctxt, | |
OSBOOL | value | |||
) |
This function will set the bit at the current encode bit cursor position to 1 or 0 and advance the cursor pointer.
- Parameters:
-
pctxt Pointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls. value The value to be encoded.
EXTERNRT int rtxEncBits | ( | OSCTXT * | pctxt, | |
OSUINT32 | value, | |||
size_t | nbits | |||
) |
This function will encode a series of bits (up to 32) from an unsigned integer value.
- Parameters:
-
pctxt Pointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls. value The value to be encoded. nbits Number of bits from the value to encode.
- Returns:
- Status of the operation. Zero if successful; a negative status code if failed.
EXTERNRT int rtxEncBitsFromByteArray | ( | OSCTXT * | pctxt, | |
const OSOCTET * | pvalue, | |||
size_t | nbits | |||
) |
This function will encode a series of bits from an octet array.
- Parameters:
-
pctxt Pointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls. pvalue Pointer to bit string to be encoded. nbits Number of bits from the value to encode.
- Returns:
- Status of the operation. Zero if successful; a negative status code if failed.
EXTERNRT int rtxEncBitsPattern | ( | OSCTXT * | pctxt, | |
OSUINT8 | pattern, | |||
size_t | nbits | |||
) |
This function encodes the given number of bits using a repeating bit pattern.
This function may be used to encode any number of bits (including more than 8 bits). It will take the bit values to encode from the pattern, in accordance with the buffer's bit offset. For example, if the next bit to encode is the highest bit of the next byte in the buffer, then the bit value encoded will be the highest bit of the pattern.
- Parameters:
-
pctxt Pointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls. pattern The repeating pattern. bits The number of bits to encode.
EXTERNRT int rtxMergeBits | ( | OSCTXT * | pctxt, | |
OSUINT32 | value, | |||
OSSIZE | nbits | |||
) |
This function will merge a series of bits (up to 32) from an unsigned integer value into an existing encoded data buffer.
- Parameters:
-
pctxt Pointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls. value The value to be encoded. nbits Number of bits from the value to merge.
- Returns:
- Status of the operation. Zero if successful; a negative status code if failed.