diff options
author | hj kim <backto.kim@samsung.com> | 2018-02-12 17:38:13 +0900 |
---|---|---|
committer | hj kim <backto.kim@samsung.com> | 2018-02-12 17:38:13 +0900 |
commit | 8ce5eba6da993f98134c2f7f7cf2de1bbc2eed51 (patch) | |
tree | b50750066b9e012be443d5691e37901e154e7fe6 | |
parent | 28c6b4cfdebba9c47bf26f03c8a1cb073aad2f81 (diff) | |
download | libmm-imgp-gstcs-8ce5eba6da993f98134c2f7f7cf2de1bbc2eed51.tar.gz libmm-imgp-gstcs-8ce5eba6da993f98134c2f7f7cf2de1bbc2eed51.tar.bz2 libmm-imgp-gstcs-8ce5eba6da993f98134c2f7f7cf2de1bbc2eed51.zip |
Remove and unify duplicated Codes
Change-Id: I0d72a901e384a70bd02f9e6830463c470bbe472d
-rwxr-xr-x | gstcs/mm_util_gstcs.c | 158 | ||||
-rwxr-xr-x | packaging/libmm-imgp-gstcs.spec | 2 |
2 files changed, 23 insertions, 137 deletions
diff --git a/gstcs/mm_util_gstcs.c b/gstcs/mm_util_gstcs.c index c14dd5b..8cdc877 100755 --- a/gstcs/mm_util_gstcs.c +++ b/gstcs/mm_util_gstcs.c @@ -253,8 +253,7 @@ static GstVideoFormat _mm_get_video_format(char *format_label) } -static void -_mm_set_image_input_format_s_capabilities(image_format_s* __format) /*_format_label: I420 _colorsapace: YUV */ +static void _mm_set_capabilities(image_format_s* __format) { GstVideoFormat videoFormat = GST_VIDEO_FORMAT_UNKNOWN; @@ -267,8 +266,7 @@ _mm_set_image_input_format_s_capabilities(image_format_s* __format) /*_format_la videoFormat = _mm_get_video_format(__format->format_label); - if (strcmp(__format->colorspace, "YUV") == 0) { - __format->caps = gst_caps_new_simple("video/x-raw", + __format->caps = gst_caps_new_simple("video/x-raw", "format", G_TYPE_STRING, gst_video_format_to_string(videoFormat), "framerate", GST_TYPE_FRACTION, 25, 1, "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1, @@ -276,27 +274,6 @@ _mm_set_image_input_format_s_capabilities(image_format_s* __format) /*_format_la "height", G_TYPE_INT, __format->elevation, "framerate", GST_TYPE_FRACTION, 1, 1, NULL); - } - - else if (strcmp(__format->colorspace, "RGB") == 0 || strcmp(__format->colorspace, "BGRX") == 0) { - __format->caps = gst_caps_new_simple("video/x-raw", - "format", G_TYPE_STRING, gst_video_format_to_string(videoFormat), - "framerate", GST_TYPE_FRACTION, 25, 1, - "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1, - "width", G_TYPE_INT, __format->stride, - "height", G_TYPE_INT, __format->elevation, - "framerate", GST_TYPE_FRACTION, 1, 1, NULL); - } - - else if (strcmp(__format->colorspace, "RGBA") == 0) { - __format->caps = gst_caps_new_simple("video/x-raw", - "format", G_TYPE_STRING, gst_video_format_to_string(videoFormat), - "framerate", GST_TYPE_FRACTION, 25, 1, - "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1, - "width", G_TYPE_INT, __format->stride, - "height", G_TYPE_INT, __format->elevation, - "framerate", GST_TYPE_FRACTION, 1, 1, NULL); - } if (__format->caps) { gstcs_debug("###__format->caps is not NULL###, %p", __format->caps); @@ -306,82 +283,21 @@ _mm_set_image_input_format_s_capabilities(image_format_s* __format) /*_format_la } } -static void -_mm_set_image_output_format_s_capabilities(image_format_s* __format) /*_format_label: I420 _colorsapace: YUV */ -{ - GstVideoFormat videoFormat = GST_VIDEO_FORMAT_UNKNOWN; - - if (__format == NULL) { - gstcs_error("Image format is NULL\n"); - return; - } - - gstcs_debug("colorspace: %s(%d)\n", __format->colorspace, strlen(__format->colorspace)); - - videoFormat = _mm_get_video_format(__format->format_label); - - if (strcmp(__format->colorspace, "YUV") == 0) { - __format->caps = gst_caps_new_simple("video/x-raw", - "format", G_TYPE_STRING, gst_video_format_to_string(videoFormat), - "framerate", GST_TYPE_FRACTION, 25, 1, - "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1, - "width", G_TYPE_INT, __format->stride, - "height", G_TYPE_INT, __format->elevation, - "framerate", GST_TYPE_FRACTION, 1, 1, - NULL); - } - - else if (strcmp(__format->colorspace, "RGB") == 0 || strcmp(__format->colorspace, "BGRX") == 0) { - __format->caps = gst_caps_new_simple("video/x-raw", - "format", G_TYPE_STRING, gst_video_format_to_string(videoFormat), - "framerate", GST_TYPE_FRACTION, 25, 1, - "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1, - "width", G_TYPE_INT, __format->stride, - "height", G_TYPE_INT, __format->elevation, - "framerate", GST_TYPE_FRACTION, 1, 1, NULL); - } - - else if (strcmp(__format->colorspace, "RGBA") == 0) { - __format->caps = gst_caps_new_simple("video/x-raw", - "format", G_TYPE_STRING, gst_video_format_to_string(videoFormat), - "framerate", GST_TYPE_FRACTION, 25, 1, - "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1, - "width", G_TYPE_INT, __format->elevation, - "height", G_TYPE_INT, __format->elevation, - "framerate", GST_TYPE_FRACTION, 1, 1, NULL); - } - - if (__format->caps) { - gstcs_debug("###__format->caps is not NULL###, %p", __format->caps); - _mm_check_caps_format(__format->caps); - } else { - gstcs_error("__format->caps is NULL"); - } -} - -static void -_mm_set_image_colorspace(image_format_s* __format) +static void _mm_set_image_colorspace(image_format_s* __format) { gstcs_debug("format_label: %s\n", __format->format_label); - __format->colorspace = (char*)malloc(sizeof(char) * IMAGE_FORMAT_LABEL_BUFFER_SIZE); - if (__format->colorspace == NULL) { - gstcs_error("memory allocation failed"); - return; - } - memset(__format->colorspace, 0, IMAGE_FORMAT_LABEL_BUFFER_SIZE); if ((strcmp(__format->format_label, "I420") == 0) || (strcmp(__format->format_label, "Y42B") == 0) || (strcmp(__format->format_label, "Y444") == 0) || (strcmp(__format->format_label, "YV12") == 0) || (strcmp(__format->format_label, "NV12") == 0) || (strcmp(__format->format_label, "UYVY") == 0) || (strcmp(__format->format_label, "YUYV") == 0)) { - SAFE_STRCPY(__format->colorspace, "YUV", IMAGE_FORMAT_LABEL_BUFFER_SIZE); + __format->colorspace = g_strdup("YUV"); } else if ((strcmp(__format->format_label, "RGB888") == 0) || (strcmp(__format->format_label, "BGR888") == 0) || (strcmp(__format->format_label, "RGB565") == 0)) { - SAFE_STRCPY(__format->colorspace, "RGB", IMAGE_FORMAT_LABEL_BUFFER_SIZE); + __format->colorspace = g_strdup("RGB"); } else if ((strcmp(__format->format_label, "ARGB8888") == 0) || (strcmp(__format->format_label, "BGRA8888") == 0) || (strcmp(__format->format_label, "RGBA8888") == 0) || (strcmp(__format->format_label, "ABGR8888") == 0)) { - SAFE_STRCPY(__format->colorspace, "RGBA", IMAGE_FORMAT_LABEL_BUFFER_SIZE); + __format->colorspace = g_strdup("RGBA"); } else if ((strcmp(__format->format_label, "BGRX") == 0)) { - SAFE_STRCPY(__format->colorspace, "BGRX", IMAGE_FORMAT_LABEL_BUFFER_SIZE); + __format->colorspace = g_strdup("BGRX"); } else { gstcs_error("Check your colorspace format label"); - GSTCS_FREE(__format->colorspace); } } @@ -416,8 +332,7 @@ static void _gstcs_destroy_image_format(image_format_s *format) } } -static void -_mm_round_up_input_image_widh_height(image_format_s* pFormat) +static void _mm_round_up_widh_height(image_format_s* pFormat) { if (strcmp(pFormat->colorspace, "YUV") == 0) { pFormat->stride = pFormat->width; @@ -429,11 +344,10 @@ _mm_round_up_input_image_widh_height(image_format_s* pFormat) pFormat->stride = pFormat->width; pFormat->elevation = MM_UTIL_ROUND_UP_2(pFormat->height); } - gstcs_debug("input_format stride: %d, elevation: %d", pFormat->stride, pFormat->elevation); + gstcs_debug("stride: %d, elevation: %d", pFormat->stride, pFormat->elevation); } -static image_format_s* -_mm_set_input_image_format_s_struct(imgp_info_s* pImgp_info) /* char* __format_label, int __width, int __height) */ +static image_format_s* _mm_set_input_image_format_s_struct(imgp_info_s* pImgp_info) { int ret = GSTCS_ERROR_NONE; image_format_s* __format = NULL; @@ -444,44 +358,21 @@ _mm_set_input_image_format_s_struct(imgp_info_s* pImgp_info) /* char* __format_l return NULL; } - __format->format_label = (char *)malloc(sizeof(char) * IMAGE_FORMAT_LABEL_BUFFER_SIZE); - if (__format->format_label == NULL) { - gstcs_error("memory allocation failed"); - _gstcs_destroy_image_format(__format); - return NULL; - } - memset(__format->format_label, 0, IMAGE_FORMAT_LABEL_BUFFER_SIZE); - SAFE_STRCPY(__format->format_label, pImgp_info->input_format_label, IMAGE_FORMAT_LABEL_BUFFER_SIZE); - gstcs_debug("input_format_label: %s\n", pImgp_info->input_format_label); + __format->format_label = g_strdup(pImgp_info->input_format_label); _mm_set_image_colorspace(__format); __format->width = pImgp_info->src_width; __format->height = pImgp_info->src_height; - _mm_round_up_input_image_widh_height(__format); + _mm_round_up_widh_height(__format); - _mm_set_image_input_format_s_capabilities(__format); + _mm_set_capabilities(__format); - return __format; -} + gstcs_debug("input_format_label: %s", pImgp_info->input_format_label); -static void -_mm_round_up_output_image_widh_height(image_format_s* pFormat, const image_format_s *input_format) -{ - if (strcmp(pFormat->colorspace, "YUV") == 0) { - pFormat->stride = pFormat->width; - pFormat->elevation = pFormat->height; - } else if (strcmp(pFormat->colorspace, "RGB") == 0) { - pFormat->stride = MM_UTIL_ROUND_UP_4(pFormat->width); - pFormat->elevation = MM_UTIL_ROUND_UP_2(pFormat->height); - } else if ((strcmp(pFormat->colorspace, "RGBA") == 0) || (strcmp(pFormat->colorspace, "BGRX") == 0)) { - pFormat->stride = pFormat->width; - pFormat->elevation = MM_UTIL_ROUND_UP_2(pFormat->height); - } - gstcs_debug("output_format stride: %d, elevation: %d", pFormat->stride, pFormat->elevation); + return __format; } -static image_format_s* -_mm_set_output_image_format_s_struct(imgp_info_s* pImgp_info, const image_format_s *input_format) +static image_format_s* _mm_set_output_image_format_s_struct(imgp_info_s* pImgp_info) { int ret = GSTCS_ERROR_NONE; image_format_s* __format = NULL; @@ -492,25 +383,20 @@ _mm_set_output_image_format_s_struct(imgp_info_s* pImgp_info, const image_format return NULL; } - __format->format_label = (char *)malloc(sizeof(char) * IMAGE_FORMAT_LABEL_BUFFER_SIZE); - if (__format->format_label == NULL) { - gstcs_error("memory allocation failed"); - _gstcs_destroy_image_format(__format); - return NULL; - } - memset(__format->format_label, 0, IMAGE_FORMAT_LABEL_BUFFER_SIZE); - SAFE_STRCPY(__format->format_label, pImgp_info->output_format_label, IMAGE_FORMAT_LABEL_BUFFER_SIZE); + __format->format_label = g_strdup(pImgp_info->output_format_label); _mm_set_image_colorspace(__format); __format->width = pImgp_info->dst_width; __format->height = pImgp_info->dst_height; - _mm_round_up_output_image_widh_height(__format, input_format); + _mm_round_up_widh_height(__format); + + _mm_set_capabilities(__format); pImgp_info->output_stride = __format->stride; pImgp_info->output_elevation = __format->elevation; gstcs_debug("output_format_label: %s", pImgp_info->output_format_label); - _mm_set_image_output_format_s_capabilities(__format); + return __format; } @@ -873,7 +759,7 @@ static int _mm_imgp_gstcs(imgp_info_s* pImgp_info, unsigned char *src, unsigned return GSTCS_ERROR_OUT_OF_MEMORY; } - output_format = _mm_set_output_image_format_s_struct(pImgp_info, input_format); + output_format = _mm_set_output_image_format_s_struct(pImgp_info); if (output_format == NULL) { gstcs_error("Error: memory allocation failed"); _gstcs_destroy_image_format(input_format); diff --git a/packaging/libmm-imgp-gstcs.spec b/packaging/libmm-imgp-gstcs.spec index e961ffa..d6dc42f 100755 --- a/packaging/libmm-imgp-gstcs.spec +++ b/packaging/libmm-imgp-gstcs.spec @@ -1,7 +1,7 @@ #sbs-git:slp/pkgs/l/libmm-imgp-gstcs libmm-imgp-gstcs 0.1 62b62e6d483557fc5750d1b4986e9a98323f1194 Name: libmm-imgp-gstcs Summary: Multimedia Framework Utility Library -Version: 0.18 +Version: 0.19 Release: 16 Group: System/Libraries License: Apache-2.0 |