mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
audio/mp3: Refactoring
This commit is contained in:
parent
e53d5920b0
commit
02e284ea9d
@ -41,22 +41,23 @@ var (
|
|||||||
|
|
||||||
func decodeL3() error {
|
func decodeL3() error {
|
||||||
out := make([]int, 576)
|
out := make([]int, 576)
|
||||||
/* Number of channels(1 for mono and 2 for stereo) */
|
// Number of channels(1 for mono and 2 for stereo)
|
||||||
nch := 2
|
nch := 2
|
||||||
if C.g_frame_header.mode == C.mpeg1_mode_single_channel {
|
if C.g_frame_header.mode == C.mpeg1_mode_single_channel {
|
||||||
nch = 1
|
nch = 1
|
||||||
}
|
}
|
||||||
for gr := 0; gr < 2; gr++ {
|
for gr := 0; gr < 2; gr++ {
|
||||||
for ch := 0; ch < nch; ch++ {
|
for ch := 0; ch < nch; ch++ {
|
||||||
L3_Requantize(C.uint(gr), C.uint(ch)) /* Requantize samples */
|
l3Requantize(gr, ch)
|
||||||
L3_Reorder(C.uint(gr), C.uint(ch)) /* Reorder short blocks */
|
// Reorder short blocks
|
||||||
|
l3Reorder(gr, ch)
|
||||||
}
|
}
|
||||||
L3_Stereo(C.uint(gr)) /* Stereo processing */
|
l3Stereo(gr)
|
||||||
for ch := 0; ch < nch; ch++ {
|
for ch := 0; ch < nch; ch++ {
|
||||||
L3_Antialias(C.uint(gr), C.uint(ch))
|
l3Antialias(gr, ch)
|
||||||
// (IMDCT,windowing,overlapp add)
|
// (IMDCT,windowing,overlapp add)
|
||||||
L3_Hybrid_Synthesis(C.uint(gr), C.uint(ch))
|
l3HybridSynthesis(gr, ch)
|
||||||
L3_Frequency_Inversion(C.uint(gr), C.uint(ch))
|
l3FrequencyInversion(gr, ch)
|
||||||
// Polyphase subband synthesis
|
// Polyphase subband synthesis
|
||||||
l3SubbandSynthesis(gr, ch, out)
|
l3SubbandSynthesis(gr, ch, out)
|
||||||
}
|
}
|
||||||
|
@ -102,8 +102,7 @@ var (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
//export L3_Requantize
|
func l3Requantize(gr int, ch int) {
|
||||||
func L3_Requantize(gr C.unsigned, ch C.unsigned) {
|
|
||||||
/* Setup sampling frequency index */
|
/* Setup sampling frequency index */
|
||||||
sfreq := C.g_frame_header.sampling_frequency
|
sfreq := C.g_frame_header.sampling_frequency
|
||||||
/* Determine type of block to process */
|
/* Determine type of block to process */
|
||||||
@ -177,8 +176,7 @@ func L3_Requantize(gr C.unsigned, ch C.unsigned) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//export L3_Reorder
|
func l3Reorder(gr int, ch int) {
|
||||||
func L3_Reorder(gr C.unsigned, ch C.unsigned) {
|
|
||||||
re := make([]float32, 576)
|
re := make([]float32, 576)
|
||||||
|
|
||||||
sfreq := C.g_frame_header.sampling_frequency /* Setup sampling freq index */
|
sfreq := C.g_frame_header.sampling_frequency /* Setup sampling freq index */
|
||||||
@ -284,8 +282,7 @@ func stereoProcessIntensityShort(gr int, sfb int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//export L3_Stereo
|
func l3Stereo(gr int) {
|
||||||
func L3_Stereo(gr C.unsigned) {
|
|
||||||
/* Do nothing if joint stereo is not enabled */
|
/* Do nothing if joint stereo is not enabled */
|
||||||
if (C.g_frame_header.mode != 1) || (C.g_frame_header.mode_extension == 0) {
|
if (C.g_frame_header.mode != 1) || (C.g_frame_header.mode_extension == 0) {
|
||||||
return
|
return
|
||||||
@ -358,8 +355,7 @@ var (
|
|||||||
ca = [8]float32{-0.514496, -0.471732, -0.313377, -0.181913, -0.094574, -0.040966, -0.014199, -0.003700}
|
ca = [8]float32{-0.514496, -0.471732, -0.313377, -0.181913, -0.094574, -0.040966, -0.014199, -0.003700}
|
||||||
)
|
)
|
||||||
|
|
||||||
//export L3_Antialias
|
func l3Antialias(gr int, ch int) {
|
||||||
func L3_Antialias(gr C.unsigned, ch C.unsigned) {
|
|
||||||
/* No antialiasing is done for short blocks */
|
/* No antialiasing is done for short blocks */
|
||||||
if (C.g_side_info.win_switch_flag[gr][ch] == 1) &&
|
if (C.g_side_info.win_switch_flag[gr][ch] == 1) &&
|
||||||
(C.g_side_info.block_type[gr][ch] == 2) &&
|
(C.g_side_info.block_type[gr][ch] == 2) &&
|
||||||
@ -388,8 +384,7 @@ func L3_Antialias(gr C.unsigned, ch C.unsigned) {
|
|||||||
|
|
||||||
var store = [2][32][18]float32{}
|
var store = [2][32][18]float32{}
|
||||||
|
|
||||||
//export L3_Hybrid_Synthesis
|
func l3HybridSynthesis(gr int, ch int) {
|
||||||
func L3_Hybrid_Synthesis(gr C.unsigned, ch C.unsigned) {
|
|
||||||
for sb := 0; sb < 32; sb++ { /* Loop through all 32 subbands */
|
for sb := 0; sb < 32; sb++ { /* Loop through all 32 subbands */
|
||||||
/* Determine blocktype for this subband */
|
/* Determine blocktype for this subband */
|
||||||
bt := int(C.g_side_info.block_type[gr][ch])
|
bt := int(C.g_side_info.block_type[gr][ch])
|
||||||
@ -410,8 +405,7 @@ func L3_Hybrid_Synthesis(gr C.unsigned, ch C.unsigned) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//export L3_Frequency_Inversion
|
func l3FrequencyInversion(gr int, ch int) {
|
||||||
func L3_Frequency_Inversion(gr C.unsigned, ch C.unsigned) {
|
|
||||||
for sb := 1; sb < 32; sb += 2 { //OPT? : for(sb = 18; sb < 576; sb += 36)
|
for sb := 1; sb < 32; sb += 2 { //OPT? : for(sb = 18; sb < 576; sb += 36)
|
||||||
for i := 1; i < 18; i += 2 {
|
for i := 1; i < 18; i += 2 {
|
||||||
C.g_main_data.is[gr][ch][sb*18+i] = -C.g_main_data.is[gr][ch][sb*18+i]
|
C.g_main_data.is[gr][ch][sb*18+i] = -C.g_main_data.is[gr][ch][sb*18+i]
|
||||||
|
@ -89,13 +89,4 @@ unsigned Get_Filepos(void);
|
|||||||
unsigned Get_Main_Pos(void);
|
unsigned Get_Main_Pos(void);
|
||||||
int Set_Main_Pos(unsigned bit_pos);
|
int Set_Main_Pos(unsigned bit_pos);
|
||||||
|
|
||||||
void L3_Requantize(unsigned gr,unsigned ch);
|
|
||||||
void L3_Reorder(unsigned gr,unsigned ch);
|
|
||||||
void L3_Stereo(unsigned gr);
|
|
||||||
void L3_Antialias(unsigned gr,unsigned ch);
|
|
||||||
void L3_Hybrid_Synthesis(unsigned gr,unsigned ch);
|
|
||||||
void L3_Frequency_Inversion(unsigned gr,unsigned ch);
|
|
||||||
|
|
||||||
int Read_CRC(void);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user