From patchwork Thu Sep 5 08:52:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul B Mahol X-Patchwork-Id: 14923 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 EC7554487BD for ; Thu, 5 Sep 2019 12:01:00 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C04756807A0; Thu, 5 Sep 2019 12:01:00 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6507C6805F4 for ; Thu, 5 Sep 2019 12:00:54 +0300 (EEST) Received: by mail-wr1-f68.google.com with SMTP id g7so1779231wrx.2 for ; Thu, 05 Sep 2019 02:00:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=NHlrXmED6Ysou7VNqWybofQVT2vS3UwtSGnQQhOVZj4=; b=Y6V8WhwLkgoWuGA9u7wtwQC3VBqMR91IE4sXKOsXcYXA1EL4kvAnxoZTq8WxcYN2un JQshjzaTK4sPm7FQyyNbcPRws59vOHkBZ/h7bMp7ycHfOzGopRDISkkXpwt/vxsghrrr T3zwU1hq1Mt1wDSNXS9Qur3iT5xamaHUg8CDwvXgK9J23Pl8D7y1p0sOi/EImGVur+Ws zuEpnSvwatV3tbZ1WaaIBehl1jopvikg+hrSPr5SqIVVjjWb2ePFcCJr+RFJJjGKUurL ek+C/aR/vKPUEtsWi8aemzcEsgSeWjFq/CrEoz71D0TF0nuA5dhH7vAjcMkz9hEKahW+ wIrQ== 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:in-reply-to :references; bh=NHlrXmED6Ysou7VNqWybofQVT2vS3UwtSGnQQhOVZj4=; b=X2lUFyw8A83YOtX6fOAKOS9OLNGDPn/krySUtUWOCB93jRTkr5/IM6DvLD7WDGKFPL USQP7qoTXW3DHQ/yIy1seQB2pk7yuNvPK9nuWbriWzfwGd2sePowZyV7+IzzIxvXalPr s0CkD7sQ6tiQpdUaCjIqIGTQKoRdWAupkmwqn+h+gwf88sXydmZRQoHDIkiYPZ2LIFK/ KYFnMWQhyE+7ICxpCz6/qu0lFNIVeZlZ1+n+I92PtzTDljBHYTp0TsbfBnr0zLQzYYHq dhRv/BpbqOocqoeAIAr1n0kCCKoxoMFvGxx4YvV795GveWsgTpQbpWekKbZ5GfhV5Nw/ rbLw== X-Gm-Message-State: APjAAAU4bpYZXPYHyZVP5X9N2HclijWAN+suAzMvuqD5r8asOr9eYB3J qpR5Q1PDryHaWQ5SvlpICqjycxfwNXI= X-Google-Smtp-Source: APXvYqyS2cTlavi5Hxl+hmq1Nwv099cvYGnUQ3teeMAhV5ndnQAZuxqnxfhvq9zVwlzDlAfz3lhlkw== X-Received: by 2002:a05:6000:1082:: with SMTP id y2mr1594660wrw.77.1567673586733; Thu, 05 Sep 2019 01:53:06 -0700 (PDT) Received: from localhost.localdomain ([77.237.106.98]) by smtp.gmail.com with ESMTPSA id u6sm1187440wrr.26.2019.09.05.01.53.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Sep 2019 01:53:06 -0700 (PDT) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Thu, 5 Sep 2019 10:52:52 +0200 Message-Id: <20190905085255.24699-2-onemda@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190905085255.24699-1-onemda@gmail.com> References: <20190905085255.24699-1-onemda@gmail.com> Subject: [FFmpeg-devel] [PATCH 2/5] avfilter/vf_v360: stop using floats in interpolation 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/vf_v360.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/libavfilter/vf_v360.c b/libavfilter/vf_v360.c index 2fee0016b9..dd41bb293c 100644 --- a/libavfilter/vf_v360.c +++ b/libavfilter/vf_v360.c @@ -118,7 +118,7 @@ typedef struct V360Context { int nb_planes; uint16_t *u[4], *v[4]; - float *ker[4]; + int16_t *ker[4]; int (*remap_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs); } V360Context; @@ -330,12 +330,12 @@ static int remap##ws##_##bits##bit_slice(AVFilterContext *ctx, void *arg, int jo uint##bits##_t *d = dst + y * out_linesize; \ const uint16_t *u = s->u[plane] + y * width * ws * ws; \ const uint16_t *v = s->v[plane] + y * width * ws * ws; \ - const float *ker = s->ker[plane] + y * width * ws * ws; \ + const int16_t *ker = s->ker[plane] + y * width * ws * ws; \ for (x = 0; x < width; x++) { \ const uint16_t *uu = u + x * ws * ws; \ const uint16_t *vv = v + x * ws * ws; \ - const float *kker = ker + x * ws * ws; \ - float tmp = 0.f; \ + const int16_t *kker = ker + x * ws * ws; \ + int tmp = 0; \ \ for (i = 0; i < ws; i++) { \ for (j = 0; j < ws; j++) { \ @@ -343,7 +343,7 @@ static int remap##ws##_##bits##bit_slice(AVFilterContext *ctx, void *arg, int jo } \ } \ \ - *d++ = av_clip_uint##bits(roundf(tmp)); \ + *d++ = av_clip_uint##bits(tmp >> (15 - ws)); \ } \ } \ } \ @@ -367,7 +367,7 @@ DEFINE_REMAP(4, 16, 2) * @param ker ker remap data */ static void nearest_kernel(float du, float dv, const XYRemap *r_tmp, - uint16_t *u, uint16_t *v, float *ker) + uint16_t *u, uint16_t *v, int16_t *ker) { const int i = roundf(dv) + 1; const int j = roundf(du) + 1; @@ -387,7 +387,7 @@ static void nearest_kernel(float du, float dv, const XYRemap *r_tmp, * @param ker ker remap data */ static void bilinear_kernel(float du, float dv, const XYRemap *r_tmp, - uint16_t *u, uint16_t *v, float *ker) + uint16_t *u, uint16_t *v, int16_t *ker) { int i, j; @@ -398,10 +398,10 @@ static void bilinear_kernel(float du, float dv, const XYRemap *r_tmp, } } - ker[0] = (1.f - du) * (1.f - dv); - ker[1] = du * (1.f - dv); - ker[2] = (1.f - du) * dv; - ker[3] = du * dv; + ker[0] = (1.f - du) * (1.f - dv) * 8192; + ker[1] = du * (1.f - dv) * 8192; + ker[2] = (1.f - du) * dv * 8192; + ker[3] = du * dv * 8192; } /** @@ -432,7 +432,7 @@ static inline void calculate_bicubic_coeffs(float t, float *coeffs) * @param ker ker remap data */ static void bicubic_kernel(float du, float dv, const XYRemap *r_tmp, - uint16_t *u, uint16_t *v, float *ker) + uint16_t *u, uint16_t *v, int16_t *ker) { int i, j; float du_coeffs[4]; @@ -445,7 +445,7 @@ static void bicubic_kernel(float du, float dv, const XYRemap *r_tmp, for (j = 0; j < 4; j++) { u[i * 4 + j] = r_tmp->u[i][j]; v[i * 4 + j] = r_tmp->v[i][j]; - ker[i * 4 + j] = du_coeffs[j] * dv_coeffs[i]; + ker[i * 4 + j] = du_coeffs[j] * dv_coeffs[i] * 2048; } } } @@ -487,7 +487,7 @@ static inline void calculate_lanczos_coeffs(float t, float *coeffs) * @param ker ker remap data */ static void lanczos_kernel(float du, float dv, const XYRemap *r_tmp, - uint16_t *u, uint16_t *v, float *ker) + uint16_t *u, uint16_t *v, int16_t *ker) { int i, j; float du_coeffs[4]; @@ -500,7 +500,7 @@ static void lanczos_kernel(float du, float dv, const XYRemap *r_tmp, for (j = 0; j < 4; j++) { u[i * 4 + j] = r_tmp->u[i][j]; v[i * 4 + j] = r_tmp->v[i][j]; - ker[i * 4 + j] = du_coeffs[j] * dv_coeffs[i]; + ker[i * 4 + j] = du_coeffs[j] * dv_coeffs[i] * 2048; } } } @@ -1985,7 +1985,7 @@ static int config_output(AVFilterLink *outlink) int i, int j, int width, int height, float *vec); void (*calculate_kernel)(float du, float dv, const XYRemap *r_tmp, - uint16_t *u, uint16_t *v, float *ker); + uint16_t *u, uint16_t *v, int16_t *ker); float rot_mat[3][3]; switch (s->interp) { @@ -2001,21 +2001,21 @@ static int config_output(AVFilterLink *outlink) s->remap_slice = depth <= 8 ? remap2_8bit_slice : remap2_16bit_slice; elements = 2 * 2; sizeof_uv = sizeof(uint16_t) * elements; - sizeof_ker = sizeof(float) * elements; + sizeof_ker = sizeof(uint16_t) * elements; break; case BICUBIC: calculate_kernel = bicubic_kernel; s->remap_slice = depth <= 8 ? remap4_8bit_slice : remap4_16bit_slice; elements = 4 * 4; sizeof_uv = sizeof(uint16_t) * elements; - sizeof_ker = sizeof(float) * elements; + sizeof_ker = sizeof(uint16_t) * elements; break; case LANCZOS: calculate_kernel = lanczos_kernel; s->remap_slice = depth <= 8 ? remap4_8bit_slice : remap4_16bit_slice; elements = 4 * 4; sizeof_uv = sizeof(uint16_t) * elements; - sizeof_ker = sizeof(float) * elements; + sizeof_ker = sizeof(uint16_t) * elements; break; } @@ -2182,7 +2182,7 @@ static int config_output(AVFilterLink *outlink) for (j = 0; j < height; j++) { uint16_t *u = s->u[p] + (j * width + i) * elements; uint16_t *v = s->v[p] + (j * width + i) * elements; - float *ker = s->ker[p] + (j * width + i) * elements; + int16_t *ker = s->ker[p] + (j * width + i) * elements; out_transform(s, i, j, width, height, vec); rotate(rot_mat, vec);