Skip to content

Commit 97ed5e9

Browse files
authored
Merge pull request #78 from AlwinEsch/Piers-change
update to visualization API 5.0.0 and code cleanups
2 parents f897984 + 7ef31df commit 97ed5e9

12 files changed

Lines changed: 583 additions & 384 deletions

File tree

.clang-format

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
# BasedOnStyle: LLVM
3+
AccessModifierOffset: -2
4+
AlignAfterOpenBracket: Align
5+
AlignConsecutiveAssignments: false
6+
AlignConsecutiveDeclarations: false
7+
AlignEscapedNewlines: DontAlign
8+
AlignOperands: true
9+
AlignTrailingComments: false
10+
AllowAllConstructorInitializersOnNextLine: false
11+
AllowAllParametersOfDeclarationOnNextLine: true
12+
AllowShortBlocksOnASingleLine: false
13+
AllowShortCaseLabelsOnASingleLine: false
14+
AllowShortFunctionsOnASingleLine: InlineOnly
15+
AllowShortIfStatementsOnASingleLine: false
16+
AllowShortLoopsOnASingleLine: false
17+
AlwaysBreakAfterDefinitionReturnType: None
18+
AlwaysBreakAfterReturnType: None
19+
AlwaysBreakBeforeMultilineStrings: false
20+
AlwaysBreakTemplateDeclarations: true
21+
BinPackArguments: true
22+
BinPackParameters: false
23+
BreakBeforeBinaryOperators: None
24+
BreakBeforeBraces: Allman
25+
BreakBeforeTernaryOperators: true
26+
BreakConstructorInitializersBeforeComma: false
27+
BreakConstructorInitializers: BeforeColon
28+
BreakAfterJavaFieldAnnotations: false
29+
BreakStringLiterals: true
30+
ColumnLimit: 100
31+
CommentPragmas: '^ IWYU pragma:'
32+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
33+
ConstructorInitializerIndentWidth: 2
34+
ContinuationIndentWidth: 4
35+
Cpp11BracedListStyle: true
36+
DerivePointerAlignment: false
37+
DisableFormat: false
38+
ExperimentalAutoDetectBinPacking: false
39+
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
40+
IncludeBlocks: Regroup
41+
IncludeCategories:
42+
- Regex: '<EGL/.*\.h>'
43+
Priority: 6
44+
- Regex: '(["/]PlatformDefs|"(system|system_gl|system_egl))\.h"'
45+
Priority: 5
46+
- Regex: '"platform/[^/]+/'
47+
Priority: 2
48+
- Regex: '^<[a-z0-9_]+>$'
49+
Priority: 3
50+
- Regex: '^<(assert|complex|ctype|errno|fenv|float|inttypes|iso646|limits|locale|math|setjmp|signal|stdalign|stdarg|stdatomic|stdbool|stddef|stdint|stdio|stdlib|stdnoreturn|string|tgmath|threads|time|uchar|wchar|wctype)\.h>$'
51+
Priority: 3
52+
- Regex: '^<'
53+
Priority: 4
54+
- Regex: '.*'
55+
Priority: 1
56+
IncludeIsMainRegex: '$'
57+
IndentCaseLabels: true
58+
IndentWidth: 2
59+
IndentWrappedFunctionNames: false
60+
JavaScriptQuotes: Leave
61+
JavaScriptWrapImports: true
62+
KeepEmptyLinesAtTheStartOfBlocks: true
63+
MacroBlockBegin: ''
64+
MacroBlockEnd: ''
65+
MaxEmptyLinesToKeep: 1
66+
NamespaceIndentation: None
67+
ObjCBlockIndentWidth: 2
68+
ObjCSpaceAfterProperty: false
69+
ObjCSpaceBeforeProtocolList: true
70+
PenaltyBreakBeforeFirstCallParameter: 19
71+
PenaltyBreakComment: 300
72+
PenaltyBreakFirstLessLess: 120
73+
PenaltyBreakString: 1000
74+
PenaltyExcessCharacter: 1000000
75+
PenaltyReturnTypeOnItsOwnLine: 60000
76+
PointerAlignment: Left
77+
ReflowComments: false
78+
SortIncludes: true
79+
SpaceAfterCStyleCast: false
80+
SpaceAfterTemplateKeyword: false
81+
SpaceBeforeAssignmentOperators: true
82+
SpaceBeforeParens: ControlStatements
83+
SpaceInEmptyParentheses: false
84+
SpacesBeforeTrailingComments: 1
85+
SpacesInAngles: false
86+
SpacesInContainerLiterals: true
87+
SpacesInCStyleCastParentheses: false
88+
SpacesInParentheses: false
89+
SpacesInSquareBrackets: false
90+
Standard: Cpp11
91+
TabWidth: 8
92+
UseTab: Never
93+
...

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.5)
1+
cmake_minimum_required(VERSION 3.18)
22
project(visualization.pictureit)
33

