mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-30 13:41:48 +00:00
display: add support for rotation modes.
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
This commit is contained in:
parent
a192f40ed9
commit
c899947e17
7 changed files with 146 additions and 0 deletions
|
@ -1415,3 +1415,54 @@ gst_vaapi_display_set_render_mode(
|
||||||
return FALSE;
|
return FALSE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_vaapi_display_get_rotation:
|
||||||
|
* @display: a #GstVaapiDisplay
|
||||||
|
*
|
||||||
|
* Returns the current VA @display rotation angle. If the VA driver
|
||||||
|
* does not support "rotation" display attribute, then the display is
|
||||||
|
* assumed to be un-rotated.
|
||||||
|
*
|
||||||
|
* Return value: the current #GstVaapiRotation value
|
||||||
|
*/
|
||||||
|
GstVaapiRotation
|
||||||
|
gst_vaapi_display_get_rotation(GstVaapiDisplay *display)
|
||||||
|
{
|
||||||
|
gint value;
|
||||||
|
|
||||||
|
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), GST_VAAPI_ROTATION_0);
|
||||||
|
|
||||||
|
if (!get_attribute(display, VADisplayAttribRotation, &value))
|
||||||
|
value = VA_ROTATION_NONE;
|
||||||
|
return to_GstVaapiRotation(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_vaapi_display_set_rotation:
|
||||||
|
* @display: a #GstVaapiDisplay
|
||||||
|
* @rotation: the #GstVaapiRotation value to set
|
||||||
|
*
|
||||||
|
* Sets the VA @display rotation angle to the supplied @rotation
|
||||||
|
* value. This function returns %FALSE if the rotation angle could not
|
||||||
|
* be set, e.g. the VA driver does not allow to change the display
|
||||||
|
* rotation angle.
|
||||||
|
*
|
||||||
|
* Return value: %TRUE if VA @display rotation angle could be changed
|
||||||
|
* to the requested value
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
gst_vaapi_display_set_rotation(
|
||||||
|
GstVaapiDisplay *display,
|
||||||
|
GstVaapiRotation rotation
|
||||||
|
)
|
||||||
|
{
|
||||||
|
guint value;
|
||||||
|
|
||||||
|
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), FALSE);
|
||||||
|
|
||||||
|
value = from_GstVaapiRotation(rotation);
|
||||||
|
if (!set_attribute(display, VADisplayAttribRotation, value))
|
||||||
|
return FALSE;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
|
@ -234,6 +234,15 @@ gst_vaapi_display_set_render_mode(
|
||||||
GstVaapiRenderMode mode
|
GstVaapiRenderMode mode
|
||||||
);
|
);
|
||||||
|
|
||||||
|
GstVaapiRotation
|
||||||
|
gst_vaapi_display_get_rotation(GstVaapiDisplay *display);
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gst_vaapi_display_set_rotation(
|
||||||
|
GstVaapiDisplay *display,
|
||||||
|
GstVaapiRotation rotation
|
||||||
|
);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* GST_VAAPI_DISPLAY_H */
|
#endif /* GST_VAAPI_DISPLAY_H */
|
||||||
|
|
|
@ -135,6 +135,21 @@ enum _GstVaapiRenderMode {
|
||||||
GST_VAAPI_RENDER_MODE_TEXTURE
|
GST_VAAPI_RENDER_MODE_TEXTURE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GstVaapiRotation:
|
||||||
|
* @GST_VAAPI_ROTATION_0: the VA display is not rotated.
|
||||||
|
* @GST_VAAPI_ROTATION_90: the VA display is rotated by 90°, clockwise.
|
||||||
|
* @GST_VAAPI_ROTATION_180: the VA display is rotated by 180°, clockwise.
|
||||||
|
* @GST_VAAPI_ROTATION_270: the VA display is rotated by 270°, clockwise.
|
||||||
|
*/
|
||||||
|
typedef enum _GstVaapiRotation GstVaapiRotation;
|
||||||
|
enum _GstVaapiRotation {
|
||||||
|
GST_VAAPI_ROTATION_0 = 0,
|
||||||
|
GST_VAAPI_ROTATION_90 = 90,
|
||||||
|
GST_VAAPI_ROTATION_180 = 180,
|
||||||
|
GST_VAAPI_ROTATION_270 = 270,
|
||||||
|
};
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* GST_VAAPI_TYPES_H */
|
#endif /* GST_VAAPI_TYPES_H */
|
||||||
|
|
|
@ -273,3 +273,31 @@ to_GstVaapiSurfaceStatus(guint va_flags)
|
||||||
#endif
|
#endif
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Translate GstVaapiRotation value to VA-API rotation value */
|
||||||
|
guint
|
||||||
|
from_GstVaapiRotation(guint value)
|
||||||
|
{
|
||||||
|
switch (value) {
|
||||||
|
case GST_VAAPI_ROTATION_0: return VA_ROTATION_NONE;
|
||||||
|
case GST_VAAPI_ROTATION_90: return VA_ROTATION_90;
|
||||||
|
case GST_VAAPI_ROTATION_180: return VA_ROTATION_180;
|
||||||
|
case GST_VAAPI_ROTATION_270: return VA_ROTATION_270;
|
||||||
|
}
|
||||||
|
GST_ERROR("unsupported GstVaapiRotation value %d", value);
|
||||||
|
return VA_ROTATION_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Translate VA-API rotation value to GstVaapiRotation value */
|
||||||
|
guint
|
||||||
|
to_GstVaapiRotation(guint value)
|
||||||
|
{
|
||||||
|
switch (value) {
|
||||||
|
case VA_ROTATION_NONE: return GST_VAAPI_ROTATION_0;
|
||||||
|
case VA_ROTATION_90: return GST_VAAPI_ROTATION_90;
|
||||||
|
case VA_ROTATION_180: return GST_VAAPI_ROTATION_180;
|
||||||
|
case VA_ROTATION_270: return GST_VAAPI_ROTATION_270;
|
||||||
|
}
|
||||||
|
GST_ERROR("unsupported VA-API rotation value %d", value);
|
||||||
|
return GST_VAAPI_ROTATION_0;
|
||||||
|
}
|
||||||
|
|
|
@ -81,4 +81,12 @@ G_GNUC_INTERNAL
|
||||||
guint
|
guint
|
||||||
to_GstVaapiSurfaceStatus(guint va_flags);
|
to_GstVaapiSurfaceStatus(guint va_flags);
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
guint
|
||||||
|
from_GstVaapiRotation(guint value);
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
guint
|
||||||
|
to_GstVaapiRotation(guint value);
|
||||||
|
|
||||||
#endif /* GST_VAAPI_UTILS_H */
|
#endif /* GST_VAAPI_UTILS_H */
|
||||||
|
|
|
@ -185,3 +185,26 @@ gst_vaapi_render_mode_get_type(void)
|
||||||
}
|
}
|
||||||
return render_mode_type;
|
return render_mode_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --- GstVaapiRotation --- */
|
||||||
|
|
||||||
|
GType
|
||||||
|
gst_vaapi_rotation_get_type(void)
|
||||||
|
{
|
||||||
|
static GType g_type = 0;
|
||||||
|
|
||||||
|
static const GEnumValue rotation_values[] = {
|
||||||
|
{ GST_VAAPI_ROTATION_0,
|
||||||
|
"Unrotated mode", "0" },
|
||||||
|
{ GST_VAAPI_ROTATION_90,
|
||||||
|
"Rotated by 90°, clockwise", "90" },
|
||||||
|
{ GST_VAAPI_ROTATION_180,
|
||||||
|
"Rotated by 180°, clockwise", "180" },
|
||||||
|
{ GST_VAAPI_ROTATION_270,
|
||||||
|
"Rotated by 270°, clockwise", "270" },
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!g_type)
|
||||||
|
g_type = g_enum_register_static("GstVaapiRotation", rotation_values);
|
||||||
|
return g_type;
|
||||||
|
}
|
||||||
|
|
|
@ -54,6 +54,15 @@ G_BEGIN_DECLS
|
||||||
*/
|
*/
|
||||||
#define GST_VAAPI_TYPE_RENDER_MODE gst_vaapi_render_mode_get_type()
|
#define GST_VAAPI_TYPE_RENDER_MODE gst_vaapi_render_mode_get_type()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GST_VAAPI_TYPE_ROTATION:
|
||||||
|
*
|
||||||
|
* A type that represents the VA display rotation.
|
||||||
|
*
|
||||||
|
* Return value: the #GType of GstVaapiRotation
|
||||||
|
*/
|
||||||
|
#define GST_VAAPI_TYPE_ROTATION gst_vaapi_rotation_get_type()
|
||||||
|
|
||||||
GType
|
GType
|
||||||
gst_vaapi_id_get_type(void) G_GNUC_CONST;
|
gst_vaapi_id_get_type(void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
@ -66,6 +75,9 @@ gst_vaapi_value_set_id(GValue *value, GstVaapiID id);
|
||||||
GType
|
GType
|
||||||
gst_vaapi_render_mode_get_type(void) G_GNUC_CONST;
|
gst_vaapi_render_mode_get_type(void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
GType
|
||||||
|
gst_vaapi_rotation_get_type(void) G_GNUC_CONST;
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* GST_VAAPI_VALUE_H */
|
#endif /* GST_VAAPI_VALUE_H */
|
||||||
|
|
Loading…
Reference in a new issue