Modify parameters in encoding APIs have been changed from mm_image_info_s to mm_util_... 63/201263/8 accepted/tizen/unified/20190318.221230 submit/tizen/20190313.075153
authorhj kim <backto.kim@samsung.com>
Tue, 12 Mar 2019 04:00:09 +0000 (13:00 +0900)
committerjiyong.min <jiyong.min@samsung.com>
Fri, 15 Mar 2019 05:46:47 +0000 (14:46 +0900)
Change-Id: I6fb2dd73bcd005d36fcfef1ae84eeac2964c1088

src/image_util_decode.c
src/image_util_encode.c

index a56304e..99b2a0a 100755 (executable)
@@ -229,11 +229,11 @@ static int __image_util_decode_internal(decode_s * _handle, mm_util_image_h *ima
        int colorspace = 0;
        int downscale = 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_fenter();
+
        switch (_handle->image_type) {
        case IMAGE_UTIL_JPEG:
                {
@@ -276,6 +276,8 @@ static int __image_util_decode_internal(decode_s * _handle, mm_util_image_h *ima
                break;
        }
 
+       image_util_fleave();
+
        return _image_error_capi(err);
 }
 
index 896c8ea..d1b0ebc 100755 (executable)
@@ -19,6 +19,7 @@
 #include <mm_util_png.h>
 #include <mm_util_gif.h>
 #include <mm_util_bmp.h>
+#include <mm_util_image.h>
 
 #include <image_util.h>
 #include <image_util_private.h>
@@ -221,6 +222,7 @@ int image_util_encode_set_input_buffer(image_util_encode_h handle, const unsigne
                        image_util_retvm_if(err != IMAGE_UTIL_ERROR_NONE, err, "__allocate_source_buffer is failed");
                }
                _handle->gif_encode_info.sources[_handle->gif_encode_info.current_buffer_count]->data = (void *)src_buffer;
+               _handle->gif_encode_info.sources[_handle->gif_encode_info.current_buffer_count]->size = TEMP_DATA_SIZE;
                _handle->gif_encode_info.current_buffer_count++;
        } else {
                _handle->src.data = (void *)src_buffer;
@@ -264,26 +266,34 @@ int image_util_encode_set_output_buffer(image_util_encode_h handle, unsigned cha
 static int _image_util_encode_internal(encode_s * _handle)
 {
        int err = MM_UTIL_ERROR_NONE;
+       mm_util_image_h _src = NULL;
 
-       image_util_retvm_if(_handle == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter");
-       image_util_retvm_if((_handle->image_type != IMAGE_UTIL_GIF && __is_invalid_image_info(_handle->src)), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid input");
-       image_util_retvm_if((_handle->image_type == IMAGE_UTIL_GIF && (_handle->gif_encode_info.sources == NULL || __is_invalid_image_info(*_handle->gif_encode_info.sources[0]))), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid input");
+       image_util_retvm_if(!_handle, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid _handle");
+       image_util_retvm_if((_handle->image_type != IMAGE_UTIL_GIF && __is_invalid_image_info(_handle->src)), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid image");
+       image_util_retvm_if((_handle->image_type == IMAGE_UTIL_GIF && (!_handle->gif_encode_info.sources || __is_invalid_image_info(*_handle->gif_encode_info.sources[0]))), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid gif");
+
+       image_util_fenter();
+
+       if (_handle->image_type != IMAGE_UTIL_GIF) {
+               err = mm_image_create_image(_handle->src.width, _handle->src.height, _handle->src.color, _handle->src.data, TEMP_DATA_SIZE, &_src);
+               image_util_retvm_if(err != MM_UTIL_ERROR_NONE, _image_error_capi(err), "fail to mm_image_create_image");
+       }
 
        switch (_handle->image_type) {
        case IMAGE_UTIL_JPEG:
                {
                        if (_handle->path)
-                               err = mm_util_jpeg_encode_to_file(&_handle->src, _handle->quality, _handle->path);
+                               err = mm_util_jpeg_encode_to_file(_src, _handle->quality, _handle->path);
                        else
-                               err = mm_util_encode_to_jpeg_memory(&_handle->src, _handle->quality, _handle->dst_buffer, &_handle->dst_size);
+                               err = mm_util_encode_to_jpeg_memory(_src, _handle->quality, _handle->dst_buffer, &_handle->dst_size);
                }
                break;
        case IMAGE_UTIL_PNG:
                {
                        if (_handle->path)
-                               err = mm_util_encode_to_png_file(&_handle->src, _handle->compression, _handle->path);
+                               err = mm_util_encode_to_png_file(_src, _handle->compression, _handle->path);
                        else
-                               err = mm_util_encode_to_png_memory(&_handle->src, _handle->compression, _handle->dst_buffer, &_handle->dst_size);
+                               err = mm_util_encode_to_png_memory(_src, _handle->compression, _handle->dst_buffer, &_handle->dst_size);
                }
                break;
        case IMAGE_UTIL_GIF:
@@ -295,17 +305,17 @@ static int _image_util_encode_internal(encode_s * _handle)
                        }
 
                        if (_handle->path)
-                               err = mm_util_encode_to_gif_file(_handle->gif_encode_info.sources, _handle->gif_encode_info.source_count, _handle->path);
+                               err = mm_util_encode_to_gif_file((mm_util_image_h *)_handle->gif_encode_info.sources, _handle->gif_encode_info.source_count, _handle->path);
                        else
-                               err = mm_util_encode_to_gif_memory(_handle->gif_encode_info.sources, _handle->gif_encode_info.source_count, _handle->dst_buffer, &_handle->dst_size);
+                               err = mm_util_encode_to_gif_memory((mm_util_image_h *)_handle->gif_encode_info.sources, _handle->gif_encode_info.source_count, _handle->dst_buffer, &_handle->dst_size);
                }
                break;
        case IMAGE_UTIL_BMP:
                {
                        if (_handle->path)
-                               err = mm_util_encode_bmp_to_file(&_handle->src, _handle->path);
+                               err = mm_util_encode_bmp_to_file(_src, _handle->path);
                        else
-                               err = mm_util_encode_bmp_to_memory(&_handle->src, _handle->dst_buffer, &_handle->dst_size);
+                               err = mm_util_encode_bmp_to_memory(_src, _handle->dst_buffer, &_handle->dst_size);
                }
                break;
        default:
@@ -313,7 +323,10 @@ static int _image_util_encode_internal(encode_s * _handle)
                break;
        }
 
-       __free_source_buffer(_handle);
+       mm_image_destroy_image(_src);
+       __free_source_buffer(_handle);  /* free gif_encode_info.sources */
+
+       image_util_fleave();
 
        return _image_error_capi(err);
 }