From 50db31a44c13d632d4ddeeba0565255e9405e90d Mon Sep 17 00:00:00 2001 From: "jiyong.min" Date: Fri, 12 Oct 2018 09:37:25 +0900 Subject: [PATCH] Replace mm_util_gif_format to mm_image_info_s Change-Id: Iccea411e9d3faacaea592ec8677ab488df581518 --- gif/include/mm_util_gif.h | 76 ++------------------------------------- gif/include/mm_util_gif_private.h | 7 +++- gif/mm_util_gif.c | 15 ++++---- gif/test/mm_util_gif_testsuite.c | 4 +-- 4 files changed, 18 insertions(+), 84 deletions(-) diff --git a/gif/include/mm_util_gif.h b/gif/include/mm_util_gif.h index 5aff4b2..8957d6f 100755 --- a/gif/include/mm_util_gif.h +++ b/gif/include/mm_util_gif.h @@ -38,29 +38,6 @@ extern "C" { */ /** - * Read data attached to decoding callback - */ -typedef struct { - size_t size; - void *mem; -} read_data; - -/** - * Write data attached to encoding callback - */ -typedef struct { - size_t size; - void **mem; -} write_data; - -/** - * format for gif - */ -typedef enum { - MM_UTIL_GIF_FMT_RGBA8888, /**< RGBA8888 format */ -} mm_util_gif_format; - -/** * Disposal mode for gif encoding */ typedef enum { @@ -70,63 +47,14 @@ typedef enum { MM_UTIL_GIF_DISPOSAL_PREVIOUS = 3, /**< Restore to previous content. */ } mm_util_gif_disposal; -typedef struct { - unsigned char red; - unsigned char green; - unsigned char blue; -} mm_util_gif_color_s; - -typedef struct { - unsigned long long delay_time; /**< Pre-display delay in 0.01sec units */ - unsigned long width; /**< Width */ - unsigned long height; /**< Height */ - unsigned long x; /**< X position */ - unsigned long y; /**< Y position */ - void *data; /**< Data */ -} mm_util_gif_frame_data; - #define GRAPHIC_EXT_BLOCK_SIZE 4 -#define APP_EXT_BLOCK_SIZE 11 -#define APP_EXT_BLOCK_DATA "NETSCAPE2.0" -#define SUB_BLOCK_SIZE 3 -#define NETSCAPE_SUB_BLOCK_INDEX 1 typedef void* mm_gif_image_h; typedef void* mm_gif_file_h; -typedef struct { - unsigned long width; /**< Width */ - unsigned long height; /**< Height */ - size_t size; /**< Size */ - void *data; /**< Frames */ -} mm_util_gif_data; - -/** - * This function extracts raw data from gif file - * - * @param decoded [out] pointer of mm_util_gif_data. - * After using it, please free the allocated memory. - * @param filename [in] input file name, encoded stream file - * @return This function returns zero on success, or negative value with error code. - * @remark - * @see mm_util_gif_data - * @since R1, 1.0 - */ -int mm_util_decode_from_gif_file(mm_util_gif_data * decoded, const char *filename); - -/** - * This function extracts raw data from gif memory - * - * @param decoded [out] pointer of mm_util_gif_data. - * After using it, please free the allocated memory. - * @param memory [in] input file memory, encoded stream file - * @return This function returns zero on success, or negative value with error code. - * @remark - * @see mm_util_gif_data - * @since R1, 1.0 - */ -int mm_util_decode_from_gif_memory(mm_util_gif_data * decoded, void *memory); +int mm_util_decode_from_gif_file(const char *filename, mm_image_info_s * decoded); +int mm_util_decode_from_gif_memory(void *memory, mm_image_info_s * decoded); /** * This function creates the handle of the single image(frame). diff --git a/gif/include/mm_util_gif_private.h b/gif/include/mm_util_gif_private.h index ca7ece7..f8a0167 100755 --- a/gif/include/mm_util_gif_private.h +++ b/gif/include/mm_util_gif_private.h @@ -30,6 +30,11 @@ extern "C" { #endif typedef struct { + size_t size; + void **mem; +} gif_mem_s; + +typedef struct { /* for giflib, Same as SavedImage */ GifImageDesc image_desc; void *image_data; @@ -50,7 +55,7 @@ typedef struct { void **enc_buffer; /**< Encoded output data attached to callback */ size_t *enc_buffer_size; unsigned char *buffer; - write_data write_data_ptr; /**< Encoded output data attached to callback */ + gif_mem_s write_data_ptr; /**< Encoded output data attached to callback */ gboolean is_started; int saved_image_count; diff --git a/gif/mm_util_gif.c b/gif/mm_util_gif.c index 2195c61..0ce9736 100755 --- a/gif/mm_util_gif.c +++ b/gif/mm_util_gif.c @@ -34,7 +34,8 @@ #define RGB_ALLOC(r, g, b, number, size) { r = calloc(1, number * size); g = calloc(1, number * size); b = calloc(1, number * size); } #define RGB_FREE(r, g, b) { MMUTIL_SAFE_FREE(r); MMUTIL_SAFE_FREE(g); MMUTIL_SAFE_FREE(b); } -static int __convert_gif_to_rgba(mm_util_gif_data *decoded, ColorMapObject *color_map, GifRowType *screen_buffer, unsigned long width, unsigned long height) + +static int __convert_gif_to_rgba(mm_image_info_s *decoded, ColorMapObject *color_map, GifRowType *screen_buffer, unsigned long width, unsigned long height) { unsigned long i, j; GifRowType gif_row; @@ -63,7 +64,7 @@ static int __convert_gif_to_rgba(mm_util_gif_data *decoded, ColorMapObject *colo static int __read_function(GifFileType *gft, GifByteType *data, int size) { - read_data *read_data_ptr = (read_data *) gft->UserData; + gif_mem_s *read_data_ptr = (gif_mem_s *) gft->UserData; if (read_data_ptr->mem && size > 0) { memcpy(data, read_data_ptr->mem + read_data_ptr->size, size); @@ -72,7 +73,7 @@ static int __read_function(GifFileType *gft, GifByteType *data, int size) return size; } -static int __read_gif(mm_util_gif_data *decoded, const char *filename, void *memory) +static int __read_gif(mm_image_info_s *decoded, const char *filename, void *memory) { int ExtCode, i, j, Row, Col, Width, Height; size_t Size = 0; @@ -81,7 +82,7 @@ static int __read_gif(mm_util_gif_data *decoded, const char *filename, void *mem GifFileType *GifFile; unsigned int image_num = 0; ColorMapObject *ColorMap; - read_data read_data_ptr; + gif_mem_s read_data_ptr; int ret; mm_util_debug("mm_util_decode_from_gif"); @@ -247,14 +248,14 @@ error: return ret; } -int mm_util_decode_from_gif_file(mm_util_gif_data *decoded, const char *fpath) +int mm_util_decode_from_gif_file(const char *fpath, mm_image_info_s *decoded) { mm_util_fenter(); return __read_gif(decoded, fpath, NULL); } -int mm_util_decode_from_gif_memory(mm_util_gif_data *decoded, void *memory) +int mm_util_decode_from_gif_memory(void *memory, mm_image_info_s *decoded) { mm_util_fenter(); @@ -263,7 +264,7 @@ int mm_util_decode_from_gif_memory(mm_util_gif_data *decoded, void *memory) static int __write_function(GifFileType *gft, const GifByteType *data, int size) { - write_data *write_data_ptr = (write_data *) gft->UserData; + gif_mem_s *write_data_ptr = (gif_mem_s *) gft->UserData; if (size > 0) { *(write_data_ptr->mem) = (void *)realloc(*(write_data_ptr->mem), (write_data_ptr->size + size)); diff --git a/gif/test/mm_util_gif_testsuite.c b/gif/test/mm_util_gif_testsuite.c index 7799915..783004e 100755 --- a/gif/test/mm_util_gif_testsuite.c +++ b/gif/test/mm_util_gif_testsuite.c @@ -34,7 +34,7 @@ static gboolean g_encode_mem = FALSE; typedef struct { char file_name[PATH_MAX]; - mm_util_gif_data decoded; + mm_image_info_s decoded; } gif_test_data_s; @@ -139,7 +139,7 @@ int main(int argc, char *argv[]) for (i = 0; i < nfiles && i < ANIMATED_FRAME_MAX; i++) { fprintf(stderr, "\tdecode %s\n", files[i].file_name); - ret = mm_util_decode_from_gif_file(&files[i].decoded, files[i].file_name); + ret = mm_util_decode_from_gif_file(files[i].file_name, &files[i].decoded); if (ret != MM_UTIL_ERROR_NONE) { fprintf(stderr, "\tERROR is occurred %x to decode %s\n", ret, files[i].file_name); continue; -- 2.7.4