[vlc-devel] [V3 3/5] demux: mkv: fix timestamp issue of RV30/RV40

Zhao Zhili quinkblack at foxmail.com
Fri Jun 1 17:20:17 CEST 2018


Fix #20537
---
 modules/demux/mkv/matroska_segment.cpp | 14 ++++++++++++++
 modules/demux/mkv/mkv.cpp              | 17 +++++++++++++++++
 modules/demux/mkv/mkv.hpp              |  2 ++
 3 files changed, 33 insertions(+)

diff --git a/modules/demux/mkv/matroska_segment.cpp b/modules/demux/mkv/matroska_segment.cpp
index 457fdbc641..c469ec7ab4 100644
--- a/modules/demux/mkv/matroska_segment.cpp
+++ b/modules/demux/mkv/matroska_segment.cpp
@@ -32,6 +32,8 @@
 #include <new>
 #include <iterator>
 
+#include <vlc_codec.h>
+
 matroska_segment_c::matroska_segment_c( demux_sys_t & demuxer, EbmlStream & estream, KaxSegment *p_seg )
     :segment(p_seg)
     ,es(estream)
@@ -799,6 +801,8 @@ bool matroska_segment_c::Seek( demux_t &demuxer, mtime_t i_absolute_mk_date, mti
         if( track.i_last_dts != VLC_TS_INVALID )
             track.b_discontinuity = true;
         track.i_last_dts        = VLC_TS_INVALID;
+        if( track.p_packetizer != NULL )
+            track.p_packetizer->pf_flush( track.p_packetizer );
 
         bool selected;
         es_out_Control( demuxer.out, ES_OUT_GET_ES_STATE, track.p_es, &selected );
@@ -1105,6 +1109,16 @@ bool matroska_segment_c::ESCreate()
             continue;
         }
 
+        if( track.fmt.i_codec == VLC_CODEC_RV30 || track.fmt.i_codec == VLC_CODEC_RV40 )
+        {
+            if( track.p_packetizer == NULL )
+            {
+                es_format_t fmt;
+                es_format_Copy( &fmt, &track.fmt );
+                track.p_packetizer = demux_PacketizerNew( &sys.demuxer, &fmt, "RV30/RV40" );
+            }
+        }
+
         if( !track.p_es )
             track.p_es = es_out_Add( sys.demuxer.out, &track.fmt );
 
diff --git a/modules/demux/mkv/mkv.cpp b/modules/demux/mkv/mkv.cpp
index 4973dc498b..7817e91e7f 100644
--- a/modules/demux/mkv/mkv.cpp
+++ b/modules/demux/mkv/mkv.cpp
@@ -33,6 +33,7 @@
 
 #include <new>
 
+#include <vlc_codec.h>
 #include <vlc_fs.h>
 #include <vlc_url.h>
 
@@ -673,6 +674,19 @@ void BlockDecode( demux_t *p_demux, KaxBlock *block, KaxSimpleBlock *simpleblock
             else
             {
                 p_block->i_pts = i_pts;
+
+                if( track.fmt.i_codec == VLC_CODEC_RV30 || track.fmt.i_codec == VLC_CODEC_RV40 )
+                {
+                    if( track.p_packetizer != NULL )
+                    {
+                        p_block = track.p_packetizer->pf_packetize(track.p_packetizer, &p_block);
+                        if( !p_block )
+                            continue;
+                        if( p_block->i_flags & BLOCK_FLAG_TYPE_I )
+                            b_key_picture = true;
+                    }
+                }
+
                 // condition when the DTS is correct (keyframe or B frame == NOT P frame)
                 if ( b_key_picture || b_discardable_picture )
                         p_block->i_dts = p_block->i_pts;
@@ -854,6 +868,7 @@ mkv_track_t::mkv_track_t(enum es_format_category_e es_cat) :
   ,p_compression_data(NULL)
   ,i_seek_preroll(0)
   ,i_codec_delay(0)
+  ,p_packetizer(NULL)
 {
     std::memset( &pi_chan_table, 0, sizeof( pi_chan_table ) );
 
@@ -882,6 +897,8 @@ mkv_track_t::~mkv_track_t()
 
     free(p_extra_data);
 
+    if( p_packetizer )
+        demux_PacketizerDestroy( p_packetizer );
     delete p_compression_data;
     delete p_sys;
 }
diff --git a/modules/demux/mkv/mkv.hpp b/modules/demux/mkv/mkv.hpp
index 90be75902f..daa753d507 100644
--- a/modules/demux/mkv/mkv.hpp
+++ b/modules/demux/mkv/mkv.hpp
@@ -229,6 +229,8 @@ class mkv_track_t
         /* Matroska 4 new elements used by Opus */
         mtime_t i_seek_preroll;
         mtime_t i_codec_delay;
+
+        decoder_t *p_packetizer;
 };
 
 
-- 
2.15.1 (Apple Git-101)



More information about the vlc-devel mailing list