1 /* 2 * 3 * Bluetooth low-complexity, subband codec (SBC) library 4 * 5 * Copyright (C) 2004-2009 Marcel Holtmann <marcel@holtmann.org> 6 * 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 * 22 */ 23 24 #include <byteswap.h> 25 26 #if __BYTE_ORDER == __LITTLE_ENDIAN 27 #define COMPOSE_ID(a,b,c,d) ((a) | ((b)<<8) | ((c)<<16) | ((d)<<24)) 28 #define LE_SHORT(v) (v) 29 #define LE_INT(v) (v) 30 #define BE_SHORT(v) bswap_16(v) 31 #define BE_INT(v) bswap_32(v) 32 #elif __BYTE_ORDER == __BIG_ENDIAN 33 #define COMPOSE_ID(a,b,c,d) ((d) | ((c)<<8) | ((b)<<16) | ((a)<<24)) 34 #define LE_SHORT(v) bswap_16(v) 35 #define LE_INT(v) bswap_32(v) 36 #define BE_SHORT(v) (v) 37 #define BE_INT(v) (v) 38 #else 39 #error "Wrong endian" 40 #endif 41 42 #define AU_MAGIC COMPOSE_ID('.','s','n','d') 43 44 #define AU_FMT_ULAW 1 45 #define AU_FMT_LIN8 2 46 #define AU_FMT_LIN16 3 47 48 struct au_header { 49 uint32_t magic; /* '.snd' */ 50 uint32_t hdr_size; /* size of header (min 24) */ 51 uint32_t data_size; /* size of data */ 52 uint32_t encoding; /* see to AU_FMT_XXXX */ 53 uint32_t sample_rate; /* sample rate */ 54 uint32_t channels; /* number of channels (voices) */ 55 }; 56