From: <sag...@us...> - 2015-06-02 14:23:21
|
Revision: 5237 http://sourceforge.net/p/modplug/code/5237 Author: saga-games Date: 2015-06-02 14:23:15 +0000 (Tue, 02 Jun 2015) Log Message: ----------- [Ref] ConvertInt2MIDI was completely unused and ConvertMIDI2Int was only used in Load_mid.cpp. Kill the former and move the latter from misc_util.h to Load_mid.cpp. Modified Paths: -------------- trunk/OpenMPT/common/misc_util.h trunk/OpenMPT/soundlib/Load_mid.cpp Modified: trunk/OpenMPT/common/misc_util.h =================================================================== --- trunk/OpenMPT/common/misc_util.h 2015-06-02 14:03:30 UTC (rev 5236) +++ trunk/OpenMPT/common/misc_util.h 2015-06-02 14:23:15 UTC (rev 5237) @@ -379,64 +379,6 @@ } -// Convert a variable-length MIDI integer held in the byte buffer <value> to a normal integer <result>. -// maxLength bytes are read from the byte buffer at max. -// Function returns how many bytes have been read. -// TODO This should report overflow errors if TOut is too small! -template <class TOut> -size_t ConvertMIDI2Int(TOut &result, uint8 *value, size_t maxLength) -//------------------------------------------------------------------ -{ - static_assert(std::numeric_limits<TOut>::is_integer == true, "Output type is a not an integer"); - - if(maxLength <= 0) - { - result = 0; - return 0; - } - size_t bytesUsed = 0; - result = 0; - uint8 b; - do - { - b = *value; - result <<= 7; - result |= (b & 0x7F); - value++; - } while (++bytesUsed < maxLength && (b & 0x80) != 0); - return bytesUsed; -} - - -// Convert an integer <value> to a variable-length MIDI integer, held in the byte buffer <result>. -// maxLength bytes are written to the byte buffer at max. -// Function returns how many bytes have been written. -template <class TIn> -size_t ConvertInt2MIDI(uint8 *result, size_t maxLength, TIn value) -//---------------------------------------------------------------- -{ - static_assert(std::numeric_limits<TIn>::is_integer == true, "Input type is a not an integer"); - - if(maxLength <= 0) - { - *result = 0; - return 0; - } - size_t bytesUsed = 0; - do - { - *result = (value & 0x7F); - value >>= 7; - if(value != 0) - { - *result |= 0x80; - } - result++; - } while (++bytesUsed < maxLength && value != 0); - return bytesUsed; -} - - namespace Util { Modified: trunk/OpenMPT/soundlib/Load_mid.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mid.cpp 2015-06-02 14:03:30 UTC (rev 5236) +++ trunk/OpenMPT/soundlib/Load_mid.cpp 2015-06-02 14:23:15 UTC (rev 5237) @@ -340,9 +340,36 @@ /////////////////////////////////////////////////////////////////////////// // Helper functions +// Convert a variable-length MIDI integer held in the byte buffer <value> to a normal integer <result>. +// maxLength bytes are read from the byte buffer at max. +// Function returns how many bytes have been read. +template <class TOut> +static size_t ConvertMIDI2Int(TOut &result, uint8 *value, size_t maxLength) +//------------------------------------------------------------------------- +{ + static_assert(std::numeric_limits<TOut>::is_integer == true, "Output type is a not an integer"); + + if(maxLength <= 0) + { + result = 0; + return 0; + } + size_t bytesUsed = 0; + result = 0; + uint8 b; + do + { + b = *value; + result <<= 7; + result |= (b & 0x7F); + value++; + } while (++bytesUsed < maxLength && (b & 0x80) != 0); + return bytesUsed; +} + // Returns MOD tempo and tick multiplier static int ConvertMidiTempo(int tempo_us, int &tickMultiplier, int importSpeed) -//------------------------------------------------------------------------------ +//----------------------------------------------------------------------------- { int nBestModTempo = 120; int nBestError = 1000000; // 1s This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |