From 7527ad735dcd59467e34005edcb78ce9ab4fdb5c Mon Sep 17 00:00:00 2001 From: hj kim Date: Tue, 16 Oct 2018 17:10:58 +0900 Subject: [PATCH] just rearrange some parameters Change-Id: Ic2407057f230166a6b08871024351d05db07dea4 --- common/include/mm_util_type.h | 2 +- gif/mm_util_gif.c | 30 ++++++++++++++++-------------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/common/include/mm_util_type.h b/common/include/mm_util_type.h index 47ad9bf..e530e2a 100755 --- a/common/include/mm_util_type.h +++ b/common/include/mm_util_type.h @@ -78,7 +78,7 @@ typedef struct { mm_util_color_format_e color; void *data; size_t size; - int delay_time; + unsigned int delay_time; } mm_image_info_s; #ifdef __cplusplus diff --git a/gif/mm_util_gif.c b/gif/mm_util_gif.c index d2c4de1..5c80755 100755 --- a/gif/mm_util_gif.c +++ b/gif/mm_util_gif.c @@ -36,20 +36,21 @@ #define GRAPHIC_EXT_BLOCK_SIZE 4 -static int __convert_gif_to_rgba(mm_image_info_s *decoded, ColorMapObject *color_map, GifRowType *screen_buffer, unsigned long width, unsigned long height) +static int __convert_gif_to_rgba(void *data, ColorMapObject *color_map, GifRowType *screen_buffer, unsigned long width, unsigned long height) { unsigned long i, j; GifRowType gif_row; GifColorType *color_map_entry; GifByteType *buffer; - mm_util_debug("__convert_gif_to_rgba"); - if ((decoded->data = (void *)calloc(1, width * height * 4)) == NULL) { + mm_util_fenter(); + + if ((data = (void *)calloc(1, width * height * 4)) == NULL) { mm_util_error("Failed to allocate memory required, aborted."); return MM_UTIL_ERROR_OUT_OF_MEMORY; } - buffer = (GifByteType *) decoded->data; + buffer = (GifByteType *) data; for (i = 0; i < height; i++) { gif_row = screen_buffer[i]; for (j = 0; j < width; j++) { @@ -71,11 +72,14 @@ static int __read_function(GifFileType *gft, GifByteType *data, int size) memcpy(data, read_data_ptr->mem + read_data_ptr->size, size); read_data_ptr->size += size; } + return size; } static int __read_gif(mm_image_info_s *decoded, const char *filename, void *memory) { + int ret = MM_UTIL_ERROR_NONE; + int ExtCode, i, j, Row, Col, Width, Height; size_t Size = 0; GifRecordType record_type; @@ -84,9 +88,9 @@ static int __read_gif(mm_image_info_s *decoded, const char *filename, void *memo unsigned int image_num = 0; ColorMapObject *ColorMap; gif_mem_s read_data_ptr; - int ret; - mm_util_debug("mm_util_decode_from_gif"); + mm_util_fenter(); + if (filename) { if ((GifFile = DGifOpenFileName(filename, NULL)) == NULL) { mm_util_error("could not open Gif File"); @@ -224,7 +228,7 @@ static int __read_gif(mm_image_info_s *decoded, const char *filename, void *memo goto error; } - ret = __convert_gif_to_rgba(decoded, ColorMap, screen_buffer, GifFile->SWidth, GifFile->SHeight); + ret = __convert_gif_to_rgba(decoded->data, ColorMap, screen_buffer, GifFile->SWidth, GifFile->SHeight); if (ret != MM_UTIL_ERROR_NONE) { mm_util_error("could not convert gif to rgba"); ret = MM_UTIL_ERROR_INVALID_OPERATION; @@ -490,11 +494,10 @@ int _gif_image_write_image(gif_file_s *gif_file, mm_image_info_s *gif_image) return MM_UTIL_ERROR_NONE; } -int _gif_image_create_ext_block(mm_image_info_s *gif_image, int function, int byte_count, ExtensionBlock **ext_block) +int _gif_image_create_ext_block(int function, int byte_count, ExtensionBlock **ext_block) { ExtensionBlock *_ext_block = NULL; - mm_util_retvm_if(gif_image == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter"); mm_util_retvm_if(byte_count == 0, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter"); mm_util_retvm_if(ext_block == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter"); @@ -519,16 +522,15 @@ int _gif_image_create_ext_block(mm_image_info_s *gif_image, int function, int by return MM_UTIL_ERROR_NONE; } -int _gif_image_write_ext_block(gif_file_s *gif_file, mm_image_info_s *gif_image) +int _gif_image_write_ext_block(gif_file_s *gif_file, unsigned int delay_time) { int ret = MM_UTIL_ERROR_NONE; ExtensionBlock *_ext_block = NULL; GraphicsControlBlock graphic_control_block; mm_util_retvm_if(gif_file == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter"); - mm_util_retvm_if(gif_image == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter"); - ret = _gif_image_create_ext_block(gif_image, GRAPHICS_EXT_FUNC_CODE, GRAPHIC_EXT_BLOCK_SIZE, &_ext_block); + ret = _gif_image_create_ext_block(GRAPHICS_EXT_FUNC_CODE, GRAPHIC_EXT_BLOCK_SIZE, &_ext_block); mm_util_retvm_if(ret != MM_UTIL_ERROR_NONE, ret, "_gif_image_alloc_ext_block failed"); mm_util_retvm_if(_ext_block->Bytes == NULL, MM_UTIL_ERROR_OUT_OF_MEMORY, "_gif_image_alloc_ext_block failed"); @@ -536,7 +538,7 @@ int _gif_image_write_ext_block(gif_file_s *gif_file, mm_image_info_s *gif_image) graphic_control_block.DisposalMode = MM_UTIL_GIF_DISPOSAL_UNSPECIFIED; graphic_control_block.UserInputFlag = FALSE; graphic_control_block.TransparentColor = NO_TRANSPARENT_COLOR; - graphic_control_block.DelayTime = gif_image->delay_time; + graphic_control_block.DelayTime = delay_time; EGifGCBToExtension(&graphic_control_block, _ext_block->Bytes); @@ -656,7 +658,7 @@ int mm_util_gif_encode_add_image(mm_gif_file_h gif_file_h, mm_image_info_s *gif_ } /* Write graphic control block */ - ret = _gif_image_write_ext_block(gif_file, gif_image); + ret = _gif_image_write_ext_block(gif_file, gif_image->delay_time); mm_util_retvm_if(ret != MM_UTIL_ERROR_NONE, ret, "_gif_image_write_ext_block failed"); /* Write image description & data */ -- 2.7.4