mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-26 10:10:32 +00:00
mpegtsdemux: Protect bitrate estimation against bogus values.
If the estimated bitrate is lower than 188 bytes, there's most likely something completely wrong with the two samples. If that happens, force recalculation. Use guint64 for observation PCR, I saw cases where it would overflow.
This commit is contained in:
parent
bc062b9acf
commit
f9dfc44a67
2 changed files with 18 additions and 5 deletions
|
@ -2355,14 +2355,27 @@ gst_mpegts_demux_parse_transport_packet (GstMpegTSDemux * demux,
|
||||||
MPEGTS_NORMAL_TS_PACKETSIZE - 1);
|
MPEGTS_NORMAL_TS_PACKETSIZE - 1);
|
||||||
|
|
||||||
if (demux->pcr[1] != -1 && demux->bitrate == -1) {
|
if (demux->pcr[1] != -1 && demux->bitrate == -1) {
|
||||||
GST_DEBUG_OBJECT (demux, "stream->last_PCR_difference: %" G_GINT64_FORMAT
|
guint64 bitrate;
|
||||||
|
GST_DEBUG_OBJECT (demux, "pcr[0]:%" G_GUINT64_FORMAT, demux->pcr[0]);
|
||||||
|
GST_DEBUG_OBJECT (demux, "pcr[1]:%" G_GUINT64_FORMAT, demux->pcr[1]);
|
||||||
|
GST_DEBUG_OBJECT (demux, "diff in time %" GST_TIME_FORMAT,
|
||||||
|
GST_TIME_ARGS (MPEGTIME_TO_GSTTIME (demux->pcr[1] - demux->pcr[0])));
|
||||||
|
GST_DEBUG_OBJECT (demux, "stream->last_PCR_difference: %" G_GUINT64_FORMAT
|
||||||
", demux->num_packets %" G_GUINT64_FORMAT,
|
", demux->num_packets %" G_GUINT64_FORMAT,
|
||||||
demux->pcr[1] - demux->pcr[0], demux->num_packets);
|
demux->pcr[1] - demux->pcr[0], demux->num_packets);
|
||||||
demux->bitrate = gst_util_uint64_scale (GST_SECOND,
|
bitrate = gst_util_uint64_scale (GST_SECOND,
|
||||||
MPEGTS_NORMAL_TS_PACKETSIZE * demux->num_packets,
|
MPEGTS_NORMAL_TS_PACKETSIZE * demux->num_packets,
|
||||||
MPEGTIME_TO_GSTTIME (demux->pcr[1] - demux->pcr[0]));
|
MPEGTIME_TO_GSTTIME (demux->pcr[1] - demux->pcr[0]));
|
||||||
|
/* somehow... I doubt a bitrate below one packet per second is valid */
|
||||||
|
if (bitrate > MPEGTS_NORMAL_TS_PACKETSIZE - 1) {
|
||||||
|
demux->bitrate = bitrate;
|
||||||
GST_DEBUG_OBJECT (demux, "bitrate is %" G_GINT64_FORMAT
|
GST_DEBUG_OBJECT (demux, "bitrate is %" G_GINT64_FORMAT
|
||||||
" bytes per second", demux->bitrate);
|
" bytes per second", demux->bitrate);
|
||||||
|
} else {
|
||||||
|
GST_WARNING_OBJECT (demux, "Couldn't compute valid bitrate, recomputing");
|
||||||
|
demux->pcr[0] = demux->pcr[1] = -1;
|
||||||
|
demux->num_packets = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
demux->num_packets++;
|
demux->num_packets++;
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -213,7 +213,7 @@ struct _GstMpegTSDemux {
|
||||||
gint64 bitrate;
|
gint64 bitrate;
|
||||||
|
|
||||||
/* Two PCRs observations to calculate bitrate */
|
/* Two PCRs observations to calculate bitrate */
|
||||||
gint64 pcr[2];
|
guint64 pcr[2];
|
||||||
|
|
||||||
/* Cached duration estimation */
|
/* Cached duration estimation */
|
||||||
GstClockTime cache_duration;
|
GstClockTime cache_duration;
|
||||||
|
|
Loading…
Reference in a new issue