]> git.sesse.net Git - vlc/commitdiff
Added a small heuristic to improve MLP detection in AOB.
authorLaurent Aimar <fenrir@videolan.org>
Fri, 7 Aug 2009 18:50:32 +0000 (20:50 +0200)
committerLaurent Aimar <fenrir@videolan.org>
Fri, 7 Aug 2009 18:51:58 +0000 (20:51 +0200)
modules/demux/ps.c
modules/demux/ps.h

index 0e5d772b207ab68b34d2d70d49734a16fd6de27d..033eee81f3abbb2ea8dbbe159b0e70b9ec94ae95 100644 (file)
@@ -87,6 +87,8 @@ struct demux_sys_t
     int         i_time_track;
     int64_t     i_current_pts;
 
+    int         i_aob_mlp_count;
+
     bool  b_lost_sync;
     bool  b_have_pack;
     bool  b_seekable;
@@ -135,6 +137,7 @@ static int OpenCommon( vlc_object_t *p_this, bool b_force )
     p_sys->i_length   = -1;
     p_sys->i_current_pts = (mtime_t) 0;
     p_sys->i_time_track = -1;
+    p_sys->i_aob_mlp_count = 0;
 
     p_sys->b_lost_sync = false;
     p_sys->b_have_pack = false;
@@ -355,6 +358,19 @@ static int Demux( demux_t *p_demux )
     default:
         if( (i_id = ps_pkt_id( p_pkt )) >= 0xc0 )
         {
+            /* Small heuristic to improve MLP detection from AOB */
+            if( i_id == 0xa001 &&
+                p_sys->i_aob_mlp_count < 500 )
+            {
+                p_sys->i_aob_mlp_count++;
+            }
+            else if( i_id == 0xbda1 &&
+                     p_sys->i_aob_mlp_count > 0 )
+            {
+                p_sys->i_aob_mlp_count--;
+                i_id = 0xa001;
+            }
+
             bool b_new = false;
             ps_track_t *tk = &p_sys->tk[PS_ID_TO_TK(i_id)];
 
index a8ca523072990834161fac04435af05290cd67cb..35708e8245a543222df7bf717e3116c0facf80eb 100644 (file)
@@ -229,7 +229,8 @@ static inline int ps_pkt_id( block_t *p_pkt )
 
         if( (i_sub_id & 0xfe) == 0xa0 &&
             p_pkt->i_buffer >= i_start + 7 &&
-            p_pkt->p_buffer[i_start + 6] != 0x80 )
+            ( p_pkt->p_buffer[i_start + 5] >=  0xc0 ||
+              p_pkt->p_buffer[i_start + 6] != 0x80 ) )
         {
             /* AOB LPCM/MLP extension
              * XXX for MLP I think that the !=0x80 test is not good and
@@ -485,7 +486,8 @@ static inline int ps_pkt_parse_pes( block_t *p_pes, int i_skip_extra )
 
     if( i_skip_extra >= 0 )
         i_skip += i_skip_extra;
-    else if( p_pes->i_buffer > i_skip + 3 && ps_pkt_id( p_pes ) == 0xa001 )
+    else if( p_pes->i_buffer > i_skip + 3 &&
+             ( ps_pkt_id( p_pes ) == 0xa001 || ps_pkt_id( p_pes ) == 0xbda1 ) )
         i_skip += 4 + p_pes->p_buffer[i_skip+3];
 
     if( p_pes->i_buffer <= i_skip )