PROP_USE_GLX,
PROP_USE_REFLECTION,
PROP_ROTATION,
+ PROP_FORCE_ASPECT_RATIO,
};
#define DEFAULT_DISPLAY_TYPE GST_VAAPI_DISPLAY_TYPE_ANY
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(
{
GstVaapiSink * const sink = GST_VAAPISINK(base_sink);
- if (!gst_vaapisink_ensure_display(sink))
- return FALSE;
-
- sink->uploader = gst_vaapi_uploader_new(sink->display);
- if (!sink->uploader)
- return FALSE;
- return TRUE;
+ return gst_vaapisink_ensure_uploader(sink);
}
static gboolean
static inline GstCaps *
gst_vaapisink_get_caps(GstBaseSink *base_sink, GstCaps *filter)
{
- return gst_vaapisink_get_caps_impl(base_sink);
+ GstCaps *caps, *out_caps;
+
+ caps = gst_vaapisink_get_caps_impl(base_sink);
+ if (caps && filter) {
+ out_caps = gst_caps_intersect_full(caps, filter,
+ GST_CAPS_INTERSECT_FIRST);
+ gst_caps_unref(caps);
+ }
+ else
+ out_caps = caps;
+ return out_caps;
}
#else
#define gst_vaapisink_get_caps gst_vaapisink_get_caps_impl
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;
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;
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
sink->use_reflection = FALSE;
sink->use_overlay = FALSE;
sink->use_rotation = FALSE;
+ sink->keep_aspect = TRUE;
}