[FFmpeg-devel] [PATCH 4/4] opus: Don't invert phase when downmixing to mono (per RFC8251)

Andrew D'Addesio modchipv12 at gmail.com
Sat Dec 2 19:46:59 EET 2017


When decoding to downmixed 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 <modchipv12 at gmail.com>
---
 libavcodec/opus_pvq.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libavcodec/opus_pvq.c b/libavcodec/opus_pvq.c
index 2f7aa74..f18c010 100644
--- a/libavcodec/opus_pvq.c
+++ b/libavcodec/opus_pvq.c
@@ -643,7 +643,13 @@ static av_always_inline uint32_t quant_band_template(CeltPVQ *pvq, CeltFrame *f,
                 }
             } else {
                 inv = (b > 2 << 3 && f->remaining2 > 2 << 3) ? ff_opus_rc_dec_log(rc, 2) : 0;
+
+                /* Don't put the channels out of phase if we are decoding to downmixed
+                 * mono as this subjectively sounds bad (RFC 8251 section 10). */
+                if (f->channels == 1)
+                    inv = 0;
             }
+
             itheta = 0;
         }
         qalloc = opus_rc_tell_frac(rc) - tell;
-- 
2.15.1.windows.2



More information about the ffmpeg-devel mailing list