OSDN Git Service

sbc: Fix missing encoding of last frame
authorMarcel Holtmann <marcel@holtmann.org>
Sat, 25 Oct 2008 22:26:20 +0000 (00:26 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Mon, 30 Jul 2012 02:48:26 +0000 (19:48 -0700)
sbc/sbcdec.c
sbc/sbcenc.c

index 5ac02b4..5029d31 100644 (file)
@@ -170,8 +170,7 @@ static void decode(char *filename, char *output, int tofile)
                 * length of the file (!) */
                pos += framelen;
                framelen = sbc_decode(&sbc, stream + pos, streamlen - pos,
-                                       buf + count, sizeof(buf) - count,
-                                       &len);
+                                       buf + count, sizeof(buf) - count, &len);
        }
 
        if (count > 0) {
index e17f8fd..6821759 100644 (file)
@@ -172,7 +172,7 @@ static void encode(char *filename, int subbands, int joint)
        while (1) {
                if (size < sizeof(input)) {
                        len = __read(fd, input + size, sizeof(input) - size);
-                       if (len == 0)
+                       if (len == 0 && size == 0)
                                break;
 
                        if (len < 0) {
@@ -183,8 +183,8 @@ static void encode(char *filename, int subbands, int joint)
                        size += len;
                }
 
-               len = sbc_encode(&sbc, input, size, output, sizeof(output),
-                                       &encoded);
+               len = sbc_encode(&sbc, input, size,
+                                       output, sizeof(output), &encoded);
                if (len < size)
                        memmove(input, input + len, size - len);