Skip to content

Commit 6ee9ce2

Browse files
committed
Significant speedup for YUV/NV12/P010 and related codecs
Log: replace old C-style format with modern C++20 for compile-time safety
1 parent ba86f69 commit 6ee9ce2

File tree

270 files changed

+5649
-4597
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

270 files changed

+5649
-4597
lines changed

.clang-tidy

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
Checks: >
2+
-*,
3+
clang-analyzer-*,
4+
modernize-*,
5+
performance-*,
6+
-cppcoreguidelines-pro-type-reinterpret-cast,
7+
-cppcoreguidelines-pro-type-union-access,
8+
-cppcoreguidelines-pro-bounds-constant-array-index,
9+
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
10+
-cppcoreguidelines-owning-memory,
11+
-cppcoreguidelines-no-malloc,
12+
-cppcoreguidelines-avoid-magic-numbers,
13+
-cppcoreguidelines-pro-type-vararg,
14+
-cppcoreguidelines-avoid-non-const-global-variables,
15+
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
16+
-clang-analyzer-security.insecureAPI.memcpy,
17+
-fuchsia-trailing-return,
18+
-modernize-use-trailing-return-type,
19+
-modernize-use-auto,
20+
-modernize-raw-string-literal,
21+
-cppcoreguidelines-pro-type-cstyle-cast,
22+
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
23+
-cppcoreguidelines-avoid-c-arrays,
24+
-cppcoreguidelines-pro-type-member-init,
25+
-cppcoreguidelines-macro-usage,
26+
-modernize-avoid-c-arrays,
27+
-performance-no-int-to-ptr,
28+
-clang-analyzer-optin.core.EnumCastOutOfRange,
29+
-clang-analyzer-core.UndefinedBinaryOperatorResult,
30+
-modernize-use-default-member-init,
31+
-cppcoreguidelines-narrowing-conversions,
32+
-modernize-return-braced-init-list,
33+
-performance-avoid-endl,
34+
-modernize-loop-convert,
35+
-clang-analyzer-security.FloatLoopCounter,
36+
-modernize-use-emplace,
37+
-modernize-macro-to-enum,
38+
-performance-enum-size
39+
40+
CheckOptions:
41+
- key: performance-unnecessary-value-param.AllowedTypes
42+
value: ^Q[A-Z].*$
43+
- key: performance-unnecessary-copy-initialization.AllowedTypes
44+
value: ^Q[A-Z].*$
45+
- key: cppcoreguidelines-macro-usage.AllowedRegexp
46+
value: ^DEBUG_*$
47+
48+
HeaderFilterRegex: '^(?!.*(autogen|mocs_|qrc_|/external/|_deps/)).*'
49+

.clang-tidy-fix

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
Checks: >
2+
-*,
3+
modernize-use-nullptr,
4+
modernize-use-override,
5+
modernize-use-equals-default,
6+
modernize-use-equals-delete,
7+
modernize-use-bool-literals,
8+
modernize-deprecated-headers,
9+
performance-faster-string-find,
10+
performance-for-range-copy,
11+
performance-inefficient-vector-operation,
12+
readability-container-size-empty,
13+
readability-redundant-string-cstr,
14+
readability-string-compare,
15+
bugprone-copy-constructor-init,
16+
bugprone-macro-parentheses,
17+
readability-redundant-smartptr-get,
18+
readability-redundant-control-flow,
19+
readability-static-accessed-through-instance,
20+
performance-move-const-arg,
21+
modernize-make-unique,
22+
readability-simplify-boolean-expr,
23+
modernize-redundant-void-arg,
24+
readability-redundant-casting,
25+
readability-inconsistent-declaration-parameter-name,
26+
performance-unnecessary-value-param,
27+
performance-unnecessary-copy-initialization
28+
29+
CheckOptions:
30+
- key: performance-unnecessary-value-param.AllowedTypes
31+
value: '.*Q[A-Z].*'
32+
- key: performance-unnecessary-copy-initialization.AllowedTypes
33+
value: '.*Q[A-Z].*'
34+
35+
HeaderFilterRegex: '^(?!.*(autogen|mocs_|qrc_|/external/|_deps/)).*'
36+
37+
#Checks: >
38+
# -*,
39+
# readability-duplicate-include
40+
#
41+
#ExtraArgs:
42+
# - "-include"
43+
# - "include/precompiled_hyperhdr_headers/AllHeaders_pch.h"
44+
# - "-DPCH_ENABLED"

