FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/sinewin_tablegen.h
Date: 2026-09-13 11:21:06
Exec Total Coverage
Lines: 16 16 100.0%
Functions: 11 11 100.0%
Branches: 2 2 100.0%

Line Branch Exec Source
1 /*
2 * Header file for hardcoded sine windows
3 *
4 * Copyright (c) 2009 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 #ifndef AVCODEC_SINEWIN_TABLEGEN_H
24 #define AVCODEC_SINEWIN_TABLEGEN_H
25
26 #include <assert.h>
27 #include <math.h>
28 #include "libavutil/attributes.h"
29 #include "libavutil/common.h"
30
31 #if !CONFIG_HARDCODED_TABLES
32 #ifndef BUILD_TABLES
33 #include "libavutil/thread.h"
34 #endif
35
36 SINETABLE( 32);
37 SINETABLE( 64);
38 SINETABLE( 128);
39 SINETABLE( 256);
40 SINETABLE( 512);
41 SINETABLE(1024);
42 SINETABLE(2048);
43 SINETABLE(4096);
44 SINETABLE(8192);
45 #else
46 #include "libavcodec/sinewin_tables.h"
47 #endif
48
49 SINETABLE_CONST float *const ff_sine_windows[] = {
50 NULL, NULL, NULL, NULL, NULL, // unused
51 ff_sine_32, ff_sine_64, ff_sine_128,
52 ff_sine_256, ff_sine_512, ff_sine_1024,
53 ff_sine_2048, ff_sine_4096, ff_sine_8192,
54 };
55
56 // Generate a sine window.
57 1359 av_cold void ff_sine_window_init(float *window, int n)
58 {
59 int i;
60
2/2
✓ Branch 0 taken 817280 times.
✓ Branch 1 taken 1359 times.
818639 for(i = 0; i < n; i++)
61 817280 window[i] = sinf((i + 0.5) * (M_PI / (2.0 * n)));
62 1359 }
63
64 #if !CONFIG_HARDCODED_TABLES && !defined(BUILD_TABLES)
65 #define INIT_FF_SINE_WINDOW_INIT_FUNC(index) \
66 static void init_ff_sine_window_ ## index(void) \
67 { \
68 ff_sine_window_init(ff_sine_windows[index], 1 << index);\
69 }
70
71 7 INIT_FF_SINE_WINDOW_INIT_FUNC(5)
72 12 INIT_FF_SINE_WINDOW_INIT_FUNC(6)
73 280 INIT_FF_SINE_WINDOW_INIT_FUNC(7)
74 15 INIT_FF_SINE_WINDOW_INIT_FUNC(8)
75 254 INIT_FF_SINE_WINDOW_INIT_FUNC(9)
76 272 INIT_FF_SINE_WINDOW_INIT_FUNC(10)
77 21 INIT_FF_SINE_WINDOW_INIT_FUNC(11)
78 5 INIT_FF_SINE_WINDOW_INIT_FUNC(12)
79 5 INIT_FF_SINE_WINDOW_INIT_FUNC(13)
80
81 static void (*const sine_window_init_func_array[])(void) = {
82 init_ff_sine_window_5,
83 init_ff_sine_window_6,
84 init_ff_sine_window_7,
85 init_ff_sine_window_8,
86 init_ff_sine_window_9,
87 init_ff_sine_window_10,
88 init_ff_sine_window_11,
89 init_ff_sine_window_12,
90 init_ff_sine_window_13,
91 };
92
93 static AVOnce init_sine_window_once[9] = {
94 AV_ONCE_INIT, AV_ONCE_INIT, AV_ONCE_INIT, AV_ONCE_INIT, AV_ONCE_INIT,
95 AV_ONCE_INIT, AV_ONCE_INIT, AV_ONCE_INIT, AV_ONCE_INIT
96 };
97 #endif
98
99 898 av_cold void ff_init_ff_sine_windows(int index)
100 {
101 assert(index >= 5 && index < FF_ARRAY_ELEMS(ff_sine_windows));
102 #if !CONFIG_HARDCODED_TABLES
103 #ifdef BUILD_TABLES
104 ff_sine_window_init(ff_sine_windows[index], 1 << index);
105 #else
106 898 ff_thread_once(&init_sine_window_once[index - 5], sine_window_init_func_array[index - 5]);
107 #endif
108 #endif
109 898 }
110
111 #endif /* AVCODEC_SINEWIN_TABLEGEN_H */
112