summaryrefslogtreecommitdiff
path: root/gstcs/mm_util_gstcs.c
diff options
context:
space:
mode:
authorHaejeong Kim <backto.kim@samsung.com>2015-12-10 10:24:53 +0900
committerHaejeong Kim <backto.kim@samsung.com>2015-12-10 10:25:11 +0900
commit1a4b91be290e15089dacb857954dc4b987557e43 (patch)
treeb7287e188e58e31a0c288c573b1f1979bbbd2921 /gstcs/mm_util_gstcs.c
parentebd1a7930734cbb4628f89f601436f3dbfbffe44 (diff)
downloadlibmm-imgp-gstcs-1a4b91be290e15089dacb857954dc4b987557e43.tar.gz
libmm-imgp-gstcs-1a4b91be290e15089dacb857954dc4b987557e43.tar.bz2
libmm-imgp-gstcs-1a4b91be290e15089dacb857954dc4b987557e43.zip
Change-Id: I31899d00f04e9bf5956395323e899775be8f3546
Diffstat (limited to 'gstcs/mm_util_gstcs.c')
-rwxr-xr-xgstcs/mm_util_gstcs.c376
1 files changed, 191 insertions, 185 deletions
diff --git a/gstcs/mm_util_gstcs.c b/gstcs/mm_util_gstcs.c
index c24dd44..b9b9f9f 100755
--- a/gstcs/mm_util_gstcs.c
+++ b/gstcs/mm_util_gstcs.c
@@ -31,7 +31,7 @@
static GstFlowReturn
_mm_sink_sample(GstElement * appsink, gpointer user_data)
{
- GstBuffer *_buf=NULL;
+ GstBuffer *_buf = NULL;
GstSample *_sample = NULL;
gstreamer_s * pGstreamer_s = (gstreamer_s*) user_data;
_sample = gst_app_sink_pull_sample((GstAppSink*)appsink);
@@ -40,7 +40,7 @@ _mm_sink_sample(GstElement * appsink, gpointer user_data)
pGstreamer_s->output_buffer = _buf;
- if(pGstreamer_s->output_buffer != NULL) {
+ if (pGstreamer_s->output_buffer != NULL) {
GstMapInfo mapinfo = GST_MAP_INFO_INIT;
gst_buffer_map(pGstreamer_s->output_buffer, &mapinfo, GST_MAP_READ);
gstcs_debug("Create Output Buffer: GST_BUFFER_DATA: %p\t GST_BUFFER_SIZE: %d", mapinfo.data, mapinfo.size);
@@ -50,7 +50,7 @@ _mm_sink_sample(GstElement * appsink, gpointer user_data)
}
}
- gst_buffer_ref (pGstreamer_s->output_buffer); /* when you want to avoid flushing */
+ gst_buffer_ref(pGstreamer_s->output_buffer); /* when you want to avoid flushing */
gst_sample_unref(_sample);
return GST_FLOW_OK;
@@ -60,25 +60,25 @@ static gboolean
_mm_on_src_message(GstBus * bus, GstMessage * message, gpointer user_data)
{
gstreamer_s * pGstreamer_s = (gstreamer_s*) user_data;
- switch (GST_MESSAGE_TYPE (message)) {
+ switch (GST_MESSAGE_TYPE(message)) {
case GST_MESSAGE_EOS: {
gstcs_debug("The source got dry");
gst_app_src_end_of_stream(GST_APP_SRC(pGstreamer_s->appsrc));
g_main_context_pop_thread_default(pGstreamer_s->context);
- g_main_loop_quit (pGstreamer_s->loop);
+ g_main_loop_quit(pGstreamer_s->loop);
break;
}
case GST_MESSAGE_ERROR: {
GError *err = NULL;
gchar *dbg_info = NULL;
- gst_message_parse_error (message, &err, &dbg_info);
- gstcs_error ("ERROR from element %s: %s\n", GST_OBJECT_NAME (message->src), err->message);
- gstcs_error ("Debugging info: %s\n", (dbg_info) ? dbg_info : "none");
- g_error_free (err);
- g_free (dbg_info);
+ gst_message_parse_error(message, &err, &dbg_info);
+ gstcs_error("ERROR from element %s: %s\n", GST_OBJECT_NAME(message->src), err->message);
+ gstcs_error("Debugging info: %s\n", (dbg_info) ? dbg_info : "none");
+ g_error_free(err);
+ g_free(dbg_info);
g_main_context_pop_thread_default(pGstreamer_s->context);
- g_main_loop_quit (pGstreamer_s->loop);
+ g_main_loop_quit(pGstreamer_s->loop);
gstcs_debug("Quit GST_CS\n");
break;
}
@@ -113,36 +113,35 @@ _mm_get_byte_per_pixcel(const char *__format_label)
return byte_per_pixcel;
}
-static int
-_mm_create_pipeline( gstreamer_s* pGstreamer_s)
+static int _mm_create_pipeline(gstreamer_s* pGstreamer_s)
{
int ret = GSTCS_ERROR_NONE;
- pGstreamer_s->pipeline= gst_pipeline_new ("videoconvert");
+ pGstreamer_s->pipeline = gst_pipeline_new("videoconvert");
if (!pGstreamer_s->pipeline) {
gstcs_error("pipeline could not be created. Exiting.\n");
ret = GSTCS_ERROR_INVALID_PARAMETER;
}
- pGstreamer_s->appsrc= gst_element_factory_make("appsrc","appsrc");
+ pGstreamer_s->appsrc = gst_element_factory_make("appsrc" , "appsrc");
if (!pGstreamer_s->appsrc) {
gstcs_error("appsrc could not be created. Exiting.\n");
ret = GSTCS_ERROR_INVALID_PARAMETER;
}
- pGstreamer_s->colorspace=gst_element_factory_make("videoconvert","colorspace");
+ pGstreamer_s->colorspace = gst_element_factory_make("videoconvert" , "colorspace");
if (!pGstreamer_s->colorspace) {
gstcs_error("colorspace could not be created. Exiting.\n");
ret = GSTCS_ERROR_INVALID_PARAMETER;
}
- pGstreamer_s->videoscale=gst_element_factory_make("videoscale", "scale");
+ pGstreamer_s->videoscale = gst_element_factory_make("videoscale", "scale");
if (!pGstreamer_s->videoscale) {
gstcs_error("videoscale could not be created. Exiting.\n");
ret = GSTCS_ERROR_INVALID_PARAMETER;
}
- pGstreamer_s->videoflip=gst_element_factory_make("videoflip", "flip");
+ pGstreamer_s->videoflip = gst_element_factory_make("videoflip", "flip");
if (!pGstreamer_s->videoflip) {
gstcs_error("videoflip could not be created. Exiting.\n");
ret = GSTCS_ERROR_INVALID_PARAMETER;
}
- pGstreamer_s->appsink=gst_element_factory_make("appsink","appsink");
+ pGstreamer_s->appsink = gst_element_factory_make("appsink" , "appsink");
if (!pGstreamer_s->appsink) {
gstcs_error("appsink could not be created. Exiting.\n");
ret = GSTCS_ERROR_INVALID_PARAMETER;
@@ -150,7 +149,8 @@ _mm_create_pipeline( gstreamer_s* pGstreamer_s)
return ret;
}
-static void _mm_destroy_notify(gpointer data) {
+static void _mm_destroy_notify(gpointer data)
+{
unsigned char *_data = (unsigned char *)data;
if (_data != NULL) {
free(_data);
@@ -161,8 +161,8 @@ static void _mm_destroy_notify(gpointer data) {
static void
_mm_check_caps_format(GstCaps* caps)
{
- GstStructure *caps_structure = gst_caps_get_structure (caps, 0);
- const gchar* formatInfo = gst_structure_get_string (caps_structure, "format");
+ GstStructure *caps_structure = gst_caps_get_structure(caps, 0);
+ const gchar* formatInfo = gst_structure_get_string(caps_structure, "format");
gstcs_debug("[%d] caps: %s", GST_IS_CAPS(caps), formatInfo);
}
@@ -171,17 +171,17 @@ _mm_link_pipeline(gstreamer_s* pGstreamer_s, image_format_s* input_format, image
{
/* set property */
gst_bin_add_many(GST_BIN(pGstreamer_s->pipeline), pGstreamer_s->appsrc, pGstreamer_s->colorspace, pGstreamer_s->videoscale, pGstreamer_s->videoflip, pGstreamer_s->appsink, NULL);
- if(!gst_element_link_many(pGstreamer_s->appsrc, pGstreamer_s->colorspace, pGstreamer_s->videoscale, pGstreamer_s->videoflip, pGstreamer_s->appsink, NULL)) {
+ if (!gst_element_link_many(pGstreamer_s->appsrc, pGstreamer_s->colorspace, pGstreamer_s->videoscale, pGstreamer_s->videoflip, pGstreamer_s->appsink, NULL)) {
gstcs_error("Fail to link pipeline");
} else {
gstcs_debug("Success to link pipeline");
}
- g_object_set (G_OBJECT (pGstreamer_s->appsrc), "stream-type", 0, "format", GST_FORMAT_TIME, NULL);
+ g_object_set(G_OBJECT(pGstreamer_s->appsrc), "stream-type", 0, "format", GST_FORMAT_TIME, NULL);
g_object_set(pGstreamer_s->appsrc, "num-buffers", 1, NULL);
g_object_set(pGstreamer_s->appsrc, "is-live", TRUE, NULL); /* add because of gstreamer_s time issue */
- g_object_set(pGstreamer_s->videoflip, "method", value, NULL ); /* GST_VIDEO_FLIP_METHOD_IDENTITY (0): none- Identity (no rotation) (1): clockwise - Rotate clockwise 90 degrees (2): rotate-180 - Rotate 180 degrees (3): counterclockwise - Rotate counter-clockwise 90 degrees (4): horizontal-flip - Flip horizontally (5): vertical-flip - Flip vertically (6): upper-left-diagonal - Flip across upper left/lower right diagonal (7): upper-right-diagonal - Flip across upper right/lower left diagonal */
+ g_object_set(pGstreamer_s->videoflip, "method", value, NULL); /* GST_VIDEO_FLIP_METHOD_IDENTITY (0): none- Identity (no rotation) (1): clockwise - Rotate clockwise 90 degrees (2): rotate-180 - Rotate 180 degrees (3): counterclockwise - Rotate counter-clockwise 90 degrees (4): horizontal-flip - Flip horizontally (5): vertical-flip - Flip vertically (6): upper-left-diagonal - Flip across upper left/lower right diagonal (7): upper-right-diagonal - Flip across upper right/lower left diagonal */
/*g_object_set(pGstreamer_s->appsink, "drop", TRUE, NULL);*/
g_object_set(pGstreamer_s->appsink, "emit-signals", TRUE, "sync", FALSE, NULL);
@@ -192,9 +192,15 @@ _mm_set_image_input_format_s_capabilities(image_format_s* __format) /*_format_la
{
char _format_name[sizeof(GST_VIDEO_FORMATS_ALL)] = {'\0'};
GstVideoFormat videoFormat;
- 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;
+ 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;
- if(__format == NULL) {
+ if (__format == NULL) {
gstcs_error("Image format is NULL\n");
return;
}
@@ -202,19 +208,19 @@ _mm_set_image_input_format_s_capabilities(image_format_s* __format) /*_format_la
gstcs_debug("colorspace: %s(%d)\n", __format->colorspace, strlen(__format->colorspace));
memset(_format_name, 0, sizeof(_format_name));
- if(strcmp(__format->colorspace,"YUV") == 0) {
- 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) {
+ if (strcmp(__format->colorspace, "YUV") == 0) {
+ 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) {
strncpy(_format_name, __format->format_label, sizeof(GST_VIDEO_FORMATS_ALL)-1);
- }else if(strcmp(__format->format_label,"YUYV") == 0) {
+ } else if (strcmp(__format->format_label, "YUYV") == 0) {
strncpy(_format_name, "YVYU", sizeof(GST_VIDEO_FORMATS_ALL)-1);
}
gstcs_debug("Chosen video format: %s", _format_name);
- __format->caps = gst_caps_new_simple ("video/x-raw",
+ __format->caps = gst_caps_new_simple("video/x-raw",
"format", G_TYPE_STRING, _format_name,
"framerate", GST_TYPE_FRACTION, 25, 1,
"pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1,
@@ -224,58 +230,58 @@ _mm_set_image_input_format_s_capabilities(image_format_s* __format) /*_format_la
NULL);
}
- else if(strcmp(__format->colorspace,"RGB") ==0 || strcmp(__format->colorspace,"BGRX") ==0) {
- if(strcmp(__format->format_label,"RGB888") == 0) {
- _bpp=24; _depth=24; _red_mask=16711680; _green_mask=65280; _blue_mask=255; _endianness=4321;
- }else if(strcmp(__format->format_label,"BGR888") == 0) {
- _bpp=24; _depth=24; _red_mask=255; _green_mask=65280; _blue_mask=16711680; _endianness=4321;
- }else if(strcmp(__format->format_label,"RGB565") == 0) {
- _bpp=16; _depth=16; _red_mask=63488; _green_mask=2016; _blue_mask=31; _endianness=1234;
- }else if( (strcmp(__format->format_label, "BGRX") == 0)) {
- _bpp=32; _depth=24; _red_mask=65280; _green_mask=16711680; _blue_mask=-16777216; _endianness=4321;
+ else if (strcmp(__format->colorspace, "RGB") == 0 || strcmp(__format->colorspace, "BGRX") == 0) {
+ if (strcmp(__format->format_label, "RGB888") == 0) {
+ _bpp = 24; _depth = 24; _red_mask = 16711680; _green_mask = 65280; _blue_mask = 255; _endianness = 4321;
+ } else if (strcmp(__format->format_label, "BGR888") == 0) {
+ _bpp = 24; _depth = 24; _red_mask = 255; _green_mask = 65280; _blue_mask = 16711680; _endianness = 4321;
+ } else if (strcmp(__format->format_label, "RGB565") == 0) {
+ _bpp = 16; _depth = 16; _red_mask = 63488; _green_mask = 2016; _blue_mask = 31; _endianness = 1234;
+ } else if ((strcmp(__format->format_label, "BGRX") == 0)) {
+ _bpp = 32; _depth = 24; _red_mask = 65280; _green_mask = 16711680; _blue_mask = -16777216; _endianness = 4321;
}
videoFormat = gst_video_format_from_masks(_depth, _bpp, _endianness, _red_mask, _green_mask, _blue_mask, 0);
gstcs_debug("Chosen video format: %s", gst_video_format_to_string(videoFormat));
- __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),
"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) {
- if(strcmp(__format->format_label,"ARGB8888") == 0) { /*[Low Arrary Address] ARGBARGB... [High Array Address]*/
+ else if (strcmp(__format->colorspace, "RGBA") == 0) {
+ if (strcmp(__format->format_label, "ARGB8888") == 0) { /*[Low Arrary Address] ARGBARGB... [High Array Address]*/
gstcs_debug("ARGB8888");
- _bpp=32; _depth=32; _red_mask=16711680; _green_mask=65280; _blue_mask=255; _alpha_mask=-16777216; _endianness=4321;
- }else if(strcmp(__format->format_label,"BGRA8888") == 0) { /*[Low Arrary Address] BGRABGRA...[High Array Address]*/
+ _bpp = 32; _depth = 32; _red_mask = 16711680; _green_mask = 65280; _blue_mask = 255; _alpha_mask = -16777216; _endianness = 4321;
+ } else if (strcmp(__format->format_label, "BGRA8888") == 0) { /*[Low Arrary Address] BGRABGRA...[High Array Address]*/
gstcs_debug("BGRA8888");
- _bpp=32; _depth=32; _red_mask=65280; _green_mask=16711680; _blue_mask=-16777216; _alpha_mask=255; _endianness=4321;
- }else if(strcmp(__format->format_label,"RGBA8888") == 0) { /*[Low Arrary Address] RGBARGBA...[High Array Address]*/
+ _bpp = 32; _depth = 32; _red_mask = 65280; _green_mask = 16711680; _blue_mask = -16777216; _alpha_mask = 255; _endianness = 4321;
+ } else if (strcmp(__format->format_label, "RGBA8888") == 0) { /*[Low Arrary Address] RGBARGBA...[High Array Address]*/
gstcs_debug("RGBA8888");
- _bpp=32; _depth=32; _red_mask=-16777216; _green_mask=16711680; _blue_mask=65280; _alpha_mask=255; _endianness=4321;
- }else if(strcmp(__format->format_label,"ABGR8888") == 0) { /*[Low Arrary Address] ABGRABGR...[High Array Address]*/
+ _bpp = 32; _depth = 32; _red_mask = -16777216; _green_mask = 16711680; _blue_mask = 65280; _alpha_mask = 255; _endianness = 4321;
+ } else if (strcmp(__format->format_label, "ABGR8888") == 0) { /*[Low Arrary Address] ABGRABGR...[High Array Address]*/
gstcs_debug("ABGR8888");
- _bpp=32; _depth=32; _red_mask=255; _green_mask=65280; _blue_mask=16711680; _alpha_mask=-16777216; _endianness=4321;
- }else {
+ _bpp = 32; _depth = 32; _red_mask = 255; _green_mask = 65280; _blue_mask = 16711680; _alpha_mask = -16777216; _endianness = 4321;
+ } else {
gstcs_error("***Wrong format cs type***\n");
}
videoFormat = gst_video_format_from_masks(_depth, _bpp, _endianness, _red_mask, _green_mask, _blue_mask, _alpha_mask);
gstcs_debug("Chosen video format: %s", gst_video_format_to_string(videoFormat));
- __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),
"width", G_TYPE_INT, __format->width,
"height", G_TYPE_INT, __format->elevation,
"framerate", GST_TYPE_FRACTION, 1, 1, NULL);
}
- if(__format->caps) {
+ if (__format->caps) {
gstcs_debug("###__format->caps is not NULL###, %p", __format->caps);
_mm_check_caps_format(__format->caps);
- }else {
+ } else {
gstcs_error("__format->caps is NULL");
}
}
@@ -285,9 +291,9 @@ _mm_set_image_output_format_s_capabilities(image_format_s* __format) /*_format_l
{
char _format_name[sizeof(GST_VIDEO_FORMATS_ALL)] = {'\0'};
GstVideoFormat videoFormat;
- 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;
+ 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;
- if(__format == NULL) {
+ if (__format == NULL) {
gstcs_error("Image format is NULL\n");
return;
}
@@ -295,19 +301,19 @@ _mm_set_image_output_format_s_capabilities(image_format_s* __format) /*_format_l
gstcs_debug("colorspace: %s(%d), w: %d, h: %d\n", __format->colorspace, strlen(__format->colorspace), __format->width, __format->height);
memset(_format_name, 0, sizeof(_format_name));
- if(strcmp(__format->colorspace,"YUV") == 0) {
- 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) {
+ if (strcmp(__format->colorspace, "YUV") == 0) {
+ 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) {
strncpy(_format_name, __format->format_label, sizeof(GST_VIDEO_FORMATS_ALL)-1);
- }else if(strcmp(__format->format_label,"YUYV") == 0) {
+ } else if (strcmp(__format->format_label, "YUYV") == 0) {
strncpy(_format_name, "YVYU", sizeof(GST_VIDEO_FORMATS_ALL)-1);
}
gstcs_debug("Chosen video format: %s", _format_name);
- __format->caps = gst_caps_new_simple ("video/x-raw",
+ __format->caps = gst_caps_new_simple("video/x-raw",
"format", G_TYPE_STRING, _format_name,
"width", G_TYPE_INT, __format->width,
"height", G_TYPE_INT, __format->height,
@@ -315,64 +321,64 @@ _mm_set_image_output_format_s_capabilities(image_format_s* __format) /*_format_l
NULL);
}
- else if(strcmp(__format->colorspace,"RGB") ==0 || strcmp(__format->colorspace,"BGRX") ==0) {
- if(strcmp(__format->format_label,"RGB888") == 0) {
- _bpp=24; _depth=24; _red_mask=16711680; _green_mask=65280; _blue_mask=255; _endianness=4321;
- }else if(strcmp(__format->format_label,"BGR888") == 0) {
- _bpp=24; _depth=24; _red_mask=255; _green_mask=65280; _blue_mask=16711680; _endianness=4321;
- }else if(strcmp(__format->format_label,"RGB565") == 0) {
- _bpp=16; _depth=16; _red_mask=63488; _green_mask=2016; _blue_mask=31; _endianness=1234;
- }else if( (strcmp(__format->format_label, "BGRX") == 0)) {
- _bpp=32; _depth=24; _red_mask=65280; _green_mask=16711680; _blue_mask=-16777216; _endianness=4321;
+ else if (strcmp(__format->colorspace, "RGB") == 0 || strcmp(__format->colorspace, "BGRX") == 0) {
+ if (strcmp(__format->format_label, "RGB888") == 0) {
+ _bpp = 24; _depth = 24; _red_mask = 16711680; _green_mask = 65280; _blue_mask = 255; _endianness = 4321;
+ } else if (strcmp(__format->format_label, "BGR888") == 0) {
+ _bpp = 24; _depth = 24; _red_mask = 255; _green_mask = 65280; _blue_mask = 16711680; _endianness = 4321;
+ } else if (strcmp(__format->format_label, "RGB565") == 0) {
+ _bpp = 16; _depth = 16; _red_mask = 63488; _green_mask = 2016; _blue_mask = 31; _endianness = 1234;
+ } else if ((strcmp(__format->format_label, "BGRX") == 0)) {
+ _bpp = 32; _depth = 24; _red_mask = 65280; _green_mask = 16711680; _blue_mask = -16777216; _endianness = 4321;
}
videoFormat = gst_video_format_from_masks(_depth, _bpp, _endianness, _red_mask, _green_mask, _blue_mask, 0);
gstcs_debug("Chosen video format: %s", gst_video_format_to_string(videoFormat));
- __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),
"width", G_TYPE_INT, __format->width,
"height", G_TYPE_INT, __format->height,
"framerate", GST_TYPE_FRACTION, 1, 1, NULL);
}
- else if(strcmp(__format->colorspace,"RGBA") ==0) {
- if(strcmp(__format->format_label,"ARGB8888") == 0) { /*[Low Arrary Address] ARGBARGB... [High Array Address]*/
+ else if (strcmp(__format->colorspace, "RGBA") == 0) {
+ if (strcmp(__format->format_label, "ARGB8888") == 0) { /*[Low Arrary Address] ARGBARGB... [High Array Address]*/
gstcs_debug("ARGB8888");
- _bpp=32; _depth=32; _red_mask=16711680; _green_mask=65280; _blue_mask=255; _alpha_mask=-16777216; _endianness=4321;
- }else if(strcmp(__format->format_label,"BGRA8888") == 0) { /*[Low Arrary Address] BGRABGRA...[High Array Address]*/
+ _bpp = 32; _depth = 32; _red_mask = 16711680; _green_mask = 65280; _blue_mask = 255; _alpha_mask = -16777216; _endianness = 4321;
+ } else if (strcmp(__format->format_label, "BGRA8888") == 0) { /*[Low Arrary Address] BGRABGRA...[High Array Address]*/
gstcs_debug("BGRA8888");
- _bpp=32; _depth=32; _red_mask=65280; _green_mask=16711680; _blue_mask=-16777216; _alpha_mask=255; _endianness=4321;
- }else if(strcmp(__format->format_label,"RGBA8888") == 0) { /*[Low Arrary Address] RGBARGBA...[High Array Address]*/
+ _bpp = 32; _depth = 32; _red_mask = 65280; _green_mask = 16711680; _blue_mask = -16777216; _alpha_mask = 255; _endianness = 4321;
+ } else if (strcmp(__format->format_label, "RGBA8888") == 0) { /*[Low Arrary Address] RGBARGBA...[High Array Address]*/
gstcs_debug("RGBA8888");
- _bpp=32; _depth=32; _red_mask=-16777216; _green_mask=16711680; _blue_mask=65280; _alpha_mask=255; _endianness=4321;
- }else if(strcmp(__format->format_label,"ABGR8888") == 0) { /*[Low Arrary Address] ABGRABGR...[High Array Address]*/
+ _bpp = 32; _depth = 32; _red_mask = -16777216; _green_mask = 16711680; _blue_mask = 65280; _alpha_mask = 255; _endianness = 4321;
+ } else if (strcmp(__format->format_label, "ABGR8888") == 0) { /*[Low Arrary Address] ABGRABGR...[High Array Address]*/
gstcs_debug("ABGR8888");
- _bpp=32; _depth=32; _red_mask=255; _green_mask=65280; _blue_mask=16711680; _alpha_mask=-16777216; _endianness=4321;
- }else {
+ _bpp = 32; _depth = 32; _red_mask = 255; _green_mask = 65280; _blue_mask = 16711680; _alpha_mask = -16777216; _endianness = 4321;
+ } else {
gstcs_error("***Wrong format cs type***\n");
}
videoFormat = gst_video_format_from_masks(_depth, _bpp, _endianness, _red_mask, _green_mask, _blue_mask, _alpha_mask);
gstcs_debug("Chosen video format: %s", gst_video_format_to_string(videoFormat));
- __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),
"width", G_TYPE_INT, __format->width,
"height", G_TYPE_INT, __format->height,
"framerate", GST_TYPE_FRACTION, 1, 1, NULL);
}
- if(__format->caps) {
+ if (__format->caps) {
gstcs_debug("###__format->caps is not NULL###, %p", __format->caps);
_mm_check_caps_format(__format->caps);
- }else {
+ } else {
gstcs_error("__format->caps is NULL");
}
}
static void
-_mm_set_image_colorspace( image_format_s* __format)
+_mm_set_image_colorspace(image_format_s* __format)
{
gstcs_debug("format_label: %s\n", __format->format_label);
@@ -382,16 +388,16 @@ _mm_set_image_colorspace( image_format_s* __format)
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)) {
+ 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)) {
strncpy(__format->colorspace, "YUV", IMAGE_FORMAT_LABEL_BUFFER_SIZE-1);
- }else if( (strcmp(__format->format_label, "RGB888") == 0) ||(strcmp(__format->format_label, "BGR888") == 0) ||(strcmp(__format->format_label, "RGB565") == 0)) {
+ } else if ((strcmp(__format->format_label, "RGB888") == 0) || (strcmp(__format->format_label, "BGR888") == 0) || (strcmp(__format->format_label, "RGB565") == 0)) {
strncpy(__format->colorspace, "RGB", IMAGE_FORMAT_LABEL_BUFFER_SIZE-1);
- }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)) {
- strncpy(__format->colorspace, "RGBA",IMAGE_FORMAT_LABEL_BUFFER_SIZE-1);
- }else if( (strcmp(__format->format_label, "BGRX") == 0)) {
+ } 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)) {
+ strncpy(__format->colorspace, "RGBA", IMAGE_FORMAT_LABEL_BUFFER_SIZE-1);
+ } else if ((strcmp(__format->format_label, "BGRX") == 0)) {
strncpy(__format->colorspace, "BGRX", IMAGE_FORMAT_LABEL_BUFFER_SIZE-1);
- }else {
+ } else {
gstcs_error("Check your colorspace format label");
GSTCS_FREE(__format->colorspace);
}
@@ -400,13 +406,13 @@ _mm_set_image_colorspace( image_format_s* __format)
static void
_mm_round_up_input_image_widh_height(image_format_s* pFormat)
{
- if(strcmp(pFormat->colorspace,"YUV") == 0) {
+ if (strcmp(pFormat->colorspace, "YUV") == 0) {
pFormat->stride = MM_UTIL_ROUND_UP_8(pFormat->width);
pFormat->elevation = MM_UTIL_ROUND_UP_2(pFormat->height);
- } else if(strcmp(pFormat->colorspace, "RGB") == 0) {
+ } 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){
+ } else if (strcmp(pFormat->colorspace, "RGBA") == 0) {
pFormat->stride = pFormat->width;
pFormat->elevation = MM_UTIL_ROUND_UP_2(pFormat->height);
}
@@ -418,7 +424,7 @@ _mm_set_input_image_format_s_struct(imgp_info_s* pImgp_info) /* char* __format_l
{
image_format_s* __format = NULL;
- __format=(image_format_s*)malloc(sizeof(image_format_s));
+ __format = (image_format_s*)malloc(sizeof(image_format_s));
if (__format == NULL) {
gstcs_error("memory allocation failed");
return NULL;
@@ -436,8 +442,8 @@ _mm_set_input_image_format_s_struct(imgp_info_s* pImgp_info) /* char* __format_l
gstcs_debug("input_format_label: %s\n", pImgp_info->input_format_label);
_mm_set_image_colorspace(__format);
- __format->width=pImgp_info->src_width;
- __format->height=pImgp_info->src_height;
+ __format->width = pImgp_info->src_width;
+ __format->height = pImgp_info->src_height;
_mm_round_up_input_image_widh_height(__format);
__format->blocksize = mm_setup_image_size(pImgp_info->input_format_label, pImgp_info->src_width, pImgp_info->src_height);
@@ -450,16 +456,16 @@ _mm_set_input_image_format_s_struct(imgp_info_s* pImgp_info) /* char* __format_l
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) {
+ if (strcmp(pFormat->colorspace, "YUV") == 0) {
pFormat->stride = MM_UTIL_ROUND_UP_8(pFormat->width);
pFormat->elevation = MM_UTIL_ROUND_UP_2(pFormat->height);
- } else if(strcmp(pFormat->colorspace, "RGB") == 0) {
+ } 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);
pFormat->width = pFormat->stride;
if (input_format->height != input_format->elevation)
pFormat->height = pFormat->elevation;
- } else if (strcmp(pFormat->colorspace,"RGBA") == 0){
+ } else if (strcmp(pFormat->colorspace, "RGBA") == 0) {
pFormat->stride = pFormat->width;
pFormat->elevation = MM_UTIL_ROUND_UP_2(pFormat->height);
if (input_format->height != input_format->elevation)
@@ -473,7 +479,7 @@ _mm_set_output_image_format_s_struct(imgp_info_s* pImgp_info, const image_format
{
image_format_s* __format = NULL;
- __format=(image_format_s*)malloc(sizeof(image_format_s));
+ __format = (image_format_s*)malloc(sizeof(image_format_s));
if (__format == NULL) {
gstcs_error("memory allocation failed");
return NULL;
@@ -490,8 +496,8 @@ _mm_set_output_image_format_s_struct(imgp_info_s* pImgp_info, const image_format
strncpy(__format->format_label, pImgp_info->output_format_label, strlen(pImgp_info->output_format_label));
_mm_set_image_colorspace(__format);
- __format->width=pImgp_info->dst_width;
- __format->height=pImgp_info->dst_height;
+ __format->width = pImgp_info->dst_width;
+ __format->height = pImgp_info->dst_height;
_mm_round_up_output_image_widh_height(__format, input_format);
pImgp_info->output_stride = __format->stride;
@@ -508,7 +514,7 @@ _mm_push_buffer_into_pipeline(imgp_info_s* pImgp_info, unsigned char *src, gstre
{
int ret = GSTCS_ERROR_NONE;
- if(pGstreamer_s->pipeline == NULL) {
+ if (pGstreamer_s->pipeline == NULL) {
gstcs_error("pipeline is NULL\n");
return GSTCS_ERROR_INVALID_PARAMETER;
}
@@ -516,12 +522,12 @@ _mm_push_buffer_into_pipeline(imgp_info_s* pImgp_info, unsigned char *src, gstre
gsize data_size = mm_setup_image_size(pImgp_info->input_format_label, pImgp_info->src_width, pImgp_info->src_height);
GstBuffer* gst_buf = gst_buffer_new_wrapped_full(GST_MEMORY_FLAG_READONLY, src, data_size, 0, data_size, NULL, NULL);
- if(gst_buf==NULL) {
+ if (gst_buf == NULL) {
gstcs_error("buffer is NULL\n");
return GSTCS_ERROR_INVALID_PARAMETER;
}
- gst_app_src_push_buffer (GST_APP_SRC (pGstreamer_s->appsrc), gst_buf); /* push buffer to pipeline */
+ gst_app_src_push_buffer(GST_APP_SRC(pGstreamer_s->appsrc), gst_buf); /* push buffer to pipeline */
return ret;
}
@@ -535,7 +541,7 @@ _mm_push_buffer_into_pipeline_new(image_format_s *input_format, image_format_s *
unsigned int stride = input_format->stride;
unsigned int elevation = input_format->elevation;
- if(pGstreamer_s->pipeline == NULL) {
+ if (pGstreamer_s->pipeline == NULL) {
gstcs_error("pipeline is NULL\n");
return GSTCS_ERROR_INVALID_PARAMETER;
}
@@ -549,65 +555,65 @@ _mm_push_buffer_into_pipeline_new(image_format_s *input_format, image_format_s *
unsigned int stride_row = stride * byte_per_pixcel;
unsigned int i = 0, y = 0;
gstcs_debug("padding will be inserted to buffer");
- data =(unsigned char *) g_malloc (src_size);
- if(data==NULL) {
+ data = (unsigned char *) g_malloc(src_size);
+ if (data == NULL) {
gstcs_error("app_buffer is NULL\n");
return GSTCS_ERROR_INVALID_PARAMETER;
}
for (y = 0; y < (unsigned int)(input_format->height); y++) {
guint8 *pLine = (guint8 *) &(src[src_row * y]);
- for(i = 0; i < src_row; i++) {
+ for (i = 0; i < src_row; i++) {
data[y * stride_row + i] = pLine[i];
}
- for(i = src_row; i < stride_row; i++) {
+ for (i = src_row; i < stride_row; i++) {
data[y * stride_row + i] = 0x00;
}
}
for (y = (unsigned int)(input_format->height); y < (unsigned int)(input_format->elevation); y++) {
- for(i = 0; i < stride_row; i++) {
+ for (i = 0; i < stride_row; i++) {
data[y * stride_row + i] = 0x00;
}
}
gst_buf = gst_buffer_new_wrapped_full(GST_MEMORY_FLAG_READONLY, data, src_size, 0, src_size, data, _mm_destroy_notify);
- if(gst_buf==NULL) {
+ if (gst_buf == NULL) {
gstcs_error("buffer is NULL\n");
return GSTCS_ERROR_INVALID_PARAMETER;
}
- gst_app_src_push_buffer (GST_APP_SRC (pGstreamer_s->appsrc), gst_buf); /* push buffer to pipeline */
+ gst_app_src_push_buffer(GST_APP_SRC(pGstreamer_s->appsrc), gst_buf); /* push buffer to pipeline */
return ret;
}
static int
-_mm_imgp_gstcs_processing( gstreamer_s* pGstreamer_s, unsigned char *src, unsigned char *dst, image_format_s* input_format, image_format_s* output_format, imgp_info_s* pImgp_info)
+_mm_imgp_gstcs_processing(gstreamer_s* pGstreamer_s, unsigned char *src, unsigned char *dst, image_format_s* input_format, image_format_s* output_format, imgp_info_s* pImgp_info)
{
GstBus *bus = NULL;
GstStateChangeReturn ret_state;
int ret = GSTCS_ERROR_NONE;
- if(src== NULL || dst == NULL) {
+ if (src == NULL || dst == NULL) {
gstcs_error("src || dst is NULL");
return GSTCS_ERROR_INVALID_PARAMETER;
}
/*create pipeline*/
ret = _mm_create_pipeline(pGstreamer_s);
- if(ret != GSTCS_ERROR_NONE) {
+ if (ret != GSTCS_ERROR_NONE) {
gstcs_error("ERROR - mm_create_pipeline ");
}
pGstreamer_s->context = g_main_context_new();
if (pGstreamer_s->context == NULL) {
gstcs_error("ERROR - g_main_context_new ");
- gst_object_unref (pGstreamer_s->pipeline);
- g_free (pGstreamer_s);
+ gst_object_unref(pGstreamer_s->pipeline);
+ g_free(pGstreamer_s);
return GSTCS_ERROR_INVALID_OPERATION;
}
- pGstreamer_s->loop = g_main_loop_new (pGstreamer_s->context, FALSE);
+ pGstreamer_s->loop = g_main_loop_new(pGstreamer_s->context, FALSE);
if (pGstreamer_s->loop == NULL) {
gstcs_error("ERROR - g_main_loop_new ");
- gst_object_unref (pGstreamer_s->pipeline);
+ gst_object_unref(pGstreamer_s->pipeline);
g_main_context_unref(pGstreamer_s->context);
return GSTCS_ERROR_INVALID_OPERATION;
}
@@ -615,10 +621,10 @@ _mm_imgp_gstcs_processing( gstreamer_s* pGstreamer_s, unsigned char *src, unsign
g_main_context_push_thread_default(pGstreamer_s->context);
/* Make appsink emit the "new-preroll" and "new-sample" signals. This option is by default disabled because signal emission is expensive and unneeded when the application prefers to operate in pull mode. */
- gst_app_sink_set_emit_signals ((GstAppSink*)pGstreamer_s->appsink, TRUE);
+ gst_app_sink_set_emit_signals((GstAppSink*)pGstreamer_s->appsink, TRUE);
- bus = gst_pipeline_get_bus (GST_PIPELINE (pGstreamer_s->pipeline));
- gst_bus_add_watch (bus, (GstBusFunc) _mm_on_src_message, pGstreamer_s);
+ bus = gst_pipeline_get_bus(GST_PIPELINE(pGstreamer_s->pipeline));
+ gst_bus_add_watch(bus, (GstBusFunc) _mm_on_src_message, pGstreamer_s);
gst_object_unref(bus);
gst_app_src_set_caps(GST_APP_SRC(pGstreamer_s->appsrc), input_format->caps);
@@ -632,9 +638,9 @@ _mm_imgp_gstcs_processing( gstreamer_s* pGstreamer_s, unsigned char *src, unsign
gstcs_debug("Start mm_push_buffer_into_pipeline");
ret = _mm_push_buffer_into_pipeline(pImgp_info, src, pGstreamer_s);
}
- if(ret != GSTCS_ERROR_NONE) {
+ if (ret != GSTCS_ERROR_NONE) {
gstcs_error("ERROR - mm_push_buffer_into_pipeline ");
- gst_object_unref (pGstreamer_s->pipeline);
+ gst_object_unref(pGstreamer_s->pipeline);
g_main_context_unref(pGstreamer_s->context);
g_main_loop_unref(pGstreamer_s->loop);
return ret;
@@ -643,36 +649,36 @@ _mm_imgp_gstcs_processing( gstreamer_s* pGstreamer_s, unsigned char *src, unsign
/*link pipeline*/
gstcs_debug("Start mm_link_pipeline");
- _mm_link_pipeline( pGstreamer_s, input_format, output_format, pImgp_info->angle);
+ _mm_link_pipeline(pGstreamer_s, input_format, output_format, pImgp_info->angle);
gstcs_debug("End mm_link_pipeline");
/* Conecting to the new-sample signal emited by the appsink*/
- gstcs_debug("Start G_CALLBACK (_mm_sink_sample)");
- g_signal_connect (pGstreamer_s->appsink, "new-sample", G_CALLBACK (_mm_sink_sample), pGstreamer_s);
- gstcs_debug("End G_CALLBACK (_mm_sink_sample)");
+ gstcs_debug("Start G_CALLBACK(_mm_sink_sample)");
+ g_signal_connect(pGstreamer_s->appsink, "new-sample", G_CALLBACK(_mm_sink_sample), pGstreamer_s);
+ gstcs_debug("End G_CALLBACK(_mm_sink_sample)");
/* GST_STATE_PLAYING*/
gstcs_debug("Start GST_STATE_PLAYING");
- ret_state = gst_element_set_state (pGstreamer_s->pipeline, GST_STATE_PLAYING);
+ ret_state = gst_element_set_state(pGstreamer_s->pipeline, GST_STATE_PLAYING);
gstcs_debug("End GST_STATE_PLAYING ret_state: %d", ret_state);
/*g_main_loop_run*/
gstcs_debug("g_main_loop_run");
- g_main_loop_run (pGstreamer_s->loop);
+ g_main_loop_run(pGstreamer_s->loop);
gstcs_debug("Sucess GST_STATE_CHANGE");
/*GST_STATE_NULL*/
- gst_element_set_state (pGstreamer_s->pipeline, GST_STATE_NULL);
+ gst_element_set_state(pGstreamer_s->pipeline, GST_STATE_NULL);
gstcs_debug("End GST_STATE_NULL");
gstcs_debug("###pGstreamer_s->output_buffer### : %p", pGstreamer_s->output_buffer);
- ret_state = gst_element_get_state (pGstreamer_s->pipeline, NULL, NULL, 1*GST_SECOND);
+ ret_state = gst_element_get_state(pGstreamer_s->pipeline, NULL, NULL, 1*GST_SECOND);
- if(ret_state == GST_STATE_CHANGE_SUCCESS) {
+ if (ret_state == GST_STATE_CHANGE_SUCCESS) {
gstcs_debug("GST_STATE_NULL ret_state = %d (GST_STATE_CHANGE_SUCCESS)\n", ret_state);
- }else if( ret_state == GST_STATE_CHANGE_ASYNC) {
+ } else if (ret_state == GST_STATE_CHANGE_ASYNC) {
gstcs_debug("GST_STATE_NULL ret_state = %d (GST_STATE_CHANGE_ASYNC)\n", ret_state);
}
@@ -681,7 +687,7 @@ _mm_imgp_gstcs_processing( gstreamer_s* pGstreamer_s, unsigned char *src, unsign
if (ret_state == GST_STATE_CHANGE_FAILURE) {
gstcs_error("GST_STATE_CHANGE_FAILURE");
} else {
- if(pGstreamer_s->output_buffer != NULL) {
+ if (pGstreamer_s->output_buffer != NULL) {
GstMapInfo mapinfo = GST_MAP_INFO_INIT;
gst_buffer_map(pGstreamer_s->output_buffer, &mapinfo, GST_MAP_READ);
int buffer_size = mapinfo.size;
@@ -694,28 +700,28 @@ _mm_imgp_gstcs_processing( gstreamer_s* pGstreamer_s, unsigned char *src, unsign
calc_buffer_size = mm_setup_image_size(pImgp_info->output_format_label, pImgp_info->dst_width, pImgp_info->dst_height);
}
gstcs_debug("buffer size: %d, calc: %d\n", buffer_size, calc_buffer_size);
- if( buffer_size != calc_buffer_size) {
+ if (buffer_size != calc_buffer_size) {
gstcs_debug("Buffer size is different \n");
gstcs_debug("unref output buffer");
- gst_buffer_unref (pGstreamer_s->output_buffer);
- gst_object_unref (pGstreamer_s->pipeline);
+ gst_buffer_unref(pGstreamer_s->output_buffer);
+ gst_object_unref(pGstreamer_s->pipeline);
pGstreamer_s->output_buffer = NULL;
g_main_context_unref(pGstreamer_s->context);
g_main_loop_unref(pGstreamer_s->loop);
- g_free (pGstreamer_s);
+ g_free(pGstreamer_s);
return GSTCS_ERROR_INVALID_OPERATION;
}
gstcs_debug("pGstreamer_s->output_buffer: 0x%2x\n", pGstreamer_s->output_buffer);
memcpy(dst, mapinfo.data, buffer_size);
pImgp_info->buffer_size = buffer_size;
gst_buffer_unmap(pGstreamer_s->output_buffer, &mapinfo);
- }else {
+ } else {
gstcs_debug("pGstreamer_s->output_buffer is NULL");
}
}
gstcs_debug("unref output buffer");
- gst_buffer_unref (pGstreamer_s->output_buffer);
- gst_object_unref (pGstreamer_s->pipeline);
+ gst_buffer_unref(pGstreamer_s->output_buffer);
+ gst_object_unref(pGstreamer_s->pipeline);
pGstreamer_s->output_buffer = NULL;
g_main_context_unref(pGstreamer_s->context);
g_main_loop_unref(pGstreamer_s->loop);
@@ -729,39 +735,39 @@ _mm_imgp_gstcs_processing( gstreamer_s* pGstreamer_s, unsigned char *src, unsign
static int
mm_setup_image_size(const char* _format_label, int width, int height)
{
- int size=0;
+ int size = 0;
- if(strcmp(_format_label, "I420") == 0) {
+ if (strcmp(_format_label, "I420") == 0) {
size = (MM_UTIL_ROUND_UP_4(width) * MM_UTIL_ROUND_UP_2(height) + MM_UTIL_ROUND_UP_8(width) * MM_UTIL_ROUND_UP_2(height) /2); /*width * height *1.5; */
- }else if(strcmp(_format_label, "Y42B") == 0) {
+ } else if (strcmp(_format_label, "Y42B") == 0) {
size = (MM_UTIL_ROUND_UP_4(width) * height + MM_UTIL_ROUND_UP_8(width) * height); /*width * height *2; */
- }else if(strcmp(_format_label, "YUV422") == 0) {
+ } else if (strcmp(_format_label, "YUV422") == 0) {
size = (MM_UTIL_ROUND_UP_4(width) * height + MM_UTIL_ROUND_UP_8(width) * height); /*width * height *2; */
- }else if(strcmp(_format_label, "Y444") == 0) {
+ } else if (strcmp(_format_label, "Y444") == 0) {
size = (MM_UTIL_ROUND_UP_4(width) * height * 3); /* width * height *3; */
- }else if(strcmp(_format_label, "YV12") == 0) {
- size = (MM_UTIL_ROUND_UP_4(width) * MM_UTIL_ROUND_UP_2(height)+ MM_UTIL_ROUND_UP_8(width) * MM_UTIL_ROUND_UP_2(height) / 2); /* width * height *1; */
- }else if(strcmp(_format_label, "NV12") == 0) {
+ } else if (strcmp(_format_label, "YV12") == 0) {
+ size = (MM_UTIL_ROUND_UP_4(width) * MM_UTIL_ROUND_UP_2(height) + MM_UTIL_ROUND_UP_8(width) * MM_UTIL_ROUND_UP_2(height) / 2); /* width * height *1; */
+ } else if (strcmp(_format_label, "NV12") == 0) {
size = (MM_UTIL_ROUND_UP_4(width) * MM_UTIL_ROUND_UP_2(height) * 1.5); /* width * height *1.5; */
- }else if(strcmp(_format_label, "RGB565") == 0) {
+ } else if (strcmp(_format_label, "RGB565") == 0) {
size = (MM_UTIL_ROUND_UP_4(width) * 2 * height); /* width * height *2; */
- }else if(strcmp(_format_label, "RGB888") == 0) {
+ } else if (strcmp(_format_label, "RGB888") == 0) {
size = (MM_UTIL_ROUND_UP_4(width) * 3 * height); /* width * height *3; */
- }else if(strcmp(_format_label, "BGR888") == 0) {
+ } else if (strcmp(_format_label, "BGR888") == 0) {
size = (MM_UTIL_ROUND_UP_4(width) * 3 * height); /* width * height *3; */
- }else if(strcmp(_format_label, "UYVY") == 0) {
+ } else if (strcmp(_format_label, "UYVY") == 0) {
size = (MM_UTIL_ROUND_UP_2(width) * 2 * height); /* width * height *2; */
- }else if(strcmp(_format_label, "YUYV") == 0) {
+ } else if (strcmp(_format_label, "YUYV") == 0) {
size = (MM_UTIL_ROUND_UP_2(width) * 2 * height); /* width * height *2; */
- }else if(strcmp(_format_label, "ARGB8888") == 0) {
+ } else if (strcmp(_format_label, "ARGB8888") == 0) {
size = width * height *4;
- }else if(strcmp(_format_label, "BGRA8888") == 0) {
+ } else if (strcmp(_format_label, "BGRA8888") == 0) {
size = width * height *4;
- }else if(strcmp(_format_label, "RGBA8888") == 0) {
+ } else if (strcmp(_format_label, "RGBA8888") == 0) {
size = width * height *4;
- }else if(strcmp(_format_label, "ABGR8888") == 0) {
+ } else if (strcmp(_format_label, "ABGR8888") == 0) {
size = width * height *4;
- }else if(strcmp(_format_label, "BGRX") == 0) {
+ } else if (strcmp(_format_label, "BGRX") == 0) {
size = width * height *4;
}
@@ -773,7 +779,7 @@ mm_setup_image_size(const char* _format_label, int width, int height)
static int
_mm_imgp_gstcs(imgp_info_s* pImgp_info, unsigned char *src, unsigned char *dst)
{
- image_format_s* input_format=NULL, *output_format=NULL;
+ image_format_s* input_format = NULL, *output_format = NULL;
gstreamer_s* pGstreamer_s;
int ret = GSTCS_ERROR_NONE;
static const int max_argc = 50;
@@ -781,12 +787,12 @@ _mm_imgp_gstcs(imgp_info_s* pImgp_info, unsigned char *src, unsigned char *dst)
gchar** argv = NULL;
int i = 0;
- if(pImgp_info == NULL) {
+ if (pImgp_info == NULL) {
gstcs_error("imgp_info_s is NULL");
return GSTCS_ERROR_INVALID_PARAMETER;
}
- if(src== NULL || dst == NULL) {
+ if (src == NULL || dst == NULL) {
gstcs_error("src || dst is NULL");
return GSTCS_ERROR_INVALID_PARAMETER;
}
@@ -812,7 +818,7 @@ _mm_imgp_gstcs(imgp_info_s* pImgp_info, unsigned char *src, unsigned char *dst)
/* add initial */
*argc = 0;
- argv[*argc] = (gchar *)g_strdup( "mmutil_gstcs" );
+ argv[*argc] = (gchar *)g_strdup("mmutil_gstcs");
(*argc)++;
/* check disable registry scan */
argv[*argc] = g_strdup("--gst-disable-registry-update");
@@ -821,7 +827,7 @@ _mm_imgp_gstcs(imgp_info_s* pImgp_info, unsigned char *src, unsigned char *dst)
gst_init(argc, &argv);
- pGstreamer_s = g_new0 (gstreamer_s, 1);
+ pGstreamer_s = g_new0(gstreamer_s, 1);
for (i = 0; i < (*argc); i++) {
GSTCS_FREE(argv[i]);
@@ -832,29 +838,29 @@ _mm_imgp_gstcs(imgp_info_s* pImgp_info, unsigned char *src, unsigned char *dst)
gstcs_debug("[input] format label : %s width: %d height: %d\t[output] format label: %s width: %d height: %d rotation vaule: %d",
pImgp_info->input_format_label, pImgp_info->src_width, pImgp_info->src_height, pImgp_info->output_format_label, pImgp_info->dst_width, pImgp_info->dst_height, pImgp_info->angle);
- input_format= _mm_set_input_image_format_s_struct(pImgp_info);
+ input_format = _mm_set_input_image_format_s_struct(pImgp_info);
if (input_format == NULL) {
gstcs_error("memory allocation failed");
- g_free (pGstreamer_s);
+ g_free(pGstreamer_s);
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, input_format);
if (output_format == NULL) {
gstcs_error("memory allocation failed");
GSTCS_FREE(input_format->format_label);
GSTCS_FREE(input_format->colorspace);
GSTCS_FREE(input_format);
- g_free (pGstreamer_s);
+ g_free(pGstreamer_s);
return GSTCS_ERROR_OUT_OF_MEMORY;
}
/* _format_label : I420, RGB888 etc*/
gstcs_debug("Start _mm_imgp_gstcs_processing ");
- ret =_mm_imgp_gstcs_processing(pGstreamer_s, src, dst, input_format, output_format, pImgp_info); /* input: buffer pointer for input image , input image format, input image width, input image height, output: buffer porinter for output image */
+ ret = _mm_imgp_gstcs_processing(pGstreamer_s, src, dst, input_format, output_format, pImgp_info); /* input: buffer pointer for input image , input image format, input image width, input image height, output: buffer porinter for output image */
- if(ret == GSTCS_ERROR_NONE) {
+ if (ret == GSTCS_ERROR_NONE) {
gstcs_debug("End _mm_imgp_gstcs_processing [dst: %p]", dst);
- }else if (ret != GSTCS_ERROR_NONE) {
+ } else if (ret != GSTCS_ERROR_NONE) {
gstcs_error("ERROR - _mm_imgp_gstcs_processing");
}
@@ -865,7 +871,7 @@ _mm_imgp_gstcs(imgp_info_s* pImgp_info, unsigned char *src, unsigned char *dst)
GSTCS_FREE(output_format->format_label);
GSTCS_FREE(output_format->colorspace);
GSTCS_FREE(output_format);
- g_free (pGstreamer_s);
+ g_free(pGstreamer_s);
return ret;
}