mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-23 15:48:23 +00:00
jpegdec: use slightly more adaptive formula for QoS
Should work at least a tad better if the decoder can't keep up, and should also spread dropped frames a bit more evenly over time.
This commit is contained in:
parent
1095e624ec
commit
e14bae6637
2 changed files with 24 additions and 6 deletions
|
@ -128,7 +128,7 @@ static gboolean gst_jpeg_dec_src_event (GstPad * pad, GstEvent * event);
|
|||
static GstStateChangeReturn gst_jpeg_dec_change_state (GstElement * element,
|
||||
GstStateChange transition);
|
||||
static void gst_jpeg_dec_update_qos (GstJpegDec * dec, gdouble proportion,
|
||||
GstClockTime time);
|
||||
GstClockTimeDiff diff, GstClockTime ts);
|
||||
static void gst_jpeg_dec_reset_qos (GstJpegDec * dec);
|
||||
static void gst_jpeg_dec_read_qos (GstJpegDec * dec, gdouble * proportion,
|
||||
GstClockTime * time);
|
||||
|
@ -785,18 +785,25 @@ gst_jpeg_dec_decode_direct (GstJpegDec * dec, guchar * base[3],
|
|||
|
||||
static void
|
||||
gst_jpeg_dec_update_qos (GstJpegDec * dec, gdouble proportion,
|
||||
GstClockTime time)
|
||||
GstClockTimeDiff diff, GstClockTime ts)
|
||||
{
|
||||
GST_OBJECT_LOCK (dec);
|
||||
dec->proportion = proportion;
|
||||
dec->earliest_time = time;
|
||||
if (G_LIKELY (ts != GST_CLOCK_TIME_NONE)) {
|
||||
if (G_UNLIKELY (diff > 0))
|
||||
dec->earliest_time = ts + 2 * diff + dec->qos_duration;
|
||||
else
|
||||
dec->earliest_time = ts + diff;
|
||||
} else {
|
||||
dec->earliest_time = GST_CLOCK_TIME_NONE;
|
||||
}
|
||||
GST_OBJECT_UNLOCK (dec);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_jpeg_dec_reset_qos (GstJpegDec * dec)
|
||||
{
|
||||
gst_jpeg_dec_update_qos (dec, 0.5, GST_CLOCK_TIME_NONE);
|
||||
gst_jpeg_dec_update_qos (dec, 0.5, 0, GST_CLOCK_TIME_NONE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -976,6 +983,17 @@ gst_jpeg_dec_chain (GstPad * pad, GstBuffer * buf)
|
|||
dec->framerate_denominator = 1;
|
||||
}
|
||||
|
||||
/* calculate or assume an average frame duration for QoS purposes */
|
||||
GST_OBJECT_LOCK (dec);
|
||||
if (dec->framerate_denominator != 0) {
|
||||
dec->qos_duration = gst_util_uint64_scale (GST_SECOND,
|
||||
dec->framerate_denominator, dec->framerate_numerator);
|
||||
} else {
|
||||
/* if not set just use 25fps */
|
||||
dec->qos_duration = gst_util_uint64_scale (GST_SECOND, 1, 25);
|
||||
}
|
||||
GST_OBJECT_UNLOCK (dec);
|
||||
|
||||
caps = gst_caps_new_simple ("video/x-raw-yuv",
|
||||
"format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'),
|
||||
"width", G_TYPE_INT, width,
|
||||
|
@ -1173,8 +1191,7 @@ gst_jpeg_dec_src_event (GstPad * pad, GstEvent * event)
|
|||
gdouble proportion;
|
||||
|
||||
gst_event_parse_qos (event, &proportion, &diff, ×tamp);
|
||||
|
||||
gst_jpeg_dec_update_qos (dec, proportion, timestamp + diff);
|
||||
gst_jpeg_dec_update_qos (dec, proportion, diff, timestamp);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -86,6 +86,7 @@ struct _GstJpegDec {
|
|||
/* QoS stuff *//* with LOCK */
|
||||
gdouble proportion;
|
||||
GstClockTime earliest_time;
|
||||
GstClockTime qos_duration;
|
||||
|
||||
/* video state */
|
||||
gint framerate_numerator;
|
||||
|
|
Loading…
Reference in a new issue