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
304daee4
Commit
304daee4
authored
Jan 14, 2024
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use ThreadPool for refining sync results (performance).
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
d22ec9d5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
24 deletions
+34
-24
syncfinder.cc
src/syncfinder.cc
+34
-24
No files found.
src/syncfinder.cc
View file @
304daee4
...
...
@@ -280,8 +280,8 @@ SyncFinder::sync_select_n_best (vector<Score>& sync_scores, size_t n)
void
SyncFinder
::
search_refine
(
const
WavData
&
wav_data
,
Mode
mode
,
KeyResult
&
key_result
,
const
vector
<
vector
<
FrameBit
>>&
sync_bits
)
{
vector
<
float
>
fft_db
;
vector
<
char
>
have_frames
;
ThreadPool
thread_pool
;
std
::
mutex
result_mutex
;
vector
<
Score
>
result_scores
;
BitPosGen
bit_pos_gen
(
key_result
.
key
);
...
...
@@ -300,34 +300,44 @@ SyncFinder::search_refine (const WavData& wav_data, Mode mode, KeyResult& key_re
for
(
const
auto
&
score
:
key_result
.
sync_scores
)
{
//printf ("%zd %s %f", score.index, find_closest_sync (score.index).c_str(), score.quality);
// refine match
double
best_quality
=
score
.
quality
;
size_t
best_index
=
score
.
index
;
ConvBlockType
best_block_type
=
score
.
block_type
;
/* doesn't really change during refinement */
int
start
=
std
::
max
(
int
(
score
.
index
)
-
Params
::
sync_search_step
,
0
);
int
end
=
score
.
index
+
Params
::
sync_search_step
;
for
(
int
fine_index
=
start
;
fine_index
<=
end
;
fine_index
+=
Params
::
sync_search_fine
)
thread_pool
.
add_job
([
this
,
score
,
total_frame_count
,
&
wav_data
,
&
want_frames
,
&
sync_bits
,
&
result_scores
,
&
result_mutex
]
()
{
sync_fft
(
wav_data
,
fine_index
,
total_frame_count
,
fft_db
,
have_frames
,
want_frames
);
if
(
fft_db
.
size
())
vector
<
float
>
fft_db
;
vector
<
char
>
have_frames
;
//printf ("%zd %s %f", score.index, find_closest_sync (score.index).c_str(), score.quality);
// refine match
double
best_quality
=
score
.
quality
;
size_t
best_index
=
score
.
index
;
ConvBlockType
best_block_type
=
score
.
block_type
;
/* doesn't really change during refinement */
int
start
=
std
::
max
(
int
(
score
.
index
)
-
Params
::
sync_search_step
,
0
);
int
end
=
score
.
index
+
Params
::
sync_search_step
;
for
(
int
fine_index
=
start
;
fine_index
<=
end
;
fine_index
+=
Params
::
sync_search_fine
)
{
ConvBlockType
block_type
;
double
q
=
sync_decode
(
sync_bits
,
wav_data
,
0
,
fft_db
,
have_frames
,
&
block_type
);
if
(
q
>
best_quality
)
sync_fft
(
wav_data
,
fine_index
,
total_frame_count
,
fft_db
,
have_frames
,
want_frames
);
if
(
fft_db
.
size
())
{
best_quality
=
q
;
best_index
=
fine_index
;
ConvBlockType
block_type
;
double
q
=
sync_decode
(
sync_bits
,
wav_data
,
0
,
fft_db
,
have_frames
,
&
block_type
);
if
(
q
>
best_quality
)
{
best_quality
=
q
;
best_index
=
fine_index
;
}
}
}
}
//printf (" => refined: %zd %s %f\n", best_index, find_closest_sync (best_index).c_str(), best_quality);
if
(
best_quality
>
Params
::
sync_threshold2
)
result_scores
.
push_back
(
Score
{
best_index
,
best_quality
,
best_block_type
});
//printf (" => refined: %zd %s %f\n", best_index, find_closest_sync (best_index).c_str(), best_quality);
if
(
best_quality
>
Params
::
sync_threshold2
)
{
std
::
lock_guard
<
std
::
mutex
>
lg
(
result_mutex
);
result_scores
.
push_back
(
Score
{
best_index
,
best_quality
,
best_block_type
});
}
});
}
thread_pool
.
wait_all
();
key_result
.
sync_scores
=
result_scores
;
}
...
...
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