[packages/vapoursynth-plugin-ocr] - added fix from git, updated plugin dir, release 2
qboosh
qboosh at pld-linux.org
Thu Nov 26 19:57:53 CET 2026
commit 0cea80376879f6776c27e58cc5c7b60287dfa31c
Author: Jakub Bogusz <qboosh at pld-linux.org>
Date: Thu Nov 26 19:56:04 2026 +0100
- added fix from git, updated plugin dir, release 2
vapoursynth-plugin-ocr.spec | 12 ++++---
vs-ocr-git.patch | 88 +++++++++++++++++++++++++++++++++++++++++++++
vs-ocr-plugindir.patch | 15 ++++++++
3 files changed, 111 insertions(+), 4 deletions(-)
---
diff --git a/vapoursynth-plugin-ocr.spec b/vapoursynth-plugin-ocr.spec
index 4c73206..244d552 100644
--- a/vapoursynth-plugin-ocr.spec
+++ b/vapoursynth-plugin-ocr.spec
@@ -2,20 +2,22 @@ Summary: Tesseract-based OCR plugin for Vapoursynth
Summary(pl.UTF-8): Oparta na Tesserakcie wtyczka OCR dla programu Vapoursynth
Name: vapoursynth-plugin-ocr
Version: 3
-Release: 1
+Release: 2
# it was vapoursynth.spec subpackage up to 54
Epoch: 1
License: MIT
Group: Libraries
Source0: https://github.com/vapoursynth/vs-ocr/archive/R%{version}/vs-ocr-R%{version}.tar.gz
# Source0-md5: 2372d12d4c7061258709106cf64c6881
+Patch0: vs-ocr-git.patch
+Patch1: vs-ocr-plugindir.patch
URL: https://github.com/vapoursynth/vs-ocr
BuildRequires: meson
BuildRequires: ninja >= 1.5
BuildRequires: rpmbuild(macros) >= 2.042
-BuildRequires: vapoursynth-devel >= 55
+BuildRequires: vapoursynth-devel >= 80
BuildRequires: tesseract-devel >= 4.1.1
-Requires: vapoursynth >= 55
+Requires: vapoursynth >= 80
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
%description
@@ -28,6 +30,8 @@ klatkach obrazu.
%prep
%setup -q -n vs-ocr-R%{version}
+%patch -P0 -p1
+%patch -P1 -p1
%build
%meson
@@ -45,4 +49,4 @@ rm -rf $RPM_BUILD_ROOT
%files
%defattr(644,root,root,755)
%doc LICENSE docs/ocr.rst
-%attr(755,root,root) %{_libdir}/vapoursynth/libocr.so
+%{py3_sitedir}/vapoursynth/plugins/libocr.so
diff --git a/vs-ocr-git.patch b/vs-ocr-git.patch
new file mode 100644
index 0000000..e6dc9c6
--- /dev/null
+++ b/vs-ocr-git.patch
@@ -0,0 +1,88 @@
+From 9f48dd29c7de97d660ece9a11f363bdb06952501 Mon Sep 17 00:00:00 2001
+From: Fredrik Mellbin <fredrik.mellbin at gmail.com>
+Date: Fri, 10 Jul 2026 17:38:12 +0200
+Subject: [PATCH] Fix the datapath argument corrupting language Fix tesseract
+ memory being freed the wrong way Check for null/errors more
+
+---
+ src/ocr.c | 53 +++++++++++++++++++++++++++++++++++++++--------------
+ 1 file changed, 39 insertions(+), 14 deletions(-)
+
+diff --git a/src/ocr.c b/src/ocr.c
+index cf77e05..696b982 100644
+--- a/src/ocr.c
++++ b/src/ocr.c
+@@ -111,17 +111,26 @@ static const VSFrame *VS_CC OCRGetFrame(int n, int activationReason,
+ char *result = TessBaseAPIRect(api, srcp, 1,
+ stride, 0, 0, width, height);
+ int *confs = TessBaseAPIAllWordConfidences(api);
+- int length = strlen(result);
+
+- for (; length > 0 && isspace(result[length - 1]); length--);
+- vsapi->mapSetData(m, "OCRString", result, length, dtUtf8, maReplace);
++ if (result) {
++ int length = strlen(result);
+
+- for (i = 0; confs[i] != -1; i++) {
+- vsapi->mapSetInt(m, "OCRConfidence", confs[i], maAppend);
++ for (; length > 0 &&
++ isspace((unsigned char)result[length - 1]); length--);
++ vsapi->mapSetData(m, "OCRString", result, length,
++ dtUtf8, maReplace);
++ } else {
++ vsapi->mapSetData(m, "OCRString", "", 0, dtUtf8, maReplace);
+ }
+
+- free(confs);
+- free(result);
++ if (confs) {
++ for (i = 0; confs[i] != -1; i++) {
++ vsapi->mapSetInt(m, "OCRConfidence", confs[i], maAppend);
++ }
++ }
++
++ TessDeleteIntArray(confs);
++ TessDeleteText(result);
+ }
+
+ TessBaseAPIEnd(api);
+@@ -231,16 +240,32 @@ static void VS_CC OCRCreate(const VSMap *in, VSMap *out, void *userData,
+ size = vsapi->mapGetDataSize(in, "datapath", 0, &err);
+
+ if (!err) {
+- d.language = szterm(opt, size);
++ d.datapath = szterm(opt, size);
+ #ifdef _WIN32
+ } else {
+ VSPlugin *ocr_plugin = vsapi->getPluginByID("biz.srsfckn.ocr", core);
+- const char *plugin_path = vsapi->getPluginPath(ocr_plugin);
+- char *last_slash = strrchr(plugin_path, '/');
+- const char *defpath = "tessdata/";
+- d.datapath = malloc(last_slash - plugin_path + 1 + strlen(defpath) + 1);
+- memcpy(d.datapath, plugin_path, last_slash - plugin_path + 1);
+- memcpy(d.datapath + (last_slash - plugin_path) + 1, defpath, strlen(defpath) + 1);
++ const char *plugin_path =
++ ocr_plugin ? vsapi->getPluginPath(ocr_plugin) : NULL;
++
++ if (plugin_path) {
++ const char *defpath = "tessdata/";
++ const char *fwd = strrchr(plugin_path, '/');
++ const char *bwd = strrchr(plugin_path, '\\');
++ const char *last_slash = fwd;
++ size_t dirlen;
++
++ if (bwd && (!last_slash || bwd > last_slash))
++ last_slash = bwd;
++
++ dirlen = last_slash ? (size_t)(last_slash - plugin_path) + 1 : 0;
++
++ d.datapath = malloc(dirlen + strlen(defpath) + 1);
++
++ if (d.datapath) {
++ memcpy(d.datapath, plugin_path, dirlen);
++ memcpy(d.datapath + dirlen, defpath, strlen(defpath) + 1);
++ }
++ }
+ #endif
+ }
+
diff --git a/vs-ocr-plugindir.patch b/vs-ocr-plugindir.patch
new file mode 100644
index 0000000..0eb8782
--- /dev/null
+++ b/vs-ocr-plugindir.patch
@@ -0,0 +1,15 @@
+--- vs-ocr-R3/meson.build.orig 2021-09-26 22:33:44.000000000 +0200
++++ vs-ocr-R3/meson.build 2026-11-26 19:37:30.561560308 +0100
+@@ -13,9 +13,11 @@ libtesseract_dep = dependency('tesseract
+
+ deps = [vapoursynth_dep, libtesseract_dep]
+
++py = import('python').find_installation(pure: false)
++
+ shared_module('ocr', sources,
+ dependencies : deps,
+ install : true,
+- install_dir : join_paths(vapoursynth_dep.get_pkgconfig_variable('libdir'), 'vapoursynth'),
++ install_dir : py.get_install_dir() / 'vapoursynth/plugins',
+ gnu_symbol_visibility : 'hidden'
+ )
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/vapoursynth-plugin-ocr.git/commitdiff/0cea80376879f6776c27e58cc5c7b60287dfa31c
More information about the pld-cvs-commit
mailing list