Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
audiowmark
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
audiowmark
Commits
ee4b66f5
Commit
ee4b66f5
authored
May 16, 2020
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make Limiter::skip() more efficient.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
5d785ab0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
9 deletions
+8
-9
limiter.cc
src/limiter.cc
+8
-9
No files found.
src/limiter.cc
View file @
ee4b66f5
...
...
@@ -69,22 +69,21 @@ Limiter::process (const vector<float>& samples)
size_t
Limiter
::
skip
(
size_t
zeros
)
{
vector
<
float
>
samples
(
zeros
*
n_channels
);
assert
(
block_size
>=
1
);
assert
(
samples
.
size
()
%
n_channels
==
0
);
// process should be called with whole frames
buffer
.
insert
(
buffer
.
end
(),
samples
.
begin
(),
samples
.
end
());
size_t
buffer_size
=
buffer
.
size
();
buffer_size
+=
zeros
*
n_channels
;
/* need at least two complete blocks in buffer to produce output */
const
uint
buffered_blocks
=
buffer
.
size
()
/
n_channels
/
block_size
;
const
uint
buffered_blocks
=
buffer
_size
/
n_channels
/
block_size
;
if
(
buffered_blocks
<
2
)
{
buffer
.
resize
(
buffer_size
);
return
0
;
}
const
uint
blocks_todo
=
buffered_blocks
-
1
;
buffer
.
erase
(
buffer
.
begin
(),
buffer
.
begin
()
+
blocks_todo
*
block_size
*
n_channels
);
buffer
.
resize
(
buffer_size
-
blocks_todo
*
block_size
*
n_channels
);
return
blocks_todo
*
block_size
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment