summaryrefslogtreecommitdiff
path: root/libavcodec/opus_celt.c
diff options
context:
space:
mode:
authorLynne <dev@lynne.ee>2019-08-15 11:13:35 +0100
committerLynne <dev@lynne.ee>2019-09-11 03:28:22 +0100
commit6b22e28f4c857b2d9c045001add083343f506d84 (patch)
tree703f78608be9880729a27e60922b85d61e933017 /libavcodec/opus_celt.c
parent40a433e34b3e7eaf9bad87858299dfb1172a2aaa (diff)
downloadffmpeg-6b22e28f4c857b2d9c045001add083343f506d84.tar.gz
opusdsp: adjust and optimize C function to match assembly
The C and asm versions behaved differently _outside_ of the codec. The C version returned pre-multiplied 'state' for the next execution to use right away, while the assembly version outputted non-multiplied 'state' for the next execution to multiply to save instructions. Since the initial state when initialized or seeking is always 0, and since C and asm versions were never mixed, there was no issue. However, comparing outputs directly in checkasm doesn't work without dividing the initial state by CELT_EMPH_COEFF and multiplying the returned state by CELT_EMPH_COEFF for the assembly function. Since its actually faster to do this in C as well, copy the behavior the asm versions use. As a reminder, the initial state 0 is divided by CELT_EMPH_COEFF on seek and init (just in case in the future this is changed, its technically more correct to init with CELT_EMPH_COEFF than 0, however when seeking this will result in more audiable pops, unlike with 0 where the output gets in sync over a few samples).
Diffstat (limited to 'libavcodec/opus_celt.c')
-rw-r--r--libavcodec/opus_celt.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libavcodec/opus_celt.c b/libavcodec/opus_celt.c
index 4655172b09..9dbeff1927 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;