#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)
+
static GstFlowReturn
_mm_sink_sample(GstElement * appsink, gpointer user_data)
|| 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);
+ SAFE_STRCPY(_format_name, __format->format_label, sizeof(_format_name));
} else if (strcmp(__format->format_label, "YUYV") == 0) {
- strncpy(_format_name, "YVYU", sizeof(GST_VIDEO_FORMATS_ALL)-1);
+ SAFE_STRCPY(_format_name, "YVYU", sizeof(_format_name));
}
gstcs_debug("Chosen video format: %s", _format_name);
__format->caps = gst_caps_new_simple("video/x-raw",
|| 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);
+ SAFE_STRCPY(_format_name, __format->format_label, sizeof(_format_name));
} else if (strcmp(__format->format_label, "YUYV") == 0) {
- strncpy(_format_name, "YVYU", sizeof(GST_VIDEO_FORMATS_ALL)-1);
+ SAFE_STRCPY(_format_name, "YVYU", sizeof(_format_name));
}
gstcs_debug("Chosen video format: %s", _format_name);
__format->caps = gst_caps_new_simple("video/x-raw",
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)) {
- strncpy(__format->colorspace, "YUV", IMAGE_FORMAT_LABEL_BUFFER_SIZE-1);
+ SAFE_STRCPY(__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)) {
- strncpy(__format->colorspace, "RGB", IMAGE_FORMAT_LABEL_BUFFER_SIZE-1);
+ SAFE_STRCPY(__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);
+ SAFE_STRCPY(__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);
+ SAFE_STRCPY(__format->colorspace, "BGRX", IMAGE_FORMAT_LABEL_BUFFER_SIZE-1);
} else {
gstcs_error("Check your colorspace format label");
GSTCS_FREE(__format->colorspace);
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));
+ SAFE_STRCPY(__format->format_label, pImgp_info->input_format_label, IMAGE_FORMAT_LABEL_BUFFER_SIZE-1);
gstcs_debug("input_format_label: %s\n", pImgp_info->input_format_label);
_mm_set_image_colorspace(__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));
+ SAFE_STRCPY(__format->format_label, pImgp_info->output_format_label, IMAGE_FORMAT_LABEL_BUFFER_SIZE-1);
_mm_set_image_colorspace(__format);
__format->width = pImgp_info->dst_width;
if (gst_buf == NULL) {
gstcs_error("buffer is NULL\n");
+ GSTCS_FREE(data);
return GSTCS_ERROR_INVALID_PARAMETER;
}