From 57326d65d9c4c4e75587ed3e8cede1184ac559d0 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 14 Apr 2025 11:19:44 +0200 Subject: [PATCH] ebur128: work around libebur128 bug Versions 1.2.5 and 1.2.6 don't scale the window in ms correctly, leading to excessive memory allocation, so work around this here. See https://github.com/jiixyj/libebur128/pull/132 Fixes #4646 --- spa/plugins/filter-graph/ebur128_plugin.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/spa/plugins/filter-graph/ebur128_plugin.c b/spa/plugins/filter-graph/ebur128_plugin.c index 22bf5f513..92904e102 100644 --- a/spa/plugins/filter-graph/ebur128_plugin.c +++ b/spa/plugins/filter-graph/ebur128_plugin.c @@ -235,6 +235,8 @@ static void ebur128_cleanup(void * Instance) static void ebur128_activate(void * Instance) { struct ebur128_impl *impl = Instance; + unsigned long max_window; + int major, minor, patch; int mode = 0, i; int modes[] = { EBUR128_MODE_M, @@ -264,12 +266,17 @@ static void ebur128_activate(void * Instance) mode |= modes[i]; } + ebur128_get_version(&major, &minor, &patch); + max_window = impl->max_window; + if (major == 1 && minor == 2 && (patch == 5 || patch == 6)) + max_window = (max_window + 999) / 1000; + for (i = 0; i < 7; i++) { impl->st[i] = ebur128_init(1, impl->rate, mode); if (impl->st[i]) { ebur128_set_channel(impl->st[i], i, channels[i]); ebur128_set_max_history(impl->st[i], impl->max_history); - ebur128_set_max_window(impl->st[i], impl->max_window); + ebur128_set_max_window(impl->st[i], max_window); } } }