mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 10:11:08 +00:00
video: don't crash when blending onto video formats that unpack to 64 bits per pixel
We only allocate 8 bits per component for our temp buffers, which causes invalid memory accesses if we try to unpack formats that unpack into a format with 16 bits per component such as e.g. v210. We don't support blending onto those yet, so just bail out.
This commit is contained in:
parent
e3bb068392
commit
377c806685
1 changed files with 25 additions and 9 deletions
|
@ -251,7 +251,7 @@ gst_video_blend (GstVideoFrame * dest,
|
||||||
guint8 *tmpdestline = NULL, *tmpsrcline = NULL;
|
guint8 *tmpdestline = NULL, *tmpsrcline = NULL;
|
||||||
gboolean src_premultiplied_alpha, dest_premultiplied_alpha;
|
gboolean src_premultiplied_alpha, dest_premultiplied_alpha;
|
||||||
void (*matrix) (guint8 * tmpline, guint width);
|
void (*matrix) (guint8 * tmpline, guint width);
|
||||||
const GstVideoFormatInfo *sinfo, *dinfo;
|
const GstVideoFormatInfo *sinfo, *dinfo, *dunpackinfo, *sunpackinfo;
|
||||||
|
|
||||||
g_assert (dest != NULL);
|
g_assert (dest != NULL);
|
||||||
g_assert (src != NULL);
|
g_assert (src != NULL);
|
||||||
|
@ -273,9 +273,6 @@ gst_video_blend (GstVideoFrame * dest,
|
||||||
dest_width = GST_VIDEO_FRAME_WIDTH (dest);
|
dest_width = GST_VIDEO_FRAME_WIDTH (dest);
|
||||||
dest_height = GST_VIDEO_FRAME_HEIGHT (dest);
|
dest_height = GST_VIDEO_FRAME_HEIGHT (dest);
|
||||||
|
|
||||||
tmpdestline = g_malloc (sizeof (guint8) * (dest_width + 8) * 4);
|
|
||||||
tmpsrcline = g_malloc (sizeof (guint8) * (dest_width + 8) * 4);
|
|
||||||
|
|
||||||
ensure_debug_category ();
|
ensure_debug_category ();
|
||||||
|
|
||||||
dinfo = gst_video_format_get_info (GST_VIDEO_FRAME_FORMAT (dest));
|
dinfo = gst_video_format_get_info (GST_VIDEO_FRAME_FORMAT (dest));
|
||||||
|
@ -284,6 +281,20 @@ gst_video_blend (GstVideoFrame * dest,
|
||||||
if (!sinfo || !dinfo)
|
if (!sinfo || !dinfo)
|
||||||
goto failed;
|
goto failed;
|
||||||
|
|
||||||
|
dunpackinfo = gst_video_format_get_info (dinfo->unpack_format);
|
||||||
|
sunpackinfo = gst_video_format_get_info (sinfo->unpack_format);
|
||||||
|
|
||||||
|
if (dunpackinfo == NULL || sunpackinfo == NULL)
|
||||||
|
goto failed;
|
||||||
|
|
||||||
|
g_assert (GST_VIDEO_FORMAT_INFO_BITS (sunpackinfo) == 8);
|
||||||
|
|
||||||
|
if (GST_VIDEO_FORMAT_INFO_BITS (dunpackinfo) != 8)
|
||||||
|
goto unpack_format_not_supported;
|
||||||
|
|
||||||
|
tmpdestline = g_malloc (sizeof (guint8) * (dest_width + 8) * 4);
|
||||||
|
tmpsrcline = g_malloc (sizeof (guint8) * (dest_width + 8) * 4);
|
||||||
|
|
||||||
matrix = matrix_identity;
|
matrix = matrix_identity;
|
||||||
if (GST_VIDEO_INFO_IS_RGB (&src->info) != GST_VIDEO_INFO_IS_RGB (&dest->info)) {
|
if (GST_VIDEO_INFO_IS_RGB (&src->info) != GST_VIDEO_INFO_IS_RGB (&dest->info)) {
|
||||||
if (GST_VIDEO_INFO_IS_RGB (&src->info)) {
|
if (GST_VIDEO_INFO_IS_RGB (&src->info)) {
|
||||||
|
@ -390,9 +401,14 @@ gst_video_blend (GstVideoFrame * dest,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
failed:
|
failed:
|
||||||
GST_WARNING ("Could not do the blending");
|
{
|
||||||
g_free (tmpdestline);
|
GST_WARNING ("Could not do the blending");
|
||||||
g_free (tmpsrcline);
|
return FALSE;
|
||||||
|
}
|
||||||
return FALSE;
|
unpack_format_not_supported:
|
||||||
|
{
|
||||||
|
GST_FIXME ("video format %s not supported yet for blending",
|
||||||
|
gst_video_format_to_string (dinfo->unpack_format));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue