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