mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
audio/mp3: Refactoring: Rename global variables
This commit is contained in:
parent
8efd0e725f
commit
2b54013ccc
@ -51,7 +51,7 @@ var imdctWinData = [4][36]float32{
|
||||
},
|
||||
}
|
||||
|
||||
var cos_N12 = [6][12]float32{
|
||||
var cosN12 = [6][12]float32{
|
||||
{
|
||||
0.608761, 0.382683, 0.130526, -0.130526, -0.382683, -0.608761,
|
||||
-0.793353, -0.923880, -0.991445, -0.991445, -0.923879, -0.793353,
|
||||
@ -78,7 +78,7 @@ var cos_N12 = [6][12]float32{
|
||||
},
|
||||
}
|
||||
|
||||
var cos_N36 = [18][36]float32{
|
||||
var cosN36 = [18][36]float32{
|
||||
{
|
||||
0.675590, 0.608761, 0.537300, 0.461749, 0.382683, 0.300706,
|
||||
0.216440, 0.130526, 0.043619, -0.043619, -0.130526, -0.216440,
|
||||
@ -233,7 +233,7 @@ func imdctWin(in []float32, blockType int) []float32 {
|
||||
for p := 0; p < N; p++ {
|
||||
sum := float32(0.0)
|
||||
for m := 0; m < N/2; m++ {
|
||||
sum += in[i+3*m] * cos_N12[m][p]
|
||||
sum += in[i+3*m] * cosN12[m][p]
|
||||
}
|
||||
out[6*i+p+6] += sum * imdctWinData[blockType][p]
|
||||
}
|
||||
@ -244,7 +244,7 @@ func imdctWin(in []float32, blockType int) []float32 {
|
||||
for p := 0; p < N; p++ {
|
||||
sum := float32(0.0)
|
||||
for m := 0; m < N/2; m++ {
|
||||
sum += in[m] * cos_N36[m][p]
|
||||
sum += in[m] * cosN36[m][p]
|
||||
}
|
||||
out[p] = sum * imdctWinData[blockType][p]
|
||||
}
|
||||
|
@ -218,7 +218,7 @@ func (f *frame) l3Reorder(gr int, ch int) {
|
||||
}
|
||||
|
||||
var (
|
||||
is_ratios = [6]float32{0.000000, 0.267949, 0.577350, 1.000000, 1.732051, 3.732051}
|
||||
isRatios = []float32{0.000000, 0.267949, 0.577350, 1.000000, 1.732051, 3.732051}
|
||||
)
|
||||
|
||||
func (f *frame) stereoProcessIntensityLong(gr int, sfb int) {
|
||||
@ -234,8 +234,8 @@ func (f *frame) stereoProcessIntensityLong(gr int, sfb int) {
|
||||
is_ratio_l = 1.0
|
||||
is_ratio_r = 0.0
|
||||
} else {
|
||||
is_ratio_l = is_ratios[is_pos] / (1.0 + is_ratios[is_pos])
|
||||
is_ratio_r = 1.0 / (1.0 + is_ratios[is_pos])
|
||||
is_ratio_l = isRatios[is_pos] / (1.0 + isRatios[is_pos])
|
||||
is_ratio_r = 1.0 / (1.0 + isRatios[is_pos])
|
||||
}
|
||||
/* Now decode all samples in this scale factor band */
|
||||
for i := sfb_start; i < sfb_stop; i++ {
|
||||
@ -262,8 +262,8 @@ func (f *frame) stereoProcessIntensityShort(gr int, sfb int) {
|
||||
is_ratio_l = 1.0
|
||||
is_ratio_r = 0.0
|
||||
} else {
|
||||
is_ratio_l = is_ratios[is_pos] / (1.0 + is_ratios[is_pos])
|
||||
is_ratio_r = 1.0 / (1.0 + is_ratios[is_pos])
|
||||
is_ratio_l = isRatios[is_pos] / (1.0 + isRatios[is_pos])
|
||||
is_ratio_r = 1.0 / (1.0 + isRatios[is_pos])
|
||||
}
|
||||
/* Now decode all samples in this scale factor band */
|
||||
for i := sfb_start; i < sfb_stop; i++ {
|
||||
@ -344,8 +344,8 @@ func (f *frame) l3Stereo(gr int) {
|
||||
}
|
||||
|
||||
var (
|
||||
cs = [8]float32{0.857493, 0.881742, 0.949629, 0.983315, 0.995518, 0.999161, 0.999899, 0.999993}
|
||||
ca = [8]float32{-0.514496, -0.471732, -0.313377, -0.181913, -0.094574, -0.040966, -0.014199, -0.003700}
|
||||
cs = []float32{0.857493, 0.881742, 0.949629, 0.983315, 0.995518, 0.999161, 0.999899, 0.999993}
|
||||
ca = []float32{-0.514496, -0.471732, -0.313377, -0.181913, -0.094574, -0.040966, -0.014199, -0.003700}
|
||||
)
|
||||
|
||||
func (f *frame) l3Antialias(gr int, ch int) {
|
||||
@ -406,18 +406,18 @@ func (f *frame) l3FrequencyInversion(gr int, ch int) {
|
||||
}
|
||||
}
|
||||
|
||||
var g_synth_n_win = [64][32]float32{}
|
||||
var synthNWin = [64][32]float32{}
|
||||
|
||||
func init() {
|
||||
for i := 0; i < 64; i++ {
|
||||
for j := 0; j < 32; j++ {
|
||||
g_synth_n_win[i][j] =
|
||||
synthNWin[i][j] =
|
||||
float32(math.Cos(float64((16+i)*(2*j+1)) * (math.Pi / 64.0)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var g_synth_dtbl = [512]float32{
|
||||
var synthDtbl = [512]float32{
|
||||
0.000000000, -0.000015259, -0.000015259, -0.000015259,
|
||||
-0.000015259, -0.000015259, -0.000015259, -0.000030518,
|
||||
-0.000030518, -0.000030518, -0.000030518, -0.000045776,
|
||||
@ -564,7 +564,7 @@ func (f *frame) l3SubbandSynthesis(gr int, ch int, out []uint8) {
|
||||
for i := 0; i < 64; i++ { /* Matrix multiply input with n_win[][] matrix */
|
||||
sum := float32(0)
|
||||
for j := 0; j < 32; j++ {
|
||||
sum += g_synth_n_win[i][j] * s_vec[j]
|
||||
sum += synthNWin[i][j] * s_vec[j]
|
||||
}
|
||||
f.v_vec[ch][i] = sum
|
||||
}
|
||||
@ -574,8 +574,8 @@ func (f *frame) l3SubbandSynthesis(gr int, ch int, out []uint8) {
|
||||
u_vec[(i<<6)+j+32] = f.v_vec[ch][(i<<7)+j+96]
|
||||
}
|
||||
}
|
||||
for i := 0; i < 512; i++ { /* Window by u_vec[i] with g_synth_dtbl[i] */
|
||||
u_vec[i] *= g_synth_dtbl[i]
|
||||
for i := 0; i < 512; i++ { /* Window by u_vec[i] with synthDtbl[i] */
|
||||
u_vec[i] *= synthDtbl[i]
|
||||
}
|
||||
for i := 0; i < 32; i++ { /* Calc 32 samples,store in outdata vector */
|
||||
sum := float32(0)
|
||||
|
@ -29,11 +29,7 @@ var mpeg1_scalefac_sizes = [16][2]int{
|
||||
func (f *frame) readMainL3() error {
|
||||
nch := f.numberOfChannels()
|
||||
// Calculate header audio data size
|
||||
framesize := (144*
|
||||
g_mpeg1_bitrates[f.header.layer][f.header.bitrate_index])/
|
||||
g_sampling_frequency[f.header.sampling_frequency] +
|
||||
f.header.padding_bit
|
||||
|
||||
framesize := f.size()
|
||||
if framesize > 2000 {
|
||||
return fmt.Errorf("mp3: framesize = %d", framesize)
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
"io"
|
||||
)
|
||||
|
||||
var g_mpeg1_bitrates = map[mpeg1Layer][15]int{
|
||||
var mpeg1Bitrates = map[mpeg1Layer][15]int{
|
||||
mpeg1Layer1: {
|
||||
0, 32000, 64000, 96000, 128000, 160000, 192000, 224000,
|
||||
256000, 288000, 320000, 352000, 384000, 416000, 448000,
|
||||
@ -36,15 +36,18 @@ var g_mpeg1_bitrates = map[mpeg1Layer][15]int{
|
||||
},
|
||||
}
|
||||
|
||||
var g_sampling_frequency = [3]int{44100, 48000, 32000}
|
||||
var samplingFrequency = [3]int{44100, 48000, 32000}
|
||||
|
||||
func (f *frame) size() int {
|
||||
return (144*mpeg1Bitrates[f.header.layer][f.header.bitrate_index])/
|
||||
samplingFrequency[f.header.sampling_frequency] +
|
||||
int(f.header.padding_bit)
|
||||
}
|
||||
|
||||
func (f *frame) readAudioL3() error {
|
||||
nch := f.numberOfChannels()
|
||||
/* Calculate header audio data size */
|
||||
framesize := (144*
|
||||
g_mpeg1_bitrates[f.header.layer][f.header.bitrate_index])/
|
||||
g_sampling_frequency[f.header.sampling_frequency] +
|
||||
int(f.header.padding_bit)
|
||||
framesize := f.size()
|
||||
if framesize > 2000 {
|
||||
return fmt.Errorf("mp3: framesize = %d\n", framesize)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user