Add to typecast 'image_util_type_e' to 'mm_util_img_codec_e' 22/274522/4 accepted/tizen/unified/20220505.134651 submit/tizen/20220503.010702
authorjiyong.min <jiyong.min@samsung.com>
Sun, 1 May 2022 23:53:09 +0000 (08:53 +0900)
committerjiyong.min <jiyong.min@samsung.com>
Mon, 2 May 2022 04:07:18 +0000 (13:07 +0900)
 - bug fix. UTC fail due to not supported format

Change-Id: I2bc7cf3c06bb2b42c5599dac908a0d6ec847c5a8

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

index 82cd290..a060711 100644 (file)
@@ -77,20 +77,20 @@ extern "C"
        } while (0)
 
 
-#define IMAGE_UTIL_STRING_VALID(str)   \
+#define IMAGE_UTIL_STRING_VALID(str) \
        ((str != NULL && strlen(str) > 0) ? true : false)
 
-#define IMAGE_UTIL_SAFE_G_FREE(src)    { if (src) {g_free(src); src = NULL; } }
+#define IMAGE_UTIL_SAFE_G_FREE(src) { if (src) {g_free(src); src = NULL; } }
+#define _NOT_SUPPORTED_COLORSPACE   (-1)
 
-#define _NOT_SUPPORTED_COLORSPACE      (-1)
+#define IMGCV_FUNC_NAME             "mm_util_cv_extract_representative_color"
+#define PATH_MMUTIL_IMGCV_LIB       PATH_LIBDIR"/libmmutil_imgcv.so"
 
-#define IMGCV_FUNC_NAME "mm_util_cv_extract_representative_color"
-#define PATH_MMUTIL_IMGCV_LIB PATH_LIBDIR"/libmmutil_imgcv.so"
+#define TYPECAST_COLOR(c)            _convert_type_of_colorspace(c)
+#define TYPECAST_COLOR_BY_TYPE(c, t) _convert_type_of_colorspace_with_image_type(c, t)
+#define TYPECAST_IMAGE_CODEC(t)      _convert_image_codec(t)
 
-#define TYPECAST_COLOR(c)                      _convert_type_of_colorspace(c)
-#define TYPECAST_COLOR_BY_TYPE(c, t)   _convert_type_of_colorspace_with_image_type(c, t)
-
-#define NUM_OF_COLORSPACE      _get_number_of_colorspace()
+#define NUM_OF_COLORSPACE            _get_number_of_colorspace()
 
 typedef struct {
        /* for converting colorspace */
@@ -127,6 +127,7 @@ gboolean _is_supported_colorspace(image_util_colorspace_e colorspace, image_util
 unsigned int _get_number_of_colorspace(void);
 int _convert_type_of_colorspace(const image_util_colorspace_e colorspace);
 int _convert_type_of_colorspace_with_image_type(const image_util_colorspace_e colorspace, const image_util_type_e type);
+int _convert_image_codec(image_util_type_e type);
 
 int _check_encode_path(const char *path);
 int _image_error_capi(int error_code);
index 436ba51..5440c54 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-image-util
 Summary:    A Image Utility library in Tizen Native API
-Version:    0.4.0
+Version:    0.4.1
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 3eaaec2..ec17918 100644 (file)
@@ -135,7 +135,7 @@ int image_util_encode_create(image_util_type_e image_type, image_util_encode_h *
                return _image_error_capi(err);
        }
 
-       err = mm_util_enc_opt_set_codec(_handle->enc_opt, image_type);
+       err = mm_util_enc_opt_set_codec(_handle->enc_opt, TYPECAST_IMAGE_CODEC(image_type));
        if (err != MM_UTIL_ERROR_NONE) {
                image_util_error("Error - mm_util_enc_opt_set_codec is failed (%d)", err);
                image_util_encode_destroy(_handle);
index 1758f52..8890937 100644 (file)
@@ -239,8 +239,6 @@ int _convert_type_of_colorspace(const image_util_colorspace_e colorspace)
 
 int _convert_type_of_colorspace_with_image_type(const image_util_colorspace_e colorspace, const image_util_type_e type)
 {
-       int new_colorspace = _NOT_SUPPORTED_COLORSPACE;
-
        if (!_is_valid_colorspace(colorspace))
                return _NOT_SUPPORTED_COLORSPACE;
 
@@ -249,31 +247,48 @@ int _convert_type_of_colorspace_with_image_type(const image_util_colorspace_e co
 
        switch (type) {
        case IMAGE_UTIL_JPEG:
-               new_colorspace = _convert_jpeg_colorspace_tbl[colorspace];
-               break;
+               return _convert_jpeg_colorspace_tbl[colorspace];
        case IMAGE_UTIL_PNG:
-               new_colorspace = _convert_png_colorspace_tbl[colorspace];
-               break;
+               return _convert_png_colorspace_tbl[colorspace];
        case IMAGE_UTIL_GIF:
-               new_colorspace = _convert_gif_colorspace_tbl[colorspace];
-               break;
+               return _convert_gif_colorspace_tbl[colorspace];
        case IMAGE_UTIL_BMP:
-               new_colorspace = _convert_bmp_colorspace_tbl[colorspace];
-               break;
+               return _convert_bmp_colorspace_tbl[colorspace];
        case IMAGE_UTIL_WEBP:
-               new_colorspace = _convert_webp_colorspace_tbl[colorspace];
-               break;
+               return _convert_webp_colorspace_tbl[colorspace];
        case IMAGE_UTIL_HEIF:
-               new_colorspace = _convert_heif_colorspace_tbl[colorspace];
-               break;
+               return _convert_heif_colorspace_tbl[colorspace];
        case IMAGE_UTIL_JPEG_XL:
-               new_colorspace = _convert_jxl_colorspace_tbl[colorspace];
-               break;
+               return _convert_jxl_colorspace_tbl[colorspace];
        default:
                image_util_error("Invalid image type");
        }
 
-       return new_colorspace;
+       return _NOT_SUPPORTED_COLORSPACE;
+}
+
+int _convert_image_codec(image_util_type_e type)
+{
+       switch (type) {
+       case IMAGE_UTIL_JPEG:
+               return IMG_CODEC_JPEG;
+       case IMAGE_UTIL_PNG:
+               return IMG_CODEC_PNG;
+       case IMAGE_UTIL_GIF:
+               return IMG_CODEC_GIF;
+       case IMAGE_UTIL_BMP:
+               return IMG_CODEC_BMP;
+       case IMAGE_UTIL_WEBP:
+               return IMG_CODEC_WEBP;
+       case IMAGE_UTIL_HEIF:
+               return IMG_CODEC_HEIF;
+       case IMAGE_UTIL_JPEG_XL:
+               return IMG_CODEC_JPEGXL;
+       default:
+               image_util_error("Invalid image type %u", type);
+       }
+
+       return IMG_CODEC_UNKNOWN_TYPE;
 }
 
 int _check_encode_path(const char *path)