Skip to content

Commit

Permalink
flac_frame: Support non-8 bit align sample size
Browse files Browse the repository at this point in the history
  • Loading branch information
wader committed Oct 18, 2021
1 parent 8eaba88 commit b643e22
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions format/flac/flac_frame.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,10 +622,12 @@ func frameDecode(d *decode.D, in interface{}) interface{} {
channelSamples[1][i] = (m - s) >> 1
}
default:
// no side channel
// not stereo or no side channel
}

bytesPerSample := sampleSize / 8
outSampleSize := sampleSize + (sampleSize % 8)

bytesPerSample := outSampleSize / 8
p := 0
le := binary.LittleEndian

Expand All @@ -642,7 +644,7 @@ func frameDecode(d *decode.D, in interface{}) interface{} {
for j := 0; j < len(channelSamples); j++ {

s := channelSamples[j][i]
switch sampleSize {
switch outSampleSize {
case 8:
interleavedSamplesBuf[p] = byte(s)
case 16:
Expand All @@ -661,6 +663,6 @@ func frameDecode(d *decode.D, in interface{}) interface{} {
SamplesBuf: interleavedSamplesBuf,
Samples: uint64(streamSamples),
Channels: int(channels),
BitsPerSample: sampleSize,
BitsPerSample: outSampleSize,
}
}

0 comments on commit b643e22

Please sign in to comment.