From c82412ad9e399b9b6391ef73c24f36ff83983e9d Mon Sep 17 00:00:00 2001 From: Brad Midgley Date: Sun, 26 Aug 2007 01:05:25 +0000 Subject: 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) --- sbc/sbc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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++) { -- cgit