Chris@69: /* Copyright (c) 2007-2008 CSIRO Chris@69: Copyright (c) 2007-2010 Xiph.Org Foundation Chris@69: Copyright (c) 2008 Gregory Maxwell Chris@69: Written by Jean-Marc Valin and Gregory Maxwell */ Chris@69: /* Chris@69: Redistribution and use in source and binary forms, with or without Chris@69: modification, are permitted provided that the following conditions Chris@69: are met: Chris@69: Chris@69: - Redistributions of source code must retain the above copyright Chris@69: notice, this list of conditions and the following disclaimer. Chris@69: Chris@69: - Redistributions in binary form must reproduce the above copyright Chris@69: notice, this list of conditions and the following disclaimer in the Chris@69: documentation and/or other materials provided with the distribution. Chris@69: Chris@69: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS Chris@69: ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT Chris@69: LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR Chris@69: A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER Chris@69: OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, Chris@69: EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, Chris@69: PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR Chris@69: PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF Chris@69: LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING Chris@69: NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS Chris@69: SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Chris@69: */ Chris@69: Chris@69: #ifdef HAVE_CONFIG_H Chris@69: #include "config.h" Chris@69: #endif Chris@69: Chris@69: #define CELT_C Chris@69: Chris@69: #include "os_support.h" Chris@69: #include "mdct.h" Chris@69: #include Chris@69: #include "celt.h" Chris@69: #include "pitch.h" Chris@69: #include "bands.h" Chris@69: #include "modes.h" Chris@69: #include "entcode.h" Chris@69: #include "quant_bands.h" Chris@69: #include "rate.h" Chris@69: #include "stack_alloc.h" Chris@69: #include "mathops.h" Chris@69: #include "float_cast.h" Chris@69: #include Chris@69: #include "celt_lpc.h" Chris@69: #include "vq.h" Chris@69: Chris@69: #ifndef PACKAGE_VERSION Chris@69: #define PACKAGE_VERSION "unknown" Chris@69: #endif Chris@69: Chris@69: #if defined(MIPSr1_ASM) Chris@69: #include "mips/celt_mipsr1.h" Chris@69: #endif Chris@69: Chris@69: Chris@69: int resampling_factor(opus_int32 rate) Chris@69: { Chris@69: int ret; Chris@69: switch (rate) Chris@69: { Chris@69: case 48000: Chris@69: ret = 1; Chris@69: break; Chris@69: case 24000: Chris@69: ret = 2; Chris@69: break; Chris@69: case 16000: Chris@69: ret = 3; Chris@69: break; Chris@69: case 12000: Chris@69: ret = 4; Chris@69: break; Chris@69: case 8000: Chris@69: ret = 6; Chris@69: break; Chris@69: default: Chris@69: #ifndef CUSTOM_MODES Chris@69: celt_assert(0); Chris@69: #endif Chris@69: ret = 0; Chris@69: break; Chris@69: } Chris@69: return ret; Chris@69: } Chris@69: Chris@69: #if !defined(OVERRIDE_COMB_FILTER_CONST) || defined(NON_STATIC_COMB_FILTER_CONST_C) Chris@69: /* This version should be faster on ARM */ Chris@69: #ifdef OPUS_ARM_ASM Chris@69: #ifndef NON_STATIC_COMB_FILTER_CONST_C Chris@69: static Chris@69: #endif Chris@69: void comb_filter_const_c(opus_val32 *y, opus_val32 *x, int T, int N, Chris@69: opus_val16 g10, opus_val16 g11, opus_val16 g12) Chris@69: { Chris@69: opus_val32 x0, x1, x2, x3, x4; Chris@69: int i; Chris@69: x4 = SHL32(x[-T-2], 1); Chris@69: x3 = SHL32(x[-T-1], 1); Chris@69: x2 = SHL32(x[-T], 1); Chris@69: x1 = SHL32(x[-T+1], 1); Chris@69: for (i=0;inbEBands;i++) Chris@69: { Chris@69: int N; Chris@69: N=(m->eBands[i+1]-m->eBands[i])<cache.caps[m->nbEBands*(2*LM+C-1)+i]+64)*C*N>>2; Chris@69: } Chris@69: } Chris@69: Chris@69: Chris@69: Chris@69: const char *opus_strerror(int error) Chris@69: { Chris@69: static const char * const error_strings[8] = { Chris@69: "success", Chris@69: "invalid argument", Chris@69: "buffer too small", Chris@69: "internal error", Chris@69: "corrupted stream", Chris@69: "request not implemented", Chris@69: "invalid state", Chris@69: "memory allocation failed" Chris@69: }; Chris@69: if (error > 0 || error < -7) Chris@69: return "unknown error"; Chris@69: else Chris@69: return error_strings[-error]; Chris@69: } Chris@69: Chris@69: const char *opus_get_version_string(void) Chris@69: { Chris@69: return "libopus " PACKAGE_VERSION Chris@69: /* Applications may rely on the presence of this substring in the version Chris@69: string to determine if they have a fixed-point or floating-point build Chris@69: at runtime. */ Chris@69: #ifdef FIXED_POINT Chris@69: "-fixed" Chris@69: #endif Chris@69: #ifdef FUZZING Chris@69: "-fuzzing" Chris@69: #endif Chris@69: ; Chris@69: }