[FFmpeg-cvslog] swscale: add sws_is_noop()
Niklas Haas
git at videolan.org
Thu Oct 24 00:15:08 EEST 2024
ffmpeg | branch: master | Niklas Haas <git at haasn.dev> | Mon Oct 14 15:16:26 2024 +0200| [b03c758600f0767d54ae663dadc8f698b79cd1c4] | committer: Niklas Haas
swscale: add sws_is_noop()
Exactly what it says on the tin.
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git at haasn.dev>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b03c758600f0767d54ae663dadc8f698b79cd1c4
---
doc/APIchanges | 3 +++
libswscale/swscale.h | 6 ++++++
libswscale/utils.c | 14 ++++++++++++++
libswscale/version.h | 2 +-
4 files changed, 24 insertions(+), 1 deletion(-)
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, \
More information about the ffmpeg-cvslog
mailing list