[vlc-devel] commit: Added a small heuristic to improve MLP detection in AOB. ( Laurent Aimar )

git version control git at videolan.org
Fri Aug 7 20:53:54 CEST 2009


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Fri Aug  7 20:50:32 2009 +0200| [7e3972c490bf6de6db0050dc05a3a6974dd12d88] | committer: Laurent Aimar 

Added a small heuristic to improve MLP detection in AOB.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7e3972c490bf6de6db0050dc05a3a6974dd12d88
---

 modules/demux/ps.c |   16 ++++++++++++++++
 modules/demux/ps.h |    6 ++++--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/modules/demux/ps.c b/modules/demux/ps.c
index 0e5d772..033eee8 100644
--- a/modules/demux/ps.c
+++ b/modules/demux/ps.c
@@ -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)];
 
diff --git a/modules/demux/ps.h b/modules/demux/ps.h
index a8ca523..35708e8 100644
--- a/modules/demux/ps.h
+++ b/modules/demux/ps.h
@@ -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 )




More information about the vlc-devel mailing list