aacparse: only require two frames in a row when we do not have sync
authorVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Tue, 23 Aug 2011 11:12:15 +0000 (12:12 +0100)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Wed, 24 Aug 2011 06:26:31 +0000 (08:26 +0200)
This avoids a single bit error dropping two frames unnecessarily.
The two consecutive frames check is still required when we don't
have sync.

https://bugzilla.gnome.org/show_bug.cgi?id=657080

gst/audioparsers/gstaacparse.c

index 5ee8466..5c50da8 100644 (file)
@@ -340,8 +340,12 @@ gst_aac_parse_check_adts_frame (GstAacParse * aacparse,
   if ((data[0] == 0xff) && ((data[1] & 0xf6) == 0xf0)) {
     *framesize = gst_aac_parse_adts_get_frame_len (data);
 
-    /* In EOS mode this is enough. No need to examine the data further */
-    if (drain) {
+    /* In EOS mode this is enough. No need to examine the data further.
+       We also relax the check when we have sync, on the assumption that
+       if we're not looking at random data, we have a much higher chance
+       to get the correct sync, and this avoids losing two frames when
+       a single bit corruption happens. */
+    if (drain || !GST_BASE_PARSE_LOST_SYNC (aacparse)) {
       return TRUE;
     }