mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
audio/mp3: Move L3_Reorder to Go
This commit is contained in:
parent
ef85c9a7bc
commit
3f24b7193a
@ -28,13 +28,7 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
type sfBandIndices struct {
|
||||
l [23]int
|
||||
s [14]int
|
||||
}
|
||||
|
||||
var (
|
||||
is_ratios = [6]float32{0.000000, 0.267949, 0.577350, 1.000000, 1.732051, 3.732051}
|
||||
g_sf_band_indices = [3]sfBandIndices{
|
||||
{
|
||||
l: [...]int{0, 4, 8, 12, 16, 20, 24, 30, 36, 44, 52, 62, 74, 90, 110, 134, 162, 196, 238, 288, 342, 418, 576},
|
||||
@ -51,6 +45,64 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
//export L3_Reorder
|
||||
func L3_Reorder(gr C.unsigned, ch C.unsigned) {
|
||||
re := make([]float32, 576)
|
||||
|
||||
sfreq := C.g_frame_header.sampling_frequency /* Setup sampling freq index */
|
||||
/* Only reorder short blocks */
|
||||
if (C.g_side_info.win_switch_flag[gr][ch] == 1) && (C.g_side_info.block_type[gr][ch] == 2) { /* Short blocks */
|
||||
/* Check if the first two subbands
|
||||
*(=2*18 samples = 8 long or 3 short sfb's) uses long blocks */
|
||||
sfb := 0
|
||||
/* 2 longbl. sb first */
|
||||
if C.g_side_info.mixed_block_flag[gr][ch] != 0 {
|
||||
sfb = 3
|
||||
}
|
||||
next_sfb := g_sf_band_indices[sfreq].s[sfb+1] * 3
|
||||
win_len := g_sf_band_indices[sfreq].s[sfb+1] - g_sf_band_indices[sfreq].s[sfb]
|
||||
i := 36
|
||||
if sfb == 0 {
|
||||
i = 0
|
||||
}
|
||||
for i < 576 {
|
||||
/* Check if we're into the next scalefac band */
|
||||
if i == next_sfb {
|
||||
/* Copy reordered data back to the original vector */
|
||||
for j := 0; j < 3*win_len; j++ {
|
||||
C.g_main_data.is[gr][ch][3*g_sf_band_indices[sfreq].s[sfb]+j] = C.float(re[j])
|
||||
}
|
||||
/* Check if this band is above the rzero region,if so we're done */
|
||||
if C.uint(i) >= C.g_side_info.count1[gr][ch] {
|
||||
return
|
||||
}
|
||||
sfb++
|
||||
next_sfb = g_sf_band_indices[sfreq].s[sfb+1] * 3
|
||||
win_len = g_sf_band_indices[sfreq].s[sfb+1] - g_sf_band_indices[sfreq].s[sfb]
|
||||
}
|
||||
for win := 0; win < 3; win++ { /* Do the actual reordering */
|
||||
for j := 0; j < win_len; j++ {
|
||||
re[j*3+win] = float32(C.g_main_data.is[gr][ch][i])
|
||||
i++
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Copy reordered data of last band back to original vector */
|
||||
for j := 0; j < 3*win_len; j++ {
|
||||
C.g_main_data.is[gr][ch][3*g_sf_band_indices[sfreq].s[12]+j] = C.float(re[j])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type sfBandIndices struct {
|
||||
l [23]int
|
||||
s [14]int
|
||||
}
|
||||
|
||||
var (
|
||||
is_ratios = [6]float32{0.000000, 0.267949, 0.577350, 1.000000, 1.732051, 3.732051}
|
||||
)
|
||||
|
||||
func stereoProcessIntensityLong(gr int, sfb int) {
|
||||
is_ratio_l := float32(0)
|
||||
is_ratio_r := float32(0)
|
||||
|
@ -45,7 +45,6 @@ static void audio_write_raw(unsigned *samples,unsigned nsamples);
|
||||
static void Decode_L3_Init_Song(void);
|
||||
static void Error(const char *s,int e);
|
||||
static void L3_Requantize(unsigned gr,unsigned ch);
|
||||
static void L3_Reorder(unsigned gr,unsigned ch);
|
||||
static void Read_Ancillary(void);
|
||||
static void Requantize_Process_Long(unsigned gr,unsigned ch,unsigned is_pos,unsigned sfb);
|
||||
static void Requantize_Process_Short(unsigned gr,unsigned ch,unsigned is_pos,unsigned sfb,unsigned win);
|
||||
@ -418,49 +417,6 @@ static void Decode_L3_Init_Song(void){
|
||||
synth_init = 1;
|
||||
}
|
||||
|
||||
/**Description: TBD
|
||||
* Parameters: TBD
|
||||
* Return value: TBD
|
||||
* Author: Krister Lagerström(krister@kmlager.com) **/
|
||||
static void L3_Reorder(unsigned gr,unsigned ch){
|
||||
unsigned sfreq,i,j,next_sfb,sfb,win_len,win;
|
||||
float re[576];
|
||||
|
||||
sfreq = g_frame_header.sampling_frequency; /* Setup sampling freq index */
|
||||
/* Only reorder short blocks */
|
||||
if((g_side_info.win_switch_flag[gr][ch] == 1) &&
|
||||
(g_side_info.block_type[gr][ch] == 2)) { /* Short blocks */
|
||||
/* Check if the first two subbands
|
||||
*(=2*18 samples = 8 long or 3 short sfb's) uses long blocks */
|
||||
sfb = (g_side_info.mixed_block_flag[gr][ch] != 0)?3:0; /* 2 longbl. sb first */
|
||||
next_sfb = g_sf_band_indices[sfreq].s[sfb+1] * 3;
|
||||
win_len = g_sf_band_indices[sfreq].s[sfb+1] - g_sf_band_indices[sfreq].s[sfb];
|
||||
for(i =((sfb == 0) ? 0 : 36); i < 576; /* i++ done below! */) {
|
||||
/* Check if we're into the next scalefac band */
|
||||
if(i == next_sfb) { /* Yes */
|
||||
/* Copy reordered data back to the original vector */
|
||||
for(j = 0; j < 3*win_len; j++)
|
||||
g_main_data.is[gr][ch][3*g_sf_band_indices[sfreq].s[sfb] + j] = re[j];
|
||||
/* Check if this band is above the rzero region,if so we're done */
|
||||
if(i >= g_side_info.count1[gr][ch]) return; /* Done */
|
||||
sfb++;
|
||||
next_sfb = g_sf_band_indices[sfreq].s[sfb+1] * 3;
|
||||
win_len = g_sf_band_indices[sfreq].s[sfb+1] - g_sf_band_indices[sfreq].s[sfb];
|
||||
} /* end if(next_sfb) */
|
||||
for(win = 0; win < 3; win++) { /* Do the actual reordering */
|
||||
for(j = 0; j < win_len; j++) {
|
||||
re[j*3 + win] = g_main_data.is[gr][ch][i];
|
||||
i++;
|
||||
} /* end for(j... */
|
||||
} /* end for(win... */
|
||||
} /* end for(i... */
|
||||
/* Copy reordered data of last band back to original vector */
|
||||
for(j = 0; j < 3*win_len; j++)
|
||||
g_main_data.is[gr][ch][3 * g_sf_band_indices[sfreq].s[12] + j] = re[j];
|
||||
} /* end else(only long blocks) */
|
||||
return; /* Done */
|
||||
}
|
||||
|
||||
/**Description: TBD
|
||||
* Parameters: TBD
|
||||
* Return value: TBD
|
||||
|
@ -99,6 +99,7 @@ int Read_Audio_L3(void);
|
||||
static int Read_Header(void);
|
||||
void Read_Huffman(unsigned part_2_start,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);
|
||||
|
Loading…
Reference in New Issue
Block a user