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_GetSizeInBits(). 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 22 WebRtc_Word16 WebRtcSpl_GetSizeInBits(WebRtc_UWord32 value) 23 { 24 25 int bits = 0; 26 27 // Fast binary search to find the number of bits used 28 if ((0xFFFF0000 & value)) 29 bits = 16; 30 if ((0x0000FF00 & (value >> bits))) 31 bits += 8; 32 if ((0x000000F0 & (value >> bits))) 33 bits += 4; 34 if ((0x0000000C & (value >> bits))) 35 bits += 2; 36 if ((0x00000002 & (value >> bits))) 37 bits += 1; 38 if ((0x00000001 & (value >> bits))) 39 bits += 1; 40 41 return bits; 42 } 43 44 #endif 45