summaryrefslogtreecommitdiff
path: root/core/fxcodec/lgif
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxcodec/lgif')
-rw-r--r--core/fxcodec/lgif/fx_gif.cpp88
-rw-r--r--core/fxcodec/lgif/fx_gif.h72
2 files changed, 80 insertions, 80 deletions
diff --git a/core/fxcodec/lgif/fx_gif.cpp b/core/fxcodec/lgif/fx_gif.cpp
index b20b4dfdec..059fa9a70b 100644
--- a/core/fxcodec/lgif/fx_gif.cpp
+++ b/core/fxcodec/lgif/fx_gif.cpp
@@ -8,11 +8,11 @@
#include "core/fxcodec/lbmp/fx_bmp.h"
-void CGifLZWDecoder::Input(uint8_t* src_buf, FX_DWORD src_size) {
+void CGifLZWDecoder::Input(uint8_t* src_buf, uint32_t src_size) {
next_in = src_buf;
avail_in = src_size;
}
-FX_DWORD CGifLZWDecoder::GetAvailInput() {
+uint32_t CGifLZWDecoder::GetAvailInput() {
return avail_in;
}
void CGifLZWDecoder::InitTable(uint8_t code_len) {
@@ -62,11 +62,11 @@ void CGifLZWDecoder::AddCode(uint16_t prefix_code, uint8_t append_char) {
}
}
}
-int32_t CGifLZWDecoder::Decode(uint8_t* des_buf, FX_DWORD& des_size) {
+int32_t CGifLZWDecoder::Decode(uint8_t* des_buf, uint32_t& des_size) {
if (des_size == 0) {
return 3;
}
- FX_DWORD i = 0;
+ uint32_t i = 0;
if (stack_size != 0) {
if (des_size < stack_size) {
FXSYS_memcpy(des_buf, &stack[GIF_MAX_LZW_CODE - stack_size], des_size);
@@ -145,10 +145,10 @@ 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) {
+ uint32_t& dst_len,
+ uint32_t size) {
if (dst_len < size) {
- FX_DWORD len_org = dst_len;
+ uint32_t len_org = dst_len;
while (dst_buf && dst_len < size) {
dst_len <<= 1;
dst_buf = FX_Realloc(uint8_t, dst_buf, dst_len);
@@ -166,18 +166,18 @@ static FX_BOOL gif_grow_buf(uint8_t*& dst_buf,
return TRUE;
}
static inline void gif_cut_index(uint8_t& val,
- FX_DWORD index,
+ uint32_t 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;
+ uint32_t 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,
+ uint32_t& offset,
uint8_t bit_cut,
uint8_t& bit_offset,
- FX_DWORD& bit_num) {
+ uint32_t& bit_num) {
if (bit_cut != 8) {
uint16_t index = 0;
index |= ((1 << bit_cut) - 1) << (7 - bit_offset);
@@ -212,7 +212,7 @@ void CGifLZWEncoder::ClearTable() {
void CGifLZWEncoder::Start(uint8_t code_len,
const uint8_t* src_buf,
uint8_t*& dst_buf,
- FX_DWORD& offset) {
+ uint32_t& offset) {
code_size = code_len + 1;
src_bit_cut = code_size;
if (code_len == 0) {
@@ -233,8 +233,8 @@ void CGifLZWEncoder::Start(uint8_t code_len,
src_bit_offset, src_bit_num);
}
void CGifLZWEncoder::WriteBlock(uint8_t*& dst_buf,
- FX_DWORD& dst_len,
- FX_DWORD& offset) {
+ uint32_t& dst_len,
+ uint32_t& offset) {
if (!gif_grow_buf(dst_buf, dst_len, offset + GIF_DATA_BLOCK + 1)) {
longjmp(jmp, 1);
}
@@ -244,10 +244,10 @@ void CGifLZWEncoder::WriteBlock(uint8_t*& dst_buf,
FXSYS_memset(index_buf, 0, GIF_DATA_BLOCK);
index_buf_len = 0;
}
-void CGifLZWEncoder::EncodeString(FX_DWORD index,
+void CGifLZWEncoder::EncodeString(uint32_t index,
uint8_t*& dst_buf,
- FX_DWORD& dst_len,
- FX_DWORD& offset) {
+ uint32_t& dst_len,
+ uint32_t& offset) {
uint8_t index_bit_use;
index_bit_use = 0;
if (index_buf_len == GIF_DATA_BLOCK) {
@@ -302,10 +302,10 @@ void CGifLZWEncoder::EncodeString(FX_DWORD index,
}
}
FX_BOOL CGifLZWEncoder::Encode(const uint8_t* src_buf,
- FX_DWORD src_len,
+ uint32_t src_len,
uint8_t*& dst_buf,
- FX_DWORD& dst_len,
- FX_DWORD& offset) {
+ uint32_t& dst_len,
+ uint32_t& offset) {
uint8_t suffix;
if (setjmp(jmp)) {
return FALSE;
@@ -333,7 +333,7 @@ FX_BOOL CGifLZWEncoder::Encode(const uint8_t* src_buf,
return TRUE;
}
FX_BOOL CGifLZWEncoder::LookUpInTable(const uint8_t* buf,
- FX_DWORD& offset,
+ uint32_t& offset,
uint8_t& bit_offset) {
for (uint16_t i = table_cur; i < index_num; i++) {
if (code_table[i].prefix == code_table[index_num].prefix &&
@@ -349,8 +349,8 @@ FX_BOOL CGifLZWEncoder::LookUpInTable(const uint8_t* buf,
return FALSE;
}
void CGifLZWEncoder::Finish(uint8_t*& dst_buf,
- FX_DWORD& dst_len,
- FX_DWORD& offset) {
+ uint32_t& dst_len,
+ uint32_t& offset) {
EncodeString(code_table[index_num].prefix, dst_buf, dst_len, offset);
EncodeString(code_end, dst_buf, dst_len, offset);
bit_offset = 0;
@@ -491,7 +491,7 @@ 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;
+ uint32_t 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) {
@@ -600,7 +600,7 @@ int32_t gif_get_frame(gif_decompress_struct_p gif_ptr) {
case GIF_D_STATUS_IMG_DATA: {
uint8_t* data_size_ptr = NULL;
uint8_t* data_ptr = NULL;
- FX_DWORD skip_size_org = gif_ptr->skip_size;
+ uint32_t skip_size_org = gif_ptr->skip_size;
if (gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
return 2;
}
@@ -640,7 +640,7 @@ void gif_takeover_gce_ptr(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;
+ uint32_t skip_size_org = gif_ptr->skip_size;
switch (gif_ptr->decode_status) {
case GIF_D_STATUS_EXT_CE: {
if (gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
@@ -751,7 +751,7 @@ int32_t gif_decode_image_info(gif_decompress_struct_p gif_ptr) {
gif_error(gif_ptr, "No Image Header Info");
return 0;
}
- FX_DWORD skip_size_org = gif_ptr->skip_size;
+ uint32_t 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) {
@@ -826,9 +826,9 @@ int32_t gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) {
}
uint8_t* data_size_ptr = NULL;
uint8_t* data_ptr = NULL;
- FX_DWORD skip_size_org = gif_ptr->skip_size;
+ uint32_t skip_size_org = gif_ptr->skip_size;
GifImage* gif_image_ptr = gif_ptr->img_ptr_arr_ptr->GetAt(frame_num);
- FX_DWORD gif_img_row_bytes = gif_image_ptr->image_info_ptr->width;
+ uint32_t gif_img_row_bytes = gif_image_ptr->image_info_ptr->width;
if (gif_ptr->decode_status == GIF_D_STATUS_TAIL) {
if (gif_image_ptr->image_row_buf) {
FX_Free(gif_image_ptr->image_row_buf);
@@ -991,7 +991,7 @@ void gif_save_decoding_status(gif_decompress_struct_p gif_ptr, int32_t status) {
}
uint8_t* gif_read_data(gif_decompress_struct_p gif_ptr,
uint8_t** des_buf_pp,
- FX_DWORD data_size) {
+ uint32_t data_size) {
if (gif_ptr == NULL || gif_ptr->avail_in < gif_ptr->skip_size + data_size) {
return NULL;
}
@@ -1001,12 +1001,12 @@ uint8_t* gif_read_data(gif_decompress_struct_p gif_ptr,
}
void gif_input_buffer(gif_decompress_struct_p gif_ptr,
uint8_t* src_buf,
- FX_DWORD src_size) {
+ uint32_t 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,
+uint32_t gif_get_avail_input(gif_decompress_struct_p gif_ptr,
uint8_t** avial_buf_ptr) {
if (avial_buf_ptr) {
*avial_buf_ptr = NULL;
@@ -1021,7 +1021,7 @@ int32_t gif_get_frame_num(gif_decompress_struct_p gif_ptr) {
}
static FX_BOOL gif_write_header(gif_compress_struct_p gif_ptr,
uint8_t*& dst_buf,
- FX_DWORD& dst_len) {
+ uint32_t& dst_len) {
if (gif_ptr->cur_offset) {
return TRUE;
}
@@ -1050,10 +1050,10 @@ static FX_BOOL gif_write_header(gif_compress_struct_p gif_ptr,
}
return TRUE;
}
-void interlace_buf(const uint8_t* buf, FX_DWORD pitch, FX_DWORD height) {
+void interlace_buf(const uint8_t* buf, uint32_t pitch, uint32_t height) {
CFX_ArrayTemplate<uint8_t*> pass[4];
int i, j;
- FX_DWORD row;
+ uint32_t row;
row = 0;
uint8_t* temp;
while (row < height) {
@@ -1082,11 +1082,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,
+ uint32_t src_len,
uint8_t*& dst_buf,
- FX_DWORD& dst_len,
- FX_DWORD& dst_offset) {
- FX_DWORD src_offset = 0;
+ uint32_t& dst_len,
+ uint32_t& dst_offset) {
+ uint32_t src_offset = 0;
while (src_len > GIF_DATA_BLOCK) {
dst_buf[dst_offset++] = GIF_DATA_BLOCK;
FXSYS_memcpy(&dst_buf[dst_offset], &src_buf[src_offset], GIF_DATA_BLOCK);
@@ -1100,7 +1100,7 @@ static void gif_write_block_data(const uint8_t* src_buf,
}
static FX_BOOL gif_write_data(gif_compress_struct_p gif_ptr,
uint8_t*& dst_buf,
- FX_DWORD& dst_len) {
+ uint32_t& dst_len) {
if (!gif_grow_buf(dst_buf, dst_len, gif_ptr->cur_offset + GIF_DATA_BLOCK)) {
return FALSE;
}
@@ -1134,7 +1134,7 @@ static FX_BOOL gif_write_data(gif_compress_struct_p gif_ptr,
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;
+ uint32_t pal_size = sizeof(GifPalette) * gif_ptr->lpal_num;
if (!gif_grow_buf(dst_buf, dst_len, pal_size + gif_ptr->cur_offset)) {
return FALSE;
}
@@ -1152,7 +1152,7 @@ static FX_BOOL gif_write_data(gif_compress_struct_p gif_ptr,
}
gif_ptr->img_encoder_ptr->Start(code_bit, gif_ptr->src_buf, dst_buf,
gif_ptr->cur_offset);
- FX_DWORD i;
+ uint32_t i;
for (i = 0; i < gif_ptr->src_row; i++) {
if (!gif_ptr->img_encoder_ptr->Encode(
&gif_ptr->src_buf[i * gif_ptr->src_pitch],
@@ -1207,11 +1207,11 @@ static FX_BOOL gif_write_data(gif_compress_struct_p gif_ptr,
}
FX_BOOL gif_encode(gif_compress_struct_p gif_ptr,
uint8_t*& dst_buf,
- FX_DWORD& dst_len) {
+ uint32_t& dst_len) {
if (!gif_write_header(gif_ptr, dst_buf, dst_len)) {
return FALSE;
}
- FX_DWORD cur_offset = gif_ptr->cur_offset;
+ uint32_t cur_offset = gif_ptr->cur_offset;
FX_BOOL res = TRUE;
if (gif_ptr->frames) {
gif_ptr->cur_offset--;
diff --git a/core/fxcodec/lgif/fx_gif.h b/core/fxcodec/lgif/fx_gif.h
index 5ed9ce1fe2..47e5eebab7 100644
--- a/core/fxcodec/lgif/fx_gif.h
+++ b/core/fxcodec/lgif/fx_gif.h
@@ -103,7 +103,7 @@ typedef struct tagGifImage {
GifPalette* local_pal_ptr;
GifImageInfo* image_info_ptr;
uint8_t image_code_size;
- FX_DWORD image_data_pos;
+ uint32_t image_data_pos;
uint8_t* image_row_buf;
int32_t image_row_num;
} GifImage;
@@ -121,10 +121,10 @@ class CGifLZWDecoder {
CGifLZWDecoder(FX_CHAR* error_ptr = NULL) { err_msg_ptr = error_ptr; }
void InitTable(uint8_t code_len);
- int32_t Decode(uint8_t* des_buf, FX_DWORD& des_size);
+ int32_t Decode(uint8_t* des_buf, uint32_t& des_size);
- void Input(uint8_t* src_buf, FX_DWORD src_size);
- FX_DWORD GetAvailInput();
+ void Input(uint8_t* src_buf, uint32_t src_size);
+ uint32_t GetAvailInput();
private:
void ClearTable();
@@ -142,10 +142,10 @@ class CGifLZWDecoder {
uint16_t code_old;
uint8_t* next_in;
- FX_DWORD avail_in;
+ uint32_t avail_in;
uint8_t bits_left;
- FX_DWORD code_store;
+ uint32_t code_store;
FX_CHAR* err_msg_ptr;
};
@@ -160,29 +160,29 @@ class CGifLZWEncoder {
void Start(uint8_t code_len,
const uint8_t* src_buf,
uint8_t*& dst_buf,
- FX_DWORD& offset);
+ uint32_t& offset);
FX_BOOL Encode(const uint8_t* src_buf,
- FX_DWORD src_len,
+ uint32_t src_len,
uint8_t*& dst_buf,
- FX_DWORD& dst_len,
- FX_DWORD& offset);
- void Finish(uint8_t*& dst_buf, FX_DWORD& dst_len, FX_DWORD& offset);
+ uint32_t& dst_len,
+ uint32_t& offset);
+ void Finish(uint8_t*& dst_buf, uint32_t& dst_len, uint32_t& offset);
private:
void ClearTable();
FX_BOOL LookUpInTable(const uint8_t* buf,
- FX_DWORD& offset,
+ uint32_t& offset,
uint8_t& bit_offset);
- void EncodeString(FX_DWORD index,
+ void EncodeString(uint32_t index,
uint8_t*& dst_buf,
- FX_DWORD& dst_len,
- FX_DWORD& offset);
- void WriteBlock(uint8_t*& dst_buf, FX_DWORD& dst_len, FX_DWORD& offset);
+ uint32_t& dst_len,
+ uint32_t& offset);
+ void WriteBlock(uint8_t*& dst_buf, uint32_t& dst_len, uint32_t& offset);
jmp_buf jmp;
- FX_DWORD src_offset;
+ uint32_t src_offset;
uint8_t src_bit_offset;
uint8_t src_bit_cut;
- FX_DWORD src_bit_num;
+ uint32_t src_bit_num;
uint8_t code_size;
uint16_t code_clear;
uint16_t code_end;
@@ -213,23 +213,23 @@ struct tag_gif_decompress_struct {
uint8_t bc_index;
uint8_t pixel_aspect;
CGifLZWDecoder* img_decoder_ptr;
- FX_DWORD img_row_offset;
- FX_DWORD img_row_avail_size;
+ uint32_t img_row_offset;
+ uint32_t 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* next_in;
- FX_DWORD avail_in;
+ uint32_t avail_in;
int32_t decode_status;
- FX_DWORD skip_size;
+ uint32_t skip_size;
void (*gif_record_current_position_fn)(gif_decompress_struct_p gif_ptr,
- FX_DWORD* cur_pos_ptr);
+ uint32_t* 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,
+ uint32_t 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,
@@ -243,11 +243,11 @@ typedef gif_compress_struct* gif_compress_struct_p;
typedef gif_compress_struct_p* gif_compress_struct_pp;
struct tag_gif_compress_struct {
const uint8_t* src_buf;
- FX_DWORD src_pitch;
- FX_DWORD src_width;
- FX_DWORD src_row;
- FX_DWORD cur_offset;
- FX_DWORD frames;
+ uint32_t src_pitch;
+ uint32_t src_width;
+ uint32_t src_row;
+ uint32_t cur_offset;
+ uint32_t frames;
GifHeader* header_ptr;
GifLSD* lsd_ptr;
GifPalette* global_pal;
@@ -258,11 +258,11 @@ struct tag_gif_compress_struct {
CGifLZWEncoder* img_encoder_ptr;
uint8_t* cmt_data_ptr;
- FX_DWORD cmt_data_len;
+ uint32_t cmt_data_len;
GifGCE* gce_ptr;
GifPTE* pte_ptr;
const uint8_t* pte_data_ptr;
- FX_DWORD pte_data_len;
+ uint32_t pte_data_len;
};
void gif_error(gif_decompress_struct_p gif_ptr, const FX_CHAR* err_msg);
@@ -281,16 +281,16 @@ void gif_takeover_gce_ptr(gif_decompress_struct_p gif_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);
+ uint32_t 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,
+ uint32_t src_size);
+uint32_t 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);
+void interlace_buf(const uint8_t* buf, uint32_t width, uint32_t height);
FX_BOOL gif_encode(gif_compress_struct_p gif_ptr,
uint8_t*& dst_buf,
- FX_DWORD& dst_len);
+ uint32_t& dst_len);
#endif // CORE_FXCODEC_LGIF_FX_GIF_H_