os/mm/devsound/sounddevbt/src/Plugin/Codec/SBCEncoder/BtSBCConst.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/devsound/sounddevbt/src/Plugin/Codec/SBCEncoder/BtSBCConst.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,180 @@
     1.4 +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#ifndef __SBCCONST_H__
    1.20 +#define __SBCCONST_H__
    1.21 +
    1.22 +/**
    1.23 +SBC Syncword, used in the begin of each sbc frame to identify sbc frame, 
    1.24 +it's value is always 0x9c
    1.25 +*/
    1.26 +const TUint8 KSBCFrameSyncWord = 0x9c;
    1.27 +
    1.28 +/**
    1.29 +This table is used to calculate bit allocation for 4 subbands sbc frame 
    1.30 +with Loudness allocation method
    1.31 +*/
    1.32 +const TInt8 KSBCOffset4[4][4] =	
    1.33 +	{
    1.34 +		{-1, 0, 0, 0}, 	// fs = 16000
    1.35 +		{-2, 0, 0, 1}, 	// fs = 32000
    1.36 +		{-2, 0, 0, 1}, 	// fs = 44100
    1.37 +		{-2, 0, 0, 1}	// fs = 48000
    1.38 +	};
    1.39 +		
    1.40 +/**
    1.41 +This table is used to calculate bit allocation for 8 subbands sbc frame 
    1.42 +with Loudness allocation method
    1.43 +*/
    1.44 +const TInt8 KSBCOffset8[4][8] =	
    1.45 +	{
    1.46 +		{-2, 0, 0, 0, 0, 0, 0, 1}, 	// fs = 16000
    1.47 +		{-3, 0, 0, 0, 0, 0, 1, 2}, 	// fs = 32000
    1.48 +		{-4, 0, 0, 0, 0, 0, 1, 2}, 	// fs = 44100
    1.49 +		{-4, 0, 0, 0, 0, 0, 1, 2}	// fs = 48000
    1.50 +	};
    1.51 +
    1.52 +/**
    1.53 +2^32, scale value of Table KSBCProto4 and KSBCProto8.
    1.54 +*/
    1.55 +const TUint8 KSBCProtoBitsShift = 32;
    1.56 +
    1.57 +/**
    1.58 +Table KSBCProto4 is derived form Table Proto_4_40 (see A2DP spec for detail) 
    1.59 +by scaling up by 2^32, it is for the Analysis process for 4 subbands sbc frames, 
    1.60 +we are using integer numbers for high speed, after the calculation the results 
    1.61 +will be scaled down by the same value.  
    1.62 +*/
    1.63 +const TInt32 KSBCProto4[40] = 
    1.64 +	{
    1.65 +	           0,     2304460,     6407591,    11741191, 
    1.66 +	    16480657,    16716234,     8013623,   -13143128, 
    1.67 +	    46874251,    87782726,   124020356,   138271872, 
    1.68 +	   111139929,    26338680,  -123788377,  -333488531, 
    1.69 +	   582368677,   837466400,  1059296397,  1210442915, 
    1.70 +	  1264074726,  1210442915,  1059296397,   837466400, 
    1.71 +	  -582368677,  -333488531,  -123788377,    26338680, 
    1.72 +	   111139929,   138271872,   124020356,    87782726, 
    1.73 +	   -46874251,   -13143128,     8013623,    16716234, 
    1.74 +	    16480657,    11741191,     6407591,     2304460
    1.75 +	};
    1.76 +
    1.77 +/**
    1.78 +Table KSBCProto8 is derived form Table Proto_8_80 (see A2DP spec for detail) 
    1.79 +by scaling up by 2^32, it is for the Analysis process for 8 subbands sbc frames, 
    1.80 +we are using integer numbers for high speed, after the calculation the results 
    1.81 +will be scaled down by the same value.  
    1.82 +*/
    1.83 +const TInt32 KSBCProto8[80] = 
    1.84 +	{
    1.85 +	           0,      672486,     1474275,     2382076, 
    1.86 +	     3538707,     4895941,     6341097,     7661007, 
    1.87 +	     8640724,     9035408,     8566508,     6943084, 
    1.88 +	     3874724,     -767963,    -7085541,   -15020250, 
    1.89 +	    24307345,    34486060,    44918676,    54748951, 
    1.90 +	    62932121,    68309566,    69668008,    65792073, 
    1.91 +	    55564768,    38042997,    12558847,   -21113115, 
    1.92 +	   -62880072,  -112141060,  -167826440,  -228437728, 
    1.93 +	   292053237,   356416821,   419083117,   477586143, 
    1.94 +	   529417202,   572366304,   604531701,   624444638, 
    1.95 +	   631167211,   624444638,   604531701,   572366304, 
    1.96 +	   529417202,   477586143,   419083117,   356416821, 
    1.97 +	  -292053237,  -228437728,  -167826440,  -112141060, 
    1.98 +	   -62880072,   -21113115,    12558847,    38042997, 
    1.99 +	    55564768,    65792073,    69668008,    68309566, 
   1.100 +	    62932121,    54748951,    44918676,    34486060, 
   1.101 +	   -24307345,   -15020250,    -7085541,     -767963, 
   1.102 +	     3874724,     6943084,     8566508,     9035408, 
   1.103 +	     8640724,     7661007,     6341097,     4895941, 
   1.104 +	     3538707,     2382076,     1474275,      672486
   1.105 +	};
   1.106 +
   1.107 +
   1.108 +/**
   1.109 +2^30, scale value of Table KSBCAnalysisMatrix4 and KSBCAnalysisMatrix8.
   1.110 +*/
   1.111 +const TUint8 KSBCAnalysisMatrixBitsShift = 30;
   1.112 +
   1.113 +/**
   1.114 +Table of cos((i + 0.5) * (k - 2) * PI / 4) * 2^30
   1.115 +This table is used in Analysis process for 4 subbands, here we are using 
   1.116 +integer values instead of real values for high speed, the values are scaled 
   1.117 +up by 2^30, after calculation the results will be scaled down by the same value.  
   1.118 +*/
   1.119 +const TInt32 KSBCAnalysisMatrix4[4][8] =
   1.120 +	{
   1.121 +		{  759250125,   992008094,  1073741824,   992008094, 
   1.122 +		   759250125,   410903207,           0,  -410903207 },
   1.123 +		   
   1.124 +		{ -759250125,   410903207,  1073741824,   410903207, 
   1.125 +		  -759250125,  -992008094,           0,   992008094 },
   1.126 +		  
   1.127 +		{ -759250125,  -410903207,  1073741824,  -410903207, 
   1.128 +		  -759250125,   992008094,           0,  -992008094 },
   1.129 +		  
   1.130 +		{  759250125,  -992008094,  1073741824,  -992008094, 
   1.131 +		   759250125,  -410903207,           0,   410903207 }
   1.132 +	};
   1.133 +
   1.134 +/**
   1.135 +Table of cos((i + 0.5) * (k - 4) * PI / 8) * 2^30
   1.136 +This table is used in Analysis process for 8 subbands, here we are using 
   1.137 +integer values instead of real values for high speed, the values are scaled 
   1.138 +up by 2^30, after calculation the results will be scaled down by the same value.  
   1.139 +*/
   1.140 +const TInt32 KSBCAnalysisMatrix8[8][16] =
   1.141 +	{
   1.142 +		{  759250125,   892783698,   992008094,  1053110176, 
   1.143 +		  1073741824,  1053110176,   992008094,   892783698, 
   1.144 +		   759250125,   596538995,   410903207,   209476638, 
   1.145 +		           0,  -209476638,  -410903207,  -596538995 },
   1.146 +		           
   1.147 +		{ -759250125,  -209476638,   410903207,   892783698, 
   1.148 +		  1073741824,   892783698,   410903207,  -209476638, 
   1.149 +		  -759250125, -1053110176,  -992008094,  -596538995, 
   1.150 +		           0,   596538995,   992008094,  1053110176 },
   1.151 +		          
   1.152 +		{ -759250125, -1053110176,  -410903207,   596538995, 
   1.153 +		  1073741824,   596538995,  -410903207, -1053110176, 
   1.154 +		  -759250125,   209476638,   992008094,   892783698, 
   1.155 +		           0,  -892783698,  -992008094,  -209476638 },
   1.156 +		           
   1.157 +		{  759250125,  -596538995,  -992008094,   209476638, 
   1.158 +		  1073741824,   209476638,  -992008094,  -596538995, 
   1.159 +		   759250125,   892783698,  -410903207, -1053110176, 
   1.160 +		           0,  1053110176,   410903207,  -892783698 },
   1.161 +		          
   1.162 +		{  759250125,   596538995,  -992008094,  -209476638, 
   1.163 +		  1073741824,  -209476638,  -992008094,   596538995, 
   1.164 +		   759250125,  -892783698,  -410903207,  1053110176, 
   1.165 +		           0, -1053110176,   410903207,   892783698 },
   1.166 +		           
   1.167 +		{ -759250125,  1053110176,  -410903207,  -596538995, 
   1.168 +		  1073741824,  -596538995,  -410903207,  1053110176, 
   1.169 +		  -759250125,  -209476638,   992008094,  -892783698, 
   1.170 +		           0,   892783698,  -992008094,   209476638 },
   1.171 +		          
   1.172 +		{ -759250125,   209476638,   410903207,  -892783698, 
   1.173 +		  1073741824,  -892783698,   410903207,   209476638, 
   1.174 +		  -759250125,  1053110176,  -992008094,   596538995, 
   1.175 +		           0,  -596538995,   992008094, -1053110176 },
   1.176 +		          
   1.177 +		{  759250125,  -892783698,   992008094, -1053110176, 
   1.178 +		  1073741824, -1053110176,   992008094,  -892783698, 
   1.179 +		   759250125,  -596538995,   410903207,  -209476638, 
   1.180 +		           0,   209476638,  -410903207,   596538995 }
   1.181 +	};
   1.182 +		
   1.183 +#endif // __SBCCONST_H__