devsound/devsoundrefplugin/src/codec/sbcencoder/SBCConst.h
changeset 0 40261b775718
equal deleted inserted replaced
-1:000000000000 0:40261b775718
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef __SBCCONST_H__
       
    17 #define __SBCCONST_H__
       
    18 
       
    19 /**
       
    20 SBC Syncword, used in the begin of each sbc frame to identify sbc frame, 
       
    21 it's value is always 0x9c
       
    22 */
       
    23 const TUint8 KSBCFrameSyncWord = 0x9c;
       
    24 
       
    25 /**
       
    26 This table is used to calculate bit allocation for 4 subbands sbc frame 
       
    27 with Loudness allocation method
       
    28 */
       
    29 const TInt8 KSBCOffset4[4][4] =	
       
    30 	{
       
    31 		{-1, 0, 0, 0}, 	// fs = 16000
       
    32 		{-2, 0, 0, 1}, 	// fs = 32000
       
    33 		{-2, 0, 0, 1}, 	// fs = 44100
       
    34 		{-2, 0, 0, 1}	// fs = 48000
       
    35 	};
       
    36 		
       
    37 /**
       
    38 This table is used to calculate bit allocation for 8 subbands sbc frame 
       
    39 with Loudness allocation method
       
    40 */
       
    41 const TInt8 KSBCOffset8[4][8] =	
       
    42 	{
       
    43 		{-2, 0, 0, 0, 0, 0, 0, 1}, 	// fs = 16000
       
    44 		{-3, 0, 0, 0, 0, 0, 1, 2}, 	// fs = 32000
       
    45 		{-4, 0, 0, 0, 0, 0, 1, 2}, 	// fs = 44100
       
    46 		{-4, 0, 0, 0, 0, 0, 1, 2}	// fs = 48000
       
    47 	};
       
    48 
       
    49 /**
       
    50 2^32, scale value of Table KSBCProto4 and KSBCProto8.
       
    51 */
       
    52 const TUint8 KSBCProtoBitsShift = 32;
       
    53 
       
    54 /**
       
    55 Table KSBCProto4 is derived form Table Proto_4_40 (see A2DP spec for detail) 
       
    56 by scaling up by 2^32, it is for the Analysis process for 4 subbands sbc frames, 
       
    57 we are using integer numbers for high speed, after the calculation the results 
       
    58 will be scaled down by the same value.  
       
    59 */
       
    60 const TInt32 KSBCProto4[40] = 
       
    61 	{
       
    62 	           0,     2304460,     6407591,    11741191, 
       
    63 	    16480657,    16716234,     8013623,   -13143128, 
       
    64 	    46874251,    87782726,   124020356,   138271872, 
       
    65 	   111139929,    26338680,  -123788377,  -333488531, 
       
    66 	   582368677,   837466400,  1059296397,  1210442915, 
       
    67 	  1264074726,  1210442915,  1059296397,   837466400, 
       
    68 	  -582368677,  -333488531,  -123788377,    26338680, 
       
    69 	   111139929,   138271872,   124020356,    87782726, 
       
    70 	   -46874251,   -13143128,     8013623,    16716234, 
       
    71 	    16480657,    11741191,     6407591,     2304460
       
    72 	};
       
    73 
       
    74 /**
       
    75 Table KSBCProto8 is derived form Table Proto_8_80 (see A2DP spec for detail) 
       
    76 by scaling up by 2^32, it is for the Analysis process for 8 subbands sbc frames, 
       
    77 we are using integer numbers for high speed, after the calculation the results 
       
    78 will be scaled down by the same value.  
       
    79 */
       
    80 const TInt32 KSBCProto8[80] = 
       
    81 	{
       
    82 	           0,      672486,     1474275,     2382076, 
       
    83 	     3538707,     4895941,     6341097,     7661007, 
       
    84 	     8640724,     9035408,     8566508,     6943084, 
       
    85 	     3874724,     -767963,    -7085541,   -15020250, 
       
    86 	    24307345,    34486060,    44918676,    54748951, 
       
    87 	    62932121,    68309566,    69668008,    65792073, 
       
    88 	    55564768,    38042997,    12558847,   -21113115, 
       
    89 	   -62880072,  -112141060,  -167826440,  -228437728, 
       
    90 	   292053237,   356416821,   419083117,   477586143, 
       
    91 	   529417202,   572366304,   604531701,   624444638, 
       
    92 	   631167211,   624444638,   604531701,   572366304, 
       
    93 	   529417202,   477586143,   419083117,   356416821, 
       
    94 	  -292053237,  -228437728,  -167826440,  -112141060, 
       
    95 	   -62880072,   -21113115,    12558847,    38042997, 
       
    96 	    55564768,    65792073,    69668008,    68309566, 
       
    97 	    62932121,    54748951,    44918676,    34486060, 
       
    98 	   -24307345,   -15020250,    -7085541,     -767963, 
       
    99 	     3874724,     6943084,     8566508,     9035408, 
       
   100 	     8640724,     7661007,     6341097,     4895941, 
       
   101 	     3538707,     2382076,     1474275,      672486
       
   102 	};
       
   103 
       
   104 
       
   105 /**
       
   106 2^30, scale value of Table KSBCAnalysisMatrix4 and KSBCAnalysisMatrix8.
       
   107 */
       
   108 const TUint8 KSBCAnalysisMatrixBitsShift = 30;
       
   109 
       
   110 /**
       
   111 Table of cos((i + 0.5) * (k - 2) * PI / 4) * 2^30
       
   112 This table is used in Analysis process for 4 subbands, here we are using 
       
   113 integer values instead of real values for high speed, the values are scaled 
       
   114 up by 2^30, after calculation the results will be scaled down by the same value.  
       
   115 */
       
   116 const TInt32 KSBCAnalysisMatrix4[4][8] =
       
   117 	{
       
   118 		{  759250125,   992008094,  1073741824,   992008094, 
       
   119 		   759250125,   410903207,           0,  -410903207 },
       
   120 		   
       
   121 		{ -759250125,   410903207,  1073741824,   410903207, 
       
   122 		  -759250125,  -992008094,           0,   992008094 },
       
   123 		  
       
   124 		{ -759250125,  -410903207,  1073741824,  -410903207, 
       
   125 		  -759250125,   992008094,           0,  -992008094 },
       
   126 		  
       
   127 		{  759250125,  -992008094,  1073741824,  -992008094, 
       
   128 		   759250125,  -410903207,           0,   410903207 }
       
   129 	};
       
   130 
       
   131 /**
       
   132 Table of cos((i + 0.5) * (k - 4) * PI / 8) * 2^30
       
   133 This table is used in Analysis process for 8 subbands, here we are using 
       
   134 integer values instead of real values for high speed, the values are scaled 
       
   135 up by 2^30, after calculation the results will be scaled down by the same value.  
       
   136 */
       
   137 const TInt32 KSBCAnalysisMatrix8[8][16] =
       
   138 	{
       
   139 		{  759250125,   892783698,   992008094,  1053110176, 
       
   140 		  1073741824,  1053110176,   992008094,   892783698, 
       
   141 		   759250125,   596538995,   410903207,   209476638, 
       
   142 		           0,  -209476638,  -410903207,  -596538995 },
       
   143 		           
       
   144 		{ -759250125,  -209476638,   410903207,   892783698, 
       
   145 		  1073741824,   892783698,   410903207,  -209476638, 
       
   146 		  -759250125, -1053110176,  -992008094,  -596538995, 
       
   147 		           0,   596538995,   992008094,  1053110176 },
       
   148 		          
       
   149 		{ -759250125, -1053110176,  -410903207,   596538995, 
       
   150 		  1073741824,   596538995,  -410903207, -1053110176, 
       
   151 		  -759250125,   209476638,   992008094,   892783698, 
       
   152 		           0,  -892783698,  -992008094,  -209476638 },
       
   153 		           
       
   154 		{  759250125,  -596538995,  -992008094,   209476638, 
       
   155 		  1073741824,   209476638,  -992008094,  -596538995, 
       
   156 		   759250125,   892783698,  -410903207, -1053110176, 
       
   157 		           0,  1053110176,   410903207,  -892783698 },
       
   158 		          
       
   159 		{  759250125,   596538995,  -992008094,  -209476638, 
       
   160 		  1073741824,  -209476638,  -992008094,   596538995, 
       
   161 		   759250125,  -892783698,  -410903207,  1053110176, 
       
   162 		           0, -1053110176,   410903207,   892783698 },
       
   163 		           
       
   164 		{ -759250125,  1053110176,  -410903207,  -596538995, 
       
   165 		  1073741824,  -596538995,  -410903207,  1053110176, 
       
   166 		  -759250125,  -209476638,   992008094,  -892783698, 
       
   167 		           0,   892783698,  -992008094,   209476638 },
       
   168 		          
       
   169 		{ -759250125,   209476638,   410903207,  -892783698, 
       
   170 		  1073741824,  -892783698,   410903207,   209476638, 
       
   171 		  -759250125,  1053110176,  -992008094,   596538995, 
       
   172 		           0,  -596538995,   992008094, -1053110176 },
       
   173 		          
       
   174 		{  759250125,  -892783698,   992008094, -1053110176, 
       
   175 		  1073741824, -1053110176,   992008094,  -892783698, 
       
   176 		   759250125,  -596538995,   410903207,  -209476638, 
       
   177 		           0,   209476638,  -410903207,   596538995 }
       
   178 	};
       
   179 		
       
   180 #endif // __SBCCONST_H__