msdk: vpp : Add force-aspect-ratio property

https://bugzilla.gnome.org/show_bug.cgi?id=793705
This commit is contained in:
Sreerenj Balachandran 2018-03-21 18:17:11 +00:00
parent fb8c536393
commit c0ea4bdafb
3 changed files with 20 additions and 0 deletions

View file

@ -77,6 +77,7 @@ enum
PROP_DETAIL,
PROP_MIRRORING,
PROP_SCALING_MODE,
PROP_FORCE_ASPECT_RATIO,
PROP_N,
};
@ -93,6 +94,7 @@ enum
#define PROP_DETAIL_DEFAULT 0
#define PROP_MIRRORING_DEFAULT MFX_MIRRORING_DISABLED
#define PROP_SCALING_MODE_DEFAULT MFX_SCALING_MODE_DEFAULT
#define PROP_FORCE_ASPECT_RATIO_DEFAULT TRUE
#define gst_msdkvpp_parent_class parent_class
G_DEFINE_TYPE (GstMsdkVPP, gst_msdkvpp, GST_TYPE_BASE_TRANSFORM);
@ -1004,6 +1006,9 @@ gst_msdkvpp_set_property (GObject * object, guint prop_id,
thiz->scaling_mode = g_value_get_enum (value);
thiz->flags |= GST_MSDK_FLAG_SCALING_MODE;
break;
case PROP_FORCE_ASPECT_RATIO:
thiz->keep_aspect = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -1056,6 +1061,9 @@ gst_msdkvpp_get_property (GObject * object, guint prop_id,
case PROP_SCALING_MODE:
g_value_set_enum (value, thiz->scaling_mode);
break;
case PROP_FORCE_ASPECT_RATIO:
g_value_set_boolean (value, thiz->keep_aspect);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -1195,6 +1203,12 @@ gst_msdkvpp_class_init (GstMsdkVPPClass * klass)
"The Scaling mode to use", gst_msdkvpp_scaling_mode_get_type (),
PROP_SCALING_MODE_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
obj_properties[PROP_FORCE_ASPECT_RATIO] =
g_param_spec_boolean ("force-aspect-ratio", "Force Aspect Ratio",
"When enabled, scaling will respect original aspect ratio",
PROP_FORCE_ASPECT_RATIO_DEFAULT,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (gobject_class, PROP_N, obj_properties);
}
@ -1215,6 +1229,7 @@ gst_msdkvpp_init (GstMsdkVPP * thiz)
thiz->detail = PROP_DETAIL_DEFAULT;
thiz->mirroring = PROP_MIRRORING_DEFAULT;
thiz->scaling_mode = PROP_SCALING_MODE_DEFAULT;
thiz->keep_aspect = PROP_FORCE_ASPECT_RATIO_DEFAULT;
gst_video_info_init (&thiz->sinkpad_info);
gst_video_info_init (&thiz->srcpad_info);
}

View file

@ -113,6 +113,7 @@ struct _GstMsdkVPP
guint detail;
guint mirroring;
guint scaling_mode;
gboolean keep_aspect;
GstClockTime field_duration;

View file

@ -508,6 +508,10 @@ _get_preferred_src_caps (GstMsdkVPP * thiz, GstVideoInfo * vinfo,
/* make a copy */
structure = gst_structure_copy (structure);
if (thiz->keep_aspect)
gst_structure_set (structure, "pixel-aspect-ratio", GST_TYPE_FRACTION, 1,
1, NULL);
/* Fixate the format */
if (!gst_structure_fixate_field (structure, "format"))
goto fixate_failed;