From 235c0575e528cc67cdf125fb62ac0802b437c39e Mon Sep 17 00:00:00 2001 From: "jiyong.min" Date: Mon, 4 Mar 2019 10:10:51 +0900 Subject: [PATCH] Remove unused macro and modify few data type due to out-of-range issue Change-Id: I88e9e8b4220e3f09aff73886c317f39f24374cf5 --- common/include/mm_util_private.h | 1 - imgp/include/mm_util_imgp.h | 19 +++++++++++++------ imgp/include/mm_util_imgp_internal.h | 0 imgp/mm_util_imgp.c | 29 ++++++++++++++--------------- packaging/libmm-utility.spec | 2 +- 5 files changed, 28 insertions(+), 23 deletions(-) mode change 100755 => 100644 imgp/include/mm_util_imgp.h mode change 100755 => 100644 imgp/include/mm_util_imgp_internal.h diff --git a/common/include/mm_util_private.h b/common/include/mm_util_private.h index 0695f15..1ef398f 100644 --- a/common/include/mm_util_private.h +++ b/common/include/mm_util_private.h @@ -44,7 +44,6 @@ extern "C" { #define MM_UTIL_ROUND_UP_2(num) (((num)+1)&~1) #define MM_UTIL_ROUND_UP_4(num) (((num)+3)&~3) #define MM_UTIL_ROUND_UP_8(num) (((num)+7)&~7) -#define MM_UTIL_ROUND_UP_16(num) (((num)+15)&~15) #define MM_UTIL_ROUND_DOWN_2(num) ((num)&(~1)) #define MM_UTIL_ROUND_DOWN_4(num) ((num)&(~3)) #define MM_UTIL_ROUND_DOWN_16(num) ((num)&(~15)) diff --git a/imgp/include/mm_util_imgp.h b/imgp/include/mm_util_imgp.h old mode 100755 new mode 100644 index 3192275..73bdb9c --- a/imgp/include/mm_util_imgp.h +++ b/imgp/include/mm_util_imgp.h @@ -42,12 +42,19 @@ typedef enum { } mm_util_img_rotate_type; int mm_util_get_image_size(mm_util_color_format_e format, unsigned int width, unsigned int height, size_t *imgsize); -int mm_util_convert_colorspace(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_color_format_e src_format, mm_util_color_format_e dst_format, unsigned char **dst, unsigned int *result_buf_width, unsigned int *result_buf_height, size_t *result_buf_size); -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 int dst_width, unsigned int dst_height, unsigned char **dst, unsigned int *result_buf_width, unsigned int *result_buf_height, size_t *result_buf_size); -int mm_util_rotate_image(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_color_format_e src_format, mm_util_img_rotate_type angle, unsigned char **dst, unsigned int *result_buf_width, unsigned int *result_buf_height, size_t *result_buf_size); -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, unsigned int *result_buf_width, unsigned int *result_buf_height, size_t *result_buf_size); +int mm_util_convert_colorspace(const unsigned char *src, unsigned int src_width, unsigned int src_height, + mm_util_color_format_e src_format, mm_util_color_format_e dst_format, unsigned char **dst, + unsigned int *result_buf_width, unsigned int *result_buf_height, size_t *result_buf_size); +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 int dst_width, unsigned int dst_height, unsigned char **dst, + unsigned int *result_buf_width, unsigned int *result_buf_height, size_t *result_buf_size); +int mm_util_rotate_image(const unsigned char *src, unsigned int src_width, unsigned int src_height, + mm_util_color_format_e src_format, mm_util_img_rotate_type angle, unsigned char **dst, + unsigned int *result_buf_width, unsigned int *result_buf_height, size_t *result_buf_size); +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, + unsigned int *result_buf_width, unsigned int *result_buf_height, size_t *result_buf_size); #ifdef __cplusplus diff --git a/imgp/include/mm_util_imgp_internal.h b/imgp/include/mm_util_imgp_internal.h old mode 100755 new mode 100644 diff --git a/imgp/mm_util_imgp.c b/imgp/mm_util_imgp.c index 7b8bcfd..2d6f4f6 100644 --- a/imgp/mm_util_imgp.c +++ b/imgp/mm_util_imgp.c @@ -32,10 +32,9 @@ typedef gboolean(*IMGPInfoFunc) (imgp_info_s *, const unsigned char *, unsigned char **, imgp_plugin_type_e); -static int check_valid_picture_size(int width, int height) +static int __check_valid_picture_size(unsigned int width, unsigned int height) { - if ((int)width > 0 && (int)height > 0 && - ((width + 128) * (unsigned long long)(height + 128)) < INT_MAX/4) + if ((size_t)((width + 128) * (height + 128)) < (size_t)(INT_MAX/4)) return MM_UTIL_ERROR_NONE; return MM_UTIL_ERROR_INVALID_PARAMETER; @@ -196,13 +195,13 @@ static int __mm_util_get_crop_image_size(mm_util_color_format_e format, unsigned int ret = MM_UTIL_ERROR_NONE; unsigned char x_chroma_shift = 0; unsigned char y_chroma_shift = 0; - int size, w2, h2, size2; - int stride, stride2; + unsigned int w2, h2, stride, stride2; + size_t size, size2; mm_util_fenter(); mm_util_retvm_if(imgsize == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid imgsize"); - mm_util_retvm_if(check_valid_picture_size(width, height) != MM_UTIL_ERROR_NONE, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid width and height"); + mm_util_retvm_if(__check_valid_picture_size(width, height) != MM_UTIL_ERROR_NONE, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid width and height"); *imgsize = 0; @@ -347,8 +346,8 @@ unsigned int crop_start_x, unsigned int crop_start_y, unsigned int crop_dest_wid { int ret = MM_UTIL_ERROR_NONE; unsigned int idx = 0; - int src_bytesperline = src_width * 3; - int dst_bytesperline = crop_dest_width * 3; + unsigned long src_bytesperline = src_width * 3; + unsigned long dst_bytesperline = crop_dest_width * 3; src += crop_start_y * src_bytesperline + 3 * crop_start_x; @@ -366,8 +365,8 @@ unsigned int crop_start_x, unsigned int crop_start_y, unsigned int crop_dest_wid { int ret = MM_UTIL_ERROR_NONE; unsigned int idx = 0; - int src_bytesperline = src_width * 2; - int dst_bytesperline = crop_dest_width * 2; + unsigned long src_bytesperline = src_width * 2; + unsigned long dst_bytesperline = crop_dest_width * 2; src += crop_start_y * src_bytesperline + 2 * crop_start_x; @@ -385,8 +384,8 @@ unsigned int crop_start_x, unsigned int crop_start_y, unsigned int crop_dest_wid { int ret = MM_UTIL_ERROR_NONE; unsigned int idx = 0; - int start_x = crop_start_x; - int start_y = crop_start_y; + unsigned int start_x = crop_start_x; + unsigned int start_y = crop_start_y; const unsigned char *_src = src + start_y * src_width + start_x; @@ -858,14 +857,14 @@ int mm_util_get_image_size(mm_util_color_format_e format, unsigned int width, un int ret = MM_UTIL_ERROR_NONE; unsigned char x_chroma_shift = 0; unsigned char y_chroma_shift = 0; - int size, w2, h2, size2; - int stride, stride2; + unsigned int w2, h2, stride, stride2; + size_t size, size2; mm_util_fenter(); mm_util_retvm_if((imgsize == NULL), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid imgsize"); mm_util_retvm_if((IS_MM_UTIL_COLOR_FORMAT(format) == FALSE), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid format [%d]", format); - mm_util_retvm_if((check_valid_picture_size(width, height) != MM_UTIL_ERROR_NONE), MM_UTIL_ERROR_INVALID_PARAMETER, "image width & height is too big"); + mm_util_retvm_if((__check_valid_picture_size(width, height) != MM_UTIL_ERROR_NONE), MM_UTIL_ERROR_INVALID_PARAMETER, "image width & height is too big"); *imgsize = 0; diff --git a/packaging/libmm-utility.spec b/packaging/libmm-utility.spec index 7c878a0..5d8a979 100755 --- a/packaging/libmm-utility.spec +++ b/packaging/libmm-utility.spec @@ -1,6 +1,6 @@ Name: libmm-utility Summary: Multimedia Framework Utility Library -Version: 0.1.30 +Version: 0.1.31 Release: 0 Group: System/Libraries License: Apache-2.0 -- 2.7.4