mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
audio/mp3: Remove all exports to C
This commit is contained in:
parent
02e284ea9d
commit
51a2507430
@ -124,19 +124,18 @@ func getBytes(buf []int) (int, error) {
|
||||
return len(buf), nil
|
||||
}
|
||||
|
||||
//export Get_Filepos
|
||||
func Get_Filepos() C.unsigned {
|
||||
func getFilepos() int {
|
||||
if len(readerCache) == 0 && readerEOF {
|
||||
return eof
|
||||
}
|
||||
return C.unsigned(readerPos)
|
||||
return readerPos
|
||||
}
|
||||
|
||||
func decode(r io.Reader, w io.Writer) error {
|
||||
// TODO: Decoder should know number of channels
|
||||
reader = r
|
||||
writer = w
|
||||
for Get_Filepos() != eof {
|
||||
for getFilepos() != eof {
|
||||
err := readFrame()
|
||||
if err == nil {
|
||||
if err := decodeL3(); err != nil {
|
||||
@ -144,7 +143,7 @@ func decode(r io.Reader, w io.Writer) error {
|
||||
}
|
||||
continue
|
||||
}
|
||||
if Get_Filepos() == eof {
|
||||
if getFilepos() == eof {
|
||||
break
|
||||
}
|
||||
return err
|
||||
|
@ -71,7 +71,7 @@ func readMainL3() error {
|
||||
}
|
||||
for gr := 0; gr < 2; gr++ {
|
||||
for ch := 0; ch < nch; ch++ {
|
||||
part_2_start := int(Get_Main_Pos())
|
||||
part_2_start := getMainPos()
|
||||
/* Number of bits in the bitstream for the bands */
|
||||
slen1 := mpeg1_scalefac_sizes[C.g_side_info.scalefac_compress[gr][ch]][0]
|
||||
slen2 := mpeg1_scalefac_sizes[C.g_side_info.scalefac_compress[gr][ch]][1]
|
||||
@ -270,18 +270,15 @@ func getMainBits(num int) int {
|
||||
return int(tmp)
|
||||
}
|
||||
|
||||
//export Get_Main_Pos
|
||||
func Get_Main_Pos() C.unsigned {
|
||||
func getMainPos() int {
|
||||
pos := theMainDataBytes.pos
|
||||
pos *= 8 /* Multiply by 8 to get number of bits */
|
||||
pos += theMainDataBytes.idx /* Add current bit index */
|
||||
return C.unsigned(pos)
|
||||
return pos
|
||||
}
|
||||
|
||||
//export Set_Main_Pos
|
||||
func Set_Main_Pos(bit_pos C.unsigned) C.int {
|
||||
func setMainPos(bit_pos int) {
|
||||
theMainDataBytes.ptr = theMainDataBytes.vec[bit_pos>>3:]
|
||||
theMainDataBytes.pos = int(bit_pos) >> 3
|
||||
theMainDataBytes.idx = int(bit_pos) & 0x7
|
||||
return C.OK
|
||||
}
|
||||
|
@ -84,9 +84,4 @@ typedef struct { /* Scale factor band indices,for long and short windows */
|
||||
}
|
||||
t_sf_band_indices;
|
||||
|
||||
unsigned Get_Filepos(void);
|
||||
|
||||
unsigned Get_Main_Pos(void);
|
||||
int Set_Main_Pos(unsigned bit_pos);
|
||||
|
||||
#endif
|
||||
|
@ -148,23 +148,23 @@ func readHeader() error {
|
||||
/* Check for invalid values and impossible combinations */
|
||||
if C.g_frame_header.id != 3 {
|
||||
return fmt.Errorf("mp3: ID must be 3\nHeader word is 0x%08x at file pos %d",
|
||||
header, C.Get_Filepos())
|
||||
header, getFilepos())
|
||||
}
|
||||
if C.g_frame_header.bitrate_index == 0 {
|
||||
return fmt.Errorf("mp3: Free bitrate format NIY!\nHeader word is 0x%08x at file pos %d",
|
||||
header, Get_Filepos())
|
||||
header, getFilepos())
|
||||
}
|
||||
if C.g_frame_header.bitrate_index == 15 {
|
||||
return fmt.Errorf("mp3: bitrate_index = 15 is invalid!\nHeader word is 0x%08x at file pos %d",
|
||||
header, Get_Filepos())
|
||||
header, getFilepos())
|
||||
}
|
||||
if C.g_frame_header.sampling_frequency == 3 {
|
||||
return fmt.Errorf("mp3: sampling_frequency = 3 is invalid! Header word is 0x%08x at file pos %d",
|
||||
header, Get_Filepos())
|
||||
header, getFilepos())
|
||||
}
|
||||
if C.g_frame_header.layer == 0 {
|
||||
return fmt.Errorf("mp3: layer = 0 is invalid! Header word is 0x%08x at file pos %d",
|
||||
header, Get_Filepos())
|
||||
header, getFilepos())
|
||||
}
|
||||
C.g_frame_header.layer = 4 - C.g_frame_header.layer
|
||||
return nil
|
||||
@ -217,7 +217,7 @@ func readHuffman(part_2_start, gr, ch int) error {
|
||||
/* Read small values until is_pos = 576 or we run out of huffman data */
|
||||
table_num := int(C.g_side_info.count1table_select[gr][ch]) + 32
|
||||
is_pos := int(C.g_side_info.big_values[gr][ch]) * 2
|
||||
for ; (is_pos <= 572) && (int(Get_Main_Pos()) <= bit_pos_end); is_pos++ {
|
||||
for ; (is_pos <= 572) && (getMainPos() <= bit_pos_end); is_pos++ {
|
||||
/* Get next Huffman coded words */
|
||||
x, y, v, w, err := huffmanDecode(table_num)
|
||||
if err != nil {
|
||||
@ -241,7 +241,7 @@ func readHuffman(part_2_start, gr, ch int) error {
|
||||
C.g_main_data.is[gr][ch][is_pos] = C.float(y)
|
||||
}
|
||||
/* Check that we didn't read past the end of this section */
|
||||
if int(C.Get_Main_Pos()) > (bit_pos_end + 1) {
|
||||
if getMainPos() > (bit_pos_end + 1) {
|
||||
/* Remove last words read */
|
||||
is_pos -= 4
|
||||
}
|
||||
@ -252,6 +252,6 @@ func readHuffman(part_2_start, gr, ch int) error {
|
||||
C.g_main_data.is[gr][ch][is_pos] = 0.0
|
||||
}
|
||||
/* Set the bitpos to point to the next part to read */
|
||||
C.Set_Main_Pos(C.unsigned(bit_pos_end) + 1)
|
||||
setMainPos(bit_pos_end + 1)
|
||||
return nil
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ func getSideinfo(size int) error {
|
||||
return fmt.Errorf("mp3: unexpected EOF at getSideinfo")
|
||||
}
|
||||
return fmt.Errorf("mp3: couldn't read sideinfo %d bytes at pos %d: %v",
|
||||
size, Get_Filepos(), err)
|
||||
size, getFilepos(), err)
|
||||
}
|
||||
theSideInfo.vec = buf[:n]
|
||||
theSideInfo.idx = 0
|
||||
|
Loading…
Reference in New Issue
Block a user