[vlc-commits] mkv: let the track init its es_format_t
Steve Lhomme
git at videolan.org
Mon Jul 31 15:23:13 CEST 2017
vlc | branch: master | Steve Lhomme <robUx4 at videolabs.io> | Mon Jul 31 15:02:54 2017 +0200| [a6785624e16814fff5d531c23bac681c0d8f0975] | committer: Jean-Baptiste Kempf
mkv: let the track init its es_format_t
So it's not created in a funny state.
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a6785624e16814fff5d531c23bac681c0d8f0975
---
modules/demux/mkv/matroska_segment_parse.cpp | 20 +++++-------
modules/demux/mkv/mkv.cpp | 47 +++++++++++++++++++++++++++-
modules/demux/mkv/mkv.hpp | 29 +----------------
3 files changed, 55 insertions(+), 41 deletions(-)
diff --git a/modules/demux/mkv/matroska_segment_parse.cpp b/modules/demux/mkv/matroska_segment_parse.cpp
index 77ffe4e5b1..896d6bd77e 100644
--- a/modules/demux/mkv/matroska_segment_parse.cpp
+++ b/modules/demux/mkv/matroska_segment_parse.cpp
@@ -204,9 +204,6 @@ void matroska_segment_c::ParseTrackEntry( const KaxTrackEntry *m )
{
bool bSupported = true;
- /* Init the track */
- mkv_track_t track;
-
EbmlUInteger *pTrackType = static_cast<EbmlUInteger*>(m->FindElt(EBML_INFO(KaxTrackType)));
uint8 ttype;
if (likely(pTrackType != NULL))
@@ -214,28 +211,27 @@ void matroska_segment_c::ParseTrackEntry( const KaxTrackEntry *m )
else
ttype = 0;
+ enum es_format_category_e es_cat;
switch( ttype )
{
case track_audio:
- es_format_Init( &track.fmt, AUDIO_ES, 0);
- track.fmt.audio.i_channels = 1;
- track.fmt.audio.i_rate = 8000;
- track.fmt.psz_language = strdup("English");
+ es_cat = AUDIO_ES;
break;
case track_video:
- es_format_Init( &track.fmt, VIDEO_ES, 0);
- track.fmt.psz_language = strdup("English");
+ es_cat = VIDEO_ES;
break;
case track_subtitle:
case track_buttons:
- es_format_Init( &track.fmt, SPU_ES, 0);
- track.fmt.psz_language = strdup("English");
+ es_cat = SPU_ES;
break;
default:
- es_format_Init( &track.fmt, UNKNOWN_ES, 0);
+ es_cat = UNKNOWN_ES;
break;
}
+ /* Init the track */
+ mkv_track_t track( es_cat );
+
MkvTree( sys.demuxer, 2, "Track Entry" );
struct MetaDataCapture {
diff --git a/modules/demux/mkv/mkv.cpp b/modules/demux/mkv/mkv.cpp
index 864981d4a6..6155708e65 100644
--- a/modules/demux/mkv/mkv.cpp
+++ b/modules/demux/mkv/mkv.cpp
@@ -528,7 +528,6 @@ void BlockDecode( demux_t *p_demux, KaxBlock *block, KaxSimpleBlock *simpleblock
if( !b )
{
- track.b_inited = false;
if( track.fmt.i_cat == VIDEO_ES || track.fmt.i_cat == AUDIO_ES )
track.i_last_dts = VLC_TS_INVALID;
return;
@@ -804,3 +803,49 @@ static int Demux( demux_t *p_demux)
return 1;
}
+
+mkv_track_t::mkv_track_t(enum es_format_category_e es_cat) :
+ 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_discontinuity(false)
+ ,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( &pi_chan_table, 0, sizeof( pi_chan_table ) );
+
+ es_format_Init(&fmt, es_cat, 0);
+
+ switch( es_cat )
+ {
+ case AUDIO_ES:
+ fmt.audio.i_channels = 1;
+ fmt.audio.i_rate = 8000;
+ /* fall through */
+ case VIDEO_ES:
+ case SPU_ES:
+ fmt.psz_language = strdup("English");
+ break;
+ default:
+ // no language needed
+ break;
+ }
+}
diff --git a/modules/demux/mkv/mkv.hpp b/modules/demux/mkv/mkv.hpp
index ec43dff2b4..4022cf09fc 100644
--- a/modules/demux/mkv/mkv.hpp
+++ b/modules/demux/mkv/mkv.hpp
@@ -183,34 +183,7 @@ 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_discontinuity(false)
- ,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( &pi_chan_table, 0, sizeof( pi_chan_table ) );
- }
+ mkv_track_t(enum es_format_category_e es_cat);
typedef unsigned int track_id_t;
More information about the vlc-commits
mailing list