Just update debug msg 46/170346/2
authorhj kim <backto.kim@samsung.com>
Mon, 19 Feb 2018 08:49:11 +0000 (17:49 +0900)
committerhj kim <backto.kim@samsung.com>
Mon, 19 Feb 2018 08:55:11 +0000 (17:55 +0900)
Change-Id: Ie1f91df536342038ea6eb5d7a0e4168241286d15

imgp/mm_util_imgp.c

index c93c579..6e964b2 100755 (executable)
@@ -231,18 +231,11 @@ static int __mm_util_get_crop_image_size(mm_util_color_format_e format, unsigned
 
        mm_util_fenter();
 
-       if (!imgsize) {
-               mm_util_error("imgsize can't be null");
-               return MM_UTIL_ERROR_NO_SUCH_FILE;
-       }
+       mm_util_retvm_if(imgsize == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid imgsize");
+       mm_util_retvm_if(check_valid_picture_size(width, height) != MM_UTIL_ERROR_NONE, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid width and height");
 
        *imgsize = 0;
 
-       if (check_valid_picture_size(width, height) < 0) {
-               mm_util_error("invalid width and height");
-               return MM_UTIL_ERROR_INVALID_PARAMETER;
-       }
-
        switch (format) {
        case MM_UTIL_COLOR_I420:
        case MM_UTIL_COLOR_YUV420:
@@ -323,18 +316,11 @@ int __mm_util_get_buffer_size(mm_util_color_format_e format, unsigned int width,
 
        mm_util_fenter();
 
-       if (!imgsize) {
-               mm_util_error("imgsize can't be null");
-               return MM_UTIL_ERROR_NO_SUCH_FILE;
-       }
+       mm_util_retvm_if(imgsize == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid imgsize");
+       mm_util_retvm_if(check_valid_picture_size(width, height) != MM_UTIL_ERROR_NONE, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid width and height");
 
        *imgsize = 0;
 
-       if (check_valid_picture_size(width, height) < 0) {
-               mm_util_error("invalid width and height");
-               return MM_UTIL_ERROR_INVALID_PARAMETER;
-       }
-
        switch (format) {
        case MM_UTIL_COLOR_I420:
        case MM_UTIL_COLOR_YUV420:
@@ -409,10 +395,8 @@ static int __mm_confirm_dst_width_height(unsigned int src_width, unsigned int sr
 {
        int ret = MM_UTIL_ERROR_NONE;
 
-       if (!dst_width || !dst_height) {
-               mm_util_error("dst_width || dst_height is NULL");
-               return MM_UTIL_ERROR_INVALID_PARAMETER;
-       }
+       mm_util_retvm_if(dst_width == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid dst_width");
+       mm_util_retvm_if(dst_height == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid dst_height");
 
        mm_util_fenter();
 
@@ -458,10 +442,7 @@ static int __mm_set_imgp_info_s(imgp_info_s *_imgp_info_s, mm_util_color_format_
 {
        int ret = MM_UTIL_ERROR_NONE;
 
-       if (_imgp_info_s == NULL) {
-               mm_util_error("_imgp_info_s is NULL");
-               return MM_UTIL_ERROR_INVALID_PARAMETER;
-       }
+       mm_util_retvm_if(_imgp_info_s == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid _imgp_info_s");
 
        _imgp_info_s->src_format = src_format;
        _imgp_info_s->src_width = src_width;
@@ -488,10 +469,7 @@ static GModule *__mm_util_imgp_initialize(imgp_plugin_type_e _imgp_plugin_type_e
        else if (_imgp_plugin_type_e == IMGP_GSTCS)
                module = g_module_open(PATH_GSTCS_LIB, G_MODULE_BIND_LAZY);
 
-       if (module == NULL) {
-               mm_util_error("[%d] %s | %s module open failed", _imgp_plugin_type_e, PATH_NEON_LIB, PATH_GSTCS_LIB);
-               return NULL;
-       }
+       mm_util_retvm_if(module == NULL, NULL, "[%d] %s | %s module open failed", _imgp_plugin_type_e, PATH_NEON_LIB, PATH_GSTCS_LIB);
        mm_util_debug("module: %p, g_module_name: %s", module, g_module_name(module));
 
        return module;
@@ -604,10 +582,7 @@ static int __mm_util_handle_init(mm_util_s *handle)
 {
        int ret = MM_UTIL_ERROR_NONE;
 
-       if (!handle) {
-               mm_util_error("[ERROR] - handle");
-               return MM_UTIL_ERROR_INVALID_OPERATION;
-       }
+       mm_util_retvm_if(handle == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid handle");
 
        /* private values init */
        handle->dst = NULL;
@@ -644,10 +619,7 @@ gpointer _mm_util_thread_repeate(gpointer data)
        int ret = MM_UTIL_ERROR_NONE;
        mm_util_color_image_h pop_data = NULL;
 
-       if (!handle) {
-               mm_util_error("[ERROR] - handle");
-               return NULL;
-       }
+       mm_util_retvm_if(handle == NULL, NULL, "invalid handle");
 
        while (!handle->is_finish) {
                mm_util_debug("waiting...");
@@ -684,22 +656,12 @@ static int __mm_util_create_thread(mm_util_s *handle)
 {
        int ret = MM_UTIL_ERROR_NONE;
 
-       if (!handle) {
-               mm_util_error("[ERROR] - handle");
-               return MM_UTIL_ERROR_INVALID_PARAMETER;
-       }
-
-       if (handle->thread) {
-               mm_util_error("Thread is already created");
-               return MM_UTIL_ERROR_NONE;
-       }
+       mm_util_retvm_if(handle == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid handle");
+       mm_util_retvm_if(handle->thread != NULL, MM_UTIL_ERROR_NONE, "[NO-ERROR] Thread is already created");
 
        /*create threads*/
        handle->thread = g_thread_new("transform_thread", (GThreadFunc)_mm_util_thread_repeate, (gpointer)handle);
-       if (!handle->thread) {
-               mm_util_error("ERROR - create thread");
-               return MM_UTIL_ERROR_INVALID_OPERATION;
-       }
+       mm_util_retvm_if(handle->thread == NULL, MM_UTIL_ERROR_INVALID_OPERATION, "ERROR - create thread");
 
        mm_util_debug("New thread is created");
 
@@ -719,10 +681,7 @@ static int __mm_util_processing(mm_util_s *handle)
        unsigned char *res_buffer = NULL;
        size_t res_buffer_size = 0;
 
-       if (handle == NULL) {
-               mm_util_error("Invalid arguments [tag null]");
-               return MM_UTIL_ERROR_INVALID_PARAMETER;
-       }
+       mm_util_retvm_if(handle == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid handle");
 
        mm_util_debug("src: %p, dst: %p", handle->src, handle->dst);
 
@@ -833,10 +792,8 @@ static int __mm_util_transform_exec(mm_util_s *handle, color_image_data_s *sourc
 {
        int ret = MM_UTIL_ERROR_NONE;
 
-       if ((handle == NULL) || (source_image == NULL)) {
-               mm_util_error("Invalid parameter");
-               return MM_UTIL_ERROR_INVALID_PARAMETER;
-       }
+       mm_util_retvm_if(handle == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid handle");
+       mm_util_retvm_if(source_image == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid source_image");
 
        mm_util_debug("orig_image: %p [%zu] %lu X %lu (%u)", source_image->data, source_image->size,
                source_image->width, source_image->height, source_image->color);
@@ -861,10 +818,7 @@ _mm_util_handle_finalize(mm_util_s *handle)
 {
        int ret = MM_UTIL_ERROR_NONE;
 
-       if (!handle) {
-               mm_util_error("[ERROR] - handle");
-               return MM_UTIL_ERROR_INVALID_OPERATION;
-       }
+       mm_util_retvm_if(handle == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid handle");
 
        /* g_thread_exit(handle->thread); */
        if (handle->thread) {
@@ -886,10 +840,7 @@ int mm_util_create(mm_util_imgp_h *imgp_handle)
 {
        int ret = MM_UTIL_ERROR_NONE;
 
-       if (imgp_handle == NULL) {
-               mm_util_error("Invalid arguments [tag null]");
-               return MM_UTIL_ERROR_INVALID_PARAMETER;
-       }
+       mm_util_retvm_if(imgp_handle == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid imgp_handle");
 
        mm_util_s *handle = calloc(1, sizeof(mm_util_s));
        if (!handle) {
@@ -914,10 +865,7 @@ int mm_util_set_colorspace_convert(mm_util_imgp_h imgp_handle, mm_util_color_for
        int ret = MM_UTIL_ERROR_NONE;
        mm_util_s *handle = (mm_util_s *) imgp_handle;
 
-       if (!handle) {
-               mm_util_error("[ERROR] - handle");
-               return MM_UTIL_ERROR_INVALID_OPERATION;
-       }
+       mm_util_retvm_if(handle == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid handle");
 
        handle->set_convert = TRUE;
        handle->dst_format = colorspace;
@@ -931,10 +879,7 @@ int mm_util_set_resolution(mm_util_imgp_h imgp_handle, unsigned int width, unsig
        int ret = MM_UTIL_ERROR_NONE;
        mm_util_s *handle = (mm_util_s *) imgp_handle;
 
-       if (!handle) {
-               mm_util_error("[ERROR] - handle");
-               return MM_UTIL_ERROR_INVALID_OPERATION;
-       }
+       mm_util_retvm_if(handle == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid handle");
 
        handle->set_resize = TRUE;
        handle->dst_width = width;
@@ -948,11 +893,7 @@ int mm_util_set_rotation(mm_util_imgp_h imgp_handle, mm_util_img_rotate_type rot
        int ret = MM_UTIL_ERROR_NONE;
        mm_util_s *handle = (mm_util_s *) imgp_handle;
 
-
-       if (!handle) {
-               mm_util_error("[ERROR] - handle");
-               return MM_UTIL_ERROR_INVALID_OPERATION;
-       }
+       mm_util_retvm_if(handle == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid handle");
 
        handle->set_rotate = TRUE;
        handle->rotation = rotation;
@@ -968,10 +909,7 @@ int mm_util_set_crop_area(mm_util_imgp_h imgp_handle, unsigned int start_x, unsi
        unsigned int dest_width = end_x - start_x;
        unsigned int dest_height = end_y - start_y;
 
-       if (!handle) {
-               mm_util_error("[ERROR] - handle");
-               return MM_UTIL_ERROR_INVALID_OPERATION;
-       }
+       mm_util_retvm_if(handle == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid handle");
 
        handle->set_crop = TRUE;
        handle->start_x = start_x;
@@ -989,22 +927,11 @@ int mm_util_transform(mm_util_imgp_h imgp_handle, mm_util_color_image_h image, m
 
        mm_util_fenter();
 
-       if (!handle) {
-               mm_util_error("[ERROR] - handle");
-               return MM_UTIL_ERROR_INVALID_OPERATION;
-       }
+       mm_util_retvm_if(handle == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid handle");
+       mm_util_retvm_if(image == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid image");
+       mm_util_retvm_if(completed_callback == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid completed_callback");
 
-       if (!image) {
-               mm_util_error("[ERROR] - image");
-               return MM_UTIL_ERROR_INVALID_PARAMETER;
-       } else {
-               mm_util_debug("image: %p", image);
-       }
-
-       if (!completed_callback) {
-               mm_util_error("[ERROR] - completed_callback");
-               return MM_UTIL_ERROR_INVALID_PARAMETER;
-       }
+       mm_util_debug("image: %p", image);
 
        MMUTIL_SAFE_FREE(handle->_util_cb);
        handle->_util_cb = (mm_util_cb_s *)calloc(1, sizeof(mm_util_cb_s));
@@ -1038,15 +965,8 @@ int mm_util_transform_is_completed(mm_util_imgp_h imgp_handle, bool *is_complete
 
        mm_util_s *handle = (mm_util_s *) imgp_handle;
 
-       if (!handle) {
-               mm_util_error("[ERROR] - handle");
-               return MM_UTIL_ERROR_INVALID_PARAMETER;
-       }
-
-       if (!is_completed) {
-               mm_util_error("[ERROR] - is_completed");
-               return MM_UTIL_ERROR_INVALID_PARAMETER;
-       }
+       mm_util_retvm_if(handle == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid handle");
+       mm_util_retvm_if(!is_completed, MM_UTIL_ERROR_INVALID_PARAMETER, "[ERROR] - is_completed");
 
        *is_completed = handle->is_completed;
        mm_util_debug("[Transform....] %d", *is_completed);
@@ -1061,16 +981,8 @@ int mm_util_destroy(mm_util_imgp_h imgp_handle)
 
        mm_util_fenter();
 
-       if (!handle) {
-               mm_util_error("[ERROR] - handle");
-               return MM_UTIL_ERROR_INVALID_PARAMETER;
-       }
-
-       /* Close */
-       if (_mm_util_handle_finalize(handle) != MM_UTIL_ERROR_NONE) {
-               mm_util_error("_mm_util_handle_finalize)");
-               return MM_UTIL_ERROR_INVALID_PARAMETER;
-       }
+       mm_util_retvm_if(handle == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid handle");
+       mm_util_retvm_if(_mm_util_handle_finalize(handle) != MM_UTIL_ERROR_NONE, MM_UTIL_ERROR_INVALID_PARAMETER, "fail _mm_util_handle_finalize");
 
        MMUTIL_SAFE_FREE(handle->_util_cb);
        MMUTIL_SAFE_FREE(handle);
@@ -1245,10 +1157,7 @@ int mm_util_resize_image(const unsigned char *src, unsigned int src_width, unsig
        mm_util_debug("src_width [%d] src_height [%d] src_format[%d]", src_width, src_height, src_format);
 
        _mm_util_imgp_func = __mm_util_initialize(IMGP_RSZ, src_format, 0, &_module);
-       if (_mm_util_imgp_func == NULL) {
-               mm_util_error("ERROR - __mm_util_initialize");
-               return MM_UTIL_ERROR_INVALID_OPERATION;
-       }
+       mm_util_retvm_if(_mm_util_imgp_func == NULL, MM_UTIL_ERROR_INVALID_OPERATION, "fail __mm_util_initialize");
 
        imgp_info_s *_imgp_info_s = (imgp_info_s *) calloc(1, sizeof(imgp_info_s));
        if (_imgp_info_s == NULL) {