Commit 1db63972 authored by David Schleef's avatar David Schleef
Browse files

sys/xvimage/xvimagesink.c: Add some sanity checking for the XVImage size returned by X.

Original commit message from CVS:
* sys/xvimage/xvimagesink.c:
Add some sanity checking for the XVImage size returned by X.
Related to #377400.
parent 01b6f0b3
2007-05-12 David Schleef <ds@schleef.org>
* sys/xvimage/xvimagesink.c:
Add some sanity checking for the XVImage size returned by X.
Related to #377400.
2007-05-12 Wim Taymans <wim@fluendo.com>
 
* gst-libs/gst/rtp/gstbasertpdepayload.c:
......@@ -543,6 +543,8 @@ gst_xvimagesink_xvimage_new (GstXvImageSink * xvimagesink, GstCaps * caps)
#ifdef HAVE_XSHM
if (xvimagesink->xcontext->use_xshm) {
int expected_size;
xvimage->xvimage = XvShmCreateImage (xvimagesink->xcontext->disp,
xvimagesink->xcontext->xv_port_id,
xvimage->im_format, NULL,
......@@ -566,6 +568,31 @@ gst_xvimagesink_xvimage_new (GstXvImageSink * xvimagesink, GstCaps * caps)
GST_LOG_OBJECT (xvimagesink, "XShm image size is %" G_GSIZE_FORMAT,
xvimage->size);
/* calculate the expected size. This is only for sanity checking the
* number we get from X. */
switch (xvimagesink->xcontext->im_format) {
case GST_MAKE_FOURCC ('I', '4', '2', '0'):
expected_size =
GST_ROUND_UP_2 (xvimage->height) * GST_ROUND_UP_4 (xvimage->width);
expected_size +=
GST_ROUND_UP_2 (xvimage->height) * GST_ROUND_UP_8 (xvimage->width) /
2;
break;
case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
expected_size = xvimage->height * GST_ROUND_UP_4 (xvimage->width * 2);
break;
default:
expected_size = 0;
break;
}
if (expected_size != 0 && xvimage->size != expected_size) {
GST_WARNING_OBJECT (xvimagesink,
"unexpected XShm image size (got %" G_GSIZE_FORMAT ", expected %d)",
xvimage->size, expected_size);
}
xvimage->SHMInfo.shmid = shmget (IPC_PRIVATE, xvimage->size,
IPC_CREAT | 0777);
if (xvimage->SHMInfo.shmid == -1) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment