Rearrange the source code and remove unused macro 29/190129/3 accepted/tizen/5.0/unified/20181102.013217 accepted/tizen/unified/20181001.092525 submit/tizen/20180928.062042 submit/tizen_5.0/20181101.000002
authorjiyong.min <jiyong.min@samsung.com>
Thu, 27 Sep 2018 05:40:01 +0000 (14:40 +0900)
committerjiyong.min <jiyong.min@samsung.com>
Thu, 27 Sep 2018 23:23:59 +0000 (08:23 +0900)
Change-Id: I748f39c12d16d8944c741ffdf9f4838bb535b396

include/image_util_private.h
packaging/capi-media-image-util.spec
src/image_util.c
src/image_util_decode.c
src/image_util_encode.c

index 036769c..8c4c090 100755 (executable)
@@ -71,9 +71,6 @@ extern "C"
                } \
        } while (0)
 
-#define DEPRECATION_LOGW(deprecated, instead) do { \
-               image_util_warning("DEPRECATION WARNING: %s is deprecated and will be removed from next release. Use %s instead.", deprecated, instead);     \
-       } while (0)
 
 #define IMAGE_UTIL_STRING_VALID(str)   \
        ((str != NULL && strlen(str) > 0) ? true : false)
index 64a021f..7c6ef5e 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       capi-media-image-util
 Summary:    A Image Utility library in Tizen Native API
-Version:    0.1.41
+Version:    0.1.42
 Release:    2
 Group:      Multimedia/API
 License:    Apache-2.0
