Change the order of the parameters 85/171585/1
authorJiyong Min <jiyong.min@samsung.com>
Tue, 6 Mar 2018 04:58:52 +0000 (13:58 +0900)
committerJiyong Min <jiyong.min@samsung.com>
Tue, 6 Mar 2018 05:07:48 +0000 (14:07 +0900)
 - The order is input parameter before output parameter.
 - The decoded data is composed with width, height, format, data and size.
 - The source data of encoding is replaced to the decoded data.

Change-Id: Ica464d3609a5821d6ac1d358522815c6dee42aa8
Signed-off-by: Jiyong Min <jiyong.min@samsung.com>
packaging/capi-media-image-util.spec
src/image_util_decode.c
src/image_util_encode.c

index a54b7b4..f716fa4 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       capi-media-image-util
 Summary:    A Image Utility library in Tizen Native API
-Version:    0.1.35
+Version:    0.1.36
 Release:    2
 Group:      Multimedia/API
 License:    Apache-2.0
index 8cdb0e6..c273aaa 100755 (executable)
@@ -350,9 +350,9 @@ static int _image_util_decode_internal(decode_encode_s * _handle)
                        mm_util_jpeg_yuv_data *jpeg_data = (mm_util_jpeg_yuv_data *) _handle->image_h;
 
                        if (_handle->path)
-                                       err = mm_util_decode_from_jpeg_file_with_downscale(jpeg_data, _handle->path, TYPECAST_COLOR_BY_TYPE(_handle->colorspace, IMAGE_UTIL_JPEG), _convert_decode_scale_tbl[_handle->down_scale]);
+                                       err = mm_util_decode_from_jpeg_file_with_downscale(_handle->path, TYPECAST_COLOR_BY_TYPE(_handle->colorspace, IMAGE_UTIL_JPEG), _convert_decode_scale_tbl[_handle->down_scale], jpeg_data);
                        else