44
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR})

debian/copyright

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Format: http://dep.debian.net/deps/dep5
22
Upstream-Name: visualization.pictureit
33

44
Files: *
5-
Copyright: 2018-2021 Team Kodi
5+
Copyright: 2018-2026 Team Kodi
66
2015-2019 LinuxWhatElse
77
License: GPL-2+
88
This package is free software; you can redistribute it and/or modify
@@ -23,7 +23,7 @@ License: GPL-2+
2323

2424

2525
Files: debian/*
26-
Copyright: 2019-2021 Team Kodi
26+
Copyright: 2019-2026 Team Kodi
2727
License: GPL-2+
2828
This package is free software; you can redistribute it and/or modify
2929
it under the terms of the GNU General Public License as published by

lib/kissfft/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.5)
1+
cmake_minimum_required(VERSION 3.18)
22
project(kissfft)
33

44
set(SOURCES kiss_fft.c

lib/kissfft/kiss_fft_log.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@
3333

3434

3535

36-
#endif /* kiss_fft_log_h */
36+
#endif /* kiss_fft_log_h */

lib/kodi-kissfft-note.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
1-
kissfft source from https://github.com/mborgerding/kissfft
2-
Sync to 131.1.0 (16 Feb. 2021)
3-
4-
TODO: As now also inside Ubuntu Packages (hirsute and impish) should it take next
5-
time the library by normal depends build on addon.
1+
kissfft from https://github.com/mborgerding/kissfft
2+
Sync to version 131.2.0 (22. Oct. 2025)

