Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Thilo Borgmann <thilo.borgmann@mail.de>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH v4 4/6] lavu/display: Add horizontal and vertical scaling to the display matrix
Date: Mon, 19 Sep 2022 11:46:02 +0200
Message-ID: <20220919094604.4645-5-thilo.borgmann@mail.de> (raw)
In-Reply-To: <20220919094604.4645-1-thilo.borgmann@mail.de>

---
 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".

  parent reply	other threads:[~2022-09-19  9:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-19  9:45 [FFmpeg-devel] [PATCH v4 0/6] Add display_matrix option Thilo Borgmann
2022-09-19  9:45 ` [FFmpeg-devel] [PATCH v4 1/6] lavu/opt: Allow options to be arguments of other options Thilo Borgmann
2022-09-19  9:46 ` [FFmpeg-devel] [PATCH v4 2/6] fftools/cmdutils: Print arguments of options Thilo Borgmann
2022-09-19  9:46 ` [FFmpeg-devel] [PATCH v4 3/6] fftools: Add support for dictionary options Thilo Borgmann
2022-09-19  9:46 ` Thilo Borgmann [this message]
2022-09-19 13:37   ` [FFmpeg-devel] [PATCH v4 4/6] lavu/display: Add horizontal and vertical scaling to the display matrix Andreas Rheinhardt
2022-09-19  9:46 ` [FFmpeg-devel] [PATCH v4 5/6] ffmpeg: Add display_matrix option Thilo Borgmann
2022-09-19  9:46 ` [FFmpeg-devel] [PATCH v4 6/6] ffmpeg: Deprecate display rotation override with a metadata key Thilo Borgmann
2022-09-20  8:36 ` [FFmpeg-devel] [PATCH v4 0/6] Add display_matrix option Anton Khirnov
2022-09-20  9:05   ` Nicolas George
2022-09-20  9:23     ` Anton Khirnov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220919094604.4645-5-thilo.borgmann@mail.de \
    --to=thilo.borgmann@mail.de \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git