CARPLAY版本整理
This commit is contained in:
12
MXC_A27-PCB4.5-270S/lib/awtk/awtk/src/compressors/SConscript
Normal file
12
MXC_A27-PCB4.5-270S/lib/awtk/awtk/src/compressors/SConscript
Normal file
@ -0,0 +1,12 @@
|
||||
import os
|
||||
import copy
|
||||
|
||||
BIN_DIR=os.environ['BIN_DIR'];
|
||||
LIB_DIR=os.environ['LIB_DIR'];
|
||||
|
||||
sources = Glob('*.c');
|
||||
|
||||
env=DefaultEnvironment().Clone()
|
||||
|
||||
env.Library(os.path.join(LIB_DIR, 'compressors'), sources, LIBS=[])
|
||||
|
@ -0,0 +1,78 @@
|
||||
/**
|
||||
* File: compressor_miniz.c
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: compressor base on miniz
|
||||
*
|
||||
* Copyright (c) 2019 - 2021 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* This program is distributed data the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* License file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* History:
|
||||
* ================================================================
|
||||
* 2019-10-12 Li XianJing <xianjimli@hotmail.com> created
|
||||
*
|
||||
*/
|
||||
|
||||
#include "tkc/mem.h"
|
||||
#include "miniz/miniz.h"
|
||||
#include "compressors/compressor_miniz.h"
|
||||
|
||||
static ret_t compressor_miniz_compress(compressor_t* compressor, const void* data, uint32_t size,
|
||||
wbuffer_t* out) {
|
||||
int level = 0;
|
||||
mz_ulong out_size = 0;
|
||||
return_value_if_fail(wbuffer_extend_capacity(out, 512 + size * 2) == RET_OK, RET_OOM);
|
||||
|
||||
out_size = out->capacity;
|
||||
level = compressor->options == COMPRESSOR_SPEED_FIRST ? 3 : 6;
|
||||
|
||||
if (mz_compress2((uint8_t*)(out->data), &out_size, (const uint8_t*)data, size, level) == MZ_OK) {
|
||||
out->cursor = out_size;
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
out->cursor = 0;
|
||||
|
||||
return RET_FAIL;
|
||||
}
|
||||
|
||||
static ret_t compressor_miniz_uncompress(compressor_t* compressor, const void* data, uint32_t size,
|
||||
wbuffer_t* out) {
|
||||
mz_ulong out_size = 0;
|
||||
return_value_if_fail(wbuffer_extend_capacity(out, size * 5) == RET_OK, RET_OOM);
|
||||
|
||||
out_size = out->capacity;
|
||||
|
||||
if (mz_uncompress((uint8_t*)(out->data), &out_size, (const uint8_t*)data, size) == MZ_OK) {
|
||||
out->cursor = out_size;
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
return RET_FAIL;
|
||||
}
|
||||
|
||||
static ret_t compressor_miniz_destroy(compressor_t* compressor) {
|
||||
TKMEM_FREE(compressor);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
compressor_t* compressor_miniz_create(compressor_options_t options) {
|
||||
compressor_t* compressor = TKMEM_ZALLOC(compressor_t);
|
||||
return_value_if_fail(compressor != NULL, NULL);
|
||||
|
||||
compressor->type = "miniz";
|
||||
compressor->options = options;
|
||||
compressor->compress = compressor_miniz_compress;
|
||||
compressor->uncompress = compressor_miniz_uncompress;
|
||||
compressor->destroy = compressor_miniz_destroy;
|
||||
|
||||
return compressor;
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
/**
|
||||
* File: compressor_miniz.h
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: compressor base on miniz
|
||||
*
|
||||
* Copyright (c) 2019 - 2021 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* This program is distributed data the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* License file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* History:
|
||||
* ================================================================
|
||||
* 2019-10-12 Li XianJing <xianjimli@hotmail.com> created
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TK_COMPRESSOR_MINIZ_H
|
||||
#define TK_COMPRESSOR_MINIZ_H
|
||||
|
||||
#include "tkc/compressor.h"
|
||||
|
||||
BEGIN_C_DECLS
|
||||
|
||||
/**
|
||||
* @class compressor_miniz_t
|
||||
* @parent compressor_t
|
||||
* @annotation ["fake"]
|
||||
*
|
||||
* 基于miniz实现的compressor接口。
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @method compressor_miniz_create
|
||||
*
|
||||
* 创建compressor对象。
|
||||
*
|
||||
* @param {compressor_options_t} options 选项。
|
||||
*
|
||||
* @return {compressor_t*} 返回compressor对象。
|
||||
*
|
||||
*/
|
||||
compressor_t* compressor_miniz_create(compressor_options_t options);
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#endif /*TK_COMPRESSOR_MINIZ_H*/
|
Reference in New Issue
Block a user