ref: 5bc8ca83006b23643cbbe9aa26480079310c009e
parent: 64e00700e744352a3542dc40e622fd0f028737bf
author: menno <menno>
date: Thu Dec 16 13:44:29 EST 1999
Fixed bug with calculating number of bytes from the number of bits.
--- a/encoder.c
+++ b/encoder.c
@@ -81,7 +81,7 @@
*samplesToRead = frameNumSample * ac->channels;
as->frame_bits = (int)(ac->bit_rate*frameNumSample/ac->sampling_rate+0.5);
- *bitBufferSize = (int)((as->frame_bits * 2 + 8)/8);
+ *bitBufferSize = (int)(((as->frame_bits * 2) + 7)/8);
/* num frames to start up encoder due to delay compensation */
@@ -159,7 +159,7 @@
as->total_bits += usedNumBit;
// Copy bitBuf into bitBuffer here
- usedBytes = (int)((usedNumBit/8)+0.5);
+ usedBytes = (int)((usedNumBit+7)/8);
*bitBufSize = usedBytes;
for (i = 0; i < usedBytes; i++)
bitBuffer[i] = bitBuf->data[i];
@@ -258,7 +258,7 @@
bits = BsBufferNumBit(bitHeader);
// Copy bitBuf into bitBuffer here
- bytes = (int)((bits+8)/8);
+ bytes = (int)((bits+7)/8);
for (i = 0; i < bytes; i++)
headerBuf[i] = bitHeader->data[i];
BsClose(bitHeader);