X-Git-Url: http://git.xiph.org/?p=opus.git;a=blobdiff_plain;f=libcelt%2Frate.h;h=e1346eedf07c8c592914cb28226e9c2455f1de81;hp=283875ac64611cafcf4cbfc19ac3594a4d49ccda;hb=a6b4e25628b3ea2671aec87058805b83c5b48b34;hpb=b2f59009f6a1ef5b9faba6c9e256bbee65f8f9f7;ds=sidebyside diff --git a/libcelt/rate.h b/libcelt/rate.h index 283875ac..e1346eed 100644 --- a/libcelt/rate.h +++ b/libcelt/rate.h @@ -5,18 +5,14 @@ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - + - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - + - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -38,12 +34,11 @@ #define MAX_PULSES 128 -#define BITRES 3 +#define MAX_FINE_BITS 8 + #define FINE_OFFSET 21 #define QTHETA_OFFSET 4 -#define QTHETA_OFFSET_STEREO 4 - -#define BITOVERFLOW 30000 +#define QTHETA_OFFSET_TWOPHASE 16 #include "cwrs.h" #include "modes.h" @@ -66,16 +61,17 @@ static inline int bits2pulses(const CELTMode *m, int band, int LM, int bits) lo = 0; hi = cache[0]; + bits--; for (i=0;i>1; + int mid = (lo+hi+1)>>1; /* OPT: Make sure this is implemented with a conditional move */ - if (cache[mid]+1 >= bits) + if (cache[mid] >= bits) hi = mid; else lo = mid; } - if (bits- (lo == 0 ? 0 : cache[lo]+1) <= cache[hi]+1-bits) + if (bits- (lo == 0 ? -1 : cache[lo]) <= cache[hi]-bits) return lo; else return hi; @@ -91,10 +87,10 @@ static inline int pulses2bits(const CELTMode *m, int band, int LM, int pulses) } /** Computes a cache of the pulses->bits mapping in each band */ -celt_int16 **compute_alloc_cache(CELTMode *m, int M); +opus_int16 **compute_alloc_cache(CELTMode *m, int M); /** Compute the pulse allocation, i.e. how many pulses will go in each - * band. + * band. @param m mode @param offsets Requested increase or decrease in the number of bits for each band @@ -102,8 +98,7 @@ celt_int16 **compute_alloc_cache(CELTMode *m, int M); @param pulses Number of pulses per band (returned) @return Total number of bits allocated */ -int compute_allocation(const CELTMode *m, int start, int end, int *offsets, int alloc_trim, - int total, int *pulses, int *ebits, int *fine_priority, int _C, int LM, void *ec, int encode, int prev); - +int compute_allocation(const CELTMode *m, int start, int end, const int *offsets, const int *cap, int alloc_trim, int *intensity, int *dual_stero, + opus_int32 total, opus_int32 *balance, int *pulses, int *ebits, int *fine_priority, int _C, int LM, ec_ctx *ec, int encode, int prev); #endif