[vlc-commits] mkv: removed manual memory management from mkv_track_t

Filip Roséen git at videolan.org
Mon May 9 15:09:24 CEST 2016


vlc | branch: master | Filip Roséen <filip at videolabs.io> | Mon May  9 14:52:59 2016 +0200| [58e1a9e80fc3fb4a2a5d0f150eae6385d37b337e] | committer: Jean-Baptiste Kempf

mkv: removed manual memory management from mkv_track_t

Minor transformation from being a plain-old-data entity to a "proper"
C++ class where manual memory management has been removed and replaced
with std::string, as well as removal of unused members.

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

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

 modules/demux/mkv/matroska_segment_parse.cpp |    9 +--
 modules/demux/mkv/mkv.hpp                    |   83 +++++++++++++-------------
 2 files changed, 42 insertions(+), 50 deletions(-)

diff --git a/modules/demux/mkv/matroska_segment_parse.cpp b/modules/demux/mkv/matroska_segment_parse.cpp
index 9d64192..e128ad3 100644
--- a/modules/demux/mkv/matroska_segment_parse.cpp
+++ b/modules/demux/mkv/matroska_segment_parse.cpp
@@ -224,11 +224,6 @@ void matroska_segment_c::ParseTrackEntry( KaxTrackEntry *m )
     tk->i_data_init            = 0;
     tk->p_data_init            = NULL;
 
-    tk->psz_codec_name         = NULL;
-    tk->psz_codec_settings     = NULL;
-    tk->psz_codec_info_url     = NULL;
-    tk->psz_codec_download_url = NULL;
-
     tk->i_compression_type     = MATROSKA_COMPRESSION_NONE;
     tk->i_encoding_scope       = MATROSKA_ENCODING_SCOPE_ALL_FRAMES;
     tk->p_compression_data     = NULL;
@@ -378,8 +373,8 @@ void matroska_segment_c::ParseTrackEntry( KaxTrackEntry *m )
         }
         E_CASE( KaxCodecName, cname )
         {
-            vars.tk->psz_codec_name = ToUTF8( UTFstring( cname ) );
-            debug( vars, "Track Codec Name=%s", vars.tk->psz_codec_name ) ;
+            vars.tk->str_codec_name = static_cast<UTFstring const&>( cname ).GetUTF8();
+            debug( vars, "Track Codec Name=%s", vars.tk->str_codec_name.c_str() ) ;
         }
         //AttachmentLink
         E_CASE( KaxCodecDecodeAll, cdall ) // UNUSED
diff --git a/modules/demux/mkv/mkv.hpp b/modules/demux/mkv/mkv.hpp
index 31991c1..64a5dff 100644
--- a/modules/demux/mkv/mkv.hpp
+++ b/modules/demux/mkv/mkv.hpp
@@ -178,62 +178,59 @@ public:
     virtual int32_t Init() { return 0; }
 };
 
-struct mkv_track_t
+class mkv_track_t
 {
-    bool         b_default;
-    bool         b_enabled;
-    bool         b_forced;
-    unsigned int i_number;
+    public:
+        typedef unsigned int track_id_t;
 
-    unsigned int i_extra_data;
-    uint8_t      *p_extra_data;
+        bool         b_default;
+        bool         b_enabled;
+        bool         b_forced;
+        track_id_t   i_number;
 
-    char         *psz_codec;
-    bool         b_dts_only;
-    bool         b_pts_only;
+        unsigned int i_extra_data;
+        uint8_t      *p_extra_data;
 
-    bool         b_no_duration;
-    uint64_t     i_default_duration;
-    float        f_timecodescale;
-    mtime_t      i_last_dts;
+        char         *psz_codec;
+        bool         b_dts_only;
+        bool         b_pts_only;
 
-    /* video */
-    es_format_t fmt;
-    float       f_fps;
-    es_out_id_t *p_es;
+        bool         b_no_duration;
+        uint64_t     i_default_duration;
+        float        f_timecodescale;
+        mtime_t      i_last_dts;
+        uint64_t     i_skip_until_fpos;
 
-    /* audio */
-    unsigned int i_original_rate;
-    uint8_t i_chans_to_reorder;            /* do we need channel reordering */
-    uint8_t pi_chan_table[AOUT_CHAN_MAX];
+        /* video */
+        es_format_t fmt;
+        float       f_fps;
+        es_out_id_t *p_es;
 
+        /* audio */
+        unsigned int i_original_rate;
+        uint8_t i_chans_to_reorder;            /* do we need channel reordering */
+        uint8_t pi_chan_table[AOUT_CHAN_MAX];
 
-    /* Private track paramters */
-    PrivateTrackData *p_sys;
 
-    bool            b_inited;
-    /* data to be send first */
-    int             i_data_init;
-    uint8_t         *p_data_init;
+        /* Private track paramters */
+        PrivateTrackData *p_sys;
 
-    /* hack : it's for seek */
-    bool            b_search_keyframe;
+        bool            b_inited;
+        /* data to be send first */
+        int             i_data_init;
+        uint8_t         *p_data_init;
 
-    /* informative */
-    const char   *psz_codec_name;
-    const char   *psz_codec_settings;
-    const char   *psz_codec_info_url;
-    const char   *psz_codec_download_url;
+        /* informative */
+        std::string str_codec_name;
 
-    /* encryption/compression */
-    int                    i_compression_type;
-    uint32_t               i_encoding_scope;
-    KaxContentCompSettings *p_compression_data;
-
-    /* Matroska 4 new elements used by Opus */
-    mtime_t i_seek_preroll;
-    mtime_t i_codec_delay;
+        /* encryption/compression */
+        int                    i_compression_type;
+        uint32_t               i_encoding_scope;
+        KaxContentCompSettings *p_compression_data;
 
+        /* Matroska 4 new elements used by Opus */
+        mtime_t i_seek_preroll;
+        mtime_t i_codec_delay;
 };
 
 struct mkv_index_t



More information about the vlc-commits mailing list