From patchwork Fri Jun 15 22:03:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takayuki 'January June' Suwa X-Patchwork-Id: 9427 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:11c:0:0:0:0:0 with SMTP id c28-v6csp2330350jad; Sat, 16 Jun 2018 17:13:46 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKXqAvnZiyvMFVSCIn5aXcpBAr7z7Nneoh04dfpZ5aeoonYJSn31FYCcHMt9sdKnmVBXNoa X-Received: by 2002:adf:deca:: with SMTP id i10-v6mr6109180wrn.37.1529194426619; Sat, 16 Jun 2018 17:13:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529194426; cv=none; d=google.com; s=arc-20160816; b=EbEwCuGoGzU+cDvq2QXMZicMVlPbdYhlA85kmdpCcB8koRGnVkgaNUZqPPSYAc8MqW q/ONlpASjjzV15VrwYR4UWmygWaYzFTkE9PASKIpdeR0Y4UJrUZSb9PPX5iF5xEdb0dq dHBz4XwR2pC58xnNpFW5Cs46vMZtW82oy6uk4qX0JHzFZa0rWnZw9b1eNfW9VjhP5wbp y+kZo/a4/uqD6h0neGHrsZXSiShF+g7btZ7z9WJH4YkQm7OenaEOOEQfUecji5gM/5ic eKRkxyZvGQqtV43TaOydbIDU8U0DQ87Qvx+ewi5oQ5cjeBdQhAaRsVOKCF9641XUprh/ V7cA== 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:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=IMMtH12WVXRq1jYAszpN2PJ7g/qUs9gIZqhL1pGj6pM=; b=xmzmem+bwepetUJJWDgB+ebh2PO+GOtXGbM728vu4ltA1HTWQHVsOxOjlSQBjDWvJv e6GNyGyUTDd2XH0sDcVMNGpMTfXHxWeZF4MX++MT0jNbmmoBfPvnYxZ9Xa2QQLtdYZ8j ahA3nKpujHHih9AGMaqQFqU/cdl9i9AIm4EWI5vgZqX6nsDT9fes4TDsuUYPg7QRneqU XbeHpVZad0IsejhrRqCPtIaMZgykrLN8JAZAgmFfR1pron123VH8w1lun8kW5JeCQQhf OVLhRa4WXHJyqW0tN+7s6KXBY5aUwY30sGRVwzY6uUa5pjW2JBl0C+BfeIT1iY8SKz2c BQzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=AIsLXahW; 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=QUARANTINE 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 g19-v6si6048982wrh.118.2018.06.16.17.13.45; Sat, 16 Jun 2018 17:13:46 -0700 (PDT) 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=AIsLXahW; 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=QUARANTINE 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 1CAAE689C18; Sun, 17 Jun 2018 03:12:52 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf0-f173.google.com (mail-pf0-f173.google.com [209.85.192.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8714768A449 for ; Sat, 16 Jun 2018 01:03:12 +0300 (EEST) Received: by mail-pf0-f173.google.com with SMTP id b74-v6so5461817pfl.5 for ; Fri, 15 Jun 2018 15:04:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=06O2D0THOOqo9zxJh/fjmPM7HGbxRgQuLwKDFI0qbp0=; b=AIsLXahWHNrZd7prunBujJlJuKLmCieAr78lRt+wgTe2ONCII4in+JaQJoJpJ2TYNm VL/EgUv4MTrq+ITVuAsgDcVX8MUAHeJWsCuqo0SAAQxh9U/3mu7aNTAwURDV8E5JMgld +lLa5TG9guj8nYMVJq7Js5yA1/k+Glb6D2ptPunUMDiRyXf3oCu/DNLpxzRzAnya+VHS wbIVjq326otUeFDH+QW38RYCo+8GZM/j67rCncn6WuCo5SfWxCnHG567vD4f0RXP97eB +OGdx5y/yqyMVVbiJdZ3Ip/SbF5aSd4ey/4Qplur1WEqEjXyj2440o5hmFCESQ/Obhmt P8eA== 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; bh=06O2D0THOOqo9zxJh/fjmPM7HGbxRgQuLwKDFI0qbp0=; b=EBp7tzieFTvMEGYtfsX7ScUUbMLMUFDyov8aPrHXrw1ex5ddhVxxRCJWPnzLVUSWOb 8+Onk4x5pIBeEEF+6+usAQE/910PIJEZ3YyjfCA7jmK0qG2KVgAjfNBeL8munJXgKD0g mVDo2dHhCS083EAFEzDSLyouJ/+31L/ElgrNrVifULzc6dQ/GFDeAZSazXV49RByeQ3C IJRE6N7BcE3eWdSHp/7qkO5pSSuiC/OzJ9eLQYLiIq2HVMmNgwopbq4vStofnzTHQ58T G7WT582VVA3dzbmt7HHmEoVWg0E3Snt7Mwfb4Gcd6h8P9UTGgMljruBAzfwxcPk6NegA jrCg== X-Gm-Message-State: APt69E1bj7XPWw10JepPZqjMSeGSXbPvFgBtf0Aqkh6V0DXhcgUg9Syz 8yIVeXAml4hItnz7FGPp8GCr6Q== X-Received: by 2002:a63:b646:: with SMTP id v6-v6mr3113579pgt.276.1529100241656; Fri, 15 Jun 2018 15:04:01 -0700 (PDT) Received: from localhost.localdomain (h175-177-005-151.catv02.itscom.jp. [175.177.5.151]) by smtp.gmail.com with ESMTPSA id s12-v6sm11355832pfm.41.2018.06.15.15.03.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Jun 2018 15:04:00 -0700 (PDT) From: Takayuki 'January June' Suwa To: ffmpeg-devel@ffmpeg.org Date: Sat, 16 Jun 2018 07:03:32 +0900 Message-Id: <20180615220332.16433-1-jjsuwa.sys3175@gmail.com> X-Mailer: git-send-email 2.11.0 X-Mailman-Approved-At: Sun, 17 Jun 2018 03:12:50 +0300 Subject: [FFmpeg-devel] [PATCH] lavc/libopusenc: add support for specifying signal type 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: Takayuki 'January June' Suwa MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- doc/encoders.texi | 14 ++++++++++++++ libavcodec/libopusenc.c | 11 +++++++++++ 2 files changed, 25 insertions(+) diff --git a/doc/encoders.texi b/doc/encoders.texi index 7b095754d1..6d0fc8e63e 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -986,6 +986,20 @@ 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). +@item signal (@emph{music} and @emph{speech}) +Set signal type. This option acts as a tuning bias for low bitrates encoding. +Valid options are listed below: + +@table @samp +@item auto (N.A.) +No bias, automatic signal type detection (the default). + +@item voice (@emph{speech}) +Bias thresholds towards choosing LPC or Hybrid modes. + +@item music (@emph{music}) +Bias thresholds towards choosing MDCT modes. +@end table @end table @anchor{libshine} diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c index 4ae81b0bb2..21ce89d288 100644 --- a/libavcodec/libopusenc.c +++ b/libavcodec/libopusenc.c @@ -42,6 +42,7 @@ typedef struct LibopusEncOpts { #ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST int apply_phase_inv; #endif + int signal_type; } LibopusEncOpts; typedef struct LibopusEncContext { @@ -165,6 +166,12 @@ static int libopus_configure_encoder(AVCodecContext *avctx, OpusMSEncoder *enc, "Unable to set phase inversion: %s\n", opus_strerror(ret)); #endif + ret = opus_multistream_encoder_ctl(enc, + OPUS_SET_SIGNAL(opts->signal_type)); + if (ret != OPUS_OK) + av_log(avctx, AV_LOG_WARNING, + "Unable to set signal type: %s\n", opus_strerror(ret)); + return OPUS_OK; } @@ -544,6 +551,10 @@ static const AVOption libopus_options[] = { #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 + { "signal", "Signal type", OFFSET(signal_type), AV_OPT_TYPE_INT, { .i64 = OPUS_AUTO }, OPUS_AUTO, OPUS_SIGNAL_MUSIC, FLAGS, "signal" }, + { "auto", "Automatic detection", 0, AV_OPT_TYPE_CONST, { .i64 = OPUS_AUTO }, 0, 0, FLAGS, "signal" }, + { "voice", "Tune for speech", 0, AV_OPT_TYPE_CONST, { .i64 = OPUS_SIGNAL_VOICE }, 0, 0, FLAGS, "signal" }, + { "music", "Tune for music", 0, AV_OPT_TYPE_CONST, { .i64 = OPUS_SIGNAL_MUSIC }, 0, 0, FLAGS, "signal" }, { NULL }, };