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
This commit is contained in:
Wim Taymans 2010-06-03 19:23:01 +02:00
parent d72a2fb6da
commit ffc06e17f0
2 changed files with 9 additions and 0 deletions

View file

@ -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;

View file

@ -65,6 +65,7 @@ struct _GstRtpMP4GDepay
guint last_AU_index;
guint next_AU_index;
guint32 prev_rtptime;
guint prev_AU_num;
GQueue *packets;