subpicture: use gst_video_overlay_rectangle_get_pixels_unscaled_raw().

Use newer gst_video_overlay_rectangle_get_pixels_unscaled_raw() helper
function with GStreamer 0.10 compatible semantics, or that tries to
approach the current meaning. Basically, this is also just about moving
the helper to gstcompat.h.
This commit is contained in:
Gwenole Beauchesne 2013-03-20 18:25:05 +01:00
parent c756766805
commit 0ad846e68d
3 changed files with 31 additions and 22 deletions

View file

@ -27,9 +27,27 @@
/* GstVideoOverlayComposition */
#include <gst/video/video-overlay-composition.h>
#undef gst_video_overlay_rectangle_get_pixels_unscaled_raw
#define gst_video_overlay_rectangle_get_pixels_unscaled_raw(rect, flags) \
gst_compat_video_overlay_rectangle_get_pixels_unscaled_raw(rect, flags)
#ifndef HAVE_GST_VIDEO_OVERLAY_HWCAPS
#define gst_video_overlay_rectangle_get_flags(rect) (0)
#define gst_video_overlay_rectangle_get_global_alpha(rect) (1.0f)
#endif
static inline GstBuffer *
gst_compat_video_overlay_rectangle_get_pixels_unscaled_raw(
GstVideoOverlayRectangle *rect, GstVideoOverlayFormatFlags flags)
{
guint width, height, stride;
/* Try to retrieve the original buffer that was passed to
gst_video_overlay_rectangle_new_argb(). This will only work if
there was no previous user that required pixels with non native
alpha type */
return gst_video_overlay_rectangle_get_pixels_unscaled_argb(rect,
&width, &height, &stride, flags);
}
#endif /* GST_COMPAT_H */

View file

@ -106,21 +106,6 @@ gst_video_overlay_rectangle_replace(GstVideoOverlayRectangle **old_rect_ptr,
GST_MINI_OBJECT_CAST(new_rect));
}
static inline GstBuffer *
gst_video_overlay_rectangle_get_pixels_raw(GstVideoOverlayRectangle *rect)
{
guint width, height, stride, flags;
flags = gst_video_overlay_rectangle_get_flags(rect);
/* Try to retrieve the original buffer that was passed to
gst_video_overlay_rectangle_new_argb(). This will only work if
there was no previous user that required pixels with non native
alpha type */
return gst_video_overlay_rectangle_get_pixels_unscaled_argb(rect,
&width, &height, &stride, flags);
}
#define overlay_rectangle_ref(overlay) \
gst_vaapi_mini_object_ref(GST_VAAPI_MINI_OBJECT(overlay))
@ -156,7 +141,7 @@ overlay_rectangle_new(GstVideoOverlayRectangle *rect, GstVaapiContext *context,
{
GstVaapiOverlayRectangle *overlay;
GstVaapiRectangle *render_rect;
guint width, height;
guint width, height, flags;
gint x, y;
overlay = (GstVaapiOverlayRectangle *)
@ -169,8 +154,9 @@ overlay_rectangle_new(GstVideoOverlayRectangle *rect, GstVaapiContext *context,
overlay->layer_id = layer_id;
overlay->rect = gst_video_overlay_rectangle_ref(rect);
flags = gst_video_overlay_rectangle_get_flags(rect);
gst_buffer_replace(&overlay->rect_buffer,
gst_video_overlay_rectangle_get_pixels_raw(rect));
gst_video_overlay_rectangle_get_pixels_unscaled_raw(rect, flags));
if (!overlay->rect_buffer)
goto error;
@ -253,7 +239,7 @@ static gboolean
overlay_rectangle_changed_pixels(GstVaapiOverlayRectangle *overlay,
GstVideoOverlayRectangle *rect)
{
guint width, height, stride, flags;
guint flags;
GstBuffer *buffer;
if (overlay->seq_num == gst_video_overlay_rectangle_get_seqnum(rect))
@ -262,9 +248,12 @@ overlay_rectangle_changed_pixels(GstVaapiOverlayRectangle *overlay,
flags = to_GstVideoOverlayFormatFlags(
gst_vaapi_subpicture_get_flags(overlay->subpicture));
buffer = gst_video_overlay_rectangle_get_pixels_unscaled_argb(rect,
&width, &height, &stride, flags);
return GST_BUFFER_DATA(overlay->rect_buffer) != GST_BUFFER_DATA(buffer);
buffer = gst_video_overlay_rectangle_get_pixels_unscaled_raw(rect, flags);
if (!buffer)
return FALSE;
if (GST_BUFFER_DATA(overlay->rect_buffer) != GST_BUFFER_DATA(buffer))
return FALSE;
return TRUE;
}
static gboolean

View file

@ -300,6 +300,7 @@ gst_vaapi_subpicture_new_from_overlay_rectangle(
GstVaapiImage *image;
GstVaapiImageRaw raw_image;
GstBuffer *buffer;
guint8 *data;
gfloat global_alpha;
guint width, height, stride;
guint hw_flags, flags;
@ -322,6 +323,7 @@ gst_vaapi_subpicture_new_from_overlay_rectangle(
&width, &height, &stride, to_GstVideoOverlayFormatFlags(flags));
if (!buffer)
return NULL;
data = GST_BUFFER_DATA(buffer);
image = gst_vaapi_image_new(display, format, width, height);
if (!image)
@ -331,7 +333,7 @@ gst_vaapi_subpicture_new_from_overlay_rectangle(
raw_image.width = width;
raw_image.height = height;
raw_image.num_planes = 1;
raw_image.pixels[0] = GST_BUFFER_DATA(buffer);
raw_image.pixels[0] = data;
raw_image.stride[0] = stride;
if (!gst_vaapi_image_update_from_raw(image, &raw_image, NULL)) {
GST_WARNING("could not update VA image with subtitle data");