mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-24 08:08:22 +00:00
vaapisink: allow scaling to ignore aspect ratio.
Other GStreamer sinks, like xvimagesink, have a force-aspect-ratio property, which allows you to say that you don't want the sink to respect aspect ratio. Add the same property to vaapisink. http://lists.freedesktop.org/archives/libva/2012-September/001298.html Signed-off-by: Simon Farnsworth <simon.farnsworth at onelan.co.uk>
This commit is contained in:
parent
e5a50af2ae
commit
0ef5979d77
2 changed files with 37 additions and 0 deletions
|
@ -158,6 +158,7 @@ enum {
|
|||
PROP_USE_GLX,
|
||||
PROP_USE_REFLECTION,
|
||||
PROP_ROTATION,
|
||||
PROP_FORCE_ASPECT_RATIO,
|
||||
};
|
||||
|
||||
#define DEFAULT_DISPLAY_TYPE GST_VAAPI_DISPLAY_TYPE_ANY
|
||||
|
@ -381,6 +382,19 @@ gst_vaapisink_ensure_render_rect(GstVaapiSink *sink, guint width, guint height)
|
|||
if (!sink->caps)
|
||||
return TRUE;
|
||||
|
||||
if (!sink->keep_aspect) {
|
||||
display_rect->width = width;
|
||||
display_rect->height = height;
|
||||
display_rect->x = 0;
|
||||
display_rect->y = 0;
|
||||
|
||||
GST_DEBUG("force-aspect-ratio is false; distorting while scaling video");
|
||||
GST_DEBUG("render rect (%d,%d):%ux%u",
|
||||
display_rect->x, display_rect->y,
|
||||
display_rect->width, display_rect->height);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GST_DEBUG("ensure render rect within %ux%u bounds", width, height);
|
||||
|
||||
gst_vaapi_display_get_pixel_aspect_ratio(
|
||||
|
@ -1255,6 +1269,9 @@ gst_vaapisink_set_property(
|
|||
case PROP_ROTATION:
|
||||
sink->rotation_req = g_value_get_enum(value);
|
||||
break;
|
||||
case PROP_FORCE_ASPECT_RATIO:
|
||||
sink->keep_aspect = g_value_get_boolean(value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
|
@ -1290,6 +1307,9 @@ gst_vaapisink_get_property(
|
|||
case PROP_ROTATION:
|
||||
g_value_set_enum(value, sink->rotation);
|
||||
break;
|
||||
case PROP_FORCE_ASPECT_RATIO:
|
||||
g_value_set_boolean(value, sink->keep_aspect);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
|
@ -1401,6 +1421,21 @@ gst_vaapisink_class_init(GstVaapiSinkClass *klass)
|
|||
GST_VAAPI_TYPE_ROTATION,
|
||||
DEFAULT_ROTATION,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* GstVaapiSink:force-aspect-ratio:
|
||||
*
|
||||
* When enabled, scaling respects video aspect ratio; when disabled, the
|
||||
* video is distorted to fit the window.
|
||||
*/
|
||||
g_object_class_install_property
|
||||
(object_class,
|
||||
PROP_FORCE_ASPECT_RATIO,
|
||||
g_param_spec_boolean("force-aspect-ratio",
|
||||
"Force aspect ratio",
|
||||
"When enabled, scaling will respect original aspect ratio",
|
||||
TRUE,
|
||||
G_PARAM_READWRITE));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1426,4 +1461,5 @@ gst_vaapisink_init(GstVaapiSink *sink)
|
|||
sink->use_reflection = FALSE;
|
||||
sink->use_overlay = FALSE;
|
||||
sink->use_rotation = FALSE;
|
||||
sink->keep_aspect = TRUE;
|
||||
}
|
||||
|
|
|
@ -95,6 +95,7 @@ struct _GstVaapiSink {
|
|||
guint use_reflection : 1;
|
||||
guint use_overlay : 1;
|
||||
guint use_rotation : 1;
|
||||
guint keep_aspect : 1;
|
||||
guint use_video_raw : 1;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue