mirror of
https://github.com/apache/nuttx.git
synced 2026-06-08 01:42:58 +08:00
libc/lzfcompress: add lzf compress stream
compress stream based on lzf algorithm: struct lib_rawoutstream_s rawstream; struct lib_lzfoutstream_s lzfstream; lib_rawoutstream(&rawstream, fd); lib_lzfoutstream(&lzfstream, &rawstream); Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
@@ -32,10 +32,19 @@
|
||||
#ifndef __INCLUDE_LZF_H
|
||||
#define __INCLUDE_LZF_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_LIBC_LZF
|
||||
|
||||
#define LZF_VERSION 0x0105 /* 1.5, API version */
|
||||
#define HLOG CONFIG_LIBC_LZF_HLOG
|
||||
|
||||
@@ -151,4 +160,5 @@ unsigned int lzf_decompress(FAR const void *const in_data,
|
||||
unsigned int in_len, FAR void *out_data,
|
||||
unsigned int out_len);
|
||||
|
||||
#endif /* CONFIG_LIBC_LZF */
|
||||
#endif /* __INCLUDE_LZF_H */
|
||||
|
||||
@@ -26,8 +26,18 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <lzf.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_LIBC_LZF
|
||||
#define LZF_STREAM_BLOCKSIZE ((1 << CONFIG_STREAM_LZF_BLOG) - 1)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
@@ -173,6 +183,20 @@ struct lib_rawsostream_s
|
||||
int fd;
|
||||
};
|
||||
|
||||
/* LZF compressed stream pipeline */
|
||||
|
||||
#ifdef CONFIG_LIBC_LZF
|
||||
struct lib_lzfoutstream_s
|
||||
{
|
||||
struct lib_outstream_s public;
|
||||
FAR struct lib_outstream_s *backend;
|
||||
lzf_state_t state;
|
||||
size_t offset;
|
||||
char in[LZF_STREAM_BLOCKSIZE];
|
||||
char out[LZF_MAX_HDR_SIZE + LZF_STREAM_BLOCKSIZE];
|
||||
};
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
@@ -329,6 +353,27 @@ void lib_zeroinstream(FAR struct lib_instream_s *zeroinstream);
|
||||
void lib_nullinstream(FAR struct lib_instream_s *nullinstream);
|
||||
void lib_nulloutstream(FAR struct lib_outstream_s *nulloutstream);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: lib_lzfoutstream
|
||||
*
|
||||
* Description:
|
||||
* LZF compressed pipeline stream
|
||||
*
|
||||
* Input Parameters:
|
||||
* stream - User allocated, uninitialized instance of struct
|
||||
* lib_lzfoutstream_s to be initialized.
|
||||
* backend - Stream backend port.
|
||||
*
|
||||
* Returned Value:
|
||||
* None (User allocated instance initialized).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_LIBC_LZF
|
||||
void lib_lzfoutstream(FAR struct lib_lzfoutstream_s *stream,
|
||||
FAR struct lib_outstream_s *backend);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: lib_noflush
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user