mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
audio/mp3: Remove audioWriteRaw
This commit is contained in:
parent
ae85ec991c
commit
19b3df1da3
@ -37,7 +37,6 @@ func (f *frame) numberOfChannels() int {
|
||||
}
|
||||
|
||||
func (f *frame) decodeL3() error {
|
||||
out := make([]uint32, 576)
|
||||
nch := f.numberOfChannels()
|
||||
for gr := 0; gr < 2; gr++ {
|
||||
for ch := 0; ch < nch; ch++ {
|
||||
@ -46,6 +45,7 @@ func (f *frame) decodeL3() error {
|
||||
f.l3Reorder(gr, ch)
|
||||
}
|
||||
f.l3Stereo(gr)
|
||||
out := make([]uint8, 576*4)
|
||||
for ch := 0; ch < nch; ch++ {
|
||||
f.l3Antialias(gr, ch)
|
||||
// (IMDCT,windowing,overlapp add)
|
||||
@ -54,33 +54,13 @@ func (f *frame) decodeL3() error {
|
||||
// Polyphase subband synthesis
|
||||
f.l3SubbandSynthesis(gr, ch, out)
|
||||
}
|
||||
if err := f.audioWriteRaw(out); err != nil {
|
||||
if _, err := writer.Write(out); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f *frame) audioWriteRaw(samples []uint32) error {
|
||||
nch := f.numberOfChannels()
|
||||
s := make([]uint8, len(samples)*2*nch)
|
||||
for i, v := range samples {
|
||||
if nch == 1 {
|
||||
s[2*i] = uint8(v)
|
||||
s[2*i+1] = uint8(v >> 8)
|
||||
} else {
|
||||
s[4*i] = uint8(v)
|
||||
s[4*i+1] = uint8(v >> 8)
|
||||
s[4*i+2] = uint8(v >> 16)
|
||||
s[4*i+3] = uint8(v >> 24)
|
||||
}
|
||||
}
|
||||
if _, err := writer.Write(s); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func getByte() (uint8, error) {
|
||||
for len(readerCache) == 0 && !readerEOF {
|
||||
buf := make([]uint8, 4096)
|
||||
|
@ -552,7 +552,7 @@ var g_synth_dtbl = [512]float32{
|
||||
|
||||
var v_vec = [2][1024]float32{}
|
||||
|
||||
func (f *frame) l3SubbandSynthesis(gr int, ch int, out []uint32) {
|
||||
func (f *frame) l3SubbandSynthesis(gr int, ch int, out []uint8) {
|
||||
u_vec := make([]float32, 512)
|
||||
s_vec := make([]float32, 32)
|
||||
|
||||
@ -595,18 +595,20 @@ func (f *frame) l3SubbandSynthesis(gr int, ch int, out []uint32) {
|
||||
}
|
||||
samp &= 0xffff
|
||||
s := uint32(samp)
|
||||
// This function must be called for channel 0 first.
|
||||
if ch == 0 {
|
||||
// We always run in stereo mode,& duplicate channels here for mono.
|
||||
if nch == 1 {
|
||||
out[32*ss+i] = (s << 16) | (s)
|
||||
} else {
|
||||
// Note that this is different from original PDMP3.
|
||||
// Samples are set in little endian order here.
|
||||
out[32*ss+i] = s
|
||||
// We always run in stereo mode and duplicate channels here for mono.
|
||||
out[4*(32*ss+i)] = uint8(s)
|
||||
out[4*(32*ss+i)+1] = uint8(s >> 8)
|
||||
out[4*(32*ss+i)+2] = uint8(s)
|
||||
out[4*(32*ss+i)+3] = uint8(s >> 8)
|
||||
continue
|
||||
}
|
||||
if ch == 0 {
|
||||
out[4*(32*ss+i)] = uint8(s)
|
||||
out[4*(32*ss+i)+1] = uint8(s >> 8)
|
||||
} else {
|
||||
out[32*ss+i] |= (s << 16)
|
||||
out[4*(32*ss+i)+2] = uint8(s)
|
||||
out[4*(32*ss+i)+3] = uint8(s >> 8)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user