[ACR-1389][Add/Deprecate] Update decoding APIs 45/201945/25 accepted/tizen/unified/20190418.010737 submit/tizen/20190416.093532
authorhj kim <backto.kim@samsung.com>
Thu, 21 Mar 2019 06:15:00 +0000 (15:15 +0900)
committerhj kim <backto.kim@samsung.com>
Fri, 12 Apr 2019 02:29:43 +0000 (11:29 +0900)
[Deprecated]
int image_util_decode_set_output_buffer(image_util_decode_h handle, unsigned char **dst_buffer)
int image_util_decode_run(image_util_decode_h handle, unsigned long *width, unsigned long *height, unsigned long long *size)
int image_util_decode_run_async(image_util_decode_h handle, image_util_decode_completed_cb callback, void *user_data)
typedef void (*image_util_decode_completed_cb) (int error_code, void *user_data, unsigned long width, unsigned long height, unsigned long long size)

[Added]
int image_util_decode_run2(image_util_decode_h handle, image_util_image_h *image)
int image_util_decode_run_async2(image_util_decode_h handle, image_util_decode_completed2_cb callback, void *user_data)
typedef void (*image_util_decode_completed2_cb) (int error_code, image_util_image_h image, void *user_data)

Change-Id: I185d5f4459ce9c55d546f6318145b5073916d3f7

decode-test/image_util_decode_encode_testsuite.c
include/image_util_decode.h
include/image_util_private.h
include/image_util_type.h
packaging/capi-media-image-util.spec
src/image_util_decode.c

index 03b3e83..9222f1e 100755 (executable)
@@ -71,12 +71,13 @@ typedef struct {
        unsigned long long encode_size;
 } test_encode_s;
 
-static unsigned int g_num_of_files;
+static unsigned int g_num_of_files;    //only for agif
 static unsigned int g_num_of_decoded;
 
 static test_inputs_s g_test_input;
 static test_decode_s g_test_decode[TEST_FILE_MAX];
 static test_encode_s g_test_encode;
+image_util_image_h g_decoded_image = NULL;
 
 static char TEST_CMD[][CMD_MAX] = {
        "decode",
@@ -259,6 +260,7 @@ void _free_datas()
        _free_inputs();
        _free_decode();
        _free_encode();
+       image_util_destroy_image(g_decoded_image);
 }
 
 gboolean _init_datas()
@@ -431,6 +433,7 @@ path);
        return TRUE;
 }
 
+
 gboolean test_decode()
 {
        int ret = 0;
@@ -498,6 +501,51 @@ gboolean test_decode()
        return TRUE;
 }
 
+static void __decode_completed2_cb(int error_code, image_util_image_h image, void *user_data)
+{
+       fprintf(stderr, "__decode_completed2_cb invoked [%d]\n", error_code);
+
+       if (error_code == IMAGE_UTIL_ERROR_NONE)
+               image_util_clone_image(image, &g_decoded_image);
+
+       _signal();
+
+       return;
+}
+
+gboolean test_new_decode()
+{
+       int ret = IMAGE_UTIL_ERROR_NONE;
+       unsigned int i = 0;
+       image_util_decode_h decoded = NULL;
+
+       ret = image_util_decode_create(&decoded);
+       if (ret != IMAGE_UTIL_ERROR_NONE)
+               return FALSE;
+
+       if ((g_test_input.cmd == TEST_DECODE_MEM) || (g_test_input.cmd == TEST_DECODE_MEM_ASYNC))
+               ret = image_util_decode_set_input_buffer(decoded, (unsigned char *)g_test_input.buffer, g_test_input.buffer_size);
+       else
+               ret = image_util_decode_set_input_path(decoded, g_test_decode[i].filepath);
+
+       if (ret != IMAGE_UTIL_ERROR_NONE) {
+               image_util_decode_destroy(decoded);
+               return FALSE;
+       }
+
+       if ((g_test_input.cmd == TEST_DECODE_ASYNC) || (g_test_input.cmd == TEST_DECODE_MEM_ASYNC)) {
+               ret = image_util_decode_run_async2(decoded, __decode_completed2_cb, NULL);
+               if (ret == IMAGE_UTIL_ERROR_NONE)
+                       _wait();
+       } else {
+               ret = image_util_decode_run2(decoded, &g_decoded_image);
+       }
+
+       image_util_decode_destroy(decoded);
+
+       return TRUE;
+}
+
 gboolean test_encode()
 {
        int ret = 0;
@@ -637,6 +685,7 @@ int main(int argc, char *argv[])
        fprintf(stderr, "\tTests Start!\n");
 
        if (test_decode() == FALSE) {
+       //if (test_new_decode() == FALSE) {
                fprintf(stderr, "\tDecode Tests failed!\n");
                _free_datas();
                return 0;
@@ -658,6 +707,8 @@ int main(int argc, char *argv[])
                }
        }
 
