mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-11 08:52:39 +00:00
vaapipostproc: add rotation support
Adds vpp rotation support to vaapipostproc. Uses property video-direction. Default is identity (no rotation). Closes #104
This commit is contained in:
parent
e592f6b415
commit
f1aa0cc5e0
4 changed files with 74 additions and 16 deletions
|
@ -1392,7 +1392,7 @@ gst_vaapi_filter_process_unlocked (GstVaapiFilter * filter,
|
||||||
guint i, num_filters = 0;
|
guint i, num_filters = 0;
|
||||||
VAStatus va_status;
|
VAStatus va_status;
|
||||||
VARectangle src_rect, dst_rect;
|
VARectangle src_rect, dst_rect;
|
||||||
guint va_mirror = from_GstVideoOrientationMethod (filter->video_direction);
|
guint va_mirror = 0, va_rotation = 0;
|
||||||
|
|
||||||
if (!ensure_operations (filter))
|
if (!ensure_operations (filter))
|
||||||
return GST_VAAPI_FILTER_STATUS_ERROR_ALLOCATION_FAILED;
|
return GST_VAAPI_FILTER_STATUS_ERROR_ALLOCATION_FAILED;
|
||||||
|
@ -1475,8 +1475,12 @@ gst_vaapi_filter_process_unlocked (GstVaapiFilter * filter,
|
||||||
pipeline_param->filters = filters;
|
pipeline_param->filters = filters;
|
||||||
pipeline_param->num_filters = num_filters;
|
pipeline_param->num_filters = num_filters;
|
||||||
|
|
||||||
|
from_GstVideoOrientationMethod (filter->video_direction, &va_mirror,
|
||||||
|
&va_rotation);
|
||||||
|
|
||||||
#if VA_CHECK_VERSION(1,1,0)
|
#if VA_CHECK_VERSION(1,1,0)
|
||||||
pipeline_param->mirror_state = va_mirror;
|
pipeline_param->mirror_state = va_mirror;
|
||||||
|
pipeline_param->rotation_state = va_rotation;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Reference frames for advanced deinterlacing
|
// Reference frames for advanced deinterlacing
|
||||||
|
@ -1893,21 +1897,39 @@ gst_vaapi_filter_set_video_direction (GstVaapiFilter * filter,
|
||||||
break;
|
break;
|
||||||
case GST_VIDEO_ORIENTATION_HORIZ:
|
case GST_VIDEO_ORIENTATION_HORIZ:
|
||||||
case GST_VIDEO_ORIENTATION_VERT:
|
case GST_VIDEO_ORIENTATION_VERT:
|
||||||
|
case GST_VIDEO_ORIENTATION_90R:
|
||||||
|
case GST_VIDEO_ORIENTATION_180:
|
||||||
|
case GST_VIDEO_ORIENTATION_90L:
|
||||||
|
case GST_VIDEO_ORIENTATION_UL_LR:
|
||||||
|
case GST_VIDEO_ORIENTATION_UR_LL:
|
||||||
{
|
{
|
||||||
#if VA_CHECK_VERSION(1,1,0)
|
#if VA_CHECK_VERSION(1,1,0)
|
||||||
VAProcPipelineCaps pipeline_caps;
|
VAProcPipelineCaps pipeline_caps;
|
||||||
guint va_mirror = from_GstVideoOrientationMethod (method);
|
guint va_mirror = VA_MIRROR_NONE;
|
||||||
|
guint va_rotation = VA_ROTATION_NONE;
|
||||||
|
|
||||||
VAStatus va_status = vaQueryVideoProcPipelineCaps (filter->va_display,
|
VAStatus va_status = vaQueryVideoProcPipelineCaps (filter->va_display,
|
||||||
filter->va_context, NULL, 0, &pipeline_caps);
|
filter->va_context, NULL, 0, &pipeline_caps);
|
||||||
if (!vaapi_check_status (va_status, "vaQueryVideoProcPipelineCaps()"))
|
if (!vaapi_check_status (va_status, "vaQueryVideoProcPipelineCaps()"))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
from_GstVideoOrientationMethod (method, &va_mirror, &va_rotation);
|
||||||
|
|
||||||
|
if (va_mirror != VA_MIRROR_NONE) {
|
||||||
if (!(pipeline_caps.mirror_flags & va_mirror)) {
|
if (!(pipeline_caps.mirror_flags & va_mirror)) {
|
||||||
GST_WARNING ("%s video-direction unsupported",
|
GST_WARNING ("%s video-direction unsupported",
|
||||||
gst_vaapi_get_video_direction_nick (method));
|
gst_vaapi_get_video_direction_nick (method));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (va_rotation != VA_ROTATION_NONE) {
|
||||||
|
if (!(pipeline_caps.rotation_flags & (1 << va_rotation))) {
|
||||||
|
GST_WARNING ("%s video-direction unsupported",
|
||||||
|
gst_vaapi_get_video_direction_nick (method));
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
GST_WARNING ("%s video-direction unsupported",
|
GST_WARNING ("%s video-direction unsupported",
|
||||||
gst_vaapi_get_video_direction_nick (method));
|
gst_vaapi_get_video_direction_nick (method));
|
||||||
|
|
|
@ -821,26 +821,50 @@ to_GstVaapiScaleMethod (guint flags)
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* VPP: translate GstVideoOrientationMethod into VA mirror flags */
|
/* VPP: translate GstVideoOrientationMethod into VA mirror/rotation flags */
|
||||||
guint
|
void
|
||||||
from_GstVideoOrientationMethod (guint value)
|
from_GstVideoOrientationMethod (guint value, guint * va_mirror,
|
||||||
|
guint * va_rotation)
|
||||||
{
|
{
|
||||||
guint va_flags = 0;
|
*va_mirror = 0;
|
||||||
|
*va_rotation = 0;
|
||||||
|
|
||||||
switch (value) {
|
switch (value) {
|
||||||
#if VA_CHECK_VERSION(1,1,0)
|
#if VA_CHECK_VERSION(1,1,0)
|
||||||
case GST_VIDEO_ORIENTATION_IDENTITY:
|
case GST_VIDEO_ORIENTATION_IDENTITY:
|
||||||
va_flags = VA_MIRROR_NONE;
|
*va_mirror = VA_MIRROR_NONE;
|
||||||
|
*va_rotation = VA_ROTATION_NONE;
|
||||||
break;
|
break;
|
||||||
case GST_VIDEO_ORIENTATION_HORIZ:
|
case GST_VIDEO_ORIENTATION_HORIZ:
|
||||||
va_flags = VA_MIRROR_HORIZONTAL;
|
*va_mirror = VA_MIRROR_HORIZONTAL;
|
||||||
|
*va_rotation = VA_ROTATION_NONE;
|
||||||
break;
|
break;
|
||||||
case GST_VIDEO_ORIENTATION_VERT:
|
case GST_VIDEO_ORIENTATION_VERT:
|
||||||
va_flags = VA_MIRROR_VERTICAL;
|
*va_mirror = VA_MIRROR_VERTICAL;
|
||||||
|
*va_rotation = VA_ROTATION_NONE;
|
||||||
|
break;
|
||||||
|
case GST_VIDEO_ORIENTATION_90R:
|
||||||
|
*va_mirror = VA_MIRROR_NONE;
|
||||||
|
*va_rotation = VA_ROTATION_90;
|
||||||
|
break;
|
||||||
|
case GST_VIDEO_ORIENTATION_180:
|
||||||
|
*va_mirror = VA_MIRROR_NONE;
|
||||||
|
*va_rotation = VA_ROTATION_180;
|
||||||
|
break;
|
||||||
|
case GST_VIDEO_ORIENTATION_90L:
|
||||||
|
*va_mirror = VA_MIRROR_NONE;
|
||||||
|
*va_rotation = VA_ROTATION_270;
|
||||||
|
break;
|
||||||
|
case GST_VIDEO_ORIENTATION_UL_LR:
|
||||||
|
*va_mirror = VA_MIRROR_HORIZONTAL;
|
||||||
|
*va_rotation = VA_ROTATION_90;
|
||||||
|
break;
|
||||||
|
case GST_VIDEO_ORIENTATION_UR_LL:
|
||||||
|
*va_mirror = VA_MIRROR_VERTICAL;
|
||||||
|
*va_rotation = VA_ROTATION_90;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return va_flags;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,8 @@ guint
|
||||||
to_GstVaapiScaleMethod (guint flags);
|
to_GstVaapiScaleMethod (guint flags);
|
||||||
|
|
||||||
G_GNUC_INTERNAL
|
G_GNUC_INTERNAL
|
||||||
guint
|
void
|
||||||
from_GstVideoOrientationMethod (guint value);
|
from_GstVideoOrientationMethod (guint value, guint * va_mirror,
|
||||||
|
guint * va_rotation);
|
||||||
|
|
||||||
#endif /* GST_VAAPI_UTILS_H */
|
#endif /* GST_VAAPI_UTILS_H */
|
||||||
|
|
|
@ -177,6 +177,17 @@ _fixate_frame_size (GstVaapiPostproc * postproc, GstVideoInfo * vinfo,
|
||||||
from_w = GST_VIDEO_INFO_WIDTH (vinfo);
|
from_w = GST_VIDEO_INFO_WIDTH (vinfo);
|
||||||
from_h = GST_VIDEO_INFO_HEIGHT (vinfo);
|
from_h = GST_VIDEO_INFO_HEIGHT (vinfo);
|
||||||
|
|
||||||
|
/* compensate for rotation if needed */
|
||||||
|
switch (postproc->video_direction) {
|
||||||
|
case GST_VIDEO_ORIENTATION_90R:
|
||||||
|
case GST_VIDEO_ORIENTATION_90L:
|
||||||
|
case GST_VIDEO_ORIENTATION_UL_LR:
|
||||||
|
case GST_VIDEO_ORIENTATION_UR_LL:
|
||||||
|
G_PRIMITIVE_SWAP (gint, from_w, from_h);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
gst_structure_get_int (outs, "width", &w);
|
gst_structure_get_int (outs, "width", &w);
|
||||||
gst_structure_get_int (outs, "height", &h);
|
gst_structure_get_int (outs, "height", &h);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue