ref: 5a3d49eb11d4430694e41b7fa59a30627cd19d8a
parent: 137241d089bcd25ce7f2db878a5c8dbbe4e65d9d
author: Jean-Marc Valin <[email protected]>
date: Sun Dec 7 09:39:42 EST 2008
Fixes two bugs in get_required_bits() for the split cwrs case.
--- a/libcelt/cwrs.c
+++ b/libcelt/cwrs.c
@@ -301,8 +301,11 @@
int get_required_bits(int N, int K, int frac)
{
int nbits = 0;
- if(fits_in32(N,K))
+ if (K==0)
{
+ nbits = 0;
+ } else if(fits_in32(N,K))
+ {
VARDECL(celt_uint32_t,u);
SAVE_STACK;
ALLOC(u,K+2,celt_uint32_t);
@@ -309,7 +312,7 @@
nbits = log2_frac(ncwrs_u32(N,K,u), frac);
RESTORE_STACK;
} else {
- nbits = log2_frac(N, frac);
+ nbits = log2_frac(K+1, frac);
nbits += get_required_bits(N/2+1, (K+1)/2, frac);
nbits += get_required_bits(N/2+1, K/2, frac);
}