From: jiyong.min Date: Sun, 1 May 2022 23:53:09 +0000 (+0900) Subject: Add to typecast 'image_util_type_e' to 'mm_util_img_codec_e' X-Git-Tag: submit/tizen/20220503.010702^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f526de8d7f09bc7fe2c58070f9c0cacece5cbec3;p=platform%2Fcore%2Fapi%2Fimage-util.git Add to typecast 'image_util_type_e' to 'mm_util_img_codec_e' - bug fix. UTC fail due to not supported format Change-Id: I2bc7cf3c06bb2b42c5599dac908a0d6ec847c5a8 --- diff --git a/include/image_util_private.h b/include/image_util_private.h index 82cd290..a060711 100644 --- a/include/image_util_private.h +++ b/include/image_util_private.h @@ -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); diff --git a/packaging/capi-media-image-util.spec b/packaging/capi-media-image-util.spec index 436ba51..5440c54 100644 --- a/packaging/capi-media-image-util.spec +++ b/packaging/capi-media-image-util.spec @@ -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 diff --git a/src/image_util_encode.c b/src/image_util_encode.c index 3eaaec2..ec17918 100644 --- a/src/image_util_encode.c +++ b/src/image_util_encode.c @@ -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); diff --git a/src/image_util_private.c b/src/image_util_private.c index 1758f52..8890937 100644 --- a/src/image_util_private.c +++ b/src/image_util_private.c @@ -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)