The "GR-PEACH_Audio_Playback_7InchLCD_Sample" is a sample code that can provides high-resolution audio playback of FLAC format files. It also allows the user to audio-playback control functions such as play, pause, and stop by manipulating key switches.
Dependencies: GR-PEACH_video R_BSP TLV320_RBSP USBHost_custom
Fork of GR-PEACH_Audio_Playback_Sample by
bitmath.c
00001 /* libFLAC - Free Lossless Audio Codec library 00002 * Copyright (C) 2001-2009 Josh Coalson 00003 * Copyright (C) 2011-2014 Xiph.Org Foundation 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions 00007 * are met: 00008 * 00009 * - Redistributions of source code must retain the above copyright 00010 * notice, this list of conditions and the following disclaimer. 00011 * 00012 * - Redistributions in binary form must reproduce the above copyright 00013 * notice, this list of conditions and the following disclaimer in the 00014 * documentation and/or other materials provided with the distribution. 00015 * 00016 * - Neither the name of the Xiph.org Foundation nor the names of its 00017 * contributors may be used to endorse or promote products derived from 00018 * this software without specific prior written permission. 00019 * 00020 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00021 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00022 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00023 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 00024 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00025 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00026 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00027 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00028 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00029 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00030 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00031 */ 00032 00033 #ifdef HAVE_CONFIG_H 00034 # include <config.h> 00035 #endif 00036 00037 #include "private/bitmath.h" 00038 00039 /* An example of what FLAC__bitmath_silog2() computes: 00040 * 00041 * silog2(-10) = 5 00042 * silog2(- 9) = 5 00043 * silog2(- 8) = 4 00044 * silog2(- 7) = 4 00045 * silog2(- 6) = 4 00046 * silog2(- 5) = 4 00047 * silog2(- 4) = 3 00048 * silog2(- 3) = 3 00049 * silog2(- 2) = 2 00050 * silog2(- 1) = 2 00051 * silog2( 0) = 0 00052 * silog2( 1) = 2 00053 * silog2( 2) = 3 00054 * silog2( 3) = 3 00055 * silog2( 4) = 4 00056 * silog2( 5) = 4 00057 * silog2( 6) = 4 00058 * silog2( 7) = 4 00059 * silog2( 8) = 5 00060 * silog2( 9) = 5 00061 * silog2( 10) = 5 00062 */ 00063 unsigned FLAC__bitmath_silog2(int v) 00064 { 00065 while(1) { 00066 if(v == 0) { 00067 return 0; 00068 } 00069 else if(v > 0) { 00070 unsigned l = 0; 00071 while(v) { 00072 l++; 00073 v >>= 1; 00074 } 00075 return l+1; 00076 } 00077 else if(v == -1) { 00078 return 2; 00079 } 00080 else { 00081 v++; 00082 v = -v; 00083 } 00084 } 00085 } 00086 00087 unsigned FLAC__bitmath_silog2_wide(FLAC__int64 v) 00088 { 00089 while(1) { 00090 if(v == 0) { 00091 return 0; 00092 } 00093 else if(v > 0) { 00094 unsigned l = 0; 00095 while(v) { 00096 l++; 00097 v >>= 1; 00098 } 00099 return l+1; 00100 } 00101 else if(v == -1) { 00102 return 2; 00103 } 00104 else { 00105 v++; 00106 v = -v; 00107 } 00108 } 00109 }
Generated on Tue Jul 12 2022 19:32:28 by 1.7.2