summaryrefslogtreecommitdiff
path: root/core/src/fxcodec
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2016-02-25 12:39:15 -0800
committerLei Zhang <thestig@chromium.org>2016-02-25 12:39:15 -0800
commit4467dea020b2c19588cc06ce1ece46cd99f3c7df (patch)
treee96a26e6bef14ba081bd1658ef7f3f171a20218f /core/src/fxcodec
parent3a479763796edeb8cf5acc8735a16878ad6bfeb9 (diff)
downloadpdfium-4467dea020b2c19588cc06ce1ece46cd99f3c7df.tar.xz
Rename some functions that start with underscore.
Fix misc issues along the way. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1739623002 .
Diffstat (limited to 'core/src/fxcodec')
-rw-r--r--core/src/fxcodec/codec/fx_codec_bmp.cpp40
-rw-r--r--core/src/fxcodec/codec/fx_codec_gif.cpp80
-rw-r--r--core/src/fxcodec/lbmp/fx_bmp.cpp364
-rw-r--r--core/src/fxcodec/lbmp/fx_bmp.h63
-rw-r--r--core/src/fxcodec/lgif/fx_gif.cpp480
-rw-r--r--core/src/fxcodec/lgif/fx_gif.h110
6 files changed, 485 insertions, 652 deletions
diff --git a/core/src/fxcodec/codec/fx_codec_bmp.cpp b/core/src/fxcodec/codec/fx_codec_bmp.cpp
index 042392c0d1..41a881d3ae 100644
--- a/core/src/fxcodec/codec/fx_codec_bmp.cpp
+++ b/core/src/fxcodec/codec/fx_codec_bmp.cpp
@@ -17,27 +17,27 @@ struct FXBMP_Context {
void (*m_FreeFunc)(void*);
};
extern "C" {
-static void* _bmp_alloc_func(unsigned int size) {
+static void* bmp_alloc_func(unsigned int size) {
return FX_Alloc(char, size);
}
-static void _bmp_free_func(void* p) {
+static void bmp_free_func(void* p) {
FX_Free(p);
}
};
-static void _bmp_error_data(bmp_decompress_struct_p bmp_ptr,
- const FX_CHAR* err_msg) {
+static void bmp_error_data(bmp_decompress_struct_p bmp_ptr,
+ const FX_CHAR* err_msg) {
FXSYS_strncpy((char*)bmp_ptr->err_ptr, err_msg, BMP_MAX_ERROR_SIZE - 1);
longjmp(bmp_ptr->jmpbuf, 1);
}
-static void _bmp_read_scanline(bmp_decompress_struct_p bmp_ptr,
- int32_t row_num,
- uint8_t* row_buf) {
+static void bmp_read_scanline(bmp_decompress_struct_p bmp_ptr,
+ int32_t row_num,
+ uint8_t* row_buf) {
FXBMP_Context* p = (FXBMP_Context*)bmp_ptr->context_ptr;
CCodec_BmpModule* pModule = (CCodec_BmpModule*)p->parent_ptr;
pModule->ReadScanlineCallback(p->child_ptr, row_num, row_buf);
}
-static FX_BOOL _bmp_get_data_position(bmp_decompress_struct_p bmp_ptr,
- FX_DWORD rcd_pos) {
+static FX_BOOL bmp_get_data_position(bmp_decompress_struct_p bmp_ptr,
+ FX_DWORD rcd_pos) {
FXBMP_Context* p = (FXBMP_Context*)bmp_ptr->context_ptr;
CCodec_BmpModule* pModule = (CCodec_BmpModule*)p->parent_ptr;
return pModule->InputImagePositionBufCallback(p->child_ptr, rcd_pos);
@@ -51,27 +51,27 @@ void* CCodec_BmpModule::Start(void* pModule) {
if (p == NULL) {
return NULL;
}
- p->m_AllocFunc = _bmp_alloc_func;
- p->m_FreeFunc = _bmp_free_func;
+ p->m_AllocFunc = bmp_alloc_func;
+ p->m_FreeFunc = bmp_free_func;
p->bmp_ptr = NULL;
p->parent_ptr = (void*)this;
p->child_ptr = pModule;
- p->bmp_ptr = _bmp_create_decompress();
+ p->bmp_ptr = bmp_create_decompress();
if (p->bmp_ptr == NULL) {
FX_Free(p);
return NULL;
}
p->bmp_ptr->context_ptr = (void*)p;
p->bmp_ptr->err_ptr = m_szLastError;
- p->bmp_ptr->_bmp_error_fn = _bmp_error_data;
- p->bmp_ptr->_bmp_get_row_fn = _bmp_read_scanline;
- p->bmp_ptr->_bmp_get_data_position_fn = _bmp_get_data_position;
+ p->bmp_ptr->bmp_error_fn = bmp_error_data;
+ p->bmp_ptr->bmp_get_row_fn = bmp_read_scanline;
+ p->bmp_ptr->bmp_get_data_position_fn = bmp_get_data_position;
return p;
}
void CCodec_BmpModule::Finish(void* pContext) {
FXBMP_Context* p = (FXBMP_Context*)pContext;
if (p) {
- _bmp_destroy_decompress(&p->bmp_ptr);
+ bmp_destroy_decompress(&p->bmp_ptr);
p->m_FreeFunc(p);
}
}
@@ -87,7 +87,7 @@ int32_t CCodec_BmpModule::ReadHeader(void* pContext,
if (setjmp(p->bmp_ptr->jmpbuf)) {
return 0;
}
- int32_t ret = _bmp_read_header(p->bmp_ptr);
+ int32_t ret = bmp_read_header(p->bmp_ptr);
if (ret != 1) {
return ret;
}
@@ -110,16 +110,16 @@ int32_t CCodec_BmpModule::LoadImage(void* pContext) {
if (setjmp(p->bmp_ptr->jmpbuf)) {
return 0;
}
- return _bmp_decode_image(p->bmp_ptr);
+ return bmp_decode_image(p->bmp_ptr);
}
FX_DWORD CCodec_BmpModule::GetAvailInput(void* pContext,
uint8_t** avial_buf_ptr) {
FXBMP_Context* p = (FXBMP_Context*)pContext;
- return _bmp_get_avail_input(p->bmp_ptr, avial_buf_ptr);
+ return bmp_get_avail_input(p->bmp_ptr, avial_buf_ptr);
}
void CCodec_BmpModule::Input(void* pContext,
const uint8_t* src_buf,
FX_DWORD src_size) {
FXBMP_Context* p = (FXBMP_Context*)pContext;
- _bmp_input_buffer(p->bmp_ptr, (uint8_t*)src_buf, src_size);
+ bmp_input_buffer(p->bmp_ptr, (uint8_t*)src_buf, src_size);
}
diff --git a/core/src/fxcodec/codec/fx_codec_gif.cpp b/core/src/fxcodec/codec/fx_codec_gif.cpp
index af0c32ea9d..661732fb3f 100644
--- a/core/src/fxcodec/codec/fx_codec_gif.cpp
+++ b/core/src/fxcodec/codec/fx_codec_gif.cpp
@@ -17,51 +17,51 @@ struct FXGIF_Context {
void (*m_FreeFunc)(void*);
};
extern "C" {
-static void* _gif_alloc_func(unsigned int size) {
+static void* gif_alloc_func(unsigned int size) {
return FX_Alloc(char, size);
}
-static void _gif_free_func(void* p) {
+static void gif_free_func(void* p) {
FX_Free(p);
}
};
-static void _gif_error_data(gif_decompress_struct_p gif_ptr,
- const FX_CHAR* err_msg) {
+static void gif_error_data(gif_decompress_struct_p gif_ptr,
+ const FX_CHAR* err_msg) {
FXSYS_strncpy((char*)gif_ptr->err_ptr, err_msg, GIF_MAX_ERROR_SIZE - 1);
longjmp(gif_ptr->jmpbuf, 1);
}
-static uint8_t* _gif_ask_buf_for_pal(gif_decompress_struct_p gif_ptr,
- int32_t pal_size) {
+static uint8_t* gif_ask_buf_for_pal(gif_decompress_struct_p gif_ptr,
+ int32_t pal_size) {
FXGIF_Context* p = (FXGIF_Context*)gif_ptr->context_ptr;
CCodec_GifModule* pModule = (CCodec_GifModule*)p->parent_ptr;
return pModule->AskLocalPaletteBufCallback(
- p->child_ptr, _gif_get_frame_num(gif_ptr), pal_size);
+ p->child_ptr, gif_get_frame_num(gif_ptr), pal_size);
}
-static void _gif_record_current_position(gif_decompress_struct_p gif_ptr,
- FX_DWORD* cur_pos_ptr) {
+static void gif_record_current_position(gif_decompress_struct_p gif_ptr,
+ FX_DWORD* cur_pos_ptr) {
FXGIF_Context* p = (FXGIF_Context*)gif_ptr->context_ptr;
CCodec_GifModule* pModule = (CCodec_GifModule*)p->parent_ptr;
pModule->RecordCurrentPositionCallback(p->child_ptr, *cur_pos_ptr);
}
-static void _gif_read_scanline(gif_decompress_struct_p gif_ptr,
- int32_t row_num,
- uint8_t* row_buf) {
+static void gif_read_scanline(gif_decompress_struct_p gif_ptr,
+ int32_t row_num,
+ uint8_t* row_buf) {
FXGIF_Context* p = (FXGIF_Context*)gif_ptr->context_ptr;
CCodec_GifModule* pModule = (CCodec_GifModule*)p->parent_ptr;
pModule->ReadScanlineCallback(p->child_ptr, row_num, row_buf);
}
-static FX_BOOL _gif_get_record_position(gif_decompress_struct_p gif_ptr,
- FX_DWORD cur_pos,
- int32_t left,
- int32_t top,
- int32_t width,
- int32_t height,
- int32_t pal_num,
- void* pal_ptr,
- int32_t delay_time,
- FX_BOOL user_input,
- int32_t trans_index,
- int32_t disposal_method,
- FX_BOOL interlace) {
+static FX_BOOL gif_get_record_position(gif_decompress_struct_p gif_ptr,
+ FX_DWORD cur_pos,
+ int32_t left,
+ int32_t top,
+ int32_t width,
+ int32_t height,
+ int32_t pal_num,
+ void* pal_ptr,
+ int32_t delay_time,
+ FX_BOOL user_input,
+ int32_t trans_index,
+ int32_t disposal_method,
+ FX_BOOL interlace) {
FXGIF_Context* p = (FXGIF_Context*)gif_ptr->context_ptr;
CCodec_GifModule* pModule = (CCodec_GifModule*)p->parent_ptr;
return pModule->InputRecordPositionBufCallback(
@@ -75,29 +75,29 @@ void* CCodec_GifModule::Start(void* pModule) {
return NULL;
}
FXSYS_memset(p, 0, sizeof(FXGIF_Context));
- p->m_AllocFunc = _gif_alloc_func;
- p->m_FreeFunc = _gif_free_func;
+ p->m_AllocFunc = gif_alloc_func;
+ p->m_FreeFunc = gif_free_func;
p->gif_ptr = NULL;
p->parent_ptr = (void*)this;
p->child_ptr = pModule;
- p->gif_ptr = _gif_create_decompress();
+ p->gif_ptr = gif_create_decompress();
if (p->gif_ptr == NULL) {
FX_Free(p);
return NULL;
}
p->gif_ptr->context_ptr = (void*)p;
p->gif_ptr->err_ptr = m_szLastError;
- p->gif_ptr->_gif_error_fn = _gif_error_data;
- p->gif_ptr->_gif_ask_buf_for_pal_fn = _gif_ask_buf_for_pal;
- p->gif_ptr->_gif_record_current_position_fn = _gif_record_current_position;
- p->gif_ptr->_gif_get_row_fn = _gif_read_scanline;
- p->gif_ptr->_gif_get_record_position_fn = _gif_get_record_position;
+ p->gif_ptr->gif_error_fn = gif_error_data;
+ p->gif_ptr->gif_ask_buf_for_pal_fn = gif_ask_buf_for_pal;
+ p->gif_ptr->gif_record_current_position_fn = gif_record_current_position;
+ p->gif_ptr->gif_get_row_fn = gif_read_scanline;
+ p->gif_ptr->gif_get_record_position_fn = gif_get_record_position;
return p;
}
void CCodec_GifModule::Finish(void* pContext) {
FXGIF_Context* p = (FXGIF_Context*)pContext;
if (p) {
- _gif_destroy_decompress(&p->gif_ptr);
+ gif_destroy_decompress(&p->gif_ptr);
p->m_FreeFunc(p);
}
}
@@ -112,7 +112,7 @@ int32_t CCodec_GifModule::ReadHeader(void* pContext,
if (setjmp(p->gif_ptr->jmpbuf)) {
return 0;
}
- int32_t ret = _gif_read_header(p->gif_ptr);
+ int32_t ret = gif_read_header(p->gif_ptr);
if (ret != 1) {
return ret;
}
@@ -130,11 +130,11 @@ int32_t CCodec_GifModule::LoadFrameInfo(void* pContext, int* frame_num) {
if (setjmp(p->gif_ptr->jmpbuf)) {
return 0;
}
- int32_t ret = _gif_get_frame(p->gif_ptr);
+ int32_t ret = gif_get_frame(p->gif_ptr);
if (ret != 1) {
return ret;
}
- *frame_num = _gif_get_frame_num(p->gif_ptr);
+ *frame_num = gif_get_frame_num(p->gif_ptr);
return 1;
}
int32_t CCodec_GifModule::LoadFrame(void* pContext,
@@ -144,7 +144,7 @@ int32_t CCodec_GifModule::LoadFrame(void* pContext,
if (setjmp(p->gif_ptr->jmpbuf)) {
return 0;
}
- int32_t ret = _gif_load_frame(p->gif_ptr, frame_num);
+ int32_t ret = gif_load_frame(p->gif_ptr, frame_num);
if (ret == 1) {
if (pAttribute) {
pAttribute->m_nGifLeft =
@@ -177,11 +177,11 @@ int32_t CCodec_GifModule::LoadFrame(void* pContext,
FX_DWORD CCodec_GifModule::GetAvailInput(void* pContext,
uint8_t** avial_buf_ptr) {
FXGIF_Context* p = (FXGIF_Context*)pContext;
- return _gif_get_avail_input(p->gif_ptr, avial_buf_ptr);
+ return gif_get_avail_input(p->gif_ptr, avial_buf_ptr);
}
void CCodec_GifModule::Input(void* pContext,
const uint8_t* src_buf,
FX_DWORD src_size) {
FXGIF_Context* p = (FXGIF_Context*)pContext;
- _gif_input_buffer(p->gif_ptr, (uint8_t*)src_buf, src_size);
+ gif_input_buffer(p->gif_ptr, (uint8_t*)src_buf, src_size);
}
diff --git a/core/src/fxcodec/lbmp/fx_bmp.cpp b/core/src/fxcodec/lbmp/fx_bmp.cpp
index 2a0e227e46..07e83a1618 100644
--- a/core/src/fxcodec/lbmp/fx_bmp.cpp
+++ b/core/src/fxcodec/lbmp/fx_bmp.cpp
@@ -13,30 +13,32 @@ namespace {
const size_t kBmpCoreHeaderSize = 12;
const size_t kBmpInfoHeaderSize = 40;
-} // namespace
-
-FX_DWORD _GetDWord_LSBFirst(uint8_t* p) {
+// TODO(thestig): Replace with FXDWORD_GET_LSBFIRST?
+FX_DWORD GetDWord_LSBFirst(uint8_t* p) {
return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
}
-FX_WORD _GetWord_LSBFirst(uint8_t* p) {
- return p[0] | (p[1] << 8);
-}
-void _SetDWord_LSBFirst(uint8_t* p, FX_DWORD v) {
+
+void SetDWord_LSBFirst(uint8_t* p, FX_DWORD v) {
p[0] = (uint8_t)v;
p[1] = (uint8_t)(v >> 8);
p[2] = (uint8_t)(v >> 16);
p[3] = (uint8_t)(v >> 24);
}
-void _SetWord_LSBFirst(uint8_t* p, FX_WORD v) {
+} // namespace
+
+FX_WORD GetWord_LSBFirst(uint8_t* p) {
+ return p[0] | (p[1] << 8);
+}
+void SetWord_LSBFirst(uint8_t* p, FX_WORD v) {
p[0] = (uint8_t)v;
p[1] = (uint8_t)(v >> 8);
}
-void _bmp_error(bmp_decompress_struct_p bmp_ptr, const FX_CHAR* err_msg) {
- if (bmp_ptr && bmp_ptr->_bmp_error_fn) {
- bmp_ptr->_bmp_error_fn(bmp_ptr, err_msg);
+void bmp_error(bmp_decompress_struct_p bmp_ptr, const FX_CHAR* err_msg) {
+ if (bmp_ptr && bmp_ptr->bmp_error_fn) {
+ bmp_ptr->bmp_error_fn(bmp_ptr, err_msg);
}
}
-bmp_decompress_struct_p _bmp_create_decompress() {
+bmp_decompress_struct_p bmp_create_decompress() {
bmp_decompress_struct_p bmp_ptr = FX_Alloc(bmp_decompress_struct, 1);
if (bmp_ptr == NULL) {
return NULL;
@@ -46,7 +48,7 @@ bmp_decompress_struct_p _bmp_create_decompress() {
bmp_ptr->bmp_header_ptr = FX_Alloc(BmpFileHeader, 1);
return bmp_ptr;
}
-void _bmp_destroy_decompress(bmp_decompress_struct_pp bmp_ptr_ptr) {
+void bmp_destroy_decompress(bmp_decompress_struct_pp bmp_ptr_ptr) {
if (bmp_ptr_ptr == NULL || *bmp_ptr_ptr == NULL) {
return;
}
@@ -59,7 +61,7 @@ void _bmp_destroy_decompress(bmp_decompress_struct_pp bmp_ptr_ptr) {
FX_Free(bmp_ptr->bmp_header_ptr);
FX_Free(bmp_ptr);
}
-int32_t _bmp_read_header(bmp_decompress_struct_p bmp_ptr) {
+int32_t bmp_read_header(bmp_decompress_struct_p bmp_ptr) {
if (bmp_ptr == NULL) {
return 0;
}
@@ -67,16 +69,16 @@ int32_t _bmp_read_header(bmp_decompress_struct_p bmp_ptr) {
if (bmp_ptr->decode_status == BMP_D_STATUS_HEADER) {
ASSERT(sizeof(BmpFileHeader) == 14);
BmpFileHeader* bmp_header_ptr = NULL;
- if (_bmp_read_data(bmp_ptr, (uint8_t**)&bmp_header_ptr, 14) == NULL) {
+ if (bmp_read_data(bmp_ptr, (uint8_t**)&bmp_header_ptr, 14) == NULL) {
return 2;
}
bmp_ptr->bmp_header_ptr->bfType =
- _GetWord_LSBFirst((uint8_t*)&bmp_header_ptr->bfType);
+ GetWord_LSBFirst((uint8_t*)&bmp_header_ptr->bfType);
bmp_ptr->bmp_header_ptr->bfOffBits =
- _GetDWord_LSBFirst((uint8_t*)&bmp_header_ptr->bfOffBits);
- bmp_ptr->data_size = _GetDWord_LSBFirst((uint8_t*)&bmp_header_ptr->bfSize);
+ GetDWord_LSBFirst((uint8_t*)&bmp_header_ptr->bfOffBits);
+ bmp_ptr->data_size = GetDWord_LSBFirst((uint8_t*)&bmp_header_ptr->bfSize);
if (bmp_ptr->bmp_header_ptr->bfType != BMP_SIGNATURE) {
- _bmp_error(bmp_ptr, "Not A Bmp Image");
+ bmp_error(bmp_ptr, "Not A Bmp Image");
return 0;
}
if (bmp_ptr->avail_in < sizeof(FX_DWORD)) {
@@ -84,7 +86,7 @@ int32_t _bmp_read_header(bmp_decompress_struct_p bmp_ptr) {
return 2;
}
bmp_ptr->img_ifh_size =
- _GetDWord_LSBFirst(bmp_ptr->next_in + bmp_ptr->skip_size);
+ GetDWord_LSBFirst(bmp_ptr->next_in + bmp_ptr->skip_size);
bmp_ptr->pal_type = 0;
static_assert(sizeof(BmpCoreHeader) == kBmpCoreHeaderSize,
"BmpCoreHeader has wrong size");
@@ -94,40 +96,40 @@ int32_t _bmp_read_header(bmp_decompress_struct_p bmp_ptr) {
case kBmpCoreHeaderSize: {
bmp_ptr->pal_type = 1;
BmpCoreHeaderPtr bmp_core_header_ptr = NULL;
- if (_bmp_read_data(bmp_ptr, (uint8_t**)&bmp_core_header_ptr,
- bmp_ptr->img_ifh_size) == NULL) {
+ if (bmp_read_data(bmp_ptr, (uint8_t**)&bmp_core_header_ptr,
+ bmp_ptr->img_ifh_size) == NULL) {
bmp_ptr->skip_size = skip_size_org;
return 2;
}
- bmp_ptr->width = (FX_DWORD)_GetWord_LSBFirst(
- (uint8_t*)&bmp_core_header_ptr->bcWidth);
- bmp_ptr->height = (FX_DWORD)_GetWord_LSBFirst(
- (uint8_t*)&bmp_core_header_ptr->bcHeight);
+ bmp_ptr->width =
+ GetWord_LSBFirst((uint8_t*)&bmp_core_header_ptr->bcWidth);
+ bmp_ptr->height =
+ GetWord_LSBFirst((uint8_t*)&bmp_core_header_ptr->bcHeight);
bmp_ptr->bitCounts =
- _GetWord_LSBFirst((uint8_t*)&bmp_core_header_ptr->bcBitCount);
+ GetWord_LSBFirst((uint8_t*)&bmp_core_header_ptr->bcBitCount);
bmp_ptr->compress_flag = BMP_RGB;
bmp_ptr->imgTB_flag = FALSE;
} break;
case kBmpInfoHeaderSize: {
BmpInfoHeaderPtr bmp_info_header_ptr = NULL;
- if (_bmp_read_data(bmp_ptr, (uint8_t**)&bmp_info_header_ptr,
- bmp_ptr->img_ifh_size) == NULL) {
+ if (bmp_read_data(bmp_ptr, (uint8_t**)&bmp_info_header_ptr,
+ bmp_ptr->img_ifh_size) == NULL) {
bmp_ptr->skip_size = skip_size_org;
return 2;
}
bmp_ptr->width =
- _GetDWord_LSBFirst((uint8_t*)&bmp_info_header_ptr->biWidth);
+ GetDWord_LSBFirst((uint8_t*)&bmp_info_header_ptr->biWidth);
bmp_ptr->height =
- _GetDWord_LSBFirst((uint8_t*)&bmp_info_header_ptr->biHeight);
+ GetDWord_LSBFirst((uint8_t*)&bmp_info_header_ptr->biHeight);
bmp_ptr->bitCounts =
- _GetWord_LSBFirst((uint8_t*)&bmp_info_header_ptr->biBitCount);
+ GetWord_LSBFirst((uint8_t*)&bmp_info_header_ptr->biBitCount);
bmp_ptr->compress_flag =
- _GetDWord_LSBFirst((uint8_t*)&bmp_info_header_ptr->biCompression);
+ GetDWord_LSBFirst((uint8_t*)&bmp_info_header_ptr->biCompression);
bmp_ptr->color_used =
- _GetDWord_LSBFirst((uint8_t*)&bmp_info_header_ptr->biClrUsed);
- bmp_ptr->dpi_x = (int32_t)_GetDWord_LSBFirst(
+ GetDWord_LSBFirst((uint8_t*)&bmp_info_header_ptr->biClrUsed);
+ bmp_ptr->dpi_x = (int32_t)GetDWord_LSBFirst(
(uint8_t*)&bmp_info_header_ptr->biXPelsPerMeter);
- bmp_ptr->dpi_y = (int32_t)_GetDWord_LSBFirst(
+ bmp_ptr->dpi_y = (int32_t)GetDWord_LSBFirst(
(uint8_t*)&bmp_info_header_ptr->biYPelsPerMeter);
if (bmp_ptr->height < 0) {
bmp_ptr->height = -bmp_ptr->height;
@@ -138,27 +140,26 @@ int32_t _bmp_read_header(bmp_decompress_struct_p bmp_ptr) {
if (bmp_ptr->img_ifh_size >
std::min(kBmpInfoHeaderSize, sizeof(BmpInfoHeader))) {
BmpInfoHeaderPtr bmp_info_header_ptr = NULL;
- if (_bmp_read_data(bmp_ptr, (uint8_t**)&bmp_info_header_ptr,
- bmp_ptr->img_ifh_size) == NULL) {
+ if (bmp_read_data(bmp_ptr, (uint8_t**)&bmp_info_header_ptr,
+ bmp_ptr->img_ifh_size) == NULL) {
bmp_ptr->skip_size = skip_size_org;
return 2;
}
FX_WORD biPlanes;
bmp_ptr->width =
- _GetDWord_LSBFirst((uint8_t*)&bmp_info_header_ptr->biWidth);
+ GetDWord_LSBFirst((uint8_t*)&bmp_info_header_ptr->biWidth);
bmp_ptr->height =
- _GetDWord_LSBFirst((uint8_t*)&bmp_info_header_ptr->biHeight);
+ GetDWord_LSBFirst((uint8_t*)&bmp_info_header_ptr->biHeight);
bmp_ptr->bitCounts =
- _GetWord_LSBFirst((uint8_t*)&bmp_info_header_ptr->biBitCount);
+ GetWord_LSBFirst((uint8_t*)&bmp_info_header_ptr->biBitCount);
bmp_ptr->compress_flag =
- _GetDWord_LSBFirst((uint8_t*)&bmp_info_header_ptr->biCompression);
+ GetDWord_LSBFirst((uint8_t*)&bmp_info_header_ptr->biCompression);
bmp_ptr->color_used =
- _GetDWord_LSBFirst((uint8_t*)&bmp_info_header_ptr->biClrUsed);
- biPlanes =
- _GetWord_LSBFirst((uint8_t*)&bmp_info_header_ptr->biPlanes);
- bmp_ptr->dpi_x = _GetDWord_LSBFirst(
+ GetDWord_LSBFirst((uint8_t*)&bmp_info_header_ptr->biClrUsed);
+ biPlanes = GetWord_LSBFirst((uint8_t*)&bmp_info_header_ptr->biPlanes);
+ bmp_ptr->dpi_x = GetDWord_LSBFirst(
(uint8_t*)&bmp_info_header_ptr->biXPelsPerMeter);
- bmp_ptr->dpi_y = _GetDWord_LSBFirst(
+ bmp_ptr->dpi_y = GetDWord_LSBFirst(
(uint8_t*)&bmp_info_header_ptr->biYPelsPerMeter);
if (bmp_ptr->height < 0) {
bmp_ptr->height = -bmp_ptr->height;
@@ -169,7 +170,7 @@ int32_t _bmp_read_header(bmp_decompress_struct_p bmp_ptr) {
break;
}
}
- _bmp_error(bmp_ptr, "Unsupported Bmp File");
+ bmp_error(bmp_ptr, "Unsupported Bmp File");
return 0;
}
}
@@ -182,18 +183,18 @@ int32_t _bmp_read_header(bmp_decompress_struct_p bmp_ptr) {
case 16:
case 24: {
if (bmp_ptr->color_used > ((FX_DWORD)1) << bmp_ptr->bitCounts) {
- _bmp_error(bmp_ptr, "The Bmp File Is Corrupt");
+ bmp_error(bmp_ptr, "The Bmp File Is Corrupt");
return 0;
}
}
case 32: {
if (bmp_ptr->width <= 0 || bmp_ptr->compress_flag > BMP_BITFIELDS) {
- _bmp_error(bmp_ptr, "The Bmp File Is Corrupt");
+ bmp_error(bmp_ptr, "The Bmp File Is Corrupt");
return 0;
}
} break;
default:
- _bmp_error(bmp_ptr, "The Bmp File Is Corrupt");
+ bmp_error(bmp_ptr, "The Bmp File Is Corrupt");
return 0;
}
bmp_ptr->src_row_bytes = BMP_WIDTHBYTES(bmp_ptr->width, bmp_ptr->bitCounts);
@@ -217,47 +218,40 @@ int32_t _bmp_read_header(bmp_decompress_struct_p bmp_ptr) {
FX_Free(bmp_ptr->out_row_buffer);
bmp_ptr->out_row_buffer = FX_Alloc(uint8_t, bmp_ptr->out_row_bytes);
FXSYS_memset(bmp_ptr->out_row_buffer, 0, bmp_ptr->out_row_bytes);
- _bmp_save_decoding_status(bmp_ptr, BMP_D_STATUS_PAL);
+ bmp_save_decoding_status(bmp_ptr, BMP_D_STATUS_PAL);
}
if (bmp_ptr->decode_status == BMP_D_STATUS_PAL) {
skip_size_org = bmp_ptr->skip_size;
-#ifdef BMP_SUPPORT_BITFIELD
if (bmp_ptr->compress_flag == BMP_BITFIELDS) {
if (bmp_ptr->bitCounts != 16 && bmp_ptr->bitCounts != 32) {
- _bmp_error(bmp_ptr, "The Bmp File Is Corrupt");
+ bmp_error(bmp_ptr, "The Bmp File Is Corrupt");
return 0;
}
FX_DWORD* mask;
- if (_bmp_read_data(bmp_ptr, (uint8_t**)&mask, 3 * sizeof(FX_DWORD)) ==
+ if (bmp_read_data(bmp_ptr, (uint8_t**)&mask, 3 * sizeof(FX_DWORD)) ==
NULL) {
bmp_ptr->skip_size = skip_size_org;
return 2;
}
- bmp_ptr->mask_red = _GetDWord_LSBFirst((uint8_t*)&mask[0]);
- bmp_ptr->mask_green = _GetDWord_LSBFirst((uint8_t*)&mask[1]);
- bmp_ptr->mask_blue = _GetDWord_LSBFirst((uint8_t*)&mask[2]);
+ bmp_ptr->mask_red = GetDWord_LSBFirst((uint8_t*)&mask[0]);
+ bmp_ptr->mask_green = GetDWord_LSBFirst((uint8_t*)&mask[1]);
+ bmp_ptr->mask_blue = GetDWord_LSBFirst((uint8_t*)&mask[2]);
if (bmp_ptr->mask_red & bmp_ptr->mask_green ||
bmp_ptr->mask_red & bmp_ptr->mask_blue ||
bmp_ptr->mask_green & bmp_ptr->mask_blue) {
- _bmp_error(bmp_ptr, "The Bitfield Bmp File Is Corrupt");
+ bmp_error(bmp_ptr, "The Bitfield Bmp File Is Corrupt");
return 0;
}
if (bmp_ptr->bmp_header_ptr->bfOffBits < 26 + bmp_ptr->img_ifh_size) {
bmp_ptr->bmp_header_ptr->bfOffBits = 26 + bmp_ptr->img_ifh_size;
}
- _bmp_save_decoding_status(bmp_ptr, BMP_D_STATUS_DATA_PRE);
+ bmp_save_decoding_status(bmp_ptr, BMP_D_STATUS_DATA_PRE);
return 1;
} else if (bmp_ptr->bitCounts == 16) {
bmp_ptr->mask_red = 0x7C00;
bmp_ptr->mask_green = 0x03E0;
bmp_ptr->mask_blue = 0x001F;
}
-#else
- if (bmp_ptr->compress_flag == BMP_BITFIELDS || bmp_ptr->bitCounts == 16) {
- _bmp_error(bmp_ptr, "Unsupported Bitfield Bmp File");
- return 0;
- }
-#endif
bmp_ptr->pal_num = 0;
if (bmp_ptr->bitCounts < 16) {
bmp_ptr->pal_num = 1 << bmp_ptr->bitCounts;
@@ -266,7 +260,7 @@ int32_t _bmp_read_header(bmp_decompress_struct_p bmp_ptr) {
}
uint8_t* src_pal_ptr = NULL;
FX_DWORD src_pal_size = bmp_ptr->pal_num * (bmp_ptr->pal_type ? 3 : 4);
- if (_bmp_read_data(bmp_ptr, (uint8_t**)&src_pal_ptr, src_pal_size) ==
+ if (bmp_read_data(bmp_ptr, (uint8_t**)&src_pal_ptr, src_pal_size) ==
NULL) {
bmp_ptr->skip_size = skip_size_org;
return 2;
@@ -295,44 +289,44 @@ int32_t _bmp_read_header(bmp_decompress_struct_p bmp_ptr) {
14 + bmp_ptr->img_ifh_size +
bmp_ptr->pal_num * (bmp_ptr->pal_type ? 3 : 4);
}
- _bmp_save_decoding_status(bmp_ptr, BMP_D_STATUS_DATA_PRE);
+ bmp_save_decoding_status(bmp_ptr, BMP_D_STATUS_DATA_PRE);
}
return 1;
}
-int32_t _bmp_decode_image(bmp_decompress_struct_p bmp_ptr) {
+int32_t bmp_decode_image(bmp_decompress_struct_p bmp_ptr) {
if (bmp_ptr->decode_status == BMP_D_STATUS_DATA_PRE) {
bmp_ptr->avail_in = 0;
- if (!bmp_ptr->_bmp_get_data_position_fn(
+ if (!bmp_ptr->bmp_get_data_position_fn(
bmp_ptr, bmp_ptr->bmp_header_ptr->bfOffBits)) {
bmp_ptr->decode_status = BMP_D_STATUS_TAIL;
- _bmp_error(bmp_ptr, "The Bmp File Is Corrupt, Unexpected Stream Offset");
+ bmp_error(bmp_ptr, "The Bmp File Is Corrupt, Unexpected Stream Offset");
return 0;
}
bmp_ptr->row_num = 0;
- _bmp_save_decoding_status(bmp_ptr, BMP_D_STATUS_DATA);
+ bmp_save_decoding_status(bmp_ptr, BMP_D_STATUS_DATA);
}
if (bmp_ptr->decode_status == BMP_D_STATUS_DATA) {
switch (bmp_ptr->compress_flag) {
case BMP_RGB:
case BMP_BITFIELDS:
- return _bmp_decode_rgb(bmp_ptr);
+ return bmp_decode_rgb(bmp_ptr);
case BMP_RLE8:
- return _bmp_decode_rle8(bmp_ptr);
+ return bmp_decode_rle8(bmp_ptr);
case BMP_RLE4:
- return _bmp_decode_rle4(bmp_ptr);
+ return bmp_decode_rle4(bmp_ptr);
}
}
- _bmp_error(bmp_ptr, "Any Uncontrol Error");
+ bmp_error(bmp_ptr, "Any Uncontrol Error");
return 0;
}
-int32_t _bmp_decode_rgb(bmp_decompress_struct_p bmp_ptr) {
+int32_t bmp_decode_rgb(bmp_decompress_struct_p bmp_ptr) {
uint8_t* row_buf = bmp_ptr->out_row_buffer;
uint8_t* des_buf = NULL;
while (bmp_ptr->row_num < bmp_ptr->height) {
- if (_bmp_read_data(bmp_ptr, &des_buf, bmp_ptr->src_row_bytes) == NULL) {
+ if (bmp_read_data(bmp_ptr, &des_buf, bmp_ptr->src_row_bytes) == NULL) {
return 2;
}
- _bmp_save_decoding_status(bmp_ptr, BMP_D_STATUS_DATA);
+ bmp_save_decoding_status(bmp_ptr, BMP_D_STATUS_DATA);
switch (bmp_ptr->bitCounts) {
case 1: {
for (int32_t col = 0; col < bmp_ptr->width; col++) {
@@ -345,7 +339,6 @@ int32_t _bmp_decode_rgb(bmp_decompress_struct_p bmp_ptr) {
: ((des_buf[col >> 1] & 0xF0) >> 4);
}
} break;
-#ifdef BMP_SUPPORT_BITFIELD
case 16: {
FX_WORD* buf = (FX_WORD*)des_buf;
uint8_t blue_bits = 0;
@@ -368,13 +361,12 @@ int32_t _bmp_decode_rgb(bmp_decompress_struct_p bmp_ptr) {
green_bits -= 8;
red_bits -= 8;
for (int32_t col = 0; col < bmp_ptr->width; col++) {
- *buf = _GetWord_LSBFirst((uint8_t*)buf);
+ *buf = GetWord_LSBFirst((uint8_t*)buf);
*row_buf++ = (uint8_t)((*buf & bmp_ptr->mask_blue) << blue_bits);
*row_buf++ = (uint8_t)((*buf & bmp_ptr->mask_green) >> green_bits);
*row_buf++ = (uint8_t)((*buf++ & bmp_ptr->mask_red) >> red_bits);
}
} break;
-#endif
case 8:
case 24:
case 32:
@@ -382,61 +374,61 @@ int32_t _bmp_decode_rgb(bmp_decompress_struct_p bmp_ptr) {
break;
}
row_buf = bmp_ptr->out_row_buffer;
- bmp_ptr->_bmp_get_row_fn(bmp_ptr,
- bmp_ptr->imgTB_flag
- ? bmp_ptr->row_num++
- : (bmp_ptr->height - 1 - bmp_ptr->row_num++),
- bmp_ptr->out_row_buffer);
+ bmp_ptr->bmp_get_row_fn(bmp_ptr,
+ bmp_ptr->imgTB_flag
+ ? bmp_ptr->row_num++
+ : (bmp_ptr->height - 1 - bmp_ptr->row_num++),
+ bmp_ptr->out_row_buffer);
}
- _bmp_save_decoding_status(bmp_ptr, BMP_D_STATUS_TAIL);
+ bmp_save_decoding_status(bmp_ptr, BMP_D_STATUS_TAIL);
return 1;
}
-int32_t _bmp_decode_rle8(bmp_decompress_struct_p bmp_ptr) {
+int32_t bmp_decode_rle8(bmp_decompress_struct_p bmp_ptr) {
uint8_t* first_byte_ptr = NULL;
uint8_t* second_byte_ptr = NULL;
bmp_ptr->col_num = 0;
while (TRUE) {
FX_DWORD skip_size_org = bmp_ptr->skip_size;
- if (_bmp_read_data(bmp_ptr, &first_byte_ptr, 1) == NULL) {
+ if (bmp_read_data(bmp_ptr, &first_byte_ptr, 1) == NULL) {
return 2;
}
switch (*first_byte_ptr) {
case RLE_MARKER: {
- if (_bmp_read_data(bmp_ptr, &first_byte_ptr, 1) == NULL) {
+ if (bmp_read_data(bmp_ptr, &first_byte_ptr, 1) == NULL) {
bmp_ptr->skip_size = skip_size_org;
return 2;
}
switch (*first_byte_ptr) {
case RLE_EOL: {
if (bmp_ptr->row_num >= bmp_ptr->height) {
- _bmp_save_decoding_status(bmp_ptr, BMP_D_STATUS_TAIL);
- _bmp_error(bmp_ptr, "The Bmp File Is Corrupt");
+ bmp_save_decoding_status(bmp_ptr, BMP_D_STATUS_TAIL);
+ bmp_error(bmp_ptr, "The Bmp File Is Corrupt");
return 0;
}
- bmp_ptr->_bmp_get_row_fn(
+ bmp_ptr->bmp_get_row_fn(
bmp_ptr, bmp_ptr->imgTB_flag
? bmp_ptr->row_num++
: (bmp_ptr->height - 1 - bmp_ptr->row_num++),
bmp_ptr->out_row_buffer);
bmp_ptr->col_num = 0;
FXSYS_memset(bmp_ptr->out_row_buffer, 0, bmp_ptr->out_row_bytes);
- _bmp_save_decoding_status(bmp_ptr, BMP_D_STATUS_DATA);
+ bmp_save_decoding_status(bmp_ptr, BMP_D_STATUS_DATA);
continue;
}
case RLE_EOI: {
if (bmp_ptr->row_num < bmp_ptr->height) {
- bmp_ptr->_bmp_get_row_fn(
+ bmp_ptr->bmp_get_row_fn(
bmp_ptr, bmp_ptr->imgTB_flag
? bmp_ptr->row_num++
: (bmp_ptr->height - 1 - bmp_ptr->row_num++),
bmp_ptr->out_row_buffer);
}
- _bmp_save_decoding_status(bmp_ptr, BMP_D_STATUS_TAIL);
+ bmp_save_decoding_status(bmp_ptr, BMP_D_STATUS_TAIL);
return 1;
}
case RLE_DELTA: {
uint8_t* delta_ptr;
- if (_bmp_read_data(bmp_ptr, &delta_ptr, 2) == NULL) {
+ if (bmp_read_data(bmp_ptr, &delta_ptr, 2) == NULL) {
bmp_ptr->skip_size = skip_size_org;
return 2;
}
@@ -444,12 +436,12 @@ int32_t _bmp_decode_rle8(bmp_decompress_struct_p bmp_ptr) {
int32_t bmp_row_num_next = bmp_ptr->row_num + (int32_t)delta_ptr[1];
if (bmp_ptr->col_num >= bmp_ptr->out_row_bytes ||
bmp_row_num_next >= bmp_ptr->height) {
- _bmp_error(bmp_ptr, "The Bmp File Is Corrupt Or Not Supported");
+ bmp_error(bmp_ptr, "The Bmp File Is Corrupt Or Not Supported");
return 0;
}
while (bmp_ptr->row_num < bmp_row_num_next) {
FXSYS_memset(bmp_ptr->out_row_buffer, 0, bmp_ptr->out_row_bytes);
- bmp_ptr->_bmp_get_row_fn(
+ bmp_ptr->bmp_get_row_fn(
bmp_ptr, bmp_ptr->imgTB_flag
? bmp_ptr->row_num++
: (bmp_ptr->height - 1 - bmp_ptr->row_num++),
@@ -459,12 +451,12 @@ int32_t _bmp_decode_rle8(bmp_decompress_struct_p bmp_ptr) {
default: {
if ((int32_t)(*first_byte_ptr) >
bmp_ptr->src_row_bytes - bmp_ptr->col_num) {
- _bmp_error(bmp_ptr, "The Bmp File Is Corrupt");
+ bmp_error(bmp_ptr, "The Bmp File Is Corrupt");
return 0;
}
- if (_bmp_read_data(bmp_ptr, &second_byte_ptr,
- *first_byte_ptr & 1 ? *first_byte_ptr + 1
- : *first_byte_ptr) == NULL) {
+ if (bmp_read_data(bmp_ptr, &second_byte_ptr,
+ *first_byte_ptr & 1 ? *first_byte_ptr + 1
+ : *first_byte_ptr) == NULL) {
bmp_ptr->skip_size = skip_size_org;
return 2;
}
@@ -475,13 +467,13 @@ int32_t _bmp_decode_rle8(bmp_decompress_struct_p bmp_ptr) {
}
} break;
default: {
- if (_bmp_read_data(bmp_ptr, &second_byte_ptr, 1) == NULL) {
+ if (bmp_read_data(bmp_ptr, &second_byte_ptr, 1) == NULL) {
bmp_ptr->skip_size = skip_size_org;
return 2;
}
if ((int32_t)(*first_byte_ptr) >
bmp_ptr->src_row_bytes - bmp_ptr->col_num) {
- _bmp_error(bmp_ptr, "The Bmp File Is Corrupt");
+ bmp_error(bmp_ptr, "The Bmp File Is Corrupt");
return 0;
}
FXSYS_memset(bmp_ptr->out_row_buffer + bmp_ptr->col_num,
@@ -490,55 +482,55 @@ int32_t _bmp_decode_rle8(bmp_decompress_struct_p bmp_ptr) {
}
}
}
- _bmp_error(bmp_ptr, "Any Uncontrol Error");
+ bmp_error(bmp_ptr, "Any Uncontrol Error");
return 0;
}
-int32_t _bmp_decode_rle4(bmp_decompress_struct_p bmp_ptr) {
+int32_t bmp_decode_rle4(bmp_decompress_struct_p bmp_ptr) {
uint8_t* first_byte_ptr = NULL;
uint8_t* second_byte_ptr = NULL;
bmp_ptr->col_num = 0;
while (TRUE) {
FX_DWORD skip_size_org = bmp_ptr->skip_size;
- if (_bmp_read_data(bmp_ptr, &first_byte_ptr, 1) == NULL) {
+ if (bmp_read_data(bmp_ptr, &first_byte_ptr, 1) == NULL) {
return 2;
}
switch (*first_byte_ptr) {
case RLE_MARKER: {
- if (_bmp_read_data(bmp_ptr, &first_byte_ptr, 1) == NULL) {
+ if (bmp_read_data(bmp_ptr, &first_byte_ptr, 1) == NULL) {
bmp_ptr->skip_size = skip_size_org;
return 2;
}
switch (*first_byte_ptr) {
case RLE_EOL: {
if (bmp_ptr->row_num >= bmp_ptr->height) {
- _bmp_save_decoding_status(bmp_ptr, BMP_D_STATUS_TAIL);
- _bmp_error(bmp_ptr, "The Bmp File Is Corrupt");
+ bmp_save_decoding_status(bmp_ptr, BMP_D_STATUS_TAIL);
+ bmp_error(bmp_ptr, "The Bmp File Is Corrupt");
return 0;
}
- bmp_ptr->_bmp_get_row_fn(
+ bmp_ptr->bmp_get_row_fn(
bmp_ptr, bmp_ptr->imgTB_flag
? bmp_ptr->row_num++
: (bmp_ptr->height - 1 - bmp_ptr->row_num++),
bmp_ptr->out_row_buffer);
bmp_ptr->col_num = 0;
FXSYS_memset(bmp_ptr->out_row_buffer, 0, bmp_ptr->out_row_bytes);
- _bmp_save_decoding_status(bmp_ptr, BMP_D_STATUS_DATA);
+ bmp_save_decoding_status(bmp_ptr, BMP_D_STATUS_DATA);
continue;
}
case RLE_EOI: {
if (bmp_ptr->row_num < bmp_ptr->height) {
- bmp_ptr->_bmp_get_row_fn(
+ bmp_ptr->bmp_get_row_fn(
bmp_ptr, bmp_ptr->imgTB_flag
? bmp_ptr->row_num++
: (bmp_ptr->height - 1 - bmp_ptr->row_num++),
bmp_ptr->out_row_buffer);
}
- _bmp_save_decoding_status(bmp_ptr, BMP_D_STATUS_TAIL);
+ bmp_save_decoding_status(bmp_ptr, BMP_D_STATUS_TAIL);
return 1;
}
case RLE_DELTA: {
uint8_t* delta_ptr;
- if (_bmp_read_data(bmp_ptr, &delta_ptr, 2) == NULL) {
+ if (bmp_read_data(bmp_ptr, &delta_ptr, 2) == NULL) {
bmp_ptr->skip_size = skip_size_org;
return 2;
}
@@ -546,12 +538,12 @@ int32_t _bmp_decode_rle4(bmp_decompress_struct_p bmp_ptr) {
int32_t bmp_row_num_next = bmp_ptr->row_num + (int32_t)delta_ptr[1];
if (bmp_ptr->col_num >= bmp_ptr->out_row_bytes ||
bmp_row_num_next >= bmp_ptr->height) {
- _bmp_error(bmp_ptr, "The Bmp File Is Corrupt Or Not Supported");
+ bmp_error(bmp_ptr, "The Bmp File Is Corrupt Or Not Supported");
return 0;
}
while (bmp_ptr->row_num < bmp_row_num_next) {
FXSYS_memset(bmp_ptr->out_row_buffer, 0, bmp_ptr->out_row_bytes);
- bmp_ptr->_bmp_get_row_fn(
+ bmp_ptr->bmp_get_row_fn(
bmp_ptr, bmp_ptr->imgTB_flag
? bmp_ptr->row_num++
: (bmp_ptr->height - 1 - bmp_ptr->row_num++),
@@ -563,13 +555,13 @@ int32_t _bmp_decode_rle4(bmp_decompress_struct_p bmp_ptr) {
if ((int32_t)*first_byte_ptr >=
bmp_ptr->out_row_bytes - bmp_ptr->col_num) {
if (size + (bmp_ptr->col_num >> 1) > bmp_ptr->src_row_bytes) {
- _bmp_error(bmp_ptr, "The Bmp File Is Corrupt");
+ bmp_error(bmp_ptr, "The Bmp File Is Corrupt");
return 0;
}
*first_byte_ptr = bmp_ptr->out_row_bytes - bmp_ptr->col_num - 1;
}
- if (_bmp_read_data(bmp_ptr, &second_byte_ptr,
- size & 1 ? size + 1 : size) == NULL) {
+ if (bmp_read_data(bmp_ptr, &second_byte_ptr,
+ size & 1 ? size + 1 : size) == NULL) {
bmp_ptr->skip_size = skip_size_org;
return 2;
}
@@ -586,7 +578,7 @@ int32_t _bmp_decode_rle4(bmp_decompress_struct_p bmp_ptr) {
}
} break;
default: {
- if (_bmp_read_data(bmp_ptr, &second_byte_ptr, 1) == NULL) {
+ if (bmp_read_data(bmp_ptr, &second_byte_ptr, 1) == NULL) {
bmp_ptr->skip_size = skip_size_org;
return 2;
}
@@ -594,7 +586,7 @@ int32_t _bmp_decode_rle4(bmp_decompress_struct_p bmp_ptr) {
bmp_ptr->out_row_bytes - bmp_ptr->col_num) {
uint8_t size = (uint8_t)(((FX_WORD)(*first_byte_ptr) + 1) >> 1);
if (size + (bmp_ptr->col_num >> 1) > bmp_ptr->src_row_bytes) {
- _bmp_error(bmp_ptr, "The Bmp File Is Corrupt");
+ bmp_error(bmp_ptr, "The Bmp File Is Corrupt");
return 0;
}
*first_byte_ptr = bmp_ptr->out_row_bytes - bmp_ptr->col_num - 1;
@@ -611,12 +603,12 @@ int32_t _bmp_decode_rle4(bmp_decompress_struct_p bmp_ptr) {
}
}
}
- _bmp_error(bmp_ptr, "Any Uncontrol Error");
+ bmp_error(bmp_ptr, "Any Uncontrol Error");
return 0;
}
-uint8_t* _bmp_read_data(bmp_decompress_struct_p bmp_ptr,
- uint8_t** des_buf_pp,
- FX_DWORD data_size) {
+uint8_t* bmp_read_data(bmp_decompress_struct_p bmp_ptr,
+ uint8_t** des_buf_pp,
+ FX_DWORD data_size) {
if (bmp_ptr == NULL || bmp_ptr->avail_in < bmp_ptr->skip_size + data_size) {
return NULL;
}
@@ -624,22 +616,21 @@ uint8_t* _bmp_read_data(bmp_decompress_struct_p bmp_ptr,
bmp_ptr->skip_size += data_size;
return *des_buf_pp;
}
-void _bmp_save_decoding_status(bmp_decompress_struct_p bmp_ptr,
- int32_t status) {
+void bmp_save_decoding_status(bmp_decompress_struct_p bmp_ptr, int32_t status) {
bmp_ptr->decode_status = status;
bmp_ptr->next_in += bmp_ptr->skip_size;
bmp_ptr->avail_in -= bmp_ptr->skip_size;
bmp_ptr->skip_size = 0;
}
-void _bmp_input_buffer(bmp_decompress_struct_p bmp_ptr,
- uint8_t* src_buf,
- FX_DWORD src_size) {
+void bmp_input_buffer(bmp_decompress_struct_p bmp_ptr,
+ uint8_t* src_buf,
+ FX_DWORD src_size) {
bmp_ptr->next_in = src_buf;
bmp_ptr->avail_in = src_size;
bmp_ptr->skip_size = 0;
}
-FX_DWORD _bmp_get_avail_input(bmp_decompress_struct_p bmp_ptr,
- uint8_t** avial_buf_ptr) {
+FX_DWORD bmp_get_avail_input(bmp_decompress_struct_p bmp_ptr,
+ uint8_t** avial_buf_ptr) {
if (avial_buf_ptr) {
*avial_buf_ptr = NULL;
if (bmp_ptr->avail_in > 0) {
@@ -648,7 +639,7 @@ FX_DWORD _bmp_get_avail_input(bmp_decompress_struct_p bmp_ptr,
}
return bmp_ptr->avail_in;
}
-bmp_compress_struct_p _bmp_create_compress() {
+bmp_compress_struct_p bmp_create_compress() {
bmp_compress_struct_p bmp_ptr;
bmp_ptr = FX_Alloc(bmp_compress_struct, 1);
if (bmp_ptr) {
@@ -656,7 +647,7 @@ bmp_compress_struct_p _bmp_create_compress() {
}
return bmp_ptr;
}
-void _bmp_destroy_compress(bmp_compress_struct_p bmp_ptr) {
+void bmp_destroy_compress(bmp_compress_struct_p bmp_ptr) {
if (bmp_ptr) {
if (bmp_ptr->src_free && bmp_ptr->src_buf) {
FX_Free(bmp_ptr->src_buf);
@@ -667,49 +658,46 @@ void _bmp_destroy_compress(bmp_compress_struct_p bmp_ptr) {
static void WriteFileHeader(BmpFileHeaderPtr head_ptr, uint8_t* dst_buf) {
FX_DWORD offset;
offset = 0;
- _SetWord_LSBFirst(&dst_buf[offset], head_ptr->bfType);
+ SetWord_LSBFirst(&dst_buf[offset], head_ptr->bfType);
offset += 2;
- _SetDWord_LSBFirst(&dst_buf[offset], head_ptr->bfSize);
+ SetDWord_LSBFirst(&dst_buf[offset], head_ptr->bfSize);
offset += 4;
- _SetWord_LSBFirst(&dst_buf[offset], head_ptr->bfReserved1);
+ SetWord_LSBFirst(&dst_buf[offset], head_ptr->bfReserved1);
offset += 2;
- _SetWord_LSBFirst(&dst_buf[offset], head_ptr->bfReserved2);
+ SetWord_LSBFirst(&dst_buf[offset], head_ptr->bfReserved2);
offset += 2;
- _SetDWord_LSBFirst(&dst_buf[offset], head_ptr->bfOffBits);
+ SetDWord_LSBFirst(&dst_buf[offset], head_ptr->bfOffBits);
offset += 4;
}
static void WriteInfoHeader(BmpInfoHeaderPtr info_head_ptr, uint8_t* dst_buf) {
FX_DWORD offset;
offset = sizeof(BmpFileHeader);
- _SetDWord_LSBFirst(&dst_buf[offset], info_head_ptr->biSize);
+ SetDWord_LSBFirst(&dst_buf[offset], info_head_ptr->biSize);
offset += 4;
- _SetDWord_LSBFirst(&dst_buf[offset], (FX_DWORD)info_head_ptr->biWidth);
+ SetDWord_LSBFirst(&dst_buf[offset], info_head_ptr->biWidth);
offset += 4;
- _SetDWord_LSBFirst(&dst_buf[offset], (FX_DWORD)info_head_ptr->biHeight);
+ SetDWord_LSBFirst(&dst_buf[offset], info_head_ptr->biHeight);
offset += 4;
- _SetWord_LSBFirst(&dst_buf[offset], info_head_ptr->biPlanes);
+ SetWord_LSBFirst(&dst_buf[offset], info_head_ptr->biPlanes);
offset += 2;
- _SetWord_LSBFirst(&dst_buf[offset], info_head_ptr->biBitCount);
+ SetWord_LSBFirst(&dst_buf[offset], info_head_ptr->biBitCount);
offset += 2;
- _SetDWord_LSBFirst(&dst_buf[offset], info_head_ptr->biCompression);
+ SetDWord_LSBFirst(&dst_buf[offset], info_head_ptr->biCompression);
offset += 4;
- _SetDWord_LSBFirst(&dst_buf[offset], info_head_ptr->biSizeImage);
+ SetDWord_LSBFirst(&dst_buf[offset], info_head_ptr->biSizeImage);
offset += 4;
- _SetDWord_LSBFirst(&dst_buf[offset],
- (FX_DWORD)info_head_ptr->biXPelsPerMeter);
+ SetDWord_LSBFirst(&dst_buf[offset], info_head_ptr->biXPelsPerMeter);
offset += 4;
- _SetDWord_LSBFirst(&dst_buf[offset],
- (FX_DWORD)info_head_ptr->biYPelsPerMeter);
+ SetDWord_LSBFirst(&dst_buf[offset], info_head_ptr->biYPelsPerMeter);
offset += 4;
- _SetDWord_LSBFirst(&dst_buf[offset], info_head_ptr->biClrUsed);
+ SetDWord_LSBFirst(&dst_buf[offset], info_head_ptr->biClrUsed);
offset += 4;
- _SetDWord_LSBFirst(&dst_buf[offset], info_head_ptr->biClrImportant);
+ SetDWord_LSBFirst(&dst_buf[offset], info_head_ptr->biClrImportant);
offset += 4;
}
-#ifdef BMP_SUPPORT_BITFIELD
-static void _bmp_encode_bitfields(bmp_compress_struct_p bmp_ptr,
- uint8_t*& dst_buf,
- FX_DWORD& dst_size) {
+static void bmp_encode_bitfields(bmp_compress_struct_p bmp_ptr,
+ uint8_t*& dst_buf,
+ FX_DWORD& dst_size) {
if (bmp_ptr->info_header.biBitCount != 16 &&
bmp_ptr->info_header.biBitCount != 32) {
return;
@@ -741,11 +729,11 @@ static void _bmp_encode_bitfields(bmp_compress_struct_p bmp_ptr,
mask_green = 0x00FF00;
mask_blue = 0x0000FF;
}
- _SetDWord_LSBFirst(&dst_buf[dst_pos], mask_red);
+ SetDWord_LSBFirst(&dst_buf[dst_pos], mask_red);
dst_pos += 4;
- _SetDWord_LSBFirst(&dst_buf[dst_pos], mask_green);
+ SetDWord_LSBFirst(&dst_buf[dst_pos], mask_green);
dst_pos += 4;
- _SetDWord_LSBFirst(&dst_buf[dst_pos], mask_blue);
+ SetDWord_LSBFirst(&dst_buf[dst_pos], mask_blue);
dst_pos += 4;
bmp_ptr->file_header.bfOffBits = dst_pos;
}
@@ -782,24 +770,22 @@ static void _bmp_encode_bitfields(bmp_compress_struct_p bmp_ptr,
pix_val |= (g << green_bits) & mask_green;
pix_val |= (r << red_bits) & mask_red;
if (bmp_ptr->info_header.biBitCount == 16) {
- _SetWord_LSBFirst(&dst_buf[dst_pos], (FX_WORD)pix_val);
+ SetWord_LSBFirst(&dst_buf[dst_pos], pix_val);
dst_pos += 2;
} else {
- _SetDWord_LSBFirst(&dst_buf[dst_pos], pix_val);
+ SetDWord_LSBFirst(&dst_buf[dst_pos], pix_val);
dst_pos += 4;
}
}
}
dst_size = dst_pos;
}
-#endif
-static void _bmp_encode_rgb(bmp_compress_struct_p bmp_ptr,
- uint8_t*& dst_buf,
- FX_DWORD& dst_size) {
+
+static void bmp_encode_rgb(bmp_compress_struct_p bmp_ptr,
+ uint8_t*& dst_buf,
+ FX_DWORD& dst_size) {
if (bmp_ptr->info_header.biBitCount == 16) {
-#ifdef BMP_SUPPORT_BITFIELD
- _bmp_encode_bitfields(bmp_ptr, dst_buf, dst_size);
-#endif
+ bmp_encode_bitfields(bmp_ptr, dst_buf, dst_size);
return;
}
FX_DWORD size, dst_pos;
@@ -821,7 +807,7 @@ static void _bmp_encode_rgb(bmp_compress_struct_p bmp_ptr,
}
dst_size = dst_pos;
}
-static uint8_t _bmp_rle8_search(const uint8_t* buf, int32_t len) {
+static uint8_t bmp_rle8_search(const uint8_t* buf, int32_t len) {
uint8_t num;
num = 1;
while (num < len) {
@@ -832,9 +818,9 @@ static uint8_t _bmp_rle8_search(const uint8_t* buf, int32_t len) {
}
return num;
}
-static void _bmp_encode_rle8(bmp_compress_struct_p bmp_ptr,
- uint8_t*& dst_buf,
- FX_DWORD& dst_size) {
+static void bmp_encode_rle8(bmp_compress_struct_p bmp_ptr,
+ uint8_t*& dst_buf,
+ FX_DWORD& dst_size) {
FX_DWORD size, dst_pos, index;
uint8_t rle[2] = {0};
size = bmp_ptr->src_pitch * bmp_ptr->src_row * 2;
@@ -847,7 +833,7 @@ static void _bmp_encode_rle8(bmp_compress_struct_p bmp_ptr,
FXSYS_memset(&dst_buf[dst_pos], 0, size);
for (int32_t row_num = bmp_ptr->src_row - 1, i = 0; row_num > -1;) {
index = row_num * bmp_ptr->src_pitch;
- rle[0] = _bmp_rle8_search(&bmp_ptr->src_buf[index + i], size - index - i);
+ rle[0] = bmp_rle8_search(&bmp_ptr->src_buf[index + i], size - index - i);
rle[1] = bmp_ptr->src_buf[index + i];
if (i + rle[0] >= (int32_t)bmp_ptr->src_pitch) {
rle[0] = uint8_t(bmp_ptr->src_pitch - i);
@@ -869,7 +855,7 @@ static void _bmp_encode_rle8(bmp_compress_struct_p bmp_ptr,
dst_buf[dst_pos++] = RLE_EOI;
dst_size = dst_pos;
}
-static uint8_t _bmp_rle4_search(const uint8_t* buf, int32_t len) {
+static uint8_t bmp_rle4_search(const uint8_t* buf, int32_t len) {
uint8_t num;
num = 2;
while (num < len) {
@@ -880,9 +866,9 @@ static uint8_t _bmp_rle4_search(const uint8_t* buf, int32_t len) {
}
return num;
}
-static void _bmp_encode_rle4(bmp_compress_struct_p bmp_ptr,
- uint8_t*& dst_buf,
- FX_DWORD& dst_size) {
+static void bmp_encode_rle4(bmp_compress_struct_p bmp_ptr,
+ uint8_t*& dst_buf,
+ FX_DWORD& dst_size) {
FX_DWORD size, dst_pos, index;
uint8_t rle[2] = {0};
size = bmp_ptr->src_pitch * bmp_ptr->src_row;
@@ -896,7 +882,7 @@ static void _bmp_encode_rle4(bmp_compress_struct_p bmp_ptr,
for (int32_t row_num = bmp_ptr->src_row - 1, i = 0; row_num > -1;
rle[1] = 0) {
index = row_num * bmp_ptr->src_pitch;
- rle[0] = _bmp_rle4_search(&bmp_ptr->src_buf[index + i], size - index - i);
+ rle[0] = bmp_rle4_search(&bmp_ptr->src_buf[index + i], size - index - i);
rle[1] |= (bmp_ptr->src_buf[index + i] & 0x0f) << 4;
rle[1] |= bmp_ptr->src_buf[index + i + 1] & 0x0f;
if (i + rle[0] >= (int32_t)bmp_ptr->src_pitch) {
@@ -919,9 +905,9 @@ static void _bmp_encode_rle4(bmp_compress_struct_p bmp_ptr,
dst_buf[dst_pos++] = RLE_EOI;
dst_size = dst_pos;
}
-FX_BOOL _bmp_encode_image(bmp_compress_struct_p bmp_ptr,
- uint8_t*& dst_buf,
- FX_DWORD& dst_size) {
+FX_BOOL bmp_encode_image(bmp_compress_struct_p bmp_ptr,
+ uint8_t*& dst_buf,
+ FX_DWORD& dst_size) {
FX_DWORD head_size = sizeof(BmpFileHeader) + sizeof(BmpInfoHeader);
FX_DWORD pal_size = sizeof(FX_DWORD) * bmp_ptr->pal_num;
if (bmp_ptr->info_header.biClrUsed > 0 &&
@@ -942,18 +928,16 @@ FX_BOOL _bmp_encode_image(bmp_compress_struct_p bmp_ptr,
WriteInfoHeader(&bmp_ptr->info_header, dst_buf);
switch (bmp_ptr->info_header.biCompression) {
case BMP_RGB:
- _bmp_encode_rgb(bmp_ptr, dst_buf, dst_size);
+ bmp_encode_rgb(bmp_ptr, dst_buf, dst_size);
break;
case BMP_BITFIELDS:
-#ifdef BMP_SUPPORT_BITFIELD
- _bmp_encode_bitfields(bmp_ptr, dst_buf, dst_size);
-#endif
+ bmp_encode_bitfields(bmp_ptr, dst_buf, dst_size);
break;
case BMP_RLE8:
- _bmp_encode_rle8(bmp_ptr, dst_buf, dst_size);
+ bmp_encode_rle8(bmp_ptr, dst_buf, dst_size);
break;
case BMP_RLE4:
- _bmp_encode_rle4(bmp_ptr, dst_buf, dst_size);
+ bmp_encode_rle4(bmp_ptr, dst_buf, dst_size);
break;
default:
break;
diff --git a/core/src/fxcodec/lbmp/fx_bmp.h b/core/src/fxcodec/lbmp/fx_bmp.h
index 063b1bd757..24c94cabbe 100644
--- a/core/src/fxcodec/lbmp/fx_bmp.h
+++ b/core/src/fxcodec/lbmp/fx_bmp.h
@@ -11,7 +11,6 @@
#include "core/include/fxcrt/fx_basic.h"
-#define BMP_SUPPORT_BITFIELD
#define BMP_WIDTHBYTES(width, bitCount) ((width * bitCount) + 31) / 32 * 4
#define BMP_PAL_ENCODE(a, r, g, b) \
(((FX_DWORD)(a) << 24) | ((r) << 16) | ((g) << 8) | (b))
@@ -70,8 +69,7 @@ typedef bmp_decompress_struct_p* bmp_decompress_struct_pp;
struct tag_bmp_decompress_struct {
jmp_buf jmpbuf;
FX_CHAR* err_ptr;
- void (*_bmp_error_fn)(bmp_decompress_struct_p gif_ptr,
- const FX_CHAR* err_msg);
+ void (*bmp_error_fn)(bmp_decompress_struct_p gif_ptr, const FX_CHAR* err_msg);
void* context_ptr;
@@ -97,39 +95,37 @@ struct tag_bmp_decompress_struct {
int32_t col_num;
int32_t dpi_x;
int32_t dpi_y;
-#ifdef BMP_SUPPORT_BITFIELD
FX_DWORD mask_red;
FX_DWORD mask_green;
FX_DWORD mask_blue;
-#endif
- FX_BOOL (*_bmp_get_data_position_fn)(bmp_decompress_struct_p bmp_ptr,
+ FX_BOOL (*bmp_get_data_position_fn)(bmp_decompress_struct_p bmp_ptr,
FX_DWORD cur_pos);
- void (*_bmp_get_row_fn)(bmp_decompress_struct_p bmp_ptr,
- int32_t row_num,
- uint8_t* row_buf);
+ void (*bmp_get_row_fn)(bmp_decompress_struct_p bmp_ptr,
+ int32_t row_num,
+ uint8_t* row_buf);
uint8_t* next_in;
FX_DWORD avail_in;
FX_DWORD skip_size;
int32_t decode_status;
};
-void _bmp_error(bmp_decompress_struct_p bmp_ptr, const FX_CHAR* err_msg);
-bmp_decompress_struct_p _bmp_create_decompress();
-void _bmp_destroy_decompress(bmp_decompress_struct_pp bmp_ptr_ptr);
-int32_t _bmp_read_header(bmp_decompress_struct_p bmp_ptr);
-int32_t _bmp_decode_image(bmp_decompress_struct_p bmp_ptr);
-int32_t _bmp_decode_rgb(bmp_decompress_struct_p bmp_ptr);
-int32_t _bmp_decode_rle8(bmp_decompress_struct_p bmp_ptr);
-int32_t _bmp_decode_rle4(bmp_decompress_struct_p bmp_ptr);
-uint8_t* _bmp_read_data(bmp_decompress_struct_p bmp_ptr,
- uint8_t** des_buf_pp,
- FX_DWORD data_size);
-void _bmp_save_decoding_status(bmp_decompress_struct_p bmp_ptr, int32_t status);
-void _bmp_input_buffer(bmp_decompress_struct_p bmp_ptr,
- uint8_t* src_buf,
- FX_DWORD src_size);
-FX_DWORD _bmp_get_avail_input(bmp_decompress_struct_p bmp_ptr,
- uint8_t** avial_buf_ptr);
+void bmp_error(bmp_decompress_struct_p bmp_ptr, const FX_CHAR* err_msg);
+bmp_decompress_struct_p bmp_create_decompress();
+void bmp_destroy_decompress(bmp_decompress_struct_pp bmp_ptr_ptr);
+int32_t bmp_read_header(bmp_decompress_struct_p bmp_ptr);
+int32_t bmp_decode_image(bmp_decompress_struct_p bmp_ptr);
+int32_t bmp_decode_rgb(bmp_decompress_struct_p bmp_ptr);
+int32_t bmp_decode_rle8(bmp_decompress_struct_p bmp_ptr);
+int32_t bmp_decode_rle4(bmp_decompress_struct_p bmp_ptr);
+uint8_t* bmp_read_data(bmp_decompress_struct_p bmp_ptr,
+ uint8_t** des_buf_pp,
+ FX_DWORD data_size);
+void bmp_save_decoding_status(bmp_decompress_struct_p bmp_ptr, int32_t status);
+void bmp_input_buffer(bmp_decompress_struct_p bmp_ptr,
+ uint8_t* src_buf,
+ FX_DWORD src_size);
+FX_DWORD bmp_get_avail_input(bmp_decompress_struct_p bmp_ptr,
+ uint8_t** avial_buf_ptr);
typedef struct tag_bmp_compress_struct bmp_compress_struct;
typedef bmp_compress_struct* bmp_compress_struct_p;
typedef bmp_compress_struct_p* bmp_compress_struct_pp;
@@ -144,15 +140,16 @@ struct tag_bmp_compress_struct {
FX_BOOL src_free;
FX_DWORD* pal_ptr;
FX_WORD pal_num;
-#ifdef BMP_SUPPORT_BITFIELD
uint8_t bit_type;
-#endif
};
-bmp_compress_struct_p _bmp_create_compress();
-void _bmp_destroy_compress(bmp_compress_struct_p bmp_ptr);
-FX_BOOL _bmp_encode_image(bmp_compress_struct_p bmp_ptr,
- uint8_t*& dst_buf,
- FX_DWORD& dst_size);
+bmp_compress_struct_p bmp_create_compress();
+void bmp_destroy_compress(bmp_compress_struct_p bmp_ptr);
+FX_BOOL bmp_encode_image(bmp_compress_struct_p bmp_ptr,
+ uint8_t*& dst_buf,
+ FX_DWORD& dst_size);
+
+FX_WORD GetWord_LSBFirst(uint8_t* p);
+void SetWord_LSBFirst(uint8_t* p, FX_WORD v);
#endif // CORE_SRC_FXCODEC_LBMP_FX_BMP_H_
diff --git a/core/src/fxcodec/lgif/fx_gif.cpp b/core/src/fxcodec/lgif/fx_gif.cpp
index ffac891032..a4de72978a 100644
--- a/core/src/fxcodec/lgif/fx_gif.cpp
+++ b/core/src/fxcodec/lgif/fx_gif.cpp
@@ -5,6 +5,9 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "core/src/fxcodec/lgif/fx_gif.h"
+
+#include "core/src/fxcodec/lbmp/fx_bmp.h"
+
void CGifLZWDecoder::Input(uint8_t* src_buf, FX_DWORD src_size) {
next_in = src_buf;
avail_in = src_size;
@@ -141,9 +144,9 @@ int32_t CGifLZWDecoder::Decode(uint8_t* des_buf, FX_DWORD& des_size) {
}
return 0;
}
-static FX_BOOL _gif_grow_buf(uint8_t*& dst_buf,
- FX_DWORD& dst_len,
- FX_DWORD size) {
+static FX_BOOL gif_grow_buf(uint8_t*& dst_buf,
+ FX_DWORD& dst_len,
+ FX_DWORD size) {
if (dst_len < size) {
FX_DWORD len_org = dst_len;
while (dst_buf && dst_len < size) {
@@ -162,19 +165,19 @@ static FX_BOOL _gif_grow_buf(uint8_t*& dst_buf,
}
return TRUE;
}
-static inline void _gif_cut_index(uint8_t& val,
- FX_DWORD index,
- uint8_t index_bit,
- uint8_t index_bit_use,
- uint8_t bit_use) {
+static inline void gif_cut_index(uint8_t& val,
+ FX_DWORD index,
+ uint8_t index_bit,
+ uint8_t index_bit_use,
+ uint8_t bit_use) {
FX_DWORD cut = ((1 << (index_bit - index_bit_use)) - 1) << index_bit_use;
val |= ((index & cut) >> index_bit_use) << bit_use;
}
-static inline uint8_t _gif_cut_buf(const uint8_t* buf,
- FX_DWORD& offset,
- uint8_t bit_cut,
- uint8_t& bit_offset,
- FX_DWORD& bit_num) {
+static inline uint8_t gif_cut_buf(const uint8_t* buf,
+ FX_DWORD& offset,
+ uint8_t bit_cut,
+ uint8_t& bit_offset,
+ FX_DWORD& bit_num) {
if (bit_cut != 8) {
FX_WORD index = 0;
index |= ((1 << bit_cut) - 1) << (7 - bit_offset);
@@ -224,15 +227,15 @@ void CGifLZWEncoder::Start(uint8_t code_len,
src_offset = 0;
src_bit_offset = 0;
src_bit_num = 0;
- code_table[index_num].prefix = _gif_cut_buf(src_buf, src_offset, src_bit_cut,
- src_bit_offset, src_bit_num);
- code_table[index_num].suffix = _gif_cut_buf(src_buf, src_offset, src_bit_cut,
- src_bit_offset, src_bit_num);
+ code_table[index_num].prefix = gif_cut_buf(src_buf, src_offset, src_bit_cut,
+ src_bit_offset, src_bit_num);
+ code_table[index_num].suffix = gif_cut_buf(src_buf, src_offset, src_bit_cut,
+ src_bit_offset, src_bit_num);
}
void CGifLZWEncoder::WriteBlock(uint8_t*& dst_buf,
FX_DWORD& dst_len,
FX_DWORD& offset) {
- if (!_gif_grow_buf(dst_buf, dst_len, offset + GIF_DATA_BLOCK + 1)) {
+ if (!gif_grow_buf(dst_buf, dst_len, offset + GIF_DATA_BLOCK + 1)) {
longjmp(jmp, 1);
}
dst_buf[offset++] = index_buf_len;
@@ -250,8 +253,8 @@ void CGifLZWEncoder::EncodeString(FX_DWORD index,
if (index_buf_len == GIF_DATA_BLOCK) {
WriteBlock(dst_buf, dst_len, offset);
}
- _gif_cut_index(index_buf[index_buf_len], index, index_bit_cur, index_bit_use,
- bit_offset);
+ gif_cut_index(index_buf[index_buf_len], index, index_bit_cur, index_bit_use,
+ bit_offset);
if (index_bit_cur <= (8 - bit_offset)) {
bit_offset += index_bit_cur;
} else if (index_bit_cur <= (16 - bit_offset)) {
@@ -261,8 +264,8 @@ void CGifLZWEncoder::EncodeString(FX_DWORD index,
if (index_buf_len == GIF_DATA_BLOCK) {
WriteBlock(dst_buf, dst_len, offset);
}
- _gif_cut_index(index_buf[index_buf_len], index, index_bit_cur,
- index_bit_use, bit_offset);
+ gif_cut_index(index_buf[index_buf_len], index, index_bit_cur, index_bit_use,
+ bit_offset);
bit_offset = index_bit_cur - index_bit_use;
} else {
index_bit_use += (8 - bit_offset);
@@ -271,16 +274,16 @@ void CGifLZWEncoder::EncodeString(FX_DWORD index,
if (index_buf_len == GIF_DATA_BLOCK) {
WriteBlock(dst_buf, dst_len, offset);
}
- _gif_cut_index(index_buf[index_buf_len], index, index_bit_cur,
- index_bit_use, bit_offset);
+ gif_cut_index(index_buf[index_buf_len], index, index_bit_cur, index_bit_use,
+ bit_offset);
index_bit_use += 8;
bit_offset = 0;
index_buf_len++;
if (index_buf_len == GIF_DATA_BLOCK) {
WriteBlock(dst_buf, dst_len, offset);
}
- _gif_cut_index(index_buf[index_buf_len], index, index_bit_cur,
- index_bit_use, bit_offset);
+ gif_cut_index(index_buf[index_buf_len], index, index_bit_cur, index_bit_use,
+ bit_offset);
bit_offset = index_bit_cur - index_bit_use;
}
if (bit_offset == 8) {
@@ -315,11 +318,11 @@ FX_BOOL CGifLZWEncoder::Encode(const uint8_t* src_buf,
EncodeString(code_clear, dst_buf, dst_len, offset);
ClearTable();
code_table[index_num].prefix = suffix;
- code_table[index_num].suffix = _gif_cut_buf(
+ code_table[index_num].suffix = gif_cut_buf(
src_buf, src_offset, src_bit_cut, src_bit_offset, src_bit_num);
} else {
code_table[index_num].prefix = code_table[index_num - 1].suffix;
- code_table[index_num].suffix = _gif_cut_buf(
+ code_table[index_num].suffix = gif_cut_buf(
src_buf, src_offset, src_bit_cut, src_bit_offset, src_bit_num);
}
}
@@ -337,7 +340,7 @@ FX_BOOL CGifLZWEncoder::LookUpInTable(const uint8_t* buf,
code_table[i].suffix == code_table[index_num].suffix) {
code_table[index_num].prefix = i;
code_table[index_num].suffix =
- _gif_cut_buf(buf, offset, src_bit_cut, bit_offset, src_bit_num);
+ gif_cut_buf(buf, offset, src_bit_cut, bit_offset, src_bit_num);
table_cur = i;
return TRUE;
}
@@ -353,7 +356,7 @@ void CGifLZWEncoder::Finish(uint8_t*& dst_buf,
bit_offset = 0;
ClearTable();
}
-gif_decompress_struct_p _gif_create_decompress() {
+gif_decompress_struct_p gif_create_decompress() {
gif_decompress_struct_p gif_ptr =
(gif_decompress_struct*)FX_Alloc(uint8_t, sizeof(gif_decompress_struct));
if (gif_ptr == NULL) {
@@ -362,15 +365,11 @@ gif_decompress_struct_p _gif_create_decompress() {
FXSYS_memset(gif_ptr, 0, sizeof(gif_decompress_struct));
gif_ptr->decode_status = GIF_D_STATUS_SIG;
gif_ptr->img_ptr_arr_ptr = new CFX_ArrayTemplate<GifImage*>;
-#ifdef GIF_SUPPORT_COMMENT_EXTENSION
gif_ptr->cmt_data_ptr = new CFX_ByteString;
-#endif
-#ifdef GIF_SUPPORT_PLAIN_TEXT_EXTENSION
gif_ptr->pt_ptr_arr_ptr = new CFX_ArrayTemplate<GifPlainText*>;
-#endif
return gif_ptr;
}
-void _gif_destroy_decompress(gif_decompress_struct_pp gif_ptr_ptr) {
+void gif_destroy_decompress(gif_decompress_struct_pp gif_ptr_ptr) {
if (gif_ptr_ptr == NULL || *gif_ptr_ptr == NULL) {
return;
}
@@ -393,16 +392,8 @@ void _gif_destroy_decompress(gif_decompress_struct_pp gif_ptr_ptr) {
gif_ptr->img_ptr_arr_ptr->RemoveAll();
delete gif_ptr->img_ptr_arr_ptr;
}
-#ifdef GIF_SUPPORT_APPLICATION_EXTENSION
- FX_Free(gif_ptr->app_data);
-#endif
-#ifdef GIF_SUPPORT_COMMENT_EXTENSION
delete gif_ptr->cmt_data_ptr;
-#endif
-#ifdef GIF_SUPPORT_GRAPHIC_CONTROL_EXTENSION
FX_Free(gif_ptr->gce_ptr);
-#endif
-#ifdef GIF_SUPPORT_PLAIN_TEXT_EXTENSION
if (gif_ptr->pt_ptr_arr_ptr) {
int32_t size_pt_arr = gif_ptr->pt_ptr_arr_ptr->GetSize();
for (int32_t i = 0; i < size_pt_arr; i++) {
@@ -414,10 +405,9 @@ void _gif_destroy_decompress(gif_decompress_struct_pp gif_ptr_ptr) {
gif_ptr->pt_ptr_arr_ptr->RemoveAll();
delete gif_ptr->pt_ptr_arr_ptr;
}
-#endif
FX_Free(gif_ptr);
}
-gif_compress_struct_p _gif_create_compress() {
+gif_compress_struct_p gif_create_compress() {
gif_compress_struct_p gif_ptr =
(gif_compress_struct*)FX_Alloc(uint8_t, sizeof(gif_compress_struct));
if (gif_ptr == NULL) {
@@ -451,11 +441,6 @@ gif_compress_struct_p _gif_create_compress() {
return NULL;
}
FXSYS_memset(gif_ptr->image_info_ptr, 0, sizeof(GifImageInfo));
-#ifdef GIF_SUPPORT_APPLICATION_EXTENSION
- FXSYS_memcpy(gif_ptr->app_identify, "netscape", 8);
- FXSYS_memcpy(gif_ptr->app_authentication, "2.0", 3);
-#endif
-#ifdef GIF_SUPPORT_GRAPHIC_CONTROL_EXTENSION
gif_ptr->gce_ptr = (GifGCE*)FX_Alloc(uint8_t, sizeof(GifGCE));
if (gif_ptr->gce_ptr == NULL) {
FX_Free(gif_ptr->image_info_ptr);
@@ -465,8 +450,6 @@ gif_compress_struct_p _gif_create_compress() {
FX_Free(gif_ptr);
return NULL;
}
-#endif
-#ifdef GIF_SUPPORT_PLAIN_TEXT_EXTENSION
gif_ptr->pte_ptr = (GifPTE*)FX_Alloc(uint8_t, sizeof(GifPTE));
if (gif_ptr->pte_ptr == NULL) {
FX_Free(gif_ptr->gce_ptr);
@@ -479,10 +462,9 @@ gif_compress_struct_p _gif_create_compress() {
}
FXSYS_memset(gif_ptr->pte_ptr, 0, sizeof(GifPTE));
gif_ptr->pte_ptr->block_size = 12;
-#endif
return gif_ptr;
}
-void _gif_destroy_compress(gif_compress_struct_pp gif_ptr_ptr) {
+void gif_destroy_compress(gif_compress_struct_pp gif_ptr_ptr) {
if (gif_ptr_ptr == NULL || *gif_ptr_ptr == NULL) {
return;
}
@@ -494,44 +476,35 @@ void _gif_destroy_compress(gif_compress_struct_pp gif_ptr_ptr) {
FX_Free(gif_ptr->image_info_ptr);
FX_Free(gif_ptr->local_pal);
delete gif_ptr->img_encoder_ptr;
-#ifdef GIF_SUPPORT_APPLICATION_EXTENSION
- FX_Free(gif_ptr->app_data);
-#endif
-#ifdef GIF_SUPPORT_GRAPHIC_CONTROL_EXTENSION
FX_Free(gif_ptr->gce_ptr);
-#endif
-#ifdef GIF_SUPPORT_COMMENT_EXTENSION
FX_Free(gif_ptr->cmt_data_ptr);
-#endif
-#ifdef GIF_SUPPORT_PLAIN_TEXT_EXTENSION
FX_Free(gif_ptr->pte_ptr);
-#endif
FX_Free(gif_ptr);
}
-void _gif_error(gif_decompress_struct_p gif_ptr, const FX_CHAR* err_msg) {
- if (gif_ptr && gif_ptr->_gif_error_fn) {
- gif_ptr->_gif_error_fn(gif_ptr, err_msg);
+void gif_error(gif_decompress_struct_p gif_ptr, const FX_CHAR* err_msg) {
+ if (gif_ptr && gif_ptr->gif_error_fn) {
+ gif_ptr->gif_error_fn(gif_ptr, err_msg);
}
}
-void _gif_warn(gif_decompress_struct_p gif_ptr, const FX_CHAR* err_msg) {}
-int32_t _gif_read_header(gif_decompress_struct_p gif_ptr) {
+void gif_warn(gif_decompress_struct_p gif_ptr, const FX_CHAR* err_msg) {}
+int32_t gif_read_header(gif_decompress_struct_p gif_ptr) {
if (gif_ptr == NULL) {
return 0;
}
FX_DWORD skip_size_org = gif_ptr->skip_size;
ASSERT(sizeof(GifHeader) == 6);
GifHeader* gif_header_ptr = NULL;
- if (_gif_read_data(gif_ptr, (uint8_t**)&gif_header_ptr, 6) == NULL) {
+ if (gif_read_data(gif_ptr, (uint8_t**)&gif_header_ptr, 6) == NULL) {
return 2;
}
if (FXSYS_strncmp(gif_header_ptr->signature, GIF_SIGNATURE, 3) != 0 ||
gif_header_ptr->version[0] != '8' || gif_header_ptr->version[2] != 'a') {
- _gif_error(gif_ptr, "Not A Gif Image");
+ gif_error(gif_ptr, "Not A Gif Image");
return 0;
}
ASSERT(sizeof(GifLSD) == 7);
GifLSD* gif_lsd_ptr = NULL;
- if (_gif_read_data(gif_ptr, (uint8_t**)&gif_lsd_ptr, 7) == NULL) {
+ if (gif_read_data(gif_ptr, (uint8_t**)&gif_lsd_ptr, 7) == NULL) {
gif_ptr->skip_size = skip_size_org;
return 2;
}
@@ -541,7 +514,7 @@ int32_t _gif_read_header(gif_decompress_struct_p gif_ptr) {
ASSERT(sizeof(GifPalette) == 3);
int32_t global_pal_size = gif_ptr->global_pal_num * 3;
uint8_t* global_pal_ptr = NULL;
- if (_gif_read_data(gif_ptr, &global_pal_ptr, global_pal_size) == NULL) {
+ if (gif_read_data(gif_ptr, &global_pal_ptr, global_pal_size) == NULL) {
gif_ptr->skip_size = skip_size_org;
return 2;
}
@@ -552,13 +525,13 @@ int32_t _gif_read_header(gif_decompress_struct_p gif_ptr) {
gif_ptr->global_pal_ptr = (GifPalette*)FX_Alloc(uint8_t, global_pal_size);
FXSYS_memcpy(gif_ptr->global_pal_ptr, global_pal_ptr, global_pal_size);
}
- gif_ptr->width = (int)_GetWord_LSBFirst((uint8_t*)&gif_lsd_ptr->width);
- gif_ptr->height = (int)_GetWord_LSBFirst((uint8_t*)&gif_lsd_ptr->height);
+ gif_ptr->width = (int)GetWord_LSBFirst((uint8_t*)&gif_lsd_ptr->width);
+ gif_ptr->height = (int)GetWord_LSBFirst((uint8_t*)&gif_lsd_ptr->height);
gif_ptr->bc_index = gif_lsd_ptr->bc_index;
gif_ptr->pixel_aspect = gif_lsd_ptr->pixel_aspect;
return 1;
}
-int32_t _gif_get_frame(gif_decompress_struct_p gif_ptr) {
+int32_t gif_get_frame(gif_decompress_struct_p gif_ptr) {
if (gif_ptr == NULL) {
return 0;
}
@@ -569,69 +542,56 @@ int32_t _gif_get_frame(gif_decompress_struct_p gif_ptr) {
return 1;
case GIF_D_STATUS_SIG: {
uint8_t* sig_ptr = NULL;
- if (_gif_read_data(gif_ptr, &sig_ptr, 1) == NULL) {
+ if (gif_read_data(gif_ptr, &sig_ptr, 1) == NULL) {
return 2;
}
switch (*sig_ptr) {
case GIF_SIG_EXTENSION:
- _gif_save_decoding_status(gif_ptr, GIF_D_STATUS_EXT);
+ gif_save_decoding_status(gif_ptr, GIF_D_STATUS_EXT);
continue;
case GIF_SIG_IMAGE:
- _gif_save_decoding_status(gif_ptr, GIF_D_STATUS_IMG_INFO);
+ gif_save_decoding_status(gif_ptr, GIF_D_STATUS_IMG_INFO);
continue;
case GIF_SIG_TRAILER:
- _gif_save_decoding_status(gif_ptr, GIF_D_STATUS_TAIL);
+ gif_save_decoding_status(gif_ptr, GIF_D_STATUS_TAIL);
return 1;
default:
if (gif_ptr->avail_in) {
- _gif_warn(gif_ptr, "The Gif File has non_standard Tag!");
- _gif_save_decoding_status(gif_ptr, GIF_D_STATUS_SIG);
+ gif_warn(gif_ptr, "The Gif File has non_standard Tag!");
+ gif_save_decoding_status(gif_ptr, GIF_D_STATUS_SIG);
continue;
}
- _gif_warn(gif_ptr, "The Gif File Doesn't have Trailer Tag!");
+ gif_warn(gif_ptr, "The Gif File Doesn't have Trailer Tag!");
return 1;
}
}
case GIF_D_STATUS_EXT: {
uint8_t* ext_ptr = NULL;
- if (_gif_read_data(gif_ptr, &ext_ptr, 1) == NULL) {
+ if (gif_read_data(gif_ptr, &ext_ptr, 1) == NULL) {
return 2;
}
switch (*ext_ptr) {
-#ifdef GIF_SUPPORT_APPLICATION_EXTENSION
- case GIF_BLOCK_AE:
- _gif_save_decoding_status(gif_ptr, GIF_D_STATUS_EXT_AE);
- continue;
-#endif
-#ifdef GIF_SUPPORT_COMMENT_EXTENSION
case GIF_BLOCK_CE:
- _gif_save_decoding_status(gif_ptr, GIF_D_STATUS_EXT_CE);
+ gif_save_decoding_status(gif_ptr, GIF_D_STATUS_EXT_CE);
continue;
-#endif
-#ifdef GIF_SUPPORT_GRAPHIC_CONTROL_EXTENSION
case GIF_BLOCK_GCE:
- _gif_save_decoding_status(gif_ptr, GIF_D_STATUS_EXT_GCE);
+ gif_save_decoding_status(gif_ptr, GIF_D_STATUS_EXT_GCE);
continue;
-#endif
-#ifdef GIF_SUPPORT_PLAIN_TEXT_EXTENSION
case GIF_BLOCK_PTE:
- _gif_save_decoding_status(gif_ptr, GIF_D_STATUS_EXT_PTE);
+ gif_save_decoding_status(gif_ptr, GIF_D_STATUS_EXT_PTE);
continue;
-#endif
default: {
int32_t status = GIF_D_STATUS_EXT_UNE;
-#ifndef GIF_SUPPORT_PLAIN_TEXT_EXTENSION
if (*ext_ptr == GIF_BLOCK_PTE) {
status = GIF_D_STATUS_EXT_PTE;
}
-#endif
- _gif_save_decoding_status(gif_ptr, status);
+ gif_save_decoding_status(gif_ptr, status);
continue;
}
}
}
case GIF_D_STATUS_IMG_INFO: {
- ret = _gif_decode_image_info(gif_ptr);
+ ret = gif_decode_image_info(gif_ptr);
if (ret != 1) {
return ret;
}
@@ -641,25 +601,25 @@ int32_t _gif_get_frame(gif_decompress_struct_p gif_ptr) {
uint8_t* data_size_ptr = NULL;
uint8_t* data_ptr = NULL;
FX_DWORD skip_size_org = gif_ptr->skip_size;
- if (_gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
+ if (gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
return 2;
}
while (*data_size_ptr != GIF_BLOCK_TERMINAL) {
- if (_gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) == NULL) {
+ if (gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) == NULL) {
gif_ptr->skip_size = skip_size_org;
return 2;
}
- _gif_save_decoding_status(gif_ptr, GIF_D_STATUS_IMG_DATA);
+ gif_save_decoding_status(gif_ptr, GIF_D_STATUS_IMG_DATA);
skip_size_org = gif_ptr->skip_size;
- if (_gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
+ if (gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
return 2;
}
}
- _gif_save_decoding_status(gif_ptr, GIF_D_STATUS_SIG);
+ gif_save_decoding_status(gif_ptr, GIF_D_STATUS_SIG);
continue;
}
default: {
- ret = _gif_decode_extension(gif_ptr);
+ ret = gif_decode_extension(gif_ptr);
if (ret != 1) {
return ret;
}
@@ -669,63 +629,29 @@ int32_t _gif_get_frame(gif_decompress_struct_p gif_ptr) {
}
return 1;
}
-void _gif_takeover_gce_ptr(gif_decompress_struct_p gif_ptr,
- GifGCE** gce_ptr_ptr) {
+void gif_takeover_gce_ptr(gif_decompress_struct_p gif_ptr,
+ GifGCE** gce_ptr_ptr) {
*gce_ptr_ptr = NULL;
-#ifdef GIF_SUPPORT_GRAPHIC_CONTROL_EXTENSION
if (gif_ptr->gce_ptr && gce_ptr_ptr) {
*gce_ptr_ptr = gif_ptr->gce_ptr;
gif_ptr->gce_ptr = NULL;
}
-#endif
}
-int32_t _gif_decode_extension(gif_decompress_struct_p gif_ptr) {
+int32_t gif_decode_extension(gif_decompress_struct_p gif_ptr) {
uint8_t* data_size_ptr = NULL;
uint8_t* data_ptr = NULL;
FX_DWORD skip_size_org = gif_ptr->skip_size;
switch (gif_ptr->decode_status) {
-#ifdef GIF_SUPPORT_APPLICATION_EXTENSION
- case GIF_D_STATUS_EXT_AE: {
- ASSERT(sizeof(GifAE) == 12);
- GifAE* gif_ae_ptr = NULL;
- if (_gif_read_data(gif_ptr, (uint8_t**)&gif_ae_ptr, 12) == NULL) {
- return 2;
- }
- CFX_ByteString gif_ae_data_str;
- if (_gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
- gif_ptr->skip_size = skip_size_org;
- return 2;
- }
- while (*data_size_ptr != GIF_BLOCK_TERMINAL) {
- uint8_t data_size = *data_size_ptr;
- if (_gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) == NULL ||
- _gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
- gif_ptr->skip_size = skip_size_org;
- return 2;
- }
- gif_ae_data_str += CFX_ByteString((const uint8_t*)data_ptr, data_size);
- }
- FXSYS_memcpy(gif_ptr->app_identify, gif_ae_ptr->app_identify, 8);
- FXSYS_memcpy(gif_ptr->app_authentication, gif_ae_ptr->app_authentication,
- 3);
- gif_ptr->app_data_size = gif_ae_data_str.GetLength();
- FX_Free(gif_ptr->app_data);
- gif_ptr->app_data = FX_Alloc(uint8_t, gif_ptr->app_data_size);
- FXSYS_memcpy(gif_ptr->app_data, const uint8_t*(gif_ae_data_str),
- gif_ptr->app_data_size);
- } break;
-#endif
-#ifdef GIF_SUPPORT_COMMENT_EXTENSION
case GIF_D_STATUS_EXT_CE: {
- if (_gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
+ if (gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
gif_ptr->skip_size = skip_size_org;
return 2;
}
gif_ptr->cmt_data_ptr->Empty();
while (*data_size_ptr != GIF_BLOCK_TERMINAL) {
uint8_t data_size = *data_size_ptr;
- if (_gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) == NULL ||
- _gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
+ if (gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) == NULL ||
+ gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
gif_ptr->skip_size = skip_size_org;
return 2;
}
@@ -733,33 +659,31 @@ int32_t _gif_decode_extension(gif_decompress_struct_p gif_ptr) {
CFX_ByteString((const FX_CHAR*)data_ptr, data_size);
}
} break;
-#endif
-#ifdef GIF_SUPPORT_PLAIN_TEXT_EXTENSION
case GIF_D_STATUS_EXT_PTE: {
ASSERT(sizeof(GifPTE) == 13);
GifPTE* gif_pte_ptr = NULL;
- if (_gif_read_data(gif_ptr, (uint8_t**)&gif_pte_ptr, 13) == NULL) {
+ if (gif_read_data(gif_ptr, (uint8_t**)&gif_pte_ptr, 13) == NULL) {
return 2;
}
GifPlainText* gif_pt_ptr = FX_Alloc(GifPlainText, 1);
FXSYS_memset(gif_pt_ptr, 0, sizeof(GifPlainText));
- _gif_takeover_gce_ptr(gif_ptr, &gif_pt_ptr->gce_ptr);
+ gif_takeover_gce_ptr(gif_ptr, &gif_pt_ptr->gce_ptr);
gif_pt_ptr->pte_ptr = (GifPTE*)FX_Alloc(uint8_t, sizeof(GifPTE));
gif_pt_ptr->string_ptr = new CFX_ByteString;
gif_pt_ptr->pte_ptr->block_size = gif_pte_ptr->block_size;
gif_pt_ptr->pte_ptr->grid_left =
- _GetWord_LSBFirst((uint8_t*)&gif_pte_ptr->grid_left);
+ GetWord_LSBFirst((uint8_t*)&gif_pte_ptr->grid_left);
gif_pt_ptr->pte_ptr->grid_top =
- _GetWord_LSBFirst((uint8_t*)&gif_pte_ptr->grid_top);
+ GetWord_LSBFirst((uint8_t*)&gif_pte_ptr->grid_top);
gif_pt_ptr->pte_ptr->grid_width =
- _GetWord_LSBFirst((uint8_t*)&gif_pte_ptr->grid_width);
+ GetWord_LSBFirst((uint8_t*)&gif_pte_ptr->grid_width);
gif_pt_ptr->pte_ptr->grid_height =
- _GetWord_LSBFirst((uint8_t*)&gif_pte_ptr->grid_height);
+ GetWord_LSBFirst((uint8_t*)&gif_pte_ptr->grid_height);
gif_pt_ptr->pte_ptr->char_width = gif_pte_ptr->char_width;
gif_pt_ptr->pte_ptr->char_height = gif_pte_ptr->char_height;
gif_pt_ptr->pte_ptr->fc_index = gif_pte_ptr->fc_index;
gif_pt_ptr->pte_ptr->bc_index = gif_pte_ptr->bc_index;
- if (_gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
+ if (gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
gif_ptr->skip_size = skip_size_org;
if (gif_pt_ptr) {
FX_Free(gif_pt_ptr->gce_ptr);
@@ -771,8 +695,8 @@ int32_t _gif_decode_extension(gif_decompress_struct_p gif_ptr) {
}
while (*data_size_ptr != GIF_BLOCK_TERMINAL) {
uint8_t data_size = *data_size_ptr;
- if (_gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) == NULL ||
- _gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
+ if (gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) == NULL ||
+ gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
gif_ptr->skip_size = skip_size_org;
if (gif_pt_ptr) {
FX_Free(gif_pt_ptr->gce_ptr);
@@ -787,12 +711,10 @@ int32_t _gif_decode_extension(gif_decompress_struct_p gif_ptr) {
}
gif_ptr->pt_ptr_arr_ptr->Add(gif_pt_ptr);
} break;
-#endif
-#ifdef GIF_SUPPORT_GRAPHIC_CONTROL_EXTENSION
case GIF_D_STATUS_EXT_GCE: {
ASSERT(sizeof(GifGCE) == 5);
GifGCE* gif_gce_ptr = NULL;
- if (_gif_read_data(gif_ptr, (uint8_t**)&gif_gce_ptr, 6) == NULL) {
+ if (gif_read_data(gif_ptr, (uint8_t**)&gif_gce_ptr, 6) == NULL) {
return 2;
}
if (gif_ptr->gce_ptr == NULL) {
@@ -801,43 +723,38 @@ int32_t _gif_decode_extension(gif_decompress_struct_p gif_ptr) {
gif_ptr->gce_ptr->block_size = gif_gce_ptr->block_size;
gif_ptr->gce_ptr->gce_flag = gif_gce_ptr->gce_flag;
gif_ptr->gce_ptr->delay_time =
- _GetWord_LSBFirst((uint8_t*)&gif_gce_ptr->delay_time);
+ GetWord_LSBFirst((uint8_t*)&gif_gce_ptr->delay_time);
gif_ptr->gce_ptr->trans_index = gif_gce_ptr->trans_index;
} break;
-#endif
default: {
-#ifndef GIF_SUPPORT_PLAIN_TEXT_EXTENSION
-#ifdef GIF_SUPPORT_GRAPHIC_CONTROL_EXTENSION
if (gif_ptr->decode_status == GIF_D_STATUS_EXT_PTE) {
FX_Free(gif_ptr->gce_ptr);
gif_ptr->gce_ptr = NULL;
}
-#endif
-#endif
- if (_gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
+ if (gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
return 2;
}
while (*data_size_ptr != GIF_BLOCK_TERMINAL) {
- if (_gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) == NULL ||
- _gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
+ if (gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) == NULL ||
+ gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
gif_ptr->skip_size = skip_size_org;
return 2;
}
}
}
}
- _gif_save_decoding_status(gif_ptr, GIF_D_STATUS_SIG);
+ gif_save_decoding_status(gif_ptr, GIF_D_STATUS_SIG);
return 1;
}
-int32_t _gif_decode_image_info(gif_decompress_struct_p gif_ptr) {
+int32_t gif_decode_image_info(gif_decompress_struct_p gif_ptr) {
if (gif_ptr->width == 0 || gif_ptr->height == 0) {
- _gif_error(gif_ptr, "No Image Header Info");
+ gif_error(gif_ptr, "No Image Header Info");
return 0;
}
FX_DWORD skip_size_org = gif_ptr->skip_size;
ASSERT(sizeof(GifImageInfo) == 9);
GifImageInfo* gif_img_info_ptr = NULL;
- if (_gif_read_data(gif_ptr, (uint8_t**)&gif_img_info_ptr, 9) == NULL) {
+ if (gif_read_data(gif_ptr, (uint8_t**)&gif_img_info_ptr, 9) == NULL) {
return 2;
}
GifImage* gif_image_ptr = (GifImage*)FX_Alloc(uint8_t, sizeof(GifImage));
@@ -845,13 +762,13 @@ int32_t _gif_decode_image_info(gif_decompress_struct_p gif_ptr) {
gif_image_ptr->image_info_ptr =
(GifImageInfo*)FX_Alloc(uint8_t, sizeof(GifImageInfo));
gif_image_ptr->image_info_ptr->left =
- _GetWord_LSBFirst((uint8_t*)&gif_img_info_ptr->left);
+ GetWord_LSBFirst((uint8_t*)&gif_img_info_ptr->left);
gif_image_ptr->image_info_ptr->top =
- _GetWord_LSBFirst((uint8_t*)&gif_img_info_ptr->top);
+ GetWord_LSBFirst((uint8_t*)&gif_img_info_ptr->top);
gif_image_ptr->image_info_ptr->width =
- _GetWord_LSBFirst((uint8_t*)&gif_img_info_ptr->width);
+ GetWord_LSBFirst((uint8_t*)&gif_img_info_ptr->width);
gif_image_ptr->image_info_ptr->height =
- _GetWord_LSBFirst((uint8_t*)&gif_img_info_ptr->height);
+ GetWord_LSBFirst((uint8_t*)&gif_img_info_ptr->height);
gif_image_ptr->image_info_ptr->local_flag = gif_img_info_ptr->local_flag;
if (gif_image_ptr->image_info_ptr->left +
gif_image_ptr->image_info_ptr->width >
@@ -862,7 +779,7 @@ int32_t _gif_decode_image_info(gif_decompress_struct_p gif_ptr) {
FX_Free(gif_image_ptr->image_info_ptr);
FX_Free(gif_image_ptr->image_row_buf);
FX_Free(gif_image_ptr);
- _gif_error(gif_ptr, "Image Data Out Of LSD, The File May Be Corrupt");
+ gif_error(gif_ptr, "Image Data Out Of LSD, The File May Be Corrupt");
return 0;
}
GifLF* gif_img_info_lf_ptr = (GifLF*)&gif_img_info_ptr->local_flag;
@@ -870,7 +787,7 @@ int32_t _gif_decode_image_info(gif_decompress_struct_p gif_ptr) {
ASSERT(sizeof(GifPalette) == 3);
int32_t loc_pal_size = (2 << gif_img_info_lf_ptr->pal_bits) * 3;
uint8_t* loc_pal_ptr = NULL;
- if (_gif_read_data(gif_ptr, &loc_pal_ptr, loc_pal_size) == NULL) {
+ if (gif_read_data(gif_ptr, &loc_pal_ptr, loc_pal_size) == NULL) {
gif_ptr->skip_size = skip_size_org;
FX_Free(gif_image_ptr->image_info_ptr);
FX_Free(gif_image_ptr->image_row_buf);
@@ -878,14 +795,14 @@ int32_t _gif_decode_image_info(gif_decompress_struct_p gif_ptr) {
return 2;
}
gif_image_ptr->local_pal_ptr =
- (GifPalette*)gif_ptr->_gif_ask_buf_for_pal_fn(gif_ptr, loc_pal_size);
+ (GifPalette*)gif_ptr->gif_ask_buf_for_pal_fn(gif_ptr, loc_pal_size);
if (gif_image_ptr->local_pal_ptr) {
FXSYS_memcpy((uint8_t*)gif_image_ptr->local_pal_ptr, loc_pal_ptr,
loc_pal_size);
}
}
uint8_t* code_size_ptr = NULL;
- if (_gif_read_data(gif_ptr, &code_size_ptr, 1) == NULL) {
+ if (gif_read_data(gif_ptr, &code_size_ptr, 1) == NULL) {
gif_ptr->skip_size = skip_size_org;
FX_Free(gif_image_ptr->image_info_ptr);
FX_Free(gif_image_ptr->local_pal_ptr);
@@ -894,15 +811,15 @@ int32_t _gif_decode_image_info(gif_decompress_struct_p gif_ptr) {
return 2;
}
gif_image_ptr->image_code_size = *code_size_ptr;
- gif_ptr->_gif_record_current_position_fn(gif_ptr,
- &gif_image_ptr->image_data_pos);
+ gif_ptr->gif_record_current_position_fn(gif_ptr,
+ &gif_image_ptr->image_data_pos);
gif_image_ptr->image_data_pos += gif_ptr->skip_size;
- _gif_takeover_gce_ptr(gif_ptr, &gif_image_ptr->image_gce_ptr);
+ gif_takeover_gce_ptr(gif_ptr, &gif_image_ptr->image_gce_ptr);
gif_ptr->img_ptr_arr_ptr->Add(gif_image_ptr);
- _gif_save_decoding_status(gif_ptr, GIF_D_STATUS_IMG_DATA);
+ gif_save_decoding_status(gif_ptr, GIF_D_STATUS_IMG_DATA);
return 1;
}
-int32_t _gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) {
+int32_t gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) {
if (gif_ptr == NULL || frame_num < 0 ||
frame_num >= gif_ptr->img_ptr_arr_ptr->GetSize()) {
return 0;
@@ -926,7 +843,7 @@ int32_t _gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) {
: 0;
gif_ptr->avail_in = 0;
if (gif_img_gce_ptr == NULL) {
- FX_BOOL bRes = gif_ptr->_gif_get_record_position_fn(
+ FX_BOOL bRes = gif_ptr->gif_get_record_position_fn(
gif_ptr, gif_image_ptr->image_data_pos,
gif_image_ptr->image_info_ptr->left,
gif_image_ptr->image_info_ptr->top,
@@ -938,11 +855,11 @@ int32_t _gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) {
if (!bRes) {
FX_Free(gif_image_ptr->image_row_buf);
gif_image_ptr->image_row_buf = NULL;
- _gif_error(gif_ptr, "Error Read Record Position Data");
+ gif_error(gif_ptr, "Error Read Record Position Data");
return 0;
}
} else {
- FX_BOOL bRes = gif_ptr->_gif_get_record_position_fn(
+ FX_BOOL bRes = gif_ptr->gif_get_record_position_fn(
gif_ptr, gif_image_ptr->image_data_pos,
gif_image_ptr->image_info_ptr->left,
gif_image_ptr->image_info_ptr->top,
@@ -962,7 +879,7 @@ int32_t _gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) {
if (!bRes) {
FX_Free(gif_image_ptr->image_row_buf);
gif_image_ptr->image_row_buf = NULL;
- _gif_error(gif_ptr, "Error Read Record Position Data");
+ gif_error(gif_ptr, "Error Read Record Position Data");
return 0;
}
}
@@ -974,20 +891,20 @@ int32_t _gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) {
gif_ptr->img_row_avail_size = 0;
gif_ptr->img_pass_num = 0;
gif_image_ptr->image_row_num = 0;
- _gif_save_decoding_status(gif_ptr, GIF_D_STATUS_IMG_DATA);
+ gif_save_decoding_status(gif_ptr, GIF_D_STATUS_IMG_DATA);
}
CGifLZWDecoder* img_decoder_ptr = gif_ptr->img_decoder_ptr;
if (gif_ptr->decode_status == GIF_D_STATUS_IMG_DATA) {
- if (_gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
+ if (gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
return 2;
}
if (*data_size_ptr != GIF_BLOCK_TERMINAL) {
- if (_gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) == NULL) {
+ if (gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) == NULL) {
gif_ptr->skip_size = skip_size_org;
return 2;
}
img_decoder_ptr->Input(data_ptr, *data_size_ptr);
- _gif_save_decoding_status(gif_ptr, GIF_D_STATUS_IMG_DATA);
+ gif_save_decoding_status(gif_ptr, GIF_D_STATUS_IMG_DATA);
gif_ptr->img_row_offset += gif_ptr->img_row_avail_size;
gif_ptr->img_row_avail_size = gif_img_row_bytes - gif_ptr->img_row_offset;
int32_t ret = img_decoder_ptr->Decode(
@@ -996,32 +913,32 @@ int32_t _gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) {
if (ret == 0) {
FX_Free(gif_image_ptr->image_row_buf);
gif_image_ptr->image_row_buf = NULL;
- _gif_save_decoding_status(gif_ptr, GIF_D_STATUS_TAIL);
- _gif_error(gif_ptr, "Decode Image Data Error");
+ gif_save_decoding_status(gif_ptr, GIF_D_STATUS_TAIL);
+ gif_error(gif_ptr, "Decode Image Data Error");
return 0;
}
while (ret != 0) {
if (ret == 1) {
- gif_ptr->_gif_get_row_fn(gif_ptr, gif_image_ptr->image_row_num,
- gif_image_ptr->image_row_buf);
+ gif_ptr->gif_get_row_fn(gif_ptr, gif_image_ptr->image_row_num,
+ gif_image_ptr->image_row_buf);
FX_Free(gif_image_ptr->image_row_buf);
gif_image_ptr->image_row_buf = NULL;
- _gif_save_decoding_status(gif_ptr, GIF_D_STATUS_TAIL);
+ gif_save_decoding_status(gif_ptr, GIF_D_STATUS_TAIL);
return 1;
}
if (ret == 2) {
ASSERT(img_decoder_ptr->GetAvailInput() == 0);
skip_size_org = gif_ptr->skip_size;
- if (_gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
+ if (gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
return 2;
}
if (*data_size_ptr != GIF_BLOCK_TERMINAL) {
- if (_gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) == NULL) {
+ if (gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) == NULL) {
gif_ptr->skip_size = skip_size_org;
return 2;
}
img_decoder_ptr->Input(data_ptr, *data_size_ptr);
- _gif_save_decoding_status(gif_ptr, GIF_D_STATUS_IMG_DATA);
+ gif_save_decoding_status(gif_ptr, GIF_D_STATUS_IMG_DATA);
gif_ptr->img_row_offset += gif_ptr->img_row_avail_size;
gif_ptr->img_row_avail_size =
gif_img_row_bytes - gif_ptr->img_row_offset;
@@ -1032,8 +949,8 @@ int32_t _gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) {
}
if (ret == 3) {
if (((GifLF*)&gif_image_ptr->image_info_ptr->local_flag)->interlace) {
- gif_ptr->_gif_get_row_fn(gif_ptr, gif_image_ptr->image_row_num,
- gif_image_ptr->image_row_buf);
+ gif_ptr->gif_get_row_fn(gif_ptr, gif_image_ptr->image_row_num,
+ gif_image_ptr->image_row_buf);
gif_image_ptr->image_row_num +=
s_gif_interlace_step[gif_ptr->img_pass_num];
if (gif_image_ptr->image_row_num >=
@@ -1043,8 +960,8 @@ int32_t _gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) {
s_gif_interlace_step[gif_ptr->img_pass_num] / 2;
}
} else {
- gif_ptr->_gif_get_row_fn(gif_ptr, gif_image_ptr->image_row_num++,
- gif_image_ptr->image_row_buf);
+ gif_ptr->gif_get_row_fn(gif_ptr, gif_image_ptr->image_row_num++,
+ gif_image_ptr->image_row_buf);
}
gif_ptr->img_row_offset = 0;
gif_ptr->img_row_avail_size = gif_img_row_bytes;
@@ -1055,27 +972,26 @@ int32_t _gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) {
if (ret == 0) {
FX_Free(gif_image_ptr->image_row_buf);
gif_image_ptr->image_row_buf = NULL;
- _gif_save_decoding_status(gif_ptr, GIF_D_STATUS_TAIL);
- _gif_error(gif_ptr, "Decode Image Data Error");
+ gif_save_decoding_status(gif_ptr, GIF_D_STATUS_TAIL);
+ gif_error(gif_ptr, "Decode Image Data Error");
return 0;
}
}
}
- _gif_save_decoding_status(gif_ptr, GIF_D_STATUS_TAIL);
+ gif_save_decoding_status(gif_ptr, GIF_D_STATUS_TAIL);
}
- _gif_error(gif_ptr, "Decode Image Data Error");
+ gif_error(gif_ptr, "Decode Image Data Error");
return 0;
}
-void _gif_save_decoding_status(gif_decompress_struct_p gif_ptr,
- int32_t status) {
+void gif_save_decoding_status(gif_decompress_struct_p gif_ptr, int32_t status) {
gif_ptr->decode_status = status;
gif_ptr->next_in += gif_ptr->skip_size;
gif_ptr->avail_in -= gif_ptr->skip_size;
gif_ptr->skip_size = 0;
}
-uint8_t* _gif_read_data(gif_decompress_struct_p gif_ptr,
- uint8_t** des_buf_pp,
- FX_DWORD data_size) {
+uint8_t* gif_read_data(gif_decompress_struct_p gif_ptr,
+ uint8_t** des_buf_pp,
+ FX_DWORD data_size) {
if (gif_ptr == NULL || gif_ptr->avail_in < gif_ptr->skip_size + data_size) {
return NULL;
}
@@ -1083,15 +999,15 @@ uint8_t* _gif_read_data(gif_decompress_struct_p gif_ptr,
gif_ptr->skip_size += data_size;
return *des_buf_pp;
}
-void _gif_input_buffer(gif_decompress_struct_p gif_ptr,
- uint8_t* src_buf,
- FX_DWORD src_size) {
+void gif_input_buffer(gif_decompress_struct_p gif_ptr,
+ uint8_t* src_buf,
+ FX_DWORD src_size) {
gif_ptr->next_in = src_buf;
gif_ptr->avail_in = src_size;
gif_ptr->skip_size = 0;
}
-FX_DWORD _gif_get_avail_input(gif_decompress_struct_p gif_ptr,
- uint8_t** avial_buf_ptr) {
+FX_DWORD gif_get_avail_input(gif_decompress_struct_p gif_ptr,
+ uint8_t** avial_buf_ptr) {
if (avial_buf_ptr) {
*avial_buf_ptr = NULL;
if (gif_ptr->avail_in > 0) {
@@ -1100,12 +1016,12 @@ FX_DWORD _gif_get_avail_input(gif_decompress_struct_p gif_ptr,
}
return gif_ptr->avail_in;
}
-int32_t _gif_get_frame_num(gif_decompress_struct_p gif_ptr) {
+int32_t gif_get_frame_num(gif_decompress_struct_p gif_ptr) {
return gif_ptr->img_ptr_arr_ptr->GetSize();
}
-static FX_BOOL _gif_write_header(gif_compress_struct_p gif_ptr,
- uint8_t*& dst_buf,
- FX_DWORD& dst_len) {
+static FX_BOOL gif_write_header(gif_compress_struct_p gif_ptr,
+ uint8_t*& dst_buf,
+ FX_DWORD& dst_len) {
if (gif_ptr->cur_offset) {
return TRUE;
}
@@ -1117,16 +1033,16 @@ static FX_BOOL _gif_write_header(gif_compress_struct_p gif_ptr,
FXSYS_memset(dst_buf, 0, dst_len);
FXSYS_memcpy(dst_buf, gif_ptr->header_ptr, sizeof(GifHeader));
gif_ptr->cur_offset += sizeof(GifHeader);
- _SetWord_LSBFirst(dst_buf + gif_ptr->cur_offset, gif_ptr->lsd_ptr->width);
+ SetWord_LSBFirst(dst_buf + gif_ptr->cur_offset, gif_ptr->lsd_ptr->width);
gif_ptr->cur_offset += 2;
- _SetWord_LSBFirst(dst_buf + gif_ptr->cur_offset, gif_ptr->lsd_ptr->height);
+ SetWord_LSBFirst(dst_buf + gif_ptr->cur_offset, gif_ptr->lsd_ptr->height);
gif_ptr->cur_offset += 2;
dst_buf[gif_ptr->cur_offset++] = gif_ptr->lsd_ptr->global_flag;
dst_buf[gif_ptr->cur_offset++] = gif_ptr->lsd_ptr->bc_index;
dst_buf[gif_ptr->cur_offset++] = gif_ptr->lsd_ptr->pixel_aspect;
if (gif_ptr->global_pal) {
FX_WORD size = sizeof(GifPalette) * gif_ptr->gpal_num;
- if (!_gif_grow_buf(dst_buf, dst_len, gif_ptr->cur_offset + size)) {
+ if (!gif_grow_buf(dst_buf, dst_len, gif_ptr->cur_offset + size)) {
return FALSE;
}
FXSYS_memcpy(&dst_buf[gif_ptr->cur_offset], gif_ptr->global_pal, size);
@@ -1165,11 +1081,11 @@ void interlace_buf(const uint8_t* buf, FX_DWORD pitch, FX_DWORD height) {
}
}
}
-static void _gif_write_block_data(const uint8_t* src_buf,
- FX_DWORD src_len,
- uint8_t*& dst_buf,
- FX_DWORD& dst_len,
- FX_DWORD& dst_offset) {
+static void gif_write_block_data(const uint8_t* src_buf,
+ FX_DWORD src_len,
+ uint8_t*& dst_buf,
+ FX_DWORD& dst_len,
+ FX_DWORD& dst_offset) {
FX_DWORD src_offset = 0;
while (src_len > GIF_DATA_BLOCK) {
dst_buf[dst_offset++] = GIF_DATA_BLOCK;
@@ -1182,13 +1098,12 @@ static void _gif_write_block_data(const uint8_t* src_buf,
FXSYS_memcpy(&dst_buf[dst_offset], &src_buf[src_offset], src_len);
dst_offset += src_len;
}
-static FX_BOOL _gif_write_data(gif_compress_struct_p gif_ptr,
- uint8_t*& dst_buf,
- FX_DWORD& dst_len) {
- if (!_gif_grow_buf(dst_buf, dst_len, gif_ptr->cur_offset + GIF_DATA_BLOCK)) {
+static FX_BOOL gif_write_data(gif_compress_struct_p gif_ptr,
+ uint8_t*& dst_buf,
+ FX_DWORD& dst_len) {
+ if (!gif_grow_buf(dst_buf, dst_len, gif_ptr->cur_offset + GIF_DATA_BLOCK)) {
return FALSE;
}
-#ifdef GIF_SUPPORT_GRAPHIC_CONTROL_EXTENSION
if (FXSYS_memcmp(gif_ptr->header_ptr->version, "89a", 3) == 0) {
dst_buf[gif_ptr->cur_offset++] = GIF_SIG_EXTENSION;
dst_buf[gif_ptr->cur_offset++] = GIF_BLOCK_GCE;
@@ -1197,32 +1112,30 @@ static FX_BOOL _gif_write_data(gif_compress_struct_p gif_ptr,
gif_ptr->gce_ptr->gce_flag = 0;
dst_buf[gif_ptr->cur_offset++] = gif_ptr->gce_ptr->gce_flag;
gif_ptr->gce_ptr->delay_time = 10;
- _SetWord_LSBFirst(dst_buf + gif_ptr->cur_offset,
- gif_ptr->gce_ptr->delay_time);
+ SetWord_LSBFirst(dst_buf + gif_ptr->cur_offset,
+ gif_ptr->gce_ptr->delay_time);
gif_ptr->cur_offset += 2;
gif_ptr->gce_ptr->trans_index = 0;
dst_buf[gif_ptr->cur_offset++] = gif_ptr->gce_ptr->trans_index;
dst_buf[gif_ptr->cur_offset++] = 0;
}
-#endif
dst_buf[gif_ptr->cur_offset++] = GIF_SIG_IMAGE;
- _SetWord_LSBFirst(dst_buf + gif_ptr->cur_offset,
- gif_ptr->image_info_ptr->left);
+ SetWord_LSBFirst(dst_buf + gif_ptr->cur_offset,
+ gif_ptr->image_info_ptr->left);
gif_ptr->cur_offset += 2;
- _SetWord_LSBFirst(dst_buf + gif_ptr->cur_offset,
- gif_ptr->image_info_ptr->top);
+ SetWord_LSBFirst(dst_buf + gif_ptr->cur_offset, gif_ptr->image_info_ptr->top);
gif_ptr->cur_offset += 2;
- _SetWord_LSBFirst(dst_buf + gif_ptr->cur_offset,
- gif_ptr->image_info_ptr->width);
+ SetWord_LSBFirst(dst_buf + gif_ptr->cur_offset,
+ gif_ptr->image_info_ptr->width);
gif_ptr->cur_offset += 2;
- _SetWord_LSBFirst(dst_buf + gif_ptr->cur_offset,
- gif_ptr->image_info_ptr->height);
+ SetWord_LSBFirst(dst_buf + gif_ptr->cur_offset,
+ gif_ptr->image_info_ptr->height);
gif_ptr->cur_offset += 2;
GifLF& lf = (GifLF&)gif_ptr->image_info_ptr->local_flag;
dst_buf[gif_ptr->cur_offset++] = gif_ptr->image_info_ptr->local_flag;
if (gif_ptr->local_pal) {
FX_DWORD pal_size = sizeof(GifPalette) * gif_ptr->lpal_num;
- if (!_gif_grow_buf(dst_buf, dst_len, pal_size + gif_ptr->cur_offset)) {
+ if (!gif_grow_buf(dst_buf, dst_len, pal_size + gif_ptr->cur_offset)) {
return FALSE;
}
FXSYS_memcpy(&dst_buf[gif_ptr->cur_offset], gif_ptr->local_pal, pal_size);
@@ -1250,75 +1163,52 @@ static FX_BOOL _gif_write_data(gif_compress_struct_p gif_ptr,
}
gif_ptr->img_encoder_ptr->Finish(dst_buf, dst_len, gif_ptr->cur_offset);
dst_buf[gif_ptr->cur_offset++] = 0;
-#ifdef GIF_SUPPORT_COMMENT_EXTENSION
if (FXSYS_memcmp(gif_ptr->header_ptr->version, "89a", 3) == 0 &&
gif_ptr->cmt_data_ptr) {
dst_buf[gif_ptr->cur_offset++] = GIF_SIG_EXTENSION;
dst_buf[gif_ptr->cur_offset++] = GIF_BLOCK_CE;
- _gif_write_block_data(gif_ptr->cmt_data_ptr, gif_ptr->cmt_data_len, dst_buf,
- dst_len, gif_ptr->cur_offset);
+ gif_write_block_data(gif_ptr->cmt_data_ptr, gif_ptr->cmt_data_len, dst_buf,
+ dst_len, gif_ptr->cur_offset);
dst_buf[gif_ptr->cur_offset++] = 0;
}
-#endif
-#ifdef GIF_SUPPORT_PLAIN_TEXT_EXTENSION
if (FXSYS_memcmp(gif_ptr->header_ptr->version, "89a", 3) == 0 &&
gif_ptr->pte_data_ptr) {
dst_buf[gif_ptr->cur_offset++] = GIF_SIG_EXTENSION;
dst_buf[gif_ptr->cur_offset++] = GIF_BLOCK_PTE;
dst_buf[gif_ptr->cur_offset++] = gif_ptr->pte_ptr->block_size;
- _SetWord_LSBFirst(dst_buf + gif_ptr->cur_offset,
- gif_ptr->pte_ptr->grid_left);
+ SetWord_LSBFirst(dst_buf + gif_ptr->cur_offset,
+ gif_ptr->pte_ptr->grid_left);
gif_ptr->cur_offset += 2;
- _SetWord_LSBFirst(dst_buf + gif_ptr->cur_offset,
- gif_ptr->pte_ptr->grid_top);
+ SetWord_LSBFirst(dst_buf + gif_ptr->cur_offset, gif_ptr->pte_ptr->grid_top);
gif_ptr->cur_offset += 2;
- _SetWord_LSBFirst(dst_buf + gif_ptr->cur_offset,
- gif_ptr->pte_ptr->grid_width);
+ SetWord_LSBFirst(dst_buf + gif_ptr->cur_offset,
+ gif_ptr->pte_ptr->grid_width);
gif_ptr->cur_offset += 2;
- _SetWord_LSBFirst(dst_buf + gif_ptr->cur_offset,
- gif_ptr->pte_ptr->grid_height);
+ SetWord_LSBFirst(dst_buf + gif_ptr->cur_offset,
+ gif_ptr->pte_ptr->grid_height);
gif_ptr->cur_offset += 2;
- _SetWord_LSBFirst(dst_buf + gif_ptr->cur_offset,
- gif_ptr->pte_ptr->char_width);
+ SetWord_LSBFirst(dst_buf + gif_ptr->cur_offset,
+ gif_ptr->pte_ptr->char_width);
gif_ptr->cur_offset += 2;
- _SetWord_LSBFirst(dst_buf + gif_ptr->cur_offset,
- gif_ptr->pte_ptr->char_height);
+ SetWord_LSBFirst(dst_buf + gif_ptr->cur_offset,
+ gif_ptr->pte_ptr->char_height);
gif_ptr->cur_offset += 2;
- _SetWord_LSBFirst(dst_buf + gif_ptr->cur_offset,
- gif_ptr->pte_ptr->fc_index);
+ SetWord_LSBFirst(dst_buf + gif_ptr->cur_offset, gif_ptr->pte_ptr->fc_index);
gif_ptr->cur_offset += 2;
- _SetWord_LSBFirst(dst_buf + gif_ptr->cur_offset,
- gif_ptr->pte_ptr->bc_index);
+ SetWord_LSBFirst(dst_buf + gif_ptr->cur_offset, gif_ptr->pte_ptr->bc_index);
gif_ptr->cur_offset += 2;
- _gif_write_block_data(gif_ptr->pte_data_ptr, gif_ptr->pte_data_len, dst_buf,
- dst_len, gif_ptr->cur_offset);
+ gif_write_block_data(gif_ptr->pte_data_ptr, gif_ptr->pte_data_len, dst_buf,
+ dst_len, gif_ptr->cur_offset);
gif_ptr->cur_offset += gif_ptr->pte_data_len;
dst_buf[gif_ptr->cur_offset++] = 0;
}
-#endif
-#ifdef GIF_SUPPORT_APPLICATION_EXTENSION
- if (FXSYS_memcmp(gif_ptr->header_ptr->version, "89a", 3) == 0 &&
- gif_ptr->app_data) {
- dst_buf[gif_ptr->cur_offset++] = GIF_SIG_EXTENSION;
- dst_buf[gif_ptr->cur_offset++] = GIF_BLOCK_AE;
- dst_buf[gif_ptr->cur_offset++] = 11;
- FXSYS_memcpy(&dst_buf[gif_ptr->cur_offset], gif_ptr->app_identify, 8);
- gif_ptr->cur_offset += 8;
- FXSYS_memcpy(&dst_buf[gif_ptr->cur_offset], gif_ptr->app_authentication, 8);
- gif_ptr->cur_offset += 3;
- FXSYS_memcpy(&dst_buf[gif_ptr->cur_offset], gif_ptr->app_data,
- gif_ptr->app_data_size);
- gif_ptr->cur_offset += gif_ptr->app_data_size;
- dst_buf[gif_ptr->cur_offset++] = 0;
- }
-#endif
dst_buf[gif_ptr->cur_offset++] = GIF_SIG_TRAILER;
return TRUE;
}
-FX_BOOL _gif_encode(gif_compress_struct_p gif_ptr,
- uint8_t*& dst_buf,
- FX_DWORD& dst_len) {
- if (!_gif_write_header(gif_ptr, dst_buf, dst_len)) {
+FX_BOOL gif_encode(gif_compress_struct_p gif_ptr,
+ uint8_t*& dst_buf,
+ FX_DWORD& dst_len) {
+ if (!gif_write_header(gif_ptr, dst_buf, dst_len)) {
return FALSE;
}
FX_DWORD cur_offset = gif_ptr->cur_offset;
@@ -1326,7 +1216,7 @@ FX_BOOL _gif_encode(gif_compress_struct_p gif_ptr,
if (gif_ptr->frames) {
gif_ptr->cur_offset--;
}
- if (!_gif_write_data(gif_ptr, dst_buf, dst_len)) {
+ if (!gif_write_data(gif_ptr, dst_buf, dst_len)) {
gif_ptr->cur_offset = cur_offset;
res = FALSE;
}
diff --git a/core/src/fxcodec/lgif/fx_gif.h b/core/src/fxcodec/lgif/fx_gif.h
index 19e21751d6..32300a50e5 100644
--- a/core/src/fxcodec/lgif/fx_gif.h
+++ b/core/src/fxcodec/lgif/fx_gif.h
@@ -11,17 +11,6 @@
#include "core/include/fxcrt/fx_basic.h"
-extern FX_WORD _GetWord_LSBFirst(uint8_t* p);
-extern void _SetWord_LSBFirst(uint8_t* p, FX_WORD v);
-extern void _BpcConvert(const uint8_t* src_buf,
- FX_DWORD src_len,
- int32_t src_bpc,
- int32_t dst_bpc,
- uint8_t*& dst_buf,
- FX_DWORD& dst_len);
-#define GIF_SUPPORT_COMMENT_EXTENSION
-#define GIF_SUPPORT_GRAPHIC_CONTROL_EXTENSION
-#define GIF_SUPPORT_PLAIN_TEXT_EXTENSION
#define GIF_SIGNATURE "GIF"
#define GIF_SIG_EXTENSION 0x21
#define GIF_SIG_IMAGE 0x2C
@@ -208,12 +197,11 @@ class CGifLZWEncoder {
typedef struct tag_gif_decompress_struct gif_decompress_struct;
typedef gif_decompress_struct* gif_decompress_struct_p;
typedef gif_decompress_struct_p* gif_decompress_struct_pp;
-static int32_t s_gif_interlace_step[4] = {8, 8, 4, 2};
+static const int32_t s_gif_interlace_step[4] = {8, 8, 4, 2};
struct tag_gif_decompress_struct {
jmp_buf jmpbuf;
FX_CHAR* err_ptr;
- void (*_gif_error_fn)(gif_decompress_struct_p gif_ptr,
- const FX_CHAR* err_msg);
+ void (*gif_error_fn)(gif_decompress_struct_p gif_ptr, const FX_CHAR* err_msg);
void* context_ptr;
int width;
int height;
@@ -229,38 +217,26 @@ struct tag_gif_decompress_struct {
FX_DWORD img_row_avail_size;
uint8_t img_pass_num;
CFX_ArrayTemplate<GifImage*>* img_ptr_arr_ptr;
- uint8_t* (*_gif_ask_buf_for_pal_fn)(gif_decompress_struct_p gif_ptr,
- int32_t pal_size);
+ uint8_t* (*gif_ask_buf_for_pal_fn)(gif_decompress_struct_p gif_ptr,
+ int32_t pal_size);
uint8_t* next_in;
FX_DWORD avail_in;
int32_t decode_status;
FX_DWORD skip_size;
- void (*_gif_record_current_position_fn)(gif_decompress_struct_p gif_ptr,
- FX_DWORD* cur_pos_ptr);
- void (*_gif_get_row_fn)(gif_decompress_struct_p gif_ptr,
- int32_t row_num,
- uint8_t* row_buf);
- FX_BOOL (*_gif_get_record_position_fn)(gif_decompress_struct_p gif_ptr,
+ void (*gif_record_current_position_fn)(gif_decompress_struct_p gif_ptr,
+ FX_DWORD* cur_pos_ptr);
+ void (*gif_get_row_fn)(gif_decompress_struct_p gif_ptr,
+ int32_t row_num,
+ uint8_t* row_buf);
+ FX_BOOL (*gif_get_record_position_fn)(gif_decompress_struct_p gif_ptr,
FX_DWORD cur_pos,
int32_t left, int32_t top, int32_t width, int32_t height,
int32_t pal_num, void* pal_ptr,
int32_t delay_time, FX_BOOL user_input,
int32_t trans_index, int32_t disposal_method, FX_BOOL interlace);
-#ifdef GIF_SUPPORT_APPLICATION_EXTENSION
- uint8_t app_identify[8];
- uint8_t app_authentication[3];
- FX_DWORD app_data_size;
- uint8_t* app_data;
-#endif
-#ifdef GIF_SUPPORT_COMMENT_EXTENSION
CFX_ByteString* cmt_data_ptr;
-#endif
-#ifdef GIF_SUPPORT_GRAPHIC_CONTROL_EXTENSION
GifGCE* gce_ptr;
-#endif
-#ifdef GIF_SUPPORT_PLAIN_TEXT_EXTENSION
CFX_ArrayTemplate<GifPlainText*>* pt_ptr_arr_ptr;
-#endif
};
typedef struct tag_gif_compress_struct gif_compress_struct;
typedef gif_compress_struct* gif_compress_struct_p;
@@ -280,55 +256,41 @@ struct tag_gif_compress_struct {
FX_WORD lpal_num;
GifImageInfo* image_info_ptr;
CGifLZWEncoder* img_encoder_ptr;
-#ifdef GIF_SUPPORT_APPLICATION_EXTENSION
- uint8_t app_identify[8];
- uint8_t app_authentication[3];
- FX_DWORD app_data_size;
- uint8_t* app_data;
-#endif
-#ifdef GIF_SUPPORT_COMMENT_EXTENSION
uint8_t* cmt_data_ptr;
FX_DWORD cmt_data_len;
-#endif
-
-#ifdef GIF_SUPPORT_GRAPHIC_CONTROL_EXTENSION
GifGCE* gce_ptr;
-#endif
-
-#ifdef GIF_SUPPORT_PLAIN_TEXT_EXTENSION
GifPTE* pte_ptr;
const uint8_t* pte_data_ptr;
FX_DWORD pte_data_len;
-#endif
};
-void _gif_error(gif_decompress_struct_p gif_ptr, const FX_CHAR* err_msg);
-void _gif_warn(gif_decompress_struct_p gif_ptr, const FX_CHAR* err_msg);
-gif_decompress_struct_p _gif_create_decompress();
-void _gif_destroy_decompress(gif_decompress_struct_pp gif_ptr_ptr);
-gif_compress_struct_p _gif_create_compress();
-void _gif_destroy_compress(gif_compress_struct_pp gif_ptr_ptr);
-int32_t _gif_read_header(gif_decompress_struct_p gif_ptr);
-int32_t _gif_get_frame(gif_decompress_struct_p gif_ptr);
-int32_t _gif_get_frame_num(gif_decompress_struct_p gif_ptr);
-int32_t _gif_decode_extension(gif_decompress_struct_p gif_ptr);
-int32_t _gif_decode_image_info(gif_decompress_struct_p gif_ptr);
-void _gif_takeover_gce_ptr(gif_decompress_struct_p gif_ptr,
- GifGCE** gce_ptr_ptr);
-int32_t _gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num);
-uint8_t* _gif_read_data(gif_decompress_struct_p gif_ptr,
- uint8_t** des_buf_pp,
- FX_DWORD data_size);
-void _gif_save_decoding_status(gif_decompress_struct_p gif_ptr, int32_t status);
-void _gif_input_buffer(gif_decompress_struct_p gif_ptr,
- uint8_t* src_buf,
- FX_DWORD src_size);
-FX_DWORD _gif_get_avail_input(gif_decompress_struct_p gif_ptr,
- uint8_t** avial_buf_ptr);
+void gif_error(gif_decompress_struct_p gif_ptr, const FX_CHAR* err_msg);
+void gif_warn(gif_decompress_struct_p gif_ptr, const FX_CHAR* err_msg);
+gif_decompress_struct_p gif_create_decompress();
+void gif_destroy_decompress(gif_decompress_struct_pp gif_ptr_ptr);
+gif_compress_struct_p gif_create_compress();
+void gif_destroy_compress(gif_compress_struct_pp gif_ptr_ptr);
+int32_t gif_read_header(gif_decompress_struct_p gif_ptr);
+int32_t gif_get_frame(gif_decompress_struct_p gif_ptr);
+int32_t gif_get_frame_num(gif_decompress_struct_p gif_ptr);
+int32_t gif_decode_extension(gif_decompress_struct_p gif_ptr);
+int32_t gif_decode_image_info(gif_decompress_struct_p gif_ptr);
+void gif_takeover_gce_ptr(gif_decompress_struct_p gif_ptr,
+ GifGCE** gce_ptr_ptr);
+int32_t gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num);
+uint8_t* gif_read_data(gif_decompress_struct_p gif_ptr,
+ uint8_t** des_buf_pp,
+ FX_DWORD data_size);
+void gif_save_decoding_status(gif_decompress_struct_p gif_ptr, int32_t status);
+void gif_input_buffer(gif_decompress_struct_p gif_ptr,
+ uint8_t* src_buf,
+ FX_DWORD src_size);
+FX_DWORD gif_get_avail_input(gif_decompress_struct_p gif_ptr,
+ uint8_t** avial_buf_ptr);
void interlace_buf(const uint8_t* buf, FX_DWORD width, FX_DWORD height);
-FX_BOOL _gif_encode(gif_compress_struct_p gif_ptr,
- uint8_t*& dst_buf,
- FX_DWORD& dst_len);
+FX_BOOL gif_encode(gif_compress_struct_p gif_ptr,
+ uint8_t*& dst_buf,
+ FX_DWORD& dst_len);
#endif // CORE_SRC_FXCODEC_LGIF_FX_GIF_H_