.clazy

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Checks=level1,level2,\
2+
container-inside-loop,\
3+
detaching-member,\
4+
inefficient-qlist,\
5+
missing-qobject-macro,\
6+
qstring-allocations,\
7+
qt4-qstring-from-array,\
8+
no-qstring-arg,\
9+
range-loop,\
10+
missing-type-info,\
11+
no-autodetect,\
12+
no-skipped-base-method

.github/workflows/push-master.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,12 +321,12 @@ jobs:
321321

322322
- name: Run clazy
323323
run: |
324-
jq -r '.[] | select((.file | type=="string") and (.file | test("^(external/|_deps/)") | not)) | .file' build/compile_commands.json | xargs clazy-standalone -p build -- > clazy-report.txt 2>&1 || true
324+
jq -r '.[] | .file' build/compile_commands.json | tr '\n' '\0' | xargs -0 clazy-standalone -p build -ignore-dirs "/external/|_deps/" 2>&1 | sed "/warning: argument unused during compilation: '-fuse-ld=gold'/d; /\[-Wclazy-const-signal-or-slot\]/,/^[[:space:]]*\^/d; /\[-Wclazy-qstring-arg\]/,/^[[:space:]]*\^/d; /\[-Wclazy-skipped-base-method\]/,/^[[:space:]]*\^/d" | sed '/^In file included from/d; /^[0-9]\+ warning.* generated\./d' > clazy-report.txt || true
325325
326326
- name: Run clang-tidy
327327
run: |
328-
jq -r '.[] | select(.file | test("external/") | not and test("_deps/") | not) | .file' build/compile_commands.json | xargs run-clang-tidy -p build > clang-tidy-report.txt || true
329-
328+
jq -r '.[] | select(.file | test("external/|_deps/|/mocs_") | not) | .file' build/compile_commands.json | xargs run-clang-tidy -p build -quiet | awk 'BEGIN{b=""}/: warning:/{if(b!=""&&!s)printf"%s",b;b="";s=0;c=$0~/(pass-by-value|value-param)/;l="";nx=0}{b=b$0"\n";if(c){if(nx){if(substr($0,idx)~/^Q[A-Z][a-zA-Z0-9]*/)s=1;nx=0}if($0~/^[ \t]*\|?[ \t]*\^/){idx=index($0,"^");if(substr(l,idx)~/^(const[ \t]+)?Q[A-Z][a-zA-Z0-9]*/)s=1;nx=1}if($0~/^[ \t]*[0-9]+ \|/)l=$0}}END{if(b!=""&&!s)printf"%s",b}' > clang-tidy-report.txt || true
329+
# jq -r '.[] | select(.file | test("external/|_deps/|autogen|mocs_|qrc_") | not) | .file' build/compile_commands.json | xargs run-clang-tidy -p build -quiet -config="$(cat .clang-tidy-fix)" -fix > clang-tidy-fix.log 2>&1 || true
330330
- name: Combine reports
331331
run: |
332332
echo "### Clang-Tidy Report" > report.md

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ build/
2525
include/flatbuffers/parser/hyperhdr_reply_generated.h
2626
include/flatbuffers/parser/hyperhdr_request_generated.h
2727

28+
tests/codec_test/build/
29+
2830

2931
# Kdevelop project files
3032
*.kdev*

CMakeLists.txt

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -602,20 +602,16 @@ else()
602602
endif()
603603
message(STATUS "C++20 support has been enabled.")
604604

