From patchwork Thu Aug 8 13:24:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarek Samic X-Patchwork-Id: 14317 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 BD5B34497E6 for ; Thu, 8 Aug 2019 16:33:06 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 989B568AB93; Thu, 8 Aug 2019 16:33:06 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ot1-f66.google.com (mail-ot1-f66.google.com [209.85.210.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C75B368AB68 for ; Thu, 8 Aug 2019 16:32:59 +0300 (EEST) Received: by mail-ot1-f66.google.com with SMTP id o101so118572112ota.8 for ; Thu, 08 Aug 2019 06:32:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=p9uM524AYYWMNyLUoQgufOwU5xY2tXWfbfcWvbYLo48=; b=bY6dU1yCI7zTfpVsE04xrrZVVR9SqD3WEFlxP/scZKfdN+NkIEv/cynfO/5OhOji1L iqlhXRar4jZlq2dgwhBM2hnoZ2LJYije8tHCvdmqNkO95RMghKkWRd4aX7LRHLRaJgxA DXv1jnp5GCQMa3hAYdRY3TRfCYKmrkoMZJBwUm6JYwHqSyLL4J1NlFinD9ivdnWHtejE +mK6vxmY3RztHxnC7W643UJcEC9vJyJBkre+TgK7CdSz8GttHgMS1jQheN5/6YHt2adJ 9kBNK1wJeW4tQh+CM7aokQzwTvEmGs/ONBnQoNueEg2g/SiD4kb4VTYLClKqggjk5RI+ QAzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=p9uM524AYYWMNyLUoQgufOwU5xY2tXWfbfcWvbYLo48=; b=uIrQH+RZ+AXTzBTutrye4uZocSFN9mPT1g/9eUl9kjCVhHJ5D9njQ8ETP15lg49+Mp VhXSPF2GQbUmIs3A4wgVZ6Qhq1K+C0WQ7vCa/gguC84jKoLAC2KZ7ZMKJ8QAos2mZd+p OOM55QtMz0SvTiqvM7B7Ua4bpRRGf78mtALlh/pRfEnBr370ADdQr80GBeOXSmk4zy+R 5c0jrj2JB3C1SScTf8Lz4W/UVCGMH4tQdIfohfrVUtNKgCNyrMns84uoBoAToJMvX4d8 X8PECpwoxLwJdkMnVPpluas+6pkXETdfewz8XMPYSd9qZ1zTaNhKKCIkHeAqo/ntm82F riYQ== X-Gm-Message-State: APjAAAX939PDJRGv3s86q0Sbq6P9G4KvtfaDe27xpqB2r0VNtQ2rhDKg 5K6FzDbQ3J3IA5qkodvq1t4HCZf6R2w= X-Google-Smtp-Source: APXvYqz9JqJ2yarzVY1dvAnxI6J0t3NIDgLypdroV9Wy3fZkgTj8jsZqLR0I4xtm7FXBislKs86HUw== X-Received: by 2002:a6b:cd07:: with SMTP id d7mr14390881iog.150.1565270691862; Thu, 08 Aug 2019 06:24:51 -0700 (PDT) Received: from cldire-arch.stormhome.local (rrcs-70-61-229-139.central.biz.rr.com. [70.61.229.139]) by smtp.gmail.com with ESMTPSA id n21sm66346197ioh.30.2019.08.08.06.24.50 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 08 Aug 2019 06:24:51 -0700 (PDT) From: Jarek Samic To: ffmpeg-devel@ffmpeg.org Date: Thu, 8 Aug 2019 09:24:31 -0400 Message-Id: <20190808132432.29544-2-cldfire3@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190808132432.29544-1-cldfire3@gmail.com> References: <20190808132432.29544-1-cldfire3@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 2/3] lavfi: modify avfilter_get_matrix to support separate scale factors 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: Jarek Samic Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavfilter/transform.c | 13 ++++++++++--- libavfilter/transform.h | 30 +++++++++++++++++++----------- libavfilter/vf_deshake.c | 7 +++++-- 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/libavfilter/transform.c b/libavfilter/transform.c index f92fc4d42f..f4f9e0a47d 100644 --- a/libavfilter/transform.c +++ b/libavfilter/transform.c @@ -103,12 +103,19 @@ INTERPOLATE_METHOD(interpolate_biquadratic) } } -void avfilter_get_matrix(float x_shift, float y_shift, float angle, float zoom, float *matrix) { - matrix[0] = zoom * cos(angle); +void ff_get_matrix( + float x_shift, + float y_shift, + float angle, + float scale_x, + float scale_y, + float *matrix +) { + matrix[0] = scale_x * cos(angle); matrix[1] = -sin(angle); matrix[2] = x_shift; matrix[3] = -matrix[1]; - matrix[4] = matrix[0]; + matrix[4] = scale_y * cos(angle); matrix[5] = y_shift; matrix[6] = 0; matrix[7] = 0; diff --git a/libavfilter/transform.h b/libavfilter/transform.h index 07436bfccb..9b0c19ceca 100644 --- a/libavfilter/transform.h +++ b/libavfilter/transform.h @@ -60,20 +60,28 @@ enum FillMethod { #define FILL_DEFAULT FILL_ORIGINAL /** - * Get an affine transformation matrix from a given translation, rotation, and - * zoom factor. The matrix will look like: + * Get an affine transformation matrix from given translation, rotation, and + * zoom factors. The matrix will look like: * - * [ zoom * cos(angle), -sin(angle), x_shift, - * sin(angle), zoom * cos(angle), y_shift, - * 0, 0, 1 ] + * [ scale_x * cos(angle), -sin(angle), x_shift, + * sin(angle), scale_y * cos(angle), y_shift, + * 0, 0, 1 ] * - * @param x_shift horizontal translation - * @param y_shift vertical translation - * @param angle rotation in radians - * @param zoom scale percent (1.0 = 100%) - * @param matrix 9-item affine transformation matrix + * @param x_shift horizontal translation + * @param y_shift vertical translation + * @param angle rotation in radians + * @param scale_x x scale percent (1.0 = 100%) + * @param scale_y y scale percent (1.0 = 100%) + * @param matrix 9-item affine transformation matrix */ -void avfilter_get_matrix(float x_shift, float y_shift, float angle, float zoom, float *matrix); +void ff_get_matrix( + float x_shift, + float y_shift, + float angle, + float scale_x, + float scale_y, + float *matrix +); /** * Add two matrices together. result = m1 + m2. diff --git a/libavfilter/vf_deshake.c b/libavfilter/vf_deshake.c index c8480e74dd..b516ea2d59 100644 --- a/libavfilter/vf_deshake.c +++ b/libavfilter/vf_deshake.c @@ -421,6 +421,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) const int chroma_width = AV_CEIL_RSHIFT(link->w, desc->log2_chroma_w); const int chroma_height = AV_CEIL_RSHIFT(link->h, desc->log2_chroma_h); int aligned; + float transform_zoom; out = ff_get_video_buffer(outlink, outlink->w, outlink->h); if (!out) { @@ -505,10 +506,12 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) deshake->last.angle = t.angle; deshake->last.zoom = t.zoom; + transform_zoom = 1.0 + t.zoom / 100.0; + // Generate a luma transformation matrix - avfilter_get_matrix(t.vec.x, t.vec.y, t.angle, 1.0 + t.zoom / 100.0, matrix_y); + ff_get_matrix(t.vec.x, t.vec.y, t.angle, transform_zoom, transform_zoom, matrix_y); // Generate a chroma transformation matrix - avfilter_get_matrix(t.vec.x / (link->w / chroma_width), t.vec.y / (link->h / chroma_height), t.angle, 1.0 + t.zoom / 100.0, matrix_uv); + ff_get_matrix(t.vec.x / (link->w / chroma_width), t.vec.y / (link->h / chroma_height), t.angle, transform_zoom, transform_zoom, matrix_uv); // Transform the luma and chroma planes ret = deshake->transform(link->dst, link->w, link->h, chroma_width, chroma_height, matrix_y, matrix_uv, INTERPOLATE_BILINEAR, deshake->edge, in, out);