[vlc-commits] mkv: cleaned up dvd_chapter_codec_c::{Enter, Leave}
Filip Roséen
git at videolan.org
Sat May 7 20:33:40 CEST 2016
vlc | branch: master | Filip Roséen <filip at videolabs.io> | Fri May 6 19:08:42 2016 +0200| [d1dc261f8d2c6240ca5f79c03efd56afa78a5528] | committer: Jean-Baptiste Kempf
mkv: cleaned up dvd_chapter_codec_c::{Enter, Leave}
These two functions did effectively the same thing, with the only
difference being the debug-dagnostic and the container modified.
This patch simply joins the two together by introducing a helper
function that will conditionally handle both Enter and Leave in terms of
the commands.
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d1dc261f8d2c6240ca5f79c03efd56afa78a5528
---
modules/demux/mkv/chapter_command.cpp | 44 +++++++++++----------------------
modules/demux/mkv/chapter_command.hpp | 4 +++
2 files changed, 19 insertions(+), 29 deletions(-)
diff --git a/modules/demux/mkv/chapter_command.cpp b/modules/demux/mkv/chapter_command.cpp
index 95bc295..adcce3e 100644
--- a/modules/demux/mkv/chapter_command.cpp
+++ b/modules/demux/mkv/chapter_command.cpp
@@ -68,50 +68,36 @@ int16 dvd_chapter_codec_c::GetTitleNumber()
bool dvd_chapter_codec_c::Enter()
{
- bool f_result = false;
- std::vector<KaxChapterProcessData*>::iterator index = enter_cmds.begin();
- while ( index != enter_cmds.end() )
- {
- if ( (*index)->GetSize() )
- {
- binary *p_data = (*index)->GetBuffer();
- size_t i_size = *p_data++;
- // avoid reading too much from the buffer
- i_size = __MIN( i_size, ((*index)->GetSize() - 1) >> 3 );
- for ( ; i_size > 0; i_size--, p_data += 8 )
- {
- msg_Dbg( &sys.demuxer, "Matroska DVD enter command" );
- f_result |= sys.dvd_interpretor.Interpret( p_data );
- }
- }
- ++index;
- }
- return f_result;
+ return EnterLeaveHelper( "Matroska DVD enter command", &enter_cmds );
}
bool dvd_chapter_codec_c::Leave()
{
+ return EnterLeaveHelper( "Matroska DVD leave command", &leave_cmds );
+}
+
+bool dvd_chapter_codec_c::EnterLeaveHelper( char const * str_diag, std::vector<KaxChapterProcessData*> * p_container )
+{
bool f_result = false;
- std::vector<KaxChapterProcessData*>::iterator index = leave_cmds.begin();
- while ( index != leave_cmds.end() )
+ std::vector<KaxChapterProcessData*>::iterator it = p_container->begin ();
+ while( it != p_container->end() )
{
- if ( (*index)->GetSize() )
+ if( (*it)->GetSize() )
{
- binary *p_data = (*index)->GetBuffer();
- size_t i_size = *p_data++;
- // avoid reading too much from the buffer
- i_size = __MIN( i_size, ((*index)->GetSize() - 1) >> 3 );
- for ( ; i_size > 0; i_size--, p_data += 8 )
+ binary *p_data = (*it)->GetBuffer();
+ size_t i_size = std::min<size_t>( *p_data++, ( (*it)->GetSize() - 1 ) >> 3 ); // avoid reading too much
+ for( ; i_size > 0; i_size -=1, p_data += 8 )
{
- msg_Dbg( &sys.demuxer, "Matroska DVD leave command" );
+ msg_Dbg( &sys.demuxer, "%s", str_diag);
f_result |= sys.dvd_interpretor.Interpret( p_data );
}
}
- ++index;
+ ++it;
}
return f_result;
}
+
std::string dvd_chapter_codec_c::GetCodecName( bool f_for_title ) const
{
std::string result;
diff --git a/modules/demux/mkv/chapter_command.hpp b/modules/demux/mkv/chapter_command.hpp
index bce3835..f206e35 100644
--- a/modules/demux/mkv/chapter_command.hpp
+++ b/modules/demux/mkv/chapter_command.hpp
@@ -256,8 +256,12 @@ public:
bool Enter();
bool Leave();
+
std::string GetCodecName( bool f_for_title = false ) const;
int16 GetTitleNumber();
+
+protected:
+ bool EnterLeaveHelper( char const*, std::vector<KaxChapterProcessData*>* );
};
class matroska_script_interpretor_c
More information about the vlc-commits
mailing list