From patchwork Tue Sep 8 21:18:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22193 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 5ABFA44BE02 for ; Wed, 9 Sep 2020 00:20:46 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EC86268B766; Wed, 9 Sep 2020 00:19:40 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5526B68B6D3 for ; Wed, 9 Sep 2020 00:19:38 +0300 (EEST) Received: by mail-wr1-f68.google.com with SMTP id z4so695573wrr.4 for ; Tue, 08 Sep 2020 14:19:38 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=YGlrKylm7iO5i9WIabm5PFRmdbq7qyfMoF5Z1zPgON4=; b=uIWHBDzcX1c/RCcNqZzp6cfr7D/t6Y8d40FHY7L0d6LDvpaoZzQh5uLQOqqsGrynVA ehZ3K3TPCQuqfD5O4fCnp/2IyFWikMZAGYuzoRxcV8mzsNKtaZlvFxWOXE/KraYLmLiD 88bMcP3wIlEjN1Gw0w5lV+NfXYLU+tdCBADlxQWNEnXuHH/aghK5NaouOC6joDLj/p1P IYVNy2GIekzwolKG/RE0HIzfAlUkDWDhZ9H66ms8cp5sDlN/1Qv/aI0G+5IgO744XttY gDxe55p1vTSTgdlchZCe/yEdJ3p73tiz1XL83N4DOOyY1wPbv1GaROp8UkGA0ZpStKih qdFg== 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:mime-version:content-transfer-encoding; bh=YGlrKylm7iO5i9WIabm5PFRmdbq7qyfMoF5Z1zPgON4=; b=ZwgljXSLAmwIhK9BfZfGRF01VjNUD8eI5bFHWM4UDQ9rzjxezNfLi3n4WKAwjtyFv4 q7K/QM6lbumzXBDk/zXmjstjR6YE6UbUwGmMt/wEl6TkdApAn3gjQFzJpi/Fxj3pqWNx eerTIStX2xhz3jLn+w/2ZLeGucBKdxYPFwEbIQIt+VhaQdRAUHo45i8ro998v0EXx6VU bQjyQ7zZMgsQRzBqeaSJZ7jNucKDXX4PZXelp6BFHztuE0Nu0iaHX518B/bPLgTRbFeY FD1Jv3/VpsbozT9RISqI3CFW/ho/xxDVaD7VhnraEGbBKkug5QHlWlREjlu8/tlSya+F IM5w== X-Gm-Message-State: AOAM531IEOJ98gwJELo4yHTMsjzgNrIrMwTUZlUg/FrY+LYqEhNhQ832 VUK9jzWz5dPpYe5hB5z1iIVJScxx028= X-Google-Smtp-Source: ABdhPJz6S07KyIcoy4vTvKy+GrsKOTIPPEozQmLMR6/3Iu+V4WtBrsHUKTBJVGJDX6DdzBuHMKGFQw== X-Received: by 2002:adf:e7c8:: with SMTP id e8mr441264wrn.358.1599599977522; Tue, 08 Sep 2020 14:19:37 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id a15sm1074304wrn.3.2020.09.08.14.19.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Sep 2020 14:19:36 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 8 Sep 2020 23:18:48 +0200 Message-Id: <20200908211856.16290-17-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200908211856.16290-1-andreas.rheinhardt@gmail.com> References: <20200908211856.16290-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 17/25] avfilter/af_headphone: Simplify finding channel index 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Before this commit, the headphone filter called av_channel_layout_extract_channel() in a loop in order to find out the index of a channel (given via its AV_CH_* value) in a channel layout. This commit changes this to av_get_channel_layout_channel_index() instead. Signed-off-by: Andreas Rheinhardt --- libavfilter/af_headphone.c | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/libavfilter/af_headphone.c b/libavfilter/af_headphone.c index d6647ff80b..b5c2bd6121 100644 --- a/libavfilter/af_headphone.c +++ b/libavfilter/af_headphone.c @@ -100,7 +100,6 @@ static void parse_map(AVFilterContext *ctx) char *arg, *tokenizer, *p; uint64_t used_channels = 0; - s->lfe_channel = -1; s->nb_inputs = 1; p = s->map; @@ -452,18 +451,9 @@ static int convert_coeffs(AVFilterContext *ctx, AVFilterLink *inlink) ptr = (float *)s->in[i + 1].frame->extended_data[0]; if (s->hrir_fmt == HRIR_STEREO) { - int idx = -1; - - for (j = 0; j < inlink->channels; j++) { - if ((av_channel_layout_extract_channel(inlink->channel_layout, j)) == s->mapping[i]) { - idx = j; - if (s->mapping[i] == AV_CH_LOW_FREQUENCY) - s->lfe_channel = j; - break; - } - } - - if (idx == -1) + int idx = av_get_channel_layout_channel_index(inlink->channel_layout, + s->mapping[i]); + if (idx < 0) continue; if (s->type == TIME_DOMAIN) { float *data_ir_l = s->data_ir[0] + idx * s->air_len; @@ -494,17 +484,9 @@ static int convert_coeffs(AVFilterContext *ctx, AVFilterLink *inlink) int I, N = ctx->inputs[1]->channels; for (k = 0; k < N / 2; k++) { - int idx = -1; - - for (j = 0; j < inlink->channels; j++) { - if ((av_channel_layout_extract_channel(inlink->channel_layout, j)) == s->mapping[k]) { - idx = j; - if (s->mapping[k] == AV_CH_LOW_FREQUENCY) - s->lfe_channel = j; - break; - } - } - if (idx == -1) + int idx = av_get_channel_layout_channel_index(inlink->channel_layout, + s->mapping[k]); + if (idx < 0) continue; I = k * 2; @@ -671,6 +653,8 @@ static int config_input(AVFilterLink *inlink) return AVERROR(EINVAL); } + s->lfe_channel = av_get_channel_layout_channel_index(inlink->channel_layout, + AV_CH_LOW_FREQUENCY); return 0; }