diff options
-rw-r--r-- | libavcodec/opus_celt.c | 6 | ||||
-rw-r--r-- | libavcodec/opusdsp.c | 11 |
2 files changed, 8 insertions, 9 deletions
diff --git a/libavcodec/opus_celt.c b/libavcodec/opus_celt.c index 4655172..9dbeff1 100644 --- a/libavcodec/opus_celt.c +++ b/libavcodec/opus_celt.c @@ -507,7 +507,11 @@ void ff_celt_flush(CeltFrame *f) memset(block->pf_gains_old, 0, sizeof(block->pf_gains_old)); memset(block->pf_gains_new, 0, sizeof(block->pf_gains_new)); - block->emph_coeff = 0.0; + /* libopus uses CELT_EMPH_COEFF on init, but 0 is better since there's + * a lesser discontinuity when seeking. + * The deemphasis functions differ from libopus in that they require + * an initial state divided by the coefficient. */ + block->emph_coeff = 0.0f / CELT_EMPH_COEFF; } f->seed = 0; diff --git a/libavcodec/opusdsp.c b/libavcodec/opusdsp.c index 0e179c9..08df87f 100644 --- a/libavcodec/opusdsp.c +++ b/libavcodec/opusdsp.c @@ -43,15 +43,10 @@ static void postfilter_c(float *data, int period, float *gains, int len) static float deemphasis_c(float *y, float *x, float coeff, int len) { - float state = coeff; + for (int i = 0; i < len; i++) + coeff = y[i] = x[i] + coeff*CELT_EMPH_COEFF; - for (int i = 0; i < len; i++) { - const float tmp = x[i] + state; - state = tmp * CELT_EMPH_COEFF; - y[i] = tmp; - } - - return state; + return coeff; } av_cold void ff_opus_dsp_init(OpusDSP *ctx) |