fix: encodeFrameHeaderBlockSize special encoding

This commit is contained in:
DataHoarder 2022-07-26 16:09:59 +02:00
parent 18f6041006
commit e1a48c4800
Signed by: DataHoarder
SSH key fingerprint: SHA256:OLTRf6Fl87G52SiR7sWLGNzlJt4WOX+tfI2yxo0z7xk

View file

@ -200,12 +200,33 @@ func encodeFrameHeaderBlockSize(bw *bitio.Writer, blockSize uint16) (nblockSizeS
case 192:
// 0001
bits = 0x1
case 576, 1152, 2304, 4608:
// 0010-0101 : 576 * (2^(n-2)) samples, i.e. 576/1152/2304/4608
bits = 0x2 + uint64(blockSize/576) - 1
case 256, 512, 1024, 2048, 4096, 8192, 16384, 32768:
// 1000-1111 : 256 * (2^(n-8)) samples, i.e. 256/512/1024/2048/4096/8192/16384/32768
bits = 0x8 + uint64(blockSize/256) - 1
// 0010-0101 : 576 * (2^(n-2)) samples, i.e. 576/1152/2304/4608
case 576:
bits = 0x2
case 1152:
bits = 0x3
case 2304:
bits = 0x4
case 4608:
bits = 0x5
// 1000-1111 : 256 * (2^(n-8)) samples, i.e. 256/512/1024/2048/4096/8192/16384/32768
case 256:
bits = 0x8
case 512:
bits = 0x9
case 1024:
bits = 0xa
case 2048:
bits = 0xb
case 4096:
bits = 0xc
case 8192:
bits = 0xd
case 16384:
bits = 0xe
case 32768:
bits = 0xf
default:
if blockSize <= 256 {
// 0110 : get 8 bit (blocksize-1) from end of header