Expose tta_info -> Info, tta_filter -> Filter
This commit is contained in:
parent
c4c8280a7d
commit
1de2d32ac5
|
@ -30,7 +30,7 @@ func Decompress(infile, outfile io.ReadWriteSeeker, passwd string, cb Callback)
|
|||
if len(passwd) > 0 {
|
||||
decoder.SetPassword(passwd)
|
||||
}
|
||||
info := tta_info{}
|
||||
info := Info{}
|
||||
if err = decoder.GetInfo(&info, 0); err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ func (this *Decoder) set_position(seconds uint32) (new_pos uint32, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func (this *Decoder) SetInfo(info *tta_info) error {
|
||||
func (this *Decoder) SetInfo(info *Info) error {
|
||||
if info.format > 2 ||
|
||||
info.bps < MIN_BPS ||
|
||||
info.bps > MAX_BPS ||
|
||||
|
@ -290,7 +290,7 @@ func (this *Decoder) SetInfo(info *tta_info) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (this *Decoder) ReadHeader(info *tta_info) (uint32, error) {
|
||||
func (this *Decoder) ReadHeader(info *Info) (uint32, error) {
|
||||
size := this.fifo.skip_id3v2()
|
||||
this.fifo.reset()
|
||||
if 'T' != this.fifo.read_byte() ||
|
||||
|
@ -311,7 +311,7 @@ func (this *Decoder) ReadHeader(info *tta_info) (uint32, error) {
|
|||
return size, nil
|
||||
}
|
||||
|
||||
func (this *Decoder) GetInfo(info *tta_info, pos int64) (err error) {
|
||||
func (this *Decoder) GetInfo(info *Info, pos int64) (err error) {
|
||||
if pos != 0 {
|
||||
if _, err = this.fifo.io.Seek(pos, os.SEEK_SET); err != nil {
|
||||
err = SEEK_ERROR
|
||||
|
|
|
@ -46,7 +46,7 @@ func Compress(infile, outfile io.ReadWriteSeeker, passwd string, cb Callback) (e
|
|||
}
|
||||
encoder := NewEncoder(outfile)
|
||||
smp_size := uint32(wave_hdr.num_channels * ((wave_hdr.bits_per_sample + 7) / 8))
|
||||
info := tta_info{
|
||||
info := Info{
|
||||
nch: uint32(wave_hdr.num_channels),
|
||||
bps: uint32(wave_hdr.bits_per_sample),
|
||||
sps: wave_hdr.sample_rate,
|
||||
|
@ -250,7 +250,7 @@ func (this *Encoder) frame_reset(frame uint32, iocb io.ReadWriteSeeker) {
|
|||
this.frame_init(frame)
|
||||
}
|
||||
|
||||
func (this *Encoder) WriteHeader(info *tta_info) (size uint32, err error) {
|
||||
func (this *Encoder) WriteHeader(info *Info) (size uint32, err error) {
|
||||
this.fifo.reset()
|
||||
// write TTA1 signature
|
||||
if err = this.fifo.write_byte('T'); err != nil {
|
||||
|
@ -288,7 +288,7 @@ func (this *Encoder) WriteHeader(info *tta_info) (size uint32, err error) {
|
|||
|
||||
}
|
||||
|
||||
func (this *Encoder) SetInfo(info *tta_info, pos int64) (err error) {
|
||||
func (this *Encoder) SetInfo(info *Info, pos int64) (err error) {
|
||||
if info.format > 2 ||
|
||||
info.bps < MIN_BPS ||
|
||||
info.bps > MAX_BPS ||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// TODO: SSE4 optimization
|
||||
package tta
|
||||
|
||||
func NewCompatibleFilter(data [8]byte, shift int32) tta_filter {
|
||||
func NewCompatibleFilter(data [8]byte, shift int32) Filter {
|
||||
this := tta_filter_compat{}
|
||||
this.shift = shift
|
||||
this.round = 1 << uint32(shift-1)
|
||||
|
@ -119,7 +119,7 @@ func (this *tta_filter_compat) Encode(in *int32) {
|
|||
this.error = *in
|
||||
}
|
||||
|
||||
func NewSSEFilter(data [8]byte, shift int32) tta_filter {
|
||||
func NewSSEFilter(data [8]byte, shift int32) Filter {
|
||||
this := tta_filter_sse{}
|
||||
this.shift = shift
|
||||
this.round = 1 << uint32(shift-1)
|
||||
|
|
6
tta.go
6
tta.go
|
@ -4,7 +4,7 @@ import (
|
|||
"io"
|
||||
)
|
||||
|
||||
type tta_info struct {
|
||||
type Info struct {
|
||||
format uint32 // audio format
|
||||
nch uint32 // number of channels
|
||||
bps uint32 // bits per sample
|
||||
|
@ -12,7 +12,7 @@ type tta_info struct {
|
|||
samples uint32 // data length in samples
|
||||
}
|
||||
|
||||
type tta_filter interface {
|
||||
type Filter interface {
|
||||
Decode(*int32)
|
||||
Encode(*int32)
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ func (rice *tta_adapt) init(k0, k1 uint32) {
|
|||
}
|
||||
|
||||
type tta_codec struct {
|
||||
filter tta_filter
|
||||
filter Filter
|
||||
rice tta_adapt
|
||||
prev int32
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue