Code cleanup for mm_util_image_h 11/234811/1
authorjiyong.min <jiyong.min@samsung.com>
Fri, 29 May 2020 03:18:44 +0000 (12:18 +0900)
committerjiyong.min <jiyong.min@samsung.com>
Fri, 29 May 2020 03:19:33 +0000 (12:19 +0900)
Change-Id: I4b41dcf9f1ff610edeef907884e1495687d15467

magick/mm_util_magick.c

index 0682259..44babdb 100644 (file)
@@ -409,7 +409,7 @@ static int __mm_util_make_tmp_file(mm_util_img_codec_type type, char **path)
        const char *template = NULL;
        GError *error = NULL;
 
-       /* GraphicsMagick determine image codec from filename suffix */
+       /* GraphicsMagick determine image codec from file extension */
        switch(type) {
        case IMG_CODEC_GIF:
                template = "XXXXXX.gif";
@@ -1093,8 +1093,7 @@ int mm_util_encode_image_to_file(mm_util_image_h decoded_image, const char *path
        char *extension = NULL;
        char *map = NULL;
        Image *_image = NULL;
-       mm_image_info_s *convert_image = NULL;
-       mm_util_color_format_e format;
+       mm_util_image_h converted_image = NULL, source = NULL;
 
        mm_util_retvm_if(!decoded_image, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid decoded_image");
        mm_util_retvm_if(!MMUTIL_STRING_VALID(path), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid path");
@@ -1115,7 +1114,7 @@ int mm_util_encode_image_to_file(mm_util_image_h decoded_image, const char *path
                */
 
                if (((mm_image_info_s *)decoded_image)->color == MM_UTIL_COLOR_RGBA) {
-                       ret = mm_util_convert_B_B(decoded_image, MM_UTIL_COLOR_RGB24, (mm_util_image_h *)&convert_image);
+                       ret = mm_util_convert_B_B(decoded_image, MM_UTIL_COLOR_RGB24, &converted_image);
                        if (ret != MM_UTIL_ERROR_NONE) {
                                mm_util_error("Error: mm_util_convert_B_B failed.");
                                goto ERROR;
@@ -1123,8 +1122,9 @@ int mm_util_encode_image_to_file(mm_util_image_h decoded_image, const char *path
                }
        }
 
-       format = (convert_image) ? (convert_image->color) : (((mm_image_info_s *)decoded_image)->color);
-       ret = __mm_util_get_map(format, &map);
+       source = (converted_image) ? converted_image : decoded_image;
+
+       ret = __mm_util_get_map(((mm_image_info_s *)source)->color, &map);
        if (ret != MM_UTIL_ERROR_NONE) {
                mm_util_error("fail to get map");
                goto ERROR;
@@ -1132,7 +1132,7 @@ int mm_util_encode_image_to_file(mm_util_image_h decoded_image, const char *path
 
        __mm_util_init(NULL);
 
-       _image = __mm_util_constitute_image((convert_image ? convert_image : decoded_image), map);
+       _image = __mm_util_constitute_image(source, map);
        if (_image == NULL) {
                mm_util_error("Error: __mm_util_constitute_image failed.");
                ret = MM_UTIL_ERROR_INVALID_OPERATION;
@@ -1146,7 +1146,7 @@ ERROR:
        __mm_util_finalize(_image, NULL, NULL);
 
        g_free(map);
-       mm_image_destroy_image((mm_util_image_h)convert_image);
+       mm_image_destroy_image(converted_image);
 
        mm_util_fleave();