| 1 | /* Copyright (c) 2007-2008 CSIRO |
| 2 | Copyright (c) 2007-2009 Xiph.Org Foundation |
| 3 | Written by Jean-Marc Valin */ |
| 4 | /* |
| 5 | Redistribution and use in source and binary forms, with or without |
| 6 | modification, are permitted provided that the following conditions |
| 7 | are met: |
| 8 | |
| 9 | - Redistributions of source code must retain the above copyright |
| 10 | notice, this list of conditions and the following disclaimer. |
| 11 | |
| 12 | - Redistributions in binary form must reproduce the above copyright |
| 13 | notice, this list of conditions and the following disclaimer in the |
| 14 | documentation and/or other materials provided with the distribution. |
| 15 | |
| 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER |
| 20 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 21 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 22 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 23 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 24 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 25 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | */ |
| 28 | |
| 29 | #ifndef RATE_H |
| 30 | #define RATE_Hcxx . . $ `external/opusfile/opus/celt/rate.h:30:9`! |
| 31 | |
| 32 | #define MAX_PSEUDOcxx . . $ `external/opusfile/opus/celt/rate.h:32:9`! 40 |
| 33 | #define LOG_MAX_PSEUDOcxx . . $ `external/opusfile/opus/celt/rate.h:33:9`! 6 |
| 34 | |
| 35 | #define CELT_MAX_PULSEScxx . . $ `external/opusfile/opus/celt/rate.h:35:9`! 128 |
| 36 | |
| 37 | #define MAX_FINE_BITScxx . . $ `external/opusfile/opus/celt/rate.h:37:9`! 8 |
| 38 | |
| 39 | #define FINE_OFFSETcxx . . $ `external/opusfile/opus/celt/rate.h:39:9`! 21 |
| 40 | #define QTHETA_OFFSETcxx . . $ `external/opusfile/opus/celt/rate.h:40:9`! 4 |
| 41 | #define QTHETA_OFFSET_TWOPHASEcxx . . $ `external/opusfile/opus/celt/rate.h:41:9`! 16 |
| 42 | |
| 43 | #include "cwrs.h"cxx . . $ `<file>/external/opusfile/opus/celt/cwrs.h`/ |
| 44 | #include "modes.h"cxx . . $ `<file>/external/opusfile/opus/celt/modes.h`/ |
| 45 | |
| 46 | void compute_pulse_cachecxx . . $ compute_pulse_cache(28166303c6baa085).(CELTModecxx . . $ OpusCustomMode# *m, int LM); |
| 47 | |
| 48 | static OPUS_INLINEcxx . . $ `external/opusfile/opus/opus_defines.h:110:10`! int get_pulsescxx . . $ get_pulses(7864480464b09eea).(int i) |
| 49 | { |
| 50 | return i<8 ? i : (8 + (i&7)) << ((i>>3)-1); |
| 51 | } |
| 52 | |
| 53 | static OPUS_INLINEcxx . . $ `external/opusfile/opus/opus_defines.h:110:10`! int bits2pulsescxx . . $ bits2pulses(8c1324332b2af3ed).(const CELTModecxx . . $ OpusCustomMode# *m, int band, int LM, int bits) |
| 54 | { |
| 55 | int i; |
| 56 | int lo, hi; |
| 57 | const unsigned char *cache; |
| 58 | |
| 59 | LM++; |
| 60 | cache = m->cachecxx . . $ OpusCustomMode#cache..bitscxx . . $ $anonymous_type_98491fdeb727afd2_0#bits. + m->cachecxx . . $ OpusCustomMode#cache..indexcxx . . $ $anonymous_type_98491fdeb727afd2_0#index.[LM*m->nbEBandscxx . . $ OpusCustomMode#nbEBands.+band]; |
| 61 | |
| 62 | lo = 0; |
| 63 | hi = cache[0]; |
| 64 | bits--; |
| 65 | for (i=0;i<LOG_MAX_PSEUDOcxx . . $ `external/opusfile/opus/celt/rate.h:33:9`!;i++) |
| 66 | { |
| 67 | int mid = (lo+hi+1)>>1; |
| 68 | /* OPT: Make sure this is implemented with a conditional move */ |
| 69 | if ((int)cache[mid] >= bits) |
| 70 | hi = mid; |
| 71 | else |
| 72 | lo = mid; |
| 73 | } |
| 74 | if (bits- (lo == 0 ? -1 : (int)cache[lo]) <= (int)cache[hi]-bits) |
| 75 | return lo; |
| 76 | else |
| 77 | return hi; |
| 78 | } |
| 79 | |
| 80 | static OPUS_INLINEcxx . . $ `external/opusfile/opus/opus_defines.h:110:10`! int pulses2bitscxx . . $ pulses2bits(8c1324332b2af3ed).(const CELTModecxx . . $ `external/opusfile/opus/celt/celt.h:51:9`! *m, int band, int LM, int pulses) |
| 81 | { |
| 82 | const unsigned char *cache; |
| 83 | |
| 84 | LM++; |
| 85 | cache = m->cachecxx . . $ OpusCustomMode#cache..bitscxx . . $ $anonymous_type_98491fdeb727afd2_0#bits. + m->cachecxx . . $ OpusCustomMode#cache..indexcxx . . $ $anonymous_type_98491fdeb727afd2_0#index.[LM*m->nbEBandscxx . . $ OpusCustomMode#nbEBands.+band]; |
| 86 | return pulses == 0 ? 0 : cache[pulses]+1; |
| 87 | } |
| 88 | |
| 89 | /** Compute the pulse allocation, i.e. how many pulses will go in each |
| 90 | * band. |
| 91 | @param m mode |
| 92 | @param offsets Requested increase or decrease in the number of bits for |
| 93 | each band |
| 94 | @param total Number of bands |
| 95 | @param pulses Number of pulses per band (returned) |
| 96 | @return Total number of bits allocated |
| 97 | */ |
| 98 | int clt_compute_allocationcxx . . $ clt_compute_allocation(a1d939ebf50a647d).(const CELTModecxx . . $ OpusCustomMode# *m, int start, int end, const int *offsets, const int *cap, int alloc_trim, int *intensity, int *dual_stereo, |
| 99 | opus_int32cxx . . $ opus_int32# total, opus_int32cxx . . $ opus_int32# *balance, int *pulses, int *ebits, int *fine_priority, int C, int LM, ec_ctxcxx . . $ ec_ctx# *ec, int encode, int prev, int signalBandwidth); |
| 100 | |
| 101 | #endif |