Code Refactoring - remove inefficient external function for png 94/171194/3 submit/tizen/20180228.025609
authorJiyong Min <jiyong.min@samsung.com>
Tue, 27 Feb 2018 09:51:15 +0000 (18:51 +0900)
committerJiyong Min <jiyong.min@samsung.com>
Wed, 28 Feb 2018 00:24:27 +0000 (00:24 +0000)
Change-Id: I3ed08594843b64a57259732967eb8dfcfc5469df
Signed-off-by: Jiyong Min <jiyong.min@samsung.com>
include/image_util_private.h
packaging/capi-media-image-util.spec
src/image_util_decode.c
src/image_util_encode.c

index 22a34f9..c465bd7 100755 (executable)
@@ -148,6 +148,7 @@ typedef struct {
        unsigned long height;
        unsigned int mode;
        int quality;
+       image_util_png_compression_e compression;
        unsigned int current_buffer_count;
        unsigned int current_resolution_count;
        unsigned int current_delay_count;
index d6aa217..a54b7b4 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       capi-media-image-util
 Summary:    A Image Utility library in Tizen Native API
-Version:    0.1.34
+Version:    0.1.35
 Release:    2
 Group:      Multimedia/API
 License:    Apache-2.0
index cb03962..8cdb0e6 100755 (executable)
@@ -135,8 +135,6 @@ static int _image_util_decode_create_png_handle(decode_encode_s * handle)
        mm_util_png_data *_handle = (mm_util_png_data *) calloc(1, sizeof(mm_util_png_data));
        image_util_retvm_if((_handle == NULL), IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
 
-       mm_util_init_decode_png(_handle);
-
        handle->image_h = (mm_util_imgp_h) _handle;
 
        return IMAGE_UTIL_ERROR_NONE;
index b2338a0..5c6332a 100755 (executable)
@@ -83,9 +83,8 @@ static int _image_util_encode_create_png_handle(decode_encode_s * handle)
        mm_util_png_data *_handle = (mm_util_png_data *) calloc(1, sizeof(mm_util_png_data));
        image_util_retvm_if((_handle == NULL), IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
 
-       mm_util_init_encode_png(_handle);
-
        handle->image_h = (mm_util_imgp_h) _handle;
+       handle->compression = IMAGE_UTIL_PNG_COMPRESSION_6;
 
        return IMAGE_UTIL_ERROR_NONE;
 }
@@ -186,8 +185,8 @@ int image_util_encode_set_resolution(image_util_encode_h handle, unsigned long w
        case IMAGE_UTIL_PNG:
                {
                        mm_util_png_data *png_data = (mm_util_png_data *) _handle->image_h;
-                       mm_util_png_encode_set_width(png_data, width);
-                       mm_util_png_encode_set_height(png_data, height);
+                       png_data->width = width;
+                       png_data->height = height;
                }
                break;
        case IMAGE_UTIL_GIF:
@@ -270,17 +269,13 @@ int image_util_encode_set_png_compression(image_util_encode_h handle, image_util
 {
        int err = IMAGE_UTIL_ERROR_NONE;
        decode_encode_s *_handle = (decode_encode_s *) handle;
-       mm_util_png_data *png_data;
 
        IMAGE_UTIL_ENCODE_HANDLE_CHECK(_handle);
        IMAGE_UTIL_SUPPORT_TYPE_CHECK(_handle->image_type, IMAGE_UTIL_PNG);
 
        image_util_retvm_if((compression < IMAGE_UTIL_PNG_COMPRESSION_0 || compression > IMAGE_UTIL_PNG_COMPRESSION_9), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid compression value");
 
-       png_data = (mm_util_png_data *) _handle->image_h;
-       image_util_retvm_if(png_data == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid png data");
-
-       mm_util_png_encode_set_compression_level(png_data, compression);
+       _handle->compression = compression;
 
        return err;
 }
@@ -410,9 +405,9 @@ static int _image_util_encode_internal(decode_encode_s * _handle)
                        mm_util_png_data *png_data = (mm_util_png_data *) _handle->image_h;
 
                        if (_handle->path)
-                               err = mm_util_encode_to_png_file(&(_handle->src_buffer[0]), png_data, _handle->path);
+                               err = mm_util_encode_to_png_file(&(_handle->src_buffer[0]), png_data, _handle->path, _handle->compression);
                        else
-                               err = mm_util_encode_to_png_memory(&(_handle->src_buffer[0]), png_data);
+                               err = mm_util_encode_to_png_memory(&(_handle->src_buffer[0]), png_data, _handle->compression);
 
                        if (err == MM_UTIL_ERROR_NONE) {
                                if (_handle->dst_buffer)