[vlc-commits] mkv: fixed faulty logic in matroska_Segment_c::ParseInfo

Filip Roséen git at videolan.org
Tue Mar 15 10:41:18 CET 2016


vlc | branch: master | Filip Roséen <filip at videolabs.io> | Mon Mar 14 15:06:25 2016 +0100| [10e912b6bd4f0f08d0d0254b8e64d0072adad3f2] | committer: Jean-Baptiste Kempf

mkv: fixed faulty logic in matroska_Segment_c::ParseInfo

Steve "robux4" Lhomme noticed an error in the code-refactoring that
would create a new chapter_translation_c for every subelement found,
even though the found subelements should belong to the same
chapter_translation_c.

This patch fixes that by introducing a nested dispatch-handler for the
EbmlTypes belonging to a KaxChapterTranslate.

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

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

 modules/demux/mkv/matroska_segment_parse.cpp |   51 +++++++++++++-------------
 1 file changed, 26 insertions(+), 25 deletions(-)

diff --git a/modules/demux/mkv/matroska_segment_parse.cpp b/modules/demux/mkv/matroska_segment_parse.cpp
index 41bcc78..f93782b 100644
--- a/modules/demux/mkv/matroska_segment_parse.cpp
+++ b/modules/demux/mkv/matroska_segment_parse.cpp
@@ -810,45 +810,46 @@ void matroska_segment_c::ParseInfo( KaxInfo *info )
         }
         E_CASE( KaxChapterTranslate, trans )
         {
-            KaxChapterTranslate *p_trans = &trans;
+            MKV_SWITCH_CREATE( EbmlTypeDispatcher, TranslationHandler, chapter_translation_c* )
+            {
+                MKV_SWITCH_INIT();
+
+                E_CASE( KaxChapterTranslateEditionUID, uid )
+                {
+                    vars->editions.push_back( static_cast<uint64>( uid ) );
+                }
+                E_CASE( KaxChapterTranslateCodec, codec_id )
+                {
+                    vars->codec_id = static_cast<uint32>( codec_id );
+                }
+                E_CASE( KaxChapterTranslateID, translated_id )
+                {
+                    vars->p_translated = new KaxChapterTranslateID( translated_id );
+                }
+            };
             try
             {
-                if( unlikely( p_trans->IsFiniteSize() && p_trans->GetSize() >= SIZE_MAX ) )
+                if( unlikely( trans.IsFiniteSize() && trans.GetSize() >= SIZE_MAX ) )
                 {
                     msg_Err( vars.p_demuxer, "Chapter translate too big, aborting" );
                     return;
                 }
 
-                p_trans->Read( vars.obj->es, EBML_CONTEXT(p_trans), vars.i_upper_level, vars.el, true );
+                trans.Read( vars.obj->es, EBML_CONTEXT(&trans), vars.i_upper_level, vars.el, true );
+
+                chapter_translation_c *p_translate = new chapter_translation_c();
 
-                dispatcher.iterate( p_trans->begin(), p_trans->end(), Payload( vars ) );
+                TranslationHandler::Dispatcher().iterate(
+                    trans.begin(), trans.end(), TranslationHandler::Payload( p_translate ) 
+                );
+
+                vars.obj->translations.push_back( p_translate );
             }
             catch(...)
             {
                 msg_Err( vars.p_demuxer, "Error while reading Chapter Tranlate");
             }
         }
-        E_CASE( KaxChapterTranslateEditionUID, uid )
-        {
-            chapter_translation_c *p_translate = new chapter_translation_c();
-            p_translate->editions.push_back( static_cast<uint64>( uid ) );
-
-            vars.obj->translations.push_back( p_translate );
-        }
-        E_CASE( KaxChapterTranslateCodec, codec_id )
-        {
-            chapter_translation_c *p_translate = new chapter_translation_c();
-            p_translate->codec_id = static_cast<uint32>( codec_id );
-
-            vars.obj->translations.push_back( p_translate );
-        }
-        E_CASE( KaxChapterTranslateID, translated_id )
-        {
-            chapter_translation_c *p_translate = new chapter_translation_c();
-            p_translate->p_translated = new KaxChapterTranslateID( translated_id );
-
-            vars.obj->translations.push_back( p_translate );
-        }
         E_CASE( EbmlVoid, )
         {
             VLC_UNUSED( vars );



More information about the vlc-commits mailing list