src/mrfft.cpp

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2015-2021 Team Kodi (https://kodi.tv)
2+
* Copyright (C) 2015-2026 Team Kodi (https://kodi.tv)
33
*
44
* SPDX-License-Identifier: GPL-2.0-or-later
55
* See LICENSE.md for more information.
@@ -12,60 +12,60 @@
1212
#endif
1313
#include <math.h>
1414

15-
MRFFT::MRFFT(int size, bool windowed) :
16-
m_size(size), m_windowed(windowed)
15+
MRFFT::MRFFT(int size, bool windowed) : m_size(size), m_windowed(windowed)
1716
{
18-
m_cfg = kiss_fftr_alloc(m_size,0,nullptr,nullptr);
17+
m_cfg = kiss_fftr_alloc(m_size, 0, nullptr, nullptr);
1918
}
2019

2120
MRFFT::~MRFFT()
2221
{
23-
// we don' use kiss_fftr_free here because
24-
// its hardcoded to free and doesn't pay attention
25-
// to SIMD (which might be used during kiss_fftr_alloc
26-
//in the C'tor).
27-
KISS_FFT_FREE(m_cfg);
22+
// we don' use kiss_fftr_free here because
23+
// its hardcoded to free and doesn't pay attention
24+
// to SIMD (which might be used during kiss_fftr_alloc
25+
//in the C'tor).
26+
KISS_FFT_FREE(m_cfg);
2827
}
2928

3029
void MRFFT::calc(const float* input, float* output)
3130
{
32-
// temporary buffers
33-
std::vector<kiss_fft_scalar> linput(m_size), rinput(m_size);
34-
std::vector<kiss_fft_cpx> loutput(m_size), routput(m_size);
31+
// temporary buffers
32+
std::vector<kiss_fft_scalar> linput(m_size), rinput(m_size);
33+
std::vector<kiss_fft_cpx> loutput(m_size), routput(m_size);
3534

36-
for (size_t i=0;i<m_size;++i)
37-
{
38-
linput[i] = input[2*i];
39-
rinput[i] = input[2*i+1];
40-
}
35+
for (size_t i = 0; i < m_size; ++i)
36+
{
37+
linput[i] = input[2 * i];
38+
rinput[i] = input[2 * i + 1];
39+
}
4140

42-
if (m_windowed)
43-
{
44-
hann(linput);
45-
hann(rinput);
46-
}
41+
if (m_windowed)
42+
{
43+
hann(linput);
44+
hann(rinput);
45+
}
4746

48-
// transform channels
49-
kiss_fftr(m_cfg, &linput[0], &loutput[0]);
50-
kiss_fftr(m_cfg, &rinput[0], &routput[0]);
47+
// transform channels
48+
kiss_fftr(m_cfg, &linput[0], &loutput[0]);
49+
kiss_fftr(m_cfg, &rinput[0], &routput[0]);
5150

52-
auto&& filter = [&](kiss_fft_cpx& data)
53-
{
54-
return sqrt(data.r*data.r+data.i*data.i) * 2.0/m_size * (m_windowed?sqrt(8.0/3.0):1.0);
55-
};
51+
auto&& filter = [&](kiss_fft_cpx& data)
52+
{
53+
return sqrt(data.r * data.r + data.i * data.i) * 2.0 / m_size *
54+
(m_windowed ? sqrt(8.0 / 3.0) : 1.0);
55+
};
5656

57-
// interleave while taking magnitudes and normalizing
58-
for (size_t i=0;i<m_size/2;++i)
59-
{
60-
output[2*i] = filter(loutput[i]);
61-
output[2*i+1] = filter(routput[i]);
62-
}
57+
// interleave while taking magnitudes and normalizing
58+
for (size_t i = 0; i < m_size / 2; ++i)
59+
{
60+
output[2 * i] = filter(loutput[i]);
61+
output[2 * i + 1] = filter(routput[i]);
62+
}
6363
}
6464

6565
#include <iostream>
6666

6767
void MRFFT::hann(std::vector<kiss_fft_scalar>& data)
6868
{
69-
for (size_t i=0;i<data.size();++i)
70-
data[i] *= 0.5*(1.0+cos(2*M_PI*i/(data.size()-1)));
69+
for (size_t i = 0; i < data.size(); ++i)
70+
data[i] *= 0.5 * (1.0 + cos(2 * M_PI * i / (data.size() - 1)));
7171
}

src/mrfft.h

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2015-2021 Team Kodi (https://kodi.tv)
2+
* Copyright (C) 2015-2026 Team Kodi (https://kodi.tv)
33
*
44
* SPDX-License-Identifier: GPL-2.0-or-later
55
* See LICENSE.md for more information.
@@ -8,30 +8,32 @@
88
#pragma once
99

1010
#include "kiss_fftr.h"
11+
1112
#include <vector>
1213

1314
//! \brief Class performing a RFFT of interleaved stereo data.
1415
class MRFFT
1516
{
1617
public:
17-
//! \brief The constructor creates a RFFT plan.
18-
//! \brief size Length of time data for a single channel.
19-
//! \brief windowed Whether or not to apply a Hann window to data.
20-
MRFFT(int size, bool windowed=false);
21-
22-
//! \brief Free the RFFT plan
23-
~MRFFT();
24-
25-
//! \brief Calculate FFTs
26-
//! \param input Input data of size 2*m_size
27-
//! \param output Output data of size m_size.
28-
void calc(const float* input, float* output);
18+
//! \brief The constructor creates a RFFT plan.
19+
//! \brief size Length of time data for a single channel.
20+
//! \brief windowed Whether or not to apply a Hann window to data.
21+
MRFFT(int size, bool windowed = false);
22+
23+
//! \brief Free the RFFT plan
24+
~MRFFT();
25+
26+
//! \brief Calculate FFTs
27+
//! \param input Input data of size 2*m_size
28+
//! \param output Output data of size m_size.
29+
void calc(const float* input, float* output);
30+
2931
protected:
30-
//! \brief Apply a Hann window to a buffer.
31-
//! \param data Vector with data to apply window to.
32-
static void hann(std::vector<kiss_fft_scalar>& data);
32+
//! \brief Apply a Hann window to a buffer.
33+
//! \param data Vector with data to apply window to.
34+
static void hann(std::vector<kiss_fft_scalar>& data);
3335

34-
size_t m_size; //!< Size for a single channel.
35-
bool m_windowed; //!< Whether or not a Hann window is applied.
36-
kiss_fftr_cfg m_cfg; //!< FFT plan
36+
size_t m_size; //!< Size for a single channel.
37+
bool m_windowed; //!< Whether or not a Hann window is applied.
38+
kiss_fftr_cfg m_cfg; //!< FFT plan
3739
};

0 commit comments

Comments
 (0)