return _bool;
}
-static gboolean __mm_gst_can_resize_format(char *__format_label)
+static gboolean __mm_gst_can_resize_format(mm_util_color_format_e color_format)
{
gboolean _bool = FALSE;
- mm_util_debug("Format label: %s", __format_label);
-
- if (strcmp(__format_label, "AYUV") == 0
- || strcmp(__format_label, "UYVY") == 0 || strcmp(__format_label, "Y800") == 0 || strcmp(__format_label, "I420") == 0 || strcmp(__format_label, "YV12") == 0
- || strcmp(__format_label, "RGB888") == 0 || strcmp(__format_label, "RGB565") == 0 || strcmp(__format_label, "BGR888") == 0 || strcmp(__format_label, "RGBA8888") == 0
- || strcmp(__format_label, "ARGB8888") == 0 || strcmp(__format_label, "BGRA8888") == 0 || strcmp(__format_label, "ABGR8888") == 0 || strcmp(__format_label, "RGBX") == 0
- || strcmp(__format_label, "XRGB") == 0 || strcmp(__format_label, "BGRX") == 0 || strcmp(__format_label, "XBGR") == 0 || strcmp(__format_label, "Y444") == 0
- || strcmp(__format_label, "Y42B") == 0 || strcmp(__format_label, "YUY2") == 0 || strcmp(__format_label, "YUYV") == 0 || strcmp(__format_label, "UYVY") == 0
- || strcmp(__format_label, "Y41B") == 0 || strcmp(__format_label, "Y16") == 0 || strcmp(__format_label, "Y800") == 0 || strcmp(__format_label, "Y8") == 0
- || strcmp(__format_label, "GREY") == 0 || strcmp(__format_label, "AY64") == 0 || strcmp(__format_label, "YUV422") == 0) {
+ mm_util_debug("color_format [%d]", color_format);
+ switch (color_format) {
+ case MM_UTIL_COLOR_YUV420:
+ case MM_UTIL_COLOR_YUV422:
+ case MM_UTIL_COLOR_I420:
+ case MM_UTIL_COLOR_UYVY:
+ case MM_UTIL_COLOR_YUYV:
+ case MM_UTIL_COLOR_RGB16:
+ case MM_UTIL_COLOR_RGB24:
+ case MM_UTIL_COLOR_ARGB:
+ case MM_UTIL_COLOR_BGRA:
+ case MM_UTIL_COLOR_RGBA:
+ case MM_UTIL_COLOR_BGRX:
_bool = TRUE;
+ break;
+ default:
+ mm_util_error("Not supported format"); //only not support NV12
}
return _bool;
}
-static gboolean __mm_gst_can_rotate_format(const char *__format_label)
+static gboolean __mm_gst_can_rotate_format(mm_util_color_format_e color_format)
{
gboolean _bool = FALSE;
- mm_util_debug("Format label: %s boolean: %d", __format_label, _bool);
-
- if (strcmp(__format_label, "I420") == 0 || strcmp(__format_label, "YV12") == 0 || strcmp(__format_label, "IYUV") == 0
- || strcmp(__format_label, "RGB888") == 0 || strcmp(__format_label, "BGR888") == 0 || strcmp(__format_label, "RGBA8888") == 0
- || strcmp(__format_label, "ARGB8888") == 0 || strcmp(__format_label, "BGRA8888") == 0 || strcmp(__format_label, "ABGR8888") == 0) {
+ mm_util_debug("color_format [%d]", color_format);
+ switch (color_format) {
+ case MM_UTIL_COLOR_YUV420:
+ case MM_UTIL_COLOR_I420:
+ case MM_UTIL_COLOR_RGB24:
+ case MM_UTIL_COLOR_ARGB:
+ case MM_UTIL_COLOR_BGRA:
+ case MM_UTIL_COLOR_RGBA:
_bool = TRUE;
+ break;
+ default:
+ mm_util_error("Not supported format");
}
- mm_util_debug("boolean: %d", _bool);
-
return _bool;
}
return ret;
}
-static int __mm_set_format_label(imgp_info_s *_imgp_info_s, mm_util_color_format_e src_format, mm_util_color_format_e dst_format)
-{
- int ret = MM_UTIL_ERROR_NONE;
- char *src_fmt_lable = NULL;
- char *dst_fmt_lable = NULL;
-
- if (_imgp_info_s == NULL) {
- mm_util_error("Invalid _imgp_info_s");
- return MM_UTIL_ERROR_INVALID_PARAMETER;
- }
-
- switch (src_format) {
- case MM_UTIL_COLOR_YUV420:
- src_fmt_lable = (char *)"YV12";
- break;
- case MM_UTIL_COLOR_YUV422:
- src_fmt_lable = (char *)"Y42B";
- break;
- case MM_UTIL_COLOR_I420:
- src_fmt_lable = (char *)"I420";
- break;
- case MM_UTIL_COLOR_NV12:
- src_fmt_lable = (char *)"NV12";
- break;
- case MM_UTIL_COLOR_UYVY:
- src_fmt_lable = (char *)"UYVY";
- break;
- case MM_UTIL_COLOR_YUYV:
- src_fmt_lable = (char *)"YUYV";
- break;
- case MM_UTIL_COLOR_RGB16:
- src_fmt_lable = (char *)"RGB565";
- break;
- case MM_UTIL_COLOR_RGB24:
- src_fmt_lable = (char *)"RGB888";
- break;
- case MM_UTIL_COLOR_ARGB:
- src_fmt_lable = (char *)"ARGB8888";
- break;
- case MM_UTIL_COLOR_BGRA:
- src_fmt_lable = (char *)"BGRA8888";
- break;
- case MM_UTIL_COLOR_RGBA:
- src_fmt_lable = (char *)"RGBA8888";
- break;
- case MM_UTIL_COLOR_BGRX:
- src_fmt_lable = (char *)"BGRX";
- break;
- default:
- mm_util_debug("[%d] Not supported format", src_format);
- break;
- }
-
- switch (dst_format) {
- case MM_UTIL_COLOR_YUV420:
- dst_fmt_lable = (char *)"YV12";
- break;
- case MM_UTIL_COLOR_YUV422:
- dst_fmt_lable = (char *)"Y42B";
- break;
- case MM_UTIL_COLOR_I420:
- dst_fmt_lable = (char *)"I420";
- break;
- case MM_UTIL_COLOR_NV12:
- dst_fmt_lable = (char *)"NV12";
- break;
- case MM_UTIL_COLOR_UYVY:
- dst_fmt_lable = (char *)"UYVY";
- break;
- case MM_UTIL_COLOR_YUYV:
- dst_fmt_lable = (char *)"YUYV";
- break;
- case MM_UTIL_COLOR_RGB16:
- dst_fmt_lable = (char *)"RGB565";
- break;
- case MM_UTIL_COLOR_RGB24:
- dst_fmt_lable = (char *)"RGB888";
- break;
- case MM_UTIL_COLOR_ARGB:
- dst_fmt_lable = (char *)"ARGB8888";
- break;
- case MM_UTIL_COLOR_BGRA:
- dst_fmt_lable = (char *)"BGRA8888";
- break;
- case MM_UTIL_COLOR_RGBA:
- dst_fmt_lable = (char *)"RGBA8888";
- break;
- case MM_UTIL_COLOR_BGRX:
- dst_fmt_lable = (char *)"BGRX";
- break;
- default:
- mm_util_error("[%d] Not supported format", dst_format);
- break;
- }
-
- if (src_fmt_lable && dst_fmt_lable) {
- unsigned int src_fmt_len = strlen(src_fmt_lable) + 1;
- unsigned int dst_fmt_len = strlen(dst_fmt_lable) + 1;
- mm_util_debug("src_fmt_lable: %s dst_fmt_lable: %s", src_fmt_lable, dst_fmt_lable);
- _imgp_info_s->input_format_label = (char *)calloc(1, src_fmt_len);
- if (_imgp_info_s->input_format_label == NULL) {
- mm_util_error("[input] input_format_label is null");
- return MM_UTIL_ERROR_OUT_OF_MEMORY;
- }
- memset(_imgp_info_s->input_format_label, 0, src_fmt_len);
- MMUTIL_SAFE_STRCPY(_imgp_info_s->input_format_label, src_fmt_lable, src_fmt_len);
-
- _imgp_info_s->output_format_label = (char *)calloc(1, dst_fmt_len);
- if (_imgp_info_s->output_format_label == NULL) {
- mm_util_error("[input] input_format_label is null");
- MMUTIL_SAFE_G_FREE(_imgp_info_s->input_format_label);
- return MM_UTIL_ERROR_OUT_OF_MEMORY;
- }
- memset(_imgp_info_s->output_format_label, 0, dst_fmt_len);
- MMUTIL_SAFE_STRCPY(_imgp_info_s->output_format_label, dst_fmt_lable, dst_fmt_len);
-
- mm_util_debug("input_format_label: %s output_format_label: %s", _imgp_info_s->input_format_label, _imgp_info_s->output_format_label);
- } else {
- mm_util_error("[error] src_fmt_lable && dst_fmt_lable");
- return MM_UTIL_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
static int __mm_set_imgp_info_s(imgp_info_s *_imgp_info_s, mm_util_color_format_e src_format, unsigned int src_width, unsigned int src_height, mm_util_color_format_e dst_format, unsigned int dst_width, unsigned int dst_height, mm_util_img_rotate_type angle)
{
int ret = MM_UTIL_ERROR_NONE;
return MM_UTIL_ERROR_INVALID_PARAMETER;
}
- ret = __mm_set_format_label(_imgp_info_s, src_format, dst_format);
- if (ret != MM_UTIL_ERROR_NONE) {
- mm_util_error("[input] mm_set_format_label error");
- return MM_UTIL_ERROR_INVALID_PARAMETER;
- }
-
_imgp_info_s->src_format = src_format;
_imgp_info_s->src_width = src_width;
_imgp_info_s->src_height = src_height;
_imgp_info_s->buffer_size = 0;
_imgp_info_s->angle = angle;
- mm_util_debug("[input] format label: %s width: %d height: %d [output] format label: %s width: %d height: %d rotation_value: %d",
- _imgp_info_s->input_format_label, _imgp_info_s->src_width, _imgp_info_s->src_height,
- _imgp_info_s->output_format_label, _imgp_info_s->dst_width, _imgp_info_s->dst_height, _imgp_info_s->angle);
+ mm_util_debug("width: %d height: %d width: %d height: %d rotation_value: %d", _imgp_info_s->src_width, _imgp_info_s->src_height, _imgp_info_s->dst_width, _imgp_info_s->dst_height, _imgp_info_s->angle);
return ret;
}
if (module)
g_module_close(module);
- 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;
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) {
+ if (__mm_gst_can_resize_format(_imgp_info_s->src_format) == FALSE) {
mm_util_error("#RESIZE ERROR# IMAGE_NOT_SUPPORT_FORMAT");
ret = MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
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) {
+ if (__mm_gst_can_rotate_format(_imgp_info_s->src_format) == FALSE) {
mm_util_error("#gstreamer ROTATE ERROR# IMAGE_NOT_SUPPORT_FORMAT");
ret = MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
goto ERROR;