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 Renesas

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers endswap.h Source File

endswap.h

00001 /* libFLAC - Free Lossless Audio Codec library
00002  * Copyright (C) 2012-2014  Xiph.org Foundation
00003  *
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following conditions
00006  * are met:
00007  *
00008  * - Redistributions of source code must retain the above copyright
00009  * notice, this list of conditions and the following disclaimer.
00010  *
00011  * - Redistributions in binary form must reproduce the above copyright
00012  * notice, this list of conditions and the following disclaimer in the
00013  * documentation and/or other materials provided with the distribution.
00014  *
00015  * - Neither the name of the Xiph.org Foundation nor the names of its
00016  * contributors may be used to endorse or promote products derived from
00017  * this software without specific prior written permission.
00018  *
00019  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00020  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00021  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00022  * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
00023  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00024  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00025  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00026  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00027  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00028  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00029  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00030  */
00031 
00032 /* It is assumed that this header will be included after "config.h". */
00033 
00034 #if HAVE_BSWAP32            /* GCC and Clang */
00035 
00036 /* GCC prior to 4.8 didn't provide bswap16 on x86_64 */
00037 #if ! HAVE_BSWAP16
00038 static inline unsigned short __builtin_bswap16(unsigned short a)
00039 {
00040     return (a<<8)|(a>>8);
00041 }
00042 #endif
00043 
00044 #define ENDSWAP_16(x)       (__builtin_bswap16 (x))
00045 #define ENDSWAP_32(x)       (__builtin_bswap32 (x))
00046 
00047 #elif defined _MSC_VER      /* Windows. Apparently in <stdlib.h>. */
00048 
00049 #define ENDSWAP_16(x)       (_byteswap_ushort (x))
00050 #define ENDSWAP_32(x)       (_byteswap_ulong (x))
00051 
00052 #elif defined HAVE_BYTESWAP_H       /* Linux */
00053 
00054 #include <byteswap.h>
00055 
00056 #define ENDSWAP_16(x)       (bswap_16 (x))
00057 #define ENDSWAP_32(x)       (bswap_32 (x))
00058 
00059 #else
00060 
00061 #define ENDSWAP_16(x)       ((((x) >> 8) & 0xFF) | (((x) & 0xFF) << 8))
00062 #define ENDSWAP_32(x)       ((((x) >> 24) & 0xFF) | (((x) >> 8) & 0xFF00) | (((x) & 0xFF00) << 8) | (((x) & 0xFF) << 24))
00063 
00064 #endif
00065 
00066 
00067 /* Host to little-endian byte swapping. */
00068 #if CPU_IS_BIG_ENDIAN
00069 
00070 #define H2LE_16(x)      ENDSWAP_16 (x)
00071 #define H2LE_32(x)      ENDSWAP_32 (x)
00072 
00073 #else
00074 
00075 #define H2LE_16(x)      (x)
00076 #define H2LE_32(x)      (x)
00077 
00078 #endif