From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id DC40343F4B for ; Mon, 19 Sep 2022 09:47:02 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3F58B68BC79; Mon, 19 Sep 2022 12:46:19 +0300 (EEST) 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --- 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, \ -- 2.20.1 (Apple Git-117) _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".