From patchwork Fri Jun 28 20:15:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yigithan Yigit X-Patchwork-Id: 50203 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:cc64:0:b0:482:c625:d099 with SMTP id k4csp508821vqv; Fri, 28 Jun 2024 13:15:59 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWyrIl5iM6AsGZapYZ2HVYtE5SYALggxqznc11YlBxKLg6miaXQM3I4YKp5rrtbz8o1rnPOj/DWmWjQvWuNR10xfqluS12j0LyfHw== X-Google-Smtp-Source: AGHT+IGJAAys2jl/cG1Pc4W5dAk7H23JxSBFrAinw6xT/N9qar3ocZgjqh6nNJqxHBkAuFtX1diO X-Received: by 2002:a50:bae1:0:b0:57c:a701:2311 with SMTP id 4fb4d7f45d1cf-57d4bdbfcafmr12840252a12.26.1719605758955; Fri, 28 Jun 2024 13:15:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719605758; cv=none; d=google.com; s=arc-20160816; b=GPxMKoYEXjiVgADj1SKiPRhciFShXsbOeFZGqlaWrV5CJ96ViVMNVZiTkqBH2IGgBH 0fRDvCO57bpsA5iQ+njhYzG6S/+fada5Z30m+HhKd0mNnd0GPciyMhpibRquCSC0ujQ0 89S+EQ8Zdk+GwO7Cot7NQC9dYk3Pu85Vx7fO8ma2wjXnTG7yCu5scmiLXdjBNEGeCzEX GxT9Hs3HKCw6Uuziqk1vKa+oBBtm2FjjeHhr9bryjcArmKEyLrek1rWB3B3CSGxLd1Pg GnzQ2Ybwt5xwAVf4pDPqpAQ0/GbAIWH7rkOqVl6VuGObKuQ+jgCjAI8LShPbiYrxoDib qEYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=4cLdGQ5CUVIOGKH5K/+2ZvXPSZvGYpnsWzn6/C46z+g=; fh=oYrUj4vT4ivb560z23e71q/pal11/Mm+yKMO8RKszaM=; b=Z+rrfYvtx1m/XLs0CeFWc0XCmlK5dtVNF35RAr9tmKCXi/UHgWCTfpabVuHxjMY+fl zW6J5UnpYetCJi3OSET+MXXBiCVLjIngO+zzpMi7fmqxaFAkivvRiz2vcbvKsA5qzsn3 +L+gmMVfDQz650ee6K2Y+Ac+YyQKQ5fz5iyYGpiRpVlnaE6zQiyCvLGOZ4QmI9OlIKBm z24b5GRwq3EVOQcay1BVQIOigqs8mKbD7/5GPC3qr2j1jQcNlM8Vwd3BZv7mOPzmSvmw r1gDvQqEAvnYhjNHpDeNWnpcWiDg4Vs0lgcPpnZ9K1Rgbw+dvtSsxif6xitA2RZPh/fM 9+Qw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=k2YRT9eu; 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 4fb4d7f45d1cf-58615033a50si1120243a12.326.2024.06.28.13.15.58; Fri, 28 Jun 2024 13:15:58 -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=20230601 header.b=k2YRT9eu; 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 2DB3068D67F; Fri, 28 Jun 2024 23:15:38 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4529B68D67B for ; Fri, 28 Jun 2024 23:15:30 +0300 (EEST) Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-367339bd00aso824354f8f.3 for ; Fri, 28 Jun 2024 13:15:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719605729; x=1720210529; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tJjCousbAeyr4cDqpLI1CWvvgJ3kHVcHk8R66SIcyHc=; b=k2YRT9euaRn9nHGjW/oJTLfz4NyfR9+Qxu9CKSXXvUhTw959xK6OUH+FI8uBU+uqH8 rRwxnjGyKxDAqWiFuVtPdh51XrONl/GgOJgILr+iQXzYh8xYEzi3CpU56GUQmhxansO3 72QT+diRvD2ATszLLZ/Ub+OPNZFqKRMsiQ7TGpPLQpBO/jfal5pCgW1TNodvEKtAuGLf 1Mx6P1JITSMQaBbJ2S5D61/XCx5TlvpPxKIBNTGiuk3bqmFkvqKjF9pikIsLsOJn6eQK d+yZEP7TQ8kGLfdX2+CPaC/VNL61JDdd1haT1FE/WFc8kX8eNWVvyT3ZCilyRqANT7NV O4Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719605729; x=1720210529; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tJjCousbAeyr4cDqpLI1CWvvgJ3kHVcHk8R66SIcyHc=; b=OG8fMdzi4DxNgIUAwrIkrdwahA57ZVdQvwn7UgRhDuTylEloYayhPvMtVdQkEexA8d Oev/cC3Jl2ZgbQAqFzfc2UzrFvtlLaSHgcMB/CHh9ldh6yXjzDJEsPNYeHxNX/hN5tEv n64XXK5X29kUc5Owhn2NqbkvEmeD6Htuts+SNaEHifBN7rJMNBL/sygrgm6hqb21LtdD ro5gBxBilb0mYppQQdhhNatG+QueSbmzP0CYqyXeYJ7XXkfF/Sl8Bf68AL1lwbNfKm3O OgsGk5lBu4RuHN8sfZNjF8HqE+qMWSJ673595jv1YxuKxItwID+p0v//CKeSdbUv+/KA 3r/Q== X-Gm-Message-State: AOJu0YxbBTwDcNT0V/NM5qiqyqTNhbyUDx6OEl+y2LsUt3hjTw0ypWAf vIXYTVbRJUQx0RnKCh6Guxegl14Ad6cyjrH9obNCQ3JVDWpS8kIapxOAXA== X-Received: by 2002:a5d:6dac:0:b0:363:7788:b975 with SMTP id ffacd0b85a97d-366e95e7154mr14821304f8f.52.1719605729399; Fri, 28 Jun 2024 13:15:29 -0700 (PDT) Received: from localhost.localdomain ([2a02:e0:8bea:ef00:1561:d557:9aa3:53f4]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0cd4a1sm3249164f8f.23.2024.06.28.13.15.28 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 13:15:29 -0700 (PDT) From: Yigithan Yigit To: ffmpeg-devel@ffmpeg.org Date: Fri, 28 Jun 2024 23:15:21 +0300 Message-ID: <20240628201523.23612-3-yigithanyigitdevel@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240628201523.23612-1-yigithanyigitdevel@gmail.com> References: <20240628201523.23612-1-yigithanyigitdevel@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 2/4] avfilter/af_volumedetect.c: Added functions for int/float and planar/packed X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: thilo.borgmann@mail.de, yigithanyigitdevel@gmail.com Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: ubiZpY7t0+Eg --- libavfilter/af_volumedetect.c | 58 +++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/libavfilter/af_volumedetect.c b/libavfilter/af_volumedetect.c index 327801a7f9..61c00e0248 100644 --- a/libavfilter/af_volumedetect.c +++ b/libavfilter/af_volumedetect.c @@ -43,6 +43,64 @@ static inline double logdb(uint64_t v) return -log10(d) * 10; } +static void process_float_planar_samples(VolDetectContext *vd, AVFrame *samples) +{ + int plane, i; + int nb_channels = samples->ch_layout.nb_channels; + int nb_samples = samples->nb_samples; + float *audio_data; + for (plane = 0; plane < nb_channels; plane++) { + audio_data = (float *)samples->extended_data[plane]; + for (i = 0; i < nb_samples; i++) { + update_float_stats(vd, &audio_data[i]); + } + } +} + +static void process_float_packed_samples(VolDetectContext *vd, AVFrame *samples) +{ + int i, j; + int nb_channels = samples->ch_layout.nb_channels; + int nb_samples = samples->nb_samples; + float *audio_data; + for (i = 0; i < nb_samples; i++) { + audio_data = (float *)samples->extended_data[0]; + for (j = 0; j < nb_channels; j++) { + update_float_stats(vd, &audio_data[i * nb_channels + j]); + } + } +} + +static void process_int_planar_samples(VolDetectContext *vd, AVFrame *samples) +{ + int plane, i; + int nb_channels = samples->ch_layout.nb_channels; + int nb_samples = samples->nb_samples; + int16_t *pcm; + for (plane = 0; plane < nb_channels; plane++) { + pcm = (int16_t *)samples->extended_data[plane]; + for (i = 0; i < nb_samples; i++) { + vd->histogram[pcm[i] + 0x8000]++; + vd->nb_samples++; + } + } +} + +static void process_int_packed_samples(VolDetectContext *vd, AVFrame *samples) +{ + int i, j; + int nb_channels = samples->ch_layout.nb_channels; + int nb_samples = samples->nb_samples; + int16_t *pcm; + for (i = 0; i < nb_samples; i++) { + pcm = (int16_t *)samples->extended_data[0]; + for (j = 0; j < nb_channels; j++) { + vd->histogram[pcm[i * nb_channels + j] + 0x8000]++; + vd->nb_samples++; + } + } +} + static int filter_frame(AVFilterLink *inlink, AVFrame *samples) { AVFilterContext *ctx = inlink->dst;