diff options
-rw-r--r-- | libcelt/arch.h | 2 | ||||
-rw-r--r-- | libcelt/celt.c | 12 | ||||
-rw-r--r-- | libcelt/celt.h | 3 |
3 files changed, 16 insertions, 1 deletions
diff --git a/libcelt/arch.h b/libcelt/arch.h index f389166..e4f2739 100644 --- a/libcelt/arch.h +++ b/libcelt/arch.h @@ -225,7 +225,7 @@ typedef float celt_mask; #define DIV32(a,b) (((celt_word32)(a))/(celt_word32)(b)) #define PDIV32(a,b) (((celt_word32)(a))/(celt_word32)(b)) -#define SCALEIN(a) (MAX16(-2, MIN16(2,a))*CELT_SIG_SCALE) +#define SCALEIN(a) ((a)*CELT_SIG_SCALE) #define SCALEOUT(a) ((a)*(1/CELT_SIG_SCALE)) #endif /* !FIXED_POINT */ diff --git a/libcelt/celt.c b/libcelt/celt.c index 9d812ed..13af35e 100644 --- a/libcelt/celt.c +++ b/libcelt/celt.c @@ -104,6 +104,7 @@ struct CELTEncoder { int stream_channels; int force_intra; + int clip; int disable_pf; int complexity; int upsample; @@ -230,6 +231,7 @@ CELTEncoder *celt_encoder_init_custom(CELTEncoder *st, const CELTMode *mode, int st->start = 0; st->end = st->mode->effEBands; st->constrained_vbr = 1; + st->clip = 1; st->bitrate = 255000*channels; st->vbr = 0; @@ -1025,6 +1027,10 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i celt_sig x, tmp; x = SCALEIN(*pcmp); +#ifndef FIXED_POINT + if (st->clip) + x = MAX32(-65536.f, MIN32(65536.f,x)); +#endif if (++count==st->upsample) { count=0; @@ -1757,6 +1763,12 @@ int celt_encoder_ctl(CELTEncoder * restrict st, int request, ...) st->tonal_average = QCONST16(1.f,8); } break; + case CELT_SET_INPUT_CLIPPING_REQUEST: + { + celt_int32 value = va_arg(ap, celt_int32); + st->clip = value; + } + break; default: goto bad_request; } diff --git a/libcelt/celt.h b/libcelt/celt.h index d99b0ab..96c1f86 100644 --- a/libcelt/celt.h +++ b/libcelt/celt.h @@ -105,6 +105,9 @@ extern "C" { #define CELT_SET_VBR_REQUEST 12 #define CELT_SET_VBR(x) CELT_SET_VBR_REQUEST, _celt_check_int(x) +#define CELT_SET_INPUT_CLIPPING_REQUEST 14 +#define CELT_SET_INPUT_CLIPPING(x) CELT_SET_INPUT_CLIPPING_REQUEST, _celt_check_int(x) + #define CELT_SET_START_BAND_REQUEST 10000 #define CELT_SET_START_BAND(x) CELT_SET_START_BAND_REQUEST, _celt_check_int(x) |