ffmpegdec: post QoS messages when dropping a frame

There seems to be a little bit of non obvious logic where
the QoS logic can decide to not drop decoding a frame and
pass it to ffmpeg, telling it to drop.
In this case, the QoS logic does not drop the frame itself,
but since the frame will end up being dropped, we still
mark it as dropped and post a QoS message.

https://bugzilla.gnome.org/show_bug.cgi?id=657950
This commit is contained in:
Vincent Penquerc'h 2011-09-01 16:46:47 +01:00 committed by Tim-Philipp Müller
parent 8a34abff64
commit 8bf3d5a2b7

View file

@ -126,6 +126,8 @@ struct _GstFFMpegDec
/* QoS stuff *//* with LOCK */ /* QoS stuff *//* with LOCK */
gdouble proportion; gdouble proportion;
GstClockTime earliest_time; GstClockTime earliest_time;
gint64 processed;
gint64 dropped;
/* clipping segment */ /* clipping segment */
GstSegment segment; GstSegment segment;
@ -539,6 +541,8 @@ static void
gst_ffmpegdec_reset_qos (GstFFMpegDec * ffmpegdec) gst_ffmpegdec_reset_qos (GstFFMpegDec * ffmpegdec)
{ {
gst_ffmpegdec_update_qos (ffmpegdec, 0.5, GST_CLOCK_TIME_NONE); gst_ffmpegdec_update_qos (ffmpegdec, 0.5, GST_CLOCK_TIME_NONE);
ffmpegdec->processed = 0;
ffmpegdec->dropped = 0;
} }
static void static void
@ -1369,6 +1373,7 @@ gst_ffmpegdec_do_qos (GstFFMpegDec * ffmpegdec, GstClockTime timestamp,
GstClockTimeDiff diff; GstClockTimeDiff diff;
gdouble proportion; gdouble proportion;
GstClockTime qostime, earliest_time; GstClockTime qostime, earliest_time;
gboolean res = TRUE;
*mode_switch = FALSE; *mode_switch = FALSE;
@ -1419,11 +1424,13 @@ gst_ffmpegdec_do_qos (GstFFMpegDec * ffmpegdec, GstClockTime timestamp,
} }
no_qos: no_qos:
ffmpegdec->processed++;
return TRUE; return TRUE;
skipping: skipping:
{ {
return FALSE; res = FALSE;
goto drop_qos;
} }
normal_mode: normal_mode:
{ {
@ -1432,6 +1439,7 @@ normal_mode:
*mode_switch = TRUE; *mode_switch = TRUE;
GST_DEBUG_OBJECT (ffmpegdec, "QOS: normal mode %g < 0.4", proportion); GST_DEBUG_OBJECT (ffmpegdec, "QOS: normal mode %g < 0.4", proportion);
} }
ffmpegdec->processed++;
return TRUE; return TRUE;
} }
skip_frame: skip_frame:
@ -1442,7 +1450,27 @@ skip_frame:
GST_DEBUG_OBJECT (ffmpegdec, GST_DEBUG_OBJECT (ffmpegdec,
"QOS: hurry up, diff %" G_GINT64_FORMAT " >= 0", diff); "QOS: hurry up, diff %" G_GINT64_FORMAT " >= 0", diff);
} }
return TRUE; goto drop_qos;
}
drop_qos:
{
GstClockTime stream_time, jitter;
GstMessage *qos_msg;
ffmpegdec->dropped++;
stream_time =
gst_segment_to_stream_time (&ffmpegdec->segment, GST_FORMAT_TIME,
timestamp);
jitter = GST_CLOCK_DIFF (qostime, earliest_time);
qos_msg =
gst_message_new_qos (GST_OBJECT_CAST (ffmpegdec), FALSE, qostime,
stream_time, timestamp, GST_CLOCK_TIME_NONE);
gst_message_set_qos_values (qos_msg, jitter, proportion, 1000000);
gst_message_set_qos_stats (qos_msg, GST_FORMAT_BUFFERS,
ffmpegdec->processed, ffmpegdec->dropped);
gst_element_post_message (GST_ELEMENT_CAST (ffmpegdec), qos_msg);
return res;
} }
} }