19cab9fdeSChristos Margiolis /* $NetBSD$ */ 29cab9fdeSChristos Margiolis 39cab9fdeSChristos Margiolis /*- 49cab9fdeSChristos Margiolis * Copyright (c) 2015 Nathanial Sloss <nathanialsloss@yahoo.com.au> 59cab9fdeSChristos Margiolis * 69cab9fdeSChristos Margiolis * This software is dedicated to the memory of - 79cab9fdeSChristos Margiolis * Baron James Anlezark (Barry) - 1 Jan 1949 - 13 May 2012. 89cab9fdeSChristos Margiolis * 99cab9fdeSChristos Margiolis * Barry was a man who loved his music. 109cab9fdeSChristos Margiolis * 119cab9fdeSChristos Margiolis * Redistribution and use in source and binary forms, with or without 129cab9fdeSChristos Margiolis * modification, are permitted provided that the following conditions 139cab9fdeSChristos Margiolis * are met: 149cab9fdeSChristos Margiolis * 1. Redistributions of source code must retain the above copyright 159cab9fdeSChristos Margiolis * notice, this list of conditions and the following disclaimer. 169cab9fdeSChristos Margiolis * 2. Redistributions in binary form must reproduce the above copyright 179cab9fdeSChristos Margiolis * notice, this list of conditions and the following disclaimer in the 189cab9fdeSChristos Margiolis * documentation and/or other materials provided with the distribution. 199cab9fdeSChristos Margiolis * 209cab9fdeSChristos Margiolis * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 219cab9fdeSChristos Margiolis * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 229cab9fdeSChristos Margiolis * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 239cab9fdeSChristos Margiolis * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 249cab9fdeSChristos Margiolis * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 259cab9fdeSChristos Margiolis * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 269cab9fdeSChristos Margiolis * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 279cab9fdeSChristos Margiolis * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 289cab9fdeSChristos Margiolis * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 299cab9fdeSChristos Margiolis * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 309cab9fdeSChristos Margiolis * POSSIBILITY OF SUCH DAMAGE. 319cab9fdeSChristos Margiolis */ 329cab9fdeSChristos Margiolis 339cab9fdeSChristos Margiolis #ifndef _SBC_ENCODE_H_ 349cab9fdeSChristos Margiolis #define _SBC_ENCODE_H_ 359cab9fdeSChristos Margiolis 369cab9fdeSChristos Margiolis #define MIN_BITPOOL 2 379cab9fdeSChristos Margiolis #define DEFAULT_MAXBPOOL 250 389cab9fdeSChristos Margiolis 399cab9fdeSChristos Margiolis /* 409cab9fdeSChristos Margiolis * SBC header format 419cab9fdeSChristos Margiolis */ 429cab9fdeSChristos Margiolis struct sbc_header { 439cab9fdeSChristos Margiolis uint8_t id; 449cab9fdeSChristos Margiolis uint8_t id2; 459cab9fdeSChristos Margiolis uint8_t seqnumMSB; 469cab9fdeSChristos Margiolis uint8_t seqnumLSB; 479cab9fdeSChristos Margiolis uint8_t ts3; 489cab9fdeSChristos Margiolis uint8_t ts2; 499cab9fdeSChristos Margiolis uint8_t ts1; 509cab9fdeSChristos Margiolis uint8_t ts0; 519cab9fdeSChristos Margiolis uint8_t reserved3; 529cab9fdeSChristos Margiolis uint8_t reserved2; 539cab9fdeSChristos Margiolis uint8_t reserved1; 549cab9fdeSChristos Margiolis uint8_t reserved0; 559cab9fdeSChristos Margiolis uint8_t numFrames; 569cab9fdeSChristos Margiolis }; 579cab9fdeSChristos Margiolis 589cab9fdeSChristos Margiolis struct sbc_encode { 599cab9fdeSChristos Margiolis int16_t music_data[256]; 609cab9fdeSChristos Margiolis uint8_t data[1024]; 619cab9fdeSChristos Margiolis uint8_t *rem_data_ptr; 629cab9fdeSChristos Margiolis int rem_data_len; 639cab9fdeSChristos Margiolis int rem_data_frames; 649cab9fdeSChristos Margiolis int bits[2][8]; 659cab9fdeSChristos Margiolis float output[256]; 669cab9fdeSChristos Margiolis float left[160]; 679cab9fdeSChristos Margiolis float right[160]; 689cab9fdeSChristos Margiolis float samples[16][2][8]; 699cab9fdeSChristos Margiolis uint32_t rem_len; 709cab9fdeSChristos Margiolis uint32_t rem_off; 719cab9fdeSChristos Margiolis uint32_t bitoffset; 729cab9fdeSChristos Margiolis uint32_t maxoffset; 739cab9fdeSChristos Margiolis uint32_t crc; 749cab9fdeSChristos Margiolis uint16_t framesamples; 759cab9fdeSChristos Margiolis uint8_t scalefactor[2][8]; 769cab9fdeSChristos Margiolis uint8_t channels; 779cab9fdeSChristos Margiolis uint8_t bands; 789cab9fdeSChristos Margiolis uint8_t blocks; 799cab9fdeSChristos Margiolis uint8_t join; 809cab9fdeSChristos Margiolis }; 819cab9fdeSChristos Margiolis 829cab9fdeSChristos Margiolis #endif /* _SBC_ENCODE_H_ */ 83