luckfox-pico-sdk/sysdrv/tools/board/buildroot/mpv_patch/0002-change-j1.patch
2024-06-07 17:17:28 +08:00

44 lines
1009 B
Diff

--- a/video/out/filter_kernels.c 2024-04-26 11:14:00.377199103 +0800
+++ b/video/out/filter_kernels.c 2024-04-26 11:13:50.217202856 +0800
@@ -32,6 +32,31 @@
// NOTE: all filters are designed for discrete convolution
+double factorial(int n) {
+ if (n == 0)
+ return 1;
+ else
+ return n * factorial(n - 1);
+}
+
+double power(double base, int exponent) {
+ double result = 1.0;
+ for (int i = 0; i < exponent; i++) {
+ result *= base;
+ }
+ return result;
+}
+
+double BesselJ1(double x) {
+ double result = 0.0;
+ for (int n = 0; n <= 10; n++) {
+ result += power(-1, n) * power(x / 2.0, 2 * n + 1) / (factorial(n) * factorial(n + 1));
+ }
+ return result;
+}
+
+
+
const struct filter_window *mp_find_filter_window(const char *name)
{
if (!name)
@@ -324,7 +349,7 @@
if (fabs(x) < 1e-8)
return 1.0;
x *= M_PI;
- return 2.0 * j1(x) / x;
+ return 2.0 * BesselJ1(x) / x;
}
static double sphinx(params *p, double x)