Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/quite/celt.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy B. Terriberry <tterribe@xiph.org>2011-02-01 23:32:34 +0300
committerJean-Marc Valin <jean-marc.valin@octasic.com>2011-02-02 01:06:28 +0300
commitcb8f366af6d80de6815e3375e4d17aee19366607 (patch)
tree1a6008af3d1c1c5abf6c59d5713a9df6a86ca395
parent7bb26e13ca0523e195dc126547bfa8264008ff07 (diff)
Don't allow empty eBands.
Currently compute_ebands()'s attempts to round bands to even sizes and enforce size constraints on consecutive bands can leave some bands entirely empty (e.g., Fs=8000, frame_size=64, i=11). This adds a simple post-processing loop to remove such bands.
-rw-r--r--libcelt/modes.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libcelt/modes.c b/libcelt/modes.c
index 67326b6..c5302b7 100644
--- a/libcelt/modes.c
+++ b/libcelt/modes.c
@@ -133,7 +133,7 @@ static const celt_int16 bark_freq[BARK_BANDS+1] = {
static celt_int16 *compute_ebands(celt_int32 Fs, int frame_size, int res, int *nbEBands)
{
celt_int16 *eBands;
- int i, lin, low, high, nBark, offset=0;
+ int i, j, lin, low, high, nBark, offset=0;
/* All modes that have 2.5 ms short blocks use the same definition */
if (Fs == 400*(celt_int32)frame_size)
@@ -190,6 +190,12 @@ static celt_int16 *compute_ebands(celt_int32 Fs, int frame_size, int res, int *n
eBands[i] -= (2*eBands[i]-eBands[i-1]-eBands[i+1])/2;
}
}
+ /* Remove any empty bands. */
+ for (i=j=0;i<*nbEBands;i++)
+ if(eBands[i+1]>eBands[j])
+ eBands[++j]=eBands[i+1];
+ *nbEBands=j;
+
/*for (i=0;i<=*nbEBands+1;i++)
printf ("%d ", eBands[i]);
printf ("\n");