mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 11:38:55 +01:00
audio/mp3: Remove isEOF
This commit is contained in:
parent
cb6e7366e2
commit
c496d94047
@ -17,6 +17,7 @@
|
||||
package mp3
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
)
|
||||
|
||||
@ -113,22 +114,17 @@ func getBytes(buf []int) (int, error) {
|
||||
return len(buf), nil
|
||||
}
|
||||
|
||||
func isEOF() bool {
|
||||
if len(readerCache) == 0 && readerEOF {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func getFilepos() int {
|
||||
return readerPos
|
||||
}
|
||||
|
||||
var eof = errors.New("mp3: expected EOF")
|
||||
|
||||
func decode(r io.Reader, w io.Writer) error {
|
||||
// TODO: Decoder should know number of channels
|
||||
reader = r
|
||||
writer = w
|
||||
for !isEOF() {
|
||||
for {
|
||||
f, err := readFrame()
|
||||
if err == nil {
|
||||
if err := f.decodeL3(); err != nil {
|
||||
@ -136,7 +132,7 @@ func decode(r io.Reader, w io.Writer) error {
|
||||
}
|
||||
continue
|
||||
}
|
||||
if isEOF() {
|
||||
if err == eof {
|
||||
break
|
||||
}
|
||||
return err
|
||||
|
@ -378,20 +378,22 @@ func (f *frame) l3Antialias(gr int, ch int) {
|
||||
var store = [2][32][18]float32{}
|
||||
|
||||
func (f *frame) l3HybridSynthesis(gr int, ch int) {
|
||||
for sb := 0; sb < 32; sb++ { /* Loop through all 32 subbands */
|
||||
/* Determine blocktype for this subband */
|
||||
// Loop through all 32 subbands
|
||||
for sb := 0; sb < 32; sb++ {
|
||||
// Determine blocktype for this subband
|
||||
bt := int(f.sideInfo.block_type[gr][ch])
|
||||
if (f.sideInfo.win_switch_flag[gr][ch] == 1) &&
|
||||
(f.sideInfo.mixed_block_flag[gr][ch] == 1) && (sb < 2) {
|
||||
bt = 0
|
||||
}
|
||||
/* Do the inverse modified DCT and windowing */
|
||||
// Do the inverse modified DCT and windowing
|
||||
in := make([]float32, 18)
|
||||
for i := range in {
|
||||
in[i] = f.mainData.is[gr][ch][sb*18+i]
|
||||
}
|
||||
rawout := imdctWin(in, bt)
|
||||
for i := 0; i < 18; i++ { /* Overlapp add with stored vector into main_data vector */
|
||||
// Overlapp add with stored vector into main_data vector
|
||||
for i := 0; i < 18; i++ {
|
||||
f.mainData.is[gr][ch][sb*18+i] = rawout[i] + store[ch][sb][i]
|
||||
store[ch][sb][i] = rawout[i+18]
|
||||
}
|
||||
@ -406,10 +408,7 @@ func (f *frame) l3FrequencyInversion(gr int, ch int) {
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
g_synth_n_win = [64][32]float32{}
|
||||
v_vec = [2][1024]float32{}
|
||||
)
|
||||
var g_synth_n_win = [64][32]float32{}
|
||||
|
||||
func init() {
|
||||
for i := 0; i < 64; i++ {
|
||||
@ -551,6 +550,8 @@ var g_synth_dtbl = [512]float32{
|
||||
0.000015259, 0.000015259, 0.000015259, 0.000015259,
|
||||
}
|
||||
|
||||
var v_vec = [2][1024]float32{}
|
||||
|
||||
func (f *frame) l3SubbandSynthesis(gr int, ch int, out []uint32) {
|
||||
u_vec := make([]float32, 512)
|
||||
s_vec := make([]float32, 32)
|
||||
|
@ -97,6 +97,9 @@ func (f *frame) readHeader() error {
|
||||
}
|
||||
if n < 4 {
|
||||
if err == io.EOF {
|
||||
if n == 0 {
|
||||
return eof
|
||||
}
|
||||
return fmt.Errorf("mp3: unexpected EOF at readHeader")
|
||||
}
|
||||
return err
|
||||
|
Loading…
Reference in New Issue
Block a user