From patchwork Wed Mar 1 14:24:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muhammad Faiz X-Patchwork-Id: 2712 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.65.149 with SMTP id x21csp1956906vsf; Wed, 1 Mar 2017 06:25:38 -0800 (PST) X-Received: by 10.28.109.147 with SMTP id b19mr3763739wmi.69.1488378338498; Wed, 01 Mar 2017 06:25:38 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id k71si7138657wmg.131.2017.03.01.06.25.37; Wed, 01 Mar 2017 06:25:38 -0800 (PST) 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; 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=NONE 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 36E6368075F; Wed, 1 Mar 2017 16:25:24 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg0-f66.google.com (mail-pg0-f66.google.com [74.125.83.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4FD0A680389 for ; Wed, 1 Mar 2017 16:25:17 +0200 (EET) Received: by mail-pg0-f66.google.com with SMTP id 1so6021017pgz.2 for ; Wed, 01 Mar 2017 06:25:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Fv35IK1ix+U30K6eV95TwzCtxFlHIic0Ck61pjclq7g=; b=KJov9YDvByO9eE7lGf8Jq2BPwvsmEUXH4Y6KRePR6/0W24+eCK/UlBgNakvqZBu3+V QFwd/r1wGS1uqK1kBlG42pm1dMkKRRdJ8zhwoICxFxTPKZYBZDhfkYEdkgpFgJi1Bqf2 PB6dZSrXGaQI91tL/htHtC5YlM7/rae6NGbFqgL6SMvoVvGCLeF1md7UoW/OjE0de2N9 654ytmVfts7qETMzxcS3zXlAIQr2T2y0KSX4erg7JsNqj6T5dPuuSzyljlo6pp201NQ9 qgFho0Lv/mYELKzJAz2wT3OWTyUaDoe/3/CUD6aIb/gMsZCDwYcS5DNvi7F+z/2aVj3c 2hzg== 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=Fv35IK1ix+U30K6eV95TwzCtxFlHIic0Ck61pjclq7g=; b=qZWnQwejNfX3F1KXSg2K0ymsVPlT9eu243AnuuuJmiBz2GBNhrgDkJj1f6iFPwvxHc +K3M/Fg0KxXmxhfG4k5dC9RzMeuSx11a0g2XuUHwPqdEcFeNxErCUTzFr6Gv8utGCCOf EyojPdDM9Tc8s5/ABMwxtTtCSatDAzwPR85IylWOg2Xm1/xgThQx3XGeKsTx/lQ9qh2W hhu/nfQCWOSX5d0N+J131LLQ85qJN+twXPRWwoYyfalVSO0VNJ4ZrlhPk7L59j8KTo44 vgv6t8M4PpYCT9VsIZ2BPV1qUZxVHEPURsa7mLr7wkcYl0kpzONIQw3Bap+MUpbmzDib CFMg== X-Gm-Message-State: AMke39nSoK1i+nOmIfgvawIymtwYYQCrEyisLIdTxEMMIXebC0tbAHhhKDlx3I7GWOn3VA== X-Received: by 10.98.214.4 with SMTP id r4mr9127404pfg.185.1488378326257; Wed, 01 Mar 2017 06:25:26 -0800 (PST) Received: from localhost.localdomain ([114.121.233.177]) by smtp.gmail.com with ESMTPSA id x21sm10612173pgf.15.2017.03.01.06.25.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Mar 2017 06:25:25 -0800 (PST) From: Muhammad Faiz To: ffmpeg-devel@ffmpeg.org Date: Wed, 1 Mar 2017 21:24:59 +0700 Message-Id: <20170301142500.4011-1-mfcc64@gmail.com> X-Mailer: git-send-email 2.9.3 Subject: [FFmpeg-devel] [PATCH 1/2] swresample/resample: use uniform normalization 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: Muhammad Faiz MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" this gives better frequency response Signed-off-by: Muhammad Faiz --- libswresample/resample.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libswresample/resample.c b/libswresample/resample.c index 8e2f769..b0d14d1 100644 --- a/libswresample/resample.c +++ b/libswresample/resample.c @@ -149,6 +149,7 @@ static int build_filter(ResampleContext *c, void *filter, double factor, int tap double *tab = av_malloc_array(tap_count+1, sizeof(*tab)); double *sin_lut = av_malloc_array(ph_nb, sizeof(*sin_lut)); const int center= (tap_count-1)/2; + double norm = 0; int ret = AVERROR(ENOMEM); if (!tab || !sin_lut) @@ -160,10 +161,9 @@ static int build_filter(ResampleContext *c, void *filter, double factor, int tap if (factor == 1.0) { for (ph = 0; ph < ph_nb; ph++) - sin_lut[ph] = sin(M_PI * ph / phase_count); + sin_lut[ph] = sin(M_PI * ph / phase_count) * (center & 1 ? 1 : -1); } for(ph = 0; ph < ph_nb; ph++) { - double norm = 0; s = sin_lut[ph]; for(i=0;i<=tap_count;i++) { x = M_PI * ((double)(i - center) - (double)ph / phase_count) * factor; @@ -194,7 +194,7 @@ static int build_filter(ResampleContext *c, void *filter, double factor, int tap tab[i] = y; s = -s; - if (i < tap_count) + if (!ph && i < tap_count) norm += y; } @@ -211,7 +211,7 @@ static int build_filter(ResampleContext *c, void *filter, double factor, int tap else { for (i = 1; i <= tap_count; i++) ((int16_t*)filter)[(phase_count-ph) * alloc + tap_count-i] = - av_clip_int16(lrintf(tab[i] * scale / (norm - tab[0] + tab[tap_count]))); + av_clip_int16(lrintf(tab[i] * scale / norm)); } break; case AV_SAMPLE_FMT_S32P: @@ -225,7 +225,7 @@ static int build_filter(ResampleContext *c, void *filter, double factor, int tap else { for (i = 1; i <= tap_count; i++) ((int32_t*)filter)[(phase_count-ph) * alloc + tap_count-i] = - av_clipl_int32(llrint(tab[i] * scale / (norm - tab[0] + tab[tap_count]))); + av_clipl_int32(llrint(tab[i] * scale / norm)); } break; case AV_SAMPLE_FMT_FLTP: @@ -238,7 +238,7 @@ static int build_filter(ResampleContext *c, void *filter, double factor, int tap } else { for (i = 1; i <= tap_count; i++) - ((float*)filter)[(phase_count-ph) * alloc + tap_count-i] = tab[i] * scale / (norm - tab[0] + tab[tap_count]); + ((float*)filter)[(phase_count-ph) * alloc + tap_count-i] = tab[i] * scale / norm; } break; case AV_SAMPLE_FMT_DBLP: @@ -251,7 +251,7 @@ static int build_filter(ResampleContext *c, void *filter, double factor, int tap } else { for (i = 1; i <= tap_count; i++) - ((double*)filter)[(phase_count-ph) * alloc + tap_count-i] = tab[i] * scale / (norm - tab[0] + tab[tap_count]); + ((double*)filter)[(phase_count-ph) * alloc + tap_count-i] = tab[i] * scale / norm; } break; }