Remove redundant parameters 00/191100/1
authorhj kim <backto.kim@samsung.com>
Thu, 11 Oct 2018 08:59:13 +0000 (17:59 +0900)
committerhj kim <backto.kim@samsung.com>
Thu, 11 Oct 2018 08:59:13 +0000 (17:59 +0900)
Change-Id: Ib654f85279fe62377f6af7d7a5c964a4c25156a4

include/image_util_private.h
src/image_util_decode.c

index 4ac3886..6f179fe 100755 (executable)
@@ -171,10 +171,7 @@ typedef struct {
        void **src_buffer;
        size_t src_size;
        void **dst_buffer;
-       size_t dst_size;
        char *path;
-       unsigned long width;
-       unsigned long height;
        int quality;
        image_util_colorspace_e colorspace;
        image_util_scale_e down_scale;
index c09fa54..9eef1f8 100755 (executable)
@@ -255,14 +255,20 @@ int image_util_decode_set_jpeg_downscale(image_util_encode_h handle, image_util_
        return IMAGE_UTIL_ERROR_NONE;
 }
 
-static int _image_util_decode_internal(decode_s * _handle)
+static int _image_util_decode_internal(decode_s * _handle, unsigned long *res_width, unsigned long *res_height, size_t *res_size)
 {
        int err = MM_UTIL_ERROR_NONE;
+       unsigned long _width = 0;
+       unsigned long _height = 0;
+       size_t _size = 0;
 
        image_util_fenter();
 
        image_util_retvm_if((_handle == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "invalid parameter");
        image_util_retvm_if(_handle->dst_buffer == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid output");
+       image_util_retvm_if(res_width == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid res_width");
+       image_util_retvm_if(res_height == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid res_height");
+       image_util_retvm_if(res_size == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid res_size");
 
        switch (_handle->image_type) {
        case IMAGE_UTIL_JPEG:
@@ -277,9 +283,9 @@ static int _image_util_decode_internal(decode_s * _handle)
 
                        if (err == MM_UTIL_ERROR_NONE) {
                                *(_handle->dst_buffer) = jpeg_data.data;
-                               _handle->dst_size = (unsigned long long)jpeg_data.size;
-                               _handle->width = jpeg_data.width;
-                               _handle->height = jpeg_data.height;
+                               _size = jpeg_data.size;
+                               _width = jpeg_data.width;
+                               _height = jpeg_data.height;
                        } else {
                                image_util_error("fail to decode jpeg [%d]", err);
                        }
@@ -297,9 +303,9 @@ static int _image_util_decode_internal(decode_s * _handle)
 
                        if (err == MM_UTIL_ERROR_NONE) {
                                *(_handle->dst_buffer) = png_data.data;
-                               _handle->dst_size = (unsigned long long)png_data.size;
-                               _handle->width = png_data.width;
-                               _handle->height = png_data.height;
+                               _size = png_data.size;
+                               _width = png_data.width;
+                               _height = png_data.height;
                        } else {
                                image_util_error("fail to decode png [%d]", err);
                        }
@@ -317,9 +323,9 @@ static int _image_util_decode_internal(decode_s * _handle)
 
                        if (err == MM_UTIL_ERROR_NONE) {
                                *(_handle->dst_buffer) = gif_data.data;
-                               _handle->dst_size = gif_data.size;
-                               _handle->width = gif_data.width;
-                               _handle->height = gif_data.height;
+                               _size = gif_data.size;
+                               _width = gif_data.width;
+                               _height = gif_data.height;
                        } else {
                                image_util_error("fail to decode gif [%d]", err);
                        }
@@ -337,9 +343,9 @@ static int _image_util_decode_internal(decode_s * _handle)
 
                        if (err == MM_UTIL_ERROR_NONE) {
                                *(_handle->dst_buffer) = bmp_data.data;
-                               _handle->dst_size = (unsigned long long)bmp_data.size;
-                               _handle->width = bmp_data.width;
-                               _handle->height = bmp_data.height;
+                               _size = bmp_data.size;
+                               _width = bmp_data.width;
+                               _height = bmp_data.height;
                        } else {
                                image_util_error("fail to decode bmp [%d]", err);
                        }
@@ -351,7 +357,11 @@ static int _image_util_decode_internal(decode_s * _handle)
                break;
        }
 
-       image_util_debug("dst_buffer(%p) width (%lu) height (%lu) dst_size (%zu)", *(_handle->dst_buffer), _handle->width, _handle->height, _handle->dst_size);
+       *res_width = _width;
+       *res_height = _height;
+       *res_size = _size;
+
+       image_util_debug("dst_buffer(%p) width (%lu) height (%lu) dst_size (%zu)", *(_handle->dst_buffer), *res_width, *res_height, *res_size);
 
        return _image_error_capi(ERR_TYPE_DECODE, err);
 }
@@ -360,34 +370,38 @@ int image_util_decode_run(image_util_decode_h handle, unsigned long *width, unsi
 {
        int err = IMAGE_UTIL_ERROR_NONE;
        decode_s *_handle = (decode_s *) handle;
+       unsigned long _width = 0;
+       unsigned long _height = 0;
+       size_t _size = 0;
 
        IMAGE_UTIL_DECODE_HANDLE_CHECK(handle);
        image_util_retvm_if((_handle->path == NULL && _handle->src_buffer == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid input");
        image_util_retvm_if(_handle->dst_buffer == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid output");
 
-       err = _image_util_decode_internal(_handle);
+       err = _image_util_decode_internal(_handle, &_width, &_height, &_size);
        image_util_retvm_if(err != IMAGE_UTIL_ERROR_NONE, err, "_image_util_decode_internal failed");
 
-       if (width)
-               *width = _handle->width;
-       if (height)
-               *height = _handle->height;
-       if (size)
-               *size = _handle->dst_size;
+       *width = _width;
+       *height = _height;
+       *size = (unsigned long long)_size;
 
        return err;
+
 }
 
 gpointer _image_util_decode_thread(gpointer data)
 {
        decode_s *_handle = (decode_s *) data;
        int err = IMAGE_UTIL_ERROR_NONE;
+       unsigned long _width = 0;
+       unsigned long _height = 0;
+       size_t _size = 0;
 
        image_util_fenter();
 
        image_util_retvm_if((_handle == NULL), NULL, "Invalid Handle");
 
-       err = _image_util_decode_internal(_handle);
+       err = _image_util_decode_internal(_handle, &_width, &_height, &_size);
        if (err == IMAGE_UTIL_ERROR_NONE)
                image_util_debug("Success - decode_internal");
        else
@@ -395,7 +409,7 @@ gpointer _image_util_decode_thread(gpointer data)
 
        if (_handle->_decode_cb) {
                image_util_debug("call completed_cb");
-               _handle->_decode_cb->image_decode_completed_cb(err, _handle->_decode_cb->user_data, _handle->width, _handle->height, _handle->dst_size);
+               _handle->_decode_cb->image_decode_completed_cb(err, _handle->_decode_cb->user_data, _width, _height, (unsigned long long)_size);
        } else {
                image_util_error("No callback");
        }