* limitations under the License.
*
*/
+#include <stdbool.h>
#include "mm_util_gstcs_internal.h"
#include <gst/check/gstcheck.h>
#include <gst/video/video-format.h>
#define MM_UTIL_ROUND_UP_2(num) (((num)+1)&~1)
#define MM_UTIL_ROUND_UP_4(num) (((num)+3)&~3)
#define MM_UTIL_ROUND_UP_8(num) (((num)+7)&~7)
-#define MM_UTIL_ROUND_UP_16(num) (((num)+15)&~15)
-#define SAFE_STRCPY(dst, src, n) g_strlcpy(dst, src, n)
+#define SAFE_UNREF_CAPS(caps) { if (caps) { gst_caps_unref(caps); caps = NULL; } }
static GstFlowReturn
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);
+ gstcs_debug("Create Output Buffer: GST_BUFFER_DATA: %p\t GST_BUFFER_SIZE: %zu", mapinfo.data, mapinfo.size);
gst_buffer_unmap(pGstreamer_s->output_buffer, &mapinfo);
} else {
gstcs_error("ERROR -Input Prepare Buffer! Check createoutput buffer function");
return TRUE;
}
-static int
-_mm_get_byte_per_pixcel(const char *__format_label)
+static int _mm_get_byte_per_pixcel(mm_util_color_format_e color_format)
{
int byte_per_pixcel = 1;
- if (strcmp(__format_label, "RGB565") == 0) {
+
+ switch (color_format) {
+ case MM_UTIL_COLOR_YUV420:
+ case MM_UTIL_COLOR_YUV422:
+ case MM_UTIL_COLOR_I420:
+ case MM_UTIL_COLOR_NV12:
+ case MM_UTIL_COLOR_UYVY:
+ case MM_UTIL_COLOR_YUYV:
+ byte_per_pixcel = 1;
+ break;
+ case MM_UTIL_COLOR_RGB16:
byte_per_pixcel = 2;
- } else if (strcmp(__format_label, "RGB888") == 0 ||
- strcmp(__format_label, "BGR888") == 0) {
+ break;
+ case MM_UTIL_COLOR_RGB24:
byte_per_pixcel = 3;
- } else if (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) {
+ break;
+ case MM_UTIL_COLOR_ARGB:
+ case MM_UTIL_COLOR_BGRA:
+ case MM_UTIL_COLOR_RGBA:
+ case MM_UTIL_COLOR_BGRX:
byte_per_pixcel = 4;
+ break;
+ default:
+ gstcs_error("Not supported format");
+ break;
}
- gstcs_debug("byte per pixcel : %d", byte_per_pixcel);
+ gstcs_debug("color_format [%d] byte per pixcel [%d]", color_format, byte_per_pixcel);
return byte_per_pixcel;
}
pGstreamer_s->pipeline = gst_pipeline_new("pipeline");
if (!pGstreamer_s->pipeline) {
gstcs_error("pipeline could not be created. Exiting.\n");
- ret = GSTCS_ERROR_INVALID_PARAMETER;
+ return GSTCS_ERROR_INVALID_PARAMETER;
}
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;
+ gst_object_unref(pGstreamer_s->pipeline);
+ return GSTCS_ERROR_INVALID_PARAMETER;
}
pGstreamer_s->colorspace = gst_element_factory_make("videoconvert" , "convert");
if (!pGstreamer_s->colorspace) {
gstcs_error("colorspace could not be created. Exiting.\n");
- ret = GSTCS_ERROR_INVALID_PARAMETER;
+ gst_object_unref(pGstreamer_s->pipeline);
+ return GSTCS_ERROR_INVALID_PARAMETER;
}
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;
+ gst_object_unref(pGstreamer_s->pipeline);
+ return GSTCS_ERROR_INVALID_PARAMETER;
}
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;
+ gst_object_unref(pGstreamer_s->pipeline);
+ return GSTCS_ERROR_INVALID_PARAMETER;
}
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;
+ gst_object_unref(pGstreamer_s->pipeline);
+ return GSTCS_ERROR_INVALID_PARAMETER;
}
return ret;
}
static void
_mm_link_pipeline(gstreamer_s* pGstreamer_s, int value)
{
+ gstcs_fenter();
+
/* 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))
/*g_object_set(pGstreamer_s->appsink, "drop", TRUE, NULL);*/
g_object_set(pGstreamer_s->appsink, "emit-signals", TRUE, "sync", FALSE, NULL);
+
+ gstcs_fleave();
}
-static GstVideoFormat _mm_get_video_format(char *format_label)
+static GstVideoFormat _mm_get_video_format(mm_util_color_format_e color_format)
{
GstVideoFormat videoFormat = GST_VIDEO_FORMAT_UNKNOWN;
int _bpp = 0;
int _alpha_mask = 0;
int _endianness = 0;
- if (format_label == NULL) {
- gstcs_error("Wrong format label");
- return videoFormat;
- }
-
- if (strcmp(format_label, "I420") == 0)
- videoFormat = GST_VIDEO_FORMAT_I420;
- else if (strcmp(format_label, "Y42B") == 0)
- videoFormat = GST_VIDEO_FORMAT_Y42B;
- else if (strcmp(format_label, "Y444") == 0)
- videoFormat = GST_VIDEO_FORMAT_Y444;
- else if (strcmp(format_label, "YV12") == 0)
+ switch (color_format) {
+ case MM_UTIL_COLOR_YUV420:
videoFormat = GST_VIDEO_FORMAT_YV12;
- else if (strcmp(format_label, "NV12") == 0)
+ break;
+ case MM_UTIL_COLOR_YUV422:
+ videoFormat = GST_VIDEO_FORMAT_Y42B;
+ break;
+ case MM_UTIL_COLOR_I420:
+ videoFormat = GST_VIDEO_FORMAT_I420;
+ break;
+ case MM_UTIL_COLOR_NV12:
videoFormat = GST_VIDEO_FORMAT_NV12;
- else if (strcmp(format_label, "UYVY") == 0)
+ break;
+ case MM_UTIL_COLOR_UYVY:
videoFormat = GST_VIDEO_FORMAT_UYVY;
- else if (strcmp(format_label, "YUYV") == 0)
+ break;
+ case MM_UTIL_COLOR_YUYV:
videoFormat = GST_VIDEO_FORMAT_YVYU;
- else if (strcmp(format_label, "RGB888") == 0) {
- _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);
- } else if (strcmp(format_label, "BGR888") == 0) {
- _bpp = 24; _depth = 24; _red_mask = 255; _green_mask = 65280; _blue_mask = 16711680; _endianness = 4321; _alpha_mask = 0;
- videoFormat = gst_video_format_from_masks(_depth, _bpp, _endianness, _red_mask, _green_mask, _blue_mask, _alpha_mask);
- } else if (strcmp(format_label, "RGB565") == 0) {
+ 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);
- } else if ((strcmp(format_label, "BGRX") == 0)) {
- _bpp = 32; _depth = 24; _red_mask = 65280; _green_mask = 16711680; _blue_mask = -16777216; _endianness = 4321; _alpha_mask = 0;
+ 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);
- } else if (strcmp(format_label, "ARGB8888") == 0) { /*[Low Arrary Address] ARGBARGB... [High Array Address]*/
- gstcs_debug("ARGB8888");
+ 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);
- } else if (strcmp(format_label, "BGRA8888") == 0) { /*[Low Arrary Address] BGRABGRA...[High Array Address]*/
- gstcs_debug("BGRA8888");
+ break;
+ case MM_UTIL_COLOR_BGRA:
_bpp = 32; _depth = 32; _red_mask = 65280; _green_mask = 16711680; _blue_mask = -16777216; _alpha_mask = 255; _endianness = 4321;
- } else if (strcmp(format_label, "RGBA8888") == 0) { /*[Low Arrary Address] RGBARGBA...[High Array Address]*/
- gstcs_debug("RGBA8888");
+ videoFormat = gst_video_format_from_masks(_depth, _bpp, _endianness, _red_mask, _green_mask, _blue_mask, _alpha_mask);
+ break;
+ case MM_UTIL_COLOR_RGBA:
_bpp = 32; _depth = 32; _red_mask = -16777216; _green_mask = 16711680; _blue_mask = 65280; _alpha_mask = 255; _endianness = 4321;
- } else if (strcmp(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 {
- gstcs_error("***Wrong format cs type***");
+ videoFormat = gst_video_format_from_masks(_depth, _bpp, _endianness, _red_mask, _green_mask, _blue_mask, _alpha_mask);
+ 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);
+ break;
+ default:
+ gstcs_error("Not supported format");
+ break;
}
- gstcs_debug("format_label [%s], Chosen video format [%s]", format_label, gst_video_format_to_string(videoFormat));
+ gstcs_debug("color_format [%d], Chosen video format [%s]", color_format, gst_video_format_to_string(videoFormat));
return videoFormat;
}
-static void
-_mm_set_image_input_format_s_capabilities(image_format_s* __format) /*_format_label: I420 _colorsapace: YUV */
+static GstCaps* _mm_get_capabilities(mm_util_color_format_e color_format, unsigned int width, unsigned int height)
{
+ GstCaps *caps = NULL;
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);
+ videoFormat = _mm_get_video_format(color_format);
+ gstcs_retvm_if(videoFormat == GST_VIDEO_FORMAT_UNKNOWN, NULL, "Unkown video format (%d)", color_format);
- if (strcmp(__format->colorspace, "YUV") == 0) {
- __format->caps = gst_caps_new_simple("video/x-raw",
+ 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->width,
- "height", G_TYPE_INT, __format->height,
+ "width", G_TYPE_INT, width,
+ "height", G_TYPE_INT, height,
"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),
- "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),
- "width", G_TYPE_INT, __format->width,
- "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_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),
- "width", G_TYPE_INT, __format->width,
- "height", G_TYPE_INT, __format->height,
- "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),
- "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) {
- __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) {
- 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)
-{
- 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);
- } 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);
- } 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);
- } else if ((strcmp(__format->format_label, "BGRX") == 0)) {
- SAFE_STRCPY(__format->colorspace, "BGRX", IMAGE_FORMAT_LABEL_BUFFER_SIZE);
- } else {
- gstcs_error("Check your colorspace format label");
- GSTCS_FREE(__format->colorspace);
- }
-}
-
-static int _gstcs_create_image_format(image_format_s **format)
-{
- int ret = GSTCS_ERROR_NONE;
- image_format_s *_format = NULL;
-
- if (format == NULL) {
- gstcs_error("format is wrong value");
- return GSTCS_ERROR_INVALID_OPERATION;
- }
-
- _format = (image_format_s*)malloc(sizeof(image_format_s));
- if (_format == NULL) {
- gstcs_error("memory allocation failed");
- return GSTCS_ERROR_OUT_OF_MEMORY;
- }
- memset(_format, 0, sizeof(image_format_s));
- *format = _format;
+ if (caps)
+ _mm_check_caps_format(caps);
+ else
+ gstcs_error("caps is NULL");
- return ret;
+ return caps;
}
-static void _gstcs_destroy_image_format(image_format_s *format)
+static void _mm_get_round_up_width_height(mm_util_color_format_e color_format, unsigned int width, unsigned int height, unsigned int *stride, unsigned int *elevation)
{
- if (format != NULL) {
- gst_caps_unref(format->caps);
- GSTCS_FREE(format->format_label);
- GSTCS_FREE(format->colorspace);
- GSTCS_FREE(format);
+ switch (color_format) {
+ case MM_UTIL_COLOR_YUV420:
+ case MM_UTIL_COLOR_YUV422:
+ case MM_UTIL_COLOR_I420:
+ case MM_UTIL_COLOR_NV12:
+ case MM_UTIL_COLOR_UYVY:
+ case MM_UTIL_COLOR_YUYV:
+ *stride = width;
+ *elevation = height;
+ break;
+ case MM_UTIL_COLOR_RGB16:
+ case MM_UTIL_COLOR_RGB24:
+ *stride = MM_UTIL_ROUND_UP_4(width);
+ *elevation = MM_UTIL_ROUND_UP_2(height);
+ break;
+ case MM_UTIL_COLOR_ARGB:
+ case MM_UTIL_COLOR_BGRA:
+ case MM_UTIL_COLOR_RGBA:
+ case MM_UTIL_COLOR_BGRX:
+ *stride = width;
+ *elevation = MM_UTIL_ROUND_UP_2(height);
+ break;
+ default:
+ gstcs_error("Not supported format");
+ break;
}
-}
-static void
-_mm_round_up_input_image_widh_height(image_format_s* pFormat)
-{
- 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) {
- 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("input_format stride: %d, elevation: %d", pFormat->stride, pFormat->elevation);
+ gstcs_debug("color_format[%d] width[%u] height[%u] stride[%u], elevation[%u]", color_format, width, height, *stride, *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 size_t _mm_setup_image_size(mm_util_color_format_e color_format, unsigned int width, unsigned int height)
{
- int ret = GSTCS_ERROR_NONE;
- image_format_s* __format = NULL;
+ size_t size = 0;
- ret = _gstcs_create_image_format(&__format);
- if (ret != GSTCS_ERROR_NONE) {
- gstcs_debug("Error: _gstcs_create_image_format is failed (%d)\n", ret);
- return NULL;
- }
+ gstcs_debug("color_format [%d] width [%u] height [%u]", color_format, width, height);
- __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;
+ switch (color_format) {
+ case MM_UTIL_COLOR_YUV420:
+ 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; */
+ break;
+ case MM_UTIL_COLOR_YUV422:
+ size = (MM_UTIL_ROUND_UP_4(width) * height + MM_UTIL_ROUND_UP_8(width) * height); /*width * height *2; */
+ break;
+ case MM_UTIL_COLOR_I420:
+ 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; */
+ break;
+ case MM_UTIL_COLOR_NV12:
+ size = (MM_UTIL_ROUND_UP_4(width) * MM_UTIL_ROUND_UP_2(height) * 1.5); /* width * height *1.5; */
+ break;
+ case MM_UTIL_COLOR_UYVY:
+ size = (MM_UTIL_ROUND_UP_2(width) * 2 * height); /* width * height *2; */
+ break;
+ case MM_UTIL_COLOR_YUYV:
+ size = (MM_UTIL_ROUND_UP_2(width) * 2 * height); /* width * height *2; */
+ break;
+ case MM_UTIL_COLOR_RGB16:
+ size = (MM_UTIL_ROUND_UP_4(width) * 2 * height); /* width * height *2; */
+ break;
+ case MM_UTIL_COLOR_RGB24:
+ size = (MM_UTIL_ROUND_UP_4(width) * 3 * height); /* width * height *3; */
+ break;
+ case MM_UTIL_COLOR_ARGB:
+ case MM_UTIL_COLOR_BGRA:
+ case MM_UTIL_COLOR_RGBA:
+ case MM_UTIL_COLOR_BGRX:
+ size = width * height *4;
+ break;
+ default:
+ gstcs_error("Not supported format");
+ break;
}
- 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);
- _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_set_image_input_format_s_capabilities(__format);
- return __format;
-}
+ gstcs_debug("Image size [%zu]", size);
-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 = MM_UTIL_ROUND_UP_8(pFormat->width);
- pFormat->elevation = MM_UTIL_ROUND_UP_2(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);
- pFormat->width = pFormat->stride;
- if (input_format->height != input_format->elevation)
- pFormat->height = pFormat->elevation;
- } 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);
- if (input_format->height != input_format->elevation)
- pFormat->height = pFormat->elevation;
- }
- gstcs_debug("output_format stride: %d, elevation: %d", pFormat->stride, pFormat->elevation);
+ return size;
}
-static image_format_s*
-_mm_set_output_image_format_s_struct(imgp_info_s* pImgp_info, const image_format_s *input_format)
+static int _mm_push_buffer_into_pipeline(imgp_info_s* pImgp_info, unsigned char *src, gstreamer_s * pGstreamer_s)
{
int ret = GSTCS_ERROR_NONE;
- image_format_s* __format = NULL;
+ size_t data_size = 0;
+ GstBuffer* gst_buf = NULL;
- ret = _gstcs_create_image_format(&__format);
- if (ret != GSTCS_ERROR_NONE) {
- gstcs_debug("Error: _gstcs_create_image_format is failed (%d)\n", ret);
- return NULL;
- }
+ gstcs_fenter();
- __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);
- _mm_set_image_colorspace(__format);
+ gstcs_retvm_if(pGstreamer_s->pipeline == NULL, GSTCS_ERROR_INVALID_PARAMETER, "Invalid pipeline");
- __format->width = pImgp_info->dst_width;
- __format->height = pImgp_info->dst_height;
- _mm_round_up_output_image_widh_height(__format, input_format);
+ data_size = _mm_setup_image_size(pImgp_info->src_format, pImgp_info->src_width, pImgp_info->src_height);
+ gst_buf = gst_buffer_new_wrapped_full(GST_MEMORY_FLAG_READONLY, src, data_size, 0, data_size, NULL, NULL);
- pImgp_info->output_stride = __format->stride;
- pImgp_info->output_elevation = __format->elevation;
+ gstcs_retvm_if(gst_buf == NULL, GSTCS_ERROR_INVALID_OPERATION, "buffer is NULL");
- gstcs_debug("output_format_label: %s", pImgp_info->output_format_label);
- _mm_set_image_output_format_s_capabilities(__format);
- return __format;
-}
-
-static int
-_mm_push_buffer_into_pipeline(imgp_info_s* pImgp_info, unsigned char *src, gstreamer_s * pGstreamer_s)
-{
- int ret = GSTCS_ERROR_NONE;
-
- if (pGstreamer_s->pipeline == NULL) {
- gstcs_error("pipeline 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 */
- 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);
+ gstcs_fleave();
- 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 */
return ret;
}
-static int
-_mm_push_buffer_into_pipeline_new(image_format_s *input_format, unsigned char *src, gstreamer_s * pGstreamer_s)
+static int _mm_push_buffer_into_pipeline_new(unsigned char *src, gstreamer_s * pGstreamer_s, mm_util_color_format_e color_format, unsigned int width, unsigned int height, unsigned int stride, unsigned int elevation)
{
int ret = GSTCS_ERROR_NONE;
GstBuffer *gst_buf = NULL;
- unsigned int src_size = 0;
+ size_t src_size = 0;
unsigned char *data = NULL;
- unsigned int stride = input_format->stride;
- unsigned int elevation = input_format->elevation;
- if (pGstreamer_s->pipeline == NULL) {
- gstcs_error("pipeline is NULL\n");
- return GSTCS_ERROR_INVALID_PARAMETER;
- }
+ gstcs_fenter();
- gstcs_debug("stride: %d, elevation: %d", stride, elevation);
- src_size = mm_setup_image_size(input_format->format_label, stride, elevation);
- gstcs_debug("buffer size (src): %d", src_size);
+ gstcs_retvm_if(pGstreamer_s->pipeline == NULL, GSTCS_ERROR_INVALID_PARAMETER, "Invalid pipeline");
+ gstcs_retvm_if((width == 0 || height == 0), GSTCS_ERROR_INVALID_PARAMETER, "Invalid width(%u) and height(%u)", width, height);
- int byte_per_pixcel = _mm_get_byte_per_pixcel(input_format->format_label);
- unsigned int src_row = input_format->width * byte_per_pixcel;
+ src_size = _mm_setup_image_size(color_format, stride, elevation);
+
+ int byte_per_pixcel = _mm_get_byte_per_pixcel(color_format);
+ unsigned int src_row = width * byte_per_pixcel;
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 *) 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++) {
+ gstcs_retvm_if(data == NULL, GSTCS_ERROR_OUT_OF_MEMORY, "data is NULL");
+
+ for (y = 0; y < height; y++) {
guint8 *pLine = (guint8 *) &(src[src_row * y]);
for (i = 0; i < src_row; i++)
data[y * stride_row + i] = pLine[i];
for (i = src_row; i < stride_row; i++)
data[y * stride_row + i] = stride_row_color;
}
- for (y = (unsigned int)(input_format->height); y < (unsigned int)(input_format->elevation); y++) {
+ for (y = height; y < elevation; y++) {
for (i = 0; i < stride_row; i++)
data[y * stride_row + i] = data[(y - 1) * stride_row + i];
}
}
gst_app_src_push_buffer(GST_APP_SRC(pGstreamer_s->appsrc), gst_buf); /* push buffer to pipeline */
+
+ gstcs_fleave();
+
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)
+static int _mm_imgp_gstcs_processing(gstreamer_s* pGstreamer_s, unsigned char *src, unsigned char **dst, imgp_info_s* pImgp_info)
{
GstBus *bus = NULL;
GstStateChangeReturn ret_state;
int ret = GSTCS_ERROR_NONE;
+ GstCaps *src_caps = NULL;
+ GstCaps *dst_caps = NULL;
+ unsigned int src_stride = 0;
+ unsigned int src_elevation = 0;
+
+ gstcs_fenter();
/*create pipeline*/
ret = _mm_create_pipeline(pGstreamer_s);
- if (ret != GSTCS_ERROR_NONE)
+ if (ret != GSTCS_ERROR_NONE) {
gstcs_error("ERROR - mm_create_pipeline ");
+ return ret;
+ }
/* 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_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);
- gst_app_sink_set_caps(GST_APP_SINK(pGstreamer_s->appsink), output_format->caps);
+ _mm_get_round_up_width_height(pImgp_info->src_format, pImgp_info->src_width, pImgp_info->src_height, &src_stride, &src_elevation);
+ _mm_get_round_up_width_height(pImgp_info->dst_format, pImgp_info->dst_width, pImgp_info->dst_height, &pImgp_info->output_stride, &pImgp_info->output_elevation);
- if (((input_format->width != input_format->stride) || (input_format->height != input_format->elevation)) &&
- ((strcmp(input_format->colorspace, "RGB") == 0) || (strcmp(input_format->colorspace, "RGBA") == 0))) {
- gstcs_debug("Start _mm_push_buffer_into_pipeline_new");
- ret = _mm_push_buffer_into_pipeline_new(input_format, src, pGstreamer_s);
+ src_caps = _mm_get_capabilities(pImgp_info->src_format, src_stride, src_elevation);
+ dst_caps = _mm_get_capabilities(pImgp_info->dst_format, pImgp_info->output_stride, pImgp_info->output_elevation);
+ if (src_caps == NULL || dst_caps == NULL) {
+ gstcs_error("ERROR - _mm_get_capabilities ");
+ SAFE_UNREF_CAPS(src_caps);
+ SAFE_UNREF_CAPS(dst_caps);
+ gst_object_unref(pGstreamer_s->pipeline);
+ return ret;
+ }
+
+ gst_app_src_set_caps(GST_APP_SRC(pGstreamer_s->appsrc), src_caps);
+ gst_app_sink_set_caps(GST_APP_SINK(pGstreamer_s->appsink), dst_caps);
+
+ if ((pImgp_info->src_width != src_stride) || (pImgp_info->src_height != src_elevation)) {
+ ret = _mm_push_buffer_into_pipeline_new(src, pGstreamer_s, pImgp_info->src_format, pImgp_info->src_width, pImgp_info->src_height, src_stride, src_elevation);
} else {
- gstcs_debug("Start mm_push_buffer_into_pipeline");
ret = _mm_push_buffer_into_pipeline(pImgp_info, src, pGstreamer_s);
}
+
if (ret != GSTCS_ERROR_NONE) {
gstcs_error("ERROR - mm_push_buffer_into_pipeline ");
+ SAFE_UNREF_CAPS(src_caps);
+ SAFE_UNREF_CAPS(dst_caps);
gst_object_unref(pGstreamer_s->pipeline);
return ret;
}
- gstcs_debug("End mm_push_buffer_into_pipeline");
/*link pipeline*/
- gstcs_debug("Start mm_link_pipeline");
_mm_link_pipeline(pGstreamer_s, 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)");
gstcs_debug("Success gst_element_get_state\n");
+ SAFE_UNREF_CAPS(src_caps);
+ SAFE_UNREF_CAPS(dst_caps);
+
if (ret_state == GST_STATE_CHANGE_FAILURE) {
gstcs_error("GST_STATE_CHANGE_FAILURE");
} else {
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;
- int calc_buffer_size = 0;
- if (((pImgp_info->dst_width != (unsigned int)(output_format->width)) || (pImgp_info->dst_height != (unsigned int)(output_format->height))) &&
- ((strcmp(input_format->colorspace, "RGB") == 0) || (strcmp(input_format->colorspace, "RGBA") == 0))) {
- gstcs_debug("calculate image size with stride & elevation");
- calc_buffer_size = mm_setup_image_size(pImgp_info->output_format_label, output_format->width, output_format->height);
- } else {
- 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);
+ size_t buffer_size = mapinfo.size;
+ size_t calc_buffer_size = 0;
+
+ calc_buffer_size = _mm_setup_image_size(pImgp_info->dst_format, pImgp_info->output_stride, pImgp_info->output_elevation);
+
+ gstcs_debug("buffer size[%zu], calc[%zu]", buffer_size, calc_buffer_size);
if (buffer_size != calc_buffer_size) {
gstcs_debug("Buffer size is different \n");
gstcs_debug("unref output buffer");
gst_object_unref(pGstreamer_s->pipeline);
pGstreamer_s->output_buffer = NULL;
- gstcs_debug("End gstreamer processing");
gstcs_debug("dst: %p", *dst);
- return ret;
-}
-
-
-static int
-mm_setup_image_size(const char* _format_label, int width, int height)
-{
- int size = 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)
- 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)
- 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)
- 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)
- 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)
- size = (MM_UTIL_ROUND_UP_4(width) * 2 * height); /* width * height *2; */
- 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)
- size = (MM_UTIL_ROUND_UP_4(width) * 3 * height); /* width * height *3; */
- 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)
- size = (MM_UTIL_ROUND_UP_2(width) * 2 * height); /* width * height *2; */
- else if (strcmp(_format_label, "ARGB8888") == 0)
- size = width * height *4;
- else if (strcmp(_format_label, "BGRA8888") == 0)
- size = width * height *4;
- else if (strcmp(_format_label, "RGBA8888") == 0)
- size = width * height *4;
- else if (strcmp(_format_label, "ABGR8888") == 0)
- size = width * height *4;
- else if (strcmp(_format_label, "BGRX") == 0)
- size = width * height *4;
+ gstcs_fleave();
- gstcs_debug("file_size: %d\n", size);
-
- return size;
+ return ret;
}
static int _gstcs_create_default_thread(gstreamer_s *gstreamer)
{
- if (gstreamer == NULL) {
- gstcs_error("ERROR - gstreamer is null ");
- return GSTCS_ERROR_INVALID_OPERATION;
- }
+ gstcs_retvm_if(gstreamer == NULL, GSTCS_ERROR_INVALID_PARAMETER, "Invalid gstreamer");
gstreamer->context = g_main_context_new();
- if (gstreamer->context == NULL) {
- gstcs_error("ERROR - g_main_context_new ");
- return GSTCS_ERROR_INVALID_OPERATION;
- }
+ gstcs_retvm_if(gstreamer->context == NULL, GSTCS_ERROR_INVALID_OPERATION, "ERROR - g_main_context_new");
+
gstreamer->loop = g_main_loop_new(gstreamer->context, FALSE);
if (gstreamer->loop == NULL) {
gstcs_error("ERROR - g_main_loop_new ");
}
g_main_context_push_thread_default(gstreamer->context);
+
return GSTCS_ERROR_NONE;
}
static int _gstcs_destroy_default_thread(gstreamer_s *gstreamer)
{
- if (gstreamer == NULL) {
- gstcs_error("ERROR - gstreamer is null ");
- return GSTCS_ERROR_INVALID_OPERATION;
- }
+ gstcs_retvm_if(gstreamer == NULL, GSTCS_ERROR_INVALID_PARAMETER, "Invalid gstreamer");
if (gstreamer->loop != NULL)
g_main_loop_unref(gstreamer->loop);
argv = malloc(sizeof(gchar*) * max_argc);
- if (!argv) {
- gstcs_error("argv is not allocated");
- return GSTCS_ERROR_OUT_OF_MEMORY;
- }
+ gstcs_retvm_if(argv == NULL, GSTCS_ERROR_OUT_OF_MEMORY, "argv is not allocated");
+
memset(argv, 0, sizeof(gchar*) * max_argc);
argv[argc] = g_strdup("mmutil_gstcs");
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;
gstreamer_s* pGstreamer_s;
int ret = GSTCS_ERROR_NONE;
/* Print debug message for inout structure */
- 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);
+ gstcs_debug("src_width [%d] src_height [%d] src_format [%d] dst_width [%d] dst_height [%d] dst_format [%d] rotation [%d]",
+ pImgp_info->src_width, pImgp_info->src_height, pImgp_info->src_format, pImgp_info->dst_width, pImgp_info->dst_height, pImgp_info->dst_format, pImgp_info->angle);
/* Initialize gstreamer */
ret = _gstcs_init(&pGstreamer_s);
return ret;
}
- /* Create input/output format for gstreamer processing */
- input_format = _mm_set_input_image_format_s_struct(pImgp_info);
- if (input_format == NULL) {
- gstcs_error("Error: memory allocation failed");
- GSTCS_FREE(pGstreamer_s);
- return GSTCS_ERROR_OUT_OF_MEMORY;
- }
-
- output_format = _mm_set_output_image_format_s_struct(pImgp_info, input_format);
- if (output_format == NULL) {
- gstcs_error("Error: memory allocation failed");
- _gstcs_destroy_image_format(input_format);
- GSTCS_FREE(pGstreamer_s);
- return GSTCS_ERROR_OUT_OF_MEMORY;
- }
-
/* Create default thread for async behavior */
ret = _gstcs_create_default_thread(pGstreamer_s);
if (ret != GSTCS_ERROR_NONE) {
gstcs_error("Error: _gstcs_create_default_thread is failed");
- _gstcs_destroy_image_format(input_format);
- _gstcs_destroy_image_format(output_format);
GSTCS_FREE(pGstreamer_s);
return ret;
}
/* Do gstreamer processing */
- 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, 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)
gstcs_debug("End _mm_imgp_gstcs_processing [dst: %p]", *dst);
if (ret != GSTCS_ERROR_NONE)
gstcs_error("Error: _gstcs_create_default_thread is failed");
- _gstcs_destroy_image_format(input_format);
- _gstcs_destroy_image_format(output_format);
GSTCS_FREE(pGstreamer_s);
return ret;
}
-int mm_imgp(imgp_info_s* pImgp_info, unsigned char *src, unsigned char **dst, imgp_type_e _imgp_type)
+static bool _mm_imgp_check_format(mm_util_color_format_e color_format)
{
- if (pImgp_info == NULL) {
- gstcs_error("Error: input vaule is NULL");
- return GSTCS_ERROR_INVALID_PARAMETER;
- }
+ if ((color_format >= MM_UTIL_COLOR_YUV420) && (color_format <= MM_UTIL_COLOR_BGRX))
+ return TRUE;
- if (src == NULL || dst == NULL) {
- gstcs_error("Error: src | dst is NULL");
- return GSTCS_ERROR_INVALID_PARAMETER;
- }
+ return FALSE;
+}
- if (_imgp_type < 0 || _imgp_type > IMGP_MAX) {
- gstcs_error("Error: imgp_type is wrong");
- return GSTCS_ERROR_INVALID_PARAMETER;
- }
+int mm_imgp(imgp_info_s* pImgp_info, unsigned char *src, unsigned char **dst, imgp_type_e _imgp_type)
+{
+ gstcs_retvm_if(pImgp_info == NULL, GSTCS_ERROR_INVALID_PARAMETER, "Invalid info");
+ gstcs_retvm_if(src == NULL, GSTCS_ERROR_INVALID_PARAMETER, "Invalid src");
+ gstcs_retvm_if(dst == NULL, GSTCS_ERROR_INVALID_PARAMETER, "Invalid dst");
+ gstcs_retvm_if((_imgp_type < 0 || _imgp_type > IMGP_MAX), GSTCS_ERROR_INVALID_PARAMETER, "Invalid _imgp_type[%d]", _imgp_type);
+ gstcs_retvm_if((_mm_imgp_check_format(pImgp_info->src_format) == FALSE), GSTCS_ERROR_NOT_SUPPORTED_FORMAT, "not supported src_format [%d]", pImgp_info->src_format);
+ gstcs_retvm_if((_mm_imgp_check_format(pImgp_info->dst_format) == FALSE), GSTCS_ERROR_NOT_SUPPORTED_FORMAT, "not supported dst_format [%d]", pImgp_info->dst_format);
gstcs_debug("[src %p] [dst %p]", src, dst);