mirror of
https://github.com/emmanuel-marty/lzsa.git
synced 2024-12-28 09:29:39 +00:00
Add documentation comments
This commit is contained in:
parent
5484395465
commit
1bca5b995a
@ -60,6 +60,7 @@ int lzsa_get_frame_size(void) {
|
|||||||
*
|
*
|
||||||
* @param pFrameData encoding buffer
|
* @param pFrameData encoding buffer
|
||||||
* @param nMaxFrameDataSize max encoding buffer size, in bytes
|
* @param nMaxFrameDataSize max encoding buffer size, in bytes
|
||||||
|
* @param nFormatVersion version of format to use (1-2)
|
||||||
*
|
*
|
||||||
* @return number of encoded bytes, or -1 for failure
|
* @return number of encoded bytes, or -1 for failure
|
||||||
*/
|
*/
|
||||||
@ -146,6 +147,7 @@ int lzsa_encode_footer_frame(unsigned char *pFrameData, const int nMaxFrameDataS
|
|||||||
*
|
*
|
||||||
* @param pFrameData data bytes
|
* @param pFrameData data bytes
|
||||||
* @param nFrameDataSize number of bytes to decode
|
* @param nFrameDataSize number of bytes to decode
|
||||||
|
* @param nFormatVersion pointer to returned format version, if successful
|
||||||
*
|
*
|
||||||
* @return 0 for success, or -1 for failure
|
* @return 0 for success, or -1 for failure
|
||||||
*/
|
*/
|
||||||
|
@ -56,6 +56,7 @@ int lzsa_get_frame_size(void);
|
|||||||
*
|
*
|
||||||
* @param pFrameData encoding buffer
|
* @param pFrameData encoding buffer
|
||||||
* @param nMaxFrameDataSize max encoding buffer size, in bytes
|
* @param nMaxFrameDataSize max encoding buffer size, in bytes
|
||||||
|
* @param nFormatVersion version of format to use (1-2)
|
||||||
*
|
*
|
||||||
* @return number of encoded bytes, or -1 for failure
|
* @return number of encoded bytes, or -1 for failure
|
||||||
*/
|
*/
|
||||||
@ -98,6 +99,7 @@ int lzsa_encode_footer_frame(unsigned char *pFrameData, const int nMaxFrameDataS
|
|||||||
*
|
*
|
||||||
* @param pFrameData data bytes
|
* @param pFrameData data bytes
|
||||||
* @param nFrameDataSize number of bytes to decode
|
* @param nFrameDataSize number of bytes to decode
|
||||||
|
* @param nFormatVersion pointer to returned format version, if successful
|
||||||
*
|
*
|
||||||
* @return 0 for success, or -1 for failure
|
* @return 0 for success, or -1 for failure
|
||||||
*/
|
*/
|
||||||
|
@ -141,7 +141,7 @@ static inline int lzsa_write_match_varlen_v1(unsigned char *pOutData, int nOutOf
|
|||||||
/**
|
/**
|
||||||
* Get offset encoding cost in bits
|
* Get offset encoding cost in bits
|
||||||
*
|
*
|
||||||
* @param nMatchOffset offset to get cost of
|
* @param __nMatchOffset offset to get cost of
|
||||||
*
|
*
|
||||||
* @return cost in bits
|
* @return cost in bits
|
||||||
*/
|
*/
|
||||||
@ -625,11 +625,11 @@ static int lzsa_write_block_v1(lzsa_compressor *pCompressor, const lzsa_match *p
|
|||||||
* @return size of compressed data in output buffer, or -1 if the data is uncompressible
|
* @return size of compressed data in output buffer, or -1 if the data is uncompressible
|
||||||
*/
|
*/
|
||||||
static int lzsa_write_raw_uncompressed_block_v1(lzsa_compressor *pCompressor, const unsigned char *pInWindow, const int nStartOffset, const int nEndOffset, unsigned char *pOutData, const int nMaxOutDataSize) {
|
static int lzsa_write_raw_uncompressed_block_v1(lzsa_compressor *pCompressor, const unsigned char *pInWindow, const int nStartOffset, const int nEndOffset, unsigned char *pOutData, const int nMaxOutDataSize) {
|
||||||
int nNumLiterals = nEndOffset - nStartOffset;
|
const int nNumLiterals = nEndOffset - nStartOffset;
|
||||||
const int nTokenLiteralsLen = (nNumLiterals >= LITERALS_RUN_LEN_V1) ? LITERALS_RUN_LEN_V1 : nNumLiterals;
|
const int nTokenLiteralsLen = (nNumLiterals >= LITERALS_RUN_LEN_V1) ? LITERALS_RUN_LEN_V1 : nNumLiterals;
|
||||||
int nOutOffset = 0;
|
int nOutOffset = 0;
|
||||||
|
|
||||||
int nCommandSize = 8 /* token */ + lzsa_get_literals_varlen_size_v1(nNumLiterals) + (nNumLiterals << 3) + 4;
|
const int nCommandSize = 8 /* token */ + lzsa_get_literals_varlen_size_v1(nNumLiterals) + (nNumLiterals << 3) + 4;
|
||||||
if ((nOutOffset + (nCommandSize >> 3)) > nMaxOutDataSize)
|
if ((nOutOffset + (nCommandSize >> 3)) > nMaxOutDataSize)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -45,14 +45,15 @@
|
|||||||
* @param pCompressor compression context to initialize
|
* @param pCompressor compression context to initialize
|
||||||
* @param nMaxWindowSize maximum size of input data window (previously compressed bytes + bytes to compress)
|
* @param nMaxWindowSize maximum size of input data window (previously compressed bytes + bytes to compress)
|
||||||
* @param nMinMatchSize minimum match size (cannot be less than MIN_MATCH_SIZE)
|
* @param nMinMatchSize minimum match size (cannot be less than MIN_MATCH_SIZE)
|
||||||
|
* @param nFormatVersion version of format to use (1-2)
|
||||||
* @param nFlags compression flags
|
* @param nFlags compression flags
|
||||||
*
|
*
|
||||||
* @return 0 for success, non-zero for failure
|
* @return 0 for success, non-zero for failure
|
||||||
*/
|
*/
|
||||||
int lzsa_compressor_init(lzsa_compressor *pCompressor, const int nMaxWindowSize, const int nMinMatchSize, const int nFormatVersion, const int nFlags) {
|
int lzsa_compressor_init(lzsa_compressor *pCompressor, const int nMaxWindowSize, const int nMinMatchSize, const int nFormatVersion, const int nFlags) {
|
||||||
int nResult;
|
int nResult;
|
||||||
int nMinMatchSizeForFormat = (nFormatVersion == 1) ? MIN_MATCH_SIZE_V1 : MIN_MATCH_SIZE_V2;
|
const int nMinMatchSizeForFormat = (nFormatVersion == 1) ? MIN_MATCH_SIZE_V1 : MIN_MATCH_SIZE_V2;
|
||||||
int nMaxMinMatchForFormat = (nFormatVersion == 1) ? 5 : 3;
|
const int nMaxMinMatchForFormat = (nFormatVersion == 1) ? 5 : 3;
|
||||||
|
|
||||||
nResult = divsufsort_init(&pCompressor->divsufsort_context);
|
nResult = divsufsort_init(&pCompressor->divsufsort_context);
|
||||||
pCompressor->intervals = NULL;
|
pCompressor->intervals = NULL;
|
||||||
|
@ -145,6 +145,7 @@ typedef struct _lzsa_compressor {
|
|||||||
* @param pCompressor compression context to initialize
|
* @param pCompressor compression context to initialize
|
||||||
* @param nMaxWindowSize maximum size of input data window (previously compressed bytes + bytes to compress)
|
* @param nMaxWindowSize maximum size of input data window (previously compressed bytes + bytes to compress)
|
||||||
* @param nMinMatchSize minimum match size (cannot be less than MIN_MATCH_SIZE)
|
* @param nMinMatchSize minimum match size (cannot be less than MIN_MATCH_SIZE)
|
||||||
|
* @param nFormatVersion version of format to use (1-2)
|
||||||
* @param nFlags compression flags
|
* @param nFlags compression flags
|
||||||
*
|
*
|
||||||
* @return 0 for success, non-zero for failure
|
* @return 0 for success, non-zero for failure
|
||||||
|
@ -105,7 +105,9 @@ int lzsa_filestream_open(lzsa_stream_t *stream, const char *pszInFilename, const
|
|||||||
const char* stdInOutFile = "-";
|
const char* stdInOutFile = "-";
|
||||||
const char* stdInMode = "rb";
|
const char* stdInMode = "rb";
|
||||||
const char* stdOutMode = "wb";
|
const char* stdOutMode = "wb";
|
||||||
|
#ifdef _WIN32
|
||||||
int result;
|
int result;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!strncmp(pszInFilename, stdInOutFile, 1)) {
|
if (!strncmp(pszInFilename, stdInOutFile, 1)) {
|
||||||
if (!strncmp(pszMode, stdInMode, 2)) {
|
if (!strncmp(pszMode, stdInMode, 2)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user