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 v5 1/3] lavu/display: Add scaling functions to the display matrix
Date: Sun, 25 Sep 2022 18:15:04 +0200
Message-ID: <20220925161506.80724-2-thilo.borgmann@mail.de> (raw)
In-Reply-To: <20220925161506.80724-1-thilo.borgmann@mail.de>

---
 doc/APIchanges      |  3 +++
 libavutil/display.c | 21 +++++++++++++++++++++
 libavutil/display.h | 15 +++++++++++++++
 libavutil/version.h |  4 ++--
 4 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 729f56be7b..42e3391b72 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -14,6 +14,9 @@ libavutil:     2021-04-27
 
 API changes, most recent first:
 
+2022-09-25 - xxxxxxxxxx - lavu 57.37.100 - display.h
+  Add av_display_matrix_scale(), av_display_scale_get()
+
 2022-09-03 - xxxxxxxxxx - lavu 57.36.100 - pixfmt.h
   Add AV_PIX_FMT_P012, AV_PIX_FMT_Y212, AV_PIX_FMT_XV30, AV_PIX_FMT_XV36
 
diff --git a/libavutil/display.c b/libavutil/display.c
index d31061283c..90758656e3 100644
--- a/libavutil/display.c
+++ b/libavutil/display.c
@@ -48,6 +48,19 @@ double av_display_rotation_get(const int32_t matrix[9])
     return -rotation;
 }
 
+double av_display_scale_get(const int32_t matrix[9])
+{
+    double scale[2];
+
+    scale[0] = hypot(CONV_FP(matrix[0]), CONV_FP(matrix[3]));
+    scale[1] = hypot(CONV_FP(matrix[1]), CONV_FP(matrix[4]));
+
+    if (scale[0] == 0.0 || scale[1] == 0.0)
+        return NAN;
+
+    return scale[0];
+}
+
 void av_display_rotation_set(int32_t matrix[9], double angle)
 {
     double radians = -angle * M_PI / 180.0f;
@@ -72,3 +85,11 @@ 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 scale)
+{
+    matrix[0] = CONV_DB(CONV_FP(matrix[0]) * scale);
+    matrix[1] = CONV_DB(CONV_FP(matrix[1]) * scale);
+    matrix[3] = CONV_DB(CONV_FP(matrix[3]) * scale);
+    matrix[4] = CONV_DB(CONV_FP(matrix[4]) * scale);
+}
diff --git a/libavutil/display.h b/libavutil/display.h
index 31d8bef361..73767b3a71 100644
--- a/libavutil/display.h
+++ b/libavutil/display.h
@@ -86,6 +86,14 @@
  */
 double av_display_rotation_get(const int32_t matrix[9]);
 
+/**
+ * Extract the scaling component of the transformation matrix.
+ *
+ * @param matrix the transformation matrix
+ * @return the scaling by which the transformation matrix scales the frame
+ */
+double av_display_scale_get(const int32_t matrix[9]);
+
 /**
  * Initialize a transformation matrix describing a pure clockwise
  * rotation by the specified angle (in degrees).
@@ -105,6 +113,13 @@ 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.
+ *
+ * @param matrix an allocated transformation matrix
+ * @param scale scale factor by which the matrix should be scaled
+ */
+void av_display_matrix_scale(int32_t matrix[9], double scale);
 /**
  * @}
  * @}
diff --git a/libavutil/version.h b/libavutil/version.h
index 0585fa7b80..9c44cef6aa 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,8 +79,8 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  57
-#define LIBAVUTIL_VERSION_MINOR  36
-#define LIBAVUTIL_VERSION_MICRO 102
+#define LIBAVUTIL_VERSION_MINOR  37
+#define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
                                                LIBAVUTIL_VERSION_MINOR, \
-- 
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".

  reply	other threads:[~2022-09-25 16:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-25 16:15 [FFmpeg-devel] [PATCH v5 0/3] ffmpeg: Add display_{rotation, hflip, vflip, scale} options Thilo Borgmann
2022-09-25 16:15 ` Thilo Borgmann [this message]
2022-09-25 17:48   ` [FFmpeg-devel] [PATCH v5 1/3] lavu/display: Add scaling functions to the display matrix Andreas Rheinhardt
2022-09-25 16:15 ` [FFmpeg-devel] [PATCH v5 2/3] ffmpeg: Add display_{rotation, hflip, vflip, scale} options Thilo Borgmann
2022-09-25 16:15 ` [FFmpeg-devel] [PATCH v5 3/3] ffmpeg: Deprecate display rotation override with a metadata key Thilo Borgmann

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=20220925161506.80724-2-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