GST_STATIC_CAPS ("video/x-raw-yuv; video/x-raw-rgb")
);
+static void gst_video_max_rate_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_video_max_rate_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
static gboolean gst_video_max_rate_start (GstBaseTransform * trans);
static gboolean gst_video_max_rate_sink_event (GstBaseTransform * trans,
GstEvent * event);
GST_BOILERPLATE (GstVideoMaxRate, gst_video_max_rate, GstBaseTransform,
GST_TYPE_BASE_TRANSFORM);
+#define DEFAULT_AVERAGE_PERIOD GST_SECOND
+
+enum
+{
+ PROP_0,
+ PROP_AVERAGE_PERIOD
+};
+
static void
gst_video_max_rate_base_init (gpointer gclass)
{
static void
gst_video_max_rate_class_init (GstVideoMaxRateClass * klass)
{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstBaseTransformClass *base_class = GST_BASE_TRANSFORM_CLASS (klass);
+ gobject_class->set_property = gst_video_max_rate_set_property;
+ gobject_class->get_property = gst_video_max_rate_get_property;
+
base_class->transform_caps =
GST_DEBUG_FUNCPTR (gst_video_max_rate_transform_caps);
base_class->set_caps = GST_DEBUG_FUNCPTR (gst_video_max_rate_set_caps);
GST_DEBUG_FUNCPTR (gst_video_max_rate_transform_ip);
base_class->event = GST_DEBUG_FUNCPTR (gst_video_max_rate_sink_event);
base_class->start = GST_DEBUG_FUNCPTR (gst_video_max_rate_start);
+
+ g_object_class_install_property (gobject_class, PROP_AVERAGE_PERIOD,
+ g_param_spec_uint64 ("average-period", "Period over which to average",
+ "Period over which to average the framerate (in ns)",
+ 1, G_MAXINT64, DEFAULT_AVERAGE_PERIOD,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
static void
{
gst_video_max_rate_reset (videomaxrate);
videomaxrate->wanted_diff = 0;
+ videomaxrate->average_period = DEFAULT_AVERAGE_PERIOD;
gst_base_transform_set_gap_aware (GST_BASE_TRANSFORM (videomaxrate), TRUE);
gst_base_transform_set_in_place (GST_BASE_TRANSFORM (videomaxrate), TRUE);
}
+
+static void
+gst_video_max_rate_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ GstVideoMaxRate *videomaxrate = GST_VIDEO_MAX_RATE (object);
+
+ switch (prop_id) {
+ case PROP_AVERAGE_PERIOD:
+ videomaxrate->average_period = g_value_get_uint64 (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+
+static void
+gst_video_max_rate_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
+{
+ GstVideoMaxRate *videomaxrate = GST_VIDEO_MAX_RATE (object);
+
+ switch (prop_id) {
+ case PROP_AVERAGE_PERIOD:
+ g_value_set_uint64 (value, videomaxrate->average_period);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
static gboolean
gst_video_max_rate_start (GstBaseTransform * trans)
{
{
GstVideoMaxRate *videomaxrate = GST_VIDEO_MAX_RATE (trans);
GstClockTime ts = GST_BUFFER_TIMESTAMP (buf);
- const GstClockTime average_period = GST_SECOND;
if (!GST_BUFFER_TIMESTAMP_IS_VALID (buf) || videomaxrate->wanted_diff == 0)
return GST_FLOW_OK;
if (videomaxrate->average) {
GstClockTimeDiff wanted_diff;
- if (G_LIKELY (average_period > videomaxrate->wanted_diff))
+ if (G_LIKELY (videomaxrate->average_period > videomaxrate->wanted_diff))
wanted_diff = videomaxrate->wanted_diff;
else
- wanted_diff = average_period * 10;
+ wanted_diff = videomaxrate->average_period * 10;
videomaxrate->average =
gst_util_uint64_scale_round (videomaxrate->average,
- average_period - wanted_diff,
- average_period) +
+ videomaxrate->average_period - wanted_diff,
+ videomaxrate->average_period) +
gst_util_uint64_scale_round (diff, wanted_diff,
- average_period);
+ videomaxrate->average_period);
} else {
videomaxrate->average = diff;
}