Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix two bugs with subframe decoding #7

Merged
merged 2 commits into from
Jan 30, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions frame/subframe.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ func (subframe *Subframe) decodeRicePart(paramSize uint) error {
if err != nil {
return unexpected(err)
}
if paramSize == 4 && x == 0xF || paramSize == 4 && x == 0x1F {
if paramSize == 4 && x == 0xF || paramSize == 5 && x == 0x1F {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for spotting this! Do you happen to have a FLAC file which uses Rice parameter escape codes? I would like to implement this functionality but have deferred it since I don't have any FLAC file to verify the implementation against.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, sorry. I just read your last paragraph where you mentioned that you don't have any file to test this. Making a mental note to read the entire pull request before sending a reply :)

// 1111 or 11111: Escape code, meaning the partition is in unencoded
// binary form using n bits per sample; n follows as a 5-bit number.
panic("not yet implemented; Rice parameter escape code.")
Expand Down Expand Up @@ -446,11 +446,11 @@ func (subframe *Subframe) decodeLPC(coeffs []int32, shift int32) error {
panic("not yet implemented; negative shift.")
}
for i := subframe.Order; i < subframe.NSamples; i++ {
var sample int32
var sample int64
for j, c := range coeffs {
sample += c * subframe.Samples[i-j-1]
sample += int64(c) * int64(subframe.Samples[i-j-1])
}
subframe.Samples[i] += sample >> uint(shift)
subframe.Samples[i] += int32(sample >> uint(shift))
}
return nil
}