baseparse: localize use of provided fps information

This commit is contained in:
Mark Nauwelaerts 2010-09-22 13:55:20 +02:00 committed by Tim-Philipp Müller
parent 5dd8a489d5
commit 1f7359d388

View file

@ -943,14 +943,8 @@ gst_base_parse_convert_default (GstBaseParse * parse,
if (!parse->priv->framecount) if (!parse->priv->framecount)
return FALSE; return FALSE;
/* either frame info (having num means den also ok) or use average bitrate */ duration = parse->priv->acc_duration / GST_MSECOND;
if (parse->priv->fps_num) { bytes = parse->priv->bytecount;
duration = parse->priv->framecount * parse->priv->fps_den * 1000;
bytes = parse->priv->bytecount * parse->priv->fps_num;
} else {
duration = parse->priv->acc_duration / GST_MSECOND;
bytes = parse->priv->bytecount;
}
if (G_UNLIKELY (!duration || !bytes)) if (G_UNLIKELY (!duration || !bytes))
return FALSE; return FALSE;
@ -1076,13 +1070,9 @@ gst_base_parse_update_bitrates (GstBaseParse * parse, GstBuffer * buffer)
data_len = GST_BUFFER_SIZE (buffer) - overhead; data_len = GST_BUFFER_SIZE (buffer) - overhead;
parse->priv->data_bytecount += data_len; parse->priv->data_bytecount += data_len;
if (parse->priv->fps_num) { /* duration should be valid by now,
/* Calculate duration of a frame from frame properties */ * either set by subclass or maybe based on fps settings */
frame_dur = (GST_SECOND * parse->priv->fps_den) / parse->priv->fps_num; if (GST_BUFFER_DURATION_IS_VALID (buffer)) {
parse->priv->avg_bitrate = (8 * parse->priv->data_bytecount * GST_SECOND) /
(parse->priv->framecount * frame_dur);
} else if (GST_BUFFER_DURATION_IS_VALID (buffer)) {
/* Calculate duration of a frame from buffer properties */ /* Calculate duration of a frame from buffer properties */
frame_dur = GST_BUFFER_DURATION (buffer); frame_dur = GST_BUFFER_DURATION (buffer);
parse->priv->avg_bitrate = (8 * parse->priv->data_bytecount * GST_SECOND) / parse->priv->avg_bitrate = (8 * parse->priv->data_bytecount * GST_SECOND) /