From ffc06e17f036c183df6037f9654eeae870d14e54 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 3 Jun 2010 19:23:01 +0200 Subject: [PATCH] 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 --- gst/rtp/gstrtpmp4gdepay.c | 8 ++++++++ gst/rtp/gstrtpmp4gdepay.h | 1 + 2 files changed, 9 insertions(+) diff --git a/gst/rtp/gstrtpmp4gdepay.c b/gst/rtp/gstrtpmp4gdepay.c index 4d8aee272c..8307becca6 100644 --- a/gst/rtp/gstrtpmp4gdepay.c +++ b/gst/rtp/gstrtpmp4gdepay.c @@ -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; diff --git a/gst/rtp/gstrtpmp4gdepay.h b/gst/rtp/gstrtpmp4gdepay.h index 2d19413274..cd088e5b19 100644 --- a/gst/rtp/gstrtpmp4gdepay.h +++ b/gst/rtp/gstrtpmp4gdepay.h @@ -65,6 +65,7 @@ struct _GstRtpMP4GDepay guint last_AU_index; guint next_AU_index; guint32 prev_rtptime; + guint prev_AU_num; GQueue *packets;