return _bool;
}
-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_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_color_format_e _format)
-{
- gboolean _bool = FALSE;
-
- mm_util_debug("_format: %d", _format);
-
- 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_color_format_e _format)
-{
- mm_util_debug("_format: %d", _format);
-
- 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 int __mm_util_get_crop_image_size(mm_util_color_format_e format, unsigned int width, unsigned int height, size_t *imgsize)
{
unsigned char x_chroma_shift = 0;
return ret;
}
-static GModule *__mm_util_imgp_initialize(imgp_plugin_type_e _imgp_plugin_type_e)
-{
- GModule *module = NULL;
- mm_util_fenter();
-
- if (_imgp_plugin_type_e == IMGP_NEON)
- module = g_module_open(PATH_NEON_LIB, G_MODULE_BIND_LAZY);
- else if (_imgp_plugin_type_e == IMGP_GSTCS)
- module = g_module_open(PATH_GSTCS_LIB, G_MODULE_BIND_LAZY);
-
- mm_util_retvm_if(module == NULL, NULL, "[%d] %s | %s module open failed", _imgp_plugin_type_e, PATH_NEON_LIB, PATH_GSTCS_LIB);
- mm_util_debug("module: %p, g_module_name: %s", module, g_module_name(module));
-
- return module;
-}
-
static void __mm_util_imgp_finalize(GModule *module, imgp_info_s *_imgp_info_s)
{
if (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)
+static IMGPInfoFunc __mm_util_initialize(GModule **module)
{
- imgp_plugin_type_e _imgp_plugin_type_e = IMGP_GSTCS;
GModule *_module = NULL;
IMGPInfoFunc _func = NULL;
- if (function == IMGP_CSC) {
- if (__mm_select_convert_plugin(src_format, dst_format))
- _imgp_plugin_type_e = IMGP_NEON;
-
- } 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;
+ _module = g_module_open(PATH_GSTCS_LIB, G_MODULE_BIND_LAZY);
+ mm_util_retvm_if(!module, NULL, "%s module open failed", PATH_GSTCS_LIB);
- } else {
- mm_util_error("invalid function : [%d]", function);
- }
-
- mm_util_debug("plugin type: %d", _imgp_plugin_type_e);
-
- _module = __mm_util_imgp_initialize(_imgp_plugin_type_e);
-
- 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_debug("mm_util_imgp_func: %p", _module);
-
- if (_module == NULL) {
- mm_util_error("invalid module");
- return NULL;
- }
+ mm_util_debug("module: %p, g_module_name: %s", _module, g_module_name(_module));
g_module_symbol(_module, IMGP_FUNC_NAME, (gpointer *)&_func);
- if (_func == NULL) {
+ if (!_func) {
mm_util_error("invalid function");
g_module_close(_module);
return NULL;
mm_util_debug("[Input] format[%d]", color);
mm_image_debug_image(src, "Input");
- _mm_util_imgp_func = __mm_util_initialize(IMGP_CSC, _src->color, color, &_module);
- if (_mm_util_imgp_func == NULL) {
- mm_util_error("ERROR - __mm_util_initialize");
- return MM_UTIL_ERROR_INVALID_OPERATION;
- }
+ _mm_util_imgp_func = __mm_util_initialize(&_module);
+ mm_util_retvm_if(!_mm_util_imgp_func, MM_UTIL_ERROR_INVALID_OPERATION, "failed to __mm_util_initialize()");
_imgp_info_s = g_new0(imgp_info_s, 1);
mm_util_debug("[Input] width[%u] height[%u]", width, height);
mm_image_debug_image(src, "Input");
- _mm_util_imgp_func = __mm_util_initialize(IMGP_RSZ, _src->color, 0, &_module);
- mm_util_retvm_if(_mm_util_imgp_func == NULL, MM_UTIL_ERROR_INVALID_OPERATION, "fail __mm_util_initialize");
+ _mm_util_imgp_func = __mm_util_initialize(&_module);
+ mm_util_retvm_if(!_mm_util_imgp_func, MM_UTIL_ERROR_INVALID_OPERATION, "failed to __mm_util_initialize()");
_imgp_info_s = g_new0(imgp_info_s, 1);
mm_util_debug("[Input] angle[%d]", angle);
mm_image_debug_image(src, "Input");
- _mm_util_imgp_func = __mm_util_initialize(IMGP_ROT, _src->color, 0, &_module);
- if (_mm_util_imgp_func == NULL) {
- mm_util_error("ERROR - __mm_util_initialize");
- return MM_UTIL_ERROR_INVALID_OPERATION;
- }
+ _mm_util_imgp_func = __mm_util_initialize(&_module);
+ mm_util_retvm_if(!_mm_util_imgp_func, MM_UTIL_ERROR_INVALID_OPERATION, "failed to __mm_util_initialize()");
_imgp_info_s = g_new0(imgp_info_s, 1);