[FFmpeg-devel] [PATCH 07/19] swscale: add sws_is_noop()

Niklas Haas ffmpeg at haasn.xyz
Fri Oct 11 01:26:54 EEST 2024


From: Niklas Haas <git at haasn.dev>

Exactly what it says on the tin.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git at haasn.dev>
---
 libswscale/swscale.h | 6 ++++++
 libswscale/utils.c   | 7 +++++++
 2 files changed, 13 insertions(+)

diff --git a/libswscale/swscale.h b/libswscale/swscale.h
index f36efa4183..d7ea9bd714 100644
--- a/libswscale/swscale.h
+++ b/libswscale/swscale.h
@@ -139,6 +139,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 22411d3429..01fe474020 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -2758,3 +2758,10 @@ int sws_test_frame(const AVFrame *frame, int output)
     const SwsFormat fmt = ff_fmt_from_frame(frame);
     return ff_test_fmt(&fmt, output);
 }
+
+int sws_is_noop(const AVFrame *dst, const AVFrame *src)
+{
+    SwsFormat dst_fmt = ff_fmt_from_frame(dst);
+    SwsFormat src_fmt = ff_fmt_from_frame(src);
+    return ff_fmt_equal(&dst_fmt, &src_fmt);
+}
-- 
2.46.1



More information about the ffmpeg-devel mailing list