PATTERN "${INC_DIR}/*.h"
)
+ADD_SUBDIRECTORY(common)
ADD_SUBDIRECTORY(bmp)
ADD_SUBDIRECTORY(gif)
ADD_SUBDIRECTORY(imgcv)
This part describes the APIs with repect to multimedia image library.
*/
-/**
- * format for bmp
- */
-typedef enum {
- MM_UTIL_BMP_FMT_RGBA8888, /**< RGBA8888 format */
-} mm_util_bmp_format;
-
typedef struct {
unsigned long width; /**< width */
unsigned long height; /**< height */
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+SET(fw_name "mmutil_common")
+
+PROJECT(${fw_name})
+
+SET(VERSION_MAJOR 0)
+SET(VERSION "${VERSION_MAJOR}.0.0")
+SET(CMAKE_INSTALL_PREFIX /usr)
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+
+SET(INC_DIR
+ include
+ )
+INCLUDE_DIRECTORIES(${INC_DIR})
+
+SET(dependents "dlog glib-2.0")
+SET(pc_dependents "dlog capi-base-common")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${fw_name} REQUIRED ${dependents})
+FOREACH(flag ${${fw_name}_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+
+IF("${ARCH}" STREQUAL "arm")
+ ADD_DEFINITIONS("-DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DLIBPREFIX=\"${LIB_INSTALL_DIR}\"")
+ADD_DEFINITIONS("-DTIZEN_DEBUG")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}")
+
+aux_source_directory(. SOURCES)
+ADD_LIBRARY(${fw_name} SHARED ${SOURCES})
+TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS})
+SET_TARGET_PROPERTIES(${fw_name}
+ PROPERTIES
+ VERSION ${VERSION}
+ SOVERSION ${VERSION_MAJOR}
+ CLEAN_DIRECT_OUTPUT 1
+)
+
+SET(BUILD_CHECK "true")
+IF("${BUILD_CHECK}" STREQUAL "true")
+INSTALL(TARGETS ${fw_name} DESTINATION ${LIB_INSTALL_DIR})
+INSTALL(
+ DIRECTORY ${INC_DIR}/ DESTINATION include/mmf
+ FILES_MATCHING
+ PATTERN "*_internal.h" EXCLUDE
+ PATTERN "*_private.h" EXCLUDE
+ PATTERN "${INC_DIR}/*.h"
+ )
+
+SET(PC_NAME mmutil-common)
+SET(PC_REQUIRED ${pc_dependents})
+SET(PC_LDFLAGS -l${fw_name})
+SET(PC_FILE_NAME ${PC_NAME}.pc.in)
+
+CONFIGURE_FILE(
+ ${PC_FILE_NAME}
+ ${CMAKE_CURRENT_SOURCE_DIR}/${PC_NAME}.pc
+ @ONLY
+)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PC_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+
+#ADD_SUBDIRECTORY(test)
+ENDIF("${BUILD_CHECK}" STREQUAL "true")
--- /dev/null
+/*
+ * libmm-utility
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: YoungHun Kim <yh8004.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __MM_UTIL_COLOR_IMAGE_H__
+#define __MM_UTIL_COLOR_IMAGE_H__
+
+#include "mm_util_type.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define IS_MM_UTIL_COLOR_FORMAT(color) mm_util_is_valid_color_format(color)
+
+gboolean mm_util_is_valid_color_format(mm_util_color_format_e color);
+
+/**
+ *
+ * @remark Creates the handle of empty color image
+ *
+ * @param image [in/out] The handle of the color image
+ * @return This function returns created color image handle
+ * if the result is 0, then handle creation succeed
+ * else if the result is -1, then handle creation failed
+ */
+int mm_util_create_empty_color_image(mm_util_color_image_h *image);
+
+/**
+ *
+ * @remark Creates the handle of color image with data
+ *
+ * @param image [in/out] The handle of the color image
+ * @param width [in] The width of color image
+ * @param height [in] The height of color image
+ * @param color [in] The color format of color image
+ * @param data [in] The data of color image
+ * @param size [in] The data-size of color image
+ * @return This function returns created color image handle
+ * if the result is 0, then handle creation succeed
+ * else if the result is -1, then handle creation failed
+ */
+int mm_util_create_color_image(mm_util_color_image_h *image, unsigned long width, unsigned long height, mm_util_color_format_e color, void *data, size_t size);
+
+/**
+ *
+ * @remark Sets the data of color image to handle
+ *
+ * @param image [in] The handle of the color image
+ * @param width [in] The width of color image
+ * @param height [in] The height of color image
+ * @param color [in] The color format of color image
+ * @param data [in] The data of color image
+ * @param size [in] The data-size of color image
+ * @return This function returns the result of setting the data in handle
+ * if the result is 0, then setting the data has succeed
+ * else if the result is -1, then setting the data has failed
+ */
+int mm_util_set_color_image(mm_util_color_image_h image, unsigned long width, unsigned long height, mm_util_color_format_e color, void *data, size_t size);
+
+/**
+ *
+ * @remark Gets the data of color image from handle
+ *
+ * @param image [in] The handle of the color image
+ * @param width [in/out] The width of color image
+ * @param height [in/out] The height of color image
+ * @param color [in/out] The color format of color image
+ * @param data [in/out] The data of color image
+ * @param size [in/out] The data-size of color image
+ * @return This function returns the result of getting the data from handle
+ * if the result is 0, then getting the data has succeed
+ * else if the result is -1, then getting the data has failed
+ */
+int mm_util_get_color_image(mm_util_color_image_h image, unsigned long *width, unsigned long *height, mm_util_color_format_e *color, void **data, size_t *size);
+
+/**
+ *
+ * @remark Destroys the handle of color image
+ *
+ * @param image [in] The handle of the color image
+ */
+void mm_util_destroy_color_image(mm_util_color_image_h image);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*__MM_UTIL_COLOR_IMAGE_H__*/
--- /dev/null
+/*
+ * libmm-utility
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: YoungHun Kim <yh8004.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __MM_UTIL_COMMON_H__
+#define __MM_UTIL_COMMON_H__
+
+#include "mm_util_color_image.h"
+
+
+#endif /*__MM_UTIL_COMMON_H__*/
#define MMUTIL_SAFE_STRCPY(dst, src, n) g_strlcpy(dst, src, n)
#define MMUTIL_STRING_VALID(str) ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
+typedef struct {
+ unsigned long width;
+ unsigned long height;
+ mm_util_color_format_e color;
+ void *data;
+ size_t size;
+} color_image_data_s;
+
#ifdef __cplusplus
}
#endif
MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT = -5, /**< Not supported format */
} mm_util_error_e;
+/**
+ * color formats
+ */
+typedef enum {
+ /* YUV planar format */
+ MM_UTIL_COLOR_YUV420, /**< YUV420 format - planer YV12*/
+ MM_UTIL_COLOR_YUV422, /**< YUV422 format - planer */
+ MM_UTIL_COLOR_I420, /**< YUV420 format - planar */
+ MM_UTIL_COLOR_NV12, /**< NV12 format - planer */
+
+ /* YUV packed format */
+ MM_UTIL_COLOR_UYVY, /**< UYVY format - YUV packed format */
+ MM_UTIL_COLOR_YUYV, /**< YUYV format - YUV packed format */
+
+ /* RGB color */
+ MM_UTIL_COLOR_RGB16, /**< RGB565 pixel format */
+ MM_UTIL_COLOR_RGB24, /**< RGB888 pixel format */
+ MM_UTIL_COLOR_ARGB, /**< ARGB8888 pixel format */
+
+ MM_UTIL_COLOR_BGRA, /**< BGRA8888 pixel format */
+ MM_UTIL_COLOR_RGBA, /**< RGBA8888 pixel format */
+ MM_UTIL_COLOR_BGRX, /**< BGRX8888 pixel format */
+
+ /* non-standard format */
+ MM_UTIL_COLOR_NV12_TILED, /**< Customized color format in s5pc110 */
+ MM_UTIL_COLOR_NV16, /**< NV16 pixel format */
+ MM_UTIL_COLOR_NV61, /**< NV61 pixel format */
+ MM_UTIL_COLOR_NV21, /**< NV21 format - planer */
+
+ /* GrayScale */
+ MM_UTIL_COLOR_GRAYSCALE, /**< Grayscale pixel format */
+ MM_UTIL_COLOR_NUM, /**< Number of image formats */
+} mm_util_color_format_e;
+
+typedef void *mm_util_color_image_h;
+
#ifdef __cplusplus
}
#endif
--- /dev/null
+/*
+ * libmm-utility
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: YoungHun Kim <yh8004.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "mm_util_private.h"
+#include "mm_util_color_image.h"
+
+gboolean mm_util_is_valid_color_format(mm_util_color_format_e color)
+{
+ if ((color < MM_UTIL_COLOR_YUV420) || (color >= MM_UTIL_COLOR_NUM)) {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+int mm_util_create_empty_color_image(mm_util_color_image_h *image)
+{
+ int ret = MM_UTIL_ERROR_NONE;
+ color_image_data_s *_color_image = NULL;
+
+ mm_util_retvm_if((image == NULL), MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid handle");
+
+ _color_image = (color_image_data_s *)calloc(1, sizeof(color_image_data_s));
+ mm_util_retvm_if((_color_image == NULL), MM_UTIL_ERROR_OUT_OF_MEMORY, "Memory allocation failed");
+
+ *image = (mm_util_color_image_h)_color_image;
+
+ return ret;
+}
+
+int mm_util_create_color_image(mm_util_color_image_h *image, unsigned long width, unsigned long height, mm_util_color_format_e color, void *data, size_t size)
+{
+ int ret = MM_UTIL_ERROR_NONE;
+ color_image_data_s *_color_image = NULL;
+
+ mm_util_retvm_if((image == NULL), MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid handle");
+
+ _color_image = (color_image_data_s *)calloc(1, sizeof(color_image_data_s));
+ mm_util_retvm_if((_color_image == NULL), MM_UTIL_ERROR_OUT_OF_MEMORY, "Memory allocation failed");
+
+ ret = mm_util_set_color_image(_color_image, width, height, color, data, size);
+ if (ret != MM_UTIL_ERROR_NONE) {
+ mm_util_error("mm_util_set_color_image failed(%d)", ret);
+ mm_util_destroy_color_image(_color_image);
+ *image = NULL;
+ return ret;
+ }
+
+ *image = (mm_util_color_image_h)_color_image;
+
+ return ret;
+}
+
+int mm_util_set_color_image(mm_util_color_image_h image, unsigned long width, unsigned long height, mm_util_color_format_e color, void *data, size_t size)
+{
+ int ret = MM_UTIL_ERROR_NONE;
+ color_image_data_s *_color_image = (color_image_data_s *)image;
+
+ mm_util_retvm_if((_color_image == NULL), MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid handle");
+ mm_util_retvm_if((color >= MM_UTIL_COLOR_NUM), MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid color");
+ mm_util_retvm_if((data == NULL || size == 0), MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid data");
+
+ _color_image->data = calloc(1, size);
+ mm_util_retvm_if((_color_image->data == NULL), MM_UTIL_ERROR_OUT_OF_MEMORY, "Memory allocation failed");
+
+ memcpy(_color_image->data, data, size);
+ _color_image->size = size;
+ _color_image->width = width;
+ _color_image->height = height;
+ _color_image->color = color;
+
+ mm_util_sec_debug("w: %lu, h: %lu, color: %u, size: %zu, data: %p", _color_image->width, _color_image->height,
+ _color_image->color, _color_image->size, _color_image->data);
+
+ return ret;
+}
+
+int mm_util_get_color_image(mm_util_color_image_h image, unsigned long *width, unsigned long *height, mm_util_color_format_e *color, void **data, size_t *size)
+{
+ int ret = MM_UTIL_ERROR_NONE;
+ color_image_data_s *_color_image = (color_image_data_s *)image;
+
+ mm_util_retvm_if((_color_image == NULL), MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid handle");
+
+ if (width != NULL)
+ *width = _color_image->width;
+
+ if (height != NULL)
+ *height = _color_image->height;
+
+ if (color != NULL)
+ *color = _color_image->color;
+
+ if (data != NULL)
+ *data = _color_image->data;
+
+ if (size != NULL)
+ *size = _color_image->size;
+
+ return ret;
+}
+
+
+void mm_util_destroy_color_image(mm_util_color_image_h image)
+{
+ color_image_data_s *_color_image = (color_image_data_s *)image;
+
+ if (_color_image == NULL) {
+ mm_util_error("[ERROR] - image");
+ return;
+ }
+
+ MMUTIL_SAFE_FREE(_color_image->data);
+ MMUTIL_SAFE_FREE(_color_image);
+}
--- /dev/null
+prefix=@PREFIX@
+exec_prefix=/usr
+libdir=@LIB_INSTALL_DIR@
+includedir=/usr/include/mmf
+
+Name : @PC_NAME@
+Description : Multimedia Framework Utility Library
+Requires : @PC_REQUIRED@
+Version : @VERSION@
+Libs : -L${libdir} @PC_LDFLAGS@
+Cflags : -I${includedir} -DLIBPREFIX=\"${libdir}\"
mm_util_jpeg_yuv_data decoded;
memset(&decoded, 0, sizeof(mm_util_jpeg_yuv_data));
- ret = mm_util_decode_from_jpeg_file(&decoded, filename, MM_UTIL_JPEG_FMT_RGB888);
+ ret = mm_util_decode_from_jpeg_file(&decoded, filename, MM_UTIL_COLOR_RGB24);
if (!ret) {
img_buffer = decoded.data;
aux_source_directory(. SOURCES)
ADD_LIBRARY(${fw_name} SHARED ${SOURCES})
-TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS})
+TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS} mmutil_common)
SET_TARGET_PROPERTIES(${fw_name}
PROPERTIES
VERSION ${VERSION}
#include "mm_util_type.h"
typedef void *mm_util_imgp_h;
-typedef void *mm_util_color_image_h;
typedef bool (*mm_util_completed_callback)(mm_util_color_image_h image, int error, void *user_param);
/**
*/
/**
- * Image formats
- */
-typedef enum {
- /* YUV planar format */
- MM_UTIL_IMG_FMT_YUV420 = 0x00, /**< YUV420 format - planer YV12*/
- MM_UTIL_IMG_FMT_YUV422, /**< YUV422 format - planer */
- MM_UTIL_IMG_FMT_I420, /**< YUV420 format - planar */
- MM_UTIL_IMG_FMT_NV12, /**< NV12 format - planer */
-
- /* YUV packed format */
- MM_UTIL_IMG_FMT_UYVY, /**< UYVY format - YUV packed format */
- MM_UTIL_IMG_FMT_YUYV, /**< YUYV format - YUV packed format */
-
- /* RGB color */
- MM_UTIL_IMG_FMT_RGB565, /**< RGB565 pixel format */
- MM_UTIL_IMG_FMT_RGB888, /**< RGB888 pixel format */
- MM_UTIL_IMG_FMT_ARGB8888, /**< ARGB8888 pixel format */
-
- MM_UTIL_IMG_FMT_BGRA8888, /**< BGRA8888 pixel format */
- MM_UTIL_IMG_FMT_RGBA8888, /**< RGBA8888 pixel format */
- MM_UTIL_IMG_FMT_BGRX8888, /**<BGRX8888 pixel format */
- /* non-standard format */
- MM_UTIL_IMG_FMT_NV12_TILED, /**< Customized color format in s5pc110 */
- MM_UTIL_IMG_FMT_NV16, /**<NV16 pixel format */
- MM_UTIL_IMG_FMT_NV61, /**<NV61 pixel format */
- MM_UTIL_IMG_FMT_NUM, /**< Number of image formats */
-} mm_util_img_format;
-
-
-/**
* Image rotation types
*/
typedef enum {
*
* @return This function returns zero on success, or negative value with error code.
* @remark
- * @see mm_util_img_format
+ * @see mm_util_color_format_e
* @since R1, 1.0
*/
-int mm_util_get_image_size(mm_util_img_format format, unsigned int width, unsigned int height, unsigned int *size);
+int mm_util_get_image_size(mm_util_color_format_e format, unsigned int width, unsigned int height, unsigned int *size);
/**
*
* if the result is 0, then handle creation succeed
* else if the result is -1, then handle creation failed
*/
-int mm_util_set_colorspace_convert(mm_util_imgp_h imgp_handle, mm_util_img_format colorspace);
+int mm_util_set_colorspace_convert(mm_util_imgp_h imgp_handle, mm_util_color_format_e colorspace);
/**
*
/**
*
- * @remark Creates the handle of color image
- *
- * @param image [in/out] The handle of the color image
- * @return This function returns created color image handle
- * if the result is 0, then handle creation succeed
- * else if the result is -1, then handle creation failed
- */
-int mm_util_create_color_image(mm_util_color_image_h *image);
-
-/**
- *
- * @remark Sets the data of color image to handle
- *
- * @param image [in] The handle of the color image
- * @param width [in] The width of color image
- * @param height [in] The height of color image
- * @param format [in] The color format of color image
- * @param buffer [in] The data of color image
- * @param buffer_size [in] The data-size of color image
- * @return This function returns the result of setting the data in handle
- * if the result is 0, then setting the data has succeed
- * else if the result is -1, then setting the data has failed
- */
-int mm_util_set_color_image(mm_util_color_image_h image, int width, int height, mm_util_img_format format, void *buffer, size_t buffer_size);
-
-/**
- *
- * @remark Gets the data of color image from handle
- *
- * @param image [in] The handle of the color image
- * @param width [in/out] The width of color image
- * @param height [in/out] The height of color image
- * @param format [in/out] The color format of color image
- * @param buffer [in/out] The data of color image
- * @param buffer_size [in/out] The data-size of color image
- * @return This function returns the result of getting the data from handle
- * if the result is 0, then getting the data has succeed
- * else if the result is -1, then getting the data has failed
- */
-int mm_util_get_color_image(mm_util_color_image_h image, int *width, int *height, mm_util_img_format *format, void **buffer, size_t *buffer_size);
-
-/**
- *
- * @remark Destroys the handle of color image
- *
- * @param image [in] The handle of the color image
- */
-void mm_util_destroy_color_image(mm_util_color_image_h image);
-
-/**
- *
* @remark Image Transform Pipeline
*
* @param imgp_handle [in] image_util_imgp_h
*
* @return This function returns zero on success, or negative value with error code.
* @remark
- * @see mm_util_img_format
+ * @see mm_util_color_format_e
* @since R1, 1.0
*/
-int mm_util_convert_colorspace(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format, unsigned char *dst, mm_util_img_format dst_format);
+int mm_util_convert_colorspace(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_color_format_e src_format, unsigned char *dst, mm_util_color_format_e dst_format);
/**
* This function resizes the source image.
*
* @return This function returns zero on success, or negative value with error code.
* @remark
- * @see mm_util_img_format
+ * @see mm_util_color_format_e
* @since R1, 1.0
*/
-int mm_util_resize_image(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format, unsigned char *dst, unsigned int *dst_width, unsigned int *dst_height);
+int mm_util_resize_image(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_color_format_e src_format, unsigned char *dst, unsigned int *dst_width, unsigned int *dst_height);
/**
* This function rotates the source image.
*
* @return This function returns zero on success, or negative value with error code.
* @remark
- * @see mm_util_img_format, mm_util_img_rotate_type
+ * @see mm_util_color_format_e, mm_util_img_rotate_type
* @since R1, 1.0
*/
-int mm_util_rotate_image(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format, unsigned char *dst, unsigned int *dst_width, unsigned int *dst_height, mm_util_img_rotate_type angle);
+int mm_util_rotate_image(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_color_format_e src_format, unsigned char *dst, unsigned int *dst_width, unsigned int *dst_height, mm_util_img_rotate_type angle);
/**
* This function crop the source image.
*
* @return This function returns zero on success, or negative value with error code.
* @remark
- * @see mm_util_img_format, mm_util_img_rotate_type
+ * @see mm_util_color_format_e, mm_util_img_rotate_type
* @since R1, 1.0
*/
-int mm_util_crop_image(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format,
+int mm_util_crop_image(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_color_format_e src_format,
unsigned int crop_start_x, unsigned int crop_start_y, unsigned int *crop_dest_width, unsigned int *crop_dest_height, unsigned char *dst);
#ifdef __cplusplus
*/
typedef struct _imgp_info_s {
char *input_format_label;
- mm_util_img_format src_format;
+ mm_util_color_format_e src_format;
unsigned int src_width;
unsigned int src_height;
char *output_format_label;
- mm_util_img_format dst_format;
+ mm_util_color_format_e dst_format;
unsigned int dst_width;
unsigned int dst_height;
unsigned int output_stride;
} mm_util_cb_s;
typedef struct {
- int width;
- int height;
- mm_util_img_format format;
- void *buffer;
- size_t buffer_size;
-} color_image_data_s;
-
-typedef struct {
color_image_data_s *src;
color_image_data_s *dst;
/* for converting colorspace */
- mm_util_img_format dst_format;
+ mm_util_color_format_e dst_format;
/* for image crop */
/* for resize */
unsigned int start_x;
#include "mm_util_private.h"
#include "mm_util_imgp.h"
#include "mm_util_imgp_internal.h"
+#include "mm_util_common.h"
#define MM_UTIL_ROUND_UP_2(num) (((num)+1)&~1)
#define MM_UTIL_ROUND_UP_4(num) (((num)+3)&~3)
MMUTIL_SAFE_FREE(buffer[i]);
}
-static gboolean __mm_cannot_convert_format(mm_util_img_format src_format, mm_util_img_format dst_format)
+static gboolean __mm_cannot_convert_format(mm_util_color_format_e src_format, mm_util_color_format_e dst_format)
{
gboolean _bool = FALSE;
mm_util_debug("src_format: %d, dst_format:%d", src_format, dst_format);
- if ((dst_format == MM_UTIL_IMG_FMT_NV16) || (dst_format == MM_UTIL_IMG_FMT_NV61) ||
- ((src_format == MM_UTIL_IMG_FMT_YUV422) && (dst_format == MM_UTIL_IMG_FMT_NV12_TILED)) ||
- ((src_format == MM_UTIL_IMG_FMT_NV12) && (dst_format == MM_UTIL_IMG_FMT_NV12_TILED)) ||
- ((src_format == MM_UTIL_IMG_FMT_UYVY) && (dst_format == MM_UTIL_IMG_FMT_NV12_TILED)) ||
- ((src_format == MM_UTIL_IMG_FMT_YUYV) && (dst_format == MM_UTIL_IMG_FMT_NV12_TILED)) ||
- ((src_format == MM_UTIL_IMG_FMT_RGB565) && (dst_format == MM_UTIL_IMG_FMT_NV12_TILED)) ||
- ((src_format == MM_UTIL_IMG_FMT_RGB888) && (dst_format == MM_UTIL_IMG_FMT_NV12_TILED)) ||
- ((src_format == MM_UTIL_IMG_FMT_BGRX8888) && (dst_format == MM_UTIL_IMG_FMT_NV12_TILED)) ||
- ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_YUV422)) ||
- ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_UYVY)) ||
- ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_YUYV)) ||
- ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_ARGB8888)) ||
- ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_RGBA8888)) ||
- ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_BGRX8888))) {
+ if ((dst_format == MM_UTIL_COLOR_NV16) || (dst_format == MM_UTIL_COLOR_NV61) ||
+ ((src_format == MM_UTIL_COLOR_YUV422) && (dst_format == MM_UTIL_COLOR_NV12_TILED)) ||
+ ((src_format == MM_UTIL_COLOR_NV12) && (dst_format == MM_UTIL_COLOR_NV12_TILED)) ||
+ ((src_format == MM_UTIL_COLOR_UYVY) && (dst_format == MM_UTIL_COLOR_NV12_TILED)) ||
+ ((src_format == MM_UTIL_COLOR_YUYV) && (dst_format == MM_UTIL_COLOR_NV12_TILED)) ||
+ ((src_format == MM_UTIL_COLOR_RGB16) && (dst_format == MM_UTIL_COLOR_NV12_TILED)) ||
+ ((src_format == MM_UTIL_COLOR_RGB24) && (dst_format == MM_UTIL_COLOR_NV12_TILED)) ||
+ ((src_format == MM_UTIL_COLOR_BGRX) && (dst_format == MM_UTIL_COLOR_NV12_TILED)) ||
+ ((src_format == MM_UTIL_COLOR_NV12_TILED) && (dst_format == MM_UTIL_COLOR_YUV422)) ||
+ ((src_format == MM_UTIL_COLOR_NV12_TILED) && (dst_format == MM_UTIL_COLOR_UYVY)) ||
+ ((src_format == MM_UTIL_COLOR_NV12_TILED) && (dst_format == MM_UTIL_COLOR_YUYV)) ||
+ ((src_format == MM_UTIL_COLOR_NV12_TILED) && (dst_format == MM_UTIL_COLOR_ARGB)) ||
+ ((src_format == MM_UTIL_COLOR_NV12_TILED) && (dst_format == MM_UTIL_COLOR_RGBA)) ||
+ ((src_format == MM_UTIL_COLOR_NV12_TILED) && (dst_format == MM_UTIL_COLOR_BGRX))) {
_bool = TRUE;
}
return _bool;
}
-static gboolean __mm_select_convert_plugin(mm_util_img_format src_format, mm_util_img_format dst_format)
+static gboolean __mm_select_convert_plugin(mm_util_color_format_e src_format, mm_util_color_format_e dst_format)
{
gboolean _bool = FALSE;
mm_util_debug("src_format: %d, dst_format:%d", src_format, dst_format);
- if (((src_format == MM_UTIL_IMG_FMT_YUV420) && (dst_format == MM_UTIL_IMG_FMT_NV12)) ||
- ((src_format == MM_UTIL_IMG_FMT_YUV420) && (dst_format == MM_UTIL_IMG_FMT_RGB565)) ||
- ((src_format == MM_UTIL_IMG_FMT_YUV420) && (dst_format == MM_UTIL_IMG_FMT_RGB888)) ||
- ((src_format == MM_UTIL_IMG_FMT_YUV420) && (dst_format == MM_UTIL_IMG_FMT_ARGB8888)) ||
- ((src_format == MM_UTIL_IMG_FMT_YUV420) && (dst_format == MM_UTIL_IMG_FMT_BGRA8888)) ||
- ((src_format == MM_UTIL_IMG_FMT_YUV420) && (dst_format == MM_UTIL_IMG_FMT_RGBA8888)) ||
- ((src_format == MM_UTIL_IMG_FMT_YUV420) && (dst_format == MM_UTIL_IMG_FMT_NV12_TILED)) ||
-
- ((src_format == MM_UTIL_IMG_FMT_I420) && (dst_format == MM_UTIL_IMG_FMT_NV12)) ||
- ((src_format == MM_UTIL_IMG_FMT_I420) && (dst_format == MM_UTIL_IMG_FMT_RGB565)) ||
- ((src_format == MM_UTIL_IMG_FMT_I420) && (dst_format == MM_UTIL_IMG_FMT_RGB888)) ||
- ((src_format == MM_UTIL_IMG_FMT_I420) && (dst_format == MM_UTIL_IMG_FMT_ARGB8888)) ||
- ((src_format == MM_UTIL_IMG_FMT_I420) && (dst_format == MM_UTIL_IMG_FMT_BGRA8888)) ||
- ((src_format == MM_UTIL_IMG_FMT_I420) && (dst_format == MM_UTIL_IMG_FMT_RGBA8888)) ||
- ((src_format == MM_UTIL_IMG_FMT_I420) && (dst_format == MM_UTIL_IMG_FMT_NV12_TILED)) ||
-
- ((src_format == MM_UTIL_IMG_FMT_NV12) && (dst_format == MM_UTIL_IMG_FMT_YUV420)) ||
- ((src_format == MM_UTIL_IMG_FMT_NV12) && (dst_format == MM_UTIL_IMG_FMT_I420)) ||
- ((src_format == MM_UTIL_IMG_FMT_NV12) && (dst_format == MM_UTIL_IMG_FMT_RGB565)) ||
- ((src_format == MM_UTIL_IMG_FMT_NV12) && (dst_format == MM_UTIL_IMG_FMT_RGB888)) ||
- ((src_format == MM_UTIL_IMG_FMT_NV12) && (dst_format == MM_UTIL_IMG_FMT_ARGB8888)) ||
- ((src_format == MM_UTIL_IMG_FMT_NV12) && (dst_format == MM_UTIL_IMG_FMT_BGRA8888)) ||
- ((src_format == MM_UTIL_IMG_FMT_NV12) && (dst_format == MM_UTIL_IMG_FMT_RGBA8888)) ||
-
- ((src_format == MM_UTIL_IMG_FMT_UYVY) && (dst_format == MM_UTIL_IMG_FMT_RGB565)) ||
- ((src_format == MM_UTIL_IMG_FMT_UYVY) && (dst_format == MM_UTIL_IMG_FMT_RGB888)) ||
-
- ((src_format == MM_UTIL_IMG_FMT_YUYV) && (dst_format == MM_UTIL_IMG_FMT_RGB565)) ||
- ((src_format == MM_UTIL_IMG_FMT_YUYV) && (dst_format == MM_UTIL_IMG_FMT_RGB888)) ||
- ((src_format == MM_UTIL_IMG_FMT_YUYV) && (dst_format == MM_UTIL_IMG_FMT_ARGB8888)) ||
- ((src_format == MM_UTIL_IMG_FMT_YUYV) && (dst_format == MM_UTIL_IMG_FMT_BGRA8888)) ||
- ((src_format == MM_UTIL_IMG_FMT_YUYV) && (dst_format == MM_UTIL_IMG_FMT_RGBA8888)) ||
-
- ((src_format == MM_UTIL_IMG_FMT_RGB565) && (dst_format == MM_UTIL_IMG_FMT_YUV420)) ||
- ((src_format == MM_UTIL_IMG_FMT_RGB565) && (dst_format == MM_UTIL_IMG_FMT_I420)) ||
- ((src_format == MM_UTIL_IMG_FMT_RGB565) && (dst_format == MM_UTIL_IMG_FMT_NV12)) ||
-
- ((src_format == MM_UTIL_IMG_FMT_RGB888) && (dst_format == MM_UTIL_IMG_FMT_YUV420)) ||
- ((src_format == MM_UTIL_IMG_FMT_RGB888) && (dst_format == MM_UTIL_IMG_FMT_I420)) ||
- ((src_format == MM_UTIL_IMG_FMT_RGB888) && (dst_format == MM_UTIL_IMG_FMT_NV12)) ||
-
- ((src_format == MM_UTIL_IMG_FMT_ARGB8888) && (dst_format == MM_UTIL_IMG_FMT_YUV420)) ||
- ((src_format == MM_UTIL_IMG_FMT_ARGB8888) && (dst_format == MM_UTIL_IMG_FMT_I420)) ||
- ((src_format == MM_UTIL_IMG_FMT_ARGB8888) && (dst_format == MM_UTIL_IMG_FMT_NV12)) ||
-
- ((src_format == MM_UTIL_IMG_FMT_BGRA8888) && (dst_format == MM_UTIL_IMG_FMT_YUV420)) ||
- ((src_format == MM_UTIL_IMG_FMT_BGRA8888) && (dst_format == MM_UTIL_IMG_FMT_I420)) ||
- ((src_format == MM_UTIL_IMG_FMT_BGRA8888) && (dst_format == MM_UTIL_IMG_FMT_NV12)) ||
- ((src_format == MM_UTIL_IMG_FMT_RGBA8888) && (dst_format == MM_UTIL_IMG_FMT_YUV420)) ||
- ((src_format == MM_UTIL_IMG_FMT_RGBA8888) && (dst_format == MM_UTIL_IMG_FMT_I420)) ||
- ((src_format == MM_UTIL_IMG_FMT_RGBA8888) && (dst_format == MM_UTIL_IMG_FMT_NV12)) ||
- ((src_format == MM_UTIL_IMG_FMT_RGBA8888) && (dst_format == MM_UTIL_IMG_FMT_RGB565)) ||
-
- ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_YUV420)) ||
- ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_I420)) ||
- ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_NV12)) ||
- ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_RGB565)) ||
- ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_RGB888)) ||
- ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_ARGB8888)) ||
- ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_BGRA8888)) ||
- ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_RGBA8888))) {
+ if (((src_format == MM_UTIL_COLOR_YUV420) && (dst_format == MM_UTIL_COLOR_NV12)) ||
+ ((src_format == MM_UTIL_COLOR_YUV420) && (dst_format == MM_UTIL_COLOR_RGB16)) ||
+ ((src_format == MM_UTIL_COLOR_YUV420) && (dst_format == MM_UTIL_COLOR_RGB24)) ||
+ ((src_format == MM_UTIL_COLOR_YUV420) && (dst_format == MM_UTIL_COLOR_ARGB)) ||
+ ((src_format == MM_UTIL_COLOR_YUV420) && (dst_format == MM_UTIL_COLOR_BGRA)) ||
+ ((src_format == MM_UTIL_COLOR_YUV420) && (dst_format == MM_UTIL_COLOR_RGBA)) ||
+ ((src_format == MM_UTIL_COLOR_YUV420) && (dst_format == MM_UTIL_COLOR_NV12_TILED)) ||
+
+ ((src_format == MM_UTIL_COLOR_I420) && (dst_format == MM_UTIL_COLOR_NV12)) ||
+ ((src_format == MM_UTIL_COLOR_I420) && (dst_format == MM_UTIL_COLOR_RGB16)) ||
+ ((src_format == MM_UTIL_COLOR_I420) && (dst_format == MM_UTIL_COLOR_RGB24)) ||
+ ((src_format == MM_UTIL_COLOR_I420) && (dst_format == MM_UTIL_COLOR_ARGB)) ||
+ ((src_format == MM_UTIL_COLOR_I420) && (dst_format == MM_UTIL_COLOR_BGRA)) ||
+ ((src_format == MM_UTIL_COLOR_I420) && (dst_format == MM_UTIL_COLOR_RGBA)) ||
+ ((src_format == MM_UTIL_COLOR_I420) && (dst_format == MM_UTIL_COLOR_NV12_TILED)) ||
+
+ ((src_format == MM_UTIL_COLOR_NV12) && (dst_format == MM_UTIL_COLOR_YUV420)) ||
+ ((src_format == MM_UTIL_COLOR_NV12) && (dst_format == MM_UTIL_COLOR_I420)) ||
+ ((src_format == MM_UTIL_COLOR_NV12) && (dst_format == MM_UTIL_COLOR_RGB16)) ||
+ ((src_format == MM_UTIL_COLOR_NV12) && (dst_format == MM_UTIL_COLOR_RGB24)) ||
+ ((src_format == MM_UTIL_COLOR_NV12) && (dst_format == MM_UTIL_COLOR_ARGB)) ||
+ ((src_format == MM_UTIL_COLOR_NV12) && (dst_format == MM_UTIL_COLOR_BGRA)) ||
+ ((src_format == MM_UTIL_COLOR_NV12) && (dst_format == MM_UTIL_COLOR_RGBA)) ||
+
+ ((src_format == MM_UTIL_COLOR_UYVY) && (dst_format == MM_UTIL_COLOR_RGB16)) ||
+ ((src_format == MM_UTIL_COLOR_UYVY) && (dst_format == MM_UTIL_COLOR_RGB24)) ||
+
+ ((src_format == MM_UTIL_COLOR_YUYV) && (dst_format == MM_UTIL_COLOR_RGB16)) ||
+ ((src_format == MM_UTIL_COLOR_YUYV) && (dst_format == MM_UTIL_COLOR_RGB24)) ||
+ ((src_format == MM_UTIL_COLOR_YUYV) && (dst_format == MM_UTIL_COLOR_ARGB)) ||
+ ((src_format == MM_UTIL_COLOR_YUYV) && (dst_format == MM_UTIL_COLOR_BGRA)) ||
+ ((src_format == MM_UTIL_COLOR_YUYV) && (dst_format == MM_UTIL_COLOR_RGBA)) ||
+
+ ((src_format == MM_UTIL_COLOR_RGB16) && (dst_format == MM_UTIL_COLOR_YUV420)) ||
+ ((src_format == MM_UTIL_COLOR_RGB16) && (dst_format == MM_UTIL_COLOR_I420)) ||
+ ((src_format == MM_UTIL_COLOR_RGB16) && (dst_format == MM_UTIL_COLOR_NV12)) ||
+
+ ((src_format == MM_UTIL_COLOR_RGB24) && (dst_format == MM_UTIL_COLOR_YUV420)) ||
+ ((src_format == MM_UTIL_COLOR_RGB24) && (dst_format == MM_UTIL_COLOR_I420)) ||
+ ((src_format == MM_UTIL_COLOR_RGB24) && (dst_format == MM_UTIL_COLOR_NV12)) ||
+
+ ((src_format == MM_UTIL_COLOR_ARGB) && (dst_format == MM_UTIL_COLOR_YUV420)) ||
+ ((src_format == MM_UTIL_COLOR_ARGB) && (dst_format == MM_UTIL_COLOR_I420)) ||
+ ((src_format == MM_UTIL_COLOR_ARGB) && (dst_format == MM_UTIL_COLOR_NV12)) ||
+
+ ((src_format == MM_UTIL_COLOR_BGRA) && (dst_format == MM_UTIL_COLOR_YUV420)) ||
+ ((src_format == MM_UTIL_COLOR_BGRA) && (dst_format == MM_UTIL_COLOR_I420)) ||
+ ((src_format == MM_UTIL_COLOR_BGRA) && (dst_format == MM_UTIL_COLOR_NV12)) ||
+ ((src_format == MM_UTIL_COLOR_RGBA) && (dst_format == MM_UTIL_COLOR_YUV420)) ||
+ ((src_format == MM_UTIL_COLOR_RGBA) && (dst_format == MM_UTIL_COLOR_I420)) ||
+ ((src_format == MM_UTIL_COLOR_RGBA) && (dst_format == MM_UTIL_COLOR_NV12)) ||
+ ((src_format == MM_UTIL_COLOR_RGBA) && (dst_format == MM_UTIL_COLOR_RGB16)) ||
+
+ ((src_format == MM_UTIL_COLOR_NV12_TILED) && (dst_format == MM_UTIL_COLOR_YUV420)) ||
+ ((src_format == MM_UTIL_COLOR_NV12_TILED) && (dst_format == MM_UTIL_COLOR_I420)) ||
+ ((src_format == MM_UTIL_COLOR_NV12_TILED) && (dst_format == MM_UTIL_COLOR_NV12)) ||
+ ((src_format == MM_UTIL_COLOR_NV12_TILED) && (dst_format == MM_UTIL_COLOR_RGB16)) ||
+ ((src_format == MM_UTIL_COLOR_NV12_TILED) && (dst_format == MM_UTIL_COLOR_RGB24)) ||
+ ((src_format == MM_UTIL_COLOR_NV12_TILED) && (dst_format == MM_UTIL_COLOR_ARGB)) ||
+ ((src_format == MM_UTIL_COLOR_NV12_TILED) && (dst_format == MM_UTIL_COLOR_BGRA)) ||
+ ((src_format == MM_UTIL_COLOR_NV12_TILED) && (dst_format == MM_UTIL_COLOR_RGBA))) {
_bool = TRUE;
}
return _bool;
}
-static gboolean __mm_select_resize_plugin(mm_util_img_format _format)
+static gboolean __mm_select_resize_plugin(mm_util_color_format_e _format)
{
gboolean _bool = FALSE;
mm_util_debug("_format: %d", _format);
- if ((_format == MM_UTIL_IMG_FMT_UYVY) || (_format == MM_UTIL_IMG_FMT_YUYV) ||
- (_format == MM_UTIL_IMG_FMT_RGBA8888) || (_format == MM_UTIL_IMG_FMT_BGRX8888))
+ if ((_format == MM_UTIL_COLOR_UYVY) || (_format == MM_UTIL_COLOR_YUYV) ||
+ (_format == MM_UTIL_COLOR_RGBA) || (_format == MM_UTIL_COLOR_BGRX))
_bool = FALSE;
else
_bool = TRUE;
return _bool;
}
-static gboolean __mm_select_rotate_plugin(mm_util_img_format _format)
+static gboolean __mm_select_rotate_plugin(mm_util_color_format_e _format)
{
mm_util_debug("_format: %d", _format);
- if ((_format == MM_UTIL_IMG_FMT_YUV420) || (_format == MM_UTIL_IMG_FMT_I420) || (_format == MM_UTIL_IMG_FMT_NV12)
- || (_format == MM_UTIL_IMG_FMT_RGB888 || _format == MM_UTIL_IMG_FMT_RGB565)) {
+ if ((_format == MM_UTIL_COLOR_YUV420) || (_format == MM_UTIL_COLOR_I420) || (_format == MM_UTIL_COLOR_NV12)
+ || (_format == MM_UTIL_COLOR_RGB24 || _format == MM_UTIL_COLOR_RGB16)) {
return TRUE;
}
return FALSE;
}
-static gboolean __mm_is_rgb_format(mm_util_img_format format)
+static gboolean __mm_is_rgb_format(mm_util_color_format_e format)
{
mm_util_debug("format: %d", format);
- if ((format == MM_UTIL_IMG_FMT_RGB565) ||
- (format == MM_UTIL_IMG_FMT_RGB888) ||
- (format == MM_UTIL_IMG_FMT_ARGB8888) ||
- (format == MM_UTIL_IMG_FMT_BGRA8888) ||
- (format == MM_UTIL_IMG_FMT_RGBA8888) ||
- (format == MM_UTIL_IMG_FMT_BGRX8888)) {
+ if ((format == MM_UTIL_COLOR_RGB16) ||
+ (format == MM_UTIL_COLOR_RGB24) ||
+ (format == MM_UTIL_COLOR_ARGB) ||
+ (format == MM_UTIL_COLOR_BGRA) ||
+ (format == MM_UTIL_COLOR_RGBA) ||
+ (format == MM_UTIL_COLOR_BGRX)) {
return TRUE;
}
return FALSE;
}
-static int __mm_util_get_crop_image_size(mm_util_img_format format, unsigned int width, unsigned int height, unsigned int *imgsize)
+static int __mm_util_get_crop_image_size(mm_util_color_format_e format, unsigned int width, unsigned int height, unsigned int *imgsize)
{
int ret = MM_UTIL_ERROR_NONE;
unsigned char x_chroma_shift = 0;
}
switch (format) {
- case MM_UTIL_IMG_FMT_I420:
- case MM_UTIL_IMG_FMT_YUV420:
+ case MM_UTIL_COLOR_I420:
+ case MM_UTIL_COLOR_YUV420:
x_chroma_shift = 1;
y_chroma_shift = 1;
stride = MM_UTIL_ROUND_UP_4(width);
size2 = stride2 * h2;
*imgsize = size + 2 * size2;
break;
- case MM_UTIL_IMG_FMT_YUV422:
- case MM_UTIL_IMG_FMT_YUYV:
- case MM_UTIL_IMG_FMT_UYVY:
- case MM_UTIL_IMG_FMT_NV16:
- case MM_UTIL_IMG_FMT_NV61:
+ case MM_UTIL_COLOR_YUV422:
+ case MM_UTIL_COLOR_YUYV:
+ case MM_UTIL_COLOR_UYVY:
+ case MM_UTIL_COLOR_NV16:
+ case MM_UTIL_COLOR_NV61:
stride = MM_UTIL_ROUND_UP_4(width) * 2;
size = stride * height;
*imgsize = size;
break;
- case MM_UTIL_IMG_FMT_RGB565:
+ case MM_UTIL_COLOR_RGB16:
stride = width * 2;
size = stride * height;
*imgsize = size;
break;
- case MM_UTIL_IMG_FMT_RGB888:
+ case MM_UTIL_COLOR_RGB24:
stride = width * 3;
size = stride * height;
*imgsize = size;
break;
- case MM_UTIL_IMG_FMT_ARGB8888:
- case MM_UTIL_IMG_FMT_BGRA8888:
- case MM_UTIL_IMG_FMT_RGBA8888:
- case MM_UTIL_IMG_FMT_BGRX8888:
+ case MM_UTIL_COLOR_ARGB:
+ case MM_UTIL_COLOR_BGRA:
+ case MM_UTIL_COLOR_RGBA:
+ case MM_UTIL_COLOR_BGRX:
stride = width * 4;
size = stride * height;
*imgsize = size;
break;
- case MM_UTIL_IMG_FMT_NV12:
- case MM_UTIL_IMG_FMT_NV12_TILED:
+ case MM_UTIL_COLOR_NV12:
+ case MM_UTIL_COLOR_NV12_TILED:
x_chroma_shift = 1;
y_chroma_shift = 1;
stride = MM_UTIL_ROUND_UP_4(width);
return ret;
}
-int __mm_util_get_buffer_size(mm_util_img_format format, unsigned int width, unsigned int height, unsigned int *imgsize)
+int __mm_util_get_buffer_size(mm_util_color_format_e format, unsigned int width, unsigned int height, unsigned int *imgsize)
{
int ret = MM_UTIL_ERROR_NONE;
unsigned char x_chroma_shift = 0;
}
switch (format) {
- case MM_UTIL_IMG_FMT_I420:
- case MM_UTIL_IMG_FMT_YUV420:
+ case MM_UTIL_COLOR_I420:
+ case MM_UTIL_COLOR_YUV420:
x_chroma_shift = 1;
y_chroma_shift = 1;
stride = MM_UTIL_ROUND_UP_4(width);
size2 = stride2 * h2;
*imgsize = size + 2 * size2;
break;
- case MM_UTIL_IMG_FMT_YUV422:
- case MM_UTIL_IMG_FMT_YUYV:
- case MM_UTIL_IMG_FMT_UYVY:
- case MM_UTIL_IMG_FMT_NV16:
- case MM_UTIL_IMG_FMT_NV61:
+ case MM_UTIL_COLOR_YUV422:
+ case MM_UTIL_COLOR_YUYV:
+ case MM_UTIL_COLOR_UYVY:
+ case MM_UTIL_COLOR_NV16:
+ case MM_UTIL_COLOR_NV61:
stride = MM_UTIL_ROUND_UP_4(width) * 2;
size = stride * height;
*imgsize = size;
break;
- case MM_UTIL_IMG_FMT_RGB565:
+ case MM_UTIL_COLOR_RGB16:
stride = MM_UTIL_ROUND_UP_4(width) * 2;
size = stride * MM_UTIL_ROUND_UP_2(height);
*imgsize = size;
break;
- case MM_UTIL_IMG_FMT_RGB888:
+ case MM_UTIL_COLOR_RGB24:
stride = MM_UTIL_ROUND_UP_4(width) * 3;
size = stride * MM_UTIL_ROUND_UP_2(height);
*imgsize = size;
break;
- case MM_UTIL_IMG_FMT_ARGB8888:
- case MM_UTIL_IMG_FMT_BGRA8888:
- case MM_UTIL_IMG_FMT_RGBA8888:
- case MM_UTIL_IMG_FMT_BGRX8888:
+ case MM_UTIL_COLOR_ARGB:
+ case MM_UTIL_COLOR_BGRA:
+ case MM_UTIL_COLOR_RGBA:
+ case MM_UTIL_COLOR_BGRX:
stride = width * 4;
size = stride * MM_UTIL_ROUND_UP_2(height);
*imgsize = size;
break;
- case MM_UTIL_IMG_FMT_NV12:
- case MM_UTIL_IMG_FMT_NV12_TILED:
+ case MM_UTIL_COLOR_NV12:
+ case MM_UTIL_COLOR_NV12_TILED:
x_chroma_shift = 1;
y_chroma_shift = 1;
stride = MM_UTIL_ROUND_UP_4(width);
return ret;
}
-static int __mm_set_format_label(imgp_info_s *_imgp_info_s, mm_util_img_format src_format, mm_util_img_format dst_format)
+static int __mm_set_format_label(imgp_info_s *_imgp_info_s, mm_util_color_format_e src_format, mm_util_color_format_e dst_format)
{
int ret = MM_UTIL_ERROR_NONE;
char *src_fmt_lable = NULL;
}
switch (src_format) {
- case MM_UTIL_IMG_FMT_YUV420:
+ case MM_UTIL_COLOR_YUV420:
src_fmt_lable = (char *)"YV12";
break;
- case MM_UTIL_IMG_FMT_YUV422:
+ case MM_UTIL_COLOR_YUV422:
src_fmt_lable = (char *)"Y42B";
break;
- case MM_UTIL_IMG_FMT_I420:
+ case MM_UTIL_COLOR_I420:
src_fmt_lable = (char *)"I420";
break;
- case MM_UTIL_IMG_FMT_NV12:
+ case MM_UTIL_COLOR_NV12:
src_fmt_lable = (char *)"NV12";
break;
- case MM_UTIL_IMG_FMT_UYVY:
+ case MM_UTIL_COLOR_UYVY:
src_fmt_lable = (char *)"UYVY";
break;
- case MM_UTIL_IMG_FMT_YUYV:
+ case MM_UTIL_COLOR_YUYV:
src_fmt_lable = (char *)"YUYV";
break;
- case MM_UTIL_IMG_FMT_RGB565:
+ case MM_UTIL_COLOR_RGB16:
src_fmt_lable = (char *)"RGB565";
break;
- case MM_UTIL_IMG_FMT_RGB888:
+ case MM_UTIL_COLOR_RGB24:
src_fmt_lable = (char *)"RGB888";
break;
- case MM_UTIL_IMG_FMT_ARGB8888:
+ case MM_UTIL_COLOR_ARGB:
src_fmt_lable = (char *)"ARGB8888";
break;
- case MM_UTIL_IMG_FMT_BGRA8888:
+ case MM_UTIL_COLOR_BGRA:
src_fmt_lable = (char *)"BGRA8888";
break;
- case MM_UTIL_IMG_FMT_RGBA8888:
+ case MM_UTIL_COLOR_RGBA:
src_fmt_lable = (char *)"RGBA8888";
break;
- case MM_UTIL_IMG_FMT_BGRX8888:
+ case MM_UTIL_COLOR_BGRX:
src_fmt_lable = (char *)"BGRX";
break;
default:
}
switch (dst_format) {
- case MM_UTIL_IMG_FMT_YUV420:
+ case MM_UTIL_COLOR_YUV420:
dst_fmt_lable = (char *)"YV12";
break;
- case MM_UTIL_IMG_FMT_YUV422:
+ case MM_UTIL_COLOR_YUV422:
dst_fmt_lable = (char *)"Y42B";
break;
- case MM_UTIL_IMG_FMT_I420:
+ case MM_UTIL_COLOR_I420:
dst_fmt_lable = (char *)"I420";
break;
- case MM_UTIL_IMG_FMT_NV12:
+ case MM_UTIL_COLOR_NV12:
dst_fmt_lable = (char *)"NV12";
break;
- case MM_UTIL_IMG_FMT_UYVY:
+ case MM_UTIL_COLOR_UYVY:
dst_fmt_lable = (char *)"UYVY";
break;
- case MM_UTIL_IMG_FMT_YUYV:
+ case MM_UTIL_COLOR_YUYV:
dst_fmt_lable = (char *)"YUYV";
break;
- case MM_UTIL_IMG_FMT_RGB565:
+ case MM_UTIL_COLOR_RGB16:
dst_fmt_lable = (char *)"RGB565";
break;
- case MM_UTIL_IMG_FMT_RGB888:
+ case MM_UTIL_COLOR_RGB24:
dst_fmt_lable = (char *)"RGB888";
break;
- case MM_UTIL_IMG_FMT_ARGB8888:
+ case MM_UTIL_COLOR_ARGB:
dst_fmt_lable = (char *)"ARGB8888";
break;
- case MM_UTIL_IMG_FMT_BGRA8888:
+ case MM_UTIL_COLOR_BGRA:
dst_fmt_lable = (char *)"BGRA8888";
break;
- case MM_UTIL_IMG_FMT_RGBA8888:
+ case MM_UTIL_COLOR_RGBA:
dst_fmt_lable = (char *)"RGBA8888";
break;
- case MM_UTIL_IMG_FMT_BGRX8888:
+ case MM_UTIL_COLOR_BGRX:
dst_fmt_lable = (char *)"BGRX";
break;
default:
return ret;
}
-static int __mm_set_imgp_info_s(imgp_info_s *_imgp_info_s, mm_util_img_format src_format, unsigned int src_width, unsigned int src_height, mm_util_img_format dst_format, unsigned int dst_width, unsigned int dst_height, mm_util_img_rotate_type angle)
+static int __mm_set_imgp_info_s(imgp_info_s *_imgp_info_s, mm_util_color_format_e src_format, unsigned int src_width, unsigned int src_height, mm_util_color_format_e dst_format, unsigned int dst_width, unsigned int dst_height, mm_util_img_rotate_type angle)
{
int ret = MM_UTIL_ERROR_NONE;
return;
}
-static int __mm_util_crop_rgba32(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format,
+static int __mm_util_crop_rgba32(const unsigned char *src, unsigned int src_width, unsigned int src_height,
unsigned int crop_start_x, unsigned int crop_start_y, unsigned int crop_dest_width, unsigned int crop_dest_height, unsigned char *dst)
{
int ret = MM_UTIL_ERROR_NONE;
return ret;
}
-static int __mm_util_crop_rgb888(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format,
+static int __mm_util_crop_rgb888(const unsigned char *src, unsigned int src_width, unsigned int src_height,
unsigned int crop_start_x, unsigned int crop_start_y, unsigned int crop_dest_width, unsigned int crop_dest_height, unsigned char *dst)
{
int ret = MM_UTIL_ERROR_NONE;
return ret;
}
-static int __mm_util_crop_rgb565(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format,
+static int __mm_util_crop_rgb565(const unsigned char *src, unsigned int src_width, unsigned int src_height,
unsigned int crop_start_x, unsigned int crop_start_y, unsigned int crop_dest_width, unsigned int crop_dest_height, unsigned char *dst)
{
int ret = MM_UTIL_ERROR_NONE;
return ret;
}
-static int __mm_util_crop_yuv420(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format,
+static int __mm_util_crop_yuv420(const unsigned char *src, unsigned int src_width, unsigned int src_height,
unsigned int crop_start_x, unsigned int crop_start_y, unsigned int crop_dest_width, unsigned int crop_dest_height, unsigned char *dst)
{
int ret = MM_UTIL_ERROR_NONE;
/* private values init */
handle->dst = NULL;
- handle->dst_format = MM_UTIL_IMG_FMT_NUM;
+ handle->dst_format = MM_UTIL_COLOR_NUM;
handle->rotation = MM_UTIL_ROTATION_NONE;
handle->start_x = -1;
unsigned char *dst_buf[4] = {NULL,};
unsigned int dst_buf_size = 0;
unsigned int src_width = 0, src_height = 0;
- mm_util_img_format src_format = -1;
+ mm_util_color_format_e src_format = -1;
unsigned int src_index = 0, dst_index = 0;
if (handle == NULL) {
mm_util_debug("src: %p, dst: %p", handle->src, handle->dst);
- dst_buf[src_index] = calloc(1, handle->src->buffer_size);
+ dst_buf[src_index] = calloc(1, handle->src->size);
src_width = handle->src->width;
src_height = handle->src->height;
- src_format = handle->src->format;
+ src_format = handle->src->color;
if (dst_buf[src_index] == NULL) {
mm_util_error("[multi func] memory allocation error");
return MM_UTIL_ERROR_INVALID_OPERATION;
}
- memcpy(dst_buf[src_index], handle->src->buffer, handle->src->buffer_size);
+ memcpy(dst_buf[src_index], handle->src->data, handle->src->size);
if (handle->set_crop) {
dst_index++;
__mm_util_get_crop_image_size(src_format, handle->dst_width, handle->dst_height, &dst_buf_size);
}
if (dst_buf[dst_index] != NULL && dst_buf_size != 0) {
- ret = mm_util_set_color_image((mm_util_color_image_h)handle->dst, (int)src_width, (int)src_height, src_format, (void *)dst_buf[dst_index], (size_t)dst_buf_size);
+ ret = mm_util_create_color_image((mm_util_color_image_h *)&(handle->dst), (unsigned long)src_width, (unsigned long)src_height, src_format, (void *)dst_buf[dst_index], (size_t)dst_buf_size);
if (ret != MM_UTIL_ERROR_NONE)
mm_util_error("mm_util_set_color_image failed");
}
return MM_UTIL_ERROR_INVALID_PARAMETER;
}
- mm_util_debug("orig_image: %p [%zu] %d X %d (%d)", source_image->buffer, source_image->buffer_size,
- source_image->width, source_image->height, source_image->format);
+ mm_util_debug("orig_image: %p [%zu] %lu X %lu (%u)", source_image->data, source_image->size,
+ source_image->width, source_image->height, source_image->color);
handle->src = source_image;
- ret = mm_util_create_color_image((mm_util_color_image_h *)&handle->dst);
- if (ret != MM_UTIL_ERROR_NONE) {
- mm_util_error("mm_util_create_color_image failed");
- return ret;
- }
+ handle->dst = NULL;
ret = __mm_util_processing(handle);
if (ret != MM_UTIL_ERROR_NONE) {
return ret;
}
- mm_util_debug("result_image: %p [%zu] %d X %d (%u)", handle->dst->buffer, handle->dst->buffer_size,
- handle->dst->width, handle->dst->height, handle->dst->format);
+ mm_util_debug("result_image: %p [%zu] %lu X %lu (%u)", handle->dst->data, handle->dst->size,
+ handle->dst->width, handle->dst->height, handle->dst->color);
return ret;
}
return ret;
}
-int mm_util_set_colorspace_convert(mm_util_imgp_h imgp_handle, mm_util_img_format colorspace)
+int mm_util_set_colorspace_convert(mm_util_imgp_h imgp_handle, mm_util_color_format_e colorspace)
{
int ret = MM_UTIL_ERROR_NONE;
mm_util_s *handle = (mm_util_s *) imgp_handle;
return ret;
}
-int mm_util_create_color_image(mm_util_color_image_h *image)
-{
- int ret = MM_UTIL_ERROR_NONE;
- color_image_data_s *color_image = NULL;
-
- if (image == NULL) {
- mm_util_error("[ERROR] - image");
- return MM_UTIL_ERROR_INVALID_PARAMETER;
- }
-
- mm_util_error("Memory allocation s");
-
- color_image = (color_image_data_s *)calloc(1, sizeof(color_image_data_s));
- if (color_image == NULL) {
- mm_util_error("Memory allocation failed");
- return MM_UTIL_ERROR_OUT_OF_MEMORY;
- }
-
- mm_util_error("Memory allocation e");
-
- *image = (mm_util_color_image_h)color_image;
-
- return ret;
-}
-
-int mm_util_set_color_image(mm_util_color_image_h image, int width, int height, mm_util_img_format format, void *buffer, size_t buffer_size)
-{
- int ret = MM_UTIL_ERROR_NONE;
- color_image_data_s *color_image = (color_image_data_s *)image;
-
- if (color_image == NULL) {
- mm_util_error("[ERROR] - raw_image");
- return MM_UTIL_ERROR_INVALID_PARAMETER;
- }
-
- if (buffer == NULL || buffer_size == 0) {
- mm_util_error("[ERROR] - Invalid parameters");
- return MM_UTIL_ERROR_INVALID_PARAMETER;
- }
-
- color_image->buffer = calloc(1, buffer_size);
- if (color_image->buffer == NULL) {
- mm_util_error("Memory allocation failed");
- return MM_UTIL_ERROR_OUT_OF_MEMORY;
- }
- memcpy(color_image->buffer, buffer, buffer_size);
- color_image->buffer_size = buffer_size;
- color_image->width = width;
- color_image->height = height;
- color_image->format = format;
-
- return ret;
-}
-
-int mm_util_get_color_image(mm_util_color_image_h image, int *width, int *height, mm_util_img_format *format, void **buffer, size_t *buffer_size)
-{
- int ret = MM_UTIL_ERROR_NONE;
- color_image_data_s *color_image = (color_image_data_s *)image;
-
- if (color_image == NULL) {
- mm_util_error("[ERROR] - raw_image");
- return MM_UTIL_ERROR_INVALID_PARAMETER;
- }
-
- if (width != NULL)
- *width = color_image->width;
-
- if (height != NULL)
- *height = color_image->height;
-
- if (format != NULL)
- *format = color_image->format;
-
- if (buffer != NULL)
- *buffer = color_image->buffer;
-
- if (buffer_size != NULL)
- *buffer_size = color_image->buffer_size;
-
- return ret;
-}
-
-
-void mm_util_destroy_color_image(mm_util_color_image_h image)
-{
- color_image_data_s *color_image = (color_image_data_s *)image;
-
- if (color_image == NULL) {
- mm_util_error("[ERROR] - image");
- return;
- }
-
- MMUTIL_SAFE_FREE(color_image->buffer);
- MMUTIL_SAFE_FREE(color_image);
-}
-
int mm_util_transform(mm_util_imgp_h imgp_handle, mm_util_color_image_h image, mm_util_completed_callback completed_callback, void *user_data)
{
int ret = MM_UTIL_ERROR_NONE;
return ret;
}
-static IMGPInfoFunc __mm_util_initialize(imgp_type_e function, mm_util_img_format src_format, mm_util_img_format dst_format, GModule **module)
+static IMGPInfoFunc __mm_util_initialize(imgp_type_e function, mm_util_color_format_e src_format, mm_util_color_format_e dst_format, GModule **module)
{
imgp_plugin_type_e _imgp_plugin_type_e = IMGP_GSTCS;
GModule *_module = NULL;
return _func;
}
-int mm_util_convert_colorspace(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format, unsigned char *dst, mm_util_img_format dst_format)
+int mm_util_convert_colorspace(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_color_format_e src_format, unsigned char *dst, mm_util_color_format_e dst_format)
{
int ret = MM_UTIL_ERROR_NONE;
IMGPInfoFunc _mm_util_imgp_func = NULL;
mm_util_retvm_if(src == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src");
mm_util_retvm_if(dst == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid dst");
- mm_util_retvm_if((src_format < MM_UTIL_IMG_FMT_YUV420) || (src_format >= MM_UTIL_IMG_FMT_NUM), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src_format [%d]", src_format);
- mm_util_retvm_if((dst_format < MM_UTIL_IMG_FMT_YUV420) || (dst_format >= MM_UTIL_IMG_FMT_NUM), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid dst_format [%d]", dst_format);
+ mm_util_retvm_if((IS_MM_UTIL_COLOR_FORMAT(src_format) == FALSE), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src_format [%d]", src_format);
+ mm_util_retvm_if((IS_MM_UTIL_COLOR_FORMAT(dst_format) == FALSE), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid dst_format [%d]", dst_format);
if (__mm_cannot_convert_format(src_format, dst_format)) {
mm_util_error("#ERROR# Cannot Support Image Format Convert");
return ret;
}
-int mm_util_resize_image(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format, unsigned char *dst, unsigned int *dst_width, unsigned int *dst_height)
+int mm_util_resize_image(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_color_format_e src_format, unsigned char *dst, unsigned int *dst_width, unsigned int *dst_height)
{
int ret = MM_UTIL_ERROR_NONE;
IMGPInfoFunc _mm_util_imgp_func = NULL;
mm_util_retvm_if(src == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src");
mm_util_retvm_if(src_width == 0, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src_width");
mm_util_retvm_if(src_height == 0, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src_height");
- mm_util_retvm_if((src_format < MM_UTIL_IMG_FMT_YUV420) || (src_format >= MM_UTIL_IMG_FMT_NUM), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src_format [%d]", src_format);
+ mm_util_retvm_if((IS_MM_UTIL_COLOR_FORMAT(src_format) == FALSE), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src_format [%d]", src_format);
mm_util_retvm_if(dst == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid dst");
mm_util_retvm_if(dst_width == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid dst_width");
mm_util_retvm_if(dst_height == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid dst_height");
return ret;
}
-int mm_util_rotate_image(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format, unsigned char *dst, unsigned int *dst_width, unsigned int *dst_height, mm_util_img_rotate_type angle)
+int mm_util_rotate_image(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_color_format_e src_format, unsigned char *dst, unsigned int *dst_width, unsigned int *dst_height, mm_util_img_rotate_type angle)
{
int ret = MM_UTIL_ERROR_NONE;
IMGPInfoFunc _mm_util_imgp_func = NULL;
mm_util_retvm_if(src == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src");
mm_util_retvm_if(src_width == 0, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src_width");
mm_util_retvm_if(src_height == 0, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src_height");
- mm_util_retvm_if((src_format < MM_UTIL_IMG_FMT_YUV420) || (src_format >= MM_UTIL_IMG_FMT_NUM), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src_format [%d]", src_format);
+ mm_util_retvm_if((IS_MM_UTIL_COLOR_FORMAT(src_format) == FALSE), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src_format [%d]", src_format);
mm_util_retvm_if(dst == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid dst");
mm_util_retvm_if(dst_width == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid dst_width");
mm_util_retvm_if(dst_height == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid dst_height");
return ret;
}
-int mm_util_crop_image(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format,
+int mm_util_crop_image(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_color_format_e src_format,
unsigned int crop_start_x, unsigned int crop_start_y, unsigned int *crop_dest_width, unsigned int *crop_dest_height, unsigned char *dst)
{
int ret = MM_UTIL_ERROR_NONE;
mm_util_retvm_if(src == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src");
mm_util_retvm_if(src_width == 0, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src_width");
mm_util_retvm_if(src_height == 0, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src_height");
- mm_util_retvm_if((src_format < MM_UTIL_IMG_FMT_YUV420) || (src_format >= MM_UTIL_IMG_FMT_NUM), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src_format [%d]", src_format);
+ mm_util_retvm_if((IS_MM_UTIL_COLOR_FORMAT(src_format) == FALSE), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src_format [%d]", src_format);
mm_util_retvm_if(dst == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid dst");
mm_util_retvm_if((crop_start_x + *crop_dest_width > src_width), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid position [%d]]", crop_start_x);
mm_util_retvm_if((crop_start_y + *crop_dest_height > src_height), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid position [%d]", crop_start_y);
src, src_width, src_height, src_format, crop_start_x, crop_start_y, *crop_dest_width, *crop_dest_height);
switch (src_format) {
- case MM_UTIL_IMG_FMT_RGB888: {
- ret = __mm_util_crop_rgb888(src, src_width, src_height, src_format, crop_start_x, crop_start_y, *crop_dest_width, *crop_dest_height, dst);
+ case MM_UTIL_COLOR_RGB24: {
+ ret = __mm_util_crop_rgb888(src, src_width, src_height, crop_start_x, crop_start_y, *crop_dest_width, *crop_dest_height, dst);
break;
}
- case MM_UTIL_IMG_FMT_RGB565: {
- ret = __mm_util_crop_rgb565(src, src_width, src_height, src_format, crop_start_x, crop_start_y, *crop_dest_width, *crop_dest_height, dst);
+ case MM_UTIL_COLOR_RGB16: {
+ ret = __mm_util_crop_rgb565(src, src_width, src_height, crop_start_x, crop_start_y, *crop_dest_width, *crop_dest_height, dst);
break;
}
- case MM_UTIL_IMG_FMT_ARGB8888:
- case MM_UTIL_IMG_FMT_BGRA8888:
- case MM_UTIL_IMG_FMT_RGBA8888:
- case MM_UTIL_IMG_FMT_BGRX8888: {
- ret = __mm_util_crop_rgba32(src, src_width, src_height, src_format, crop_start_x, crop_start_y, *crop_dest_width, *crop_dest_height, dst);
+ case MM_UTIL_COLOR_ARGB:
+ case MM_UTIL_COLOR_BGRA:
+ case MM_UTIL_COLOR_RGBA:
+ case MM_UTIL_COLOR_BGRX: {
+ ret = __mm_util_crop_rgba32(src, src_width, src_height, crop_start_x, crop_start_y, *crop_dest_width, *crop_dest_height, dst);
break;
}
- case MM_UTIL_IMG_FMT_I420:
- case MM_UTIL_IMG_FMT_YUV420: {
+ case MM_UTIL_COLOR_I420:
+ case MM_UTIL_COLOR_YUV420: {
if ((*crop_dest_width % 2) != 0) {
mm_util_warn("#YUV Width value(%d) must be even at least# ", *crop_dest_width);
*crop_dest_width = ((*crop_dest_width+1)>>1)<<1;
mm_util_debug("Image isplay is suceeded when YUV crop height value %d", *crop_dest_height);
}
- ret = __mm_util_crop_yuv420(src, src_width, src_height, src_format, crop_start_x, crop_start_y, *crop_dest_width, *crop_dest_height, dst);
+ ret = __mm_util_crop_yuv420(src, src_width, src_height, crop_start_x, crop_start_y, *crop_dest_width, *crop_dest_height, dst);
break;
}
default:
return ret;
}
-int mm_util_get_image_size(mm_util_img_format format, unsigned int width, unsigned int height, unsigned int *imgsize)
+int mm_util_get_image_size(mm_util_color_format_e format, unsigned int width, unsigned int height, unsigned int *imgsize)
{
int ret = MM_UTIL_ERROR_NONE;
unsigned char x_chroma_shift = 0;
}
switch (format) {
- case MM_UTIL_IMG_FMT_I420:
- case MM_UTIL_IMG_FMT_YUV420:
+ case MM_UTIL_COLOR_I420:
+ case MM_UTIL_COLOR_YUV420:
x_chroma_shift = 1;
y_chroma_shift = 1;
stride = MM_UTIL_ROUND_UP_4(width);
size2 = stride2 * h2;
*imgsize = size + 2 * size2;
break;
- case MM_UTIL_IMG_FMT_YUV422:
- case MM_UTIL_IMG_FMT_YUYV:
- case MM_UTIL_IMG_FMT_UYVY:
- case MM_UTIL_IMG_FMT_NV16:
- case MM_UTIL_IMG_FMT_NV61:
+ case MM_UTIL_COLOR_YUV422:
+ case MM_UTIL_COLOR_YUYV:
+ case MM_UTIL_COLOR_UYVY:
+ case MM_UTIL_COLOR_NV16:
+ case MM_UTIL_COLOR_NV61:
stride = MM_UTIL_ROUND_UP_4(width) * 2;
size = stride * height;
*imgsize = size;
break;
- case MM_UTIL_IMG_FMT_RGB565:
+ case MM_UTIL_COLOR_RGB16:
stride = MM_UTIL_ROUND_UP_4(width) * 2;
size = stride * height;
*imgsize = size;
break;
- case MM_UTIL_IMG_FMT_RGB888:
+ case MM_UTIL_COLOR_RGB24:
stride = MM_UTIL_ROUND_UP_4(width) * 3;
size = stride * height;
*imgsize = size;
break;
- case MM_UTIL_IMG_FMT_ARGB8888:
- case MM_UTIL_IMG_FMT_BGRA8888:
- case MM_UTIL_IMG_FMT_RGBA8888:
- case MM_UTIL_IMG_FMT_BGRX8888:
+ case MM_UTIL_COLOR_ARGB:
+ case MM_UTIL_COLOR_BGRA:
+ case MM_UTIL_COLOR_RGBA:
+ case MM_UTIL_COLOR_BGRX:
stride = width * 4;
size = stride * height;
*imgsize = size;
break;
- case MM_UTIL_IMG_FMT_NV12:
- case MM_UTIL_IMG_FMT_NV12_TILED:
+ case MM_UTIL_COLOR_NV12:
+ case MM_UTIL_COLOR_NV12_TILED:
x_chroma_shift = 1;
y_chroma_shift = 1;
stride = MM_UTIL_ROUND_UP_4(width);
#include <inttypes.h>
#include <errno.h>
#include <mm_util_imgp.h>
+#include <mm_util_common.h>
#define MAX_STRING_LEN 128
#define IMAGE_FORMAT_LABEL_BUFFER_SIZE 4
unsigned char *dst = NULL;
if (argc < 12) {
- fprintf(stderr, "Usage: %s sync {filename} {command} src_width src_height src_foramt dst_width dst_height dst_format rotation crop_start_x crop_start_y \n", argv[0]);
- fprintf(stderr, "Usage: %s async {filename} {command} src_width src_height src_foramt dst_width dst_height dst_format rotation crop_start_x crop_start_y \n", argv[0]);
+ fprintf(stderr, "Usage: %s sync {filename} {command} src_width src_height src_foramt dst_width dst_height dst_format roation crop_start_x crop_start_y \n", argv[0]);
+ fprintf(stderr, "Usage: %s async {filename} {command} src_width src_height src_foramt dst_width dst_height dst_format roation crop_start_x crop_start_y \n", argv[0]);
fprintf(stderr, "ex: %s sync test.rgb resize 1920 1080 7 1280 720 7 0 0 0 \n", argv[0]);
return ret;
}
char *command = strdup(argv[3]);
unsigned int src_width = (unsigned int)atoi(argv[4]);
unsigned int src_height = (unsigned int)atoi(argv[5]);
- mm_util_img_format src_format = atoi(argv[6]);
+ mm_util_color_format_e src_format = atoi(argv[6]);
unsigned int dst_width = (unsigned int)atoi(argv[7]);
unsigned int dst_height = (unsigned int)atoi(argv[8]);
- mm_util_img_format dst_format = atoi(argv[9]);
+ mm_util_color_format_e dst_format = atoi(argv[9]);
mm_util_img_rotate_type rotation = atoi(argv[10]);
unsigned int start_x = (unsigned int)atoi(argv[11]);
unsigned int start_y = (unsigned int)atoi(argv[12]);
{ /* ready output file */
char *output_fmt = (char *) calloc(1, sizeof(char) * IMAGE_FORMAT_LABEL_BUFFER_SIZE);
memset(output_fmt, 0, IMAGE_FORMAT_LABEL_BUFFER_SIZE);
- if (dst_format == MM_UTIL_IMG_FMT_YUV420 ||
- dst_format == MM_UTIL_IMG_FMT_YUV422 ||
- dst_format == MM_UTIL_IMG_FMT_I420) {
+ if (dst_format == MM_UTIL_COLOR_YUV420 ||
+ dst_format == MM_UTIL_COLOR_YUV422 ||
+ dst_format == MM_UTIL_COLOR_I420) {
strncpy(output_fmt, "yuv", strlen("yuv"));
} else {
//strncpy(output_fmt, "rgb", strlen("rgb"));
goto TEST_FAIL;
}
- ret = mm_util_create_color_image(&orig_image);
- if (ret == MM_UTIL_ERROR_NONE) {
- fprintf(stderr, "Success - mm_util_create_color_image\n");
- } else {
- fprintf(stderr, "ERROR - mm_util_create_color_image\n");
- goto TEST_FAIL;
- }
-
- ret = mm_util_set_color_image(orig_image, src_width, src_height, src_format, src, src_size);
+ ret = mm_util_create_color_image(&orig_image, src_width, src_height, src_format, src, src_size);
if (ret == MM_UTIL_ERROR_NONE) {
fprintf(stderr, "Success - mm_util_create_color_image\n");
} else {
aux_source_directory(. SOURCES)
ADD_LIBRARY(${fw_name} SHARED ${SOURCES})
-TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS} mmutil_imgp jpeg turbojpeg)
+TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS} mmutil_common mmutil_imgp jpeg turbojpeg)
SET_TARGET_PROPERTIES(${fw_name}
PROPERTIES
VERSION ${VERSION}
*/
/**
- * YUV format for jpeg
- */
-typedef enum {
- /* YUV planar format */
- MM_UTIL_JPEG_FMT_YUV420 = 0x00, /**< YUV420 format - planer I420 */
- MM_UTIL_JPEG_FMT_YUV422, /**< YUV422 format - planer */
- /* YUV packed format */
- MM_UTIL_JPEG_FMT_UYVY, /**< UYVY format - YUV packed format */
- /* RGB888 format */
- MM_UTIL_JPEG_FMT_RGB888, /**< RGB888 format */
- /* GrayScale format */
- MM_UTIL_JPEG_FMT_GraySacle, /**< GrayScale format */
- /* YUV packed format */
- MM_UTIL_JPEG_FMT_YUYV, /**< YUYV format - YUV packed format */
- /*Following formats are only for qualcomm hardware codecs.*/
- MM_UTIL_JPEG_FMT_NV12, /**< YUV format - YUV420 semi-planar (NV12) */
- MM_UTIL_JPEG_FMT_NV21, /**< YUV format - YUV420 semi-planar (NV21) */
- MM_UTIL_JPEG_FMT_NV16, /**< YUV format - YUV422 semi-planar (NV16) */
- MM_UTIL_JPEG_FMT_NV61, /**< YUV format - YUV422 semi-planar (NV61) */
- MM_UTIL_JPEG_FMT_RGBA8888, /**< RGBA8888 format */
- MM_UTIL_JPEG_FMT_BGRA8888, /**< BGRA8888 format */
- MM_UTIL_JPEG_FMT_ARGB8888, /**< ARGB8888 format */
-} mm_util_jpeg_yuv_format;
-
-/**
* downscale decoding for jpeg
*/
typedef enum {
* YUV data
*/
typedef struct {
- mm_util_jpeg_yuv_format format; /**< pixel format*/
+ mm_util_color_format_e format; /**< pixel format*/
int width; /**< width */
int height; /**< heigt */
unsigned int size; /**< size */
* @param quality [in] encoding quality, from 1 to 100
* @return This function returns zero on success, or negative value with error code.
* @remark
- * @see mm_util_jpeg_yuv_format
+ * @see mm_util_color_format_e
* @since R1, 1.0
*/
-int mm_util_jpeg_encode_to_file(const char *filename, void *src, int width, int height, mm_util_jpeg_yuv_format fmt, int quality);
+int mm_util_jpeg_encode_to_file(const char *filename, void *src, int width, int height, mm_util_color_format_e fmt, int quality);
/**
* @param quality [in] encoding quality, from 1 to 100
* @return This function returns zero on success, or negative value with error code.
* @remark
- * @see mm_util_jpeg_yuv_format
+ * @see mm_util_color_format_e
* @since R1, 1.0
*/
-int mm_util_jpeg_encode_to_memory(void **mem, unsigned int *size, void *src, int width, int height, mm_util_jpeg_yuv_format fmt, int quality);
+int mm_util_jpeg_encode_to_memory(void **mem, unsigned int *size, void *src, int width, int height, mm_util_color_format_e fmt, int quality);
/**
* @param fmt [in] color format
* @return This function returns zero on success, or negative value with error code.
* @remark
- * @see mm_util_jpeg_yuv_data, mm_util_jpeg_yuv_format
+ * @see mm_util_jpeg_yuv_data, mm_util_color_format_e
* @since R1, 1.0
*/
-int mm_util_decode_from_jpeg_file(mm_util_jpeg_yuv_data *decoded, const char *filename, mm_util_jpeg_yuv_format fmt);
+int mm_util_decode_from_jpeg_file(mm_util_jpeg_yuv_data *decoded, const char *filename, mm_util_color_format_e fmt);
/**
* @param fmt [in] color format
* @return This function returns zero on success, or negative value with error code.
* @remark
- * @see mm_util_jpeg_yuv_data, mm_util_jpeg_yuv_format
+ * @see mm_util_jpeg_yuv_data, mm_util_color_format_e
* @since R1, 1.0
*/
-int mm_util_decode_from_jpeg_memory(mm_util_jpeg_yuv_data *decoded, void *src, unsigned int size, mm_util_jpeg_yuv_format fmt);
+int mm_util_decode_from_jpeg_memory(mm_util_jpeg_yuv_data *decoded, void *src, unsigned int size, mm_util_color_format_e fmt);
/**
* This function extracts yuv data from jpeg file with downscale decode option
* @param downscale [in] downscale value
* @return This function returns zero on success, or negative value with error code.
* @remark
- * @see mm_util_jpeg_yuv_data, mm_util_jpeg_yuv_format
+ * @see mm_util_jpeg_yuv_data, mm_util_color_format_e
* @since R1, 1.0
*/
-int mm_util_decode_from_jpeg_file_with_downscale(mm_util_jpeg_yuv_data *decoded, const char *filename, mm_util_jpeg_yuv_format fmt, mm_util_jpeg_decode_downscale downscale);
+int mm_util_decode_from_jpeg_file_with_downscale(mm_util_jpeg_yuv_data *decoded, const char *filename, mm_util_color_format_e fmt, mm_util_jpeg_decode_downscale downscale);
/**
* This function extracts yuv data from jpeg buffer with downscale decode option
* @param downscale [in] downscale value
* @return This function returns zero on success, or negative value with error code.
* @remark
- * @see mm_util_jpeg_yuv_data, mm_util_jpeg_yuv_format
+ * @see mm_util_jpeg_yuv_data, mm_util_color_format_e
* @since R1, 1.0
*/
-int mm_util_decode_from_jpeg_memory_with_downscale(mm_util_jpeg_yuv_data *decoded, void *src, unsigned int size, mm_util_jpeg_yuv_format fmt, mm_util_jpeg_decode_downscale downscale);
+int mm_util_decode_from_jpeg_memory_with_downscale(mm_util_jpeg_yuv_data *decoded, void *src, unsigned int size, mm_util_color_format_e fmt, mm_util_jpeg_decode_downscale downscale);
#ifdef __cplusplus
#include <glib.h>
#include "mm_util_jpeg.h"
#include "mm_util_imgp.h"
+#include "mm_util_common.h"
#include "mm_util_private.h"
#ifndef YUV420_SIZE
}
#endif
-static void __mm_decode_libjpeg_turbo_decompress(tjhandle handle, unsigned char *jpegBuf, unsigned long jpegSize, int TD_BU, mm_util_jpeg_yuv_data* decoded_data, mm_util_jpeg_yuv_format input_fmt)
+static void __mm_decode_libjpeg_turbo_decompress(tjhandle handle, unsigned char *jpegBuf, unsigned long jpegSize, int TD_BU, mm_util_jpeg_yuv_data* decoded_data, mm_util_color_format_e input_fmt)
{
int _hdrw = 0, _hdrh = 0, _hdrsubsamp = -1;
int scaledWidth = 0;
return;
}
- if ((_hdrsubsamp == TJSAMP_444 || _hdrsubsamp == TJSAMP_GRAY) || input_fmt == MM_UTIL_JPEG_FMT_RGB888)
+ if ((_hdrsubsamp == TJSAMP_444 || _hdrsubsamp == TJSAMP_GRAY) || input_fmt == MM_UTIL_COLOR_RGB24)
_sf = sf[i];
else
_sf = sf1;
scaledHeight = TJSCALED(_hdrh, _sf);
mm_util_debug("_hdrw:%d _hdrh:%d, _hdrsubsamp:%d, scaledWidth:%d, scaledHeight:%d", _hdrw, _hdrh, _hdrsubsamp, scaledWidth, scaledHeight);
- if (input_fmt == MM_UTIL_JPEG_FMT_YUV420 || input_fmt == MM_UTIL_JPEG_FMT_YUV422)
+ if (input_fmt == MM_UTIL_COLOR_YUV420 || input_fmt == MM_UTIL_COLOR_YUV422)
mm_util_debug("JPEG -> YUV %s ... ", subName[_hdrsubsamp]);
- else if (input_fmt == MM_UTIL_JPEG_FMT_RGB888)
+ else if (input_fmt == MM_UTIL_COLOR_RGB24)
mm_util_debug("JPEG -> RGB %d/%d ... ", _sf.num, _sf.denom);
- if (input_fmt == MM_UTIL_JPEG_FMT_YUV420 || input_fmt == MM_UTIL_JPEG_FMT_YUV422) {
+ if (input_fmt == MM_UTIL_COLOR_YUV420 || input_fmt == MM_UTIL_COLOR_YUV422) {
dstSize = TJBUFSIZEYUV(_hdrw, _hdrh, _hdrsubsamp);
- mm_util_debug("MM_UTIL_JPEG_FMT_YUV420 dstSize: %d _hdrsubsamp:%d TJBUFSIZEYUV(w, h, _hdrsubsamp): %d",
+ mm_util_debug("MM_UTIL_COLOR_YUV420 dstSize: %d _hdrsubsamp:%d TJBUFSIZEYUV(w, h, _hdrsubsamp): %d",
dstSize, _hdrsubsamp, TJBUFSIZEYUV(_hdrw, _hdrh, _hdrsubsamp));
- } else if (input_fmt == MM_UTIL_JPEG_FMT_RGB888) {
+ } else if (input_fmt == MM_UTIL_COLOR_RGB24) {
dstSize = scaledWidth*scaledHeight*tjPixelSize[TJPF_RGB];
- mm_util_debug("MM_UTIL_JPEG_FMT_RGB888 dstSize: %d _hdrsubsamp:%d", dstSize, _hdrsubsamp);
+ mm_util_debug("MM_UTIL_COLOR_RGB24 dstSize: %d _hdrsubsamp:%d", dstSize, _hdrsubsamp);
}
if ((decoded_data->data = (void *)calloc(1, dstSize)) == NULL) {
mm_util_debug("dstBuf:%p", decoded_data->data);
- if (input_fmt == MM_UTIL_JPEG_FMT_YUV420 || input_fmt == MM_UTIL_JPEG_FMT_YUV422) {
+ if (input_fmt == MM_UTIL_COLOR_YUV420 || input_fmt == MM_UTIL_COLOR_YUV422) {
_tj(tjDecompressToYUV(handle, jpegBuf, jpegSize, decoded_data->data, TD_BU));
- mm_util_debug("MM_UTIL_JPEG_FMT_YUV420, dstBuf: %d", decoded_data->data);
+ mm_util_debug("MM_UTIL_COLOR_YUV420, dstBuf: %d", decoded_data->data);
decoded_data->format = input_fmt;
- } else if (input_fmt == MM_UTIL_JPEG_FMT_RGB888) {
+ } else if (input_fmt == MM_UTIL_COLOR_RGB24) {
_tj(tjDecompress2(handle, jpegBuf, jpegSize, decoded_data->data, scaledWidth, 0, scaledHeight, TJPF_RGB, TD_BU));
- mm_util_debug("MM_UTIL_JPEG_FMT_RGB888, dstBuf: %p", decoded_data->data);
- decoded_data->format = MM_UTIL_JPEG_FMT_RGB888;
+ mm_util_debug("MM_UTIL_COLOR_RGB24, dstBuf: %p", decoded_data->data);
+ decoded_data->format = MM_UTIL_COLOR_RGB24;
} else {
mm_util_error("[%s][%05d] We can't support the IMAGE format");
return;
}
decoded_data->size = dstSize;
- if (input_fmt == MM_UTIL_JPEG_FMT_RGB888) {
+ if (input_fmt == MM_UTIL_COLOR_RGB24) {
decoded_data->width = scaledWidth;
decoded_data->height = scaledHeight;
decoded_data->size = dstSize;
- } else if (input_fmt == MM_UTIL_JPEG_FMT_YUV420 || input_fmt == MM_UTIL_JPEG_FMT_YUV422) {
+ } else if (input_fmt == MM_UTIL_COLOR_YUV420 || input_fmt == MM_UTIL_COLOR_YUV422) {
if (_hdrsubsamp == TJSAMP_422) {
mm_util_debug("_hdrsubsamp == TJSAMP_422", decoded_data->width, _hdrw);
decoded_data->width = MM_JPEG_ROUND_UP_2(_hdrw);
}
}
-static int __mm_image_decode_from_jpeg_file_with_libjpeg_turbo(mm_util_jpeg_yuv_data *decoded_data, const char *pFileName, mm_util_jpeg_yuv_format input_fmt)
+static int __mm_image_decode_from_jpeg_file_with_libjpeg_turbo(mm_util_jpeg_yuv_data *decoded_data, const char *pFileName, mm_util_color_format_e input_fmt)
{
int iErrorCode = MM_UTIL_ERROR_NONE;
tjhandle dhandle = NULL;
return iErrorCode;
}
-static int __mm_image_decode_from_jpeg_memory_with_libjpeg_turbo(mm_util_jpeg_yuv_data *decoded_data, void *src, unsigned int size, mm_util_jpeg_yuv_format input_fmt)
+static int __mm_image_decode_from_jpeg_memory_with_libjpeg_turbo(mm_util_jpeg_yuv_data *decoded_data, void *src, unsigned int size, mm_util_color_format_e input_fmt)
{
int iErrorCode = MM_UTIL_ERROR_NONE;
tjhandle dhandle = NULL;
return iErrorCode;
}
-static void _mm_encode_libjpeg_turbo_compress(tjhandle handle, void *src, unsigned char **dstBuf, unsigned long *dstSize, int w, int h, int jpegQual, int flags, mm_util_jpeg_yuv_format fmt)
+static void _mm_encode_libjpeg_turbo_compress(tjhandle handle, void *src, unsigned char **dstBuf, unsigned long *dstSize, int w, int h, int jpegQual, int flags, mm_util_color_format_e fmt)
{
unsigned char *srcBuf = NULL;
unsigned long jpegSize = 0;
return;
} else {
mm_util_debug("srcBuf: 0x%2x", srcBuf);
- if (fmt == MM_UTIL_JPEG_FMT_RGB888) {
+ if (fmt == MM_UTIL_COLOR_RGB24) {
__initBuf(srcBuf, w, h, TJPF_RGB, flags);
- } else if (fmt == MM_UTIL_JPEG_FMT_YUV420 || fmt == MM_UTIL_JPEG_FMT_YUV422) {
+ } else if (fmt == MM_UTIL_COLOR_YUV420 || fmt == MM_UTIL_COLOR_YUV422) {
__initBuf(srcBuf, w, h, TJPF_GRAY, flags);
} else {
MMUTIL_SAFE_FREE(srcBuf);
if (*dstBuf && *dstSize > 0) memset(*dstBuf, 0, *dstSize);
mm_util_debug("Done.");
*dstSize = TJBUFSIZE(w, h);
- if (fmt == MM_UTIL_JPEG_FMT_RGB888) {
+ if (fmt == MM_UTIL_COLOR_RGB24) {
_tj(tjCompress2(handle, srcBuf, w, 0, h, TJPF_RGB, dstBuf, dstSize, TJPF_RGB, jpegQual, flags));
mm_util_debug("*dstSize: %d", *dstSize);
- } else if (fmt == MM_UTIL_JPEG_FMT_YUV420) {
+ } else if (fmt == MM_UTIL_COLOR_YUV420) {
*dstSize = TJBUFSIZEYUV(w, h, TJSAMP_420);
_tj(tjEncodeYUV2(handle, srcBuf, w, 0, h, TJPF_RGB, *dstBuf, TJSAMP_420, flags));
mm_util_debug("*dstSize: %d \t decode_yuv_subsample: %d TJBUFSIZE(w, h):%d", *dstSize, TJSAMP_420, TJBUFSIZE(w, h));
- } else if (fmt == MM_UTIL_JPEG_FMT_YUV422) {
+ } else if (fmt == MM_UTIL_COLOR_YUV422) {
*dstSize = TJBUFSIZEYUV(w, h, TJSAMP_422);
_tj(tjEncodeYUV2(handle, srcBuf, w, 0, h, TJPF_RGB, *dstBuf, TJSAMP_422, flags));
mm_util_debug("*dstSize: %d \t decode_yuv_subsample: %d TJBUFSIZE(w, h):%d", *dstSize, TJSAMP_422, TJBUFSIZE(w, h));
MMUTIL_SAFE_FREE(srcBuf);
}
-static int __mm_image_encode_to_jpeg_file_with_libjpeg_turbo(const char *filename, void* src, int width, int height, mm_util_jpeg_yuv_format fmt, int quality)
+static int __mm_image_encode_to_jpeg_file_with_libjpeg_turbo(const char *filename, void* src, int width, int height, mm_util_color_format_e fmt, int quality)
{
int iErrorCode = MM_UTIL_ERROR_NONE;
tjhandle chandle = NULL;
return iErrorCode;
}
-static int __mm_image_encode_to_jpeg_memory_with_libjpeg_turbo(void **mem, unsigned int *csize, void *rawdata, int w, int h, mm_util_jpeg_yuv_format fmt, int quality)
+static int __mm_image_encode_to_jpeg_memory_with_libjpeg_turbo(void **mem, unsigned int *csize, void *rawdata, int w, int h, mm_util_color_format_e fmt, int quality)
{
int iErrorCode = MM_UTIL_ERROR_NONE;
tjhandle chandle = NULL;
int TD_BU = 0;
*csize = TJBUFSIZE(w, h);
- if (fmt == MM_UTIL_JPEG_FMT_RGB888) {
- mm_util_debug("MM_UTIL_JPEG_FMT_RGB888 size: %u", *csize);
- } else if (fmt == MM_UTIL_JPEG_FMT_YUV420 || fmt == MM_UTIL_JPEG_FMT_YUV422) {
+ if (fmt == MM_UTIL_COLOR_RGB24) {
+ mm_util_debug("MM_UTIL_COLOR_RGB24 size: %u", *csize);
+ } else if (fmt == MM_UTIL_COLOR_YUV420 || fmt == MM_UTIL_COLOR_YUV422) {
mm_util_debug("TJSAMP_420 ||TJSAMP_422 size: %u", *csize);
} else {
mm_util_error("We can't support the IMAGE format");
longjmp(myerr->setjmp_buffer, 1); /* Return control to the setjmp point */
}
-static int __mm_image_encode_to_jpeg_file_with_libjpeg(const char *pFileName, void *rawdata, int width, int height, mm_util_jpeg_yuv_format fmt, int quality)
+static int __mm_image_encode_to_jpeg_file_with_libjpeg(const char *pFileName, void *rawdata, int width, int height, mm_util_color_format_e fmt, int quality)
{
int iErrorCode = MM_UTIL_ERROR_NONE;
char *realPATH = NULL;
jpeg_stdio_dest(&cinfo, fpWriter);
cinfo.image_width = width;
cinfo.image_height = height;
- if (fmt == MM_UTIL_JPEG_FMT_YUV420 || fmt == MM_UTIL_JPEG_FMT_YUV422 || fmt == MM_UTIL_JPEG_FMT_UYVY) {
+ if (fmt == MM_UTIL_COLOR_YUV420 || fmt == MM_UTIL_COLOR_YUV422 || fmt == MM_UTIL_COLOR_UYVY) {
mm_util_debug("[__mm_image_encode_to_jpeg_file_with_libjpeg] jpeg_stdio_dest for YUV");
mm_util_debug("[Height] %d", height);
_height = MM_JPEG_ROUND_DOWN_16(height);
cinfo.do_fancy_downsampling = FALSE;
cinfo.comp_info[0].h_samp_factor = 2;
- if (fmt == MM_UTIL_JPEG_FMT_YUV420)
+ if (fmt == MM_UTIL_COLOR_YUV420)
cinfo.comp_info[0].v_samp_factor = 2;
- else if (fmt == MM_UTIL_JPEG_FMT_YUV422 || fmt == MM_UTIL_JPEG_FMT_UYVY)
+ else if (fmt == MM_UTIL_COLOR_YUV422 || fmt == MM_UTIL_COLOR_UYVY)
cinfo.comp_info[0].v_samp_factor = 1;
cinfo.comp_info[1].h_samp_factor = 1;
cinfo.comp_info[1].v_samp_factor = 1;
mm_util_debug("jpeg_destroy_compress");
}
- else if (fmt == MM_UTIL_JPEG_FMT_RGB888 || fmt == MM_UTIL_JPEG_FMT_GraySacle || fmt == MM_UTIL_JPEG_FMT_RGBA8888 || fmt == MM_UTIL_JPEG_FMT_BGRA8888 || fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
+ else if (fmt == MM_UTIL_COLOR_RGB24 || fmt == MM_UTIL_COLOR_GRAYSCALE || fmt == MM_UTIL_COLOR_RGBA || fmt == MM_UTIL_COLOR_BGRA || fmt == MM_UTIL_COLOR_ARGB) {
JSAMPROW row_pointer[1];
int iRowStride = 0;
- if (fmt == MM_UTIL_JPEG_FMT_RGB888) {
+ if (fmt == MM_UTIL_COLOR_RGB24) {
cinfo.input_components = 3;
cinfo.in_color_space = JCS_RGB;
mm_util_debug("JCS_RGB");
- } else if (fmt == MM_UTIL_JPEG_FMT_GraySacle) {
+ } else if (fmt == MM_UTIL_COLOR_GRAYSCALE) {
cinfo.input_components = 1; /* one colour component */
cinfo.in_color_space = JCS_GRAYSCALE;
mm_util_debug("JCS_GRAYSCALE");
- } else if (fmt == MM_UTIL_JPEG_FMT_RGBA8888) {
+ } else if (fmt == MM_UTIL_COLOR_RGBA) {
cinfo.input_components = 4; /* one colour component */
cinfo.in_color_space = JCS_EXT_RGBA;
mm_util_debug("JCS_EXT_RGBA");
- } else if (fmt == MM_UTIL_JPEG_FMT_BGRA8888) {
+ } else if (fmt == MM_UTIL_COLOR_BGRA) {
cinfo.input_components = 4;
cinfo.in_color_space = JCS_EXT_BGRA;
mm_util_debug("JCS_EXT_BGRA");
- } else if (fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
+ } else if (fmt == MM_UTIL_COLOR_ARGB) {
cinfo.input_components = 4;
cinfo.in_color_space = JCS_EXT_ARGB;
mm_util_debug("JCS_EXT_ARGB");
mm_util_debug("jpeg_set_quality");
jpeg_start_compress(&cinfo, TRUE);
mm_util_debug("jpeg_start_compress");
- if (fmt == MM_UTIL_JPEG_FMT_RGB888)
+ if (fmt == MM_UTIL_COLOR_RGB24)
iRowStride = width * 3;
- else if (fmt == MM_UTIL_JPEG_FMT_GraySacle)
+ else if (fmt == MM_UTIL_COLOR_GRAYSCALE)
iRowStride = width;
- else if (fmt == MM_UTIL_JPEG_FMT_RGBA8888 || fmt == MM_UTIL_JPEG_FMT_BGRA8888 || fmt == MM_UTIL_JPEG_FMT_ARGB8888)
+ else if (fmt == MM_UTIL_COLOR_RGBA || fmt == MM_UTIL_COLOR_BGRA || fmt == MM_UTIL_COLOR_ARGB)
iRowStride = width * 4;
JSAMPLE *image_buffer = (JSAMPLE *)rawdata;
return iErrorCode;
}
-static int __mm_image_encode_to_jpeg_memory_with_libjpeg(void **mem, unsigned int *csize, void *rawdata, int width, int height, mm_util_jpeg_yuv_format fmt, int quality)
+static int __mm_image_encode_to_jpeg_memory_with_libjpeg(void **mem, unsigned int *csize, void *rawdata, int width, int height, mm_util_color_format_e fmt, int quality)
{
int iErrorCode = MM_UTIL_ERROR_NONE;
jpeg_mem_dest(&cinfo, (unsigned char **)mem, &size);
cinfo.image_width = width;
cinfo.image_height = height;
- if (fmt == MM_UTIL_JPEG_FMT_YUV420 || fmt == MM_UTIL_JPEG_FMT_YUV422 || fmt == MM_UTIL_JPEG_FMT_UYVY) {
+ if (fmt == MM_UTIL_COLOR_YUV420 || fmt == MM_UTIL_COLOR_YUV422 || fmt == MM_UTIL_COLOR_UYVY) {
mm_util_debug("[__mm_image_encode_to_jpeg_file_with_libjpeg] jpeg_stdio_dest for YUV");
_height = MM_JPEG_ROUND_DOWN_16(height);
flag = height - _height;
cinfo.do_fancy_downsampling = FALSE;
cinfo.comp_info[0].h_samp_factor = 2;
- if (fmt == MM_UTIL_JPEG_FMT_YUV420)
+ if (fmt == MM_UTIL_COLOR_YUV420)
cinfo.comp_info[0].v_samp_factor = 2;
- else if (fmt == MM_UTIL_JPEG_FMT_YUV422 || fmt == MM_UTIL_JPEG_FMT_UYVY)
+ else if (fmt == MM_UTIL_COLOR_YUV422 || fmt == MM_UTIL_COLOR_UYVY)
cinfo.comp_info[0].v_samp_factor = 1;
cinfo.comp_info[1].h_samp_factor = 1;
cinfo.comp_info[1].v_samp_factor = 1;
mm_util_debug("Exit jpeg_destroy_compress, mem: %p\t size:%u", *mem, *csize);
}
- else if (fmt == MM_UTIL_JPEG_FMT_RGB888 || fmt == MM_UTIL_JPEG_FMT_GraySacle || fmt == MM_UTIL_JPEG_FMT_RGBA8888 || fmt == MM_UTIL_JPEG_FMT_BGRA8888 || fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
+ else if (fmt == MM_UTIL_COLOR_RGB24 || fmt == MM_UTIL_COLOR_GRAYSCALE || fmt == MM_UTIL_COLOR_RGBA || fmt == MM_UTIL_COLOR_BGRA || fmt == MM_UTIL_COLOR_ARGB) {
JSAMPROW row_pointer[1];
int iRowStride = 0;
- mm_util_debug("MM_UTIL_JPEG_FMT_RGB888");
- if (fmt == MM_UTIL_JPEG_FMT_RGB888) {
+ mm_util_debug("MM_UTIL_COLOR_RGB24");
+ if (fmt == MM_UTIL_COLOR_RGB24) {
cinfo.input_components = 3;
cinfo.in_color_space = JCS_RGB;
mm_util_debug("JCS_RGB");
- } else if (fmt == MM_UTIL_JPEG_FMT_GraySacle) {
+ } else if (fmt == MM_UTIL_COLOR_GRAYSCALE) {
cinfo.input_components = 1; /* one colour component */
cinfo.in_color_space = JCS_GRAYSCALE;
mm_util_debug("JCS_GRAYSCALE");
- } else if (fmt == MM_UTIL_JPEG_FMT_RGBA8888) {
+ } else if (fmt == MM_UTIL_COLOR_RGBA) {
cinfo.input_components = 4;
cinfo.in_color_space = JCS_EXT_RGBA;
mm_util_debug("JCS_EXT_RGBA");
- } else if (fmt == MM_UTIL_JPEG_FMT_BGRA8888) {
+ } else if (fmt == MM_UTIL_COLOR_BGRA) {
cinfo.input_components = 4;
cinfo.in_color_space = JCS_EXT_BGRA;
mm_util_debug("JCS_EXT_BGRA");
- } else if (fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
+ } else if (fmt == MM_UTIL_COLOR_ARGB) {
cinfo.input_components = 4;
cinfo.in_color_space = JCS_EXT_ARGB;
mm_util_debug("JCS_EXT_ARGB");
mm_util_debug("jpeg_set_quality");
jpeg_start_compress(&cinfo, TRUE);
mm_util_debug("jpeg_start_compress");
- if (fmt == MM_UTIL_JPEG_FMT_RGB888)
+ if (fmt == MM_UTIL_COLOR_RGB24)
iRowStride = width * 3;
- else if (fmt == MM_UTIL_JPEG_FMT_GraySacle)
+ else if (fmt == MM_UTIL_COLOR_GRAYSCALE)
iRowStride = width;
- else if (fmt == MM_UTIL_JPEG_FMT_RGBA8888 || fmt == MM_UTIL_JPEG_FMT_BGRA8888 || fmt == MM_UTIL_JPEG_FMT_ARGB8888)
+ else if (fmt == MM_UTIL_COLOR_RGBA || fmt == MM_UTIL_COLOR_BGRA || fmt == MM_UTIL_COLOR_ARGB)
iRowStride = width * 4;
JSAMPLE *image_buffer = (JSAMPLE *)rawdata;
return iErrorCode;
}
-static int __mm_image_decode_from_jpeg_file_with_libjpeg(mm_util_jpeg_yuv_data *decoded_data, const char *pFileName, mm_util_jpeg_yuv_format input_fmt, mm_util_jpeg_decode_downscale downscale)
+static int __mm_image_decode_from_jpeg_file_with_libjpeg(mm_util_jpeg_yuv_data *decoded_data, const char *pFileName, mm_util_color_format_e input_fmt, mm_util_jpeg_decode_downscale downscale)
{
int iErrorCode = MM_UTIL_ERROR_NONE;
FILE *infile = NULL;
dinfo.dct_method = JDCT_FASTEST;
/* set parameters for decompression */
- if (input_fmt == MM_UTIL_JPEG_FMT_RGB888) {
+ if (input_fmt == MM_UTIL_COLOR_RGB24) {
dinfo.out_color_space = JCS_RGB;
mm_util_debug("cinfo.out_color_space = JCS_RGB");
- } else if (input_fmt == MM_UTIL_JPEG_FMT_YUV420 || input_fmt == MM_UTIL_JPEG_FMT_YUV422 || input_fmt == MM_UTIL_JPEG_FMT_UYVY) {
+ } else if (input_fmt == MM_UTIL_COLOR_YUV420 || input_fmt == MM_UTIL_COLOR_YUV422 || input_fmt == MM_UTIL_COLOR_UYVY) {
dinfo.out_color_space = JCS_YCbCr;
mm_util_debug("cinfo.out_color_space = JCS_YCbCr");
- } else if (input_fmt == MM_UTIL_JPEG_FMT_GraySacle) {
+ } else if (input_fmt == MM_UTIL_COLOR_GRAYSCALE) {
dinfo.out_color_space = JCS_GRAYSCALE;
mm_util_debug("cinfo.out_color_space = JCS_GRAYSCALE");
- } else if (input_fmt == MM_UTIL_JPEG_FMT_RGBA8888) {
+ } else if (input_fmt == MM_UTIL_COLOR_RGBA) {
dinfo.out_color_space = JCS_EXT_RGBA;
mm_util_debug("cinfo.out_color_space = JCS_EXT_RGBA");
- } else if (input_fmt == MM_UTIL_JPEG_FMT_BGRA8888) {
+ } else if (input_fmt == MM_UTIL_COLOR_BGRA) {
dinfo.out_color_space = JCS_EXT_BGRA;
mm_util_debug("cinfo.out_color_space = JCS_EXT_BGRA");
- } else if (input_fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
+ } else if (input_fmt == MM_UTIL_COLOR_ARGB) {
dinfo.out_color_space = JCS_EXT_ARGB;
mm_util_debug("cinfo.out_color_space = JCS_EXT_ARGB");
}
jpeg_start_decompress(&dinfo);
/* byte-align for YUV format */
- if (input_fmt == MM_UTIL_JPEG_FMT_YUV420 || input_fmt == MM_UTIL_JPEG_FMT_YUV422) {
+ if (input_fmt == MM_UTIL_COLOR_YUV420 || input_fmt == MM_UTIL_COLOR_YUV422) {
if (dinfo.output_width % 2 != 0)
dinfo.output_width = MM_JPEG_ROUND_DOWN_2(dinfo.output_width);
if (dinfo.output_height % 2 != 0)
/* Make a one-row-high sample array that will go away when done with image */
buffer = (*dinfo.mem->alloc_sarray) ((j_common_ptr) &dinfo, JPOOL_IMAGE, row_stride, 1);
- mm_util_debug("JPOOL_IMAGE BUFFER");
+ mm_util_debug("JPOOL_IMAGE BUFFER (input_fmt: %d)", input_fmt);
decoded_data->width = dinfo.output_width;
decoded_data->height = dinfo.output_height;
- if (input_fmt == MM_UTIL_JPEG_FMT_RGB888 || input_fmt == MM_UTIL_JPEG_FMT_RGBA8888 || input_fmt == MM_UTIL_JPEG_FMT_BGRA8888 || input_fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
+ if (input_fmt == MM_UTIL_COLOR_RGB24 || input_fmt == MM_UTIL_COLOR_RGBA || input_fmt == MM_UTIL_COLOR_BGRA || input_fmt == MM_UTIL_COLOR_ARGB) {
decoded_data->size = dinfo.output_height * row_stride;
- } else if (input_fmt == MM_UTIL_JPEG_FMT_YUV420) {
+ } else if (input_fmt == MM_UTIL_COLOR_YUV420) {
decoded_data->size = dinfo.output_height * row_stride / 2;
- } else if (input_fmt == MM_UTIL_JPEG_FMT_YUV422 || input_fmt == MM_UTIL_JPEG_FMT_UYVY) {
+ } else if (input_fmt == MM_UTIL_COLOR_YUV422 || input_fmt == MM_UTIL_COLOR_UYVY) {
decoded_data->size = dinfo.output_height * dinfo.output_width * 2;
- } else if (input_fmt == MM_UTIL_JPEG_FMT_GraySacle) {
+ } else if (input_fmt == MM_UTIL_COLOR_GRAYSCALE) {
decoded_data->size = dinfo.output_height * dinfo.output_width;
} else{
jpeg_finish_decompress(&dinfo);
}
mm_util_debug("decoded_data->data");
- if (input_fmt == MM_UTIL_JPEG_FMT_YUV420 || input_fmt == MM_UTIL_JPEG_FMT_YUV422 || input_fmt == MM_UTIL_JPEG_FMT_UYVY) {
+ if (input_fmt == MM_UTIL_COLOR_YUV420 || input_fmt == MM_UTIL_COLOR_YUV422 || input_fmt == MM_UTIL_COLOR_UYVY) {
image = decoded_data->data;
u_image = image + (dinfo.output_width * dinfo.output_height);
v_image = u_image + (dinfo.output_width*dinfo.output_height) / 4;
v_image += dinfo.output_width / 2;
}
}
- } else if (input_fmt == MM_UTIL_JPEG_FMT_RGB888 || input_fmt == MM_UTIL_JPEG_FMT_GraySacle || input_fmt == MM_UTIL_JPEG_FMT_RGBA8888 || input_fmt == MM_UTIL_JPEG_FMT_BGRA8888 || input_fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
+ } else if (input_fmt == MM_UTIL_COLOR_RGB24 || input_fmt == MM_UTIL_COLOR_GRAYSCALE || input_fmt == MM_UTIL_COLOR_RGBA || input_fmt == MM_UTIL_COLOR_BGRA || input_fmt == MM_UTIL_COLOR_ARGB) {
int state = 0;
/* while (scan lines remain to be read) jpeg_read_scanlines(...); */
while (dinfo.output_scanline < dinfo.output_height) {
return iErrorCode;
}
-static int __mm_image_decode_from_jpeg_memory_with_libjpeg(mm_util_jpeg_yuv_data *decoded_data, void *src, unsigned int size, mm_util_jpeg_yuv_format input_fmt, mm_util_jpeg_decode_downscale downscale)
+static int __mm_image_decode_from_jpeg_memory_with_libjpeg(mm_util_jpeg_yuv_data *decoded_data, void *src, unsigned int size, mm_util_color_format_e input_fmt, mm_util_jpeg_decode_downscale downscale)
{
int iErrorCode = MM_UTIL_ERROR_NONE;
struct jpeg_decompress_struct dinfo;
dinfo.dct_method = JDCT_FASTEST;
/* set parameters for decompression */
- if (input_fmt == MM_UTIL_JPEG_FMT_RGB888) {
+ if (input_fmt == MM_UTIL_COLOR_RGB24) {
dinfo.out_color_space = JCS_RGB;
mm_util_debug("cinfo.out_color_space = JCS_RGB");
- } else if (input_fmt == MM_UTIL_JPEG_FMT_YUV420 || input_fmt == MM_UTIL_JPEG_FMT_YUV422 || input_fmt == MM_UTIL_JPEG_FMT_UYVY) {
+ } else if (input_fmt == MM_UTIL_COLOR_YUV420 || input_fmt == MM_UTIL_COLOR_YUV422 || input_fmt == MM_UTIL_COLOR_UYVY) {
dinfo.out_color_space = JCS_YCbCr;
mm_util_debug("cinfo.out_color_space = JCS_YCbCr");
- } else if (input_fmt == MM_UTIL_JPEG_FMT_GraySacle) {
+ } else if (input_fmt == MM_UTIL_COLOR_GRAYSCALE) {
dinfo.out_color_space = JCS_GRAYSCALE;
mm_util_debug("cinfo.out_color_space = JCS_GRAYSCALE");
- } else if (input_fmt == MM_UTIL_JPEG_FMT_RGBA8888) {
+ } else if (input_fmt == MM_UTIL_COLOR_RGBA) {
dinfo.out_color_space = JCS_EXT_RGBA;
mm_util_debug("cinfo.out_color_space = JCS_EXT_RGBA");
- } else if (input_fmt == MM_UTIL_JPEG_FMT_BGRA8888) {
+ } else if (input_fmt == MM_UTIL_COLOR_BGRA) {
dinfo.out_color_space = JCS_EXT_BGRA;
mm_util_debug("cinfo.out_color_space = JCS_EXT_BGRA");
- } else if (input_fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
+ } else if (input_fmt == MM_UTIL_COLOR_ARGB) {
dinfo.out_color_space = JCS_EXT_ARGB;
mm_util_debug("cinfo.out_color_space = JCS_EXT_ARGB");
}
mm_util_debug("jpeg_start_decompress");
/* byte-align for YUV format */
- if (input_fmt == MM_UTIL_JPEG_FMT_YUV420 || input_fmt == MM_UTIL_JPEG_FMT_YUV422) {
+ if (input_fmt == MM_UTIL_COLOR_YUV420 || input_fmt == MM_UTIL_COLOR_YUV422) {
if (dinfo.output_width % 2 != 0)
dinfo.output_width = MM_JPEG_ROUND_DOWN_2(dinfo.output_width);
if (dinfo.output_height % 2 != 0)
/* Make a one-row-high sample array that will go away when done with image */
buffer = (*dinfo.mem->alloc_sarray) ((j_common_ptr) &dinfo, JPOOL_IMAGE, row_stride, 1);
- mm_util_debug("JPOOL_IMAGE BUFFER");
+ mm_util_debug("JPOOL_IMAGE BUFFER (input_fmt: %d)", input_fmt);
decoded_data->width = dinfo.output_width;
decoded_data->height = dinfo.output_height;
- if (input_fmt == MM_UTIL_JPEG_FMT_RGB888 || input_fmt == MM_UTIL_JPEG_FMT_RGBA8888 || input_fmt == MM_UTIL_JPEG_FMT_BGRA8888 || input_fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
+ if (input_fmt == MM_UTIL_COLOR_RGB24 || input_fmt == MM_UTIL_COLOR_RGBA || input_fmt == MM_UTIL_COLOR_BGRA || input_fmt == MM_UTIL_COLOR_ARGB) {
decoded_data->size = dinfo.output_height * row_stride;
- } else if (input_fmt == MM_UTIL_JPEG_FMT_YUV420) {
+ } else if (input_fmt == MM_UTIL_COLOR_YUV420) {
decoded_data->size = dinfo.output_height * row_stride / 2;
- } else if (input_fmt == MM_UTIL_JPEG_FMT_YUV422 || input_fmt == MM_UTIL_JPEG_FMT_UYVY) {
+ } else if (input_fmt == MM_UTIL_COLOR_YUV422 || input_fmt == MM_UTIL_COLOR_UYVY) {
decoded_data->size = dinfo.output_height * dinfo.output_width * 2;
- } else if (input_fmt == MM_UTIL_JPEG_FMT_GraySacle) {
+ } else if (input_fmt == MM_UTIL_COLOR_GRAYSCALE) {
decoded_data->size = dinfo.output_height * dinfo.output_width;
} else{
jpeg_finish_decompress(&dinfo);
mm_util_debug("decoded_data->data");
/* while (scan lines remain to be read) jpeg_read_scanlines(...); */
- if (input_fmt == MM_UTIL_JPEG_FMT_YUV420 || input_fmt == MM_UTIL_JPEG_FMT_YUV422 || input_fmt == MM_UTIL_JPEG_FMT_UYVY) {
+ if (input_fmt == MM_UTIL_COLOR_YUV420 || input_fmt == MM_UTIL_COLOR_YUV422 || input_fmt == MM_UTIL_COLOR_UYVY) {
image = decoded_data->data;
u_image = image + (dinfo.output_width * dinfo.output_height);
v_image = u_image + (dinfo.output_width*dinfo.output_height)/4;
v_image += dinfo.output_width / 2;
}
}
- } else if (input_fmt == MM_UTIL_JPEG_FMT_RGB888 || input_fmt == MM_UTIL_JPEG_FMT_GraySacle || input_fmt == MM_UTIL_JPEG_FMT_RGBA8888 || input_fmt == MM_UTIL_JPEG_FMT_BGRA8888 || input_fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
+ } else if (input_fmt == MM_UTIL_COLOR_RGB24 || input_fmt == MM_UTIL_COLOR_GRAYSCALE || input_fmt == MM_UTIL_COLOR_RGBA || input_fmt == MM_UTIL_COLOR_BGRA || input_fmt == MM_UTIL_COLOR_ARGB) {
int state = 0;
while (dinfo.output_scanline < dinfo.output_height) {
/* jpeg_read_scanlines expects an array of pointers to scanlines. Here the array is only one element long, but you could ask formore than one scanline at a time if that's more convenient. */
return iErrorCode;
}
#endif
-int mm_util_jpeg_encode_to_file(const char *filename, void* src, int width, int height, mm_util_jpeg_yuv_format fmt, int quality)
+int mm_util_jpeg_encode_to_file(const char *filename, void* src, int width, int height, mm_util_color_format_e fmt, int quality)
{
int ret = MM_UTIL_ERROR_NONE;
return MM_UTIL_ERROR_INVALID_PARAMETER;
}
- if ((fmt < MM_UTIL_JPEG_FMT_YUV420) || (fmt > MM_UTIL_JPEG_FMT_ARGB8888)) {
+ if (IS_MM_UTIL_COLOR_FORMAT(fmt) == FALSE) {
mm_util_error("#ERROR# fmt value [%d]", fmt);
return MM_UTIL_ERROR_INVALID_PARAMETER;
}
ret = __mm_image_encode_to_jpeg_file_with_libjpeg_turbo(filename, src, width, height, fmt, quality);
#else
mm_util_debug("#START# LIBJPEG");
- if (fmt == MM_UTIL_JPEG_FMT_NV12) {
+ if (fmt == MM_UTIL_COLOR_NV12) {
unsigned int dst_size = 0;
- ret = mm_util_get_image_size(MM_UTIL_IMG_FMT_NV12, (unsigned int)width, (unsigned int)height, &dst_size);
+ ret = mm_util_get_image_size(MM_UTIL_COLOR_NV12, (unsigned int)width, (unsigned int)height, &dst_size);
unsigned char *dst = NULL;
dst = calloc(1, dst_size);
if (dst) {
- ret = mm_util_convert_colorspace(src, width, height, MM_UTIL_IMG_FMT_NV12, dst, MM_UTIL_IMG_FMT_YUV420);
- ret = __mm_image_encode_to_jpeg_file_with_libjpeg(filename, dst, width, height, MM_UTIL_JPEG_FMT_YUV420, quality);
+ ret = mm_util_convert_colorspace(src, width, height, MM_UTIL_COLOR_NV12, dst, MM_UTIL_COLOR_YUV420);
+ ret = __mm_image_encode_to_jpeg_file_with_libjpeg(filename, dst, width, height, MM_UTIL_COLOR_YUV420, quality);
MMUTIL_SAFE_FREE(dst);
} else {
return MM_UTIL_ERROR_OUT_OF_MEMORY;
}
- } else if (fmt == MM_UTIL_JPEG_FMT_NV21) {
+ } else if (fmt == MM_UTIL_COLOR_NV21) {
return MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
} else {
ret = __mm_image_encode_to_jpeg_file_with_libjpeg(filename, src, width, height, fmt, quality);
return ret;
}
-int mm_util_jpeg_encode_to_memory(void **mem, unsigned int *size, void* src, int width, int height, mm_util_jpeg_yuv_format fmt, int quality)
+int mm_util_jpeg_encode_to_memory(void **mem, unsigned int *size, void* src, int width, int height, mm_util_color_format_e fmt, int quality)
{
int ret = MM_UTIL_ERROR_NONE;
return MM_UTIL_ERROR_INVALID_PARAMETER;
}
- if ((fmt < MM_UTIL_JPEG_FMT_YUV420) || (fmt > MM_UTIL_JPEG_FMT_ARGB8888)) {
+ if (IS_MM_UTIL_COLOR_FORMAT(fmt) == FALSE) {
mm_util_error("#ERROR# fmt value [%d]", fmt);
return MM_UTIL_ERROR_INVALID_PARAMETER;
}
ret = __mm_image_encode_to_jpeg_memory_with_libjpeg_turbo(mem, size, src, width, height, fmt, quality);
#else /* LIBJPEG_TURBO */
mm_util_debug("#START# libjpeg");
- if (fmt == MM_UTIL_JPEG_FMT_NV12) {
+ if (fmt == MM_UTIL_COLOR_NV12) {
unsigned int dst_size = 0;
- ret = mm_util_get_image_size(MM_UTIL_IMG_FMT_NV12, (unsigned int)width, (unsigned int)height, &dst_size);
+ ret = mm_util_get_image_size(MM_UTIL_COLOR_NV12, (unsigned int)width, (unsigned int)height, &dst_size);
unsigned char *dst = NULL;
dst = calloc(1, dst_size);
if (dst) {
- ret = mm_util_convert_colorspace(src, width, height, MM_UTIL_IMG_FMT_NV12, dst, MM_UTIL_IMG_FMT_YUV420);
- ret = __mm_image_encode_to_jpeg_memory_with_libjpeg(mem, size, dst, width, height, MM_UTIL_JPEG_FMT_YUV420, quality);
+ ret = mm_util_convert_colorspace(src, width, height, MM_UTIL_COLOR_NV12, dst, MM_UTIL_COLOR_YUV420);
+ ret = __mm_image_encode_to_jpeg_memory_with_libjpeg(mem, size, dst, width, height, MM_UTIL_COLOR_YUV420, quality);
MMUTIL_SAFE_FREE(dst);
} else {
return MM_UTIL_ERROR_OUT_OF_MEMORY;
}
- } else if (fmt == MM_UTIL_JPEG_FMT_NV21) {
+ } else if (fmt == MM_UTIL_COLOR_NV21) {
return MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
} else {
ret = __mm_image_encode_to_jpeg_memory_with_libjpeg(mem, size, src, width, height, fmt, quality);
return ret;
}
-int mm_util_decode_from_jpeg_file(mm_util_jpeg_yuv_data *decoded, const char *filename, mm_util_jpeg_yuv_format fmt)
+int mm_util_decode_from_jpeg_file(mm_util_jpeg_yuv_data *decoded, const char *filename, mm_util_color_format_e fmt)
{
int ret = MM_UTIL_ERROR_NONE;
return MM_UTIL_ERROR_INVALID_PARAMETER;
}
- if ((fmt < MM_UTIL_JPEG_FMT_YUV420) || (fmt > MM_UTIL_JPEG_FMT_ARGB8888)) {
+ if (IS_MM_UTIL_COLOR_FORMAT(fmt) == FALSE) {
mm_util_error("#ERROR# fmt value [%d]", fmt);
return MM_UTIL_ERROR_INVALID_PARAMETER;
}
mm_util_debug("#START# LIBJPEG_TURBO");
ret = __mm_image_decode_from_jpeg_file_with_libjpeg_turbo(decoded, filename, fmt);
#else
- mm_util_debug("#START# libjpeg");
- if (fmt == MM_UTIL_JPEG_FMT_NV12) {
+ mm_util_debug("#START# libjpeg(fmt:%d)", fmt);
+ if (fmt == MM_UTIL_COLOR_NV12) {
unsigned int dst_size = 0;
- ret = __mm_image_decode_from_jpeg_file_with_libjpeg(decoded, filename, MM_UTIL_IMG_FMT_YUV420, MM_UTIL_JPEG_DECODE_DOWNSCALE_1_1);
+ ret = __mm_image_decode_from_jpeg_file_with_libjpeg(decoded, filename, MM_UTIL_COLOR_YUV420, MM_UTIL_JPEG_DECODE_DOWNSCALE_1_1);
if (ret == MM_UTIL_ERROR_NONE) {
int err = MM_UTIL_ERROR_NONE;
- err = mm_util_get_image_size(MM_UTIL_IMG_FMT_NV12, decoded->width, decoded->height, &dst_size);
+ err = mm_util_get_image_size(MM_UTIL_COLOR_NV12, decoded->width, decoded->height, &dst_size);
if (err != MM_UTIL_ERROR_NONE)
mm_util_error("fail mm_util_get_image_size");
unsigned char *dst = NULL;
dst = calloc(1, dst_size);
if (dst) {
- ret = mm_util_convert_colorspace(decoded->data, decoded->width, decoded->height, MM_UTIL_IMG_FMT_YUV420, dst, MM_UTIL_IMG_FMT_NV12);
+ ret = mm_util_convert_colorspace(decoded->data, decoded->width, decoded->height, MM_UTIL_COLOR_YUV420, dst, MM_UTIL_COLOR_NV12);
MMUTIL_SAFE_FREE(decoded->data);
decoded->data = calloc(1, dst_size);
if (decoded->data == NULL) {
return ret;
}
-int mm_util_decode_from_jpeg_memory(mm_util_jpeg_yuv_data *decoded, void *src, unsigned int size, mm_util_jpeg_yuv_format fmt)
+int mm_util_decode_from_jpeg_memory(mm_util_jpeg_yuv_data *decoded, void *src, unsigned int size, mm_util_color_format_e fmt)
{
int ret = MM_UTIL_ERROR_NONE;
return MM_UTIL_ERROR_INVALID_PARAMETER;
}
- if ((fmt < MM_UTIL_JPEG_FMT_YUV420) || (fmt > MM_UTIL_JPEG_FMT_ARGB8888)) {
+ if (IS_MM_UTIL_COLOR_FORMAT(fmt) == FALSE) {
mm_util_error("#ERROR# fmt value [%d]", fmt);
return MM_UTIL_ERROR_INVALID_PARAMETER;
}
ret = __mm_image_decode_from_jpeg_memory_with_libjpeg_turbo(decoded, src, size, fmt);
#else
mm_util_debug("#START# libjpeg");
- if (fmt == MM_UTIL_JPEG_FMT_NV12) {
+ if (fmt == MM_UTIL_COLOR_NV12) {
unsigned int dst_size = 0;
unsigned char *dst = NULL;
- ret = __mm_image_decode_from_jpeg_memory_with_libjpeg(decoded, src, size, MM_UTIL_IMG_FMT_YUV420, MM_UTIL_JPEG_DECODE_DOWNSCALE_1_1);
+ ret = __mm_image_decode_from_jpeg_memory_with_libjpeg(decoded, src, size, MM_UTIL_COLOR_YUV420, MM_UTIL_JPEG_DECODE_DOWNSCALE_1_1);
if (ret == MM_UTIL_ERROR_NONE) {
int err = MM_UTIL_ERROR_NONE;
- err = mm_util_get_image_size(MM_UTIL_IMG_FMT_NV12, decoded->width, decoded->height, &dst_size);
+ err = mm_util_get_image_size(MM_UTIL_COLOR_NV12, decoded->width, decoded->height, &dst_size);
if (err != MM_UTIL_ERROR_NONE)
mm_util_error("fail mm_util_get_image_size");
dst = calloc(1, dst_size);
if (dst) {
- ret = mm_util_convert_colorspace(decoded->data, decoded->width, decoded->height, MM_UTIL_IMG_FMT_YUV420, dst, MM_UTIL_IMG_FMT_NV12);
+ ret = mm_util_convert_colorspace(decoded->data, decoded->width, decoded->height, MM_UTIL_COLOR_YUV420, dst, MM_UTIL_COLOR_NV12);
MMUTIL_SAFE_FREE(decoded->data);
decoded->data = calloc(1, dst_size);
if (decoded->data == NULL) {
return ret;
}
-int mm_util_decode_from_jpeg_file_with_downscale(mm_util_jpeg_yuv_data *decoded, const char *filename, mm_util_jpeg_yuv_format fmt, mm_util_jpeg_decode_downscale downscale)
+int mm_util_decode_from_jpeg_file_with_downscale(mm_util_jpeg_yuv_data *decoded, const char *filename, mm_util_color_format_e fmt, mm_util_jpeg_decode_downscale downscale)
{
int ret = MM_UTIL_ERROR_NONE;
return MM_UTIL_ERROR_INVALID_PARAMETER;
}
- if ((fmt < MM_UTIL_JPEG_FMT_YUV420) || (fmt > MM_UTIL_JPEG_FMT_ARGB8888)) {
+ if (IS_MM_UTIL_COLOR_FORMAT(fmt) == FALSE) {
mm_util_error("#ERROR# fmt value [%d]", fmt);
return MM_UTIL_ERROR_INVALID_PARAMETER;
}
ret = __mm_image_decode_from_jpeg_file_with_libjpeg_turbo(decoded, filename, fmt);
#else
mm_util_debug("#START# libjpeg");
- if (fmt == MM_UTIL_JPEG_FMT_NV12) {
+ if (fmt == MM_UTIL_COLOR_NV12) {
unsigned int dst_size = 0;
- ret = __mm_image_decode_from_jpeg_file_with_libjpeg(decoded, filename, MM_UTIL_IMG_FMT_YUV420, downscale);
+ ret = __mm_image_decode_from_jpeg_file_with_libjpeg(decoded, filename, MM_UTIL_COLOR_YUV420, downscale);
if (ret == MM_UTIL_ERROR_NONE) {
int err = MM_UTIL_ERROR_NONE;
- err = mm_util_get_image_size(MM_UTIL_IMG_FMT_NV12, decoded->width, decoded->height, &dst_size);
+ err = mm_util_get_image_size(MM_UTIL_COLOR_NV12, decoded->width, decoded->height, &dst_size);
if (err != MM_UTIL_ERROR_NONE)
mm_util_error("fail mm_util_get_image_size");
unsigned char *dst = NULL;
dst = calloc(1, dst_size);
if (dst) {
- ret = mm_util_convert_colorspace(decoded->data, decoded->width, decoded->height, MM_UTIL_IMG_FMT_YUV420, dst, MM_UTIL_IMG_FMT_NV12);
+ ret = mm_util_convert_colorspace(decoded->data, decoded->width, decoded->height, MM_UTIL_COLOR_YUV420, dst, MM_UTIL_COLOR_NV12);
MMUTIL_SAFE_FREE(decoded->data);
decoded->data = calloc(1, dst_size);
if (decoded->data == NULL) {
return ret;
}
-int mm_util_decode_from_jpeg_memory_with_downscale(mm_util_jpeg_yuv_data *decoded, void *src, unsigned int size, mm_util_jpeg_yuv_format fmt, mm_util_jpeg_decode_downscale downscale)
+int mm_util_decode_from_jpeg_memory_with_downscale(mm_util_jpeg_yuv_data *decoded, void *src, unsigned int size, mm_util_color_format_e fmt, mm_util_jpeg_decode_downscale downscale)
{
int ret = MM_UTIL_ERROR_NONE;
return MM_UTIL_ERROR_INVALID_PARAMETER;
}
- if ((fmt < MM_UTIL_JPEG_FMT_YUV420) || (fmt > MM_UTIL_JPEG_FMT_ARGB8888)) {
+ if (IS_MM_UTIL_COLOR_FORMAT(fmt) == FALSE) {
mm_util_error("#ERROR# fmt value [%d]", fmt);
return MM_UTIL_ERROR_INVALID_PARAMETER;
}
ret = __mm_image_decode_from_jpeg_memory_with_libjpeg_turbo(decoded, src, size, fmt);
#else
mm_util_debug("#START# libjpeg");
- if (fmt == MM_UTIL_JPEG_FMT_NV12) {
+ if (fmt == MM_UTIL_COLOR_NV12) {
unsigned int dst_size = 0;
unsigned char *dst = NULL;
- ret = __mm_image_decode_from_jpeg_memory_with_libjpeg(decoded, src, size, MM_UTIL_IMG_FMT_YUV420, downscale);
+ ret = __mm_image_decode_from_jpeg_memory_with_libjpeg(decoded, src, size, MM_UTIL_COLOR_YUV420, downscale);
if (ret == MM_UTIL_ERROR_NONE) {
int err = MM_UTIL_ERROR_NONE;
- err = mm_util_get_image_size(MM_UTIL_IMG_FMT_NV12, decoded->width, decoded->height, &dst_size);
+ err = mm_util_get_image_size(MM_UTIL_COLOR_NV12, decoded->width, decoded->height, &dst_size);
if (err != MM_UTIL_ERROR_NONE)
mm_util_error("fail mm_util_get_image_size");
dst = calloc(1, dst_size);
if (dst) {
- ret = mm_util_convert_colorspace(decoded->data, decoded->width, decoded->height, MM_UTIL_IMG_FMT_YUV420, dst, MM_UTIL_IMG_FMT_NV12);
+ ret = mm_util_convert_colorspace(decoded->data, decoded->width, decoded->height, MM_UTIL_COLOR_YUV420, dst, MM_UTIL_COLOR_NV12);
MMUTIL_SAFE_FREE(decoded->data);
decoded->data = calloc(1, dst_size);
if (decoded->data == NULL) {
void *dst = NULL;
mm_util_jpeg_yuv_data decoded_data = {0,};
- mm_util_jpeg_yuv_format fmt; /* = MM_UTIL_JPEG_FMT_RGB888; */
+ mm_util_color_format_e fmt; /* = MM_UTIL_COLOR_RGB24; */
mm_util_jpeg_decode_downscale downscale;
if (argc < 2) {
fprintf(stderr, "\t##Decoded data##: %p\t width: %d\t height:%d\t size: %d\n", decoded_data.data, decoded_data.width, decoded_data.height, decoded_data.size);
char filename[BUFFER_SIZE] = {0, };
memset(filename, 0, BUFFER_SIZE);
- if (fmt == MM_UTIL_JPEG_FMT_RGB888 || fmt == MM_UTIL_JPEG_FMT_RGBA8888 || fmt == MM_UTIL_JPEG_FMT_BGRA8888 || fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
+ if (fmt == MM_UTIL_COLOR_RGB24 || fmt == MM_UTIL_COLOR_RGBA || fmt == MM_UTIL_COLOR_BGRA || fmt == MM_UTIL_COLOR_ARGB) {
snprintf(filename, BUFFER_SIZE, "%s%s", DECODE_RESULT_PATH, "rgb");
- } else if ((fmt == MM_UTIL_JPEG_FMT_YUV420) ||
- (fmt == MM_UTIL_JPEG_FMT_YUV422) ||
- (fmt == MM_UTIL_JPEG_FMT_NV12) ||
- (fmt == MM_UTIL_JPEG_FMT_NV21) ||
- (fmt == MM_UTIL_JPEG_FMT_NV16) ||
- (fmt == MM_UTIL_JPEG_FMT_NV61)) {
+ } else if ((fmt == MM_UTIL_COLOR_YUV420) ||
+ (fmt == MM_UTIL_COLOR_YUV422) ||
+ (fmt == MM_UTIL_COLOR_NV12) ||
+ (fmt == MM_UTIL_COLOR_NV21) ||
+ (fmt == MM_UTIL_COLOR_NV16) ||
+ (fmt == MM_UTIL_COLOR_NV61)) {
snprintf(filename, BUFFER_SIZE, "%s%s", DECODE_RESULT_PATH, "yuv");
}
_write_file(filename, decoded_data.data, decoded_data.size);
typedef void *mm_util_image_h;
/**
- * Image formats
- */
-typedef enum {
- MM_UTIL_IMG_FMT_RGB888, /**< RGB888 pixel format */
- MM_UTIL_IMG_FMT_ARGB8888, /**< ARGB8888 pixel format */
- MM_UTIL_IMG_FMT_BGRA8888, /**< BGRA8888 pixel format */
- MM_UTIL_IMG_FMT_RGBA8888, /**< RGBA8888 pixel format */
- MM_UTIL_IMG_FMT_NUM, /**< Number of image formats */
-} mm_util_magick_format;
-
-/**
* Image rotation types
*/
typedef enum {
IMG_CODEC_DRM = (1 << 8),
} mm_util_img_codec_type;
-int mm_util_create_handle(mm_util_image_h *handle, const unsigned char *buffer, unsigned int width, unsigned int height, size_t size, mm_util_magick_format format);
+int mm_util_create_handle(mm_util_image_h *handle, const unsigned char *buffer, unsigned int width, unsigned int height, size_t size, mm_util_color_format_e format);
/*You must release buffer using free().*/
-int mm_util_get_image(mm_util_image_h handle, unsigned char **buffer, unsigned int *width, unsigned int *height, size_t *size, mm_util_magick_format *format);
+int mm_util_get_image(mm_util_image_h handle, unsigned char **buffer, unsigned int *width, unsigned int *height, size_t *size, mm_util_color_format_e *format);
int mm_util_destroy_handle(mm_util_image_h handle);
int mm_util_rotate_B_B(mm_util_image_h src_handle, mm_util_magick_rotate_type angle, mm_util_image_h *dst_handle);
int mm_util_rotate_B_P(mm_util_image_h src_handle, mm_util_magick_rotate_type angle, const char *dst_path);
-int mm_util_rotate_P_B(const char *src_path, mm_util_magick_rotate_type angle, mm_util_magick_format req_format, mm_util_image_h *dst_handle);
+int mm_util_rotate_P_B(const char *src_path, mm_util_magick_rotate_type angle, mm_util_color_format_e req_format, mm_util_image_h *dst_handle);
int mm_util_rotate_P_P(const char *src_path, mm_util_magick_rotate_type angle, const char *dst_path);
int mm_util_resize_B_B(mm_util_image_h src_handle, unsigned int req_width, unsigned int req_height, mm_util_image_h *dst_handle);
int mm_util_resize_B_P(mm_util_image_h src_handle, unsigned int req_width, unsigned int req_height, const char *dst_path);
-int mm_util_resize_P_B(const char *src_path, unsigned int req_width, unsigned int req_height, mm_util_magick_format req_format, mm_util_image_h *dst_handle);
+int mm_util_resize_P_B(const char *src_path, unsigned int req_width, unsigned int req_height, mm_util_color_format_e req_format, mm_util_image_h *dst_handle);
int mm_util_resize_P_P(const char *src_path, unsigned int req_width, unsigned int req_height, const char *dst_path);
-int mm_util_convert_B_B(mm_util_image_h src_handle, mm_util_magick_format req_format, mm_util_image_h *dst_handle);
+int mm_util_convert_B_B(mm_util_image_h src_handle, mm_util_color_format_e req_format, mm_util_image_h *dst_handle);
int mm_util_extract_image_info(const char *path, mm_util_img_codec_type *type, unsigned int *width, unsigned int *height);
unsigned int width;
unsigned int height;
size_t size;
- mm_util_magick_format format;
+ mm_util_color_format_e format;
} util_image_s;
static bool __mm_util_check_angle(mm_util_magick_rotate_type angle);
return;
}
-static int __mm_util_get_map(mm_util_magick_format format, char **map)
+static int __mm_util_get_map(mm_util_color_format_e format, char **map)
{
mm_util_retvm_if(map == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid map");
switch (format) {
- case MM_UTIL_IMG_FMT_RGB888:
+ case MM_UTIL_COLOR_RGB24:
*map = g_strdup("RGB");
break;
- case MM_UTIL_IMG_FMT_ARGB8888:
+ case MM_UTIL_COLOR_ARGB:
*map = g_strdup("ARGB");
break;
- case MM_UTIL_IMG_FMT_BGRA8888:
+ case MM_UTIL_COLOR_BGRA:
*map = g_strdup("BGRA");
break;
- case MM_UTIL_IMG_FMT_RGBA8888:
+ case MM_UTIL_COLOR_RGBA:
*map = g_strdup("RGBA");
break;
default:
return FALSE;
}
-int mm_util_create_handle(mm_util_image_h *handle, const unsigned char *buffer, unsigned int width, unsigned int height, size_t size, mm_util_magick_format format)
+int mm_util_create_handle(mm_util_image_h *handle, const unsigned char *buffer, unsigned int width, unsigned int height, size_t size, mm_util_color_format_e format)
{
int ret = MM_UTIL_ERROR_NONE;
return ret;
}
-int mm_util_get_image(mm_util_image_h handle, unsigned char **buffer, unsigned int *width, unsigned int *height, size_t *size, mm_util_magick_format *format)
+int mm_util_get_image(mm_util_image_h handle, unsigned char **buffer, unsigned int *width, unsigned int *height, size_t *size, mm_util_color_format_e *format)
{
int ret = MM_UTIL_ERROR_NONE;
return ret;
}
-int mm_util_rotate_P_B(const char *src_path, mm_util_magick_rotate_type angle, mm_util_magick_format req_format, mm_util_image_h *dst_handle)
+int mm_util_rotate_P_B(const char *src_path, mm_util_magick_rotate_type angle, mm_util_color_format_e req_format, mm_util_image_h *dst_handle)
{
int ret = MM_UTIL_ERROR_NONE;
char *map = NULL;
return ret;
}
-int mm_util_resize_P_B(const char *src_path, unsigned int req_width, unsigned int req_height, mm_util_magick_format req_format, mm_util_image_h *dst_handle)
+int mm_util_resize_P_B(const char *src_path, unsigned int req_width, unsigned int req_height, mm_util_color_format_e req_format, mm_util_image_h *dst_handle)
{
int ret = MM_UTIL_ERROR_NONE;
char *map = NULL;
return ret;
}
-int mm_util_convert_B_B(mm_util_image_h src_handle, mm_util_magick_format req_format, mm_util_image_h *dst_handle)
+int mm_util_convert_B_B(mm_util_image_h src_handle, mm_util_color_format_e req_format, mm_util_image_h *dst_handle)
{
int ret = MM_UTIL_ERROR_NONE;
util_image_s *_src_handle = (util_image_s*)src_handle;
#define MM_UTIL_SAFE_FREE(src) { if (src) { free(src); src = NULL; } }
static int _magick_rotate_P_P_test(mm_util_magick_rotate_type angle);
-static int _magick_rotate_P_B_test(mm_util_magick_rotate_type angle, mm_util_magick_format req_format);
-static int _magick_rotate_B_P_test(mm_util_magick_rotate_type angle, mm_util_magick_format req_format);
-static int _magick_rotate_B_B_test(mm_util_magick_rotate_type angle, mm_util_magick_format req_format);
+static int _magick_rotate_P_B_test(mm_util_magick_rotate_type angle, mm_util_color_format_e req_format);
+static int _magick_rotate_B_P_test(mm_util_magick_rotate_type angle, mm_util_color_format_e req_format);
+static int _magick_rotate_B_B_test(mm_util_magick_rotate_type angle, mm_util_color_format_e req_format);
static int _magick_resize_P_P_test(unsigned int req_width, unsigned int req_height);
-static int _magick_resize_P_B_test(unsigned int req_width, unsigned int req_height, mm_util_magick_format req_format);
-static int _magick_resize_B_P_test(unsigned int req_width, unsigned int req_height, mm_util_magick_format req_format);
-static int _magick_resize_B_B_test(unsigned int req_width, unsigned int req_height, mm_util_magick_format req_format);
-static int _magick_convert_B_B_test(mm_util_magick_format in_format, mm_util_magick_format out_format);
+static int _magick_resize_P_B_test(unsigned int req_width, unsigned int req_height, mm_util_color_format_e req_format);
+static int _magick_resize_B_P_test(unsigned int req_width, unsigned int req_height, mm_util_color_format_e req_format);
+static int _magick_resize_B_B_test(unsigned int req_width, unsigned int req_height, mm_util_color_format_e req_format);
+static int _magick_convert_B_B_test(mm_util_color_format_e in_format, mm_util_color_format_e out_format);
static char *__get_dst_path(mm_util_magick_rotate_type angle)
{
unsigned int width = 0;
unsigned int height = 0;
size_t size = 0;
- mm_util_magick_format format = MM_UTIL_IMG_FMT_NUM;
+ mm_util_color_format_e format = MM_UTIL_COLOR_NUM;
ret = mm_util_get_image(handle, &buffer, &width, &height, &size, &format);
if (ret != MM_UTIL_ERROR_NONE) {
return;
}
-static int __get_buffer_for_test(mm_util_magick_format req_format, unsigned char **buffer, unsigned int *width, unsigned int *height, size_t *size, mm_util_magick_format *format)
+static int __get_buffer_for_test(mm_util_color_format_e req_format, unsigned char **buffer, unsigned int *width, unsigned int *height, size_t *size, mm_util_color_format_e *format)
{
int ret = MM_UTIL_ERROR_NONE;
mm_util_image_h dst_handle = NULL;
return ret;
}
-static int _magick_rotate_P_B_test(mm_util_magick_rotate_type angle, mm_util_magick_format req_format)
+static int _magick_rotate_P_B_test(mm_util_magick_rotate_type angle, mm_util_color_format_e req_format)
{
int ret = MM_UTIL_ERROR_NONE;
mm_util_image_h dst_handle = NULL;
return ret;
}
-static int _magick_resize_P_B_test(unsigned int req_width, unsigned int req_height, mm_util_magick_format req_format)
+static int _magick_resize_P_B_test(unsigned int req_width, unsigned int req_height, mm_util_color_format_e req_format)
{
int ret = MM_UTIL_ERROR_NONE;
mm_util_image_h dst_handle = NULL;
return ret;
}
-static int _magick_rotate_B_P_test(mm_util_magick_rotate_type angle, mm_util_magick_format req_format)
+static int _magick_rotate_B_P_test(mm_util_magick_rotate_type angle, mm_util_color_format_e req_format)
{
int ret = MM_UTIL_ERROR_NONE;
mm_util_image_h src_handle = NULL;
unsigned int width = 0;
unsigned int height = 0;
size_t size = 0;
- mm_util_magick_format format = MM_UTIL_IMG_FMT_NUM;
+ mm_util_color_format_e format = MM_UTIL_COLOR_NUM;
printf("* Rotate B P Test * angle = [%d] \n", angle);
return ret;
}
-static int _magick_resize_B_P_test(unsigned int req_width, unsigned int req_height, mm_util_magick_format req_format)
+static int _magick_resize_B_P_test(unsigned int req_width, unsigned int req_height, mm_util_color_format_e req_format)
{
int ret = MM_UTIL_ERROR_NONE;
mm_util_image_h src_handle = NULL;
unsigned int width = 0;
unsigned int height = 0;
size_t size = 0;
- mm_util_magick_format format = MM_UTIL_IMG_FMT_NUM;
+ mm_util_color_format_e format = MM_UTIL_COLOR_NUM;
char dst_path[1024] = {0, };
memset(dst_path, 0x00, sizeof(dst_path));
snprintf(dst_path, sizeof(dst_path), "/opt/usr/home/owner/resize_bp_%d_%d.jpg", req_width, req_height);
return ret;
}
-static int _magick_rotate_B_B_test(mm_util_magick_rotate_type angle, mm_util_magick_format req_format)
+static int _magick_rotate_B_B_test(mm_util_magick_rotate_type angle, mm_util_color_format_e req_format)
{
int ret = MM_UTIL_ERROR_NONE;
mm_util_image_h src_handle = NULL;
unsigned int width = 0;
unsigned int height = 0;
size_t size = 0;
- mm_util_magick_format format = MM_UTIL_IMG_FMT_NUM;
+ mm_util_color_format_e format = MM_UTIL_COLOR_NUM;
printf("* Rotate B B Test * angle = [%d] \n", angle);
return ret;
}
-static int _magick_resize_B_B_test(unsigned int req_width, unsigned int req_height, mm_util_magick_format req_format)
+static int _magick_resize_B_B_test(unsigned int req_width, unsigned int req_height, mm_util_color_format_e req_format)
{
int ret = MM_UTIL_ERROR_NONE;
mm_util_image_h src_handle = NULL;
unsigned int width = 0;
unsigned int height = 0;
size_t size = 0;
- mm_util_magick_format format = MM_UTIL_IMG_FMT_NUM;
+ mm_util_color_format_e format = MM_UTIL_COLOR_NUM;
char dst_path[1024] = {0, };
memset(dst_path, 0x00, sizeof(dst_path));
snprintf(dst_path, sizeof(dst_path), "/opt/usr/home/owner/resize_bb_%d_%d.raw", req_width, req_height);
return ret;
}
-static int _magick_convert_B_B_test(mm_util_magick_format in_format, mm_util_magick_format out_format)
+static int _magick_convert_B_B_test(mm_util_color_format_e in_format, mm_util_color_format_e out_format)
{
int ret = MM_UTIL_ERROR_NONE;
mm_util_image_h src_handle = NULL;
unsigned int width = 0;
unsigned int height = 0;
size_t size = 0;
- mm_util_magick_format format = MM_UTIL_IMG_FMT_NUM;
+ mm_util_color_format_e format = MM_UTIL_COLOR_NUM;
char dst_path[1024] = {0, };
memset(dst_path, 0x00, sizeof(dst_path));
ret = _magick_rotate_P_P_test(MM_UTIL_ROTATE_FLIP_VERT);
} else if (strcmp(argv[1], "2") == 0) {
- ret = _magick_rotate_P_B_test(MM_UTIL_ROTATE_0, MM_UTIL_IMG_FMT_ARGB8888);
- ret = _magick_rotate_P_B_test(MM_UTIL_ROTATE_90, MM_UTIL_IMG_FMT_RGB888);
- ret = _magick_rotate_P_B_test(MM_UTIL_ROTATE_180, MM_UTIL_IMG_FMT_ARGB8888);
- ret = _magick_rotate_P_B_test(MM_UTIL_ROTATE_270, MM_UTIL_IMG_FMT_BGRA8888);
- ret = _magick_rotate_P_B_test(MM_UTIL_ROTATE_FLIP_HORZ, MM_UTIL_IMG_FMT_RGBA8888);
- ret = _magick_rotate_P_B_test(MM_UTIL_ROTATE_FLIP_VERT, MM_UTIL_IMG_FMT_RGBA8888);
+ ret = _magick_rotate_P_B_test(MM_UTIL_ROTATE_0, MM_UTIL_COLOR_ARGB);
+ ret = _magick_rotate_P_B_test(MM_UTIL_ROTATE_90, MM_UTIL_COLOR_RGB24);
+ ret = _magick_rotate_P_B_test(MM_UTIL_ROTATE_180, MM_UTIL_COLOR_ARGB);
+ ret = _magick_rotate_P_B_test(MM_UTIL_ROTATE_270, MM_UTIL_COLOR_BGRA);
+ ret = _magick_rotate_P_B_test(MM_UTIL_ROTATE_FLIP_HORZ, MM_UTIL_COLOR_RGBA);
+ ret = _magick_rotate_P_B_test(MM_UTIL_ROTATE_FLIP_VERT, MM_UTIL_COLOR_RGBA);
} else if (strcmp(argv[1], "3") == 0) {
- ret = _magick_rotate_B_P_test(MM_UTIL_ROTATE_0, MM_UTIL_IMG_FMT_ARGB8888);
- ret = _magick_rotate_B_P_test(MM_UTIL_ROTATE_90, MM_UTIL_IMG_FMT_RGB888);
- ret = _magick_rotate_B_P_test(MM_UTIL_ROTATE_180, MM_UTIL_IMG_FMT_ARGB8888);
- ret = _magick_rotate_B_P_test(MM_UTIL_ROTATE_270, MM_UTIL_IMG_FMT_BGRA8888);
- ret = _magick_rotate_B_P_test(MM_UTIL_ROTATE_FLIP_HORZ, MM_UTIL_IMG_FMT_RGBA8888);
- ret = _magick_rotate_B_P_test(MM_UTIL_ROTATE_FLIP_VERT, MM_UTIL_IMG_FMT_RGBA8888);
+ ret = _magick_rotate_B_P_test(MM_UTIL_ROTATE_0, MM_UTIL_COLOR_ARGB);
+ ret = _magick_rotate_B_P_test(MM_UTIL_ROTATE_90, MM_UTIL_COLOR_RGB24);
+ ret = _magick_rotate_B_P_test(MM_UTIL_ROTATE_180, MM_UTIL_COLOR_ARGB);
+ ret = _magick_rotate_B_P_test(MM_UTIL_ROTATE_270, MM_UTIL_COLOR_BGRA);
+ ret = _magick_rotate_B_P_test(MM_UTIL_ROTATE_FLIP_HORZ, MM_UTIL_COLOR_RGBA);
+ ret = _magick_rotate_B_P_test(MM_UTIL_ROTATE_FLIP_VERT, MM_UTIL_COLOR_RGBA);
} else if (strcmp(argv[1], "4") == 0) {
- ret = _magick_rotate_B_B_test(MM_UTIL_ROTATE_0, MM_UTIL_IMG_FMT_ARGB8888);
- ret = _magick_rotate_B_B_test(MM_UTIL_ROTATE_90, MM_UTIL_IMG_FMT_RGB888);
- ret = _magick_rotate_B_B_test(MM_UTIL_ROTATE_180, MM_UTIL_IMG_FMT_ARGB8888);
- ret = _magick_rotate_B_B_test(MM_UTIL_ROTATE_270, MM_UTIL_IMG_FMT_BGRA8888);
- ret = _magick_rotate_B_B_test(MM_UTIL_ROTATE_FLIP_HORZ, MM_UTIL_IMG_FMT_RGBA8888);
- ret = _magick_rotate_B_B_test(MM_UTIL_ROTATE_FLIP_VERT, MM_UTIL_IMG_FMT_RGBA8888);
- ret = _magick_rotate_B_B_test(100, MM_UTIL_IMG_FMT_RGBA8888); //invalid parameter
+ ret = _magick_rotate_B_B_test(MM_UTIL_ROTATE_0, MM_UTIL_COLOR_ARGB);
+ ret = _magick_rotate_B_B_test(MM_UTIL_ROTATE_90, MM_UTIL_COLOR_RGB24);
+ ret = _magick_rotate_B_B_test(MM_UTIL_ROTATE_180, MM_UTIL_COLOR_ARGB);
+ ret = _magick_rotate_B_B_test(MM_UTIL_ROTATE_270, MM_UTIL_COLOR_BGRA);
+ ret = _magick_rotate_B_B_test(MM_UTIL_ROTATE_FLIP_HORZ, MM_UTIL_COLOR_RGBA);
+ ret = _magick_rotate_B_B_test(MM_UTIL_ROTATE_FLIP_VERT, MM_UTIL_COLOR_RGBA);
+ ret = _magick_rotate_B_B_test(100, MM_UTIL_COLOR_RGBA); //invalid parameter
} else if (strcmp(argv[1], "5") == 0) {
ret = _magick_resize_P_P_test(3000, 2000);
ret = _magick_resize_P_P_test(0, 2000); //invalid parameter
} else if (strcmp(argv[1], "6") == 0) {
- ret = _magick_resize_P_B_test(3000, 2000, MM_UTIL_IMG_FMT_RGB888);
- ret = _magick_resize_P_B_test(199, 299, MM_UTIL_IMG_FMT_ARGB8888);
- ret = _magick_resize_P_B_test(3, 2, MM_UTIL_IMG_FMT_BGRA8888);
- ret = _magick_resize_P_B_test(1000, 999, MM_UTIL_IMG_FMT_RGBA8888);
- ret = _magick_resize_P_B_test(10000, 999, MM_UTIL_IMG_FMT_RGBA8888);
+ ret = _magick_resize_P_B_test(3000, 2000, MM_UTIL_COLOR_RGB24);
+ ret = _magick_resize_P_B_test(199, 299, MM_UTIL_COLOR_ARGB);
+ ret = _magick_resize_P_B_test(3, 2, MM_UTIL_COLOR_BGRA);
+ ret = _magick_resize_P_B_test(1000, 999, MM_UTIL_COLOR_RGBA);
+ ret = _magick_resize_P_B_test(10000, 999, MM_UTIL_COLOR_RGBA);
} else if (strcmp(argv[1], "7") == 0) {
- ret = _magick_resize_B_P_test(3000, 2000, MM_UTIL_IMG_FMT_RGB888);
- ret = _magick_resize_B_P_test(199, 299, MM_UTIL_IMG_FMT_ARGB8888);
- ret = _magick_resize_B_P_test(3, 2, MM_UTIL_IMG_FMT_BGRA8888);
- ret = _magick_resize_B_P_test(1000, 999, MM_UTIL_IMG_FMT_RGBA8888);
- ret = _magick_resize_B_P_test(10000, 999, MM_UTIL_IMG_FMT_RGBA8888);
+ ret = _magick_resize_B_P_test(3000, 2000, MM_UTIL_COLOR_RGB24);
+ ret = _magick_resize_B_P_test(199, 299, MM_UTIL_COLOR_ARGB);
+ ret = _magick_resize_B_P_test(3, 2, MM_UTIL_COLOR_BGRA);
+ ret = _magick_resize_B_P_test(1000, 999, MM_UTIL_COLOR_RGBA);
+ ret = _magick_resize_B_P_test(10000, 999, MM_UTIL_COLOR_RGBA);
} else if (strcmp(argv[1], "8") == 0) {
- ret = _magick_resize_B_B_test(3000, 2000, MM_UTIL_IMG_FMT_RGB888);
- ret = _magick_resize_B_B_test(199, 299, MM_UTIL_IMG_FMT_ARGB8888);
- ret = _magick_resize_B_B_test(3, 2, MM_UTIL_IMG_FMT_BGRA8888);
- ret = _magick_resize_B_B_test(1000, 999, MM_UTIL_IMG_FMT_RGBA8888);
- ret = _magick_resize_B_B_test(10000, 999, MM_UTIL_IMG_FMT_RGBA8888);
+ ret = _magick_resize_B_B_test(3000, 2000, MM_UTIL_COLOR_RGB24);
+ ret = _magick_resize_B_B_test(199, 299, MM_UTIL_COLOR_ARGB);
+ ret = _magick_resize_B_B_test(3, 2, MM_UTIL_COLOR_BGRA);
+ ret = _magick_resize_B_B_test(1000, 999, MM_UTIL_COLOR_RGBA);
+ ret = _magick_resize_B_B_test(10000, 999, MM_UTIL_COLOR_RGBA);
} else if (strcmp(argv[1], "9") == 0) {
- ret = _magick_convert_B_B_test(MM_UTIL_IMG_FMT_RGB888, MM_UTIL_IMG_FMT_RGBA8888);
- ret = _magick_convert_B_B_test(MM_UTIL_IMG_FMT_ARGB8888, MM_UTIL_IMG_FMT_RGBA8888);
- ret = _magick_convert_B_B_test(MM_UTIL_IMG_FMT_BGRA8888, MM_UTIL_IMG_FMT_RGBA8888);
- ret = _magick_convert_B_B_test(MM_UTIL_IMG_FMT_RGBA8888, MM_UTIL_IMG_FMT_RGB888);
- ret = _magick_convert_B_B_test(MM_UTIL_IMG_FMT_BGRA8888, MM_UTIL_IMG_FMT_RGB888);
+ ret = _magick_convert_B_B_test(MM_UTIL_COLOR_RGB24, MM_UTIL_COLOR_RGBA);
+ ret = _magick_convert_B_B_test(MM_UTIL_COLOR_ARGB, MM_UTIL_COLOR_RGBA);
+ ret = _magick_convert_B_B_test(MM_UTIL_COLOR_BGRA, MM_UTIL_COLOR_RGBA);
+ ret = _magick_convert_B_B_test(MM_UTIL_COLOR_RGBA, MM_UTIL_COLOR_RGB24);
+ ret = _magick_convert_B_B_test(MM_UTIL_COLOR_BGRA, MM_UTIL_COLOR_RGB24);
} else {
printf("Invalid parameter\n");
Name: libmm-utility
Summary: Multimedia Framework Utility Library
-Version: 0.1.10
+Version: 0.1.11
Release: 0
Group: System/Libraries
License: Apache-2.0
%cmake .
make %{?jobs:-j%jobs}
-sed -i -e "s#@IMGP_REQPKG@#$IMGP_REQPKG#g" imgp/mmutil-imgp.pc
-sed -i -e "s#@JPEG_REQPKG@#$JPEG_REQPKG#g" jpeg/mmutil-jpeg.pc
-sed -i -e "s#@IMGCV_REQPKG@#$IMGCV_REQPKG#g" imgcv/mmutil-imgcv.pc
-sed -i -e "s#@PNG_REQPKG@#$PNG_REQPKG#g" png/mmutil-png.pc
-sed -i -e "s#@GIF_REQPKG@#$GIF_REQPKG#g" gif/mmutil-gif.pc
-sed -i -e "s#@BMP_REQPKG@#$BMP_REQPKG#g" bmp/mmutil-bmp.pc
-
%install
rm -rf %{buildroot}
%make_install
This part describes the APIs with repect to multimedia image library.
*/
-/* These describe the color_type field in png_info. */
-/* color types. Note that not all combinations are legal */
-typedef enum {
- MM_UTIL_PNG_COLOR_TYPE_RGB_ALPHA,
-} mm_util_png_color_type;
-
typedef enum {
MM_UTIL_COMPRESSION_0 = 0, /* No compression */
MM_UTIL_COMPRESSION_1 = 1, /* Best speed */
png_set_compression_level(png_ptr, encoded->png.compression_level);
/* convert color type */
- if (encoded->png.color_type == MM_UTIL_PNG_COLOR_TYPE_RGB_ALPHA)
+ if (encoded->png.color_type == MM_UTIL_COLOR_RGBA)
encoded->png.color_type = PNG_COLOR_TYPE_RGB_ALPHA;
png_set_IHDR(png_ptr, info_ptr, encoded->width, encoded->height, encoded->png.bit_depth, encoded->png.color_type, encoded->png.interlace_type, PNG_COMPRESSION_TYPE_BASE, encoded->png.filter_type);