From patchwork Thu Aug 18 00:03:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 214 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.134 with SMTP id o128csp450433vsd; Thu, 18 Aug 2016 10:17:37 -0700 (PDT) X-Received: by 10.194.127.37 with SMTP id nd5mr3008735wjb.156.1471540657748; Thu, 18 Aug 2016 10:17:37 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id n2si2736268wjm.293.2016.08.18.10.17.37; Thu, 18 Aug 2016 10:17:37 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E0935689C3C; Thu, 18 Aug 2016 03:10:24 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-qmta-pe01-1.mx.upcmail.net (unknown [62.179.121.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6693068043D for ; Thu, 18 Aug 2016 03:08:14 +0300 (EEST) Received: from [172.31.218.33] (helo=vie01a-dmta-pe01-3.mx.upcmail.net) by vie01a-pqmta-pe01.mx.upcmail.net with esmtp (Exim 4.87) (envelope-from ) id 1baAsN-0008E4-Iz for ffmpeg-devel@ffmpeg.org; Thu, 18 Aug 2016 02:08:03 +0200 Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe01.mx.upcmail.net with esmtp (Exim 4.87) (envelope-from ) id 1baArT-000388-Ts for ffmpeg-devel@ffmpeg.org; Thu, 18 Aug 2016 02:07:07 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id YQ761t00a0S5wYM01Q77zC; Thu, 18 Aug 2016 02:07:07 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 18 Aug 2016 02:03:55 +0200 Message-Id: <20160818000356.32482-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.9.3 Subject: [FFmpeg-devel] [PATCH 1/2] swresample: Use double and float for matrixes for best quality and speed 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Michael Niedermayer --- libswresample/rematrix.c | 11 ++++++++++- libswresample/swresample_internal.h | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/libswresample/rematrix.c b/libswresample/rematrix.c index ddba043..0d6138d 100644 --- a/libswresample/rematrix.c +++ b/libswresample/rematrix.c @@ -73,6 +73,9 @@ int swr_set_matrix(struct SwrContext *s, const double *matrix, int stride) for (out = 0; out < nb_out; out++) { for (in = 0; in < nb_in; in++) s->matrix[out][in] = matrix[in]; + if (s->int_sample_fmt == AV_SAMPLE_FMT_FLTP) + for (in = 0; in < nb_in; in++) + s->matrix_flt[out][in] = matrix[in]; matrix += stride; } s->rematrix_custom = 1; @@ -354,6 +357,12 @@ av_cold static int auto_matrix(SwrContext *s) } av_log(s, AV_LOG_DEBUG, "\n"); } + if (s->int_sample_fmt == AV_SAMPLE_FMT_FLTP) { + int i; + for (i = 0; i < FF_ARRAY_ELEMS(s->matrix[0])*FF_ARRAY_ELEMS(s->matrix[0]); i++) + s->matrix_flt[0][i] = s->matrix[0][i]; + } + return 0; } @@ -513,7 +522,7 @@ int swri_rematrix(SwrContext *s, AudioData *out, AudioData *in, int len, int mus float v=0; for(j=0; jmatrix_ch[out_i][0]; j++){ in_i= s->matrix_ch[out_i][1+j]; - v+= ((float*)in->ch[in_i])[i] * s->matrix[out_i][in_i]; + v+= ((float*)in->ch[in_i])[i] * s->matrix_flt[out_i][in_i]; } ((float*)out->ch[out_i])[i]= v; } diff --git a/libswresample/swresample_internal.h b/libswresample/swresample_internal.h index 3828b72..4028d4b 100644 --- a/libswresample/swresample_internal.h +++ b/libswresample/swresample_internal.h @@ -167,7 +167,8 @@ struct SwrContext { struct ResampleContext *resample; ///< resampling context struct Resampler const *resampler; ///< resampler virtual function table - float matrix[SWR_CH_MAX][SWR_CH_MAX]; ///< floating point rematrixing coefficients + double matrix[SWR_CH_MAX][SWR_CH_MAX]; ///< floating point rematrixing coefficients + float matrix_flt[SWR_CH_MAX][SWR_CH_MAX]; ///< single precission floating point rematrixing coefficients uint8_t *native_matrix; uint8_t *native_one; uint8_t *native_simd_one;