Bug fix. Color swap problem when converting colorspace 16/319516/7
authorJiyong <jiyong.min@samsung.com>
Wed, 12 Feb 2025 07:40:55 +0000 (16:40 +0900)
committerJiyong <jiyong.min@samsung.com>
Wed, 19 Feb 2025 04:26:01 +0000 (13:26 +0900)
 - temporary fix
  Because I could not identify the clear cause.
  When color was converted, some results showed red and blue swapped,
  so it was modified to use formats that changed red and blue.

Change-Id: I61a35a96845455410f54df2a7090864489f7686c

gstcs/mm_util_gstcs.c
packaging/libmm-imgp-gstcs.spec

index 9060632118c414f7e42821f93913ec2b88c21041..0515c373dcab37632ccfcccfea18119e98952353 100644 (file)
@@ -115,7 +115,7 @@ static int _mm_get_byte_per_pixcel(mm_util_color_format_e color_format)
                byte_per_pixcel = 4;
                break;
        default:
-               gstcs_error("Not supported format");
+               gstcs_error("Not supported format [%d]", color_format);
                break;
        }
 
@@ -126,7 +126,6 @@ static int _mm_get_byte_per_pixcel(mm_util_color_format_e color_format)
 
 static int _mm_create_pipeline(gstreamer_s* pGstreamer_s)
 {
-       int ret = GSTCS_ERROR_NONE;
        pGstreamer_s->pipeline = gst_pipeline_new("pipeline");
        if (!pGstreamer_s->pipeline) {
                gstcs_error("pipeline could not be created. Exiting.\n");
@@ -162,7 +161,7 @@ static int _mm_create_pipeline(gstreamer_s* pGstreamer_s)
                gst_object_unref(pGstreamer_s->pipeline);
                return GSTCS_ERROR_INVALID_PARAMETER;
        }
-       return ret;
+       return GSTCS_ERROR_NONE;
 }
 
 static void _mm_destroy_notify(gpointer data)
@@ -209,13 +208,6 @@ _mm_link_pipeline(gstreamer_s* pGstreamer_s, int value)
 static GstVideoFormat _mm_get_video_format(mm_util_color_format_e color_format)
 {
        GstVideoFormat videoFormat = GST_VIDEO_FORMAT_UNKNOWN;
-       int _bpp = 0;
-       int _depth = 0;
-       int _red_mask = 0;
-       int _green_mask = 0;
-       int _blue_mask = 0;
-       int _alpha_mask = 0;
-       int _endianness = 0;
 
        switch (color_format) {
        case MM_UTIL_COLOR_YUV420:
@@ -228,7 +220,7 @@ static GstVideoFormat _mm_get_video_format(mm_util_color_format_e color_format)
                videoFormat = GST_VIDEO_FORMAT_I420;
                break;
        case MM_UTIL_COLOR_NV12:
-               videoFormat = GST_VIDEO_FORMAT_NV12;
+               videoFormat = GST_VIDEO_FORMAT_NV21;
                break;
        case MM_UTIL_COLOR_UYVY:
                videoFormat = GST_VIDEO_FORMAT_UYVY;
@@ -237,35 +229,29 @@ static GstVideoFormat _mm_get_video_format(mm_util_color_format_e color_format)
                videoFormat = GST_VIDEO_FORMAT_YVYU;
                break;
        case MM_UTIL_COLOR_RGB16:
-               _bpp = 16; _depth = 16; _red_mask = 63488; _green_mask = 2016; _blue_mask = 31; _endianness = 1234; _alpha_mask = 0;
-               videoFormat = gst_video_format_from_masks(_depth, _bpp, _endianness, _red_mask, _green_mask, _blue_mask, _alpha_mask);
+               videoFormat = GST_VIDEO_FORMAT_BGR16;
                break;
        case MM_UTIL_COLOR_RGB24:
-               _bpp = 24; _depth = 24; _red_mask = 16711680; _green_mask = 65280; _blue_mask = 255; _endianness = 4321; _alpha_mask = 0;
-               videoFormat = gst_video_format_from_masks(_depth, _bpp, _endianness, _red_mask, _green_mask, _blue_mask, _alpha_mask);
+               videoFormat = GST_VIDEO_FORMAT_BGR;
                break;
        case MM_UTIL_COLOR_ARGB:
-               _bpp = 32; _depth = 32; _red_mask = 16711680; _green_mask = 65280; _blue_mask = 255; _alpha_mask = -16777216; _endianness = 4321;
-               videoFormat = gst_video_format_from_masks(_depth, _bpp, _endianness, _red_mask, _green_mask, _blue_mask, _alpha_mask);
+               videoFormat = GST_VIDEO_FORMAT_ABGR;
                break;
        case MM_UTIL_COLOR_BGRA:
-               _bpp = 32; _depth = 32; _red_mask = 65280; _green_mask = 16711680; _blue_mask = -16777216; _alpha_mask = 255; _endianness = 4321;
-               videoFormat = gst_video_format_from_masks(_depth, _bpp, _endianness, _red_mask, _green_mask, _blue_mask, _alpha_mask);
+               videoFormat = GST_VIDEO_FORMAT_RGBA;
                break;
        case MM_UTIL_COLOR_RGBA:
-               _bpp = 32; _depth = 32; _red_mask = -16777216; _green_mask = 16711680; _blue_mask = 65280; _alpha_mask = 255; _endianness = 4321;
-               videoFormat = gst_video_format_from_masks(_depth, _bpp, _endianness, _red_mask, _green_mask, _blue_mask, _alpha_mask);
+               videoFormat = GST_VIDEO_FORMAT_BGRA;
                break;
        case MM_UTIL_COLOR_BGRX:
-               _bpp = 32; _depth = 24; _red_mask = 65280; _green_mask = 16711680; _blue_mask = -16777216; _endianness = 4321; _alpha_mask = 0;
-               videoFormat = gst_video_format_from_masks(_depth, _bpp, _endianness, _red_mask, _green_mask, _blue_mask, _alpha_mask);
+               videoFormat = GST_VIDEO_FORMAT_RGBx;
                break;
        default:
-               gstcs_error("Not supported format");
+               gstcs_error("Not supported format [%d]", color_format);
                break;
        }
 
-       gstcs_debug("color_format [%d], Chosen video format [%s]", color_format, gst_video_format_to_string(videoFormat));
+       gstcs_info("color_format [%d], Chosen video format [%s]", color_format, gst_video_format_to_string(videoFormat));
 
        return videoFormat;
 
@@ -320,7 +306,7 @@ static void _mm_get_round_up_width_height(mm_util_color_format_e color_format, u
                *elevation = MM_UTIL_ROUND_UP_2(height);
                break;
        default:
-               gstcs_error("Not supported format");
+               gstcs_error("Not supported format [%d]", color_format);
                break;
        }
 
@@ -477,7 +463,7 @@ static int _mm_imgp_gstcs_processing(gstreamer_s* pGstreamer_s, unsigned char *s
                SAFE_UNREF_CAPS(src_caps);
                SAFE_UNREF_CAPS(dst_caps);
                gst_object_unref(pGstreamer_s->pipeline);
-               return ret;
+               return GSTCS_ERROR_NOT_SUPPORTED_FORMAT;
        }
 
        gst_app_src_set_caps(GST_APP_SRC(pGstreamer_s->appsrc), src_caps);
index df0dc79c46fe4023a7bd43d675519dcaff5c5dbb..2acf733bc93fb0186fab11eba8d33f4f166b1031 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-imgp-gstcs
 Summary:    Multimedia Framework Utility Library
-Version:    0.28
+Version:    0.29
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0