Apply new coding rule, add macro for logs & remove build warnings 44/44944/2 tizen_3.0.m1_mobile tizen_3.0.m1_tv accepted/tizen/mobile/20150730.074533 accepted/tizen/tv/20150730.074743 accepted/tizen/wearable/20150730.074926 submit/tizen/20150730.065603 submit/tizen_common/20151023.083358 submit/tizen_common/20151026.085049 tizen_3.0.m1_mobile_release tizen_3.0.m1_tv_release
authorJi Yong Min <jiyong.min@samsung.com>
Thu, 30 Jul 2015 02:42:12 +0000 (11:42 +0900)
committerJi Yong Min <jiyong.min@samsung.com>
Thu, 30 Jul 2015 04:57:56 +0000 (13:57 +0900)
Change-Id: Id64fd417070ea69da8d14c25091ff48c667a84dc
Signed-off-by: Jiyong Min <jiyong.min@samsung.com>
CMakeLists.txt [changed mode: 0644->0755]
doc/image_util_doc.h
include/image_util.h
include/image_util_private.h
packaging/capi-media-image-util.spec
src/image_util.c
test/image_util_test.c

old mode 100644 (file)
new mode 100755 (executable)
index 25a5002..eb2a38f
@@ -53,6 +53,9 @@ ENDIF("${ARCH}" MATCHES "^arm.*")
 
 ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
 ADD_DEFINITIONS("-DTIZEN_DEBUG")
+IF(FEATURE_ENABLE_HW_ACCELERATION)
+ADD_DEFINITIONS("-DENABLE_HW_ACCELERATION")
+ENDIF(FEATURE_ENABLE_HW_ACCELERATION)
 
 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}")
 
index ac63a44..d2d4797 100755 (executable)
@@ -40,7 +40,7 @@
  *
  * The decoding of a jpeg image located at a given path, to a buffer can be done by calling #image_util_decode_jpeg() function and decoding of a jpeg image on memory
  * can be done by calling #image_util_decode_jpeg_from_memory(). Similarly, for encoding #image_util_encode_jpeg() and #image_util_encode_jpeg_to_memory() functions can be called
