--- /dev/null
+/*
+* Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* 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_IMAGE_H__
+#define __MM_UTIL_IMAGE_H__
+
+#include <glib.h>
+#include "mm_util_type.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+gboolean mm_image_is_valid_image(mm_util_image_h image);
+void mm_image_debug_image(mm_util_image_h image, const char *message);
+
+int mm_image_create_image(unsigned int width, unsigned int height,
+ mm_util_color_format_e color, unsigned char *data, size_t size,
+ mm_util_image_h *image);
+
+int mm_image_set_delay_time(mm_util_image_h image, unsigned int delay_time);
+int mm_image_get_delay_time(mm_util_image_h image, unsigned int *delay_time);
+/* After @data is used, it must be released using free().*/
+int mm_image_get_image(mm_util_image_h image, unsigned int *width,
+ unsigned int *height, mm_util_color_format_e *color,
+ unsigned char **data, size_t *size);
+
+void mm_image_destroy_image(mm_util_image_h image);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*__MM_UTIL_IMAGE_H__*/
#include <glib.h>
#include <stdio.h>
#include <stdlib.h>
-#include "mm_util_debug.h"
#include "mm_util_type.h"
+#include "mm_util_debug.h"
+#include "mm_util_image.h"
#ifdef __cplusplus
extern "C" {
#define MM_UTIL_ROUND_DOWN_16(num) ((num)&(~15))
#define IS_VALID_COLOR(color) mm_util_is_valid_color_format(color)
+#define IS_VALID_IMAGE(image) mm_image_is_valid_image(image)
gboolean mm_util_is_valid_color_format(mm_util_color_format_e color);
extern "C" {
#endif
+typedef void *mm_util_image_h;
+
/**
* error type
*/
--- /dev/null
+/*
+* Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* 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 <stdio.h>
+
+#include "mm_util_private.h"
+
+gboolean mm_image_is_valid_image(mm_util_image_h image)
+{
+ mm_image_info_s *_image = (mm_image_info_s *)image;
+
+ mm_util_retvm_if(image == NULL, FALSE, "Invalid image");
+ mm_util_retvm_if(_image->width == 0, FALSE, "Invalid width");
+ mm_util_retvm_if(_image->height == 0, FALSE, "Invalid height");
+ mm_util_retvm_if(!IS_VALID_COLOR(_image->color), FALSE, "Invalid color [%d]", _image->color);
+ mm_util_retvm_if((_image->data == NULL) || (_image->size == 0), FALSE, "Invalid data [%zu, %p]", _image->size, _image->data);
+
+ return TRUE;
+}
+
+void mm_image_debug_image(mm_util_image_h image, const char *message)
+{
+ mm_image_info_s *_image = (mm_image_info_s *)image;
+
+ mm_util_retm_if(image == NULL, "Invalid image");
+
+ if (message)
+ mm_util_sec_debug("[%s] w [%u], h [%u], color [%u], data [%p], size [%zu]", message,
+ _image->width, _image->height, _image->color, _image->data, _image->size);
+ else
+ mm_util_sec_debug("w [%u], h [%u], color [%u], data [%p], size [%zu]",
+ _image->width, _image->height, _image->color, _image->data, _image->size);
+}
+
+int mm_image_create_image(unsigned int width, unsigned int height,
+ mm_util_color_format_e color, unsigned char *data, size_t size,
+ mm_util_image_h *image)
+{
+ mm_image_info_s *_image = NULL;
+
+ /* initialize return value */
+ *image = NULL;
+
+ mm_util_retvm_if(image == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid image");
+ mm_util_retvm_if(width == 0, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid width");
+ mm_util_retvm_if(height == 0, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid height");
+ mm_util_retvm_if(!IS_VALID_COLOR(color), MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid color [%d]", color);
+ mm_util_retvm_if(data == NULL || (size == 0), MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid data");
+
+ _image = (mm_image_info_s *)calloc(1, sizeof(mm_image_info_s));
+ mm_util_retvm_if((_image == NULL), MM_UTIL_ERROR_OUT_OF_MEMORY, "Memory allocation failed");
+
+ _image->data = calloc(1, size);
+ if (_image->data == NULL) {
+ mm_util_error("Memory allocation failed");
+ mm_image_destroy_image(_image);
+ return MM_UTIL_ERROR_OUT_OF_MEMORY;
+ }
+
+ memcpy(_image->data, data, size);
+ _image->size = size;
+ _image->width = width;
+ _image->height = height;
+ _image->color = color;
+
+ mm_util_sec_debug("w [%u], h [%u], color [%u], data [%p], size [%zu]",
+ _image->width, _image->height, _image->color, _image->data, _image->size);
+
+ *image = (mm_util_image_h)_image;
+
+ return MM_UTIL_ERROR_NONE;
+}
+
+int mm_image_set_delay_time(mm_util_image_h image, unsigned int delay_time)
+{
+ mm_image_info_s *_image = (mm_image_info_s *)image;
+
+ mm_util_retvm_if(image == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid image");
+
+ _image->delay_time = delay_time;
+
+ return MM_UTIL_ERROR_NONE;
+}
+
+int mm_image_get_delay_time(mm_util_image_h image, unsigned int *delay_time)
+{
+ mm_image_info_s *_image = (mm_image_info_s *)image;
+
+ mm_util_retvm_if(image == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid image");
+ mm_util_retvm_if(delay_time == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid delay_time");
+
+ *delay_time = _image->delay_time;
+
+ return MM_UTIL_ERROR_NONE;
+}
+
+int mm_image_get_image(mm_util_image_h image, unsigned int *width,
+ unsigned int *height, mm_util_color_format_e *color,
+ unsigned char **data, size_t *size)
+{
+ mm_image_info_s *_image = (mm_image_info_s *)image;
+ unsigned char *_data = NULL;
+
+ mm_util_retvm_if(!IS_VALID_IMAGE(image), MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid image");
+
+ if (width)
+ *width = _image->width;
+
+ if (height)
+ *height = _image->height;
+
+ if (color)
+ *color = _image->color;
+
+ if (data && size) {
+ _data = calloc(1, _image->size);
+ mm_util_retvm_if(_data == NULL, MM_UTIL_ERROR_OUT_OF_MEMORY, "Memory allocation failed");
+ memcpy(_data, _image->data, _image->size);
+ *data = _data;
+ *size = _image->size;
+ }
+
+ return MM_UTIL_ERROR_NONE;
+}
+
+void mm_image_destroy_image(mm_util_image_h image)
+{
+ mm_image_info_s *_image = (mm_image_info_s *)image;
+
+ mm_util_retm_if(image == NULL, "Invalid image");
+
+ MMUTIL_SAFE_FREE(_image->data);
+ MMUTIL_SAFE_FREE(_image);
+}
data[1] = cb;
data[2] = cr;
- mm_util_debug("rawdata[%p] width[%d] height[%d] color_format[%u] quality[%d]", rawdata, width, height, color_format, quality);
+ mm_util_debug("rawdata[%p] width[%u] height[%u] color_format[%u] quality[%d]", rawdata, width, height, color_format, quality);
cinfo.err = jpeg_std_error(&jerr); /* Errors get written to stderr */
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}
#endif
#include "mm_util_type.h"
-
-typedef void *mm_util_image_h;
+#include "mm_util_image.h"
/**
* Image rotation types
IMG_CODEC_UNKNOWN_TYPE,
} 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_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_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_color_format_e req_format, mm_util_image_h *dst_handle);
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_color_format_e format)
-{
- int ret = MM_UTIL_ERROR_NONE;
-
- mm_util_retvm_if(handle == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid handle");
-
- mm_image_info_s *_handle = (mm_image_info_s*)calloc(1, sizeof(mm_image_info_s));
- mm_util_retvm_if(_handle == NULL, MM_UTIL_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-
- _handle->data = (unsigned char *)buffer;
- _handle->width = width;
- _handle->height = height;
- _handle->size = size;
- _handle->color = format;
-
- *handle = (mm_util_image_h)_handle;
-
- 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_color_format_e *format)
-{
- int ret = MM_UTIL_ERROR_NONE;
-
- mm_util_retvm_if(handle == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid handle");
- mm_util_retvm_if(buffer == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid buffer");
- mm_util_retvm_if(width == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid width");
- mm_util_retvm_if(height == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid height");
- mm_util_retvm_if(size == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid size");
- mm_util_retvm_if(format == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid format");
-
- mm_image_info_s *_handle = (mm_image_info_s*)handle;
-
- *buffer = _handle->data;
- *width = _handle->width;
- *height = _handle->height;
- *size = _handle->size;
- *format = _handle->color;
-
- return ret;
-}
-
-int mm_util_destroy_handle(mm_util_image_h handle)
-{
- mm_util_retvm_if(handle == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid handle");
-
- mm_image_info_s *_handle = (mm_image_info_s*)handle;
-
- MMUTIL_SAFE_FREE(_handle);
-
- return MM_UTIL_ERROR_NONE;
-}
-
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 ret = MM_UTIL_ERROR_NONE;
goto ERROR;
}
- ret = mm_util_create_handle(dst_handle, pixels, _processed_image->columns, _processed_image->rows, pixels_size, _src_handle->color);
- if (ret != MM_UTIL_ERROR_NONE) {
- mm_util_error("Error: __mm_util_write_image_to_buffer failed.");
- MagickFree(pixels);
- }
+ ret = mm_image_create_image(_processed_image->columns, _processed_image->rows, _src_handle->color, pixels, pixels_size, dst_handle);
+ if (ret != MM_UTIL_ERROR_NONE)
+ mm_util_error("Error: mm_image_create_image failed.");
+
+ MagickFree(pixels);
ERROR:
goto ERROR;
}
- ret = mm_util_create_handle(dst_handle, pixels, _processed_image->columns, _processed_image->rows, pixels_size, req_format);
- if (ret != MM_UTIL_ERROR_NONE) {
- mm_util_error("Error: __mm_util_write_image_to_buffer failed.");
- MagickFree(pixels);
- }
+ ret = mm_image_create_image(_processed_image->columns, _processed_image->rows, req_format, pixels, pixels_size, dst_handle);
+ if (ret != MM_UTIL_ERROR_NONE)
+ mm_util_error("Error: mm_image_create_image failed.");
+
+ MagickFree(pixels);
ERROR:
goto ERROR;
}
- ret = mm_util_create_handle(dst_handle, pixels, _processed_image->columns, _processed_image->rows, pixels_size, _src_handle->color);
- if (ret != MM_UTIL_ERROR_NONE) {
- mm_util_error("Error: __mm_util_write_image_to_buffer failed.");
- MagickFree(pixels);
- }
+ ret = mm_image_create_image(_processed_image->columns, _processed_image->rows, _src_handle->color, pixels, pixels_size, dst_handle);
+ if (ret != MM_UTIL_ERROR_NONE)
+ mm_util_error("Error: mm_image_create_image failed.");
+
+ MagickFree(pixels);
ERROR:
goto ERROR;
}
- ret = mm_util_create_handle(dst_handle, pixels, _processed_image->columns, _processed_image->rows, pixels_size, req_format);
- if (ret != MM_UTIL_ERROR_NONE) {
- mm_util_error("Error: __mm_util_write_image_to_buffer failed.");
- MagickFree(pixels);
- }
+ ret = mm_image_create_image(_processed_image->columns, _processed_image->rows, req_format, pixels, pixels_size, dst_handle);
+ if (ret != MM_UTIL_ERROR_NONE)
+ mm_util_error("Error: mm_image_create_image failed.");
+
+ MagickFree(pixels);
ERROR:
goto ERROR;
}
- ret = mm_util_create_handle(dst_handle, pixels, _image->columns, _image->rows, pixels_size, _src_handle->color);
- if (ret != MM_UTIL_ERROR_NONE) {
- mm_util_error("Error: __mm_util_write_image_to_buffer failed.");
- MagickFree(pixels);
- }
+ ret = mm_image_create_image(_image->columns, _image->rows, _src_handle->color, pixels, pixels_size, dst_handle);
+ if (ret != MM_UTIL_ERROR_NONE)
+ mm_util_error("Error: mm_image_create_image failed.");
+
+ MagickFree(pixels);
ERROR:
size_t size = 0;
mm_util_color_format_e format = MM_UTIL_COLOR_NUM;
- ret = mm_util_get_image(handle, &buffer, &width, &height, &size, &format);
+ ret = mm_image_get_image(handle, &width, &height, &format, &buffer, &size);
if (ret != MM_UTIL_ERROR_NONE) {
- printf("Fail mm_util_get_image [%d]\n", ret);
+ printf("Fail mm_image_get_image [%d]\n", ret);
return;
}
- printf("[save to file] buffer[%p], width[%d], height[%d], size[%zu], format [%d], out_path [%s]\n", buffer, width, height, size, format, out_path);
+ printf("[save to file] buffer[%p], width[%u], height[%u], size[%zu], format [%d], out_path [%s]\n", buffer, width, height, size, format, out_path);
__write_to_file(out_path, buffer, size);
return;
}
-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)
+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;
}
- ret = mm_util_get_image(dst_handle, buffer, width, height, size, format);
+ ret = mm_image_get_image(dst_handle, width, height, format, buffer, size);
if (ret != MM_UTIL_ERROR_NONE) {
- printf("Fail mm_util_get_image [%d]\n", ret);
- ret = mm_util_destroy_handle(dst_handle);
- if (ret != MM_UTIL_ERROR_NONE)
- printf("Fail mm_util_destroy_handle [%d]\n", ret);
+ printf("Fail mm_image_get_image [%d]\n", ret);
+ mm_image_destroy_image(dst_handle);
MM_UTIL_SAFE_FREE(*buffer);
return ret;
}
- printf("[get_buffer] buffer[%p], width[%d], height[%d], size[%zu], format [%d]\n", *buffer, *width, *height, *size, *format);
+ printf("[get_buffer] buffer[%p], width[%u], height[%u], size[%zu], format [%d]\n", *buffer, *width, *height, *size, *format);
- ret = mm_util_destroy_handle(dst_handle);
- if (ret != MM_UTIL_ERROR_NONE) {
- printf("Fail mm_util_destroy_handle [%d]\n", ret);
- MM_UTIL_SAFE_FREE(*buffer);
- return ret;
- }
+ mm_image_destroy_image(dst_handle);
return ret;
}
char * src_path = "/opt/usr/home/owner/origin.jpg";
char dst_path[1024] = {0, };
memset(dst_path, 0x00, sizeof(dst_path));
- snprintf(dst_path, sizeof(dst_path), "/opt/usr/home/owner/resize_pp_%d_%d.jpg", req_width, req_height);
+ snprintf(dst_path, sizeof(dst_path), "/opt/usr/home/owner/resize_pp_%u_%u.jpg", req_width, req_height);
//snprintf(dst_path, sizeof(dst_path), "/opt/usr/home/owner/resize_%d_%d.png", req_width, req_height);
- printf("* Resize P P Test * W * H = [%d * %d], path = [%s] \n", req_width, req_height, dst_path);
+ printf("* Resize P P Test * W * H = [%u * %u], path = [%s] \n", req_width, req_height, dst_path);
ret = mm_util_resize_P_P(src_path, req_width, req_height, dst_path);
if (ret != MM_UTIL_ERROR_NONE)
__save_to_file(dst_handle, __get_dst_raw_path(angle));
- ret = mm_util_destroy_handle(dst_handle);
- if (ret != MM_UTIL_ERROR_NONE) {
- printf("Fail mm_util_destroy_handle [%d]\n", ret);
- return ret;
- }
+ mm_image_destroy_image(dst_handle);
return ret;
}
char * src_path = "/opt/usr/home/owner/origin.jpg";
char dst_path[1024] = {0, };
memset(dst_path, 0x00, sizeof(dst_path));
- snprintf(dst_path, sizeof(dst_path), "/opt/usr/home/owner/resize_pb_%d_%d.raw", req_width, req_height);
+ snprintf(dst_path, sizeof(dst_path), "/opt/usr/home/owner/resize_pb_%u_%u.raw", req_width, req_height);
- printf("* Resize P B Test * W * H [%d * %d], foramt [%d], path [%s]\n", req_width, req_height, req_format, dst_path);
+ printf("* Resize P B Test * W * H [%u * %u], foramt [%d], path [%s]\n", req_width, req_height, req_format, dst_path);
ret = mm_util_resize_P_B(src_path, req_width, req_height, req_format, &dst_handle);
if (ret != MM_UTIL_ERROR_NONE) {
__save_to_file(dst_handle, dst_path);
- ret = mm_util_destroy_handle(dst_handle);
- if (ret != MM_UTIL_ERROR_NONE) {
- printf("Fail mm_util_destroy_handle [%d]\n", ret);
- return ret;
- }
+ mm_image_destroy_image(dst_handle);
return ret;
}
return ret;
}
- ret = mm_util_create_handle(&src_handle, buffer, width, height, size, format);
+ ret = mm_image_create_image(width, height, format, buffer, size, &src_handle);
if (ret != MM_UTIL_ERROR_NONE) {
- printf("Fail mm_util_create_handle [%d]\n", ret);
+ printf("Fail mm_image_create_image [%d]\n", ret);
MM_UTIL_SAFE_FREE(buffer);
return ret;
}
if (ret != MM_UTIL_ERROR_NONE)
printf("Fail mm_util_rotate_B_P [%d]\n", ret);
- ret = mm_util_destroy_handle(src_handle);
- if (ret != MM_UTIL_ERROR_NONE)
- printf("Fail mm_util_destroy_handle [%d]\n", ret);
+ mm_image_destroy_image(src_handle);
MM_UTIL_SAFE_FREE(buffer);
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);
+ snprintf(dst_path, sizeof(dst_path), "/opt/usr/home/owner/resize_bp_%u_%u.jpg", req_width, req_height);
- printf("* Resize B P Test * W * H [%d * %d], foramt [%d], path [%s]\n", req_width, req_height, req_format, dst_path);
+ printf("* Resize B P Test * W * H [%u * %u], foramt [%d], path [%s]\n", req_width, req_height, req_format, dst_path);
ret = __get_buffer_for_test(req_format, &buffer, &width, &height, &size, &format);
if (ret != MM_UTIL_ERROR_NONE) {
return ret;
}
- ret = mm_util_create_handle(&src_handle, buffer, width, height, size, format);
+ ret = mm_image_create_image(width, height, format, buffer, size, &src_handle);
if (ret != MM_UTIL_ERROR_NONE) {
- printf("Fail mm_util_create_handle [%d]\n", ret);
+ printf("Fail mm_image_create_image [%d]\n", ret);
MM_UTIL_SAFE_FREE(buffer);
return ret;
}
if (ret != MM_UTIL_ERROR_NONE)
printf("Fail mm_util_resize_B_P [%d]\n", ret);
- ret = mm_util_destroy_handle(src_handle);
- if (ret != MM_UTIL_ERROR_NONE)
- printf("Fail mm_util_destroy_handle [%d]\n", ret);
+ mm_image_destroy_image(src_handle);
MM_UTIL_SAFE_FREE(buffer);
return ret;
}
- ret = mm_util_create_handle(&src_handle, buffer, width, height, size, format);
+ ret = mm_image_create_image(width, height, format, buffer, size, &src_handle);
if (ret != MM_UTIL_ERROR_NONE) {
- printf("Fail mm_util_create_handle [%d]\n", ret);
+ printf("Fail mm_image_create_image [%d]\n", ret);
MM_UTIL_SAFE_FREE(buffer);
return ret;
}
__save_to_file(dst_handle, __get_dst_raw_path(angle));
- ret = mm_util_destroy_handle(src_handle);
- if (ret != MM_UTIL_ERROR_NONE)
- printf("Fail destroy src_handle [%d]\n", ret);
-
- ret = mm_util_destroy_handle(dst_handle);
- if (ret != MM_UTIL_ERROR_NONE)
- printf("Fail destroy dst_handle [%d]\n", ret);
+ mm_image_destroy_image(src_handle);
+ mm_image_destroy_image(dst_handle);
return ret;
}
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);
+ snprintf(dst_path, sizeof(dst_path), "/opt/usr/home/owner/resize_bb_%u_%u.raw", req_width, req_height);
- printf("* Resize B B Test * W * H [%d * %d], foramt [%d], path [%s]\n", req_width, req_height, req_format, dst_path);
+ printf("* Resize B B Test * W * H [%u * %u], foramt [%d], path [%s]\n", req_width, req_height, req_format, dst_path);
ret = __get_buffer_for_test(req_format, &buffer, &width, &height, &size, &format);
if (ret != MM_UTIL_ERROR_NONE) {
return ret;
}
- ret = mm_util_create_handle(&src_handle, buffer, width, height, size, format);
+ ret = mm_image_create_image(width, height, format, buffer, size, &src_handle);
if (ret != MM_UTIL_ERROR_NONE) {
- printf("Fail mm_util_create_handle [%d]\n", ret);
+ printf("Fail mm_image_create_image [%d]\n", ret);
MM_UTIL_SAFE_FREE(buffer);
return ret;
}
__save_to_file(dst_handle, dst_path);
- ret = mm_util_destroy_handle(src_handle);
- if (ret != MM_UTIL_ERROR_NONE)
- printf("Fail destroy src_handle [%d]\n", ret);
-
- ret = mm_util_destroy_handle(dst_handle);
- if (ret != MM_UTIL_ERROR_NONE)
- printf("Fail destroy dst_handle [%d]\n", ret);
+ mm_image_destroy_image(src_handle);
+ mm_image_destroy_image(dst_handle);
return ret;
}
return ret;
}
- snprintf(dst_path, sizeof(dst_path), "/opt/usr/home/owner/convert_bb_%d_%d_%d_%d.raw", width, height, in_format, out_format);
+ snprintf(dst_path, sizeof(dst_path), "/opt/usr/home/owner/convert_bb_%u_%u_%d_%d.raw", width, height, in_format, out_format);
printf("* Convert B B Test * input_foramt [%d], output_formt [%d] path [%s]\n", in_format, out_format, dst_path);
- ret = mm_util_create_handle(&src_handle, buffer, width, height, size, format);
+ ret = mm_image_create_image(width, height, format, buffer, size, &src_handle);
if (ret != MM_UTIL_ERROR_NONE) {
- printf("Fail mm_util_create_handle [%d]\n", ret);
+ printf("Fail mm_image_create_image [%d]\n", ret);
MM_UTIL_SAFE_FREE(buffer);
return ret;
}
__save_to_file(dst_handle, dst_path);
- ret = mm_util_destroy_handle(src_handle);
- if (ret != MM_UTIL_ERROR_NONE)
- printf("Fail destroy src_handle [%d]\n", ret);
-
- ret = mm_util_destroy_handle(dst_handle);
- if (ret != MM_UTIL_ERROR_NONE)
- printf("Fail destroy dst_handle [%d]\n", ret);
+ mm_image_destroy_image(src_handle);
+ mm_image_destroy_image(dst_handle);
return ret;
}