aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.dev>2024-10-14 15:16:26 +0200
committerNiklas Haas <git@haasn.dev>2024-10-23 23:06:55 +0200
commitb03c758600f0767d54ae663dadc8f698b79cd1c4 (patch)
treed6af910da7be33f57e5a9ad27ac87237ddd92bd4
parent5e50a56b9c4998838005ddaaed1422a9d717c50f (diff)
downloadffmpeg-b03c758600f0767d54ae663dadc8f698b79cd1c4.tar.gz
swscale: add sws_is_noop()
Exactly what it says on the tin. Sponsored-by: Sovereign Tech Fund Signed-off-by: Niklas Haas <git@haasn.dev>
-rw-r--r--doc/APIchanges3
-rw-r--r--libswscale/swscale.h6
-rw-r--r--libswscale/utils.c14
-rw-r--r--libswscale/version.h2
4 files changed, 24 insertions, 1 deletions
diff --git a/doc/APIchanges b/doc/APIchanges
index 7d94b7bf97..eeb859b873 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07
API changes, most recent first:
+2024-10-23 - xxxxxxxxxx - lsws 8.9.100 - swscale.h
+ Add sws_is_noop().
+
2024-10-23 - xxxxxxxxxx - lsws 8.8.100 - swscale.h
Add frame property testing API:
- sws_test_format()
diff --git a/libswscale/swscale.h b/libswscale/swscale.h
index e3362d5328..50c705ae06 100644
--- a/libswscale/swscale.h
+++ b/libswscale/swscale.h
@@ -140,6 +140,12 @@ int sws_test_transfer(enum AVColorTransferCharacteristic trc, int output);
*/
int sws_test_frame(const AVFrame *frame, int output);
+/**
+ * Check if a given conversion is a noop. Returns a positive integer if
+ * no operation needs to be performed, 0 otherwise.
+ */
+int sws_is_noop(const AVFrame *dst, const AVFrame *src);
+
/* values for the flags, the stuff on the command line is different */
#define SWS_FAST_BILINEAR 1
#define SWS_BILINEAR 2
diff --git a/libswscale/utils.c b/libswscale/utils.c
index c9c80fdb79..3008d4db4d 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -2777,3 +2777,17 @@ int sws_test_frame(const AVFrame *frame, int output)
return 1;
}
+
+int sws_is_noop(const AVFrame *dst, const AVFrame *src)
+{
+ for (int field = 0; field < 2; field++) {
+ SwsFormat dst_fmt = ff_fmt_from_frame(dst, field);
+ SwsFormat src_fmt = ff_fmt_from_frame(src, field);
+ if (!ff_fmt_equal(&dst_fmt, &src_fmt))
+ return 0;
+ if (!dst_fmt.interlaced)
+ break;
+ }
+
+ return 1;
+}
diff --git a/libswscale/version.h b/libswscale/version.h
index c0610fec1e..109bb5cfd9 100644
--- a/libswscale/version.h
+++ b/libswscale/version.h
@@ -28,7 +28,7 @@
#include "version_major.h"
-#define LIBSWSCALE_VERSION_MINOR 8
+#define LIBSWSCALE_VERSION_MINOR 9
#define LIBSWSCALE_VERSION_MICRO 100
#define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \