Change to allocate dstination buffer memory here 42/169542/2
authorhj kim <backto.kim@samsung.com>
Wed, 7 Feb 2018 09:00:03 +0000 (18:00 +0900)
committerhj kim <backto.kim@samsung.com>
Thu, 8 Feb 2018 05:13:33 +0000 (14:13 +0900)
Change-Id: I3fff406d3c8613c4233351ccf1408148d54fe09a

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

index 4b44fd1..98350c0 100755 (executable)
@@ -120,7 +120,7 @@ typedef struct _imgp_info_s {
  *             else if  the resule is 0, then you can use output_image pointer(char** value)
 */
 
-int mm_imgp(imgp_info_s* pImgp_info, unsigned char *src, unsigned char *dst, imgp_type_e _imgp_type_e);
+int mm_imgp(imgp_info_s* pImgp_info, unsigned char *src, unsigned char **dst, imgp_type_e _imgp_type_e);
 
 #ifdef __cplusplus__
 };
index 1a9d7f7..fe3c7b3 100755 (executable)
@@ -617,7 +617,7 @@ _mm_push_buffer_into_pipeline_new(image_format_s *input_format, image_format_s *
 }
 
 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;
@@ -714,7 +714,16 @@ _mm_imgp_gstcs_processing(gstreamer_s* pGstreamer_s, unsigned char *src, unsigne
                                return GSTCS_ERROR_INVALID_OPERATION;
                        }
                        gstcs_debug("pGstreamer_s->output_buffer: %p\n", pGstreamer_s->output_buffer);
-                       memcpy(dst, mapinfo.data, buffer_size);
+                       *dst = calloc(1, buffer_size);
+                       if (*dst == NULL) {
+                               gstcs_error("ERROR - calloc ");
+                               gst_buffer_unref(pGstreamer_s->output_buffer);
+                               gst_object_unref(pGstreamer_s->pipeline);
+                               pGstreamer_s->output_buffer = NULL;
+                               return GSTCS_ERROR_INVALID_OPERATION;
+                       }
+
+                       memcpy(*dst, mapinfo.data, buffer_size);
                        pImgp_info->buffer_size = buffer_size;
                        gst_buffer_unmap(pGstreamer_s->output_buffer, &mapinfo);
                } else {
@@ -727,7 +736,7 @@ _mm_imgp_gstcs_processing(gstreamer_s* pGstreamer_s, unsigned char *src, unsigne
        pGstreamer_s->output_buffer = NULL;
 
        gstcs_debug("End gstreamer processing");
-       gstcs_debug("dst: %p", dst);
+       gstcs_debug("dst: %p", *dst);
        return ret;
 }
 
@@ -866,7 +875,7 @@ static int _gstcs_init(gstreamer_s** gstreamer)
        return ret;
 }
 
-static int _mm_imgp_gstcs(imgp_info_s* pImgp_info, unsigned char *src, unsigned char *dst)
+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;
@@ -914,7 +923,7 @@ static int _mm_imgp_gstcs(imgp_info_s* pImgp_info, unsigned char *src, unsigned
        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)
-               gstcs_debug("End _mm_imgp_gstcs_processing [dst: %p]", dst);
+               gstcs_debug("End _mm_imgp_gstcs_processing [dst: %p]", *dst);
        else if (ret != GSTCS_ERROR_NONE)
                gstcs_error("ERROR - _mm_imgp_gstcs_processing");
 
@@ -930,7 +939,7 @@ static int _mm_imgp_gstcs(imgp_info_s* pImgp_info, unsigned char *src, unsigned
        return ret;
 }
 
-int mm_imgp(imgp_info_s* pImgp_info, unsigned char *src, unsigned char *dst, imgp_type_e _imgp_type)
+int mm_imgp(imgp_info_s* pImgp_info, unsigned char *src, unsigned char **dst, imgp_type_e _imgp_type)
 {
        if (pImgp_info == NULL) {
                gstcs_error("Error: input vaule is NULL");
index 1eee8a2..e961ffa 100755 (executable)
@@ -1,7 +1,7 @@
 #sbs-git:slp/pkgs/l/libmm-imgp-gstcs libmm-imgp-gstcs 0.1 62b62e6d483557fc5750d1b4986e9a98323f1194
 Name:       libmm-imgp-gstcs
 Summary:    Multimedia Framework Utility Library
-Version:    0.17
+Version:    0.18
 Release:    16
 Group:      System/Libraries
 License:    Apache-2.0