surface: use unscaled overlay rectangle for blending.

This commit is contained in:
Gwenole Beauchesne 2011-12-12 18:27:14 +01:00
parent 010f94b85d
commit b014567502

View file

@ -836,27 +836,43 @@ gst_vaapi_surface_update_composition(
for (n = 0; n < nb_rectangles; ++n) { for (n = 0; n < nb_rectangles; ++n) {
GstBuffer *buf; GstBuffer *buf;
GstVideoOverlayRectangle *rect; GstVideoOverlayRectangle *rect;
guint stride; guint width, height, stride;
GstVaapiImageFormat format;
GstVaapiImage *subtitle_image; GstVaapiImage *subtitle_image;
GstVaapiRectangle sub_rect; GstVaapiRectangle sub_rect;
GstVaapiSubpicture *subpicture; GstVaapiSubpicture *subpicture;
GstVaapiImageRaw raw_image;
rect = gst_video_overlay_composition_get_rectangle (composition, n); rect = gst_video_overlay_composition_get_rectangle (composition, n);
buf = gst_video_overlay_rectangle_get_pixels_argb (rect, buf = gst_video_overlay_rectangle_get_pixels_unscaled_argb (rect,
&stride, GST_VIDEO_OVERLAY_FORMAT_FLAG_NONE); &width, &height, &stride, GST_VIDEO_OVERLAY_FORMAT_FLAG_NONE);
gst_video_overlay_rectangle_get_render_rectangle (rect, /* XXX: use gst_vaapi_image_format_from_video() */
(gint *)&sub_rect.x, (gint *)&sub_rect.y, #if G_BYTE_ORDER == G_LITTLE_ENDIAN
&sub_rect.width, &sub_rect.height); format = GST_VAAPI_IMAGE_BGRA;
subtitle_image = gst_vaapi_image_new (display, #else
GST_VAAPI_IMAGE_RGBA, sub_rect.width, sub_rect.height); format = GST_VAAPI_IMAGE_ARGB;
#endif
subtitle_image = gst_vaapi_image_new (display, format, width, height);
if (!subtitle_image)
return FALSE;
if (!gst_vaapi_image_update_from_buffer (subtitle_image, buf, &sub_rect)) { raw_image.format = format;
raw_image.width = width;
raw_image.height = height;
raw_image.num_planes = 1;
raw_image.pixels[0] = GST_BUFFER_DATA(buf);
raw_image.stride[0] = stride;
if (!gst_vaapi_image_update_from_raw (subtitle_image, &raw_image, NULL)) {
GST_WARNING ("could not update VA image with subtitle data"); GST_WARNING ("could not update VA image with subtitle data");
g_object_unref (subtitle_image); g_object_unref (subtitle_image);
return FALSE; return FALSE;
} }
gst_video_overlay_rectangle_get_render_rectangle (rect,
(gint *)&sub_rect.x, (gint *)&sub_rect.y,
&sub_rect.width, &sub_rect.height);
subpicture = gst_vaapi_subpicture_new (subtitle_image); subpicture = gst_vaapi_subpicture_new (subtitle_image);
g_object_unref (subtitle_image); g_object_unref (subtitle_image);