CELT no longer prints to stderr (unless assertions are enabled)
This commit is contained in:
parent
c09807d3e5
commit
6d3829f266
6 changed files with 17 additions and 68 deletions
|
@ -44,6 +44,13 @@
|
||||||
|
|
||||||
#define celt_fatal(str) _celt_fatal(str, __FILE__, __LINE__);
|
#define celt_fatal(str) _celt_fatal(str, __FILE__, __LINE__);
|
||||||
#ifdef ENABLE_ASSERTIONS
|
#ifdef ENABLE_ASSERTIONS
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
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);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
#define celt_assert(cond) {if (!(cond)) {celt_fatal("assertion failed: " #cond);}}
|
#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);}}
|
#define celt_assert2(cond, message) {if (!(cond)) {celt_fatal("assertion failed: " #cond "\n" message);}}
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -119,20 +119,20 @@ CELTEncoder *celt_encoder_init(CELTEncoder *st, const CELTMode *mode, int channe
|
||||||
{
|
{
|
||||||
if (channels < 0 || channels > 2)
|
if (channels < 0 || channels > 2)
|
||||||
{
|
{
|
||||||
celt_warning("Only mono and stereo supported");
|
|
||||||
if (error)
|
if (error)
|
||||||
*error = CELT_BAD_ARG;
|
*error = CELT_BAD_ARG;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CELT_MEMSET((char*)st, 0, celt_encoder_get_size(mode, channels));
|
|
||||||
|
|
||||||
if (st==NULL)
|
if (st==NULL)
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
*error = CELT_ALLOC_FAIL;
|
*error = CELT_ALLOC_FAIL;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CELT_MEMSET((char*)st, 0, celt_encoder_get_size(mode, channels));
|
||||||
|
|
||||||
st->mode = mode;
|
st->mode = mode;
|
||||||
st->overlap = mode->overlap;
|
st->overlap = mode->overlap;
|
||||||
st->channels = channels;
|
st->channels = channels;
|
||||||
|
@ -1155,14 +1155,11 @@ CELTDecoder *celt_decoder_init(CELTDecoder *st, const CELTMode *mode, int channe
|
||||||
{
|
{
|
||||||
if (channels < 0 || channels > 2)
|
if (channels < 0 || channels > 2)
|
||||||
{
|
{
|
||||||
celt_warning("Only mono and stereo supported");
|
|
||||||
if (error)
|
if (error)
|
||||||
*error = CELT_BAD_ARG;
|
*error = CELT_BAD_ARG;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CELT_MEMSET((char*)st, 0, celt_decoder_get_size(mode, channels));
|
|
||||||
|
|
||||||
if (st==NULL)
|
if (st==NULL)
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
|
@ -1170,6 +1167,8 @@ CELTDecoder *celt_decoder_init(CELTDecoder *st, const CELTMode *mode, int channe
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CELT_MEMSET((char*)st, 0, celt_decoder_get_size(mode, channels));
|
||||||
|
|
||||||
st->mode = mode;
|
st->mode = mode;
|
||||||
st->overlap = mode->overlap;
|
st->overlap = mode->overlap;
|
||||||
st->channels = channels;
|
st->channels = channels;
|
||||||
|
|
|
@ -45,10 +45,7 @@ void ec_byte_readinit(ec_byte_buffer *_b,unsigned char *_buf,ec_uint32 _bytes){
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char ec_byte_look_at_end(ec_byte_buffer *_b){
|
unsigned char ec_byte_look_at_end(ec_byte_buffer *_b){
|
||||||
if (_b->end_ptr < _b->buf)
|
celt_assert2 (_b->end_ptr >= _b->buf, "Trying to read raw bits before the beginning of the stream");
|
||||||
{
|
|
||||||
celt_fatal("Trying to read raw bits before the beginning of the stream");
|
|
||||||
}
|
|
||||||
return *(_b->end_ptr--);
|
return *(_b->end_ptr--);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +96,6 @@ ec_uint32 ec_dec_uint(ec_dec *_this,ec_uint32 _ft){
|
||||||
t = t<<ftb|ec_dec_bits(_this,ftb);
|
t = t<<ftb|ec_dec_bits(_this,ftb);
|
||||||
if (t>_ft)
|
if (t>_ft)
|
||||||
{
|
{
|
||||||
celt_notify("uint decode error");
|
|
||||||
_this->error |= 1;
|
_this->error |= 1;
|
||||||
t = _ft;
|
t = _ft;
|
||||||
}
|
}
|
||||||
|
|
|
@ -460,8 +460,6 @@ static void kf_work(
|
||||||
#ifndef RADIX_TWO_ONLY
|
#ifndef RADIX_TWO_ONLY
|
||||||
case 3: kf_bfly3(Fout,fstride,st,m, N, m2); break;
|
case 3: kf_bfly3(Fout,fstride,st,m, N, m2); break;
|
||||||
case 5: kf_bfly5(Fout,fstride,st,m, N, m2); break;
|
case 5: kf_bfly5(Fout,fstride,st,m, N, m2); break;
|
||||||
#else
|
|
||||||
default: celt_fatal("kiss_fft: only powers of two enabled");
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -494,8 +492,6 @@ static void ki_work(
|
||||||
#ifndef RADIX_TWO_ONLY
|
#ifndef RADIX_TWO_ONLY
|
||||||
case 3: ki_bfly3(Fout,fstride,st,m, N, m2); break;
|
case 3: ki_bfly3(Fout,fstride,st,m, N, m2); break;
|
||||||
case 5: ki_bfly5(Fout,fstride,st,m, N, m2); break;
|
case 5: ki_bfly5(Fout,fstride,st,m, N, m2); break;
|
||||||
#else
|
|
||||||
default: celt_fatal("kiss_fft: only powers of two enabled");
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -558,9 +554,12 @@ int kf_factor(int n,celt_int16 * facbuf)
|
||||||
p = n; /* no more factors, skip to end */
|
p = n; /* no more factors, skip to end */
|
||||||
}
|
}
|
||||||
n /= p;
|
n /= p;
|
||||||
|
#ifdef RADIX_TWO_ONLY
|
||||||
|
if (p!=2 && p != 4)
|
||||||
|
#else
|
||||||
if (p>5)
|
if (p>5)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
celt_warning("Only powers of 2, 3 and 5 are supported");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
*facbuf++ = p;
|
*facbuf++ = p;
|
||||||
|
|
|
@ -262,7 +262,6 @@ CELTMode *celt_mode_create(celt_int32 Fs, int frame_size, int *error)
|
||||||
return (CELTMode*)static_mode_list[i];
|
return (CELTMode*)static_mode_list[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
celt_warning("Mode not included as part of the static modes");
|
|
||||||
if (error)
|
if (error)
|
||||||
*error = CELT_BAD_ARG;
|
*error = CELT_BAD_ARG;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -291,14 +290,12 @@ CELTMode *celt_mode_create(celt_int32 Fs, int frame_size, int *error)
|
||||||
|
|
||||||
if (Fs < 8000 || Fs > 96000)
|
if (Fs < 8000 || Fs > 96000)
|
||||||
{
|
{
|
||||||
celt_warning("Sampling rate must be between 8 kHz and 96 kHz");
|
|
||||||
if (error)
|
if (error)
|
||||||
*error = CELT_BAD_ARG;
|
*error = CELT_BAD_ARG;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (frame_size < 40 || frame_size > 1024 || frame_size%2!=0)
|
if (frame_size < 40 || frame_size > 1024 || frame_size%2!=0)
|
||||||
{
|
{
|
||||||
celt_warning("Only even frame sizes from 40 to 1024 are supported");
|
|
||||||
if (error)
|
if (error)
|
||||||
*error = CELT_BAD_ARG;
|
*error = CELT_BAD_ARG;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -428,10 +425,7 @@ void celt_mode_destroy(CELTMode *mode)
|
||||||
{
|
{
|
||||||
#ifndef STATIC_MODES
|
#ifndef STATIC_MODES
|
||||||
if (mode == NULL)
|
if (mode == NULL)
|
||||||
{
|
|
||||||
celt_warning("NULL passed to celt_mode_destroy");
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
celt_free((celt_int16*)mode->eBands);
|
celt_free((celt_int16*)mode->eBands);
|
||||||
celt_free((celt_int16*)mode->allocVectors);
|
celt_free((celt_int16*)mode->allocVectors);
|
||||||
|
|
|
@ -63,14 +63,6 @@ static inline void *celt_alloc_scratch (int size)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** CELT wrapper for realloc(). To do your own dynamic allocation, all you need to do is replace this function, celt_alloc and celt_free */
|
|
||||||
#ifndef OVERRIDE_CELT_REALLOC
|
|
||||||
static inline void *celt_realloc (void *ptr, int size)
|
|
||||||
{
|
|
||||||
return realloc(ptr, size);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** CELT wrapper for free(). To do your own dynamic allocation, all you need to do is replace this function, celt_realloc and celt_alloc */
|
/** CELT wrapper for free(). To do your own dynamic allocation, all you need to do is replace this function, celt_realloc and celt_alloc */
|
||||||
#ifndef OVERRIDE_CELT_FREE
|
#ifndef OVERRIDE_CELT_FREE
|
||||||
static inline void celt_free (void *ptr)
|
static inline void celt_free (void *ptr)
|
||||||
|
@ -103,44 +95,6 @@ static inline void celt_free_scratch (void *ptr)
|
||||||
#define CELT_MEMSET(dst, c, n) (memset((dst), (c), (n)*sizeof(*(dst))))
|
#define CELT_MEMSET(dst, c, n) (memset((dst), (c), (n)*sizeof(*(dst))))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifndef OVERRIDE_CELT_FATAL
|
|
||||||
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);
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef OVERRIDE_CELT_WARNING
|
|
||||||
static inline void celt_warning(const char *str)
|
|
||||||
{
|
|
||||||
#ifndef DISABLE_WARNINGS
|
|
||||||
fprintf (stderr, "warning: %s\n", str);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef OVERRIDE_CELT_WARNING_INT
|
|
||||||
static inline void celt_warning_int(const char *str, int val)
|
|
||||||
{
|
|
||||||
#ifndef DISABLE_WARNINGS
|
|
||||||
fprintf (stderr, "warning: %s %d\n", str, val);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef OVERRIDE_CELT_NOTIFY
|
|
||||||
static inline void celt_notify(const char *str)
|
|
||||||
{
|
|
||||||
#ifndef DISABLE_NOTIFICATIONS
|
|
||||||
fprintf (stderr, "notification: %s\n", str);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*#ifdef __GNUC__
|
/*#ifdef __GNUC__
|
||||||
#pragma GCC poison printf sprintf
|
#pragma GCC poison printf sprintf
|
||||||
#pragma GCC poison malloc free realloc calloc
|
#pragma GCC poison malloc free realloc calloc
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue