When downmixing to mono, don't put the channels out of phase, as they
will cancel out and create audible artifacts. (See RFC 8251 sec.10.)

Signed-off-by: Andrew D'Addesio <modchip...@gmail.com>
---
 libavcodec/opus_celt.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libavcodec/opus_celt.c b/libavcodec/opus_celt.c
index 4ba4fde..d58b8e9 100644
--- a/libavcodec/opus_celt.c
+++ b/libavcodec/opus_celt.c
@@ -1445,6 +1445,12 @@ static unsigned int celt_decode_band(CeltContext *s, 
OpusRangeCoder *rc,
             Let's do that at higher complexity */
         } else if (dualstereo) {
             inv = (b > 2 << 3 && s->remaining2 > 2 << 3) ? opus_rc_p2model(rc, 
2) : 0;
+
+            /* Don't put the channels out of phase if we are downmixing to mono
+            as this subjectively sounds bad (RFC 8251 section 10). */
+            if (s->output_channels == 1)
+                inv = 0;
+
             itheta = 0;
         }
         qalloc = opus_rc_tell_frac(rc) - tell;
-- 
2.15.1.windows.2

_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to