Mercurial > SDL_sound_CoreAudio
comparison decoders/mpglib/layer3.c @ 279:52b9f37998db
Removed global state variable; should be thread safe now.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Thu, 14 Mar 2002 16:38:59 +0000 |
parents | 9e7f9e09ea0e |
children | ad4c8f34136a |
comparison
equal
deleted
inserted
replaced
278:dfe4a46f88f7 | 279:52b9f37998db |
---|---|
14 | 14 |
15 #include "mpg123_sdlsound.h" | 15 #include "mpg123_sdlsound.h" |
16 #include "mpglib_sdlsound.h" | 16 #include "mpglib_sdlsound.h" |
17 #include "huffman.h" | 17 #include "huffman.h" |
18 | 18 |
19 extern struct mpstr *gmp; | |
20 | |
21 #define MPEG1 | 19 #define MPEG1 |
22 | |
23 | 20 |
24 static real ispow[8207]; | 21 static real ispow[8207]; |
25 static real aa_ca[8],aa_cs[8]; | 22 static real aa_ca[8],aa_cs[8]; |
26 static real COS1[12][6]; | 23 static real COS1[12][6]; |
27 static real win[4][36]; | 24 static real win[4][36]; |
1817 | 1814 |
1818 /* | 1815 /* |
1819 * III_hybrid | 1816 * III_hybrid |
1820 */ | 1817 */ |
1821 static void III_hybrid(real fsIn[SBLIMIT][SSLIMIT],real tsOut[SSLIMIT][SBLIMIT], | 1818 static void III_hybrid(real fsIn[SBLIMIT][SSLIMIT],real tsOut[SSLIMIT][SBLIMIT], |
1822 int ch,struct gr_info_s *gr_info) | 1819 int ch,struct gr_info_s *gr_info,struct mpstr *mp) |
1823 { | 1820 { |
1824 real *tspnt = (real *) tsOut; | 1821 real *tspnt = (real *) tsOut; |
1825 real (*block)[2][SBLIMIT*SSLIMIT] = gmp->hybrid_block; | 1822 real (*block)[2][SBLIMIT*SSLIMIT] = mp->hybrid_block; |
1826 int *blc = gmp->hybrid_blc; | 1823 int *blc = mp->hybrid_blc; |
1827 real *rawout1,*rawout2; | 1824 real *rawout1,*rawout2; |
1828 int bt; | 1825 int bt; |
1829 int sb = 0; | 1826 int sb = 0; |
1830 | 1827 |
1831 { | 1828 { |
1868 } | 1865 } |
1869 | 1866 |
1870 /* | 1867 /* |
1871 * main layer3 handler | 1868 * main layer3 handler |
1872 */ | 1869 */ |
1873 int do_layer3(struct frame *fr,unsigned char *pcm_sample,int *pcm_point) | 1870 int do_layer3(struct frame *fr,unsigned char *pcm_sample,int *pcm_point,struct mpstr *mp) |
1874 { | 1871 { |
1875 int gr, ch, ss,clip=0; | 1872 int gr, ch, ss,clip=0; |
1876 int scalefacs[2][39]; /* max 39 for short[13][3] mode, mixed: 38, long: 22 */ | 1873 int scalefacs[2][39]; /* max 39 for short[13][3] mode, mixed: 38, long: 22 */ |
1877 struct III_sideinfo sideinfo; | 1874 struct III_sideinfo sideinfo; |
1878 int stereo = fr->stereo; | 1875 int stereo = fr->stereo; |
1910 #else | 1907 #else |
1911 Sound_SetError("MPGLIB: Not supported!"); | 1908 Sound_SetError("MPGLIB: Not supported!"); |
1912 #endif | 1909 #endif |
1913 } | 1910 } |
1914 | 1911 |
1915 if(set_pointer(sideinfo.main_data_begin) == MP3_ERR) | 1912 if(set_pointer(sideinfo.main_data_begin,mp) == MP3_ERR) |
1916 return -1; | 1913 return -1; |
1917 | 1914 |
1918 for (gr=0;gr<granules;gr++) | 1915 for (gr=0;gr<granules;gr++) |
1919 { | 1916 { |
1920 real hybridIn[2][SBLIMIT][SSLIMIT]; | 1917 real hybridIn[2][SBLIMIT][SSLIMIT]; |
1927 part2bits = III_get_scale_factors_2(scalefacs[0],gr_info,0); | 1924 part2bits = III_get_scale_factors_2(scalefacs[0],gr_info,0); |
1928 else { | 1925 else { |
1929 #ifdef MPEG1 | 1926 #ifdef MPEG1 |
1930 part2bits = III_get_scale_factors_1(scalefacs[0],gr_info); | 1927 part2bits = III_get_scale_factors_1(scalefacs[0],gr_info); |
1931 #else | 1928 #else |
1932 Sound_SetError("MPGLIB: Not supported!"); | 1929 Sound_SetError("MPGLIB: Not supported!"); |
1933 #endif | 1930 #endif |
1934 } | 1931 } |
1935 if(III_dequantize_sample(hybridIn[0], scalefacs[0],gr_info,sfreq,part2bits)) | 1932 if(III_dequantize_sample(hybridIn[0], scalefacs[0],gr_info,sfreq,part2bits)) |
1936 return clip; | 1933 return clip; |
1937 } | 1934 } |
1942 part2bits = III_get_scale_factors_2(scalefacs[1],gr_info,i_stereo); | 1939 part2bits = III_get_scale_factors_2(scalefacs[1],gr_info,i_stereo); |
1943 else { | 1940 else { |
1944 #ifdef MPEG1 | 1941 #ifdef MPEG1 |
1945 part2bits = III_get_scale_factors_1(scalefacs[1],gr_info); | 1942 part2bits = III_get_scale_factors_1(scalefacs[1],gr_info); |
1946 #else | 1943 #else |
1947 Sound_SetError("MPGLIB: Not supported!"); | 1944 Sound_SetError("MPGLIB: Not supported!"); |
1948 #endif | 1945 #endif |
1949 } | 1946 } |
1950 | 1947 |
1951 if(III_dequantize_sample(hybridIn[1],scalefacs[1],gr_info,sfreq,part2bits)) | 1948 if(III_dequantize_sample(hybridIn[1],scalefacs[1],gr_info,sfreq,part2bits)) |
1952 return clip; | 1949 return clip; |
1993 } | 1990 } |
1994 | 1991 |
1995 for(ch=0;ch<stereo1;ch++) { | 1992 for(ch=0;ch<stereo1;ch++) { |
1996 struct gr_info_s *gr_info = &(sideinfo.ch[ch].gr[gr]); | 1993 struct gr_info_s *gr_info = &(sideinfo.ch[ch].gr[gr]); |
1997 III_antialias(hybridIn[ch],gr_info); | 1994 III_antialias(hybridIn[ch],gr_info); |
1998 III_hybrid(hybridIn[ch], hybridOut[ch], ch,gr_info); | 1995 III_hybrid(hybridIn[ch], hybridOut[ch], ch,gr_info,mp); |
1999 } | 1996 } |
2000 | 1997 |
2001 for(ss=0;ss<SSLIMIT;ss++) { | 1998 for(ss=0;ss<SSLIMIT;ss++) { |
2002 if(single >= 0) { | 1999 if(single >= 0) { |
2003 clip += synth_1to1_mono(hybridOut[0][ss],pcm_sample,pcm_point); | 2000 clip += synth_1to1_mono(hybridOut[0][ss],pcm_sample,pcm_point,mp); |
2004 } | 2001 } |
2005 else { | 2002 else { |
2006 int p1 = *pcm_point; | 2003 int p1 = *pcm_point; |
2007 clip += synth_1to1(hybridOut[0][ss],0,pcm_sample,&p1); | 2004 clip += synth_1to1(hybridOut[0][ss],0,pcm_sample,&p1,mp); |
2008 clip += synth_1to1(hybridOut[1][ss],1,pcm_sample,pcm_point); | 2005 clip += synth_1to1(hybridOut[1][ss],1,pcm_sample,pcm_point,mp); |
2009 } | 2006 } |
2010 } | 2007 } |
2011 } | 2008 } |
2012 | 2009 |
2013 return clip; | 2010 return clip; |