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.
This commit is contained in:
parent
01b6f0b353
commit
1db63972f0
@ -1,3 +1,9 @@
|
|||||||
|
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>
|
2007-05-12 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
* gst-libs/gst/rtp/gstbasertpdepayload.c:
|
* gst-libs/gst/rtp/gstbasertpdepayload.c:
|
||||||
|
@ -543,6 +543,8 @@ gst_xvimagesink_xvimage_new (GstXvImageSink * xvimagesink, GstCaps * caps)
|
|||||||
|
|
||||||
#ifdef HAVE_XSHM
|
#ifdef HAVE_XSHM
|
||||||
if (xvimagesink->xcontext->use_xshm) {
|
if (xvimagesink->xcontext->use_xshm) {
|
||||||
|
int expected_size;
|
||||||
|
|
||||||
xvimage->xvimage = XvShmCreateImage (xvimagesink->xcontext->disp,
|
xvimage->xvimage = XvShmCreateImage (xvimagesink->xcontext->disp,
|
||||||
xvimagesink->xcontext->xv_port_id,
|
xvimagesink->xcontext->xv_port_id,
|
||||||
xvimage->im_format, NULL,
|
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,
|
GST_LOG_OBJECT (xvimagesink, "XShm image size is %" G_GSIZE_FORMAT,
|
||||||
xvimage->size);
|
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,
|
xvimage->SHMInfo.shmid = shmget (IPC_PRIVATE, xvimage->size,
|
||||||
IPC_CREAT | 0777);
|
IPC_CREAT | 0777);
|
||||||
if (xvimage->SHMInfo.shmid == -1) {
|
if (xvimage->SHMInfo.shmid == -1) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user