Commit 0b405d11 authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

Making encoder-side clipping optional

parent 4305ab6b
......@@ -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 */
......
......@@ -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;
}
......
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment