diff options
author | Nicolas Dufresne <nicolas.dufresne@collabora.com> | 2021-06-02 11:26:41 -0400 |
---|---|---|
committer | Nicolas Dufresne <nicolas.dufresne@collabora.com> | 2021-06-02 11:26:41 -0400 |
commit | a01883013a4506844d05659cdd915d69926b8709 (patch) | |
tree | 21c8ed088bd384c54041c57ffeeb89e94e59708d /tests | |
parent | c442c9bd5e16b40cc386577ddffa6e404cd9bebe (diff) | |
download | gstreamer-plugins-bad-a01883013a4506844d05659cdd915d69926b8709.tar.gz |
test: camerabin: Fix buffer size calculation
We were assunming that GStreamer size for RGB (24bit packed) data was width x
height x 3, but GStreamer defaults to specific alignment. Use GstVideoInfo API
in order to obtain the buffer size.
This fixes failure seen when trying to merge: https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/998
which make us negoaite 1x1 instead of 16x16 in this test.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2297>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/check/elements/camerabin.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/tests/check/elements/camerabin.c b/tests/check/elements/camerabin.c index c339cf541..664e71022 100644 --- a/tests/check/elements/camerabin.c +++ b/tests/check/elements/camerabin.c @@ -335,6 +335,7 @@ static GstFlowReturn gst_test_video_src_alloc (GstPushSrc * src, GstBuffer ** buf) { GstTestVideoSrc *self = GST_TEST_VIDEO_SRC (src); + GstVideoInfo vinfo; guint8 *data; gsize data_size; @@ -344,7 +345,10 @@ gst_test_video_src_alloc (GstPushSrc * src, GstBuffer ** buf) self->caps = NULL; } - data_size = self->width * self->height * 3; /* RGB size */ + gst_video_info_set_format (&vinfo, GST_VIDEO_FORMAT_RGB, self->width, + self->height); + + data_size = vinfo.size; data = g_malloc (data_size); *buf = gst_buffer_new_wrapped (data, data_size); |