[vlc-commits] demux:mkv: initialize all the mkv_track_t fields in the constructor

Steve Lhomme git at videolan.org
Thu Jul 13 11:10:12 CEST 2017


vlc | branch: master | Steve Lhomme <robux4 at videolabs.io> | Wed Jul 12 15:14:59 2017 +0200| [da676267f86bc4b61b07353875a383c6c1fcea07] | committer: Jean-Baptiste Kempf

demux:mkv: initialize all the mkv_track_t fields in the constructor

No object should be left with uninitialized members.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/demux/mkv/matroska_segment_parse.cpp | 45 ----------------------------
 modules/demux/mkv/mkv.hpp                    | 34 +++++++++++++++++++++
 2 files changed, 34 insertions(+), 45 deletions(-)

diff --git a/modules/demux/mkv/matroska_segment_parse.cpp b/modules/demux/mkv/matroska_segment_parse.cpp
index 63a9d0cf58..c4f796da2a 100644
--- a/modules/demux/mkv/matroska_segment_parse.cpp
+++ b/modules/demux/mkv/matroska_segment_parse.cpp
@@ -207,24 +207,6 @@ void matroska_segment_c::ParseTrackEntry( const KaxTrackEntry *m )
     /* Init the track */
     mkv_track_t track;
 
-    track.b_default              = true;
-    track.b_enabled              = true;
-    track.b_forced               = false;
-    track.i_number               = 0;
-
-    track.i_extra_data           = 0;
-    track.p_extra_data           = NULL;
-
-    track.codec                  = "";
-    track.b_dts_only             = false;
-    track.b_pts_only             = false;
-
-    track.b_no_duration          = false;
-    track.i_default_duration     = 0;
-    track.f_timecodescale        = 1.0;
-    track.i_last_dts             = 0;
-    track.i_skip_until_fpos      = -1;
-
     EbmlUInteger *pTrackType = static_cast<EbmlUInteger*>(m->FindElt(EBML_INFO(KaxTrackType)));
     uint8 ttype;
     if (likely(pTrackType != NULL))
@@ -253,33 +235,6 @@ void matroska_segment_c::ParseTrackEntry( const KaxTrackEntry *m )
             break;
     }
 
-    track.fmt.psz_language       = strdup("English");
-    track.fmt.psz_description    = NULL;
-
-    track.f_fps = 0;
-    track.p_es = NULL;
-
-    track.i_original_rate        = 0;
-    track.i_chans_to_reorder     = 0;
-    std::memset( &track.pi_chan_table, 0, sizeof( track.pi_chan_table ) );
-
-    track.p_sys                  = NULL;
-
-    track.b_inited               = false;
-    track.b_discontinuity        = false;
-
-    track.i_data_init            = 0;
-    track.p_data_init            = NULL;
-
-    track.str_codec_name         = "";
-
-    track.i_compression_type     = MATROSKA_COMPRESSION_NONE;
-    track.i_encoding_scope       = MATROSKA_ENCODING_SCOPE_ALL_FRAMES;
-    track.p_compression_data     = NULL;
-
-    track.i_seek_preroll          = 0;
-    track.i_codec_delay           = 0;
-
     MkvTree( sys.demuxer, 2, "Track Entry" );
 
     struct MetaDataCapture {
diff --git a/modules/demux/mkv/mkv.hpp b/modules/demux/mkv/mkv.hpp
index 3c94d14f60..5439df5d15 100644
--- a/modules/demux/mkv/mkv.hpp
+++ b/modules/demux/mkv/mkv.hpp
@@ -183,6 +183,40 @@ public:
 class mkv_track_t
 {
     public:
+        mkv_track_t() :
+            b_default(true)
+          ,b_enabled(true)
+          ,b_forced(false)
+          ,i_number(0)
+          ,i_extra_data(0)
+          ,p_extra_data(NULL)
+          ,b_dts_only(false)
+          ,b_pts_only(false)
+          ,b_no_duration(false)
+          ,i_default_duration(0)
+          ,f_timecodescale(1.0)
+          ,i_last_dts(0)
+          ,i_skip_until_fpos(-1)
+          ,f_fps(0)
+          ,p_es(NULL)
+          ,i_original_rate(0)
+          ,i_chans_to_reorder(0)
+          ,p_sys(NULL)
+          ,b_inited(false)
+          ,b_discontinuity(false)
+          ,i_data_init(0)
+          ,p_data_init(NULL)
+          ,i_compression_type(MATROSKA_COMPRESSION_NONE)
+          ,i_encoding_scope(MATROSKA_ENCODING_SCOPE_ALL_FRAMES)
+          ,p_compression_data(NULL)
+          ,i_seek_preroll(0)
+          ,i_codec_delay(0)
+        {
+            std::memset( &fmt, 0, sizeof( fmt ) );
+            std::memset( &pi_chan_table, 0, sizeof( pi_chan_table ) );
+            fmt.psz_language = strdup("English");
+        }
+
         typedef unsigned int track_id_t;
 
         bool         b_default;



More information about the vlc-commits mailing list