+       _free_datas();
+
        fprintf(stderr, "\tEncoding is done!\n");
 
        fprintf(stderr, "\tTests Finished!\n");
index 81d07d1..0db466d 100755 (executable)
@@ -76,13 +76,12 @@ int image_util_decode_create(image_util_decode_h *handle);
 *
 * @pre image_util_decode_create()
 *
-* @post image_util_decode_run() / image_util_decode_run_async()
+* @post image_util_decode_run2() / image_util_decode_run_async2()
 * @post image_util_decode_destroy()
 *
 * @see image_util_decode_create()
-* @see image_util_decode_set_output_buffer()
-* @see image_util_decode_run()
-* @see image_util_decode_run_async()
+* @see image_util_decode_run2()
+* @see image_util_decode_run_async2()
 * @see image_util_decode_destroy()
 */
 int image_util_decode_set_input_path(image_util_decode_h handle, const char *path);
@@ -110,18 +109,18 @@ int image_util_decode_set_input_path(image_util_decode_h handle, const char *pat
 *
 * @pre image_util_decode_create()
 *
-* @post image_util_decode_run() / image_util_decode_run_async()
+* @post image_util_decode_run2() / image_util_decode_run_async2()
 * @post image_util_decode_destroy()
 *
 * @see image_util_decode_create()
-* @see image_util_decode_set_output_buffer()
-* @see image_util_decode_run()
-* @see image_util_decode_run_async()
+* @see image_util_decode_run2()
+* @see image_util_decode_run_async2()
 * @see image_util_decode_destroy()
 */
 int image_util_decode_set_input_buffer(image_util_decode_h handle, const unsigned char *src_buffer, unsigned long long src_size);
 
 /**
+* @deprecated Deprecated since 5.5.
 * @brief Sets the output buffer to which the decoded buffer will be written to.
 * @since_tizen 3.0
 *
@@ -152,7 +151,7 @@ int image_util_decode_set_input_buffer(image_util_decode_h handle, const unsigne
 * @see image_util_decode_run_async()
 * @see image_util_decode_destroy()
 */
-int image_util_decode_set_output_buffer(image_util_decode_h handle, unsigned char **dst_buffer);
+int image_util_decode_set_output_buffer(image_util_decode_h handle, unsigned char **dst_buffer) TIZEN_DEPRECATED_API;
 
 /**
 * @brief Sets the decoded image colorspace format.
@@ -175,7 +174,7 @@ int image_util_decode_set_output_buffer(image_util_decode_h handle, unsigned cha
 * @pre image_util_decode_create()
 * @pre image_util_decode_set_input_path() / image_util_decode_set_input_buffer()
 *
-* @post image_util_decode_run() / image_util_decode_run_async()
+* @post image_util_decode_run2() / image_util_decode_run_async2()
 * @post image_util_decode_destroy()
 *
 * @see image_util_supported_colorspace_cb()
@@ -183,9 +182,8 @@ int image_util_decode_set_output_buffer(image_util_decode_h handle, unsigned cha
 * @see image_util_decode_create()
 * @see image_util_decode_set_input_path()
 * @see image_util_decode_set_input_buffer()
-* @see image_util_decode_set_output_buffer()
-* @see image_util_decode_run()
-* @see image_util_decode_run_async()
+* @see image_util_decode_run2()
+* @see image_util_decode_run_async2()
 * @see image_util_decode_destroy()
 */
 int image_util_decode_set_colorspace(image_util_decode_h handle, image_util_colorspace_e colorspace);
@@ -209,20 +207,20 @@ int image_util_decode_set_colorspace(image_util_decode_h handle, image_util_colo
 * @pre image_util_decode_create()
 * @pre image_util_decode_set_input_path() / image_util_decode_set_input_buffer()
 *
-* @post image_util_decode_run() / image_util_decode_run_async()
+* @post image_util_decode_run2() / image_util_decode_run_async2()
 * @post image_util_decode_destroy()
 *
 * @see image_util_decode_create()
 * @see image_util_decode_set_input_path()
 * @see image_util_decode_set_input_buffer()
-* @see image_util_decode_set_output_buffer()
-* @see image_util_decode_run()
-* @see image_util_decode_run_async()
+* @see image_util_decode_run2()
+* @see image_util_decode_run_async2()
 * @see image_util_decode_destroy()
 */
 int image_util_decode_set_jpeg_downscale(image_util_decode_h handle, image_util_scale_e down_scale);
 
 /**
+* @deprecated Deprecated since 5.5. Use image_util_decode_run2() instead.
 * @brief Starts decoding of the image and fills the output buffer set using image_util_decode_set_output_buffer().
 * @since_tizen 3.0
 *
@@ -254,9 +252,10 @@ int image_util_decode_set_jpeg_downscale(image_util_decode_h handle, image_util_
 * @see image_util_decode_set_output_buffer()
 * @see image_util_decode_destroy()
 */
-int image_util_decode_run(image_util_decode_h handle, unsigned long *width, unsigned long *height, unsigned long long *size);
+int image_util_decode_run(image_util_decode_h handle, unsigned long *width, unsigned long *height, unsigned long long *size) TIZEN_DEPRECATED_API;
 
 /**
+* @deprecated Deprecated since 5.5. Use image_util_decode_run_async2() instead.
 * @brief Starts decoding of the image and fills the output buffer set using image_util_decode_set_output_buffer().
 * @since_tizen 3.0
 *
@@ -287,7 +286,76 @@ int image_util_decode_run(image_util_decode_h handle, unsigned long *width, unsi
 * @see image_util_decode_set_output_buffer()
 * @see image_util_decode_destroy()
 */
-int image_util_decode_run_async(image_util_decode_h handle, image_util_decode_completed_cb callback, void *user_data);
+int image_util_decode_run_async(image_util_decode_h handle, image_util_decode_completed_cb callback, void *user_data) TIZEN_DEPRECATED_API;
+
+/**
+* @brief Decodes the image with the given decode handle.
+* @details This function decodes the image synchronously.
+* @since_tizen 5.5
+*
+* @remarks If the decoding fails, the @a image will be @c NULL.\n
+*          The @a image should be released using image_util_destroy_image().\n
+*          If any of the required functions listed in the preconditions section has not been called, #IMAGE_UTIL_ERROR_INVALID_PARAMETER is returned.
+*
+* @param[in] handle The handle of image util decoding
+* @param[out] image The decoded image
+*
+* @return @c 0 on success,
+*                 otherwise a negative error value
+*
+* @retval #IMAGE_UTIL_ERROR_NONE Successful
+* @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
+* @retval #IMAGE_UTIL_ERROR_OUT_OF_MEMORY Out of memory
+* @retval #IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT Format not supported
+*
+* @pre image_util_decode_create()
+* @pre image_util_decode_set_input_buffer() / image_util_decode_set_input_path().
+*
+* @post image_util_decode_destroy()
+*
+* @see image_util_decode_create()
+* @see image_util_decode_set_input_path()
+* @see image_util_decode_set_input_buffer()
+* @see image_util_decode_destroy()
+* @see image_util_destroy_image()
+*/
+int image_util_decode_run2(image_util_decode_h handle, image_util_image_h *image);
+
+/**
+* @brief Starts decoding of the image with the given decode handle.
+* @details This function decodes the image asynchronously.
+* @since_tizen 5.5
+*
+* @remarks If the decoding fails, the image_util_decode_completed2_cb() will be called with @c NULL image and a non-zero error_code.\n
+*          If any of the required functions listed in the preconditions section has not been called, #IMAGE_UTIL_ERROR_INVALID_PARAMETER is returned.
+*
+* @param[in] handle The handle of image util decoding
+* @param[in] callback The callback function to be invoked
+* @param[in] user_data The user data to be passed to the callback function
+*
+* @return @c 0 on success,
+*                 otherwise a negative error value
+*
+* @retval #IMAGE_UTIL_ERROR_NONE Successful
+* @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
+* @retval #IMAGE_UTIL_ERROR_OUT_OF_MEMORY Out of memory
+* @retval #IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT Format not supported
+*
+* @pre image_util_decode_create()
+* @pre image_util_decode_set_input_buffer() / image_util_decode_set_input_path().
+*
+* @post image_util_decode_destroy()
+*
+* @see image_util_decode_create()
+* @see image_util_decode_set_input_path()
+* @see image_util_decode_set_input_buffer()
+* @see image_util_decode_destroy()
+* @see image_util_destroy_image()
+* @see image_util_decode_completed2_cb()
+*/
+int image_util_decode_run_async2(image_util_decode_h handle, image_util_decode_completed2_cb callback, void *user_data);
 
 /**
 * @brief Destroys the image decoding handle.
@@ -318,4 +386,4 @@ int image_util_decode_destroy(image_util_decode_h handle);
 }
 #endif
 
-#endif /* __TIZEN_MULTIMEDIA_IMAGE_UTIL_DECODE_H__ */
\ No newline at end of file
+#endif /* __TIZEN_MULTIMEDIA_IMAGE_UTIL_DECODE_H__ */
index f1f0113..72e6772 100755 (executable)
@@ -77,6 +77,7 @@ extern "C"
        ((str != NULL && strlen(str) > 0) ? true : false)
 
 #define IMAGE_UTIL_SAFE_FREE(src)      { if (src) {free(src); src = NULL; } }
+#define IMAGE_UTIL_SAFE_G_FREE(src)    { if (src) {g_free(src); src = NULL; } }
 
 #define _NOT_SUPPORTED_COLORSPACE      (-1)
 
@@ -120,6 +121,11 @@ typedef struct {
 
 typedef struct {
        void *user_data;
+       image_util_decode_completed2_cb image_decode_completed_cb;
+} decode2_cb_s;
+
+typedef struct {
+       void *user_data;
        image_util_encode_completed_cb image_encode_completed_cb;
 } encode_cb_s;
 
@@ -160,6 +166,8 @@ typedef struct {
 
        /* for async */
        GThread *thread;
+       gboolean is_decode2;
+       decode2_cb_s *decode2_cb;
 } decode_s;
 
 #define IMAGE_UTIL_TYPE_CHECK(type) \
index 957500f..696cedd 100755 (executable)
@@ -203,6 +203,7 @@ typedef enum {
 
 /**
 * @ingroup CAPI_MEDIA_IMAGE_UTIL_ENCODE_DECODE_MODULE
+* @deprecated Deprecated since 5.5.
 * @brief Called when Image-util decoding is finished just before returning the output.
 * @since_tizen 3.0
 *
@@ -218,12 +219,35 @@ typedef enum {
 * @param[in] height Height of the decoded image
 * @param[in] size Size of the decoded image
 *
-* @pre image_util_decode_run() will invoke this function.
+* @pre image_util_decode_run_async() will invoke this function.
 */
 typedef void (*image_util_decode_completed_cb) (int error_code, void *user_data, unsigned long width, unsigned long height, unsigned long long size);
 
 /**
 * @ingroup CAPI_MEDIA_IMAGE_UTIL_ENCODE_DECODE_MODULE
+* @brief Called when image_util_decode_run_async2() finishes decoding an image.
+* @since_tizen 5.5
+*
+* @remarks The callback is called in a separate thread(not in the main loop). \n
+*            The @a image should not be released by the application. \n
+*            The @a image can be used only in the callback. To use outside, make a copy using image_util_clone_image().
+*
+* @param[in] error_code The error code of image util decoding
+*                    #IMAGE_UTIL_ERROR_NONE Successful
+*                    #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
+*                    #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
+*                    #IMAGE_UTIL_ERROR_OUT_OF_MEMORY Out of memory
+*                    #IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT Format not supported
+*
+* @param[in] image The decoded image (or @c NULL if decoding failed)
+* @param[in] user_data The user data passed from the callback registration function
+*
+* @pre image_util_decode_run_async2() will invoke this function.
+*/
+typedef void (*image_util_decode_completed2_cb) (int error_code, image_util_image_h image, void *user_data);
+
+/**
+* @ingroup CAPI_MEDIA_IMAGE_UTIL_ENCODE_DECODE_MODULE
 * @brief Called when Image-util encoding is finished just before returning the output.
 * @since_tizen 3.0
 *
index 3c7e11f..bfb9237 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       capi-media-image-util
 Summary:    A Image Utility library in Tizen Native API
-Version:    0.1.47
+Version:    0.1.48
 Release:    2
 Group:      Multimedia/API
 License:    Apache-2.0
index 99b2a0a..9aa887e 100755 (executable)
@@ -129,6 +129,10 @@ int image_util_decode_create(image_util_decode_h * handle)
        _handle->colorspace = IMAGE_UTIL_COLORSPACE_RGBA8888;
        _handle->down_scale = IMAGE_UTIL_DOWNSCALE_1_1;
 
+       _handle->thread = NULL;
+       _handle->is_decode2 = FALSE;
+       _handle->decode2_cb = NULL;
+
        *handle = (image_util_decode_h) _handle;
 
        return IMAGE_UTIL_ERROR_NONE;
@@ -184,6 +188,8 @@ int image_util_decode_set_output_buffer(image_util_decode_h handle, unsigned cha
 {
        decode_s *_handle = (decode_s *) handle;
 
+       image_util_warning("DEPRECATION WARNING: image_util_decode_set_output_buffer() is deprecated and will be removed from next release.");
+
        image_util_fenter();
 
        image_util_retvm_if(_handle == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
@@ -229,8 +235,8 @@ static int __image_util_decode_internal(decode_s * _handle, mm_util_image_h *ima
        int colorspace = 0;
        int downscale = 0;
 
-       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(!_handle, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid _handle");
+       image_util_retvm_if(!image_info, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid image_info");
 
        image_util_fenter();
 
@@ -291,6 +297,8 @@ int image_util_decode_run(image_util_decode_h handle, unsigned long *width, unsi
        unsigned char *_buffer = NULL;
        size_t _size = 0;
 
+       image_util_warning("DEPRECATION WARNING: image_util_decode_run() is deprecated and will be removed from next release. Use image_util_decode_run2() instead.");
+
        image_util_retvm_if(_handle == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid 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");
@@ -312,10 +320,112 @@ int image_util_decode_run(image_util_decode_h handle, unsigned long *width, unsi
        return _image_error_capi(err);
 }
 
+static int __image_util_decode_run_from_file(image_util_decode_h handle, const char *file_path, image_util_image_h *image)
+{
+       int ret = IMAGE_UTIL_ERROR_NONE;
+       decode_s *_handle = (decode_s *) handle;
+       unsigned char *image_header = NULL;
+       image_util_type_e image_type = 0;
+       int colorspace = 0;
+       int downscale = 0;
+
+       image_util_retvm_if(!handle, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid handle");
+       image_util_retvm_if(!IMAGE_UTIL_STRING_VALID(file_path), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid file_path");
+       image_util_retvm_if(!image, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid image");
+
+       image_util_fenter();
+
+       ret = _image_util_decode_read_header(file_path, &image_header);
+       image_util_retvm_if((ret != IMAGE_UTIL_ERROR_NONE), ret, "_image_util_decode_read_header failed");
+
+       ret = _image_util_decode_check_image_type(image_header, &image_type);
+       IMAGE_UTIL_SAFE_FREE(image_header);
+       image_util_retvm_if((ret != IMAGE_UTIL_ERROR_NONE), ret, "_image_util_decode_check_image_type failed");
+
+       switch (image_type) {
+       case IMAGE_UTIL_JPEG:
+               {
+                       colorspace = TYPECAST_COLOR_BY_TYPE(_handle->colorspace, IMAGE_UTIL_JPEG);
+                       downscale = _convert_decode_scale_tbl[_handle->down_scale];
+
+                       ret = mm_util_decode_from_jpeg_file(file_path, colorspace, downscale, image);
+               }
+               break;
+
+       case IMAGE_UTIL_PNG:
+               ret = mm_util_decode_from_png_file(file_path, image);
+               break;
+
+       case IMAGE_UTIL_GIF:
+               ret = mm_util_decode_from_gif_file(file_path, image);
+               break;
+
+       case IMAGE_UTIL_BMP:
+               ret = mm_util_decode_from_bmp_file(file_path, image);
+               break;
+
+       default:
+               image_util_error("Not supported format [%d]", image_type);
+               return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
+               break;
+       }
+
+       image_util_fleave();
+
+       return _image_error_capi(ret);
+}
+
+static int __image_util_decode_run_from_buffer(image_util_decode_h handle, const unsigned char *buffer, size_t buffer_size, image_util_image_h *image)
+{
+       int ret = MM_UTIL_ERROR_NONE;
+       decode_s *_handle = (decode_s *) handle;
+       image_util_type_e image_type = 0;
+       int colorspace = 0;
+       int downscale = 0;
+
+       image_util_retvm_if(!handle, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid handle");
+       image_util_retvm_if(!buffer, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid buffer");
+       image_util_retvm_if(buffer_size == 0, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid buffer_size");
+       image_util_retvm_if(!image, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid image");
+
+       image_util_fenter();
+
+       ret = _image_util_decode_check_image_type(buffer, &image_type);
+       image_util_retvm_if(ret != IMAGE_UTIL_ERROR_NONE, ret, "_image_util_decode_check_image_type failed");
+
+       switch (image_type) {
+       case IMAGE_UTIL_JPEG:
+               {
+                       colorspace = TYPECAST_COLOR_BY_TYPE(_handle->colorspace, IMAGE_UTIL_JPEG);
+                       downscale = _convert_decode_scale_tbl[_handle->down_scale];
+
+                       ret = mm_util_decode_from_jpeg_memory((void *)buffer, buffer_size, colorspace, downscale, image);
+               }
+               break;
+       case IMAGE_UTIL_PNG:
+               ret = mm_util_decode_from_png_memory((void *)buffer, buffer_size, image);
+               break;
+       case IMAGE_UTIL_GIF:
+               ret = mm_util_decode_from_gif_memory((void *)buffer, buffer_size, image);
+               break;
+       case IMAGE_UTIL_BMP:
+               ret = mm_util_decode_from_bmp_memory((void *)buffer, buffer_size, image);
+               break;
+       default:
+               image_util_error("Not supported format [%d]", image_type);
+               return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
+               break;
+       }
+
+       image_util_fleave();
+
+       return _image_error_capi(ret);
+}
+
 gpointer _image_util_decode_thread(gpointer data)
 {
        decode_s *_handle = (decode_s *) data;
-       int err = IMAGE_UTIL_ERROR_NONE;
+       int ret = IMAGE_UTIL_ERROR_NONE;
        unsigned int _width = 0;
        unsigned int _height = 0;
        size_t _size = 0;
@@ -326,24 +436,43 @@ gpointer _image_util_decode_thread(gpointer data)
 
        image_util_retvm_if((_handle == NULL), NULL, "Invalid Handle");
 
-       err = __image_util_decode_internal(_handle, &image_info);
-       if (err == IMAGE_UTIL_ERROR_NONE)
-               image_util_debug("Success - decode_internal");
-       else
-               image_util_error("Error - decode_internal");
+       if (_handle->is_decode2) {      //new decode
+               if (_handle->path)
+                       ret = __image_util_decode_run_from_file(_handle, _handle->path, &image_info);
+               else
+                       ret = __image_util_decode_run_from_buffer(_handle, _handle->src_buffer, _handle->src_size, &image_info);
 
-       mm_image_get_image(image_info, &_width, &_height, NULL, &_buffer, &_size);
+               if (_handle->decode2_cb) {
+                       image_util_debug("call decode2_cb [%d]", ret);
+                       _handle->decode2_cb->image_decode_completed_cb(ret, image_info, _handle->decode2_cb->user_data);
+               } else {
+                       image_util_error("No decode2_cb");
+               }
 
-       *(_handle->dst_buffer) = _buffer;
+               mm_image_destroy_image(image_info);
+               IMAGE_UTIL_SAFE_FREE(_handle->decode2_cb);
+               IMAGE_UTIL_SAFE_G_FREE(_handle->path);
 
-       if (_handle->_decode_cb) {
-               image_util_debug("call completed_cb");
-               _handle->_decode_cb->image_decode_completed_cb(err, _handle->_decode_cb->user_data, (unsigned long)_width, (unsigned long)_height, (unsigned long long)_size);
        } else {
-               image_util_error("No callback");
-       }
+               ret = __image_util_decode_internal(_handle, &image_info);
+               if (ret == IMAGE_UTIL_ERROR_NONE)
+                       image_util_debug("Success - decode_internal");
+               else
+                       image_util_error("Error - decode_internal");
 
-       mm_image_destroy_image(image_info);
+               mm_image_get_image(image_info, &_width, &_height, NULL, &_buffer, &_size);
+
+               *(_handle->dst_buffer) = _buffer;
+
+               if (_handle->_decode_cb) {
+                       image_util_debug("call completed_cb");
+                       _handle->_decode_cb->image_decode_completed_cb(ret, _handle->_decode_cb->user_data, (unsigned long)_width, (unsigned long)_height, (unsigned long long)_size);
+               } else {
+                       image_util_error("No callback");
+               }
+
+               mm_image_destroy_image(image_info);
+       }
 
        image_util_fleave();
 
@@ -357,10 +486,7 @@ static int _image_util_decode_create_thread(decode_s * handle)
 
        /*create threads */
        handle->thread = g_thread_new("decode_thread", (GThreadFunc) _image_util_decode_thread, (gpointer) handle);
-       if (!handle->thread) {
-               image_util_error("ERROR - create thread");
-               return IMAGE_UTIL_ERROR_INVALID_OPERATION;
-       }
+       image_util_retvm_if((!handle->thread), IMAGE_UTIL_ERROR_INVALID_OPERATION, "ERROR - create thread");
 
        return IMAGE_UTIL_ERROR_NONE;
 }
@@ -370,6 +496,8 @@ int image_util_decode_run_async(image_util_decode_h handle, image_util_decode_co
        int err = IMAGE_UTIL_ERROR_NONE;
        decode_s *_handle = (decode_s *) handle;
 
+       image_util_warning("DEPRECATION WARNING: image_util_decode_run_async() is deprecated and will be removed from next release. Use image_util_decode_run_async2() instead.");
+
        image_util_fenter();
 
        image_util_retvm_if(_handle == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
@@ -400,6 +528,47 @@ int image_util_decode_run_async(image_util_decode_h handle, image_util_decode_co
        return err;
 }
 
+int image_util_decode_run2(image_util_decode_h handle, image_util_image_h *image)
+{
+       decode_s *_handle = (decode_s *) handle;
+
+       image_util_retvm_if(!_handle, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
+       image_util_retvm_if((!_handle->path && !_handle->src_buffer), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid input");
+
+       if (_handle->path)
+               return __image_util_decode_run_from_file(handle, _handle->path, image);
+       else
+               return __image_util_decode_run_from_buffer(handle, _handle->src_buffer, _handle->src_size, image);
+}
+
+int image_util_decode_run_async2(image_util_decode_h handle, image_util_decode_completed2_cb callback, void *user_data)
+{
+       int ret = IMAGE_UTIL_ERROR_NONE;
+       decode_s *_handle = (decode_s *) handle;
+
+       image_util_retvm_if(!_handle, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid handle");
+       image_util_retvm_if((!_handle->path && !_handle->src_buffer), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid input");
+       image_util_retvm_if(!callback, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid callback");
+
+       image_util_fenter();
+
+       _handle->is_decode2 = TRUE;
+
+       _handle->decode2_cb = (decode2_cb_s *) calloc(1, sizeof(decode2_cb_s));
+       image_util_retvm_if((!_handle->decode2_cb), IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "Out of memory");
+
+       _handle->decode2_cb->user_data = user_data;
+       _handle->decode2_cb->image_decode_completed_cb = callback;
+
+       ret = _image_util_decode_create_thread(_handle);
+       if (ret != IMAGE_UTIL_ERROR_NONE)
+               IMAGE_UTIL_SAFE_FREE(_handle->decode2_cb);
+
+       image_util_fleave();
+
+       return ret;
+}
+
 int image_util_decode_destroy(image_util_decode_h handle)
 {
        decode_s *_handle = (decode_s *) handle;