Change source buffer to 'void*' from 'void**', decoding an image needs single source... 14/191614/2
authorjiyong.min <jiyong.min@samsung.com>
Fri, 19 Oct 2018 04:43:40 +0000 (13:43 +0900)
committerJiyong Min <jiyong.min@samsung.com>
Fri, 19 Oct 2018 04:58:15 +0000 (04:58 +0000)
Change-Id: I7c1dc60f5fdac93f5b34d085ca36ff2bd3cb2ba3

include/image_util_private.h
src/image_util_decode.c

index 1ff6168..8610ef3 100755 (executable)
@@ -160,7 +160,7 @@ typedef struct {
 
 typedef struct {
        image_util_type_e image_type;
-       void **src_buffer;
+       void *src_buffer;
        size_t src_size;
        void **dst_buffer;
        char *path;
index 6368288..8fa201e 100755 (executable)
@@ -135,9 +135,6 @@ int image_util_decode_set_input_path(image_util_decode_h handle, const char *pat
        image_util_retvm_if(_handle == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
        image_util_retvm_if(!IMAGE_UTIL_STRING_VALID(path), IMAGE_UTIL_ERROR_NO_SUCH_FILE, "Invalid path");
 
-       if (_handle->src_buffer)
-               _handle->src_buffer = NULL;
-
        err = _image_util_decode_read_header(path, &image_header);
        image_util_retvm_if((err != IMAGE_UTIL_ERROR_NONE), err, "_image_util_decode_read_header failed");
 
@@ -169,12 +166,7 @@ int image_util_decode_set_input_buffer(image_util_decode_h handle, const unsigne
        err = _image_util_decode_check_image_type(src_buffer, &_handle->image_type);
        image_util_retvm_if(err != IMAGE_UTIL_ERROR_NONE, err, "_image_util_decode_check_image_type failed");
 
-       IMAGE_UTIL_SAFE_FREE(_handle->src_buffer);
-
-       _handle->src_buffer = (void *)calloc(1, sizeof(void *));
-       image_util_retvm_if(_handle->src_buffer == NULL, IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "The memory of input buffer was not allocated");
-
-       _handle->src_buffer[0] = (void *)src_buffer;
+       _handle->src_buffer = (void *)src_buffer;
        _handle->src_size = src_size;
 
        return err;
@@ -243,7 +235,7 @@ static int _image_util_decode_internal(decode_s * _handle, unsigned long *res_wi
                        if (_handle->path)
                                err = mm_util_decode_from_jpeg_file(_handle->path, TYPECAST_COLOR_BY_TYPE(_handle->colorspace, IMAGE_UTIL_JPEG), _convert_decode_scale_tbl[_handle->down_scale], &image_info);
                        else
-                               err = mm_util_decode_from_jpeg_memory(_handle->src_buffer[0], _handle->src_size, TYPECAST_COLOR_BY_TYPE(_handle->colorspace, IMAGE_UTIL_JPEG), _convert_decode_scale_tbl[_handle->down_scale], &image_info);
+                               err = mm_util_decode_from_jpeg_memory(_handle->src_buffer, _handle->src_size, TYPECAST_COLOR_BY_TYPE(_handle->colorspace, IMAGE_UTIL_JPEG), _convert_decode_scale_tbl[_handle->down_scale], &image_info);
                }
                break;
        case IMAGE_UTIL_PNG:
@@ -251,7 +243,7 @@ static int _image_util_decode_internal(decode_s * _handle, unsigned long *res_wi
                        if (_handle->path)
                                err = mm_util_decode_from_png_file(_handle->path, &image_info);
                        else
-                               err = mm_util_decode_from_png_memory(_handle->src_buffer[0], (size_t)_handle->src_size, &image_info);
+                               err = mm_util_decode_from_png_memory(_handle->src_buffer, (size_t)_handle->src_size, &image_info);
                }
                break;
        case IMAGE_UTIL_GIF:
@@ -259,7 +251,7 @@ static int _image_util_decode_internal(decode_s * _handle, unsigned long *res_wi
                        if (_handle->path)
                                err = mm_util_decode_from_gif_file(_handle->path, &image_info);
                        else
-                               err = mm_util_decode_from_gif_memory(_handle->src_buffer[0], (size_t)_handle->src_size, &image_info);
+                               err = mm_util_decode_from_gif_memory(_handle->src_buffer, (size_t)_handle->src_size, &image_info);
                }
                break;
        case IMAGE_UTIL_BMP:
@@ -267,7 +259,7 @@ static int _image_util_decode_internal(decode_s * _handle, unsigned long *res_wi
                        if (_handle->path)
                                err = mm_util_decode_from_bmp_file(_handle->path, &image_info);
                        else
-                               err = mm_util_decode_from_bmp_memory(_handle->src_buffer[0], (size_t)_handle->src_size, &image_info);
+                               err = mm_util_decode_from_bmp_memory(_handle->src_buffer, (size_t)_handle->src_size, &image_info);
                }
                break;
        default:
@@ -413,7 +405,6 @@ int image_util_decode_destroy(image_util_decode_h handle)
                IMAGE_UTIL_SAFE_FREE(_handle->_decode_cb);
        }
        IMAGE_UTIL_SAFE_FREE(_handle->path);
-       IMAGE_UTIL_SAFE_FREE(_handle->src_buffer);
        IMAGE_UTIL_SAFE_FREE(_handle);
 
        image_util_fleave();