-                                       err = mm_util_decode_from_jpeg_memory_with_downscale(jpeg_data, _handle->src_buffer[0], (unsigned int)_handle->src_size, TYPECAST_COLOR_BY_TYPE(_handle->colorspace, IMAGE_UTIL_JPEG), _convert_decode_scale_tbl[_handle->down_scale]);
+                                       err = mm_util_decode_from_jpeg_memory_with_downscale(_handle->src_buffer[0], (unsigned int)_handle->src_size, TYPECAST_COLOR_BY_TYPE(_handle->colorspace, IMAGE_UTIL_JPEG), _convert_decode_scale_tbl[_handle->down_scale], jpeg_data);
 
                        if (err == MM_UTIL_ERROR_NONE) {
                                *(_handle->dst_buffer) = jpeg_data->data;
@@ -367,9 +367,9 @@ static int _image_util_decode_internal(decode_encode_s * _handle)
                        mm_util_png_data *png_data = (mm_util_png_data *) _handle->image_h;
 
                        if (_handle->path)
-                               err = mm_util_decode_from_png_file(png_data, _handle->path);
+                               err = mm_util_decode_from_png_file(_handle->path, png_data);
                        else
-                               err = mm_util_decode_from_png_memory(png_data, _handle->src_buffer[0], _handle->src_size);
+                               err = mm_util_decode_from_png_memory(_handle->src_buffer[0], _handle->src_size, png_data);
 
                        if (err == MM_UTIL_ERROR_NONE) {
                                *(_handle->dst_buffer) = png_data->data;
@@ -401,9 +401,9 @@ static int _image_util_decode_internal(decode_encode_s * _handle)
                        mm_util_bmp_data *bmp_data = (mm_util_bmp_data *) _handle->image_h;
 
                        if (_handle->path)
-                               err = mm_util_decode_from_bmp_file(bmp_data, _handle->path);
+                               err = mm_util_decode_from_bmp_file(_handle->path, bmp_data);
                        else
-                               err = mm_util_decode_from_bmp_memory(bmp_data, _handle->src_buffer[0], _handle->src_size);
+                               err = mm_util_decode_from_bmp_memory(_handle->src_buffer[0], _handle->src_size, bmp_data);
 
                        if (err == MM_UTIL_ERROR_NONE) {
                                *(_handle->dst_buffer) = bmp_data->data;
@@ -572,7 +572,7 @@ int image_util_decode_jpeg_with_downscale(const char *path, image_util_colorspac
        mm_util_jpeg_yuv_data decoded;
        memset(&decoded, 0, sizeof(mm_util_jpeg_yuv_data));
 
-       err = mm_util_decode_from_jpeg_file_with_downscale(&decoded, path, TYPECAST_COLOR_BY_TYPE(colorspace, IMAGE_UTIL_JPEG), _convert_decode_scale_tbl[downscale]);
+       err = mm_util_decode_from_jpeg_file_with_downscale(path, TYPECAST_COLOR_BY_TYPE(colorspace, IMAGE_UTIL_JPEG), _convert_decode_scale_tbl[downscale], &decoded);
        if (err == MM_UTIL_ERROR_NONE) {
                *image_buffer = decoded.data;
                if (width)
@@ -601,7 +601,7 @@ int image_util_decode_jpeg_from_memory_with_downscale(const unsigned char *jpeg_
        mm_util_jpeg_yuv_data decoded;
        memset(&decoded, 0, sizeof(mm_util_jpeg_yuv_data));
 
-       err = mm_util_decode_from_jpeg_memory_with_downscale(&decoded, (void *)jpeg_buffer, (unsigned int)jpeg_size, TYPECAST_COLOR_BY_TYPE(colorspace, IMAGE_UTIL_JPEG), _convert_decode_scale_tbl[downscale]);
+       err = mm_util_decode_from_jpeg_memory_with_downscale((void *)jpeg_buffer, (unsigned int)jpeg_size, TYPECAST_COLOR_BY_TYPE(colorspace, IMAGE_UTIL_JPEG), _convert_decode_scale_tbl[downscale], &decoded);
 
        if (err == MM_UTIL_ERROR_NONE) {
                *image_buffer = decoded.data;
index 0717d07..bfd9f33 100755 (executable)
@@ -394,10 +394,19 @@ static int _image_util_encode_internal(decode_encode_s * _handle)
        switch (_handle->image_type) {
        case IMAGE_UTIL_JPEG:
                {
+                       mm_util_jpeg_yuv_data *jpeg_data = (mm_util_jpeg_yuv_data *) _handle->image_h;
+                       unsigned int size = 0;
+
+                       jpeg_data->data = _handle->src_buffer[0];
+                       jpeg_data->format = TYPECAST_COLOR_BY_TYPE(_handle->colorspace, IMAGE_UTIL_JPEG);
+
                        if (_handle->path)
-                               err = mm_util_jpeg_encode_to_file(_handle->path, _handle->src_buffer[0], _handle->width, _handle->height, TYPECAST_COLOR_BY_TYPE(_handle->colorspace, IMAGE_UTIL_JPEG), _handle->quality);
+                               err = mm_util_jpeg_encode_to_file(jpeg_data, _handle->quality, _handle->path);
                        else
-                               err = mm_util_jpeg_encode_to_memory(_handle->dst_buffer, (unsigned int *)&(_handle->dst_size), _handle->src_buffer[0], _handle->width, _handle->height, TYPECAST_COLOR_BY_TYPE(_handle->colorspace, IMAGE_UTIL_JPEG), _handle->quality);
+                               err = mm_util_jpeg_encode_to_memory(jpeg_data, _handle->quality, _handle->dst_buffer, &size);
+
+                       if (err == MM_UTIL_ERROR_NONE)
+                               _handle->dst_size = (unsigned long long)size;
                }
                break;
        case IMAGE_UTIL_PNG:
@@ -412,11 +421,8 @@ static int _image_util_encode_internal(decode_encode_s * _handle)
                        else
                                err = mm_util_encode_to_png_memory(png_data, _handle->compression, _handle->dst_buffer, &size);
 
-                       if (err == MM_UTIL_ERROR_NONE) {
-                               _handle->dst_size = size;
-                               _handle->width = png_data->width;
-                               _handle->height = png_data->height;
-                       }
+                       if (err == MM_UTIL_ERROR_NONE)
+                               _handle->dst_size = (unsigned long long)size;
                }
                break;
        case IMAGE_UTIL_GIF:
@@ -452,23 +458,20 @@ static int _image_util_encode_internal(decode_encode_s * _handle)
        case IMAGE_UTIL_BMP:
                {
                        mm_util_bmp_data *bmp_data = (mm_util_bmp_data *) _handle->image_h;
+                       size_t size = 0;
 
                        bmp_data->data = _handle->src_buffer[0];
                        if (_handle->path) {
                                err = mm_util_encode_bmp_to_file(bmp_data, _handle->path);
                        } else {
-                               size_t size = 0;
                                err = mm_util_encode_bmp_to_memory(bmp_data, _handle->dst_buffer, &size);
                                if (err == MM_UTIL_ERROR_NONE)
                                        bmp_data->size = (unsigned long long)size;
                                else
                                        bmp_data->size = 0;
                        }
-                       if (err == MM_UTIL_ERROR_NONE) {
-                               _handle->dst_size = bmp_data->size;
-                               _handle->width = bmp_data->width;
-                               _handle->height = bmp_data->height;
-                       }
+                       if (err == MM_UTIL_ERROR_NONE)
+                               _handle->dst_size = (unsigned long long)size;
                }
                break;
        default:
@@ -612,7 +615,13 @@ int image_util_encode_jpeg(const unsigned char *buffer, int width, int height, i
        image_util_retvm_if((is_valid_colorspace(colorspace) == FALSE), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid colorspace");
        image_util_retvm_if((is_supported_colorspace(colorspace, IMAGE_UTIL_JPEG) == FALSE), IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "not supported format");
 
-       err = mm_util_jpeg_encode_to_file(path, (void *)buffer, width, height, TYPECAST_COLOR_BY_TYPE(colorspace, IMAGE_UTIL_JPEG), quality);
+       mm_util_jpeg_yuv_data decoded = {0, };
+       decoded.width = width;
+       decoded.height = height;
+       decoded.format = TYPECAST_COLOR_BY_TYPE(colorspace, IMAGE_UTIL_JPEG);
+       decoded.data = (void *)buffer;
+
+       err = mm_util_jpeg_encode_to_file(&decoded, quality, path);
        return _image_error_capi(ERR_TYPE_ENCODE, err);
 }
 
@@ -628,7 +637,13 @@ int image_util_encode_jpeg_to_memory(const unsigned char *image_buffer, int widt
        image_util_retvm_if((is_valid_colorspace(colorspace) == FALSE), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid colorspace");
        image_util_retvm_if((is_supported_colorspace(colorspace, IMAGE_UTIL_JPEG) == FALSE), IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "not supported format");
 
-       err = mm_util_jpeg_encode_to_memory((void **)jpeg_buffer, jpeg_size, (void *)image_buffer, width, height, TYPECAST_COLOR_BY_TYPE(colorspace, IMAGE_UTIL_JPEG), quality);
+       mm_util_jpeg_yuv_data decoded = {0, };
+       decoded.width = width;
+       decoded.height = height;
+       decoded.format = TYPECAST_COLOR_BY_TYPE(colorspace, IMAGE_UTIL_JPEG);
+       decoded.data = (void *)image_buffer;
+
+       err = mm_util_jpeg_encode_to_memory(&decoded, quality, (void **)jpeg_buffer, jpeg_size);
        return _image_error_capi(ERR_TYPE_ENCODE, err);
 }