From 75f9c84c140c8841cfe1324ef59452025899ad8b Mon Sep 17 00:00:00 2001
From: Damiano Galassi <damiog@gmail.com>
Date: Fri, 21 Feb 2025 12:05:14 +0100
Subject: [PATCH] contrib: update SVT-AV1 to 3.0.0

---
 contrib/svt-av1/A02-memory-leak-fix.patch | 10 ++++++++++
 contrib/svt-av1/module.defs               |  6 +++---
 libhb/encsvtav1.c                         |  2 +-
 3 files changed, 14 insertions(+), 4 deletions(-)
 create mode 100644 contrib/svt-av1/A02-memory-leak-fix.patch

diff --git a/contrib/svt-av1/A02-memory-leak-fix.patch b/contrib/svt-av1/A02-memory-leak-fix.patch
new file mode 100644
index 000000000000..2615b1e75c31
--- /dev/null
+++ b/contrib/svt-av1/A02-memory-leak-fix.patch
@@ -0,0 +1,10 @@
+diff --git a/Source/Lib/Codec/global_me.c b/Source/Lib/Codec/global_me.c
+index f6adbf59..53002238 100644
+--- a/Source/Lib/Codec/global_me.c
++++ b/Source/Lib/Codec/global_me.c
+@@ -454,4 +454,5 @@ void compute_global_motion(PictureParentControlSet *pcs, int *frm_corners, int n
+     *best_wm = global_motion;
+ 
+     for (int m = 0; m < RANSAC_NUM_MOTIONS; m++) { free(params_by_motion[m].inliers); }
++    free(correspondences);
+ }
diff --git a/libhb/encsvtav1.c b/libhb/encsvtav1.c
index 2f16984d5139..54f52a117465 100644
--- a/libhb/encsvtav1.c
+++ b/libhb/encsvtav1.c
@@ -99,7 +99,7 @@ int encsvtInit(hb_work_object_t *w, hb_job_t *job)
     EbErrorType svt_ret;
     int ret;
 
-    svt_ret = svt_av1_enc_init_handle(&pv->svt_handle, pv, &pv->enc_params);
+    svt_ret = svt_av1_enc_init_handle(&pv->svt_handle, &pv->enc_params);
     if (svt_ret != EB_ErrorNone)
     {
         hb_error("encsvtav1: error initializing encoder handle");
