Commit ffc06e17 authored by Wim Taymans's avatar Wim Taymans

mp4gdepay: calculate the frame duration correctly

When we calculate the frame duration, we need to use the amount of
frames in the _previous_ packet, not the current packet. The frame duration is
needed to correctly de-interleave interleaved streams. This fixes the case where
there are a variable number of frames in a packet.

Fixes #620494
parent d72a2fb6
......@@ -544,7 +544,13 @@ gst_rtp_mp4g_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
if (rtpmp4gdepay->constantDuration != 0) {
cd = rtpmp4gdepay->constantDuration;
GST_DEBUG_OBJECT (depayload, "using constantDuration %d", cd);
} else if (rtpmp4gdepay->prev_AU_num > 0) {
/* use number of packets and of previous frame */
cd = diff / rtpmp4gdepay->prev_AU_num;
GST_DEBUG_OBJECT (depayload, "guessing constantDuration %d", cd);
} else {
/* assume this frame has the same number of packets as the
* previous one */
cd = diff / num_AU_headers;
GST_DEBUG_OBJECT (depayload, "guessing constantDuration %d", cd);
}
......@@ -592,6 +598,7 @@ gst_rtp_mp4g_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
}
}
rtpmp4gdepay->prev_rtptime = rtptime;
rtpmp4gdepay->prev_AU_num = num_AU_headers;
} else {
AU_index_delta =
gst_bs_parse_read (&bs, rtpmp4gdepay->indexdeltalength);
......@@ -709,6 +716,7 @@ gst_rtp_mp4g_depay_change_state (GstElement * element,
rtpmp4gdepay->prev_AU_index = -1;
rtpmp4gdepay->prev_rtptime = -1;
rtpmp4gdepay->last_AU_index = -1;
rtpmp4gdepay->prev_AU_num = -1;
break;
default:
break;
......
......@@ -65,6 +65,7 @@ struct _GstRtpMP4GDepay
guint last_AU_index;
guint next_AU_index;
guint32 prev_rtptime;
guint prev_AU_num;
GQueue *packets;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment