summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad Midgley <bmidgley@xmission.com>2007-08-26 01:05:25 +0000
committerBrad Midgley <bmidgley@xmission.com>2007-08-26 01:05:25 +0000
commitc82412ad9e399b9b6391ef73c24f36ff83983e9d (patch)
tree72c021ecd5f8f504b4ea70980ccc210591c26caa
parentd542fb37a81d1d96604d41b36a6d6b11087ba2da (diff)
indicate 0 bytes consumed in encoder if input is too short.
caller is responsible for filling the end of the input if it really wants the frame encoded (ie with silence at the end)
-rw-r--r--sbc/sbc.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sbc/sbc.c b/sbc/sbc.c
index ca683e86..240a5d24 100644
--- a/sbc/sbc.c
+++ b/sbc/sbc.c
@@ -28,7 +28,6 @@
use a log2 table for byte integer scale factors calculation (sum log2 results for high and low bytes)
fill bitpool by 16 bits instead of one at a time in bits allocation/bitpool generation
port to the dsp
- don't consume more bytes than passed into the encoder
*/
@@ -1390,6 +1389,10 @@ int sbc_encode(sbc_t *sbc, void *data, int count)
priv->init = 1;
}
+ /* input must be large enough to encode a complete frame */
+ if (count < priv->frame.subbands * priv->frame.blocks * sbc->channels * 2)
+ return 0;
+
ptr = data;
for (i = 0; i < priv->frame.subbands * priv->frame.blocks; i++) {