mp4gdepay: calculate the frame duration correctly
authorWim Taymans <wim.taymans@collabora.co.uk>
Thu, 3 Jun 2010 17:23:01 +0000 (19:23 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Thu, 3 Jun 2010 17:39:04 +0000 (19:39 +0200)
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
gst/rtp/gstrtpmp4gdepay.h

index 4d8aee2..8307bec 100644 (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;
index 2d19413..cd088e5 100644 (file)
@@ -65,6 +65,7 @@ struct _GstRtpMP4GDepay
   guint last_AU_index;
   guint next_AU_index;
   guint32 prev_rtptime;
+  guint prev_AU_num;
 
   GQueue *packets;