Index: modules/demux/mkv.cpp
===================================================================
--- modules/demux/mkv.cpp    (revision 9924)
+++ modules/demux/mkv.cpp    (working copy)
@@ -56,7 +56,6 @@
 #include "ebml/EbmlSubHead.h"
 #include "ebml/EbmlStream.h"
 #include "ebml/EbmlContexts.h"
-#include "ebml/EbmlVersion.h"
 #include "ebml/EbmlVoid.h"
 #include "ebml/StdIOCallback.h"
 
@@ -390,6 +389,9 @@
 
     std::vector<KaxSegmentFamily> families;
     std::vector<KaxSegment*> family_members;
+
+    int64_t                  edition_uid;
+    bool                     edition_ordered;
 };
 
 #define MKVD_TIMECODESCALE 1000000
@@ -588,48 +590,48 @@
                         bool b_keep_file_opened = false;
                         StdIOCallback *p_file_io = new StdIOCallback(s_filename.c_str(), MODE_READ);
                         EbmlStream *p_stream = new EbmlStream(*p_file_io);
-                        EbmlElement *p_l0, *p_l1, *p_l2;
-
-                        // verify the EBML Header
-                        p_l0 = p_stream->FindNextID(EbmlHead::ClassInfos, 0xFFFFFFFFL);
-                        if (p_l0 == NULL)
-                        {
-                            delete p_stream;
-                            delete p_file_io;
-                            continue;
-                        }
-
-                        p_l0->SkipData(*p_stream, EbmlHead_Context);
-                        delete p_l0;
-
-                        // find all segments in this file
-                        p_l0 = p_stream->FindNextID(KaxSegment::ClassInfos, 0xFFFFFFFFL);
-                        if (p_l0 == NULL)
-                        {
-                            delete p_stream;
-                            delete p_file_io;
-                            continue;
-                        }
-
-                        i_upper_lvl = 0;
-
-                        while (p_l0 != 0)
-                        {
-                            if (EbmlId(*p_l0) == KaxSegment::ClassInfos.GlobalId)
-                            {
-                                EbmlParser  *ep;
-                                KaxSegmentUID *p_uid = NULL;
-
-                                ep = new EbmlParser(p_stream, p_l0);
-                                bool b_this_segment_matches = false;
-                                while ((p_l1 = ep->Get()))
-                                {
-                                    if (MKV_IS_ID(p_l1, KaxInfo))
-                                    {
-                                        // find the families of this segment
-                                        KaxInfo *p_info = static_cast<KaxInfo*>(p_l1);
-
-                                        p_info->Read(*p_stream, KaxInfo::ClassInfos.Context, i_upper_lvl, p_l2, true);
+                        EbmlElement *p_l0, *p_l1, *p_l2;
+
+                        // verify the EBML Header
+                        p_l0 = p_stream->FindNextID(EbmlHead::ClassInfos, 0xFFFFFFFFL);
+                        if (p_l0 == NULL)
+                        {
+                            delete p_stream;
+                            delete p_file_io;
+                            continue;
+                        }
+
+                        p_l0->SkipData(*p_stream, EbmlHead_Context);
+                        delete p_l0;
+
+                        // find all segments in this file
+                        p_l0 = p_stream->FindNextID(KaxSegment::ClassInfos, 0xFFFFFFFFL);
+                        if (p_l0 == NULL)
+                        {
+                            delete p_stream;
+                            delete p_file_io;
+                            continue;
+                        }
+
+                        i_upper_lvl = 0;
+
+                        while (p_l0 != 0)
+                        {
+                            if (EbmlId(*p_l0) == KaxSegment::ClassInfos.GlobalId)
+                            {
+                                EbmlParser  *ep;
+                                KaxSegmentUID *p_uid = NULL;
+
+                                ep = new EbmlParser(p_stream, p_l0);
+                                bool b_this_segment_matches = false;
+                                while ((p_l1 = ep->Get()))
+                                {
+                                    if (MKV_IS_ID(p_l1, KaxInfo))
+                                    {
+                                        // find the families of this segment
+                                        KaxInfo *p_info = static_cast<KaxInfo*>(p_l1);
+
+                                        p_info->Read(*p_stream, KaxInfo::ClassInfos.Context, i_upper_lvl, p_l2, true);
                                         for( i = 0; i < p_info->ListSize() && !b_this_segment_matches; i++ )
                                         {
                                             EbmlElement *l = (*p_info)[i];
@@ -653,26 +655,26 @@
                                                 }
                                             }
                                         }
-                                        break;
-                                    }
-                                }
-
-                                if (b_this_segment_matches)
-                                {
-                                    b_keep_file_opened = true;
-                                }
-                            }
-
-                            p_l0->SkipData(*p_stream, EbmlHead_Context);
-                            delete p_l0;
-                            p_l0 = p_stream->FindNextID(KaxSegment::ClassInfos, 0xFFFFFFFFL);
-                        }
-
-                        if (!b_keep_file_opened)
-                        {
-                            delete p_stream;
-                            delete p_file_io;
-                        }
+                                        break;
+                                    }
+                                }
+
+                                if (b_this_segment_matches)
+                                {
+                                    b_keep_file_opened = true;
+                                }
+                            }
+
+                            p_l0->SkipData(*p_stream, EbmlHead_Context);
+                            delete p_l0;
+                            p_l0 = p_stream->FindNextID(KaxSegment::ClassInfos, 0xFFFFFFFFL);
+                        }
+
+                        if (!b_keep_file_opened)
+                        {
+                            delete p_stream;
+                            delete p_file_io;
+                        }
                     }
                 }
             }
