From patchwork Tue Mar 5 20:46:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 12205 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 B55B6447ADC for ; Tue, 5 Mar 2019 22:46:24 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A4C24689D0C; Tue, 5 Mar 2019 22:46:24 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3BB16689C85 for ; Tue, 5 Mar 2019 22:46:19 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 18451E1503; Tue, 5 Mar 2019 21:46:19 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lYsIWG1w5cKE; Tue, 5 Mar 2019 21:46:18 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 756B0E1445; Tue, 5 Mar 2019 21:46:17 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Tue, 5 Mar 2019 21:46:05 +0100 Message-Id: <20190305204606.20281-4-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190305204606.20281-1-cus@passwd.hu> References: <20190305204606.20281-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH 4/5] avfilter/af_astats: rework sample loops 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: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The channel loop is now the outer loop for both planar and interleaved. This is needed by the next patch, and the speed difference is negligable if any. Signed-off-by: Marton Balint --- libavfilter/af_astats.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/libavfilter/af_astats.c b/libavfilter/af_astats.c index f45558909a..9915a7965e 100644 --- a/libavfilter/af_astats.c +++ b/libavfilter/af_astats.c @@ -410,17 +410,18 @@ static void set_metadata(AudioStatsContext *s, AVDictionary **metadata) for (int c = 0; c < channels; c++) { \ ChannelStats *p = &s->chstats[c]; \ const type *src = (const type *)data[c]; \ - for (int i = 0; i < samples; i++, src++) \ + const type * const srcend = src + samples; \ + for (; src < srcend; src++) \ update_stat(s, p, double_sample, normalized_sample, int_sample); \ } -#define UPDATE_STATS_I(type, double_sample, normalized_sample, int_sample) \ - { \ - const type *src = (const type *)data[0]; \ - for (int i = 0; i < samples; i++) { \ - for (int c = 0; c < channels; c++, src++) \ - update_stat(s, &s->chstats[c], double_sample, normalized_sample, int_sample); \ - } \ +#define UPDATE_STATS_I(type, double_sample, normalized_sample, int_sample) \ + for (int c = 0; c < channels; c++) { \ + ChannelStats *p = &s->chstats[c]; \ + const type *src = (const type *)data[0]; \ + const type * const srcend = src + samples * channels; \ + for (src += c; src < srcend; src += channels) \ + update_stat(s, p, double_sample, normalized_sample, int_sample); \ } #define UPDATE_STATS(planar, type, sample, normalizer_suffix, int_sample) \