- * to encode an image buffer to a jpeg image and a jpeg buffer respectively. The API also allows to transform including convert the colorspace (#image_util_colorspace_e) of an image by calling
+ * to encode an image buffer to a jpeg image and a jpeg buffer respectively. The API also allows to transform including convert the colorspace(#image_util_colorspace_e) of an image by calling
  * #image_util_transform_run() function.
  *
  * @subsection CAPI_MEDIA_IMAGE_UTIL_FOREACH_OPERATIONS Foreach Operations
@@ -58,4 +58,4 @@
  *</table></div>
  */
 
-#endif // __TIZEN_MEDIA_IMAGE_UTIL_DOC_H__
+#endif /* __TIZEN_MEDIA_IMAGE_UTIL_DOC_H__ */
index 0bd0fc3..7ef9953 100755 (executable)
@@ -24,8 +24,6 @@ extern "C"
 {
 #endif
 
-#define IMAGE_UTIL_ERROR_CLASS          TIZEN_ERROR_MULTIMEDIA_CLASS | 0x70
-
 /**
  * @file image_util.h
  * @brief This file contains the image util API.
index fbbdee2..0722826 100755 (executable)
 #define __TIZEN_MEDIA_IMAGE_UTIL_PRIVATE_H__
 
 #include <image_util_type.h>
+#include <dlog.h>
+#include <stdlib.h>
 
 #ifdef __cplusplus
 extern "C"
 {
 #endif
 
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "CAPI_MEDIA_IMAGE_UTIL"
+
+#define FONT_COLOR_RESET    "\033[0m"
+#define FONT_COLOR_RED      "\033[31m"
+
+#define image_util_debug(fmt, arg...) do { \
+               LOGD(FONT_COLOR_RESET""fmt"", ##arg);     \
+       } while (0)
+
+#define image_util_error(fmt, arg...) do { \
+               LOGE(FONT_COLOR_RED""fmt"", ##arg);     \
+       } while (0)
+
+#define image_util_retm_if(expr, fmt, arg...) do { \
+               if(expr) { \
+                       LOGE(FONT_COLOR_RED""fmt"", ##arg);     \
+                       return; \
+               } \
+       } while (0)
+
+#define image_util_retvm_if(expr, val, fmt, arg...) do { \
+               if(expr) { \
+                       LOGE(FONT_COLOR_RED""fmt"", ##arg);     \
+                       return (val); \
+               } \
+       } while (0)
+
 typedef struct {
        void *user_data;
        media_packet_h dst;
index 961ef66..9763088 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       capi-media-image-util
 Summary:    A Image Utility library in Tizen Native API
-Version:    0.1.2
+Version:    0.1.3
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
@@ -13,7 +13,6 @@ BuildRequires:  pkgconfig(mmutil-imgp)
 BuildRequires:  pkgconfig(capi-base-common)
 BuildRequires:  pkgconfig(capi-media-tool)
 BuildRequires:  cmake
-BuildRequires:  gettext-devel
 
 %description
 A Image Utility library in Tizen Native API package
@@ -36,8 +35,16 @@ A Image Utility library in Tizen Native API (Development) package
 cp %{SOURCE1001} .
 
 %build
+export CFLAGS+=" -Wextra -Wno-array-bounds"
+export CFLAGS+=" -Wno-ignored-qualifiers -Wno-unused-parameter -Wshadow"
+export CFLAGS+=" -Wwrite-strings -Wswitch-default"
 MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
-%cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+%cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \
+%if 0%{?model_build_feature_multimedia_image_hw_acceleration}
+ -DFEATURE_ENABLE_HW_ACCELERATION:BOOL=ON
+%else
+ -DFEATURE_ENABLE_HW_ACCELERATION:BOOL=OFF
+%endif
 %__make %{?jobs:-j%jobs}
 
 %install
index 61d42a8..ab8a046 100755 (executable)
@@ -14,7 +14,6 @@
 * limitations under the License.
 */
 
-#define LOG_TAG "CAPI_MEDIA_IMAGE_UTIL"
 #include <dlog.h>
 
 #include <mm_util_imgp.h>
@@ -116,7 +115,7 @@ static int _convert_image_util_error_code(const char *func, int code)
 
        }
 
-       LOGD("[%s] %s(0x%08x)", func, errorstr, ret);
+       image_util_debug("[%s] %s(0x%08x)", func, errorstr, ret);
        IMAGE_UTIL_SAFE_FREE(errorstr);
        return ret;
 }
@@ -125,19 +124,18 @@ static image_util_error_e _image_util_error_convert(int error)
 {
        switch (error) {
                case MM_ERROR_NONE:
-                       LOGD("Error None");
+                       image_util_debug("Error None");
                        return IMAGE_UTIL_ERROR_NONE;
                case MM_ERROR_IMAGE_INVALID_VALUE:
-                       LOGE("INVALID_PARAMETER(0x%08x)", IMAGE_UTIL_ERROR_INVALID_PARAMETER);
+                       image_util_error("INVALID_PARAMETER(0x%08x)", IMAGE_UTIL_ERROR_INVALID_PARAMETER);
                        return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
                case MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT:
-                       LOGE("NOT_SUPPORTED_FORMAT(0x%08x)", IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT);
+                       image_util_error("NOT_SUPPORTED_FORMAT(0x%08x)", IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT);
                        return IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
                default:
-                       break;
+                       image_util_error("INVALID_OPERATION(0x%08x)", error);
+                       return IMAGE_UTIL_ERROR_INVALID_OPERATION;
        }
-       LOGE("INVALID_OPERATION(0x%08x)", error);
-       return IMAGE_UTIL_ERROR_INVALID_OPERATION;
 }
 
 static void _image_util_transform_completed_cb(media_packet_h *dst, int error, void *user_data)
@@ -160,11 +158,9 @@ static int _image_util_create_transform_handle(transformation_s *handle)
 
        ret = mm_util_create(&image_h);
 
-       if (ret == MM_ERROR_NONE) {
-               handle->image_h = image_h;
-       } else {
-               LOGE("Error in mm_util_create");
-       }
+       image_util_retvm_if((ret != MM_ERROR_NONE), ret, "Error in mm_util_create");
+
+       handle->image_h = image_h;
 
        return ret;
 }
