1
1
mirror of https://github.com/wader/fq.git synced 2024-11-23 09:56:07 +03:00

flac_frame: Support non-8 bit align sample size

This commit is contained in:
Mattias Wadman 2021-10-19 01:52:59 +02:00
parent 8eaba88a10
commit b643e22877

View File

@ -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
@ -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:
@ -661,6 +663,6 @@ func frameDecode(d *decode.D, in interface{}) interface{} {
SamplesBuf: interleavedSamplesBuf,
Samples: uint64(streamSamples),
Channels: int(channels),
BitsPerSample: sampleSize,
BitsPerSample: outSampleSize,
}
}