[vlc-commits] demux: mkv: fix opus block truncation (fix #10176)

Francois Cartegnie git at videolan.org
Thu Mar 13 23:59:48 CET 2014


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Mar 13 23:40:37 2014 +0100| [aad4b35c049ba3276c1d19bfb6b12048dd1c5089] | committer: Francois Cartegnie

demux: mkv: fix opus block truncation (fix #10176)

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

 modules/demux/mkv/matroska_segment.cpp |    6 +++++-
 modules/demux/mkv/mkv.cpp              |   15 +++------------
 2 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/modules/demux/mkv/matroska_segment.cpp b/modules/demux/mkv/matroska_segment.cpp
index 1d6ccaa..81657ca 100644
--- a/modules/demux/mkv/matroska_segment.cpp
+++ b/modules/demux/mkv/matroska_segment.cpp
@@ -1431,7 +1431,11 @@ int matroska_segment_c::BlockGet( KaxBlock * & pp_block, KaxSimpleBlock * & pp_s
                     else if( MKV_IS_ID( el, KaxDiscardPadding ) )
                     {
                         KaxDiscardPadding &dp = *(KaxDiscardPadding*) el;
-                        *pi_duration -= int64(dp);
+                        dp.ReadData( es.I_O() );
+                        if ( *pi_duration < int64(dp) )
+                            *pi_duration = 0;
+                        else
+                            *pi_duration -= int64(dp);
                     }
 #endif
                     break;
diff --git a/modules/demux/mkv/mkv.cpp b/modules/demux/mkv/mkv.cpp
index ac2c977..4b49f4c 100644
--- a/modules/demux/mkv/mkv.cpp
+++ b/modules/demux/mkv/mkv.cpp
@@ -601,20 +601,11 @@ void BlockDecode( demux_t *p_demux, KaxBlock *block, KaxSimpleBlock *simpleblock
             continue;
          }
          case VLC_CODEC_OPUS:
-            if( i_duration > 0 )
-            {
-                mtime_t i_length = i_duration * tk-> f_timecodescale *
+            mtime_t i_length = i_duration * tk-> f_timecodescale *
                     (double) p_segment->i_timescale / 1000.0;
-                p_block->i_nb_samples = i_length * tk->fmt.audio.i_rate
-                     / CLOCK_FREQ;
-                break;
-            }
-            else if( i_duration < 0 )
-            {
-                /* Opus uses p_block->i_length to handle discard padding */
-                p_block->i_length = -1 * i_duration * tk->fmt.audio.i_rate
+            if ( i_length < 0 ) i_length = 0;
+            p_block->i_nb_samples = i_length * tk->fmt.audio.i_rate
                     / CLOCK_FREQ;
-            }
             break;
         }
 



More information about the vlc-commits mailing list