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