From patchwork Sun Apr 9 20:11:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul B Mahol X-Patchwork-Id: 3351 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.44.195 with SMTP id s186csp1095677vss; Sun, 9 Apr 2017 13:11:59 -0700 (PDT) X-Received: by 10.223.134.46 with SMTP id 43mr10046955wrv.190.1491768719092; Sun, 09 Apr 2017 13:11:59 -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 l20si11278474wrc.333.2017.04.09.13.11.58; Sun, 09 Apr 2017 13:11:59 -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; 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 21C5B6882E2; Sun, 9 Apr 2017 23:11:51 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr0-f194.google.com (mail-wr0-f194.google.com [209.85.128.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B3DEC687EC1 for ; Sun, 9 Apr 2017 23:11:44 +0300 (EEST) Received: by mail-wr0-f194.google.com with SMTP id o21so21558627wrb.3 for ; Sun, 09 Apr 2017 13:11:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=r2UwqS0CP5OlF7uoJeU0HvoWHceMerC6WID652phvBs=; b=rIYKdAa677wt7+VySvWtIIAUCn1fgPC8SuuNsevpBXXyYxLJW/qAvhYyehg6puYFCP meUcs7C/KH8u1L7daE8iCx1qbQX4Gmb2HIN04ICC75XMCXYSudK/v3Bd7MH8XTIn+wbE DQLB1O4TzEGywqoddCskNk+1/T7NSqfjJLLwNZgp7vGhEgdO4PDlz0izCXHiWIxP03o6 4rdWlFMyrDNwgypklJR6whiskKDf2GaPw+fCYSobfnLOm+SSQW3Sl2dYbBXvw3casW1m ngISlvOf7TcxfwYzIEjDkEBC7w+pT9moxt9sK8wZ5WvslD0GHbM9sFxw35zKmIAY7RuK XoIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=r2UwqS0CP5OlF7uoJeU0HvoWHceMerC6WID652phvBs=; b=eigam72yqDHQ+9SlST6vNBoVIzOTTZUcmC722QmyNt4sA1xsEN4QoApktca3skc7QG Xy/P4U2YSqTTJPcL7/eXYW0gI31AxvkjwNfW9rA3A5HVNrar8w5l7hf8C5VPzJ151CEr MBw2AqaUCrNSfyIAD9tm8rErNSBycoQ+mfUeNAGRHS3meDGT3qAi1ZxY3mVIyvtY1WY0 G97Z2iUjkmyCfRJJd/lyATih75jxA/6zGiBiBIJbWhzvUSReu8MCc0tr4nYudxCsCq77 GCLYoV7ij6SAaOn0XqsL7hkKXKEltG+F5eKYtJvkgvlXGpVuhDEi+ZHEPW2qVozRrxZS eJlQ== X-Gm-Message-State: AFeK/H3+myKGhO2e5aOoPut1oje138YweWMkqW/O663PRsvqNNcWO1bnTMfFvohjlZB8CQ== X-Received: by 10.223.134.74 with SMTP id 10mr33801748wrw.200.1491768708709; Sun, 09 Apr 2017 13:11:48 -0700 (PDT) Received: from localhost.localdomain ([94.250.174.60]) by smtp.gmail.com with ESMTPSA id l14sm14650254wre.23.2017.04.09.13.11.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Apr 2017 13:11:47 -0700 (PDT) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Apr 2017 22:11:33 +0200 Message-Id: <20170409201133.29991-1-onemda@gmail.com> X-Mailer: git-send-email 2.9.3 Subject: [FFmpeg-devel] [PATCH] avfilter/af_amix: add double sample format support 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: Paul B Mahol --- libavfilter/af_amix.c | 19 +++++++++++++++---- libavutil/float_dsp.c | 9 +++++++++ libavutil/float_dsp.h | 16 ++++++++++++++++ 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/libavfilter/af_amix.c b/libavfilter/af_amix.c index a4d1389..2dacb22 100644 --- a/libavfilter/af_amix.c +++ b/libavfilter/af_amix.c @@ -336,10 +336,19 @@ static int output_frame(AVFilterLink *outlink) plane_size = nb_samples * (s->planar ? 1 : s->nb_channels); plane_size = FFALIGN(plane_size, 16); - for (p = 0; p < planes; p++) { - s->fdsp->vector_fmac_scalar((float *)out_buf->extended_data[p], - (float *) in_buf->extended_data[p], - s->input_scale[i], plane_size); + if (out_buf->format == AV_SAMPLE_FMT_FLT || + out_buf->format == AV_SAMPLE_FMT_FLTP) { + for (p = 0; p < planes; p++) { + s->fdsp->vector_fmac_scalar((float *)out_buf->extended_data[p], + (float *) in_buf->extended_data[p], + s->input_scale[i], plane_size); + } + } else { + for (p = 0; p < planes; p++) { + s->fdsp->vector_dmac_scalar((double *)out_buf->extended_data[p], + (double *) in_buf->extended_data[p], + s->input_scale[i], plane_size); + } } } } @@ -529,6 +538,8 @@ static int query_formats(AVFilterContext *ctx) if ((ret = ff_add_format(&formats, AV_SAMPLE_FMT_FLT )) < 0 || (ret = ff_add_format(&formats, AV_SAMPLE_FMT_FLTP)) < 0 || + (ret = ff_add_format(&formats, AV_SAMPLE_FMT_DBL )) < 0 || + (ret = ff_add_format(&formats, AV_SAMPLE_FMT_DBLP)) < 0 || (ret = ff_set_common_formats (ctx, formats)) < 0 || (ret = ff_set_common_channel_layouts(ctx, layouts)) < 0 || (ret = ff_set_common_samplerates(ctx, ff_all_samplerates())) < 0) diff --git a/libavutil/float_dsp.c b/libavutil/float_dsp.c index c85daff..1d4911d 100644 --- a/libavutil/float_dsp.c +++ b/libavutil/float_dsp.c @@ -40,6 +40,14 @@ static void vector_fmac_scalar_c(float *dst, const float *src, float mul, dst[i] += src[i] * mul; } +static void vector_dmac_scalar_c(double *dst, const double *src, double mul, + int len) +{ + int i; + for (i = 0; i < len; i++) + dst[i] += src[i] * mul; +} + static void vector_fmul_scalar_c(float *dst, const float *src, float mul, int len) { @@ -125,6 +133,7 @@ av_cold AVFloatDSPContext *avpriv_float_dsp_alloc(int bit_exact) fdsp->vector_fmul = vector_fmul_c; fdsp->vector_fmac_scalar = vector_fmac_scalar_c; fdsp->vector_fmul_scalar = vector_fmul_scalar_c; + fdsp->vector_dmac_scalar = vector_dmac_scalar_c; fdsp->vector_dmul_scalar = vector_dmul_scalar_c; fdsp->vector_fmul_window = vector_fmul_window_c; fdsp->vector_fmul_add = vector_fmul_add_c; diff --git a/libavutil/float_dsp.h b/libavutil/float_dsp.h index d1be38f..2c24d93 100644 --- a/libavutil/float_dsp.h +++ b/libavutil/float_dsp.h @@ -55,6 +55,22 @@ typedef struct AVFloatDSPContext { int len); /** + * Multiply a vector of doubles by a scalar double and add to + * destination vector. Source and destination vectors must + * overlap exactly or not at all. + * + * @param dst result vector + * constraints: 32-byte aligned + * @param src input vector + * constraints: 32-byte aligned + * @param mul scalar value + * @param len length of vector + * constraints: multiple of 16 + */ + void (*vector_dmac_scalar)(double *dst, const double *src, double mul, + int len); + + /** * Multiply a vector of floats by a scalar float. Source and * destination vectors must overlap exactly or not at all. *