/*********************************************************************** Copyright (c) 2006-2011, Skype Limited. All rights reserved. Copyright (C) 2012 Xiph.Org Foundation Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of Internet Society, IETF or IETF Trust, nor the names of specific contributors, may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
#ifndef MACRO_DEBUG_H #define MACRO_DEBUG_H
/* Redefine macro functions with extensive assertion in DEBUG mode.
As functions can't be undefined, this file can't work with SigProcFIX_MacroCount.h */
#if ( defined (FIXED_DEBUG) || ( 0 && defined (_DEBUG) ) ) && !defined (silk_MACRO_COUNT)
ret = a + b; if ( ret != silk_ADD_SAT16( a, b ) )
{
fprintf (stderr, "silk_ADD16(%d, %d) in %s: line %d\n", a, b, file, line); #ifdef FIXED_DEBUG_ASSERT
silk_assert( 0 ); #endif
} return ret;
}
ret = (opus_int32)((opus_uint32)a + (opus_uint32)b); if ( ret != silk_ADD_SAT32( a, b ) )
{
fprintf (stderr, "silk_ADD32(%d, %d) in %s: line %d\n", a, b, file, line); #ifdef FIXED_DEBUG_ASSERT
silk_assert( 0 ); #endif
} return ret;
}
ret = a + b; if ( ret != silk_ADD_SAT64( a, b ) )
{
fprintf (stderr, "silk_ADD64(%lld, %lld) in %s: line %d\n", (longlong)a, (longlong)b, file, line); #ifdef FIXED_DEBUG_ASSERT
silk_assert( 0 ); #endif
} return ret;
}
ret = a - b; if ( ret != silk_SUB_SAT16( a, b ) )
{
fprintf (stderr, "silk_SUB16(%d, %d) in %s: line %d\n", a, b, file, line); #ifdef FIXED_DEBUG_ASSERT
silk_assert( 0 ); #endif
} return ret;
}
ret = a - (opus_int64)b; if ( ret != silk_SUB_SAT32( a, b ) )
{
fprintf (stderr, "silk_SUB32(%d, %d) in %s: line %d\n", a, b, file, line); #ifdef FIXED_DEBUG_ASSERT
silk_assert( 0 ); #endif
} return ret;
}
ret = a - b; if ( ret != silk_SUB_SAT64( a, b ) )
{
fprintf (stderr, "silk_SUB64(%lld, %lld) in %s: line %d\n", (longlong)a, (longlong)b, file, line); #ifdef FIXED_DEBUG_ASSERT
silk_assert( 0 ); #endif
} return ret;
}
tmp = silk_SMULWW( b32, c32 );
ret = silk_ADD32( a32, tmp ); if ( ret != silk_ADD_SAT32( a32, tmp ) )
{
fprintf (stderr, "silk_SMLAWW(%d, %d, %d) in %s: line %d\n", a32, b32, c32, file, line); #ifdef FIXED_DEBUG_ASSERT
silk_assert( 0 ); #endif
} return ret;
}
/* no checking needed for silk_SMULL no checking needed for silk_SMLAL no checking needed for silk_SMLALBB no checking needed for SigProcFIX_CLZ16
no checking needed for SigProcFIX_CLZ32*/
/* no checking needed for silk_SAT8 no checking needed for silk_SAT16 no checking needed for silk_SAT32 no checking needed for silk_POS_SAT32 no checking needed for silk_ADD_POS_SAT8 no checking needed for silk_ADD_POS_SAT16
no checking needed for silk_ADD_POS_SAT32 */
#undef silk_RSHIFT_ROUND #define silk_RSHIFT_ROUND(a,b) silk_RSHIFT_ROUND_((a), (b), __FILE__, __LINE__) static OPUS_INLINE opus_int32 silk_RSHIFT_ROUND_(opus_int32 a, opus_int32 shift, char *file, int line){
opus_int32 ret;
ret = shift == 1 ? (a >> 1) + (a & 1) : ((a >> (shift - 1)) + 1) >> 1; /* the macro definition can't handle a shift of zero */ if ( (shift <= 0) || (shift>31) || ((opus_int64)ret != ((opus_int64)a + ((opus_int64)1 << (shift - 1))) >> shift) )
{
fprintf (stderr, "silk_RSHIFT_ROUND(%d, %d) in %s: line %d\n", a, shift, file, line); #ifdef FIXED_DEBUG_ASSERT
silk_assert( 0 ); #endif
} return ret;
}
#undef silk_RSHIFT_ROUND64 #define silk_RSHIFT_ROUND64(a,b) silk_RSHIFT_ROUND64_((a), (b), __FILE__, __LINE__) static OPUS_INLINE opus_int64 silk_RSHIFT_ROUND64_(opus_int64 a, opus_int32 shift, char*file, int line){
opus_int64 ret; /* the macro definition can't handle a shift of zero */ if ( (shift <= 0) || (shift>=64) )
{
fprintf (stderr, "silk_RSHIFT_ROUND64(%lld, %d) in %s: line %d\n", (longlong)a, shift, file, line); #ifdef FIXED_DEBUG_ASSERT
silk_assert( 0 ); #endif
}
ret = shift == 1 ? (a >> 1) + (a & 1) : ((a >> (shift - 1)) + 1) >> 1; return ret;
}
/* silk_abs is used on floats also, so doesn't work... */ /*#undef silk_abs static OPUS_INLINE opus_int32 silk_abs(opus_int32 a){ silk_assert(a != 0x80000000); return (((a) > 0) ? (a) : -(a)); // Be careful, silk_abs returns wrong when input equals to silk_intXX_MIN
}*/
#undef silk_abs_int64 #define silk_abs_int64(a) silk_abs_int64_((a), __FILE__, __LINE__) static OPUS_INLINE opus_int64 silk_abs_int64_(opus_int64 a, char *file, int line){ if ( a == silk_int64_MIN )
{
fprintf (stderr, "silk_abs_int64(%lld) in %s: line %d\n", (longlong)a, file, line); #ifdef FIXED_DEBUG_ASSERT
silk_assert( 0 ); #endif
} return (((a) > 0) ? (a) : -(a)); /* Be careful, silk_abs returns wrong when input equals to silk_intXX_MIN */
}
#undef silk_abs_int32 #define silk_abs_int32(a) silk_abs_int32_((a), __FILE__, __LINE__) static OPUS_INLINE opus_int32 silk_abs_int32_(opus_int32 a, char *file, int line){ if ( a == silk_int32_MIN )
{
fprintf (stderr, "silk_abs_int32(%d) in %s: line %d\n", a, file, line); #ifdef FIXED_DEBUG_ASSERT
silk_assert( 0 ); #endif
} return silk_abs(a);
}
#undef silk_CHECK_FIT8 #define silk_CHECK_FIT8(a) silk_CHECK_FIT8_((a), __FILE__, __LINE__) static OPUS_INLINE opus_int8 silk_CHECK_FIT8_( opus_int64 a, char *file, int line ){
opus_int8 ret;
ret = (opus_int8)a; if ( (opus_int64)ret != a )
{
fprintf (stderr, "silk_CHECK_FIT8(%lld) in %s: line %d\n", (longlong)a, file, line); #ifdef FIXED_DEBUG_ASSERT
silk_assert( 0 ); #endif
} return( ret );
}
#undef silk_CHECK_FIT16 #define silk_CHECK_FIT16(a) silk_CHECK_FIT16_((a), __FILE__, __LINE__) static OPUS_INLINE opus_int16 silk_CHECK_FIT16_( opus_int64 a, char *file, int line ){
opus_int16 ret;
ret = (opus_int16)a; if ( (opus_int64)ret != a )
{
fprintf (stderr, "silk_CHECK_FIT16(%lld) in %s: line %d\n", (longlong)a, file, line); #ifdef FIXED_DEBUG_ASSERT
silk_assert( 0 ); #endif
} return( ret );
}
#undef silk_CHECK_FIT32 #define silk_CHECK_FIT32(a) silk_CHECK_FIT32_((a), __FILE__, __LINE__) static OPUS_INLINE opus_int32 silk_CHECK_FIT32_( opus_int64 a, char *file, int line ){
opus_int32 ret;
ret = (opus_int32)a; if ( (opus_int64)ret != a )
{
fprintf (stderr, "silk_CHECK_FIT32(%lld) in %s: line %d\n", (longlong)a, file, line); #ifdef FIXED_DEBUG_ASSERT
silk_assert( 0 ); #endif
} return( ret );
}
/* no checking for silk_NSHIFT_MUL_32_32 no checking for silk_NSHIFT_MUL_16_16 no checking needed for silk_min no checking needed for silk_max no checking needed for silk_sign
*/
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.