From 0a6001dc6ae7f8346999e028a6ba290c35c5fc7f Mon Sep 17 00:00:00 2001 From: Sebastian Dröge Date: Tue, 16 Dec 2014 15:03:55 +0100 Subject: Revert "video: Fix non-default usage of gst_video_sink_center_rect" This reverts commit 899461d722e45f591eeddf33c405677170d63de4. There seems to be a lot of code out there that does not properly initialize the rectangles and then causes undefined behaviour. Including our video sinks. Let's keep this out of 1.4, fix everything everywhere and keep it in 1.6 --- gst-libs/gst/video/gstvideosink.c | 16 +++++----- tests/check/libs/video.c | 61 --------------------------------------- 2 files changed, 8 insertions(+), 69 deletions(-) diff --git a/gst-libs/gst/video/gstvideosink.c b/gst-libs/gst/video/gstvideosink.c index 26b7df21c..47045933a 100644 --- a/gst-libs/gst/video/gstvideosink.c +++ b/gst-libs/gst/video/gstvideosink.c @@ -87,8 +87,8 @@ gst_video_sink_center_rect (GstVideoRectangle src, GstVideoRectangle dst, if (!scaling) { result->w = MIN (src.w, dst.w); result->h = MIN (src.h, dst.h); - result->x = dst.x + (dst.w - result->w) / 2; - result->y = dst.y + (dst.h - result->h) / 2; + result->x = (dst.w - result->w) / 2; + result->y = (dst.h - result->h) / 2; } else { gdouble src_ratio, dst_ratio; @@ -98,16 +98,16 @@ gst_video_sink_center_rect (GstVideoRectangle src, GstVideoRectangle dst, if (src_ratio > dst_ratio) { result->w = dst.w; result->h = dst.w / src_ratio; - result->x = dst.x; - result->y = dst.y + (dst.h - result->h) / 2; + result->x = 0; + result->y = (dst.h - result->h) / 2; } else if (src_ratio < dst_ratio) { result->w = dst.h * src_ratio; result->h = dst.h; - result->x = dst.x + (dst.w - result->w) / 2; - result->y = dst.y; + result->x = (dst.w - result->w) / 2; + result->y = 0; } else { - result->x = dst.x; - result->y = dst.y; + result->x = 0; + result->y = 0; result->w = dst.w; result->h = dst.h; } diff --git a/tests/check/libs/video.c b/tests/check/libs/video.c index b8e5ba084..d7cac0673 100644 --- a/tests/check/libs/video.c +++ b/tests/check/libs/video.c @@ -1693,66 +1693,6 @@ GST_START_TEST (test_overlay_composition_global_alpha) GST_END_TEST; - -GST_START_TEST (test_video_center_rect) -{ - GstVideoRectangle src, dest, result, expected; - -#define NEW_RECT(x,y,w,h) ((GstVideoRectangle) {x,y,w,h}) -#define CHECK_RECT(res, exp) \ - fail_unless_equals_int(exp.x, res.x);\ - fail_unless_equals_int(exp.y, res.y);\ - fail_unless_equals_int(exp.w, res.w);\ - fail_unless_equals_int(exp.h, res.h); - - /* 1:1 Aspect Ratio */ - src = NEW_RECT (0, 0, 100, 100); - dest = NEW_RECT (0, 0, 100, 100); - expected = NEW_RECT (0, 0, 100, 100); - gst_video_sink_center_rect (src, dest, &result, TRUE); - CHECK_RECT (result, expected); - - src = NEW_RECT (0, 0, 100, 100); - dest = NEW_RECT (0, 0, 50, 50); - expected = NEW_RECT (0, 0, 50, 50); - gst_video_sink_center_rect (src, dest, &result, TRUE); - CHECK_RECT (result, expected); - - src = NEW_RECT (0, 0, 100, 100); - dest = NEW_RECT (50, 50, 100, 100); - expected = NEW_RECT (50, 50, 100, 100); - gst_video_sink_center_rect (src, dest, &result, TRUE); - CHECK_RECT (result, expected); - - /* Aspect ratio scaling (tall) */ - src = NEW_RECT (0, 0, 50, 100); - dest = NEW_RECT (0, 0, 50, 50); - expected = NEW_RECT (12, 0, 25, 50); - gst_video_sink_center_rect (src, dest, &result, TRUE); - CHECK_RECT (result, expected); - - src = NEW_RECT (0, 0, 50, 100); - dest = NEW_RECT (50, 50, 50, 50); - expected = NEW_RECT (62, 50, 25, 50); - gst_video_sink_center_rect (src, dest, &result, TRUE); - CHECK_RECT (result, expected); - - /* Aspect ratio scaling (wide) */ - src = NEW_RECT (0, 0, 100, 50); - dest = NEW_RECT (0, 0, 50, 50); - expected = NEW_RECT (0, 12, 50, 25); - gst_video_sink_center_rect (src, dest, &result, TRUE); - CHECK_RECT (result, expected); - - src = NEW_RECT (0, 0, 100, 50); - dest = NEW_RECT (50, 50, 50, 50); - expected = NEW_RECT (50, 62, 50, 25); - gst_video_sink_center_rect (src, dest, &result, TRUE); - CHECK_RECT (result, expected); -} - -GST_END_TEST; - static Suite * video_suite (void) { @@ -1774,7 +1714,6 @@ video_suite (void) tcase_add_test (tc_chain, test_overlay_composition); tcase_add_test (tc_chain, test_overlay_composition_premultiplied_alpha); tcase_add_test (tc_chain, test_overlay_composition_global_alpha); - tcase_add_test (tc_chain, test_video_center_rect); return s; } -- cgit v1.2.3