mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
audio/mp3: Move Requantize_Process_Short to Go
This commit is contained in:
parent
bf9a259565
commit
8e4abca1f8
@ -28,6 +28,34 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
var powtab34 = make([]float64, 8207)
|
||||
|
||||
func init() {
|
||||
for i := range powtab34 {
|
||||
powtab34[i] = math.Pow(float64(i), 4.0/3.0)
|
||||
}
|
||||
}
|
||||
|
||||
func requantizeProcessShort(gr, ch, is_pos, sfb, win int) {
|
||||
sf_mult := 0.5
|
||||
if C.g_side_info.scalefac_scale[gr][ch] != 0 {
|
||||
sf_mult = 1.0
|
||||
}
|
||||
tmp1 := 1.0
|
||||
if sfb < 12 {
|
||||
tmp1 = math.Pow(2.0, -(sf_mult * float64(C.g_main_data.scalefac_s[gr][ch][sfb][win])))
|
||||
}
|
||||
tmp2 := math.Pow(2.0, 0.25*(float64(C.g_side_info.global_gain[gr][ch])-210.0-
|
||||
8.0*float64(C.g_side_info.subblock_gain[gr][ch][win])))
|
||||
tmp3 := 0.0
|
||||
if C.g_main_data.is[gr][ch][is_pos] < 0 {
|
||||
tmp3 = -powtab34[int(-C.g_main_data.is[gr][ch][is_pos])]
|
||||
} else {
|
||||
tmp3 = powtab34[int(C.g_main_data.is[gr][ch][is_pos])]
|
||||
}
|
||||
C.g_main_data.is[gr][ch][is_pos] = C.float(tmp1 * tmp2 * tmp3)
|
||||
}
|
||||
|
||||
type sfBandIndices struct {
|
||||
l []int
|
||||
s []int
|
||||
@ -85,7 +113,7 @@ func L3_Requantize(gr C.unsigned, ch C.unsigned) {
|
||||
}
|
||||
for win := 0; win < 3; win++ {
|
||||
for j := 0; j < win_len; j++ {
|
||||
C.Requantize_Process_Short(gr, ch, C.unsigned(i), C.unsigned(sfb), C.unsigned(win))
|
||||
requantizeProcessShort(int(gr), int(ch), i, sfb, win)
|
||||
i++
|
||||
}
|
||||
}
|
||||
@ -106,7 +134,7 @@ func L3_Requantize(gr C.unsigned, ch C.unsigned) {
|
||||
}
|
||||
for win := 0; win < 3; win++ {
|
||||
for j := 0; j < win_len; j++ {
|
||||
C.Requantize_Process_Short(gr, ch, C.unsigned(i), C.unsigned(sfb), C.unsigned(win))
|
||||
requantizeProcessShort(int(gr), int(ch), i, sfb, win)
|
||||
i++
|
||||
} /* end for(j... */
|
||||
}
|
||||
|
@ -494,7 +494,11 @@ void Requantize_Process_Long(unsigned gr,unsigned ch,unsigned is_pos,unsigned sf
|
||||
|
||||
sf_mult = g_side_info.scalefac_scale[gr][ch] ? 1.0 : 0.5;
|
||||
pf_x_pt = g_side_info.preflag[gr][ch] * pretab[sfb];
|
||||
if (sfb >= 21) {
|
||||
tmp1 = 1.0;
|
||||
} else {
|
||||
tmp1 = pow(2.0,-(sf_mult *(g_main_data.scalefac_l[gr][ch][sfb] + pf_x_pt)));
|
||||
}
|
||||
tmp2 = pow(2.0,0.25 *((int32_t) g_side_info.global_gain[gr][ch] - 210));
|
||||
if(g_main_data.is[gr][ch][is_pos] < 0.0)
|
||||
tmp3 = -Requantize_Pow_43(-g_main_data.is[gr][ch][is_pos]);
|
||||
@ -503,24 +507,6 @@ void Requantize_Process_Long(unsigned gr,unsigned ch,unsigned is_pos,unsigned sf
|
||||
return; /* Done */
|
||||
}
|
||||
|
||||
/**Description: requantize sample in subband that uses short blocks.
|
||||
* Parameters: TBD
|
||||
* Return value: TBD
|
||||
* Author: Krister Lagerström(krister@kmlager.com) **/
|
||||
void Requantize_Process_Short(unsigned gr,unsigned ch,unsigned is_pos,unsigned sfb,unsigned win){
|
||||
float res,tmp1,tmp2,tmp3,sf_mult;
|
||||
|
||||
sf_mult = g_side_info.scalefac_scale[gr][ch] ? 1.0f : 0.5f;
|
||||
tmp1 = pow(2.0f,-(sf_mult * g_main_data.scalefac_s[gr][ch][sfb][win]));
|
||||
tmp2 = pow(2.0f,0.25f *((float) g_side_info.global_gain[gr][ch] - 210.0f -
|
||||
8.0f *(float) g_side_info.subblock_gain[gr][ch][win]));
|
||||
tmp3 =(g_main_data.is[gr][ch][is_pos] < 0.0)
|
||||
? -Requantize_Pow_43(-g_main_data.is[gr][ch][is_pos])
|
||||
: Requantize_Pow_43(g_main_data.is[gr][ch][is_pos]);
|
||||
res = g_main_data.is[gr][ch][is_pos] = tmp1 * tmp2 * tmp3;
|
||||
return; /* Done */
|
||||
}
|
||||
|
||||
/**Description: output audio data
|
||||
* Parameters: Pointers to the samples,the number of samples
|
||||
* Return value: None
|
||||
|
@ -108,7 +108,6 @@ void L3_Frequency_Inversion(unsigned gr,unsigned ch);
|
||||
void L3_Subband_Synthesis(unsigned gr,unsigned ch, unsigned* outdata);
|
||||
|
||||
void Requantize_Process_Long(unsigned gr,unsigned ch,unsigned is_pos,unsigned sfb);
|
||||
void Requantize_Process_Short(unsigned gr,unsigned ch,unsigned is_pos,unsigned sfb,unsigned win);
|
||||
|
||||
int Read_CRC(void);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user