Fixed correct handling of frame sizes in the encoder

This commit is contained in:
Christian Hoene 2009-01-05 13:26:08 +01:00 committed by Marcel Holtmann
parent 365f92ed45
commit 2cada66773
3 changed files with 7 additions and 5 deletions

View File

@ -69,7 +69,7 @@ struct sbc_frame {
uint8_t subband_mode;
uint8_t subbands;
uint8_t bitpool;
uint8_t codesize;
uint16_t codesize;
uint8_t length;
/* bit number x set means joint stereo has been used in subband x */
@ -1329,9 +1329,9 @@ int sbc_get_frame_duration(sbc_t *sbc)
return (1000000 * blocks * subbands) / frequency;
}
int sbc_get_codesize(sbc_t *sbc)
uint16_t sbc_get_codesize(sbc_t *sbc)
{
uint8_t subbands, channels, blocks;
uint16_t subbands, channels, blocks;
struct sbc_priv *priv;
priv = sbc->priv;

View File

@ -87,7 +87,7 @@ int sbc_encode(sbc_t *sbc, void *input, int input_len, void *output,
int output_len, int *written);
int sbc_get_frame_length(sbc_t *sbc);
int sbc_get_frame_duration(sbc_t *sbc);
int sbc_get_codesize(sbc_t *sbc);
uint16_t sbc_get_codesize(sbc_t *sbc);
void sbc_finish(sbc_t *sbc);
#ifdef __cplusplus

View File

@ -47,7 +47,7 @@ static ssize_t __read(int fd, void *buf, size_t count)
while (count > 0) {
len = read(fd, buf + pos, count);
if (len <= 0)
return len;
return pos > len ? pos : len;
count -= len;
pos += len;
@ -188,6 +188,8 @@ static void encode(char *filename, int subbands, int bitpool, int joint,
len = sbc_encode(&sbc, input, size,
output, sizeof(output), &encoded);
if (len <= 0)
break;
if (len < size)
memmove(input, input + len, size - len);