#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#define CELT_DECODER_C
#include "cpu_support.h"
#include "os_support.h"
#include "mdct.h"
#include <math.h>
#include "celt.h"
#include "pitch.h"
#include "bands.h"
#include "modes.h"
#include "entcode.h"
#include "quant_bands.h"
#include "rate.h"
#include "stack_alloc.h"
#include "mathops.h"
#include "float_cast.h"
#include <stdarg.h>
#include "celt_lpc.h"
#include "vq.h"
#define PLC_PITCH_LAG_MAX …
#define PLC_PITCH_LAG_MIN …
#if defined(SMALL_FOOTPRINT) && defined(FIXED_POINT)
#define NORM_ALIASING_HACK
#endif
#define DECODE_BUFFER_SIZE …
struct OpusCustomDecoder { … };
#if defined(ENABLE_HARDENING) || defined(ENABLE_ASSERTIONS)
void validate_celt_decoder(CELTDecoder *st)
{ … }
#endif
int celt_decoder_get_size(int channels)
{ … }
OPUS_CUSTOM_NOSTATIC int opus_custom_decoder_get_size(const CELTMode *mode, int channels)
{ … }
#ifdef CUSTOM_MODES
CELTDecoder *opus_custom_decoder_create(const CELTMode *mode, int channels, int *error)
{
int ret;
CELTDecoder *st = (CELTDecoder *)opus_alloc(opus_custom_decoder_get_size(mode, channels));
ret = opus_custom_decoder_init(st, mode, channels);
if (ret != OPUS_OK)
{
opus_custom_decoder_destroy(st);
st = NULL;
}
if (error)
*error = ret;
return st;
}
#endif
int celt_decoder_init(CELTDecoder *st, opus_int32 sampling_rate, int channels)
{ … }
OPUS_CUSTOM_NOSTATIC int opus_custom_decoder_init(CELTDecoder *st, const CELTMode *mode, int channels)
{ … }
#ifdef CUSTOM_MODES
void opus_custom_decoder_destroy(CELTDecoder *st)
{
opus_free(st);
}
#endif
#ifndef CUSTOM_MODES
static void deemphasis_stereo_simple(celt_sig *in[], opus_val16 *pcm, int N, const opus_val16 coef0,
celt_sig *mem)
{ … }
#endif
#ifndef RESYNTH
static
#endif
void deemphasis(celt_sig *in[], opus_val16 *pcm, int N, int C, int downsample, const opus_val16 *coef,
celt_sig *mem, int accum)
{ … }
#ifndef RESYNTH
static
#endif
void celt_synthesis(const CELTMode *mode, celt_norm *X, celt_sig * out_syn[],
opus_val16 *oldBandE, int start, int effEnd, int C, int CC,
int isTransient, int LM, int downsample,
int silence, int arch)
{ … }
static void tf_decode(int start, int end, int isTransient, int *tf_res, int LM, ec_dec *dec)
{ … }
static int celt_plc_pitch_search(celt_sig *decode_mem[2], int C, int arch)
{ … }
static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM)
{ … }
int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *data,
int len, opus_val16 * OPUS_RESTRICT pcm, int frame_size, ec_dec *dec, int accum)
{ … }
#ifdef CUSTOM_MODES
#ifdef FIXED_POINT
int opus_custom_decode(CELTDecoder * OPUS_RESTRICT st, const unsigned char *data, int len, opus_int16 * OPUS_RESTRICT pcm, int frame_size)
{
return celt_decode_with_ec(st, data, len, pcm, frame_size, NULL, 0);
}
#ifndef DISABLE_FLOAT_API
int opus_custom_decode_float(CELTDecoder * OPUS_RESTRICT st, const unsigned char *data, int len, float * OPUS_RESTRICT pcm, int frame_size)
{
int j, ret, C, N;
VARDECL(opus_int16, out);
ALLOC_STACK;
if (pcm==NULL)
return OPUS_BAD_ARG;
C = st->channels;
N = frame_size;
ALLOC(out, C*N, opus_int16);
ret=celt_decode_with_ec(st, data, len, out, frame_size, NULL, 0);
if (ret>0)
for (j=0;j<C*ret;j++)
pcm[j]=out[j]*(1.f/32768.f);
RESTORE_STACK;
return ret;
}
#endif
#else
int opus_custom_decode_float(CELTDecoder * OPUS_RESTRICT st, const unsigned char *data, int len, float * OPUS_RESTRICT pcm, int frame_size)
{
return celt_decode_with_ec(st, data, len, pcm, frame_size, NULL, 0);
}
int opus_custom_decode(CELTDecoder * OPUS_RESTRICT st, const unsigned char *data, int len, opus_int16 * OPUS_RESTRICT pcm, int frame_size)
{
int j, ret, C, N;
VARDECL(celt_sig, out);
ALLOC_STACK;
if (pcm==NULL)
return OPUS_BAD_ARG;
C = st->channels;
N = frame_size;
ALLOC(out, C*N, celt_sig);
ret=celt_decode_with_ec(st, data, len, out, frame_size, NULL, 0);
if (ret>0)
for (j=0;j<C*ret;j++)
pcm[j] = FLOAT2INT16 (out[j]);
RESTORE_STACK;
return ret;
}
#endif
#endif
int opus_custom_decoder_ctl(CELTDecoder * OPUS_RESTRICT st, int request, ...)
{ … }