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>
This commit is contained in:
Nicolas Dufresne 2021-06-02 11:26:41 -04:00
parent c442c9bd5e
commit a01883013a

View file

@ -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);