1/* 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 12/* 13 * This file contains the function WebRtcSpl_SubSatW16(). 14 * The description header can be found in signal_processing_library.h 15 * 16 */ 17 18#include "signal_processing_library.h" 19 20#ifndef SPL_NO_DOUBLE_IMPLEMENTATIONS 21#ifndef XSCALE_OPT 22 23WebRtc_Word16 WebRtcSpl_SubSatW16(WebRtc_Word16 var1, WebRtc_Word16 var2) 24{ 25 WebRtc_Word32 l_diff; 26 WebRtc_Word16 s_diff; 27 28 // perform subtraction 29 l_diff = (WebRtc_Word32)var1 - (WebRtc_Word32)var2; 30 31 // default setting 32 s_diff = (WebRtc_Word16)l_diff; 33 34 // check for overflow 35 if (l_diff > (WebRtc_Word32)32767) 36 s_diff = (WebRtc_Word16)32767; 37 38 // check for underflow 39 if (l_diff < (WebRtc_Word32)-32768) 40 s_diff = (WebRtc_Word16)-32768; 41 42 return s_diff; 43} 44 45#else 46#pragma message(">> WebRtcSpl_SubSatW16.c is excluded from this build") 47#endif // XSCALE_OPT 48#endif // SPL_NO_DOUBLE_IMPLEMENTATIONS 49