605-
# Use lld then ld.gold linker if available
606-
if((CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") AND NOT WIN32 AND NOT APPLE)
607-
find_program(LLD_EXECUTABLE lld)
608-
find_program(GOLD_EXECUTABLE ld.gold)
609-
610-
if(LLD_EXECUTABLE)
611-
message(STATUS "Found 'lld' linker, enabling...")
612-
add_compile_options("-fuse-ld=lld")
613-
elseif(GOLD_EXECUTABLE)
614-
message(STATUS "Found 'gold' linker, enabling...")
615-
add_compile_options("-fuse-ld=gold")
616-
else()
617-
message(STATUS "Using default system linker (lld and gold not found).")
618-
endif()
605+
# Use lld linker if available
606+
if((CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") AND NOT WIN32 AND NOT APPLE)
607+
find_program(LLD_EXECUTABLE ld.lld)
608+
609+
if(LLD_EXECUTABLE)
610+
message(STATUS "Found 'lld' linker, enabling...")
611+
add_link_options("-fuse-ld=lld")
612+
else()
613+
message(STATUS "Using default system linker (ld.lld not found).")
614+
endif()
619615
endif()
620616

621617
# Don't create new dynamic tags (RUNPATH)

include/api/BaseAPI.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class BaseAPI : public QObject
1919
Q_OBJECT
2020

2121
public:
22-
BaseAPI(Logger* log, bool localConnection, QObject* parent);
22+
BaseAPI(const LoggerName& log, bool localConnection, QObject* parent);
2323

2424
struct ImageCmdData
2525
{
@@ -118,7 +118,7 @@ class BaseAPI : public QObject
118118

119119
bool _adminAuthorized;
120120

121-
Logger* _log;
121+
LoggerName _log;
122122
std::shared_ptr<HyperHdrManager> _instanceManager;
123123
std::shared_ptr<AccessManager> _accessManager;
124124
std::shared_ptr<HyperHdrInstance> _hyperhdr;

include/api/CallbackAPI.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class CallbackAPI : public BaseAPI
2828
Q_OBJECT
2929

3030
public:
31-
CallbackAPI(Logger* log, bool localConnection, QObject* parent);
31+
CallbackAPI(const LoggerName& log, bool localConnection, QObject* parent);
3232

3333
void subscribe(QJsonArray subsArr);
3434

@@ -38,7 +38,7 @@ class CallbackAPI : public BaseAPI
3838
void stopDataConnections() override = 0;
3939
void removeSubscriptions() override;
4040
void addSubscriptions() override;
41-
bool subscribeFor(const QString& cmd, bool unsubscribe = false);
41+
bool subscribeFor(const QString& type, bool unsubscribe = false);
4242

4343
signals:
4444
void SignalCallbackToClient(QJsonObject);

include/api/HyperAPI.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class HyperAPI : public CallbackAPI
1919
Q_OBJECT
2020

2121
public:
22-
HyperAPI(QString peerAddress, Logger* log, bool localConnection, QObject* parent, bool noListener = false);
22+
HyperAPI(QString peerAddress, const LoggerName& log, bool localConnection, QObject* parent, bool noListener = false);
2323
void handleMessage(const QString& message, const QString& httpAuthHeader = "");
2424
void initialize();
2525

@@ -31,7 +31,7 @@ public slots:
3131
private slots:
3232
void newPendingTokenRequest(const QString& id, const QString& comment);
3333
void handleTokenResponse(bool success, const QString& token, const QString& comment, const QString& id, const int& tan);
34-
void handleInstanceStateChange(InstanceState state, quint8 instance, const QString& name = QString());
34+
void handleInstanceStateChange(hyperhdr::InstanceState state, quint8 instance, const QString& name = QString());
3535
void handleLedColorsTimer();
3636
void lutDownloaded(QNetworkReply* reply, int hardware_brightness, int hardware_contrast, int hardware_saturation, qint64 time);
3737

include/base/AccessManager.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#ifndef PCH_ENABLED
44
#include <QMap>
55
#include <QVector>
6+
#include <vector>
67
#endif
7-
88
#include <utils/Logger.h>
99
#include <utils/settings.h>
1010

@@ -80,8 +80,8 @@ public slots:
8080
bool _localAdminAuthRequired;
8181
QTimer* _timer;
8282
QTimer* _authBlockTimer;
83-
QVector<uint64_t> _userAuthAttempts;
84-
QVector<uint64_t> _tokenAuthAttempts;
83+
std::vector<uint64_t> _userAuthAttempts;
84+
std::vector<uint64_t> _tokenAuthAttempts;
8585

8686
private slots:
8787
void checkTimeout();

0 commit comments

Comments
 (0)