FFmpeg
Loading...
Searching...
No Matches
kbdwin.c
Go to the documentation of this file.
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#include "libavutil/avassert.h"
20#include "libavutil/libm.h"
23#include "kbdwin.h"
24
25av_cold static void kbd_window_init(float *float_window, int *int_window, float alpha, int n)
26{
27 int i;
28 double sum = 0.0, tmp;
29 double scale = 0.0;
30 double temp[FF_KBD_WINDOW_MAX / 2 + 1];
31 double alpha2 = 4 * (alpha * M_PI / n) * (alpha * M_PI / n);
32
34
35 for (i = 0; i <= n / 2; i++) {
36 tmp = i * (n - i) * alpha2;
37 temp[i] = av_bessel_i0(sqrt(tmp));
38 scale += temp[i] * (1 + (i && i<n/2));
39 }
40 scale = 1.0/(scale + 1);
41
42 for (i = 0; i <= n / 2; i++) {
43 sum += temp[i];
44 if (float_window) float_window[i] = sqrt(sum * scale);
45 else int_window[i] = lrint(2147483647 * sqrt(sum * scale));
46 }
47 for (; i < n; i++) {
48 sum += temp[n - i];
49 if (float_window) float_window[i] = sqrt(sum * scale);
50 else int_window[i] = lrint(2147483647 * sqrt(sum * scale));
51 }
52}
53
54av_cold void ff_kbd_window_init(float *window, float alpha, int n)
55{
57}
58
int32_t
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition avassert.h:42
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define NULL
Definition coverity.c:32
static SDL_Window * window
Definition ffplay.c:365
double av_bessel_i0(double x)
0th order modified bessel function of the first kind.
static const int16_t alpha[]
Definition ilbcdata.h:55
static void scale(int *out, const int *in, const int w, const int h, const int shift)
Definition intra.c:278
static av_cold void kbd_window_init(float *float_window, int *int_window, float alpha, int n)
Definition kbdwin.c:25
av_cold void ff_kbd_window_init(float *window, float alpha, int n)
Generate a Kaiser-Bessel Derived Window.
Definition kbdwin.c:54
av_cold void ff_kbd_window_init_fixed(int32_t *window, float alpha, int n)
Definition kbdwin.c:59
#define FF_KBD_WINDOW_MAX
Maximum window size for ff_kbd_window_init.
Definition kbdwin.h:27
Macro definitions for various function/variable attributes.
#define av_cold
Definition attributes.h:117
Replacements for frequently missing libm functions.
#define M_PI
Definition mathematics.h:67
#define lrint
Definition tablegen.h:53
static uint8_t tmp[40]
Definition aes_ctr.c:52
else temp
Definition vf_mcdeint.c:275