From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id F38AB4B247 for ; Tue, 2 Jul 2024 01:34:39 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 08B7268D886; Tue, 2 Jul 2024 04:34:11 +0300 (EEST) Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7645868D876 for ; Tue, 2 Jul 2024 04:34:02 +0300 (EEST) Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-42567ddf099so25765685e9.3 for ; Mon, 01 Jul 2024 18:34:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719884041; x=1720488841; 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=P3ek+3Uy5fJmLpZFIAinBd+2jDzrxdAoQ6k6/5ZJLiA=; b=Sg3M3bI+PHZFZSTAIoGVdbjiWTptbxTs8iMqUBpqfTsocwSEWrXPb2v5kLa1SlOVJV L/Sbp7LOhB2nclfbE1HBbgyq/rc7j6xyDaoFXv1U1qMnpO+0nob2CQSpTqZoMCCIY5/+ UYoTTRxVcljUdT8ZD1iYGFeWc4W83dllj/vgi8YrMVRPNwDsE2w05roeBUSUq53yUlue /s5PEuVp7cylJUQf1Xkn/veVvJA37p93LR1PHnUonUoV59lkvlePOiJACiNSMVB4QcI9 dJWEegcVU3/6kLyvf9lC0fJrySizALKdG1LFHKO8WrooDcN7/yzGDU6IYub0JMXUZDqH DWDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719884041; x=1720488841; 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=P3ek+3Uy5fJmLpZFIAinBd+2jDzrxdAoQ6k6/5ZJLiA=; b=cbiQKtJi0Wya8o175EMngvnEXA1rzrICNlfvHxaAsM9EsqyKAYISy8xxfr48Q1KJQy 6BzAM8lWXo3dWBtdpB+nGzF2jy9Q1PYBjU4XChaTHsVJyripe+wsFzFaEJyVFkytUC+u VW4mv/4uP/dQMlpy+j7mXnhQ1YfSu9HmnYvC0bvpTyKzjZ8R75if7k5eqhg1UhFItKAu 5MODvvTsfWkMwdIUCwN/uXGocjepzTO3UpD8VYGY3b9y3m2Lf4rgbuyfh07MlaIHKiNg EiCnJhdBKkrfh+bR7iuvIpT1K1IkRKSNrvyclkCHEpkQrZ07v9xg+LCNQC3y4qHDekHq VkYQ== X-Gm-Message-State: AOJu0YwlPGg1kz2KkzQOxd7Z56Hhuvn2TBwhSm9SPlBCjBUDkoJLZ1Xv JaNycFNdYvZFjoD1hW/0OdE0ZH/OtxFr+B3DaOaDYUMJasizL986vaCIsw== X-Google-Smtp-Source: AGHT+IHBdOcwqscUD1UTlyXA4ii2R01nkgIi0DfBN8A5ACqnx8dNFZ1byInDqqT7CyxMrLFAChfbOg== X-Received: by 2002:a05:600c:3089:b0:425:5ea5:a8f8 with SMTP id 5b1f17b1804b1-4257a00dce6mr48026675e9.13.1719884041631; Mon, 01 Jul 2024 18:34:01 -0700 (PDT) Received: from localhost.localdomain ([2a02:e0:8bea:ef00:81b5:4ba8:1843:4f00]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b068e93sm176273295e9.24.2024.07.01.18.34.00 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 01 Jul 2024 18:34:01 -0700 (PDT) From: Yigithan Yigit To: ffmpeg-devel@ffmpeg.org Date: Tue, 2 Jul 2024 04:33:52 +0300 Message-ID: <20240702013354.14942-4-yigithanyigitdevel@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240702013354.14942-1-yigithanyigitdevel@gmail.com> References: <20240702013354.14942-1-yigithanyigitdevel@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 3/5] 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --- libavfilter/af_volumedetect.c | 66 +++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/libavfilter/af_volumedetect.c b/libavfilter/af_volumedetect.c index edd2d56f7a..778f0cac6c 100644 --- a/libavfilter/af_volumedetect.c +++ b/libavfilter/af_volumedetect.c @@ -71,6 +71,64 @@ static void update_float_stats(VolDetectContext *vd, float *audio_data) vd->nb_samples++; } +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; @@ -157,12 +215,20 @@ static int config_output(AVFilterLink *outlink) * The extra element is there for symmetry. */ histogram_size = HISTOGRAM_SIZE + 1; + if (av_sample_fmt_is_planar(outlink->format)) + vd->process_samples = process_int_planar_samples; + else + vd->process_samples = process_int_packed_samples; } else { /* * The histogram is used to store the number of samples at each dB * instead of the number of samples at each PCM value. */ histogram_size = HISTOGRAM_SIZE_FLT + 1; + if (av_sample_fmt_is_planar(outlink->format)) + vd->process_samples = process_float_planar_samples; + else + vd->process_samples = process_float_packed_samples; } vd->histogram = av_calloc(histogram_size, sizeof(uint64_t)); if (!vd->histogram) -- 2.45.2 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".