From d566df1d19b6c015cc840245d92f3331d0145f85 Mon Sep 17 00:00:00 2001 From: "minje.ahn" Date: Fri, 16 Feb 2024 11:53:13 +0900 Subject: [PATCH] Code cleanup Change-Id: I74d12651c6e92d9a788cfee8774563f7eb561ebd Signed-off-by: minje.ahn --- gif/unittest/FileInterface.cpp | 4 ++-- imgp/mm_util_imgp.c | 20 ++++++-------------- jpeg/mm_util_jpeg.c | 20 ++++++-------------- jpeg/unittest/FileInterface.cpp | 4 ++-- 4 files changed, 16 insertions(+), 32 deletions(-) diff --git a/gif/unittest/FileInterface.cpp b/gif/unittest/FileInterface.cpp index b85607d..aad9430 100644 --- a/gif/unittest/FileInterface.cpp +++ b/gif/unittest/FileInterface.cpp @@ -60,9 +60,9 @@ bool FileInterface::ReadData() return false; readData = (unsigned char *)calloc(1, fileSize); - if (fread(readData, 1, fileSize, fp) != fileSize) { + if (fread(readData, 1, fileSize, fp) != fileSize) return false; - } + readDataSize = fileSize; return true; } diff --git a/imgp/mm_util_imgp.c b/imgp/mm_util_imgp.c index af16cf9..5cb316b 100644 --- a/imgp/mm_util_imgp.c +++ b/imgp/mm_util_imgp.c @@ -42,8 +42,6 @@ static int __check_valid_picture_size(unsigned int width, unsigned int height) static bool __mm_gst_can_resize_format(mm_util_color_format_e color_format) { - bool _bool = false; - mm_util_debug("color_format [%d]", color_format); switch (color_format) { @@ -58,19 +56,15 @@ static bool __mm_gst_can_resize_format(mm_util_color_format_e color_format) case MM_UTIL_COLOR_BGRA: case MM_UTIL_COLOR_RGBA: case MM_UTIL_COLOR_BGRX: - _bool = true; - break; + return true; default: mm_util_error("Not supported format"); //only not support NV12 + return false; } - - return _bool; } static bool __mm_gst_can_rotate_format(mm_util_color_format_e color_format) { - bool _bool = false; - mm_util_debug("color_format [%d]", color_format); switch (color_format) { @@ -80,13 +74,11 @@ static bool __mm_gst_can_rotate_format(mm_util_color_format_e color_format) case MM_UTIL_COLOR_ARGB: case MM_UTIL_COLOR_BGRA: case MM_UTIL_COLOR_RGBA: - _bool = true; - break; + return true; default: mm_util_error("Not supported format"); + return false; } - - return _bool; } static int __mm_util_get_image_size(mm_util_color_format_e format, unsigned int width, unsigned int height, bool is_crop, size_t *imgsize) @@ -415,7 +407,7 @@ int mm_util_resize_image(mm_util_image_h src, unsigned int width, unsigned int h goto ERROR; } - if (__mm_gst_can_resize_format(_imgp_info_s->src_format) == false) { + if (!__mm_gst_can_resize_format(_imgp_info_s->src_format)) { mm_util_error("Not supported format"); ret = MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT; goto ERROR; @@ -504,7 +496,7 @@ int mm_util_rotate_image(mm_util_image_h src, mm_util_rotate_type_e angle, mm_ut goto ERROR; } - if (__mm_gst_can_rotate_format(_imgp_info_s->src_format) == false) { + if (!__mm_gst_can_rotate_format(_imgp_info_s->src_format)) { mm_util_error("Not supported format"); ret = MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT; goto ERROR; diff --git a/jpeg/mm_util_jpeg.c b/jpeg/mm_util_jpeg.c index 3a659d6..579be03 100644 --- a/jpeg/mm_util_jpeg.c +++ b/jpeg/mm_util_jpeg.c @@ -55,8 +55,6 @@ static void __my_error_exit(j_common_ptr cinfo) static bool __is_supported_color_format_with_libjpeg(mm_util_color_format_e color_format) { - bool _bool = false; - if (color_format == MM_UTIL_COLOR_RGB24 || color_format == MM_UTIL_COLOR_RGBA || color_format == MM_UTIL_COLOR_BGRA || @@ -65,28 +63,22 @@ static bool __is_supported_color_format_with_libjpeg(mm_util_color_format_e colo color_format == MM_UTIL_COLOR_YUV422 || color_format == MM_UTIL_COLOR_UYVY || color_format == MM_UTIL_COLOR_GRAYSCALE) { - _bool = true; + return true; } - if (!_bool) - mm_util_error("not supported color format %d", color_format); - - return _bool; + mm_util_error("not supported color format %d", color_format); + return false; } static bool __mm_util_is_supported_color_format(mm_util_color_format_e color_format) { - bool _bool = false; - if (__is_supported_color_format_with_libjpeg(color_format) || color_format == MM_UTIL_COLOR_NV12) { - _bool = true; + return true; } - if (!_bool) - mm_util_error("not supported color format %d", color_format); - - return _bool; + mm_util_error("not supported color format %d", color_format); + return false; } static int __jpeg_set_error_handler(my_error_ptr jerr, jpeg_error_ptr *err) diff --git a/jpeg/unittest/FileInterface.cpp b/jpeg/unittest/FileInterface.cpp index b85607d..aad9430 100644 --- a/jpeg/unittest/FileInterface.cpp +++ b/jpeg/unittest/FileInterface.cpp @@ -60,9 +60,9 @@ bool FileInterface::ReadData() return false; readData = (unsigned char *)calloc(1, fileSize); - if (fread(readData, 1, fileSize, fp) != fileSize) { + if (fread(readData, 1, fileSize, fp) != fileSize) return false; - } + readDataSize = fileSize; return true; } -- 2.7.4