From patchwork Mon Sep 19 09:46:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thilo Borgmann X-Patchwork-Id: 38045 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp1112968pzh; Mon, 19 Sep 2022 02:47:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6SF0J/i/VRwEh4WcDHPRkx4CQP1DJ3piDRrzSZvHcf4cx8kvSPK+mlpRTiW0fP9V955Wme X-Received: by 2002:a17:906:794f:b0:781:7231:d72f with SMTP id l15-20020a170906794f00b007817231d72fmr1237277ejo.63.1663580825610; Mon, 19 Sep 2022 02:47:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663580825; cv=none; d=google.com; s=arc-20160816; b=JIgYEKzd8A2u+PIY6Q69nCU9n4BYRuiwEFTUA7szJJBsVRRPNDFHColnvgAnWHjNEo xunm1alVfp/0TyLS3nYnFDHrzYr2zb8RWOeu65Q90W/k7zYSDrpAZpAi71DN5AdotwbZ WPLfycfXYzAdrJLqyrUVO8iTm/oa6eobTUyiBJJnA4zwuDDBgnHJB939M/krGW/Q4yGi K+GngvbxjXQRT7upVnId/9WTPJkRibo2WElzpkZVBcdZzNtyKrVfNQucVqiNPeLC0avj nN4XJQepO8NAgv4p3lv3umnjB3V/e1A5o0TIMj99oKDQgMfky5QRQK6gaBwomQ6tB3QW N0dQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=9NCwarZz5FRGJDqZryrZMF+CHsV/JQZfSN/EOQMLOZg=; b=oU03fN5LYdzQjAbYhp/JE8rrLvLsvyj+UqBxT8dvGIqLsGpyBUfGnzVRHrU93jboTj mfrCnXxfIljhmNtW+ZWyJEOs18KAXaTJ8bLQK42SbldH+iCO+sGNyPrkKjqt6+MD+rB5 sNfT0HmusOqMXlYv2PxbolsBgP/a1QeZyyqY37EhIEfzXuWE2J33OBETdFhDxNS2hy6V Ngn6FKxGU3/vb3cbT7WPZYYqpmklUknJe7XMSVTPntbiBx2pYT4xSvTOtRK4msDocgpk UXcNz8b9z7ac27CS8rNyNmGghWTF0/lkkIa1SSGBR1wi4tkQ783aKAiZv6iCw2+l8Flg kJGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@mail.de header.s=mailde202009 header.b=tSleYTev; 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=mail.de Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id e10-20020a056402190a00b0044874cf4c88si11815969edz.430.2022.09.19.02.47.05; Mon, 19 Sep 2022 02:47:05 -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=@mail.de header.s=mailde202009 header.b=tSleYTev; 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=mail.de Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7985068BC7D; Mon, 19 Sep 2022 12:46:19 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from shout02.mail.de (shout02.mail.de [62.201.172.25]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C7CCE68BC64 for ; Mon, 19 Sep 2022 12:46:11 +0300 (EEST) Received: from postfix02.mail.de (postfix02.bt.mail.de [10.0.121.126]) by shout02.mail.de (Postfix) with ESMTP id 9BFCCA0C61 for ; Mon, 19 Sep 2022 11:46:06 +0200 (CEST) Received: from smtp01.mail.de (smtp01.bt.mail.de [10.0.121.211]) by postfix02.mail.de (Postfix) with ESMTP id 840BEA03C6 for ; Mon, 19 Sep 2022 11:46:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mail.de; s=mailde202009; t=1663580766; bh=iGapqFXDk05upwAd8qt3jJxhijaD24qI1Ynll2vBFvQ=; h=From:To:Subject:Date:Message-Id:From:To:CC:Subject:Reply-To; b=tSleYTevuqogsJml6fFa3FJaKTvPVAnZP7wPpNYnuLhNpRguNW1A6zr8LLZHlWCgu Iob1oiAO9KRVkgS1+bMHb/237LKDg27pGInGF1XEacndUFLzqNqe5WRomyAMFWGTCg k7IVkzyA3F/g9nACwBn7+bDnJBqM2bECbwwqWzTY+WNDujiybvYwa5JLRPP3hs17aK Wy1yjYQcJque/TT5IpmGuPsh9XMYAEc+gQP8gbLA+O9EsPiYQMg3YXroY1KeUFottF uwR96ZquFw592/H6On9RcwGuWaeD37lt2BwLtRZoLS8yV5xzEWOQLdmKCfaVl5EBUE FqzcsPMjy4tKQ== Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp01.mail.de (Postfix) with ESMTPSA id 4EF88100170 for ; Mon, 19 Sep 2022 11:46:06 +0200 (CEST) From: Thilo Borgmann To: ffmpeg-devel@ffmpeg.org Date: Mon, 19 Sep 2022 11:46:02 +0200 Message-Id: <20220919094604.4645-5-thilo.borgmann@mail.de> In-Reply-To: <20220919094604.4645-1-thilo.borgmann@mail.de> References: <20220919094604.4645-1-thilo.borgmann@mail.de> MIME-Version: 1.0 X-purgate: clean X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate-type: clean X-purgate-Ad: Categorized by eleven eXpurgate (R) http://www.eleven.de X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate: clean X-purgate-size: 4044 X-purgate-ID: 154282::1663580766-CD7F95FC-DE6621B5/0/0 Subject: [FFmpeg-devel] [PATCH v4 4/6] lavu/display: Add horizontal and vertical scaling to the display matrix X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: +khK/JKgpitd --- doc/APIchanges | 3 +++ libavutil/display.c | 35 +++++++++++++++++++++++++++++++++++ libavutil/display.h | 26 ++++++++++++++++++++++++++ libavutil/version.h | 2 +- 4 files changed, 65 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index e4b2fc8799..9dc393d999 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,9 @@ libavutil: 2021-04-27 API changes, most recent first: +2022-09-19 - xxxxxxxxxx - lavu 57.38.100 - display.h + Add av_display_matrix_scale(), av_display_{h,v}scale_get() + 2022-09-19 - xxxxxxxxxx - lavu 57.37.100 - opt.h Add AV_OPT_FLAG_ARGUMENT. Add av_arg_show() to print arguments to options. diff --git a/libavutil/display.c b/libavutil/display.c index d31061283c..434ed50104 100644 --- a/libavutil/display.c +++ b/libavutil/display.c @@ -48,6 +48,30 @@ double av_display_rotation_get(const int32_t matrix[9]) return -rotation; } +double av_display_hscale_get(const int32_t matrix[9]) +{ + double scale; + + scale = hypot(CONV_FP(matrix[0]), CONV_FP(matrix[1])); + + if (scale == 0.0) + return NAN; + + return scale; +} + +double av_display_vscale_get(const int32_t matrix[9]) +{ + double scale; + + scale = hypot(CONV_FP(matrix[3]), CONV_FP(matrix[4])); + + if (scale == 0.0) + return NAN; + + return scale; +} + void av_display_rotation_set(int32_t matrix[9], double angle) { double radians = -angle * M_PI / 180.0f; @@ -72,3 +96,14 @@ void av_display_matrix_flip(int32_t matrix[9], int hflip, int vflip) for (i = 0; i < 9; i++) matrix[i] *= flip[i % 3]; } + +void av_display_matrix_scale(int32_t matrix[9], double hscale, double vscale) +{ + // hscale + matrix[0] = CONV_DB(CONV_FP(matrix[0]) * hscale); + matrix[1] = CONV_DB(CONV_FP(matrix[1]) * hscale); + + // vscale + matrix[3] = CONV_DB(CONV_FP(matrix[3]) * vscale); + matrix[4] = CONV_DB(CONV_FP(matrix[4]) * vscale); +} diff --git a/libavutil/display.h b/libavutil/display.h index 31d8bef361..ef507eb521 100644 --- a/libavutil/display.h +++ b/libavutil/display.h @@ -86,6 +86,24 @@ */ double av_display_rotation_get(const int32_t matrix[9]); +/** + * Extract the horizontal scaling component of the transformation matrix. + * + * @param matrix the transformation matrix + * @return the horizontal scaling by which the transformation matrix scales the frame + * in the horizontal direction. + */ +double av_display_hscale_get(const int32_t matrix[9]); + +/** + * Extract the vertical scaling component of the transformation matrix. + * + * @param matrix the transformation matrix + * @return the vertical scaling by which the transformation matrix scales the frame + * in the vertical direction. + */ +double av_display_vscale_get(const int32_t matrix[9]); + /** * Initialize a transformation matrix describing a pure clockwise * rotation by the specified angle (in degrees). @@ -105,6 +123,14 @@ void av_display_rotation_set(int32_t matrix[9], double angle); */ void av_display_matrix_flip(int32_t matrix[9], int hflip, int vflip); +/** + * Scale the input matrix horizontally and/or vertically. + * + * @param matrix an allocated transformation matrix + * @param hscale scale factor by which the matrix should be scaled horizontally + * @param vscale scale factor by which the matrix should be scaled vertically + */ +void av_display_matrix_scale(int32_t matrix[9], double hscale, double vscale); /** * @} * @} diff --git a/libavutil/version.h b/libavutil/version.h index 9c44cef6aa..5aca550f45 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 57 -#define LIBAVUTIL_VERSION_MINOR 37 +#define LIBAVUTIL_VERSION_MINOR 38 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \