From patchwork Sun Nov 20 08:56:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muhammad Faiz X-Patchwork-Id: 1495 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.90.1 with SMTP id o1csp978810vsb; Sun, 20 Nov 2016 00:57:30 -0800 (PST) X-Received: by 10.25.202.9 with SMTP id a9mr1984018lfg.161.1479632250764; Sun, 20 Nov 2016 00:57:30 -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 h37si6220396lfi.306.2016.11.20.00.57.30; Sun, 20 Nov 2016 00:57:30 -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 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 5A1BE689EDA; Sun, 20 Nov 2016 10:57:24 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg0-f68.google.com (mail-pg0-f68.google.com [74.125.83.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4FF49689A40 for ; Sun, 20 Nov 2016 10:57:17 +0200 (EET) Received: by mail-pg0-f68.google.com with SMTP id 3so25311010pgd.0 for ; Sun, 20 Nov 2016 00:57:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=o2RYwz1vDVE36V28CQxa/YE4GvL9VmmZVJ865lgZG3c=; b=ojJTIaDrN8Log+/6i0fSgQ1TMMuPIsddSMRVHISU3hPIYJoPA0lQ0KOHYcQb7zQCgX e3nFdmDnK91b56KNkI90uudzBYGW64rTc+lDGgNQEDAXdIAuIO+bbJdhd75OxLGCUmnQ 2t4JzMjZEMe58zx9S4cY819DoH3AOhlH2/RTUEjf/Qqag6ZGmDr+EfBOqB7C6U/Anapb bt1VUT4owdAmgeuq1v5encV28iKr5Z/H5OaJCYZZOlqyalZCLuw4/vtFPwE3InsgSfgP 3u0KZTPEdMXwTe0D+uup0cDalEEvncUIN+4Fk+SIU1PKAE38SeCGlVhW+YcnYLAnrFTx 0p9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=o2RYwz1vDVE36V28CQxa/YE4GvL9VmmZVJ865lgZG3c=; b=WMMPN2sWy85CNjg0k0WXoXuaM53ythUMhcrA2fgk6NdWmE00OfmPsqTLLXfyFiEds0 7sQGgjgEZBPa7N11bkaLnUaBcRkI5WuNREm67U2qxUKaxaLkUwb4sFrSGrLmT9be5eoU Ok8fdT8X2FbAbpGk9xt6tESsSwTbUWIdVPC1FzMgd5Bs61BZnXF9TZS6tsiGAlZAO0M4 l5L3/6TOFIL24NRWrWILXGE4mTmIq83AlTWcXb5hwItGd7+9Q1Zj8vPXixsYgmLw3kTn Szri+FEQTQgpg5u3ylE6cvcYx0bBtzoL3/A/8eticgPiQ/R5wilt5NtxkOYKr+u6Pp0P rQzg== X-Gm-Message-State: AKaTC02eNJbUYedRJ0L7JWNTGz9XvfQfzLCmpeyyYpH6E8U5D1pB1FtnoQbOh5nsjSR1VQ== X-Received: by 10.98.108.3 with SMTP id h3mr10454868pfc.65.1479632237730; Sun, 20 Nov 2016 00:57:17 -0800 (PST) Received: from localhost.localdomain.localdomain ([114.120.239.149]) by smtp.gmail.com with ESMTPSA id b64sm29287205pfc.74.2016.11.20.00.57.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 20 Nov 2016 00:57:16 -0800 (PST) From: Muhammad Faiz To: ffmpeg-devel@ffmpeg.org Date: Sun, 20 Nov 2016 15:56:28 +0700 Message-Id: <1479632188-21626-1-git-send-email-mfcc64@gmail.com> X-Mailer: git-send-email 2.5.0 Subject: [FFmpeg-devel] [PATCH] swresample/resample: add force_comp argument 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 allow to use phase_count_compensation on init (rather than rebuild on swr_set_compensation) when options suggest that soft compensation is enabled Signed-off-by: Muhammad Faiz --- libswresample/resample.c | 4 +++- libswresample/soxr_resample.c | 2 +- libswresample/swresample.c | 5 ++++- libswresample/swresample_internal.h | 3 ++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/libswresample/resample.c b/libswresample/resample.c index 8635bf1..c07a7d7 100644 --- a/libswresample/resample.c +++ b/libswresample/resample.c @@ -302,7 +302,7 @@ fail: static ResampleContext *resample_init(ResampleContext *c, int out_rate, int in_rate, int filter_size, int phase_shift, int linear, double cutoff0, enum AVSampleFormat format, enum SwrFilterType filter_type, double kaiser_beta, - double precision, int cheby, int exact_rational) + double precision, int cheby, int exact_rational, int force_comp) { double cutoff = cutoff0? cutoff0 : 0.97; double factor= FFMIN(out_rate * cutoff / in_rate, 1.0); @@ -316,6 +316,8 @@ static ResampleContext *resample_init(ResampleContext *c, int out_rate, int in_r if (phase_count_exact <= phase_count) { phase_count_compensation = phase_count_exact * (phase_count / phase_count_exact); phase_count = phase_count_exact; + if (force_comp) + phase_count = phase_count_compensation; } } diff --git a/libswresample/soxr_resample.c b/libswresample/soxr_resample.c index b9c6735..b451b96 100644 --- a/libswresample/soxr_resample.c +++ b/libswresample/soxr_resample.c @@ -30,7 +30,7 @@ #include static struct ResampleContext *create(struct ResampleContext *c, int out_rate, int in_rate, int filter_size, int phase_shift, int linear, - double cutoff, enum AVSampleFormat format, enum SwrFilterType filter_type, double kaiser_beta, double precision, int cheby, int exact_rational){ + double cutoff, enum AVSampleFormat format, enum SwrFilterType filter_type, double kaiser_beta, double precision, int cheby, int exact_rational, int force_comp){ soxr_error_t error; soxr_datatype_t type = diff --git a/libswresample/swresample.c b/libswresample/swresample.c index 0ef4dea..0bc7683 100644 --- a/libswresample/swresample.c +++ b/libswresample/swresample.c @@ -265,7 +265,10 @@ av_cold int swr_init(struct SwrContext *s){ } if (s->out_sample_rate!=s->in_sample_rate || (s->flags & SWR_FLAG_RESAMPLE)){ - s->resample = s->resampler->init(s->resample, s->out_sample_rate, s->in_sample_rate, s->filter_size, s->phase_shift, s->linear_interp, s->cutoff, s->int_sample_fmt, s->filter_type, s->kaiser_beta, s->precision, s->cheby, s->exact_rational); + s->resample = s->resampler->init(s->resample, s->out_sample_rate, s->in_sample_rate, s->filter_size, + s->phase_shift, s->linear_interp, s->cutoff, s->int_sample_fmt, s->filter_type, + s->kaiser_beta, s->precision, s->cheby, s->exact_rational, + s->min_compensation < FLT_MAX && s->soft_compensation_duration && s->max_soft_compensation); if (!s->resample) { av_log(s, AV_LOG_ERROR, "Failed to initialize resampler\n"); return AVERROR(ENOMEM); diff --git a/libswresample/swresample_internal.h b/libswresample/swresample_internal.h index f2ea5a2..f00439e 100644 --- a/libswresample/swresample_internal.h +++ b/libswresample/swresample_internal.h @@ -69,7 +69,8 @@ struct DitherContext { }; typedef struct ResampleContext * (* resample_init_func)(struct ResampleContext *c, int out_rate, int in_rate, int filter_size, int phase_shift, int linear, - double cutoff, enum AVSampleFormat format, enum SwrFilterType filter_type, double kaiser_beta, double precision, int cheby, int exact_rational); + double cutoff, enum AVSampleFormat format, enum SwrFilterType filter_type, double kaiser_beta, double precision, int cheby, + int exact_rational, int force_comp); typedef void (* resample_free_func)(struct ResampleContext **c); typedef int (* multiple_resample_func)(struct ResampleContext *c, AudioData *dst, int dst_size, AudioData *src, int src_size, int *consumed); typedef int (* resample_flush_func)(struct SwrContext *c);