index 9e79528..1d6be7a 100755 (executable)
@@ -87,10 +87,7 @@ static int __create_media_format(media_format_mimetype_e mimetype, unsigned int
        image_util_retvm_if((new_fmt == NULL) || (width == 0) || (height == 0), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter");
 
        err = media_format_create(new_fmt);
-       if (err != MEDIA_FORMAT_ERROR_NONE) {
-               image_util_error("media_format_make_writable failed (%d)", err);
-               return IMAGE_UTIL_ERROR_INVALID_OPERATION;
-       }
+       image_util_retvm_if((err != MEDIA_FORMAT_ERROR_NONE), IMAGE_UTIL_ERROR_INVALID_OPERATION, "media_format_make_writable failed (%d)", err);
 
        err = media_format_set_video_mime(*new_fmt, mimetype);
        if (err != MEDIA_FORMAT_ERROR_NONE) {
@@ -128,10 +125,7 @@ static int _image_util_packet_to_image(media_packet_h packet, mm_util_color_imag
        image_util_retvm_if(((packet == NULL) || (color_image == NULL)), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter");
 
        err = media_packet_get_format(packet, &fmt);
-       if (err != MEDIA_PACKET_ERROR_NONE) {
-               image_util_error("media_packet_get_format failed (%d)", err);
-               return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
-       }
+       image_util_retvm_if((err != MEDIA_PACKET_ERROR_NONE), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "media_packet_get_format failed (%d)", err);
 
        err = media_format_get_video_info(fmt, &mimetype, &width, &height, NULL, NULL);
        if (err != MEDIA_FORMAT_ERROR_NONE) {
@@ -142,30 +136,18 @@ static int _image_util_packet_to_image(media_packet_h packet, mm_util_color_imag
        media_format_unref(fmt);
 
        err = media_packet_get_buffer_size(packet, &size);
-       if (err != MEDIA_PACKET_ERROR_NONE) {
-               image_util_error("media_packet_get_buffer_size failed (%d)", err);
-               return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
-       }
+       image_util_retvm_if((err != MEDIA_PACKET_ERROR_NONE), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "media_packet_get_buffer_size failed (%d)", err);
 
        if (size) {
                err = media_packet_get_buffer_data_ptr(packet, &ptr);
-               if (err != MM_UTIL_ERROR_NONE) {
-                       image_util_error("media_packet_get_buffer_data_ptr failed (%d)", err);
-                       return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
-               }
+               image_util_retvm_if((err != MEDIA_PACKET_ERROR_NONE), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "media_packet_get_buffer_data_ptr failed (%d)", err);
        }
 
        image_util_debug("[Fotmat: %u] W x H : %d x %d", mimetype, width, height);
-       if ((width == 0) || (height == 0) || (size == 0) || (ptr == NULL)) {
-               image_util_error("Invalid source packet");
-               return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
-       }
+       image_util_retvm_if(((width == 0) || (height == 0) || (size == 0) || (ptr == NULL)), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid source packet");
 
        err = mm_util_create_color_image(color_image, (unsigned long)width, (unsigned long)height, __mimetype_to_image_format(mimetype), ptr, (size_t)size);
-       if (err != MM_UTIL_ERROR_NONE) {
-               image_util_error("mm_util_create_color_image failed (%d)", err);
-               return _image_error_capi(ERR_TYPE_TRANSFORM, err);
-       }
+       image_util_retvm_if((err != MM_UTIL_ERROR_NONE), _image_error_capi(ERR_TYPE_TRANSFORM, err), "mm_util_create_color_image failed (%d)", err);
 
        image_util_debug("_image_util_packet_to_image succeed");
 
@@ -185,16 +167,10 @@ static int _image_util_image_to_packet(mm_util_color_image_h image, media_packet
        size_t size = 0;
 
        err = mm_util_get_color_image(image, &width, &height, &format, &buffer, &buffer_size);
-       if (err != MM_UTIL_ERROR_NONE) {
-               image_util_error("mm_util_get_color_image failed (%d)", err);
-               return _image_error_capi(ERR_TYPE_TRANSFORM, err);
-       }
+       image_util_retvm_if((err != MM_UTIL_ERROR_NONE), _image_error_capi(ERR_TYPE_TRANSFORM, err), "mm_util_get_color_image failed (%d)", err);
 
        err = __create_media_format(__image_format_to_mimetype(format), (unsigned int)width, (unsigned int)height, &fmt);
-       if (err != IMAGE_UTIL_ERROR_NONE) {
-               image_util_error("mm_util_push_request_image failed (%d)", err);
-               return err;
-       }
+       image_util_retvm_if((err != IMAGE_UTIL_ERROR_NONE), err, "__create_media_format failed (%d)", err);
 
        err = media_packet_create_alloc(fmt, NULL, NULL, packet);
        if (err != MEDIA_PACKET_ERROR_NONE) {
@@ -263,10 +239,7 @@ static int _image_util_create_transform_handle(transformation_s * handle)
        mm_util_imgp_h image_h;
 
        err = mm_util_create(&image_h);
-       if (err != MM_UTIL_ERROR_NONE) {
-               image_util_error("Error - mm_util_create");
-               return _image_error_capi(ERR_TYPE_TRANSFORM, err);
-       }
+       image_util_retvm_if((err != MM_UTIL_ERROR_NONE), _image_error_capi(ERR_TYPE_TRANSFORM, err), "Error - mm_util_create");
 
        handle->image_h = image_h;
 
@@ -331,10 +304,7 @@ int image_util_transform_set_colorspace(transformation_h handle, image_util_colo
        image_util_retvm_if((_handle == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
 
        err = mm_util_set_colorspace_convert(_handle->image_h, colorspace);
-       if (err != MM_UTIL_ERROR_NONE) {
-               image_util_error("Error - Set colorspace convert");
-               return _image_error_capi(ERR_TYPE_TRANSFORM, err);
-       }
+       image_util_retvm_if((err != MM_UTIL_ERROR_NONE), _image_error_capi(ERR_TYPE_TRANSFORM, err), "Error - Set colorspace convert");
 
        _handle->colorspace = colorspace;
        _handle->set_convert = true;
@@ -354,10 +324,8 @@ int image_util_transform_set_resolution(transformation_h handle, unsigned int wi
        image_util_retvm_if((_image_util_check_resolution(width, height) == false), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid resolution");
 
        err = mm_util_set_resolution(_handle->image_h, width, height);
-       if (err != MM_UTIL_ERROR_NONE) {
-               image_util_error("Error - Set resolution");
-               return _image_error_capi(ERR_TYPE_TRANSFORM, err);
-       }
+       image_util_retvm_if((err != MM_UTIL_ERROR_NONE), _image_error_capi(ERR_TYPE_TRANSFORM, err), "Error - Set resolution");
+
        _handle->width = width;
        _handle->height = height;
        _handle->set_resize = true;
@@ -375,10 +343,8 @@ int image_util_transform_set_rotation(transformation_h handle, image_util_rotati
        image_util_retvm_if((_handle == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
 
        err = mm_util_set_rotation(_handle->image_h, rotation);
-       if (err != MM_UTIL_ERROR_NONE) {
-               image_util_error("Error - Set rotation");
-               return _image_error_capi(ERR_TYPE_TRANSFORM, err);
-       }
+       image_util_retvm_if((err != MM_UTIL_ERROR_NONE), _image_error_capi(ERR_TYPE_TRANSFORM, err), "Error - Set rotation");
+
        _handle->rotation = rotation;
        _handle->set_rotate = true;
 
@@ -402,10 +368,8 @@ int image_util_transform_set_crop_area(transformation_h handle, unsigned int sta
 
        image_util_retvm_if((_image_util_check_resolution(dest_width, dest_height) == false), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid dest resolution");
        err = mm_util_set_crop_area(_handle->image_h, start_x, start_y, end_x, end_y);
-       if (err != MM_UTIL_ERROR_NONE) {
-               image_util_error("Error - Set crop area");
-               return _image_error_capi(ERR_TYPE_TRANSFORM, err);
-       }
+       image_util_retvm_if((err != MM_UTIL_ERROR_NONE), _image_error_capi(ERR_TYPE_TRANSFORM, err), "Error - Set crop area");
+
        _handle->start_x = start_x;
        _handle->start_y = start_y;
        _handle->end_x = end_x;
index eab8d36..6eadc18 100755 (executable)
@@ -46,10 +46,7 @@ static int _image_util_decode_read_header(const char *path, unsigned char **buff
        image_util_retvm_if(buffer == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid buffer");
 
        fp = fopen(path, "r");
-       if (fp == NULL) {
-               image_util_error("File open failed %s", path);
-               return IMAGE_UTIL_ERROR_NO_SUCH_FILE;
-       }
+       image_util_retvm_if(fp == NULL, IMAGE_UTIL_ERROR_NO_SUCH_FILE, "File open failed %s", path);
 
        read_buffer = (void *)calloc(1, IMG_HEADER_LENGTH + 1);
        if (read_buffer == NULL) {
@@ -169,10 +166,7 @@ int image_util_decode_set_input_path(image_util_decode_h handle, const char *pat
                _handle->src_buffer = NULL;
 
        err = _image_util_decode_read_header(path, &image_header);
-       if (err != IMAGE_UTIL_ERROR_NONE) {
-               image_util_error("_image_util_decode_read_header failed");
-               return err;
-       }
+       image_util_retvm_if((err != IMAGE_UTIL_ERROR_NONE), err, "_image_util_decode_read_header failed");
 
        err = _image_util_decode_check_image_type(image_header, &_handle->image_type);
        if (err != IMAGE_UTIL_ERROR_NONE) {
@@ -184,10 +178,7 @@ int image_util_decode_set_input_path(image_util_decode_h handle, const char *pat
        IMAGE_UTIL_SAFE_FREE(image_header);
 
        err = _image_util_decode_create_image_handle(_handle);
-       if (err != IMAGE_UTIL_ERROR_NONE) {
-               image_util_error("_image_util_decode_create_image_handle failed");
-               return err;
-       }
+       image_util_retvm_if((err != IMAGE_UTIL_ERROR_NONE), err, "_image_util_decode_create_image_handle failed");
 
        _handle->path = g_strndup(path, strlen(path));
        image_util_retvm_if(_handle->path == NULL, IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
@@ -376,7 +367,7 @@ int image_util_decode_run(image_util_decode_h handle, unsigned long *width, unsi
        image_util_retvm_if(_handle->dst_buffer == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid output");
 
        err = _image_util_decode_internal(_handle);
-       image_util_retvm_if(err != IMAGE_UTIL_ERROR_NONE, err, "fail to _image_util_decode_internal");
+       image_util_retvm_if(err != IMAGE_UTIL_ERROR_NONE, err, "_image_util_decode_internal failed");
 
        if (width)
                *width = _handle->width;
index 51326c4..7733bc0 100755 (executable)
@@ -30,16 +30,12 @@ static int _image_util_encode_get_gif_frame(mm_gif_file_h gif_data, unsigned int
        image_util_retvm_if((frame == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
 
        err = mm_util_gif_enocde_get_image_handle(gif_data, (int)index, frame);
-       if (err != MM_UTIL_ERROR_NONE) {
-               image_util_error("mm_util_gif_enocde_get_image_handle is failed %d", err);
-               return _image_error_capi(ERR_TYPE_ENCODE, err);
-       }
+       image_util_retvm_if((err != MM_UTIL_ERROR_NONE), _image_error_capi(ERR_TYPE_ENCODE, err), "mm_util_gif_enocde_get_image_handle failed %d", err);
+
        if (*frame == NULL) {
                err = mm_util_gif_image_create(gif_data, frame);
-               if (err != MM_UTIL_ERROR_NONE) {
-                       image_util_error("mm_util_gif_image_create is failed %d", err);
-                       return _image_error_capi(ERR_TYPE_ENCODE, err);
-               }
+               image_util_retvm_if((err != MM_UTIL_ERROR_NONE), _image_error_capi(ERR_TYPE_ENCODE, err), "mm_util_gif_image_create failed %d", err);
+
                err = mm_util_gif_enocde_set_image_handle(gif_data, *frame);
                if (err != MM_UTIL_ERROR_NONE) {
                        image_util_error("mm_util_gif_enocde_set_image_handle is failed %d", err);
@@ -202,15 +198,11 @@ int image_util_encode_set_resolution(image_util_encode_h handle, unsigned long w
                        }
                        mm_gif_image_h frame = NULL;
                        err = _image_util_encode_get_gif_frame(gif_data, _handle->current_resolution_count, &frame);
-                       if (err != IMAGE_UTIL_ERROR_NONE) {
-                               image_util_error("_image_util_encode_get_gif_frame is failed %d", err);
-                               return err;
-                       }
+                       image_util_retvm_if((err != IMAGE_UTIL_ERROR_NONE), err, "_image_util_encode_get_gif_frame failed %d", err);
+
                        err = mm_util_gif_image_set_position(frame, 0, 0, (int)width, (int)height);
-                       if (err != MM_UTIL_ERROR_NONE) {
-                               image_util_error("mm_util_gif_image_set_position is failed %d", err);
-                               return _image_error_capi(ERR_TYPE_ENCODE, err);
-                       }
+                       image_util_retvm_if((err != MM_UTIL_ERROR_NONE), _image_error_capi(ERR_TYPE_ENCODE, err), "mm_util_gif_image_set_position failed %d", err);
+
                        _handle->current_resolution_count++;
 
                        return err;
@@ -296,15 +288,11 @@ int image_util_encode_set_gif_frame_delay_time(image_util_encode_h handle, unsig
 
        mm_gif_image_h frame = NULL;
        err = _image_util_encode_get_gif_frame(gif_data, _handle->current_delay_count, &frame);
-       if (err != IMAGE_UTIL_ERROR_NONE) {
-               image_util_error("_image_util_encode_get_gif_frame is failed %d", err);
-               return err;
-       }
+       image_util_retvm_if((err != IMAGE_UTIL_ERROR_NONE), err, "_image_util_encode_get_gif_frame failed %d", err);
+
        err = mm_util_gif_image_set_delay_time(frame, (int)delay_time);
-       if (err != MM_UTIL_ERROR_NONE) {
-               image_util_error("mm_util_gif_image_set_delay_time is failed %d", err);
-               return  _image_error_capi(ERR_TYPE_ENCODE, err);
-       }
+       image_util_retvm_if((err != MM_UTIL_ERROR_NONE), _image_error_capi(ERR_TYPE_ENCODE, err), "mm_util_gif_image_set_delay_time failed %d", err);
+
        _handle->current_delay_count++;
 
        return err;
@@ -329,15 +317,11 @@ int image_util_encode_set_input_buffer(image_util_encode_h handle, const unsigne
                image_util_retvm_if(gif_data == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid gif data");
 
                err = _image_util_encode_get_gif_frame(gif_data, _handle->current_buffer_count, &frame);
-               if (err != IMAGE_UTIL_ERROR_NONE) {
-                       image_util_error("_image_util_encode_get_gif_frame is failed %d", err);
-                       return err;
-               }
+               image_util_retvm_if((err != IMAGE_UTIL_ERROR_NONE), err, "_image_util_encode_get_gif_frame failed %d", err);
+
                err = mm_util_gif_image_set_image(frame, src_buffer);
-               if (err != MM_UTIL_ERROR_NONE) {
-                       image_util_error("mm_util_gif_image_set_image is failed %d", err);
-                       return  _image_error_capi(ERR_TYPE_ENCODE, err);
-               }
+               image_util_retvm_if((err != MM_UTIL_ERROR_NONE), _image_error_capi(ERR_TYPE_ENCODE, err), "mm_util_gif_image_set_image failed %d", err);
+
                _handle->current_buffer_count++;
        } else {
                if (_handle->src_buffer == NULL)
@@ -442,15 +426,11 @@ static int _image_util_encode_internal(decode_encode_s * _handle)
                                err = mm_util_gif_encode_set_file(gif_data, _handle->path);
                        else
                                err = mm_util_gif_encode_set_mem(gif_data, _handle->dst_buffer, &encoded_buffer_size);
-                       if (err != MM_UTIL_ERROR_NONE) {
-                               image_util_error("mm_util_gif_encode_set_file | mm_util_gif_encode_set_mem is failed(%d)", err);
-                               return _image_error_capi(ERR_TYPE_ENCODE, err);
-                       }
+                       image_util_retvm_if((err != MM_UTIL_ERROR_NONE), _image_error_capi(ERR_TYPE_ENCODE, err), "mm_util_gif_encode_set_file | mm_util_gif_encode_set_mem failed %d", err);
+
                        err = mm_util_gif_encode(gif_data);
-                       if (err != MM_UTIL_ERROR_NONE) {
-                               image_util_error("mm_util_gif_encode is failed(%d)", err);
-                               return _image_error_capi(ERR_TYPE_ENCODE, err);
-                       }
+                       image_util_retvm_if((err != MM_UTIL_ERROR_NONE), _image_error_capi(ERR_TYPE_ENCODE, err), "mm_util_gif_encode failed %d", err);
+
                        if (encoded_buffer_size != 0)
                                _handle->dst_size = (unsigned long long)encoded_buffer_size;
                }
@@ -490,10 +470,7 @@ int image_util_encode_run(image_util_encode_h handle, unsigned long long *size)
        image_util_retvm_if((_image_util_check_resolution(_handle->width, _handle->height) == false), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid resolution");
 
        err = _image_util_encode_internal(_handle);
-       if (err != IMAGE_UTIL_ERROR_NONE) {
-               image_util_error("Error - encode run");
-               return err;
-       }
+       image_util_retvm_if((err != IMAGE_UTIL_ERROR_NONE), err, "_image_util_encode_internal failed");
 
        if (size)
                *size = _handle->dst_size;