return _bool;
}
-static gboolean __mm_select_rotate_plugin(mm_util_img_format _format, unsigned int width, unsigned int height, mm_util_img_rotate_type angle)
+static gboolean __mm_select_rotate_plugin(mm_util_img_format _format)
{
- mm_util_debug("_format: %d (angle: %d)", _format, angle);
+ 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)) {
return module;
}
-static IMGPInfoFunc __mm_util_imgp_process(GModule *module)
+static void __mm_util_imgp_finalize(GModule *module, imgp_info_s *_imgp_info_s)
{
- IMGPInfoFunc mm_util_imgp_func = NULL;
- mm_util_fenter();
-
- if (module == NULL) {
- mm_util_error("module is NULL");
- return NULL;
- }
-
- g_module_symbol(module, IMGP_FUNC_NAME, (gpointer *)&mm_util_imgp_func);
- mm_util_debug("mm_util_imgp_func: %p", mm_util_imgp_func);
-
- return mm_util_imgp_func;
-}
-
-static int __mm_util_imgp_finalize(GModule *module, imgp_info_s *_imgp_info_s)
-{
- int ret = MM_UTIL_ERROR_NONE;
-
- if (module) {
- mm_util_debug("module : %p", module);
+ if (module)
g_module_close(module);
- mm_util_debug("#End g_module_close#");
- module = NULL;
- } else {
- mm_util_error("#module is NULL#");
- ret = MM_UTIL_ERROR_INVALID_PARAMETER;
- }
MMUTIL_SAFE_G_FREE(_imgp_info_s->input_format_label);
MMUTIL_SAFE_G_FREE(_imgp_info_s->output_format_label);
MMUTIL_SAFE_FREE(_imgp_info_s);
- return ret;
+ 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,
return ret;
}
-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)
+static IMGPInfoFunc __mm_util_initialize(imgp_type_e function, mm_util_img_format src_format, mm_util_img_format dst_format, GModule **module)
{
- int ret = MM_UTIL_ERROR_NONE;
- unsigned char *output_buffer = NULL;
- unsigned int output_buffer_size = 0;
+ imgp_plugin_type_e _imgp_plugin_type_e = IMGP_GSTCS;
+ GModule *_module = NULL;
+ IMGPInfoFunc _func = NULL;
- mm_util_fenter();
+ if (function == IMGP_CSC) {
+ if (__mm_select_convert_plugin(src_format, dst_format))
+ _imgp_plugin_type_e = IMGP_NEON;
- if (!src || !dst) {
- mm_util_error("invalid src or dst");
- return MM_UTIL_ERROR_INVALID_PARAMETER;
+ } else if (function == IMGP_RSZ) {
+ if (__mm_select_resize_plugin(src_format))
+ _imgp_plugin_type_e = IMGP_NEON;
+
+ } else if (function == IMGP_ROT) {
+ if (__mm_select_rotate_plugin(src_format))
+ _imgp_plugin_type_e = IMGP_NEON;
+
+ } else {
+ mm_util_error("invalid function : [%d]", function);
}
- if ((src_format < MM_UTIL_IMG_FMT_YUV420) || (src_format > MM_UTIL_IMG_FMT_NUM) || (dst_format < MM_UTIL_IMG_FMT_YUV420) || (dst_format > MM_UTIL_IMG_FMT_NUM)) {
- mm_util_error("#ERROR# src_format : [%d] dst_format : [%d] value ", src_format, dst_format);
- return MM_UTIL_ERROR_INVALID_PARAMETER;
+ mm_util_debug("plugin type: %d", _imgp_plugin_type_e);
+
+ _module = __mm_util_imgp_initialize(_imgp_plugin_type_e);
+ mm_util_debug("__mm_util_imgp_initialize: %p", _module);
+
+ if (_module == NULL) { /* when IMGP_NEON is NULL */
+ _imgp_plugin_type_e = IMGP_GSTCS;
+ mm_util_debug("You use %s module", PATH_GSTCS_LIB);
+ _module = __mm_util_imgp_initialize(_imgp_plugin_type_e);
}
- if (__mm_cannot_convert_format(src_format, dst_format)) {
- mm_util_error("#ERROR# Cannot Support Image Format Convert");
- return MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
+ mm_util_debug("mm_util_imgp_func: %p", _module);
+
+ if (_module == NULL) {
+ mm_util_error("invalid module");
+ return NULL;
}
- mm_util_debug("(%d x %d)", src_width, src_height);
+ g_module_symbol(_module, IMGP_FUNC_NAME, (gpointer *)&_func);
- imgp_info_s *_imgp_info_s = (imgp_info_s *) calloc(1, sizeof(imgp_info_s));
- if (_imgp_info_s == NULL) {
- mm_util_error("ERROR - alloc handle");
- return MM_UTIL_ERROR_OUT_OF_MEMORY;
+ if (_func == NULL) {
+ mm_util_error("invalid function");
+ g_module_close(_module);
+ return NULL;
}
+ *module = _module;
+
+ 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 ret = MM_UTIL_ERROR_NONE;
IMGPInfoFunc _mm_util_imgp_func = NULL;
GModule *_module = NULL;
- imgp_plugin_type_e _imgp_plugin_type_e = 0;
+ unsigned char *output_buffer = NULL;
+ unsigned int output_buffer_size = 0;
- /* Initialize */
- if (__mm_select_convert_plugin(src_format, dst_format))
- _imgp_plugin_type_e = IMGP_NEON;
- else
- _imgp_plugin_type_e = IMGP_GSTCS;
+ 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_debug("plugin type: %d", _imgp_plugin_type_e);
+ if (__mm_cannot_convert_format(src_format, dst_format)) {
+ mm_util_error("#ERROR# Cannot Support Image Format Convert");
+ return MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
+ }
- _module = __mm_util_imgp_initialize(_imgp_plugin_type_e);
- mm_util_debug("__mm_util_imgp_initialize: %p", _module);
+ mm_util_debug("src_width [%d] src_height [%d] src_format[%d]", src_width, src_height, src_format);
- if (_module == NULL) { /* when IMGP_NEON is NULL */
- _imgp_plugin_type_e = IMGP_GSTCS;
- mm_util_debug("You use %s module", PATH_GSTCS_LIB);
- _module = __mm_util_imgp_initialize(_imgp_plugin_type_e);
+ _mm_util_imgp_func = __mm_util_initialize(IMGP_CSC, src_format, dst_format, &_module);
+ if (_mm_util_imgp_func == NULL) {
+ mm_util_error("ERROR - __mm_util_initialize");
+ return MM_UTIL_ERROR_INVALID_OPERATION;
+ }
+
+ imgp_info_s *_imgp_info_s = (imgp_info_s *) calloc(1, sizeof(imgp_info_s));
+ if (_imgp_info_s == NULL) {
+ mm_util_error("ERROR - alloc handle");
+ ret = MM_UTIL_ERROR_OUT_OF_MEMORY;
+ goto ERROR;
}
- mm_util_debug("mm_util_imgp_func: %p", _module);
ret = __mm_set_imgp_info_s(_imgp_info_s, src_format, src_width, src_height, dst_format, src_width, src_height, MM_UTIL_ROTATE_0);
if (ret != MM_UTIL_ERROR_NONE) {
mm_util_error("__mm_set_imgp_info_s failed");
- __mm_util_imgp_finalize(_module, _imgp_info_s);
- return MM_UTIL_ERROR_INVALID_PARAMETER;
+ ret = MM_UTIL_ERROR_INVALID_OPERATION;
+ goto ERROR;
}
+
mm_util_debug("Sucess __mm_set_imgp_info_s");
ret = __mm_util_get_buffer_size(dst_format, src_width, src_height, &output_buffer_size);
if (ret != MM_UTIL_ERROR_NONE) {
- mm_util_error("__mm_set_imgp_info_s failed");
- __mm_util_imgp_finalize(_module, _imgp_info_s);
- return ret;
+ mm_util_error("__mm_util_get_buffer_size failed");
+ goto ERROR;
}
output_buffer = (unsigned char *) calloc(1, output_buffer_size);
if (output_buffer == NULL) {
mm_util_error("memory allocation failed");
- __mm_util_imgp_finalize(_module, _imgp_info_s);
- return MM_UTIL_ERROR_OUT_OF_MEMORY;
+ ret = MM_UTIL_ERROR_OUT_OF_MEMORY;
+ goto ERROR;
}
mm_util_debug("memory allocation outputbuffer: %p (%d)", output_buffer, output_buffer_size);
- /* image processing */
- _mm_util_imgp_func = __mm_util_imgp_process(_module);
- mm_util_debug("Sucess __mm_util_imgp_process");
-
- if (_mm_util_imgp_func) {
- ret = _mm_util_imgp_func(_imgp_info_s, src, output_buffer, IMGP_CSC);
- if (ret != MM_UTIL_ERROR_NONE) {
- mm_util_error("image processing failed");
- __mm_util_imgp_finalize(_module, _imgp_info_s);
- MMUTIL_SAFE_FREE(output_buffer);
- return ret;
- }
- } else {
- mm_util_error("g_module_symbol failed");
- __mm_util_imgp_finalize(_module, _imgp_info_s);
- MMUTIL_SAFE_FREE(output_buffer);
- return MM_UTIL_ERROR_INVALID_PARAMETER;
+ ret = _mm_util_imgp_func(_imgp_info_s, src, output_buffer, IMGP_CSC);
+ if (ret != MM_UTIL_ERROR_NONE) {
+ mm_util_error("image processing failed");
+ goto ERROR;
}
if ((_imgp_info_s->dst_width != _imgp_info_s->output_stride || _imgp_info_s->dst_height != _imgp_info_s->output_elevation) && __mm_is_rgb_format(src_format)) {
ret = mm_util_crop_image(output_buffer, _imgp_info_s->output_stride, _imgp_info_s->output_elevation, dst_format, 0, 0, &_imgp_info_s->dst_width, &_imgp_info_s->dst_height, dst);
if (ret != MM_UTIL_ERROR_NONE) {
- mm_util_error("__mm_util_imgp_finalize failed");
- MMUTIL_SAFE_FREE(output_buffer);
- return MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
+ mm_util_error("mm_util_crop_image failed");
+ ret = MM_UTIL_ERROR_INVALID_OPERATION;
+ goto ERROR;
}
} else {
memcpy(dst, output_buffer, _imgp_info_s->buffer_size);
mm_util_debug("dst: %p dst_width: %d, dst_height: %d, output_stride: %d, output_elevation: %d",
dst, _imgp_info_s->dst_width, _imgp_info_s->dst_height, _imgp_info_s->output_stride, _imgp_info_s->output_elevation);
+ERROR:
/* Finalize */
- ret = __mm_util_imgp_finalize(_module, _imgp_info_s);
- if (ret != MM_UTIL_ERROR_NONE) {
- mm_util_error("__mm_util_imgp_finalize failed");
- MMUTIL_SAFE_FREE(output_buffer);
- return MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
- }
+ __mm_util_imgp_finalize(_module, _imgp_info_s);
MMUTIL_SAFE_FREE(output_buffer);
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 ret = MM_UTIL_ERROR_NONE;
+ IMGPInfoFunc _mm_util_imgp_func = NULL;
+ GModule *_module = NULL;
unsigned char *output_buffer = NULL;
unsigned int output_buffer_size = 0;
- mm_util_fenter();
+ 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(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");
- if (!src || !dst) {
- mm_util_error("invalid argument");
- return MM_UTIL_ERROR_INVALID_PARAMETER;
- }
+ mm_util_debug("src_width [%d] src_height [%d] src_format[%d]", src_width, src_height, src_format);
- if ((src_format < MM_UTIL_IMG_FMT_YUV420) || (src_format > MM_UTIL_IMG_FMT_NUM)) {
- mm_util_error("#ERROR# src_format value ");
- return MM_UTIL_ERROR_INVALID_PARAMETER;
- }
-
- if (!dst_width || !dst_height) {
- mm_util_error("#ERROR# dst width/height buffer is NULL");
- return MM_UTIL_ERROR_INVALID_PARAMETER;
- }
-
- if (!src_width || !src_height) {
- mm_util_error("#ERROR# src_width || src_height valuei is 0 ");
- return MM_UTIL_ERROR_INVALID_PARAMETER;
+ _mm_util_imgp_func = __mm_util_initialize(IMGP_RSZ, src_format, 0, &_module);
+ if (_mm_util_imgp_func == NULL) {
+ mm_util_error("ERROR - __mm_util_initialize");
+ return MM_UTIL_ERROR_INVALID_OPERATION;
}
- mm_util_debug("(%d x %d)", src_width, src_height);
-
imgp_info_s *_imgp_info_s = (imgp_info_s *) calloc(1, sizeof(imgp_info_s));
if (_imgp_info_s == NULL) {
mm_util_error("ERROR - alloc handle");
- return MM_UTIL_ERROR_OUT_OF_MEMORY;
- }
-
- IMGPInfoFunc _mm_util_imgp_func = NULL;
- GModule *_module = NULL;
- imgp_plugin_type_e _imgp_plugin_type_e = 0;
-
- /* Initialize */
- if (__mm_select_resize_plugin(src_format))
- _imgp_plugin_type_e = IMGP_NEON;
- else
- _imgp_plugin_type_e = IMGP_GSTCS;
-
- mm_util_debug("plugin type: %d", _imgp_plugin_type_e);
-
- _module = __mm_util_imgp_initialize(_imgp_plugin_type_e);
- mm_util_debug("__mm_util_imgp_initialize: %p", _module);
- /* when IMGP_NEON is NULL */
- if (_module == NULL) {
- _imgp_plugin_type_e = IMGP_GSTCS;
- mm_util_debug("You use %s module", PATH_GSTCS_LIB);
- _module = __mm_util_imgp_initialize(_imgp_plugin_type_e);
+ ret = MM_UTIL_ERROR_OUT_OF_MEMORY;
+ goto ERROR;
}
mm_util_debug("__mm_set_imgp_info_s");
ret = __mm_set_imgp_info_s(_imgp_info_s, src_format, src_width, src_height, src_format, *dst_width, *dst_height, MM_UTIL_ROTATE_0);
if (ret != MM_UTIL_ERROR_NONE) {
mm_util_error("__mm_set_imgp_info_s failed [%d]", ret);
- __mm_util_imgp_finalize(_module, _imgp_info_s);
- return MM_UTIL_ERROR_INVALID_PARAMETER;
+ ret = MM_UTIL_ERROR_INVALID_OPERATION;
+ goto ERROR;
}
mm_util_debug("Sucess __mm_set_imgp_info_s");
if (g_strrstr(g_module_name(_module), GST)) {
if (__mm_gst_can_resize_format(_imgp_info_s->input_format_label) == FALSE) {
mm_util_error("#RESIZE ERROR# IMAGE_NOT_SUPPORT_FORMAT");
- __mm_util_imgp_finalize(_module, _imgp_info_s);
- return MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
+ ret = MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
+ goto ERROR;
}
}
ret = __mm_util_get_buffer_size(src_format, *dst_width, *dst_height, &output_buffer_size);
if (ret != MM_UTIL_ERROR_NONE) {
- mm_util_error("__mm_set_imgp_info_s failed");
- __mm_util_imgp_finalize(_module, _imgp_info_s);
- return ret;
+ mm_util_error("__mm_util_get_buffer_size failed");
+ goto ERROR;
}
output_buffer = (unsigned char *) calloc(1, output_buffer_size);
if (output_buffer == NULL) {
mm_util_error("memory allocation failed");
- __mm_util_imgp_finalize(_module, _imgp_info_s);
- return MM_UTIL_ERROR_OUT_OF_MEMORY;
+ ret = MM_UTIL_ERROR_OUT_OF_MEMORY;
+ goto ERROR;
}
mm_util_debug("memory allocation outputbuffer: %p (%d)", output_buffer, output_buffer_size);
- /* image processing */
- _mm_util_imgp_func = __mm_util_imgp_process(_module);
- mm_util_debug("Sucess __mm_util_imgp_process");
- if (_mm_util_imgp_func) {
- ret = _mm_util_imgp_func(_imgp_info_s, src, output_buffer, IMGP_RSZ);
- mm_util_debug("_mm_util_imgp_func, ret: %d", ret);
- if (ret != MM_UTIL_ERROR_NONE) {
- mm_util_error("image processing failed");
- __mm_util_imgp_finalize(_module, _imgp_info_s);
- MMUTIL_SAFE_FREE(output_buffer);
- return ret;
- }
- } else {
- mm_util_error("g_module_symbol failed");
- __mm_util_imgp_finalize(_module, _imgp_info_s);
- MMUTIL_SAFE_FREE(output_buffer);
- return MM_UTIL_ERROR_INVALID_PARAMETER;
+ ret = _mm_util_imgp_func(_imgp_info_s, src, output_buffer, IMGP_RSZ);
+ mm_util_debug("_mm_util_imgp_func, ret: %d", ret);
+ if (ret != MM_UTIL_ERROR_NONE) {
+ mm_util_error("image processing failed");
+ goto ERROR;
}
if ((_imgp_info_s->dst_width != _imgp_info_s->output_stride || _imgp_info_s->dst_height != _imgp_info_s->output_elevation) && __mm_is_rgb_format(src_format)) {
mm_util_debug("dst: %p dst_width: %d, dst_height: %d, output_stride: %d, output_elevation: %d",
dst, _imgp_info_s->dst_width, _imgp_info_s->dst_height, _imgp_info_s->output_stride, _imgp_info_s->output_elevation);
+ERROR:
/* Finalize */
- ret = __mm_util_imgp_finalize(_module, _imgp_info_s);
- if (ret != MM_UTIL_ERROR_NONE) {
- mm_util_error("__mm_util_imgp_finalize failed");
- MMUTIL_SAFE_FREE(output_buffer);
- return MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
- }
+ __mm_util_imgp_finalize(_module, _imgp_info_s);
MMUTIL_SAFE_FREE(output_buffer);
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 ret = MM_UTIL_ERROR_NONE;
+ IMGPInfoFunc _mm_util_imgp_func = NULL;
+ GModule *_module = NULL;
unsigned char *output_buffer = NULL;
unsigned int output_buffer_size = 0;
- mm_util_fenter();
-
- if (!src || !dst) {
- mm_util_error("invalid argument");
- return MM_UTIL_ERROR_INVALID_PARAMETER;
- }
-
- if ((src_format < MM_UTIL_IMG_FMT_YUV420) || (src_format > MM_UTIL_IMG_FMT_NUM)) {
- mm_util_error("#ERROR# src_format value");
- return MM_UTIL_ERROR_INVALID_PARAMETER;
- }
-
- if (!dst_width || !dst_height) {
- mm_util_error("#ERROR# dst width/height buffer is NUL");
- return MM_UTIL_ERROR_INVALID_PARAMETER;
- }
+ 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(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");
+ mm_util_retvm_if((angle < MM_UTIL_ROTATE_0) || (angle >= MM_UTIL_ROTATE_NUM), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid angle [%d]", angle);
- if (!src_width || !src_height) {
- mm_util_error("#ERROR# src_width || src_height value is 0 ");
- return MM_UTIL_ERROR_INVALID_PARAMETER;
- }
+ mm_util_debug("src_width [%d] src_height [%d] src_format[%d]", src_width, src_height, src_format);
- if ((angle < MM_UTIL_ROTATE_0) || (angle > MM_UTIL_ROTATE_NUM)) {
- mm_util_error("#ERROR# angle vaule");
- return MM_UTIL_ERROR_INVALID_PARAMETER;
+ _mm_util_imgp_func = __mm_util_initialize(IMGP_ROT, src_format, 0, &_module);
+ if (_mm_util_imgp_func == NULL) {
+ mm_util_error("ERROR - __mm_util_initialize");
+ return MM_UTIL_ERROR_INVALID_OPERATION;
}
- mm_util_debug("(%d x %d)", src_width, src_height);
-
imgp_info_s *_imgp_info_s = (imgp_info_s *) calloc(1, sizeof(imgp_info_s));
if (_imgp_info_s == NULL) {
mm_util_error("ERROR - alloc handle");
- return MM_UTIL_ERROR_INVALID_PARAMETER;
- }
- IMGPInfoFunc _mm_util_imgp_func = NULL;
- GModule *_module = NULL;
- imgp_plugin_type_e _imgp_plugin_type_e = 0;
-
- /* Initialize */
- if (__mm_select_rotate_plugin(src_format, src_width, src_height, angle))
- _imgp_plugin_type_e = IMGP_NEON;
- else
- _imgp_plugin_type_e = IMGP_GSTCS;
-
- mm_util_debug("plugin type: %d", _imgp_plugin_type_e);
-
- _module = __mm_util_imgp_initialize(_imgp_plugin_type_e);
- mm_util_debug("__mm_util_imgp_initialize: %p", _module);
- if (_module == NULL) { /* when IMGP_NEON is NULL */
- _imgp_plugin_type_e = IMGP_GSTCS;
- mm_util_debug("You use %s module", PATH_GSTCS_LIB);
- _module = __mm_util_imgp_initialize(_imgp_plugin_type_e);
+ ret = MM_UTIL_ERROR_OUT_OF_MEMORY;
+ goto ERROR;
}
mm_util_debug("__mm_confirm_dst_width_height");
ret = __mm_confirm_dst_width_height(src_width, src_height, dst_width, dst_height, angle);
if (ret != MM_UTIL_ERROR_NONE) {
mm_util_error("dst_width || dest_height size Error");
- __mm_util_imgp_finalize(_module, _imgp_info_s);
- return MM_UTIL_ERROR_INVALID_PARAMETER;
+ ret = MM_UTIL_ERROR_INVALID_PARAMETER;
+ goto ERROR;
}
ret = __mm_set_imgp_info_s(_imgp_info_s, src_format, src_width, src_height, src_format, *dst_width, *dst_height, angle);
mm_util_debug("__mm_set_imgp_info_s");
if (ret != MM_UTIL_ERROR_NONE) {
mm_util_error("__mm_set_imgp_info_s failed");
- __mm_util_imgp_finalize(_module, _imgp_info_s);
- return MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
+ ret = MM_UTIL_ERROR_INVALID_OPERATION;
+ goto ERROR;
}
mm_util_debug("Sucess __mm_set_imgp_info_s");
if (g_strrstr(g_module_name(_module), GST)) {
if (__mm_gst_can_rotate_format(_imgp_info_s->input_format_label) == FALSE) {
mm_util_error("#gstreamer ROTATE ERROR# IMAGE_NOT_SUPPORT_FORMAT");
- __mm_util_imgp_finalize(_module, _imgp_info_s);
- return MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
+ ret = MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
+ goto ERROR;
}
}
ret = __mm_util_get_buffer_size(src_format, *dst_width, *dst_height, &output_buffer_size);
if (ret != MM_UTIL_ERROR_NONE) {
- mm_util_error("__mm_set_imgp_info_s failed");
- __mm_util_imgp_finalize(_module, _imgp_info_s);
- return ret;
+ mm_util_error("__mm_util_get_buffer_size failed");
+ goto ERROR;
}
output_buffer = (unsigned char *) calloc(1, output_buffer_size);
if (output_buffer == NULL) {
mm_util_error("memory allocation failed");
- __mm_util_imgp_finalize(_module, _imgp_info_s);
- return MM_UTIL_ERROR_OUT_OF_MEMORY;
+ ret = MM_UTIL_ERROR_OUT_OF_MEMORY;
+ goto ERROR;
}
mm_util_debug("memory allocation outputbuffer: %p (%d)", output_buffer, output_buffer_size);
- /* image processing */
- _mm_util_imgp_func = __mm_util_imgp_process(_module);
- mm_util_debug("Sucess __mm_util_imgp_process");
- if (_mm_util_imgp_func) {
- ret = _mm_util_imgp_func(_imgp_info_s, src, output_buffer, IMGP_ROT);
- if (ret != MM_UTIL_ERROR_NONE) {
- mm_util_error("image processing failed");
- __mm_util_imgp_finalize(_module, _imgp_info_s);
- MMUTIL_SAFE_FREE(output_buffer);
- return ret;
- }
- } else {
- mm_util_error("g_module_symbol failed");
- __mm_util_imgp_finalize(_module, _imgp_info_s);
- MMUTIL_SAFE_FREE(output_buffer);
- return MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
+ ret = _mm_util_imgp_func(_imgp_info_s, src, output_buffer, IMGP_ROT);
+ if (ret != MM_UTIL_ERROR_NONE) {
+ mm_util_error("image processing failed");
+ goto ERROR;
}
if ((_imgp_info_s->dst_width != _imgp_info_s->output_stride || _imgp_info_s->dst_height != _imgp_info_s->output_elevation) && __mm_is_rgb_format(src_format)) {
mm_util_debug("dst: %p dst_width: %d, dst_height: %d, output_stride: %d, output_elevation: %d",
dst, _imgp_info_s->dst_width, _imgp_info_s->dst_height, _imgp_info_s->output_stride, _imgp_info_s->output_elevation);
+ERROR:
/* Finalize */
- ret = __mm_util_imgp_finalize(_module, _imgp_info_s);
- if (ret != MM_UTIL_ERROR_NONE) {
- mm_util_error("__mm_util_imgp_finalize failed");
- MMUTIL_SAFE_FREE(output_buffer);
- return MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
- }
+ __mm_util_imgp_finalize(_module, _imgp_info_s);
MMUTIL_SAFE_FREE(output_buffer);
{
int ret = MM_UTIL_ERROR_NONE;
- mm_util_fenter();
-
- if (!src || !dst) {
- mm_util_error("invalid argument");
- return MM_UTIL_ERROR_INVALID_PARAMETER;
- }
-
- if ((src_format < MM_UTIL_IMG_FMT_YUV420) || (src_format > MM_UTIL_IMG_FMT_NUM)) {
- mm_util_error("#ERROR# src_format value");
- return MM_UTIL_ERROR_INVALID_PARAMETER;
- }
-
- if ((crop_start_x + *crop_dest_width > src_width) || (crop_start_y + *crop_dest_height > src_height)) {
- mm_util_error("#ERROR# dest width | height value");
- return MM_UTIL_ERROR_INVALID_PARAMETER;
- }
+ 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(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);
mm_util_debug("[Input] src: [%p] src_width: [%ui] src_height: [%ui] src_format: [%d] crop_start_x: [%ui] crop_start_y: [%ui] crop_dest_width: [%ui] crop_dest_height: [%ui]",
src, src_width, src_height, src_format, crop_start_x, crop_start_y, *crop_dest_width, *crop_dest_height);