2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef __TIZEN_MULTIMEDIA_IMAGE_UTIL_PRIVATE_H__
18 #define __TIZEN_MULTIMEDIA_IMAGE_UTIL_PRIVATE_H__
20 #include <image_util_type.h>
24 #include <mm_util_imgp.h>
35 #define LOG_TAG "CAPI_MEDIA_IMAGE_UTIL"
37 #define FONT_COLOR_RESET "\033[0m"
38 #define FONT_COLOR_RED "\033[31m"
39 #define FONT_COLOR_YELLOW "\033[33m"
41 #define image_util_debug(fmt, arg...) do { \
42 LOGD(FONT_COLOR_RESET""fmt""FONT_COLOR_RESET, ##arg); \
45 #define image_util_error(fmt, arg...) do { \
46 LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \
49 #define image_util_warning(fmt, arg...) do { \
50 LOGW(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \
53 #define image_util_fenter() do { \
54 LOGD(FONT_COLOR_YELLOW"<ENTER>"FONT_COLOR_RESET); \
57 #define image_util_fleave() do { \
58 LOGD(FONT_COLOR_YELLOW"<LEAVE>"FONT_COLOR_RESET); \
61 #define image_util_retm_if(expr, fmt, arg...) do { \
63 LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \
68 #define image_util_retvm_if(expr, val, fmt, arg...) do { \
70 LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \
76 #define IMAGE_UTIL_STRING_VALID(str) \
77 ((str != NULL && strlen(str) > 0) ? true : false)
79 #define IMAGE_UTIL_SAFE_FREE(src) { if (src) {free(src); src = NULL; } }
81 #define _NOT_SUPPORTED_COLORSPACE (-1)
86 #define DECODE_ENCODE_CAST(obj) ((decode_encode_s *)(obj))
87 #define IS_DECODE_MODE(x) (x == MODE_DECODE)
88 #define IS_ENCODE_MODE(x) (x == MODE_ENCODE)
90 #define IMGCV_FUNC_NAME "mm_util_cv_extract_representative_color"
91 #define PATH_MMUTIL_IMGCV_LIB PATH_LIBDIR"/libmmutil_imgcv.so"
93 #define TYPECAST_COLOR(c) convert_type_of_colorspace(c)
94 #define TYPECAST_COLOR_BY_TYPE(c, t) convert_type_of_colorspace_with_image_type(c, t)
96 #define NUM_OF_COLORSPACE get_number_of_colorspace()
98 typedef gboolean(*ModuleFunc)(void *, int, int, unsigned char *, unsigned char *, unsigned char *);
102 image_util_transform_completed_cb completed_cb;
106 mm_image_info_s *src;
107 mm_image_info_s *dst;
109 /* for converting colorspace */
110 mm_util_color_format_e dst_format;
113 unsigned int start_x;
114 unsigned int start_y;
115 unsigned int dst_width;
116 unsigned int dst_height;
119 mm_util_img_rotate_type rotation;
126 /* for multi instance */
127 image_util_cb_s *_util_cb;
135 image_util_decode_completed_cb image_decode_completed_cb;
140 image_util_encode_completed_cb image_encode_completed_cb;
144 image_util_type_e image_type;
149 size_t gif_encode_size;
153 unsigned long height;
156 image_util_png_compression_e compression;
157 unsigned int current_buffer_count;
158 unsigned int current_resolution_count;
159 unsigned int current_delay_count;
160 image_util_colorspace_e colorspace;
161 image_util_scale_e down_scale;
162 decode_cb_s *_decode_cb;
163 encode_cb_s *_encode_cb;
178 } image_util_error_type_e;
180 #define IMAGE_UTIL_TYPE_CHECK(type) \
181 image_util_retvm_if((type < IMAGE_UTIL_JPEG || type > IMAGE_UTIL_BMP), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter")
183 #define IMAGE_UTIL_SUPPORT_TYPE_CHECK(value, support) \
184 image_util_retvm_if((value != support), IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "Not supported format")
186 #define IMAGE_UTIL_DECODE_HANDLE_CHECK(obj) do { \
187 image_util_retvm_if(obj == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid decode handle"); \
188 image_util_retvm_if(!IS_DECODE_MODE(DECODE_ENCODE_CAST(obj)->mode), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid decode handle"); \
191 #define IMAGE_UTIL_ENCODE_HANDLE_CHECK(obj) do { \
192 image_util_retvm_if(obj == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid encode handle"); \
193 image_util_retvm_if(!IS_ENCODE_MODE(DECODE_ENCODE_CAST(obj)->mode), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid encode handle"); \
196 gboolean is_valid_colorspace(image_util_colorspace_e colorspace);
197 gboolean is_supported_colorspace(image_util_colorspace_e colorspace, image_util_type_e type);
199 unsigned int get_number_of_colorspace(void);
200 int convert_type_of_colorspace(const image_util_colorspace_e colorspace);
201 int convert_type_of_colorspace_with_image_type(const image_util_colorspace_e colorspace, const image_util_type_e type);
202 int _image_error_capi(image_util_error_type_e error_type, int error_code);
203 bool _image_util_check_resolution(int width, int height);
213 #endif /* __TIZEN_MULTIMEDIA_IMAGE_UTIL_PRIVATE_H__ */