#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 setup_image_size_I420(width, height) { \
int size=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); \
size = (MM_UTIL_ROUND_UP_4 (width*3) * height); \
return size; \
}
-/*########################################################################################*/
static void
-_mm_sink_buffer (GstElement * appsink, gpointer user_data)
+_mm_sink_sample (GstElement * appsink, gpointer user_data)
{
GstBuffer *_buf=NULL;
GstSample *_sample = NULL;
pGstreamer_s->output_buffer = _buf;
if(pGstreamer_s->output_buffer != NULL) {
- GstMapInfo mapinfo = GST_MAP_INFO_INIT;
- gst_buffer_map(pGstreamer_s->output_buffer, &mapinfo, GST_MAP_READ);
- debug_log("Create Output Buffer: GST_BUFFER_DATA: %p\t GST_BUFFER_SIZE: %d\n", mapinfo.data, mapinfo.size);
- gst_buffer_unmap(pGstreamer_s->output_buffer, &mapinfo);
- }else {
+ GstMapInfo mapinfo = GST_MAP_INFO_INIT;
+ gst_buffer_map(pGstreamer_s->output_buffer, &mapinfo, GST_MAP_READ);
+ debug_log("Create Output Buffer: GST_BUFFER_DATA: %p\t GST_BUFFER_SIZE: %d", mapinfo.data, mapinfo.size);
+ gst_buffer_unmap(pGstreamer_s->output_buffer, &mapinfo);
+ } else {
debug_error("ERROR -Input Prepare Buffer! Check createoutput buffer function");
}
gst_buffer_ref (pGstreamer_s->output_buffer); /* when you want to avoid flushing */
GstSample *_sample = NULL;
GstBuffer *_buf=NULL;
gstreamer_s * pGstreamer_s = (gstreamer_s*) user_data;
-
- _sample = gst_app_sink_pull_preroll((GstAppSink*)appsink);
- _buf = gst_sample_get_buffer(_sample);
+ _buf = gst_app_sink_pull_preroll((GstAppSink*)appsink);
pGstreamer_s->output_buffer = _buf;
/* pGstreamer_s->output_image_format_s->caps = GST_BUFFER_CAPS(_buf); */
if(pGstreamer_s->output_buffer != NULL) {
GstMapInfo mapinfo = GST_MAP_INFO_INIT;
gst_buffer_map(pGstreamer_s->output_buffer, &mapinfo, GST_MAP_READ);
- debug_log("Create Output Buffer: GST_BUFFER_DATA: %p\t GST_BUFFER_SIZE: %d\n",
- mapinfo.data, mapinfo.size);
+ debug_log("Create Output Buffer: GST_BUFFER_DATA: %p\t GST_BUFFER_SIZE: %d", mapinfo.data, mapinfo.size);
gst_buffer_unmap(pGstreamer_s->output_buffer, &mapinfo);
} else {
debug_error("ERROR -Input Prepare Buffer! Check createoutput buffer function");
}
+
gst_buffer_ref (pGstreamer_s->output_buffer); /* when you want to avoid flushings */
gst_sample_unref(_sample);
}
{
int ret = MM_ERROR_NONE;
pGstreamer_s->pipeline= gst_pipeline_new ("videoconvert");
+ if (!pGstreamer_s->pipeline) {
+ debug_error("pipeline could not be created. Exiting.\n");
+ ret = MM_ERROR_IMAGE_INVALID_VALUE;
+ }
pGstreamer_s->appsrc= gst_element_factory_make("appsrc","appsrc");
+ if (!pGstreamer_s->appsrc) {
+ debug_error("appsrc could not be created. Exiting.\n");
+ ret = MM_ERROR_IMAGE_INVALID_VALUE;
+ }
pGstreamer_s->colorspace=gst_element_factory_make("videoconvert","colorconverter");
-
+ if (!pGstreamer_s->colorspace) {
+ debug_error("colorspace could not be created. Exiting.\n");
+ ret = MM_ERROR_IMAGE_INVALID_VALUE;
+ }
pGstreamer_s->videoscale=gst_element_factory_make("videoscale", "scale");
+ if (!pGstreamer_s->videoscale) {
+ debug_error("videoscale could not be created. Exiting.\n");
+ ret = MM_ERROR_IMAGE_INVALID_VALUE;
+ }
pGstreamer_s->videoflip=gst_element_factory_make( "videoflip", "flip" );
-
+ if (!pGstreamer_s->videoflip) {
+ debug_error("videoflip could not be created. Exiting.\n");
+ ret = MM_ERROR_IMAGE_INVALID_VALUE;
+ }
pGstreamer_s->appsink=gst_element_factory_make("appsink","appsink");
-
- if (!pGstreamer_s->pipeline || !pGstreamer_s->appsrc||!pGstreamer_s->colorspace || !pGstreamer_s->appsink) {
- debug_error("One element could not be created. Exiting.\n");
+ if (!pGstreamer_s->appsink) {
+ debug_error("appsink could not be created. Exiting.\n");
ret = MM_ERROR_IMAGE_INVALID_VALUE;
}
+
return ret;
}
}
static void
-_mm_link_pipeline_order_csc_rsz(gstreamer_s* pGstreamer_s, image_format_s* input_format, image_format_s* output_format)
+_mm_check_caps_format(GstCaps* caps)
{
- if(_mm_check_resize_format(input_format->width,input_format->height, output_format->width, output_format->height)) {
- debug_log("check_for_resize");
- gst_bin_add_many(GST_BIN(pGstreamer_s->pipeline), pGstreamer_s->appsrc, pGstreamer_s->videoscale, pGstreamer_s->colorspace, pGstreamer_s->appsink, NULL);
- debug_log("gst_bin_add_many");
- if(_mm_check_resize_format_label( input_format->format_label)) {
- debug_log(" input_format->format_label: %s", input_format->format_label);
- if(!gst_element_link_many(pGstreamer_s->appsrc, pGstreamer_s->videoscale, pGstreamer_s->colorspace, pGstreamer_s->appsink, NULL)) {
- debug_error("Fail to link b/w ffmpeg and appsink except rot\n");
- }
- }else if(_mm_check_resize_format_label(output_format->format_label)) {
- debug_log("output_format->format_label: %s", output_format->format_label);
- if(!gst_element_link_many(pGstreamer_s->appsrc, pGstreamer_s->colorspace, pGstreamer_s->videoscale, pGstreamer_s->appsink, NULL)) {
- debug_error("Fail to link b/w ffmpeg and appsink except rot\n");
- }
- }
- }else {
- debug_log("check_for_convert");
- gst_bin_add_many(GST_BIN(pGstreamer_s->pipeline), pGstreamer_s->appsrc, pGstreamer_s->colorspace, pGstreamer_s->appsink, NULL);
- debug_log("gst_bin_add_many");
- if(!gst_element_link_many(pGstreamer_s->appsrc, pGstreamer_s->colorspace, pGstreamer_s->appsink, NULL)) {
- debug_error("Fail to link b/w ffmpeg and appsink except rsz & rot\n");
- }
- }
+ GstStructure *caps_structure = gst_caps_get_structure (caps, 0);
+ const gchar* formatInfo = gst_structure_get_string (caps_structure, "format");
+ debug_log("[%d] caps: %s", GST_IS_CAPS(caps), formatInfo);
}
static void
-_mm_link_pipeline_order_csc_rsz_rot(gstreamer_s* pGstreamer_s, image_format_s* input_format, image_format_s* output_format)
-{
- if(_mm_check_rotate_format_label(input_format->format_label)) {
- gst_bin_add_many(GST_BIN(pGstreamer_s->pipeline), pGstreamer_s->appsrc, pGstreamer_s->videoscale, pGstreamer_s->videoflip, pGstreamer_s->colorspace, pGstreamer_s->appsink, NULL);
- if(!gst_element_link_many(pGstreamer_s->appsrc, pGstreamer_s->videoscale, pGstreamer_s->videoflip, pGstreamer_s->colorspace, pGstreamer_s->appsink, NULL)) {
- debug_error("Fail to link b/w appsrc and ffmpeg in rotate\n");
- }
- }else if(_mm_check_rotate_format_label(output_format->format_label)) {
- 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)) {
- debug_error("Fail to link b/w ffmpeg and appsink in rotate\n");
- }
- }
-}
-
-
-static void
-_mm_link_pipeline( gstreamer_s* pGstreamer_s, image_format_s* input_format, image_format_s* output_format, int _valuepGstreamer_sVideoFlipMethod)
+_mm_link_pipeline(gstreamer_s* pGstreamer_s, image_format_s* input_format, image_format_s* output_format, int value)
{
/* set property */
- gst_app_src_set_caps(GST_APP_SRC(pGstreamer_s->appsrc), input_format->caps); /* g_object_set(pGstreamer_s->appsrc, "caps", input_format->caps, NULL); you can use appsrc'cap property */
+ gst_app_src_set_caps(GST_APP_SRC(pGstreamer_s->appsrc), input_format->caps); /*g_object_set(pGstreamer_s->appsrc, "caps", input_format->caps, NULL);*/
+ gst_app_sink_set_caps(GST_APP_SINK(pGstreamer_s->appsink), output_format->caps); /*g_object_set(pGstreamer_s->appsink, "caps", output_format->caps, NULL); */
+ 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)) {
+ debug_error("Fail to link pipeline");
+ } else {
+ debug_log("Success to link pipeline");
+ }
+
+ 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->appsrc, "format", GST_FORMAT_TIME, NULL);
- g_object_set(pGstreamer_s->appsrc, "stream-type", 0 /*stream*/, NULL);
- g_object_set(pGstreamer_s->videoflip, "method", _valuepGstreamer_sVideoFlipMethod, 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 */
- gst_app_sink_set_caps(GST_APP_SINK(pGstreamer_s->appsink), output_format->caps); /*g_object_set(pGstreamer_s->appsink, "caps", output_format->caps, NULL); */
g_object_set(pGstreamer_s->appsink, "drop", TRUE, NULL);
g_object_set(pGstreamer_s->appsink, "emit-signals", TRUE, "sync", FALSE, NULL);
-
- if(_mm_check_rotate_format(_valuepGstreamer_sVideoFlipMethod)) { /* when you want to rotate image */
- /* because IYUV, I420, YV12 format can use vidoeflip*/
- debug_log("set_link_pipeline_order_csc_rsz_rot");
- _mm_link_pipeline_order_csc_rsz_rot(pGstreamer_s, input_format, output_format);
- }else {
- debug_log("set_link_pipeline_order_csc_rsz");
- _mm_link_pipeline_order_csc_rsz(pGstreamer_s, input_format, output_format);
- }
- /* Conecting to the new-sample signal emited by the appsink*/
- debug_log("Start G_CALLBACK (mm_sink_buffer)");
- g_signal_connect (pGstreamer_s->appsink, "new-sample", G_CALLBACK (_mm_sink_buffer), pGstreamer_s);
- debug_log("End G_CALLBACK (mm_sink_buffer)");
}
-
-
static void
_mm_set_image_format_s_capabilities(image_format_s* __format) /*_format_label: I420 _colorsapace: YUV */
{
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;
if(__format == NULL) {
}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);
+ debug_log("Chosen video format: %s", gst_video_format_to_string(videoFormat));
+
__format->caps = gst_caps_new_simple ("video/x-raw",
- "format", G_TYPE_STRING, gst_video_format_to_string(
- gst_video_format_from_masks(_depth, _bpp, _endianness,
- _red_mask, _green_mask, _blue_mask, 0)),
+ "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]*/
+ debug_log("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=65280; _green_mask=16711680; _blue_mask=-16777216; _alpha_mask=255; _endianness=4321;
+ debug_log("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]*/
+ debug_log("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=255; _green_mask=65280; _blue_mask=16711680; _alpha_mask=-16777216; _endianness=4321;
+ debug_log("ABGR8888");
+ _bpp=32; _depth=32; _red_mask=255; _green_mask=65280; _blue_mask=16711680; _alpha_mask=-16777216; _endianness=4321;
}else {
debug_error("***Wrong format cs type***\n");
}
+ videoFormat = gst_video_format_from_masks(_depth, _bpp, _endianness, _red_mask, _green_mask, _blue_mask, _alpha_mask);
+ debug_log("Chosen video format: %s", gst_video_format_to_string(videoFormat));
+
__format->caps = gst_caps_new_simple ("video/x-raw",
- "format", G_TYPE_STRING, gst_video_format_to_string(
- gst_video_format_from_masks(_depth, _bpp, _endianness,
- _red_mask, _green_mask, _blue_mask, _alpha_mask)),
+ "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) {
debug_log("###__format->caps is not NULL###, %p", __format->caps);
+ _mm_check_caps_format(__format->caps);
}else {
debug_error("__format->caps is NULL");
}
debug_log("format_label: %s\n", __format->format_label);
__format->colorspace = (char*)malloc(sizeof(char) * IMAGE_FORMAT_LABEL_BUFFER_SIZE);
+ if (__format->colorspace == NULL) {
+ debug_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)) {
image_format_s* __format = NULL;
__format=(image_format_s*)malloc(sizeof(image_format_s));
+ if (__format == NULL) {
+ debug_error("memory allocation failed");
+ return NULL;
+ }
memset(__format, 0, sizeof(image_format_s));
__format->format_label = (char *)malloc(sizeof(char) * IMAGE_FORMAT_LABEL_BUFFER_SIZE);
+ if (__format->format_label == NULL) {
+ debug_error("memory allocation failed");
+ GSTCS_FREE(__format);
+ return NULL;
+ }
memset(__format->format_label, 0, IMAGE_FORMAT_LABEL_BUFFER_SIZE);
strncpy(__format->format_label, pImgp_info->input_format_label, strlen(pImgp_info->input_format_label));
debug_log("input_format_label: %s\n", pImgp_info->input_format_label);
image_format_s* __format = NULL;
__format=(image_format_s*)malloc(sizeof(image_format_s));
+ if (__format == NULL) {
+ debug_error("memory allocation failed");
+ return NULL;
+ }
memset(__format, 0, sizeof(image_format_s));
__format->format_label = (char *)malloc(sizeof(char) * IMAGE_FORMAT_LABEL_BUFFER_SIZE);
+ if (__format->format_label == NULL) {
+ debug_error("memory allocation failed");
+ GSTCS_FREE(__format);
+ return NULL;
+ }
memset(__format->format_label, 0, IMAGE_FORMAT_LABEL_BUFFER_SIZE);
strncpy(__format->format_label, pImgp_info->output_format_label, strlen(pImgp_info->output_format_label));
_mm_set_image_colorspace(__format);
__format->blocksize = mm_setup_image_size(pImgp_info->output_format_label, pImgp_info->dst_width, pImgp_info->dst_height);
debug_log("output_format_label: %s", pImgp_info->output_format_label);
_mm_set_image_format_s_capabilities(__format);
- debug_log("pImgp_info->dst: %p", pImgp_info->dst);
return __format;
}
-static gboolean
-__mm_check_resize_format( char* _in_format_label, int _in_w, int _in_h, char* _out_format_label, int _out_w, int _out_h)
-{
- gboolean _bool=TRUE;
- debug_log("input image format: %s input image width: %d input image height: %d output image format: %s output image width: %d output image height: %d\n",
- _in_format_label, _in_w,_in_h, _out_format_label, _out_w, _out_h);
- if(_mm_check_resize_format(_in_w, _in_h, _out_w, _out_h)) {
- if( !( _mm_check_resize_format_label(_in_format_label) ||_mm_check_resize_format_label(_out_format_label) ) ) {
- debug_error("ERROR-%s | %s Resize Only [AYUV] [YUY2] [YVYU] [UYVY] [Y800] [I420][YV12] format can use vidoeflip ERROR- Resize!!!#####\n", _in_format_label, _out_format_label);
- _bool = FALSE;
- }
- }
- return _bool;
-}
-
-static gboolean
-__mm_check_rotate_format(int angle, const char* input_format_label, const char* output_format_label)
-{
- gboolean _bool=TRUE;
- debug_log("rotate value: %d input_format_label: %s output_format_label: %s\n",
- angle, input_format_label, output_format_label);
- if(_mm_check_rotate_format(angle)) {
- if(!(_mm_check_rotate_format_label(input_format_label) || _mm_check_rotate_format_label(output_format_label))) {
- debug_error("ERROR- %s | %s Rotate Only IYUV, I420, YV12 format can use vidoeflip ERROR -Rotate", input_format_label, output_format_label);
- _bool = FALSE;
- }
- }
- return _bool;
-}
-
static int
-_mm_push_buffer_into_pipeline(imgp_info_s* pImgp_info, gstreamer_s * pGstreamer_s)
+_mm_push_buffer_into_pipeline(imgp_info_s* pImgp_info, unsigned char *src, gstreamer_s * pGstreamer_s)
{
int ret = MM_ERROR_NONE;
}
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, pImgp_info->src, data_size, 0, data_size, NULL, NULL);
+ GstBuffer* gst_buf = gst_buffer_new_wrapped_full(GST_MEMORY_FLAG_READONLY, src, data_size, 0, data_size, NULL, NULL);
if(gst_buf==NULL) {
debug_error("buffer is NULL\n");
static int
-_mm_imgp_gstcs_processing( gstreamer_s* pGstreamer_s, 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 = MM_ERROR_NONE;
+
+ if(src== NULL || dst == NULL) {
+ debug_error("src || dst is NULL");
+ return MM_ERROR_IMAGE_INVALID_VALUE;
+ }
+
/*create pipeline*/
ret = _mm_create_pipeline(pGstreamer_s);
if(ret != MM_ERROR_NONE) {
debug_error("ERROR - mm_create_pipeline ");
}
-
/* 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_PIPELINE (pipeline)); */
/* gst_bus_add_watch (bus, (GstBusFunc) _mm_on_sink_message, pGstreamer_s); thow to appplicaton */
gst_object_unref(bus);
debug_log("Start mm_push_buffer_into_pipeline");
- ret = _mm_push_buffer_into_pipeline(pImgp_info, pGstreamer_s);
+ ret = _mm_push_buffer_into_pipeline(pImgp_info, src, pGstreamer_s);
if(ret != MM_ERROR_NONE) {
debug_error("ERROR - mm_push_buffer_into_pipeline ");
}
debug_log("End mm_link_pipeline");
/* Conecting to the new-sample signal emited by the appsink*/
- debug_log("Start G_CALLBACK (_mm_sink_preroll)");
- g_signal_connect (pGstreamer_s->appsink, "new-preroll", G_CALLBACK (_mm_sink_preroll), pGstreamer_s);
- debug_log("End G_CALLBACK (mm_sink_preroll)");
+ debug_log("Start G_CALLBACK (_mm_sink_sample)");
+ g_signal_connect (pGstreamer_s->appsink, "new-sample", G_CALLBACK (_mm_sink_sample), pGstreamer_s);
+ debug_log("End G_CALLBACK (_mm_sink_sample)");
/* GST_STATE_PLAYING*/
debug_log("Start GST_STATE_PLAYING");
debug_log("Success gst_element_get_state\n");
- if (ret_state == 0) {
+ if (ret_state == 0) {
debug_error("GST_STATE_CHANGE_FAILURE");
}else {
if(pGstreamer_s->output_buffer != NULL) {
debug_log("Buffer size is different stride:%d elevation: %d\n", pImgp_info->output_stride, pImgp_info->output_elevation);
}
debug_log("pGstreamer_s->output_buffer: 0x%2x\n", pGstreamer_s->output_buffer);
- memcpy( pImgp_info->dst, mapinfo.data, buffer_size);
+ memcpy(dst, mapinfo.data, buffer_size);
gst_buffer_unmap(pGstreamer_s->output_buffer, &mapinfo);
}else {
debug_log("pGstreamer_s->output_buffer is NULL");
}
}
gst_object_unref (pGstreamer_s->pipeline);
- g_free(GST_BUFFER_MALLOCDATA(pGstreamer_s->output_buffer));
pGstreamer_s->output_buffer = NULL;
g_free (pGstreamer_s);
- debug_log("End mm_convert_colorspace \n");
+ debug_log("End gstreamer processing \n");
}
- debug_log("pImgp_info->dst: %p", pImgp_info->dst);
+ debug_log("dst: %p", dst);
return ret;
}
}else if(strcmp(_format_label, "YUYV") == 0) {
setup_image_size_YUYV(width, height); /* width * height *2; */
}else if(strcmp(_format_label, "ARGB8888") == 0) {
- size = width * height *4; debug_log("file_size: %d\n", size);
+ size = width * height *4; debug_log("file_size: %d\n", size);
}else if(strcmp(_format_label, "BGRA8888") == 0) {
size = width * height *4; debug_log("file_size: %d\n", size);
}else if(strcmp(_format_label, "RGBA8888") == 0) {
}
static int
-_mm_imgp_gstcs(imgp_info_s* pImgp_info)
+_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;
return MM_ERROR_IMAGE_INVALID_VALUE;
}
- debug_log("[input] format label : %s width: %d height: %d\t[output] format label: %s width: %d height: %d rotation vaule: %d dst: 0x%2x",
- 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, pImgp_info->dst);
+ if(src== NULL || dst == NULL) {
+ debug_error("src || dst is NULL");
+ return MM_ERROR_IMAGE_INVALID_VALUE;
+ }
+ debug_log("[src %p] [dst %p]", src, dst);
+
+ argc = malloc(sizeof(int));
+ argv = malloc(sizeof(gchar*) * max_argc);
- if(pImgp_info->dst == NULL) {
- debug_error("imgp_info_s->dst is NULL");
+ if (!argc || !argv) {
+ debug_error("argc ||argv is NULL");
+ GSTCS_FREE(input_format);
+ GSTCS_FREE(output_format);
+ if (argc != NULL) {
+ free(argc);
+ }
+ if (argv != NULL) {
+ free(argv);
+ }
+ return MM_ERROR_IMAGE_INVALID_VALUE;
}
- input_format= _mm_set_input_image_format_s_struct(pImgp_info);
- output_format= _mm_set_output_image_format_s_struct(pImgp_info);
+ memset(argv, 0, sizeof(gchar*) * max_argc);
+ debug_log("memset argv");
- pImgp_info->output_stride = output_format->width;
- pImgp_info->output_elevation = output_format->height;
+ /* add initial */
+ *argc = 1;
+ argv[0] = g_strdup( "mmutil_gstcs" );
+ /* check disable registry scan */
+ argv[*argc] = g_strdup("--gst-disable-registry-update");
+ (*argc)++;
+ debug_log("--gst-disable-registry-update");
- debug_log("mm_check_resize_format&&mm_check_rotate_format ");
+ gst_init(argc, &argv);
- if(__mm_check_resize_format(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)
- && __mm_check_rotate_format(pImgp_info->angle, pImgp_info->input_format_label, pImgp_info->output_format_label) ) {
- argc = malloc(sizeof(int));
- argv = malloc(sizeof(gchar*) * max_argc);
+ pGstreamer_s = g_new0 (gstreamer_s, 1);
- if (!argc || !argv) {
- debug_error("argc ||argv is NULL");
- GSTCS_FREE(input_format);
- GSTCS_FREE(output_format);
- if (argc != NULL) {
- free(argc);
- }
- if (argv != NULL) {
- free(argv);
- }
- return MM_ERROR_IMAGE_INVALID_VALUE;
- }
- memset(argv, 0, sizeof(gchar*) * max_argc);
- debug_log("memset argv");
+ GSTCS_FREE(argv);
+ GSTCS_FREE(argc);
- /* add initial */
- *argc = 1;
- argv[0] = g_strdup( "mmutil_gstcs" );
- /* check disable registry scan */
- argv[*argc] = g_strdup("--gst-disable-registry-update");
- (*argc)++;
- debug_log("--gst-disable-registry-update");
+ debug_log("[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);
- gst_init(argc, &argv);
+ input_format= _mm_set_input_image_format_s_struct(pImgp_info);
+ if (input_format == NULL) {
+ debug_error("memory allocation failed");
+ return MM_ERROR_IMAGE_NO_FREE_SPACE;
+ }
+ output_format= _mm_set_output_image_format_s_struct(pImgp_info);
+ if (output_format == NULL) {
+ debug_error("memory allocation failed");
+ GSTCS_FREE(input_format->format_label);
+ GSTCS_FREE(input_format->colorspace);
+ GSTCS_FREE(input_format);
+ return MM_ERROR_IMAGE_NO_FREE_SPACE;
+ }
- pGstreamer_s = g_new0 (gstreamer_s, 1);
+ pImgp_info->output_stride = output_format->width;
+ pImgp_info->output_elevation = output_format->height;
- /* _format_label : I420, RGB888 etc*/
- debug_log("Start mm_convert_colorspace ");
- ret =_mm_imgp_gstcs_processing(pGstreamer_s, 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 */
+ /* _format_label : I420, RGB888 etc*/
+ debug_log("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 */
- if(ret == MM_ERROR_NONE) {
- debug_log("End mm_convert_colorspace [pImgp_info->dst: %p]", pImgp_info->dst);
- }else if (ret != MM_ERROR_NONE) {
- debug_error("ERROR - mm_convert_colorspace");
- }
- } else {
- debug_error("Error - Check your input / ouput image input_format_label: %s src_width: %d src_height: %d output_format_label: %s output_stride: %d output_elevation: %d angle: %d ",
- pImgp_info->input_format_label, pImgp_info->src_width, pImgp_info->src_height, pImgp_info->output_format_label, pImgp_info->output_stride, pImgp_info->output_elevation, pImgp_info->angle);
- ret = MM_ERROR_IMAGE_INVALID_VALUE;
+ if(ret == MM_ERROR_NONE) {
+ debug_log("End _mm_imgp_gstcs_processing [dst: %p]", dst);
+ }else if (ret != MM_ERROR_NONE) {
+ debug_error("ERROR - _mm_imgp_gstcs_processing");
}
- GSTCS_FREE(argv);
- GSTCS_FREE(argc)
-
GSTCS_FREE(input_format->format_label);
GSTCS_FREE(input_format->colorspace);
GSTCS_FREE(input_format);
}
int
-mm_imgp(imgp_info_s* pImgp_info, imgp_type_e _imgp_type)
+mm_imgp(imgp_info_s* pImgp_info, unsigned char *src, unsigned char *dst, imgp_type_e _imgp_type)
{
if (pImgp_info == NULL) {
debug_error("input vaule is error");
}
- return _mm_imgp_gstcs(pImgp_info);
+ return _mm_imgp_gstcs(pImgp_info, src, dst);
}