1 /* $NetBSD$ */ 2 3 /*- 4 * Copyright (c) 2015 Nathanial Sloss <nathanialsloss@yahoo.com.au> 5 * 6 * This software is dedicated to the memory of - 7 * Baron James Anlezark (Barry) - 1 Jan 1949 - 13 May 2012. 8 * 9 * Barry was a man who loved his music. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 #ifndef _SBC_ENCODE_H_ 34 #define _SBC_ENCODE_H_ 35 36 #define MIN_BITPOOL 2 37 #define DEFAULT_MAXBPOOL 250 38 39 /* 40 * SBC header format 41 */ 42 struct sbc_header { 43 uint8_t id; 44 uint8_t id2; 45 uint8_t seqnumMSB; 46 uint8_t seqnumLSB; 47 uint8_t ts3; 48 uint8_t ts2; 49 uint8_t ts1; 50 uint8_t ts0; 51 uint8_t reserved3; 52 uint8_t reserved2; 53 uint8_t reserved1; 54 uint8_t reserved0; 55 uint8_t numFrames; 56 }; 57 58 struct sbc_encode { 59 int16_t music_data[256]; 60 uint8_t data[1024]; 61 uint8_t *rem_data_ptr; 62 int rem_data_len; 63 int rem_data_frames; 64 int bits[2][8]; 65 float output[256]; 66 float left[160]; 67 float right[160]; 68 float samples[16][2][8]; 69 uint32_t rem_len; 70 uint32_t rem_off; 71 uint32_t bitoffset; 72 uint32_t maxoffset; 73 uint32_t crc; 74 uint16_t framesamples; 75 uint8_t scalefactor[2][8]; 76 uint8_t channels; 77 uint8_t bands; 78 uint8_t blocks; 79 uint8_t join; 80 }; 81 82 #endif /* _SBC_ENCODE_H_ */ 83