Making sure not to use the C library calls directly
This commit is contained in:
parent
4ff068e670
commit
c7e0b76c06
12 changed files with 31 additions and 36 deletions
|
@ -224,8 +224,5 @@ struct kiss_fft_state{
|
|||
(x)->i = TRIG_UPSCALE*celt_cos_norm((phase)-32768);\
|
||||
}while(0)
|
||||
|
||||
/* a debugging function */
|
||||
#define pcpx(c)\
|
||||
fprintf(stderr,"%g + %gi\n",(double)((c)->r),(double)((c)->i) )
|
||||
|
||||
#endif /* KISS_FFT_GUTS_H */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* Copyright (C) 2003-2008 Jean-Marc Valin */
|
||||
/**
|
||||
@file arch.h
|
||||
@brief Various architecture definitions Speex
|
||||
@brief Various architecture definitions for CELT
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
@ -36,7 +36,17 @@
|
|||
#define ARCH_H
|
||||
|
||||
#include "celt_types.h"
|
||||
#include "stack_alloc.h"
|
||||
|
||||
|
||||
#define celt_fatal(str) _celt_fatal(str, __FILE__, __LINE__);
|
||||
#ifdef ENABLE_ASSERTIONS
|
||||
#define celt_assert(cond) {if (!(cond)) {celt_fatal("assertion failed: " #cond);}}
|
||||
#define celt_assert2(cond, message) {if (!(cond)) {celt_fatal("assertion failed: " #cond "\n" message);}}
|
||||
#else
|
||||
#define celt_assert(cond)
|
||||
#define celt_assert2(cond, message)
|
||||
#endif
|
||||
|
||||
|
||||
#define ABS(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute integer value. */
|
||||
#define ABS16(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 16-bit value. */
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "modes.h"
|
||||
#include "vq.h"
|
||||
#include "cwrs.h"
|
||||
#include "stack_alloc.h"
|
||||
#include "os_support.h"
|
||||
#include "mathops.h"
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "quant_bands.h"
|
||||
#include "psy.h"
|
||||
#include "rate.h"
|
||||
#include "stack_alloc.h"
|
||||
|
||||
static const celt_word16_t preemph = QCONST16(0.8f,15);
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#define CWRS_H
|
||||
|
||||
#include "arch.h"
|
||||
#include "stack_alloc.h"
|
||||
#include "entenc.h"
|
||||
#include "entdec.h"
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ void ec_byte_writecopy(ec_byte_buffer *_b,void *_source,long _bytes){
|
|||
}
|
||||
|
||||
void ec_byte_writeclear(ec_byte_buffer *_b){
|
||||
free(_b->buf);
|
||||
celt_free(_b->buf);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#include "os_support.h"
|
||||
#include "_kiss_fft_guts.h"
|
||||
#include "mathops.h"
|
||||
#include "stack_alloc.h"
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.141592653
|
||||
|
|
|
@ -116,7 +116,7 @@ static inline void celt_free_scratch (void *ptr)
|
|||
static inline void _celt_fatal(const char *str, const char *file, int line)
|
||||
{
|
||||
fprintf (stderr, "Fatal (internal) error in %s, line %d: %s\n", file, line, str);
|
||||
exit(1);
|
||||
abort();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -147,24 +147,12 @@ static inline void celt_notify(const char *str)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifndef OVERRIDE_CELT_PUTC
|
||||
/** Speex wrapper for putc */
|
||||
static inline void _celt_putc(int ch, void *file)
|
||||
{
|
||||
FILE *f = (FILE *)file;
|
||||
fprintf(f, "%c", ch);
|
||||
}
|
||||
#endif
|
||||
|
||||
#define celt_fatal(str) _celt_fatal(str, __FILE__, __LINE__);
|
||||
#ifdef ENABLE_ASSERTIONS
|
||||
#define celt_assert(cond) {if (!(cond)) {celt_fatal("assertion failed: " #cond);}}
|
||||
#define celt_assert2(cond, message) {if (!(cond)) {celt_fatal("assertion failed: " #cond "\n" message);}}
|
||||
#else
|
||||
#define celt_assert(cond)
|
||||
#define celt_assert2(cond, message)
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC poison printf sprintf
|
||||
#pragma GCC poison malloc free realloc calloc
|
||||
#endif
|
||||
|
||||
#endif /* OS_SUPPORT_H */
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "psy.h"
|
||||
#include "os_support.h"
|
||||
#include "mathops.h"
|
||||
#include "stack_alloc.h"
|
||||
|
||||
kiss_fftr_cfg pitch_state_alloc(int max_lag)
|
||||
{
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "os_support.h"
|
||||
#include "arch.h"
|
||||
#include "mathops.h"
|
||||
#include "stack_alloc.h"
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
const celt_word16_t eMeans[24] = {11520, -2048, -3072, -640, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
|
|
|
@ -39,8 +39,6 @@
|
|||
#include "arch.h"
|
||||
#include "mathops.h"
|
||||
|
||||
//#define PGAIN(codebook, i) ((celt_pgain_t)(Q15ONE*(codebook)[i]))
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
#define PGAIN(codebook, i) ((i)&1 ? (celt_word16_t)(((codebook)[(i)>>1]&0x00ffU)<<7) : (celt_word16_t)(((codebook)[(i)>>1]&0xff00U)>>1) )
|
||||
#else
|
||||
|
@ -55,7 +53,7 @@
|
|||
int vq_index(celt_pgain_t *in, const celt_uint16_t *codebook, int len, int entries)
|
||||
{
|
||||
int i,j;
|
||||
int index = 0;
|
||||
int ind = 0;
|
||||
celt_word32_t min_dist=0;
|
||||
int best_index=0;
|
||||
for (i=0;i<entries;i++)
|
||||
|
@ -63,8 +61,8 @@ int vq_index(celt_pgain_t *in, const celt_uint16_t *codebook, int len, int entri
|
|||
celt_word32_t dist=0;
|
||||
for (j=0;j<len;j++)
|
||||
{
|
||||
celt_pgain_t tmp = SHR16(SUB16(in[j],PGAIN(codebook, index)),1);
|
||||
index++;
|
||||
celt_pgain_t tmp = SHR16(SUB16(in[j],PGAIN(codebook, ind)),1);
|
||||
ind++;
|
||||
dist = MAC16_16(dist, tmp, tmp);
|
||||
}
|
||||
if (i==0 || dist<min_dist)
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include "os_support.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
@ -106,11 +105,10 @@ int main(int argc, char *argv[])
|
|||
|
||||
celt_mode_info(mode, CELT_GET_FRAME_SIZE, &frame_size);
|
||||
celt_mode_info(mode, CELT_GET_NB_CHANNELS, &channels);
|
||||
in = (celt_int16_t*)celt_alloc(frame_size*channels*sizeof(celt_int16_t));
|
||||
out = (celt_int16_t*)celt_alloc(frame_size*channels*sizeof(celt_int16_t));
|
||||
in = (celt_int16_t*)malloc(frame_size*channels*sizeof(celt_int16_t));
|
||||
out = (celt_int16_t*)malloc(frame_size*channels*sizeof(celt_int16_t));
|
||||
while (!feof(fin))
|
||||
{
|
||||
SAVE_STACK;
|
||||
fread(in, sizeof(short), frame_size*channels, fin);
|
||||
if (feof(fin))
|
||||
break;
|
||||
|
@ -118,7 +116,6 @@ int main(int argc, char *argv[])
|
|||
if (len <= 0)
|
||||
{
|
||||
fprintf (stderr, "celt_encode() returned %d\n", len);
|
||||
RESTORE_STACK;
|
||||
return 1;
|
||||
}
|
||||
/* This is to simulate packet loss */
|
||||
|
@ -141,7 +138,6 @@ int main(int argc, char *argv[])
|
|||
count++;
|
||||
fwrite(out, sizeof(short), (frame_size-skip)*channels, fout);
|
||||
skip = 0;
|
||||
RESTORE_STACK;
|
||||
}
|
||||
celt_encoder_destroy(enc);
|
||||
celt_decoder_destroy(dec);
|
||||
|
@ -159,8 +155,8 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
#endif
|
||||
celt_mode_destroy(mode);
|
||||
celt_free(in);
|
||||
celt_free(out);
|
||||
free(in);
|
||||
free(out);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue