summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wtaymans@redhat.com>2015-03-04 11:21:33 (GMT)
committerWim Taymans <wtaymans@redhat.com>2015-03-04 11:29:45 (GMT)
commite0a192d3dde09e52e24f0e91d2b7eddd135a04ed (patch)
tree5ccac8dcc48043f0ce7b72c113c3e3c02db9d501
parentace35b78ee81311983fc3f87a2480d188b297045 (diff)
downloadgst-plugins-base-e0a192d3dde09e52e24f0e91d2b7eddd135a04ed.tar.gz
gst-plugins-base-e0a192d3dde09e52e24f0e91d2b7eddd135a04ed.tar.xz
video-converter: don't reuse the input line when adding borders
When we need to add borders, we need a writable input line, so don't reuse the source memory directly. Fixes https://bugzilla.gnome.org/show_bug.cgi?id=745207
-rw-r--r--gst-libs/gst/video/video-converter.c3
-rw-r--r--tests/check/libs/video.c42
2 files changed, 44 insertions, 1 deletions
diff --git a/gst-libs/gst/video/video-converter.c b/gst-libs/gst/video/video-converter.c
index d099f13..68acdae 100644
--- a/gst-libs/gst/video/video-converter.c
+++ b/gst-libs/gst/video/video-converter.c
@@ -1754,7 +1754,8 @@ setup_allocators (GstVideoConverter * convert)
setup_border_alloc (convert, user_data);
notify = (GDestroyNotify) converter_alloc_free;
alloc_line = get_border_temp_line;
- alloc_writable = FALSE;
+ /* when we add a border, we need to write */
+ alloc_writable = convert->borderline != NULL;
}
/* now walk backwards, we try to write into the dest lines directly
diff --git a/tests/check/libs/video.c b/tests/check/libs/video.c
index 4ffa1c6..ef648b8 100644
--- a/tests/check/libs/video.c
+++ b/tests/check/libs/video.c
@@ -2251,6 +2251,47 @@ GST_END_TEST;
#undef WIDTH
#undef HEIGHT
+GST_START_TEST (test_video_convert)
+{
+ GstVideoInfo ininfo, outinfo;
+ GstVideoFrame inframe, outframe;
+ GstBuffer *inbuffer, *outbuffer;
+ GstVideoConverter *convert;
+
+ gst_video_info_set_format (&ininfo, GST_VIDEO_FORMAT_ARGB, 320, 240);
+ inbuffer = gst_buffer_new_and_alloc (ininfo.size);
+ gst_buffer_memset (inbuffer, 0, 0, -1);
+ gst_video_frame_map (&inframe, &ininfo, inbuffer, GST_MAP_READ);
+
+ gst_video_info_set_format (&outinfo, GST_VIDEO_FORMAT_BGRx, 400, 300);
+ outbuffer = gst_buffer_new_and_alloc (outinfo.size);
+ gst_video_frame_map (&outframe, &outinfo, outbuffer, GST_MAP_WRITE);
+
+ convert = gst_video_converter_new (&ininfo, &outinfo,
+ gst_structure_new ("options",
+ GST_VIDEO_CONVERTER_OPT_RESAMPLER_METHOD,
+ GST_TYPE_VIDEO_RESAMPLER_METHOD, 3,
+ GST_VIDEO_CONVERTER_OPT_SRC_X, G_TYPE_INT, 10,
+ GST_VIDEO_CONVERTER_OPT_SRC_Y, G_TYPE_INT, 0,
+ GST_VIDEO_CONVERTER_OPT_SRC_WIDTH, G_TYPE_INT, 300,
+ GST_VIDEO_CONVERTER_OPT_SRC_HEIGHT, G_TYPE_INT, 220,
+ GST_VIDEO_CONVERTER_OPT_DEST_X, G_TYPE_INT, 80,
+ GST_VIDEO_CONVERTER_OPT_DEST_Y, G_TYPE_INT, 60,
+ GST_VIDEO_CONVERTER_OPT_DEST_WIDTH, G_TYPE_INT, 300,
+ GST_VIDEO_CONVERTER_OPT_DEST_HEIGHT, G_TYPE_INT, 220, NULL));
+
+ gst_video_converter_frame (convert, &inframe, &outframe);
+ gst_video_converter_free (convert);
+
+ gst_video_frame_unmap (&outframe);
+ gst_buffer_unref (outbuffer);
+ gst_video_frame_unmap (&inframe);
+ gst_buffer_unref (inbuffer);
+
+}
+
+GST_END_TEST;
+
GST_START_TEST (test_video_transfer)
{
gint i, j;
@@ -2527,6 +2568,7 @@ video_suite (void)
tcase_add_test (tc_chain, test_video_scaler);
tcase_add_test (tc_chain, test_video_color_convert);
tcase_add_test (tc_chain, test_video_size_convert);
+ tcase_add_test (tc_chain, test_video_convert);
tcase_add_test (tc_chain, test_video_transfer);
tcase_add_test (tc_chain, test_overlay_blend);
tcase_add_test (tc_chain, test_video_center_rect);