Add code for adding encoding option 50/238250/8 accepted/tizen/unified/20200717.124752 submit/tizen/20200715.035035
authorhj kim <backto.kim@samsung.com>
Fri, 10 Jul 2020 03:48:45 +0000 (12:48 +0900)
committerhj kim <backto.kim@samsung.com>
Mon, 13 Jul 2020 05:51:54 +0000 (05:51 +0000)
Change-Id: I5772d256531ec946637c5d1befa3c27f41f6ae83

packaging/capi-media-image-util.spec
src/image_util_encode.c

index 7acbbd5..71aa93d 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       capi-media-image-util
 Summary:    A Image Utility library in Tizen Native API
-Version:    0.2.6
+Version:    0.2.7
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 3d5b06e..2307b17 100644 (file)
@@ -59,6 +59,7 @@ typedef struct {
        image_util_png_compression_e compression;
        gif_encode_s gif_encode_info;
        encode_cb_s *_encode_cb;
+       mm_util_enc_opt_h enc_opt;
 
        /* for async */
        GThread *thread;
@@ -127,6 +128,20 @@ int image_util_encode_create(image_util_type_e image_type, image_util_encode_h *
        _handle->quality = 75;
        _handle->compression = IMAGE_UTIL_PNG_COMPRESSION_6;
 
+       err = mm_util_enc_opt_create(&_handle->enc_opt);
+       if (err != MM_UTIL_ERROR_NONE) {
+               image_util_error("Error - mm_util_enc_opt_create is failed (%d)", err);
+               image_util_encode_destroy(_handle);
+               return _image_error_capi(err);
+       }
+
+       err = mm_util_enc_opt_set_codec(_handle->enc_opt, image_type);
+       if (err != MM_UTIL_ERROR_NONE) {
+               image_util_error("Error - mm_util_enc_opt_set_codec is failed (%d)", err);
+               image_util_encode_destroy(_handle);
+               return _image_error_capi(err);
+       }
+
        _handle->src.color = IMAGE_UTIL_COLORSPACE_RGBA8888;
 
        _handle->thread = NULL;
@@ -365,9 +380,9 @@ static int __image_util_encode_internal(encode_s * _handle)
        case IMAGE_UTIL_BMP:
                {
                        if (_handle->path)
-                               err = mm_util_encode_image_to_file(_src, _handle->path);
+                               err = mm_util_encode_image_to_file(_src, _handle->enc_opt, _handle->path);
                        else
-                               err = mm_util_encode_image_to_buffer(_src, IMG_CODEC_BMP, _handle->dst_buffer, &_handle->dst_size);
+                               err = mm_util_encode_image_to_buffer(_src, _handle->enc_opt, _handle->dst_buffer, &_handle->dst_size);
                }
                break;
        default:
@@ -411,7 +426,7 @@ static int __image_util_encode_run_to_file(image_util_encode_h handle, image_uti
                break;
 
        case IMAGE_UTIL_BMP:
-               ret = mm_util_encode_image_to_file(image, file_path);
+               ret = mm_util_encode_image_to_file(image, _handle->enc_opt, file_path);
                break;
 
        default:
@@ -450,7 +465,7 @@ static int __image_util_encode_run_to_buffer(image_util_encode_h handle, image_u
                break;
 
        case IMAGE_UTIL_BMP:
-               ret = mm_util_encode_image_to_buffer(image, IMG_CODEC_BMP, (void **)buffer, buffer_size);
+               ret = mm_util_encode_image_to_buffer(image, _handle->enc_opt, (void **)buffer, buffer_size);
                break;
        default:
                return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
@@ -669,6 +684,8 @@ int image_util_encode_destroy(image_util_encode_h handle)
 
        __free_source_buffer(_handle);
 
+       mm_util_enc_opt_destroy(_handle->enc_opt);
+
        g_free(_handle->path);
        g_free(_handle);