@@ -172,12 +168,12 @@ static int _image_util_create_transform_handle(transformation_s *handle)
 static bool _image_util_check_resolution(int width, int height)
 {
        if (width <= 0) {
-               LOGE("invalid width [%d]", width);
+               image_util_error("invalid width [%d]", width);
                return false;
        }
 
        if (height <= 0) {
-               LOGE("invalid height [%d]", height);
+               image_util_error("invalid height [%d]", height);
                return false;
        }
 
@@ -205,18 +201,12 @@ int image_util_transform_create(transformation_h *handle)
 {
        int ret = IMAGE_UTIL_ERROR_NONE;
 
-       LOGD("image_util_create");
+       image_util_debug("image_util_create");
 
-       if (handle == NULL) {
-               LOGE("Invalid Handle");
-               return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
-       }
+       image_util_retvm_if((handle == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
 
        transformation_s *_handle = (transformation_s *)calloc(1, sizeof(transformation_s));
-       if (_handle == NULL) {
-               LOGE("OUT_OF_MEMORY(0x%08x)", IMAGE_UTIL_ERROR_OUT_OF_MEMORY);
-               return IMAGE_UTIL_ERROR_OUT_OF_MEMORY;
-       }
+       image_util_retvm_if((_handle == NULL), IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY(0x%08x)", IMAGE_UTIL_ERROR_OUT_OF_MEMORY);
 
        _handle->colorspace = -1;
        _handle->_util_cb = NULL;
@@ -229,7 +219,7 @@ int image_util_transform_create(transformation_h *handle)
 
        ret = _image_util_create_transform_handle(_handle);
        if (ret != MM_ERROR_NONE) {
-               LOGE("INVALID_OPERATION");
+               image_util_error("INVALID_OPERATION");
                IMAGE_UTIL_SAFE_FREE(_handle);
                return IMAGE_UTIL_ERROR_INVALID_OPERATION;
        }
@@ -241,29 +231,21 @@ int image_util_transform_create(transformation_h *handle)
 
 int  image_util_transform_set_hardware_acceleration(transformation_h handle, bool mode)
 {
+       int ret = IMAGE_UTIL_ERROR_NONE;
        transformation_s *_handle = (transformation_s *)handle;
 
-       LOGD("Set hardware_acceleration %d", mode);
-
-       if (_handle == NULL) {
-               LOGE("Invalid Handle");
-               return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
-       }
+       image_util_debug("Set hardware_acceleration %d", mode);
 
+       image_util_retvm_if((_handle == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
 #ifndef ENABLE_HW_ACCELERATION
-       if (mode == true) {
-               LOGE("hardware acceleration is not supported");
-               return IMAGE_UTIL_ERROR_NOT_SUPPORTED;
-       }
+       image_util_retvm_if((mode == true), IMAGE_UTIL_ERROR_NOT_SUPPORTED, "hardware acceleration is not supported");
 #endif
 
-       if (mm_util_set_hardware_acceleration(_handle->image_h, mode) == MM_ERROR_NONE) {
-               LOGD("Set hardware_acceleration %d", mode);
-               _handle->hardware_acceleration = mode;
-       } else {
-               LOGE("Error - Set hardware_acceleration");
-               return IMAGE_UTIL_ERROR_INVALID_OPERATION;
-       }
+       ret = mm_util_set_hardware_acceleration(_handle->image_h, mode);
+       image_util_retvm_if((ret != MM_ERROR_NONE), IMAGE_UTIL_ERROR_INVALID_OPERATION, "Error - Set hardware_acceleration");
+
+       image_util_debug("Set hardware_acceleration %d", mode);
+       _handle->hardware_acceleration = mode;
 
        return IMAGE_UTIL_ERROR_NONE;
 }
@@ -273,18 +255,12 @@ int image_util_transform_set_colorspace(transformation_h handle, image_util_colo
        int ret = IMAGE_UTIL_ERROR_NONE;
        transformation_s *_handle = (transformation_s *)handle;
 
-       LOGD("Set colorspace_convert_info [%d]", colorspace);
+       image_util_debug("Set colorspace_convert_info [%d]", colorspace);
 
-       if (_handle == NULL) {
-               LOGE("Invalid Handle");
-               return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
-       }
+       image_util_retvm_if((_handle == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
 
        ret = mm_util_set_colorspace_convert(_handle->image_h, colorspace);
-       if (ret != MM_ERROR_NONE) {
-               LOGE("IMAGE_UTIL_ERROR_INVALID_OPERATION(0x%08x)", IMAGE_UTIL_ERROR_INVALID_OPERATION);
-               return IMAGE_UTIL_ERROR_INVALID_OPERATION;
-       }
+       image_util_retvm_if((ret != MM_ERROR_NONE), IMAGE_UTIL_ERROR_INVALID_OPERATION, "IMAGE_UTIL_ERROR_INVALID_OPERATION(0x%08x)", IMAGE_UTIL_ERROR_INVALID_OPERATION);
 
        _handle->colorspace = colorspace;
        _handle->set_convert = true;
@@ -297,29 +273,19 @@ int image_util_transform_set_resolution(transformation_h handle, unsigned int wi
        int ret = IMAGE_UTIL_ERROR_NONE;
        transformation_s *_handle = (transformation_s *)handle;
 
-       LOGD("Set resize_info w[%d] h[%d]", width, height);
+       image_util_debug("Set resize_info w[%d] h[%d]", width, height);
 
-       if (_handle == NULL) {
-               LOGE("Invalid Handle");
-               return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
-       }
-
-       if (_handle->set_crop) {
-               LOGE("Crop and Resize can't do at the same time");
-               return IMAGE_UTIL_ERROR_INVALID_OPERATION;
-       }
+       image_util_retvm_if((_handle == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
+       image_util_retvm_if((_handle->set_crop), IMAGE_UTIL_ERROR_INVALID_OPERATION, "Crop and Resize can't do at the same time");
 
        if (_image_util_check_resolution(width, height)) {
                ret = mm_util_set_resolution(_handle->image_h, width, height);
-               if (ret != MM_ERROR_NONE) {
-                       LOGE("IMAGE_UTIL_ERROR_INVALID_OPERATION(0x%08x)", IMAGE_UTIL_ERROR_INVALID_OPERATION);
-                       return IMAGE_UTIL_ERROR_INVALID_OPERATION;
-               }
+               image_util_retvm_if((ret != MM_ERROR_NONE), IMAGE_UTIL_ERROR_INVALID_OPERATION, "IMAGE_UTIL_ERROR_INVALID_OPERATION(0x%08x)", IMAGE_UTIL_ERROR_INVALID_OPERATION);
                _handle->width = width;
                _handle->height = height;
                _handle->set_resize  = true;
        } else {
-               LOGE("INVALID_PARAMETER");
+               image_util_error("INVALID_PARAMETER");
                return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
        }
 
@@ -331,18 +297,12 @@ int image_util_transform_set_rotation(transformation_h handle, image_util_rotati
        int ret = IMAGE_UTIL_ERROR_NONE;
        transformation_s *_handle = (transformation_s *)handle;
 
-       LOGD("Set rotate_info [%d]", rotation);
+       image_util_debug("Set rotate_info [%d]", rotation);
 
-       if (_handle == NULL) {
-               LOGE("Invalid Handle");
-               return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
-       }
+       image_util_retvm_if((_handle == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
 
        ret = mm_util_set_rotation(_handle->image_h, rotation);
-       if (ret != MM_ERROR_NONE) {
-               LOGE("IMAGE_UTIL_ERROR_INVALID_OPERATION(0x%08x)", IMAGE_UTIL_ERROR_INVALID_OPERATION);
-               return IMAGE_UTIL_ERROR_INVALID_OPERATION;
-       }
+       image_util_retvm_if((ret != MM_ERROR_NONE), IMAGE_UTIL_ERROR_INVALID_OPERATION, "IMAGE_UTIL_ERROR_INVALID_OPERATION(0x%08x)", IMAGE_UTIL_ERROR_INVALID_OPERATION);
        _handle->rotation = rotation;
        _handle->set_rotate = true;
 
@@ -356,34 +316,24 @@ int image_util_transform_set_crop_area(transformation_h handle, unsigned int sta
        int dest_width;
        int dest_height;
 
-       if (_handle == NULL) {
-               LOGE("Invalid Handle");
-               return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
-       }
-
-       if (_handle->set_resize) {
-               LOGE("Crop and Resize can't do at the same time");
-               return IMAGE_UTIL_ERROR_INVALID_OPERATION;
-       }
+       image_util_retvm_if((_handle == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
+       image_util_retvm_if((_handle->set_resize), IMAGE_UTIL_ERROR_INVALID_OPERATION, "Crop and Resize can't do at the same time");
 
        dest_width = end_x - start_x;
        dest_height = end_y - start_y;
 
-       LOGD("Set crop_info x[%d] y[%d] w[%d] h[%d]", start_x, start_y, dest_width, dest_height);
+       image_util_debug("Set crop_info x[%d] y[%d] w[%d] h[%d]", start_x, start_y, dest_width, dest_height);
 
        if (_image_util_check_resolution(dest_width, dest_height)) {
                ret = mm_util_set_crop_area(_handle->image_h, start_x, start_y, end_x, end_y);
-               if (ret != MM_ERROR_NONE) {
-                       LOGE("IMAGE_UTIL_ERROR_INVALID_OPERATION(0x%08x)", IMAGE_UTIL_ERROR_INVALID_OPERATION);
-                       return IMAGE_UTIL_ERROR_INVALID_OPERATION;
-               }
+               image_util_retvm_if((ret != MM_ERROR_NONE), IMAGE_UTIL_ERROR_INVALID_OPERATION, "IMAGE_UTIL_ERROR_INVALID_OPERATION(0x%08x)", IMAGE_UTIL_ERROR_INVALID_OPERATION);
                _handle->start_x = start_x;
                _handle->start_y = start_y;
                _handle->end_x = end_x;
                _handle->end_y = end_y;
                _handle->set_crop  = true;
        } else {
-               LOGE("INVALID_PARAMETER");
+               image_util_error("INVALID_PARAMETER");
                return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
        }
 
@@ -395,20 +345,20 @@ int image_util_transform_get_colorspace(transformation_h handle, image_util_colo
        int ret = IMAGE_UTIL_ERROR_NONE;
        transformation_s *_handle = (transformation_s *)handle;
 
-       LOGD("Get colorspace_convert_info [%d]", colorspace);
+       image_util_debug("Get colorspace_convert_info [%d]", colorspace);
 
        if (_handle == NULL) {
-               LOGE("Invalid Handle");
+               image_util_error("Invalid Handle");
                return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       if (!_handle->set_convert) {
-               LOGE("Did not set colorspace before");
+       if (!colorspace) {
+               image_util_error("colorspace area parameter error");
                return IMAGE_UTIL_ERROR_INVALID_OPERATION;
        }
 
-       if (!colorspace) {
-               LOGE("colorspace area parameter error");
+       if (!_handle->set_convert) {
+               image_util_error("Did not set colorspace before");
                return IMAGE_UTIL_ERROR_INVALID_OPERATION;
        }
 
@@ -421,20 +371,20 @@ int image_util_transform_get_resolution(transformation_h handle, unsigned int *w
        int ret = IMAGE_UTIL_ERROR_NONE;
        transformation_s *_handle = (transformation_s *)handle;
 
-       LOGD("Set resize_info w[%d] h[%d]", width, height);
+       image_util_debug("Set resize_info w[%d] h[%d]", width, height);
 
        if (_handle == NULL) {
-               LOGE("Invalid Handle");
+               image_util_error("Invalid Handle");
                return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       if (!_handle->set_resize) {
-               LOGE("Did not set resolution before");
+       if (!width || !height) {
+               image_util_error("resolution area parameter error");
                return IMAGE_UTIL_ERROR_INVALID_OPERATION;
        }
 
-       if (!width || !height) {
-               LOGE("resolution area parameter error");
+       if (!_handle->set_resize) {
+               image_util_error("Did not set resolution before");
                return IMAGE_UTIL_ERROR_INVALID_OPERATION;
        }
 
@@ -449,20 +399,20 @@ int image_util_transform_get_rotation(transformation_h handle, image_util_rotati
        int ret = IMAGE_UTIL_ERROR_NONE;
        transformation_s *_handle = (transformation_s *)handle;
 
-       LOGD("Set rotate_info [%d]", rotation);
+       image_util_debug("Set rotate_info [%d]", rotation);
 
        if (_handle == NULL) {
-               LOGE("Invalid Handle");
+               image_util_error("Invalid Handle");
                return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       if (!_handle->set_rotate) {
-               LOGE("Did not set rotation before");
+       if (!rotation) {
+               image_util_error("rotation area parameter error");
                return IMAGE_UTIL_ERROR_INVALID_OPERATION;
        }
 
-       if (!rotation) {
-               LOGE("rotation area parameter error");
+       if (!_handle->set_rotate) {
+               image_util_error("Did not set rotation before");
                return IMAGE_UTIL_ERROR_INVALID_OPERATION;
        }
 
@@ -477,17 +427,17 @@ int image_util_transform_get_crop_area(transformation_h handle, unsigned int *st
        transformation_s *_handle = (transformation_s *)handle;
 
        if (_handle == NULL) {
-               LOGE("Invalid Handle");
+               image_util_error("Invalid Handle");
                return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       if (!_handle->set_crop) {
-               LOGE("Did not set crop area before");
+       if (!start_x || !start_y || !end_x || !end_y) {
+               image_util_error("crop area parameter error");
                return IMAGE_UTIL_ERROR_INVALID_OPERATION;
        }
 
-       if (!start_x || !start_y || !end_x || !end_y) {
-               LOGE("crop area parameter error");
+       if (!_handle->set_crop) {
+               image_util_error("Did not set crop area before");
                return IMAGE_UTIL_ERROR_INVALID_OPERATION;
        }
 
@@ -504,12 +454,9 @@ int image_util_transform_run(transformation_h handle, media_packet_h src, image_
        int ret = IMAGE_UTIL_ERROR_NONE;
        transformation_s *_handle = (transformation_s *)handle;
 
-       LOGD("image_util_transform");
+       image_util_debug("image_util_transform");
 
-       if (_handle == NULL) {
-               LOGE("Invalid Handle");
-               return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
-       }
+       image_util_retvm_if((_handle == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
 
        if (completed_cb) {
                if (_handle->_util_cb != NULL) {
@@ -517,22 +464,19 @@ int image_util_transform_run(transformation_h handle, media_packet_h src, image_
                        _handle->_util_cb = NULL;
                }
                _handle->_util_cb = (image_util_cb_s *)calloc(1, sizeof(image_util_cb_s));
-               if (!_handle->_util_cb) {
-                       LOGE("Out of memory");
-                       return IMAGE_UTIL_ERROR_OUT_OF_MEMORY;
-               }
+               image_util_retvm_if((_handle->_util_cb == NULL), IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "Out of memory");
 
                _handle->_util_cb->user_data = user_data;
                _handle->_util_cb->image_processing_completed_cb = completed_cb;
        } else {
-               LOGE("INVALID_PARAMETER[completed_cb](0x%08x)", IMAGE_UTIL_ERROR_INVALID_PARAMETER);
+               image_util_error("INVALID_PARAMETER[completed_cb](0x%08x)", IMAGE_UTIL_ERROR_INVALID_PARAMETER);
                return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
        }
 
        if (_handle->_util_cb && src && (_handle->set_convert || _handle->set_resize || _handle->set_rotate || _handle->set_crop)) {
                ret = mm_util_transform(_handle->image_h, src, (mm_util_completed_callback)_image_util_transform_completed_cb, (void *)_handle->_util_cb);
        } else {
-               LOGE("INVALID_PARAMETER[transform] (0x%08x)", IMAGE_UTIL_ERROR_INVALID_PARAMETER);
+               image_util_error("INVALID_PARAMETER[transform] (0x%08x)", IMAGE_UTIL_ERROR_INVALID_PARAMETER);
                return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
        }
        return _convert_image_util_error_code(__func__, ret);
@@ -543,10 +487,10 @@ int image_util_transform_destroy(transformation_h handle)
        int ret = IMAGE_UTIL_ERROR_NONE;
        transformation_s *_handle = (transformation_s *)handle;
 
-       LOGD("image_util_destroy");
+       image_util_debug("image_util_destroy");
 
        if (_handle == NULL) {
-               LOGE("Invalid Handle");
+               image_util_error("Invalid Handle");
                return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
        }
 
index 1fa1614..7329a06 100755 (executable)
 */
 
 #include <glib.h>
+#include <glib/gprintf.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <image_util.h>
 #include <image_util_type.h>
 #include <mm_error.h>
 
 #define MAX_STRING_LEN 128
 #define IMAGE_FORMAT_LABEL_BUFFER_SIZE 4
+#define IMAGE_TEST_MAX_REPEAT_COUNT 100
 
 #define IMAGE_UTIL_SAFE_FREE(src)      { if(src) {free(src); src = NULL;}}
 
 GMainLoop *g_loop = NULL;
 transformation_h g_handle = NULL;
 media_packet_h g_src = NULL;
-media_packet_h g_result = NULL;
 char *g_path = NULL;
 unsigned int g_width = 0;
 unsigned int g_height = 0;
 int g_format = -1;
 
-GCond *g_thread_cond = NULL;
-GMutex *g_thread_mutex = NULL;
+GCond g_thread_cond;
+GMutex g_thread_mutex;
 
 enum {
     CURRENT_STATE_MAIN_MENU,
@@ -57,19 +59,19 @@ int g_menu_set_image_state = CURRENT_STATE_SET_IMAGE_NONE;
 
 void _wait()
 {
-       g_mutex_lock(g_thread_mutex);
+       g_mutex_lock(&g_thread_mutex);
        g_printf("waiting... untill finishing transform \n");
-       g_cond_wait(g_thread_cond, g_thread_mutex);
+       g_cond_wait(&g_thread_cond, &g_thread_mutex);
        g_printf("<=== get signal from callback \n");
-       g_mutex_unlock(g_thread_mutex);
+       g_mutex_unlock(&g_thread_mutex);
 }
 
 void _signal()
 {
-       g_mutex_lock(g_thread_mutex);
-       g_cond_signal(g_thread_cond);
+       g_mutex_lock(&g_thread_mutex);
+       g_cond_signal(&g_thread_cond);
        g_printf("===> send signal to test proc \n");
-       g_mutex_unlock(g_thread_mutex);
+       g_mutex_unlock(&g_thread_mutex);
 }
 
 media_format_mimetype_e
@@ -136,7 +138,7 @@ bool test_transform_completed_cb(media_packet_h *packet, image_util_error_e erro
 
        g_printf("test_transform_completed_cb============= [%d] \n", error);
        if (error == MM_ERROR_NONE) {
-               g_printf("completed");
+               g_printf("<<<<< SUCCESS >>>>>");
                output_fmt = (char *)malloc(sizeof(char) * IMAGE_FORMAT_LABEL_BUFFER_SIZE);
                if (output_fmt) {
                        if (media_packet_get_format(*packet, &dst_fmt) != MM_ERROR_NONE) {
@@ -145,18 +147,6 @@ bool test_transform_completed_cb(media_packet_h *packet, image_util_error_e erro
                                return FALSE;
                        }
 
-                       if (g_result != NULL) {
-                               media_packet_destroy(g_result);
-                       }
-                       media_packet_create_alloc(dst_fmt, NULL, NULL, &g_result);
-                       if (media_packet_get_buffer_size(g_result, &size) != MM_ERROR_NONE) {
-                               g_printf("Imedia_packet_get_format)");
-                               media_format_unref(dst_fmt);
-                               _signal();
-                               return FALSE;
-                       }
-                       g_printf("g_result: %p [%d] \n", g_result, size);
-
                        if (media_format_get_video_info(dst_fmt, &dst_mimetype, &dst_width, &dst_height, &dst_avg_bps, &dst_max_bps) == MEDIA_FORMAT_ERROR_NONE) {
                                memset(output_fmt, 0, IMAGE_FORMAT_LABEL_BUFFER_SIZE);
                                if (dst_mimetype  == MEDIA_FORMAT_YV12 || dst_mimetype == MEDIA_FORMAT_422P || dst_mimetype == MEDIA_FORMAT_I420
@@ -182,7 +172,7 @@ bool test_transform_completed_cb(media_packet_h *packet, image_util_error_e erro
                                _signal();
                                return FALSE;
                        }
-                       g_printf("dst: %p [%d] \n", dst, size);
+                       g_printf("dst: %p [%llu] \n", dst, size);
                        fwrite(dst, 1, size, fpout);
                        g_printf("FREE \n");
                        fclose(fpout);
@@ -192,7 +182,7 @@ bool test_transform_completed_cb(media_packet_h *packet, image_util_error_e erro
                g_printf("Free (output_fmt) \n");
                IMAGE_UTIL_SAFE_FREE(output_fmt);
        } else {
-               g_printf("[ERROR] complete cb");
+               g_printf("<<<<< ERROR >>>>> complete cb");
                _signal();
                return FALSE;
        }
@@ -337,7 +327,7 @@ static void _destroy()
        g_handle = NULL;
 }
 
-static void _transform(char *cmd)
+static void _transform(const char *cmd)
 {
        int ret = 0;
        unsigned int width = 0;
@@ -350,7 +340,7 @@ static void _transform(char *cmd)
        int end_y;
 
        if (!strcmp("convert", cmd)) {
-               colorspace = IMAGE_UTIL_COLORSPACE_RGB888;
+               colorspace = IMAGE_UTIL_COLORSPACE_I420;
 
                ret = image_util_transform_set_colorspace(g_handle, colorspace);
                if (ret != IMAGE_UTIL_ERROR_NONE) {
@@ -360,8 +350,10 @@ static void _transform(char *cmd)
        }
 
        if (!strcmp("resize", cmd)) {
-               width = 480;
-               height = 360;
+               width = g_width/2;
+               height = g_height/2;
+//             width = g_width;
+//             height = g_height;
 
                ret = image_util_transform_set_resolution(g_handle, width, height);
                if (ret != IMAGE_UTIL_ERROR_NONE) {
@@ -394,7 +386,7 @@ static void _transform(char *cmd)
        }
 
        if (!strcmp("run", cmd)) {
-               ret = image_util_transform_run(g_handle, g_src, test_transform_completed_cb, NULL);
+               ret = image_util_transform_run(g_handle, g_src, (image_util_transform_completed_cb)test_transform_completed_cb, NULL);
                if (ret != IMAGE_UTIL_ERROR_NONE) {
                        g_printf("[%d]Error image_util_transform [%d]\n", __LINE__, ret);
                        return;
@@ -404,6 +396,16 @@ static void _transform(char *cmd)
 
 }
 
+static void _loop_test(const int count)
+{
+       int i = 0;
+       for(i = 0; i < count; i++) {
+               _transform("run");
+               _set_image();
+               g_printf("<<<<< %03d >>>>>\n", i);
+       }
+}
+
 void quit(void)
 {
        if (g_loop)
@@ -445,7 +447,7 @@ static void display_menu(void)
        g_print("5. set resize \n");
        g_print("6. set rotate \n");
        g_print("7. run \n");
-       g_print("8. run with result \n");
+       g_print("8. run repeatly \n");
        g_print("9. destroy handle \n");
        g_print("0. quit \n");
        g_print("----------------------------------------------------\n");
@@ -523,6 +525,8 @@ static void interpret_cmd(char *cmd)
                                _transform("rotate");
                        } else if (!strncmp(cmd, "7", len)) {
                                _transform("run");
+                       } else if (!strncmp(cmd, "8", len)) {
+                               _loop_test(IMAGE_TEST_MAX_REPEAT_COUNT);
                        } else if (!strncmp(cmd, "9", len)) {
                                _destroy();
                        } else if (!strncmp(cmd, "0", len)) {
@@ -578,8 +582,8 @@ int main(int argc, char **argv)
        g_height = atoi(argv[3]);
        g_format = atoi(argv[4]);
 
-       g_thread_mutex = g_mutex_new();
-       g_thread_cond = g_cond_new();
+       g_mutex_init(&g_thread_mutex);
+       g_cond_init(&g_thread_cond);
 
        ret = image_util_transform_create(&g_handle);
        if (ret != IMAGE_UTIL_ERROR_NONE) {
@@ -611,8 +615,8 @@ int main(int argc, char **argv)
        g_main_loop_unref(g_loop);
 
 Exit:
-       g_mutex_free(g_thread_mutex);
-       g_cond_free(g_thread_cond);
+       g_mutex_clear(&g_thread_mutex);
+       g_cond_clear(&g_thread_cond);
        if (g_path) {
                IMAGE_UTIL_SAFE_FREE(g_path);
                g_printf("[%d]Success file path is destroyed \n", __LINE__);