From patchwork Tue Sep 3 12:11:29 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: 14884 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 7FCD044815A for ; Tue, 3 Sep 2019 15:20:10 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 63B76688048; Tue, 3 Sep 2019 15:20:10 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3D8FE680692 for ; Tue, 3 Sep 2019 15:20:04 +0300 (EEST) Received: by mail-wr1-f66.google.com with SMTP id l11so8423775wrx.5 for ; Tue, 03 Sep 2019 05:20:04 -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=T03OCOsQVFzneKeKKmeAxX/bdfEAI5viM3Lf99lFfK5gpBcrNgAK/vUKXo9CmeMG8O 5N+ZlVCbu1PXWEbaoXaYFVQhCaiFjuEwUK74T8zuhrhXTCKdiki7VThhDrKPYu/fLX0y BRa9cxvUu8Wr4ojpfvX1n9wL8qc+iAPdLRfZmVAaR52MUNGbWTYpr8CFzhygnnHh7Cm/ VzEwskkglYJ7h9bA2/r4I7D7/ivWsfP3JFEF1N/oK3bnRf/JWLTvNDHSWTiwO9EAi3Z6 dARA5cO7xJo1LpWC2VchwMl5uA0bWffazB8NVnqkPxzSpahFBvASrBpcG7svv5QlzQHT cPEA== 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=N4WPKj9rz+1hsAvas2Q9ZDKYnE1TQPyCKjdGIZnTbtS5JTamLJkBcPOiShKj+Zd/qP XrWaVAO3AYKxRU6+dbBH50gWXBYDKRnwkduHvEaWK9UGC8Sbm6LXQpDmbEvNCtDI8XTV 2zc2ZoO1ZI0TqSkVvjFXqVxZR+YLzF8hL6MMXySr8OsFR3MfCuDamK9/i+e4aBxWRnsI mG/M4TOJUek1aNR63P12BoivycbW9WfhpxrxwFpb+g4LgV8iHeTcuAr39mTTOHWj2jzZ kyuleQTbnfb9R9p0vWDpL7bO0w/uMQxDtYu487UFwMN/9NKk3n8SvDhoIpfRFHf7AZez UNCA== X-Gm-Message-State: APjAAAXPUJhoSGEpFucvDJ8svwxRzWEfas+fDINngY8JqB0SjTu1hqTD raTEf9aaYwiCKqYHVObnf/BA1iPo178= X-Google-Smtp-Source: APXvYqz1P9XvQgKlA7paFXcQsZXpzinB4TdO35nnulJiPgraRwlinzJFoFjdPbPudD1zbMLd3ofcVg== X-Received: by 2002:a5d:5591:: with SMTP id i17mr42582032wrv.280.1567512700717; Tue, 03 Sep 2019 05:11:40 -0700 (PDT) Received: from localhost.localdomain ([77.237.106.98]) by smtp.gmail.com with ESMTPSA id m18sm11731645wrg.97.2019.09.03.05.11.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Sep 2019 05:11:40 -0700 (PDT) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Tue, 3 Sep 2019 14:11:29 +0200 Message-Id: <20190903121129.24875-2-onemda@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190903121129.24875-1-onemda@gmail.com> References: <20190903121129.24875-1-onemda@gmail.com> Subject: [FFmpeg-devel] [PATCH 2/2] 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);