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 <math.h>
20
21#include "libavutil/avassert.h"
24#include "kbdwin.h"
25
26av_cold static void kbd_window_init(float *float_window, int *int_window, float alpha, int n)
27{
28 int i;
29 double sum = 0.0, tmp;
30 double scale = 0.0;
31 double temp[FF_KBD_WINDOW_MAX / 2 + 1];
32 double alpha2 = 4 * (alpha * M_PI / n) * (alpha * M_PI / n);
33
35
36 for (i = 0; i <= n / 2; i++) {
37 tmp = i * (n - i) * alpha2;
38 temp[i] = av_bessel_i0(sqrt(tmp));
39 scale += temp[i] * (1 + (i && i<n/2));
40 }
41 scale = 1.0/(scale + 1);
42
43 for (i = 0; i <= n / 2; i++) {
44 sum += temp[i];
45 if (float_window) float_window[i] = sqrt(sum * scale);
46 else int_window[i] = lrint(2147483647 * sqrt(sum * scale));
47 }
48 for (; i < n; i++) {
49 sum += temp[n - i];
50 if (float_window) float_window[i] = sqrt(sum * scale);
51 else int_window[i] = lrint(2147483647 * sqrt(sum * scale));
52 }
53}
54
55av_cold void ff_kbd_window_init(float *window, float alpha, int n)
56{
58}
59
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:369
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:26
av_cold void ff_kbd_window_init(float *window, float alpha, int n)
Generate a Kaiser-Bessel Derived Window.
Definition kbdwin.c:55
av_cold void ff_kbd_window_init_fixed(int32_t *window, float alpha, int n)
Definition kbdwin.c:60
#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
#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