diff mbox series

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

Message ID 20241010222750.582921-8-ffmpeg@haasn.xyz
State New
Headers show
Series swscale: major API refactor and new graph dispatch | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Niklas Haas Oct. 10, 2024, 10:26 p.m. UTC
From: Niklas Haas <git@haasn.dev>

Exactly what it says on the tin.

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

Patch

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);
+}