From patchwork Tue Jan 23 12:50:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: mrdegier@gmail.com X-Patchwork-Id: 7399 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.156.27 with SMTP id q27csp4247776jak; Tue, 23 Jan 2018 04:51:16 -0800 (PST) X-Google-Smtp-Source: AH8x227ceQ+a82jGqIvkyQdHgLgd57eP9l4E05l1Xzgh94yeKYGPVHhby+CTBNmZfplLpsfwNAqA X-Received: by 10.28.184.131 with SMTP id i125mr1976294wmf.44.1516711876465; Tue, 23 Jan 2018 04:51:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516711876; cv=none; d=google.com; s=arc-20160816; b=0ect6vttzbra3G7foI48NZUSjKx57hD41WtCJnXh9OtztYToKRWfp75z5Euo0ssXN9 MKrzWJK/EtLY4TBojfRlA24aVa6TEOXPMImPKmsvKsngsVv+3ljzPtChmns+zOmf2FKX kIA+tbyAraD+TXyozCoYf5pe0lg6e+3y8gqkhgpvdQOMldZLo5mwhYEFCy/b7eICl8g7 dtuONhbXjogm0ywNqdaV3nFe4HIB7XH1Cz8tQPVnvw2i9kR/jZlsXSyw/zHX+wGSdEFA H6LzD2c/r9Dw35bH59jMsajV/dGiV77Ga00aDdXwfW7lwXSeKeA/CqFWrZQaCokh1m2E ydXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=pktPuNxErAGgCFAbonq/seUtt2zwRyvMvKR5xaVVOFY=; b=f0XtuNNWItM4O4CgdH/09AlraU2VgH1hG4N9F6QygD5DWKTj+g/5/HDY6PGYty/eei v7cz5tUwdRrUsS797R0Wg36psL/8M2Xq7eJShAvz/Xt9BSUdRpPOydm1K5dS9fHeWw/a dxymGbGwYxqZTvHBBuJGZOT9o/H0TRK2MPO7nrl4SbVqvemTS50ezZux4ANEnirtl31J 6HKU46cAG4ByoBoi5CuD9SQzhs9FP9+igrQdXh3ce6jXydQrZUXCmnQ8+Jt2zPQ5Vc/T 52dcGUStVzc77USl2f6Im9cvO2HNgznW52Cb0OcKJZOeRUAB4ZwP9L5aZ4Yiai6CptvC Q8gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=o7zsE1Gm; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 63si4927239wmm.277.2018.01.23.04.51.15; Tue, 23 Jan 2018 04:51:16 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=o7zsE1Gm; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C8C18689BB4; Tue, 23 Jan 2018 14:51:11 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f47.google.com (mail-wm0-f47.google.com [74.125.82.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4AF9E689934 for ; Tue, 23 Jan 2018 14:51:05 +0200 (EET) Received: by mail-wm0-f47.google.com with SMTP id j21so13333632wmh.1 for ; Tue, 23 Jan 2018 04:51:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=19Hhn+zUz5qiZ1d+yDgKfZAcoCNR9WAVAFqoVUmxtd4=; b=o7zsE1GmQfNlDl1NDc3RiYmERV2nvrE0dbIlZNBxM+eSQKN/+fvsKt35yL2Fwzr2+k CDIjNpaCvLIJea8UxPv5lkodVaEjTqedd2v7gHxSjdFmeaVfxJykTOTtmSVnKwSIu0Nw BlVrYRGeTu+UnKMnQ0Y/Q8kN30XooKik14Z1mbOYQlg9pOd3A2vIHwYLks6C1cXt/WzP pGDTpKwZHaVh2302CwBYEv0Mvtj7fgu0h07sM8BF1TYMSnTQqo4V8Pc+Io/4Kxh0623s TChuY16JgryBMjsr+78of/ORGhl+FqHg5jB1P+R3a6tt1wdHbanxhj6Y27B5YOqW1q4M aHYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=19Hhn+zUz5qiZ1d+yDgKfZAcoCNR9WAVAFqoVUmxtd4=; b=k374Z+hbgiYHkk2nZyEuZxH+ICtoX+OFxgWnYoWgIdQllA9pm5UFj8bqhBydSXtTge Zj3TXmGnjVt9paFbuRGK3nT5aJNEQzwgkLri8GMSQw+pUo+MHGzPmvzWWpnC+t27iuxU j8/SxRhm6fjiZhltQhEUXgVNhxNY9Xd76OtxwXmd+qLshnUi2cawmOA9gvVFTG4WShFU nllGaVpmnO29Vx0r55Y0edZTEuTFu15dM1S3XZJE26wEWnYJq5cuPXf5SWrOMdr4ZGNx g7dJU0nocIX1/5WrFyR/jzjfPrygr1lQgFQ2qKIReZxOFuZYgn4T7KGpciEGHCiaNOA4 gL8Q== X-Gm-Message-State: AKwxytcBPMhPPljM5Zel0b/m5ZGjuelmoMDr1ZpThBBUAMZOJ6ei+5K1 Pe4QNzy7+ECj7+IrjeIKxLDeABkS X-Received: by 10.80.151.198 with SMTP id f6mr19590837edb.106.1516711866892; Tue, 23 Jan 2018 04:51:06 -0800 (PST) Received: from yoyodyne.local.net ([80.82.202.196]) by smtp.gmail.com with ESMTPSA id v23sm10002802eda.92.2018.01.23.04.51.05 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 23 Jan 2018 04:51:06 -0800 (PST) From: Menno To: ffmpeg-devel@ffmpeg.org Date: Tue, 23 Jan 2018 13:50:41 +0100 Message-Id: <20180123125041.98428-1-mrdegier@gmail.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180122113826.26172-1-mrdegier@gmail.com> References: <20180122113826.26172-1-mrdegier@gmail.com> Subject: [FFmpeg-devel] [PATCH v2] libopus: support disabling phase inversion. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Menno MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Renamed the option. I looked into adding support on the decoder side but things look a bit different there (e.g. there aren't any cli params set up yet.) Is it OK to merge this first and I can work on the decoder later? Signed-off-by: Menno --- doc/encoders.texi | 5 +++++ libavcodec/libopusenc.c | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/doc/encoders.texi b/doc/encoders.texi index 6a410a8cb6..c5dfc646d9 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -981,6 +981,11 @@ Other values include 0 for mono and stereo, 1 for surround sound with masking and LFE bandwidth optimizations, and 255 for independent streams with an unspecified channel layout. +@item apply_phase_inv (N.A.) (requires libopus >= 1.2) +If set to 0, disables the use of phase inversion for intensity stereo, +improving the quality of mono downmixes, but slightly reducing normal stereo +quality. The default is 1 (phase inversion enabled). + @end table @anchor{libshine} diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c index b449497d15..4ae81b0bb2 100644 --- a/libavcodec/libopusenc.c +++ b/libavcodec/libopusenc.c @@ -39,6 +39,9 @@ typedef struct LibopusEncOpts { int packet_size; int max_bandwidth; int mapping_family; +#ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST + int apply_phase_inv; +#endif } LibopusEncOpts; typedef struct LibopusEncContext { @@ -154,6 +157,14 @@ static int libopus_configure_encoder(AVCodecContext *avctx, OpusMSEncoder *enc, "Unable to set maximum bandwidth: %s\n", opus_strerror(ret)); } +#ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST + ret = opus_multistream_encoder_ctl(enc, + OPUS_SET_PHASE_INVERSION_DISABLED(!opts->apply_phase_inv)); + if (ret != OPUS_OK) + av_log(avctx, AV_LOG_WARNING, + "Unable to set phase inversion: %s\n", + opus_strerror(ret)); +#endif return OPUS_OK; } @@ -530,6 +541,9 @@ static const AVOption libopus_options[] = { { "on", "Use variable bit rate", 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, 0, 0, FLAGS, "vbr" }, { "constrained", "Use constrained VBR", 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, 0, 0, FLAGS, "vbr" }, { "mapping_family", "Channel Mapping Family", OFFSET(mapping_family), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 255, FLAGS, "mapping_family" }, +#ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST + { "apply_phase_inv", "Apply intensity stereo phase inversion", OFFSET(apply_phase_inv), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS }, +#endif { NULL }, };