@@ -1057,6 +1059,7 @@
     demux_sys_t *p_sys = p_demux->p_sys;
     int64_t     *pi64;
     double      *pf, f;
+    int         i_skp;
 
     vlc_meta_t **pp_meta;
 
@@ -1125,11 +1128,13 @@
 
         case DEMUX_SET_SEEKPOINT:
             /* FIXME do a better implementation */
-            if( p_sys->title && p_sys->title->i_seekpoint > 0 )
+            i_skp = (int)va_arg( args, int );
+
+            if( p_sys->title && i_skp < p_sys->title->i_seekpoint)
             {
-                int i_skp = (int)va_arg( args, int );
-
                 Seek( p_demux, (int64_t)p_sys->title->seekpoint[i_skp]->i_time_offset, -1);
+                p_demux->info.i_seekpoint |= INPUT_UPDATE_SEEKPOINT;
+                p_demux->info.i_seekpoint = i_skp;
                 return VLC_SUCCESS;
             }
             return VLC_EGENERIC;
@@ -1390,7 +1395,7 @@
     p_sys->cluster = NULL;
 
     /* seek without index or without date */
-    if( config_GetInt( p_demux, "mkv-seek-percent" ) || !p_sys->b_cues || i_date < 0 )
+    if( i_percent >= 0 && (config_GetInt( p_demux, "mkv-seek-percent" ) || !p_sys->b_cues || i_date < 0 ))
     {
         int64_t i_pos = i_percent * stream_Size( p_demux->s ) / 100;
 
@@ -2616,6 +2621,7 @@
     demux_sys_t *p_sys = p_demux->p_sys;
     unsigned int i;
     seekpoint_t *sk;
+    bool b_display_seekpoint = true;
 
     if( p_sys->title == NULL )
     {
@@ -2623,6 +2629,8 @@
     }
     sk = vlc_seekpoint_New();
 
+    sk->i_level = i_level;
+
     msg_Dbg( p_demux, "|   |   |   + ChapterAtom (level=%d)", i_level );
     for( i = 0; i < ca->ListSize(); i++ )
     {
@@ -2634,6 +2642,13 @@
             uint32_t i_uid = uint32( uid );
             msg_Dbg( p_demux, "|   |   |   |   + ChapterUID: 0x%x", i_uid );
         }
+        else if( MKV_IS_ID( l, KaxChapterFlagHidden ) )
+        {
+            KaxChapterFlagHidden &flag =*(KaxChapterFlagHidden*)l;
+            b_display_seekpoint = uint8( flag ) == 0;
+
+            msg_Dbg( p_demux, "|   |   |   |   + ChapterFlagHidden: %s", b_display_seekpoint ? "no":"yes" );
+        }
         else if( MKV_IS_ID( l, KaxChapterTimeStart ) )
         {
             KaxChapterTimeStart &start =*(KaxChapterTimeStart*)l;
@@ -2660,10 +2675,16 @@
 
                 if( MKV_IS_ID( l, KaxChapterString ) )
                 {
+                    std::string psz;
+                    int k;
+
                     KaxChapterString &name =*(KaxChapterString*)l;
-                    char *psz = UTF8ToStr( UTFstring( name ) );
-                    sk->psz_name = strdup( psz );
-                    msg_Dbg( p_demux, "|   |   |   |   |    + ChapterString '%s'", psz );
+                    for (k = 0; k < i_level; k++)
+                        psz += '+';
+                    psz += ' ';
+                    psz += UTF8ToStr( UTFstring( name ) );
+                    sk->psz_name = strdup( psz.c_str() );
+                    msg_Dbg( p_demux, "|   |   |   |   |    + ChapterString '%s'", UTF8ToStr(UTFstring(name)) );
                 }
                 else if( MKV_IS_ID( l, KaxChapterLanguage ) )
                 {
@@ -2686,10 +2707,18 @@
             ParseChapterAtom( p_demux, i_level+1, static_cast<EbmlMaster *>(l) );
         }
     }
-    // A start time of '0' is ok. A missing ChapterTime element is ok, too, because '0' is its default value.
-    p_sys->title->i_seekpoint++;
-    p_sys->title->seekpoint = (seekpoint_t**)realloc( p_sys->title->seekpoint, p_sys->title->i_seekpoint * sizeof( seekpoint_t* ) );
-    p_sys->title->seekpoint[p_sys->title->i_seekpoint-1] = sk;
+
+    if (b_display_seekpoint)
+    {
+        // A start time of '0' is ok. A missing ChapterTime element is ok, too, because '0' is its default value.
+        p_sys->title->i_seekpoint++;
+        p_sys->title->seekpoint = (seekpoint_t**)realloc( p_sys->title->seekpoint, p_sys->title->i_seekpoint * sizeof( seekpoint_t* ) );
+        p_sys->title->seekpoint[p_sys->title->i_seekpoint-1] = sk;
+    }
+    else
+    {
+        vlc_seekpoint_Delete(sk);
+    }
 }
 
 /*****************************************************************************
@@ -2717,6 +2746,7 @@
             EbmlMaster *E = static_cast<EbmlMaster *>(l );
             unsigned int j;
             msg_Dbg( p_demux, "|   |   + EditionEntry" );
+            p_sys->edition_ordered = false;
             for( j = 0; j < E->ListSize(); j++ )
             {
                 EbmlElement *l = (*E)[j];
@@ -2725,6 +2755,14 @@
                 {
                     ParseChapterAtom( p_demux, 0, static_cast<EbmlMaster *>(l) );
                 }
+                else if( MKV_IS_ID( l, KaxEditionUID ) )
+                {
+                    p_sys->edition_uid = uint64(*static_cast<KaxEditionUID *>(l));
+                }
+                else if( MKV_IS_ID( l, KaxEditionFlagOrdered ) )
+                {
+                    p_sys->edition_ordered = uint8(*static_cast<KaxEditionFlagOrdered *>(l)) != 0;
+                }
                 else
                 {
                     msg_Dbg( p_demux, "|   |   |   + Unknown (%s)", typeid(*l).name() );
