Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
---
# BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: DontAlign
AlignOperands: true
AlignTrailingComments: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: InlineOnly
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Allman
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 100
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '<EGL/.*\.h>'
Priority: 6
- Regex: '(["/]PlatformDefs|"(system|system_gl|system_egl))\.h"'
Priority: 5
- Regex: '"platform/[^/]+/'
Priority: 2
- Regex: '^<[a-z0-9_]+>$'
Priority: 3
- 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>$'
Priority: 3
- Regex: '^<'
Priority: 4
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '$'
IndentCaseLabels: true
IndentWidth: 2
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60000
PointerAlignment: Left
ReflowComments: false
SortIncludes: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 8
UseTab: Never
...
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.18)
project(visualization.pictureit)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR})
Expand Down
4 changes: 2 additions & 2 deletions debian/copyright
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Format: http://dep.debian.net/deps/dep5
Upstream-Name: visualization.pictureit

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


Files: debian/*
Copyright: 2019-2021 Team Kodi
Copyright: 2019-2026 Team Kodi
License: GPL-2+
This package is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion lib/kissfft/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.18)
project(kissfft)

set(SOURCES kiss_fft.c
Expand Down
2 changes: 1 addition & 1 deletion lib/kissfft/kiss_fft_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@



#endif /* kiss_fft_log_h */
#endif /* kiss_fft_log_h */
7 changes: 2 additions & 5 deletions lib/kodi-kissfft-note.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
kissfft source from https://github.com/mborgerding/kissfft
Sync to 131.1.0 (16 Feb. 2021)

TODO: As now also inside Ubuntu Packages (hirsute and impish) should it take next
time the library by normal depends build on addon.
kissfft from https://github.com/mborgerding/kissfft
Sync to version 131.2.0 (22. Oct. 2025)
74 changes: 37 additions & 37 deletions src/mrfft.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015-2021 Team Kodi (https://kodi.tv)
* Copyright (C) 2015-2026 Team Kodi (https://kodi.tv)
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSE.md for more information.
Expand All @@ -12,60 +12,60 @@
#endif
#include <math.h>

MRFFT::MRFFT(int size, bool windowed) :
m_size(size), m_windowed(windowed)
MRFFT::MRFFT(int size, bool windowed) : m_size(size), m_windowed(windowed)
{
m_cfg = kiss_fftr_alloc(m_size,0,nullptr,nullptr);
m_cfg = kiss_fftr_alloc(m_size, 0, nullptr, nullptr);
}

MRFFT::~MRFFT()
{
// we don' use kiss_fftr_free here because
// its hardcoded to free and doesn't pay attention
// to SIMD (which might be used during kiss_fftr_alloc
//in the C'tor).
KISS_FFT_FREE(m_cfg);
// we don' use kiss_fftr_free here because
// its hardcoded to free and doesn't pay attention
// to SIMD (which might be used during kiss_fftr_alloc
//in the C'tor).
KISS_FFT_FREE(m_cfg);
}

void MRFFT::calc(const float* input, float* output)
{
// temporary buffers
std::vector<kiss_fft_scalar> linput(m_size), rinput(m_size);
std::vector<kiss_fft_cpx> loutput(m_size), routput(m_size);
// temporary buffers
std::vector<kiss_fft_scalar> linput(m_size), rinput(m_size);
std::vector<kiss_fft_cpx> loutput(m_size), routput(m_size);

for (size_t i=0;i<m_size;++i)
{
linput[i] = input[2*i];
rinput[i] = input[2*i+1];
}
for (size_t i = 0; i < m_size; ++i)
{
linput[i] = input[2 * i];
rinput[i] = input[2 * i + 1];
}

if (m_windowed)
{
hann(linput);
hann(rinput);
}
if (m_windowed)
{
hann(linput);
hann(rinput);
}

// transform channels
kiss_fftr(m_cfg, &linput[0], &loutput[0]);
kiss_fftr(m_cfg, &rinput[0], &routput[0]);
// transform channels
kiss_fftr(m_cfg, &linput[0], &loutput[0]);
kiss_fftr(m_cfg, &rinput[0], &routput[0]);

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

// interleave while taking magnitudes and normalizing
for (size_t i=0;i<m_size/2;++i)
{
output[2*i] = filter(loutput[i]);
output[2*i+1] = filter(routput[i]);
}
// interleave while taking magnitudes and normalizing
for (size_t i = 0; i < m_size / 2; ++i)
{
output[2 * i] = filter(loutput[i]);
output[2 * i + 1] = filter(routput[i]);
}
}

#include <iostream>

void MRFFT::hann(std::vector<kiss_fft_scalar>& data)
{
for (size_t i=0;i<data.size();++i)
data[i] *= 0.5*(1.0+cos(2*M_PI*i/(data.size()-1)));
for (size_t i = 0; i < data.size(); ++i)
data[i] *= 0.5 * (1.0 + cos(2 * M_PI * i / (data.size() - 1)));
}
40 changes: 21 additions & 19 deletions src/mrfft.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015-2021 Team Kodi (https://kodi.tv)
* Copyright (C) 2015-2026 Team Kodi (https://kodi.tv)
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSE.md for more information.
Expand All @@ -8,30 +8,32 @@
#pragma once

#include "kiss_fftr.h"

#include <vector>

//! \brief Class performing a RFFT of interleaved stereo data.
class MRFFT
{
public:
//! \brief The constructor creates a RFFT plan.
//! \brief size Length of time data for a single channel.
//! \brief windowed Whether or not to apply a Hann window to data.
MRFFT(int size, bool windowed=false);

//! \brief Free the RFFT plan
~MRFFT();

//! \brief Calculate FFTs
//! \param input Input data of size 2*m_size
//! \param output Output data of size m_size.
void calc(const float* input, float* output);
//! \brief The constructor creates a RFFT plan.
//! \brief size Length of time data for a single channel.
//! \brief windowed Whether or not to apply a Hann window to data.
MRFFT(int size, bool windowed = false);

//! \brief Free the RFFT plan
~MRFFT();

//! \brief Calculate FFTs
//! \param input Input data of size 2*m_size
//! \param output Output data of size m_size.
void calc(const float* input, float* output);

protected:
//! \brief Apply a Hann window to a buffer.
//! \param data Vector with data to apply window to.
static void hann(std::vector<kiss_fft_scalar>& data);
//! \brief Apply a Hann window to a buffer.
//! \param data Vector with data to apply window to.
static void hann(std::vector<kiss_fft_scalar>& data);

size_t m_size; //!< Size for a single channel.
bool m_windowed; //!< Whether or not a Hann window is applied.
kiss_fftr_cfg m_cfg; //!< FFT plan
size_t m_size; //!< Size for a single channel.
bool m_windowed; //!< Whether or not a Hann window is applied.
kiss_fftr_cfg m_cfg; //!< FFT plan
};
Loading