@@ -1,4 +1,5 @@
/*
+ * Copyright (C) 2024 Niklas Haas
* Copyright (C) 2001-2011 Michael Niedermayer <michaelni@gmx.at>
*
* This file is part of FFmpeg.
@@ -78,6 +79,12 @@ const AVClass *sws_get_class(void);
*/
SwsContext *sws_alloc_context(void);
+/**
+ * Free the context and everything associated with it, and write NULL
+ * to the provided pointer.
+ */
+void sws_free_context(SwsContext **ctx);
+
/* values for the flags, the stuff on the command line is different */
#define SWS_FAST_BILINEAR 1
#define SWS_BILINEAR 2
@@ -2520,6 +2520,16 @@ void sws_freeContext(SwsContext *sws)
av_free(sws);
}
+void sws_free_context(SwsContext **pctx)
+{
+ SwsContext *ctx = *pctx;
+ if (!ctx)
+ return;
+
+ sws_freeContext(ctx);
+ *pctx = NULL;
+}
+
SwsContext *sws_getCachedContext(SwsContext *sws, int srcW,
int srcH, enum AVPixelFormat srcFormat,
int dstW, int dstH,