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
8941a7a3
Commit
8941a7a3
authored
Dec 13, 2020
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reorder speed detection functions.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
ed7e78fe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
67 deletions
+68
-67
wmspeed.cc
src/wmspeed.cc
+68
-67
No files found.
src/wmspeed.cc
View file @
8941a7a3
...
...
@@ -133,73 +133,6 @@ public:
}
};
static
double
speed_scan
(
ThreadPool
&
thread_pool
,
double
clip_location
,
const
WavData
&
in_data
,
const
SpeedScanParams
&
scan_params
,
double
speed
,
bool
print_results
)
{
/* speed is between 0.8 and 1.25, so we use a clip seconds factor of 1.3 to provide enough samples */
WavData
in_clip
=
get_speed_clip
(
clip_location
,
in_data
,
scan_params
.
seconds
*
1.3
);
auto
t0
=
get_time
();
vector
<
std
::
unique_ptr
<
SpeedSync
>>
speed_sync
;
for
(
int
c
=
-
scan_params
.
n_center_steps
;
c
<=
scan_params
.
n_center_steps
;
c
++
)
{
double
c_speed
=
speed
*
pow
(
scan_params
.
step
,
c
*
(
scan_params
.
n_steps
*
2
+
1
));
speed_sync
.
push_back
(
std
::
make_unique
<
SpeedSync
>
(
in_clip
,
scan_params
,
c_speed
));
}
for
(
auto
&
s
:
speed_sync
)
s
->
start_prepare_job
(
thread_pool
);
thread_pool
.
wait_all
();
auto
t1
=
get_time
();
for
(
auto
&
s
:
speed_sync
)
s
->
start_search_jobs
(
thread_pool
);
thread_pool
.
wait_all
();
auto
t2
=
get_time
();
vector
<
SpeedSync
::
Score
>
scores
;
for
(
auto
&
s
:
speed_sync
)
{
vector
<
SpeedSync
::
Score
>
step_scores
=
s
->
get_scores
();
scores
.
insert
(
scores
.
end
(),
step_scores
.
begin
(),
step_scores
.
end
());
}
/* output best result, or: if there is not a unique best result, average all best results */
double
best_quality
=
0
;
for
(
auto
score
:
scores
)
best_quality
=
max
(
best_quality
,
score
.
quality
);
double
best_speed
=
0
;
int
speed_count
=
0
;
for
(
auto
score
:
scores
)
{
const
double
factor
=
0.99
;
/* all matches which are closer than this are considered relevant */
if
(
score
.
quality
>=
best_quality
*
factor
)
{
best_speed
+=
score
.
speed
;
speed_count
++
;
}
}
if
(
speed_count
)
best_speed
/=
speed_count
;
if
(
print_results
)
{
printf
(
"detect_speed %.0f %f %f %f %.3f %.3f
\n
"
,
scan_params
.
seconds
,
best_speed
,
best_quality
,
100
*
fabs
(
best_speed
-
Params
::
detect_speed_hint
)
/
Params
::
detect_speed_hint
,
t1
-
t0
,
t2
-
t1
);
}
return
best_speed
;
}
/* FIXME: is this the best choice */
inline
double
...
...
@@ -371,6 +304,74 @@ SpeedSync::compare (double relative_speed)
result_scores
.
push_back
(
best_score
);
}
static
double
speed_scan
(
ThreadPool
&
thread_pool
,
double
clip_location
,
const
WavData
&
in_data
,
const
SpeedScanParams
&
scan_params
,
double
speed
,
bool
print_results
)
{
/* speed is between 0.8 and 1.25, so we use a clip seconds factor of 1.3 to provide enough samples */
WavData
in_clip
=
get_speed_clip
(
clip_location
,
in_data
,
scan_params
.
seconds
*
1.3
);
auto
t0
=
get_time
();
vector
<
std
::
unique_ptr
<
SpeedSync
>>
speed_sync
;
for
(
int
c
=
-
scan_params
.
n_center_steps
;
c
<=
scan_params
.
n_center_steps
;
c
++
)
{
double
c_speed
=
speed
*
pow
(
scan_params
.
step
,
c
*
(
scan_params
.
n_steps
*
2
+
1
));
speed_sync
.
push_back
(
std
::
make_unique
<
SpeedSync
>
(
in_clip
,
scan_params
,
c_speed
));
}
for
(
auto
&
s
:
speed_sync
)
s
->
start_prepare_job
(
thread_pool
);
thread_pool
.
wait_all
();
auto
t1
=
get_time
();
for
(
auto
&
s
:
speed_sync
)
s
->
start_search_jobs
(
thread_pool
);
thread_pool
.
wait_all
();
auto
t2
=
get_time
();
vector
<
SpeedSync
::
Score
>
scores
;
for
(
auto
&
s
:
speed_sync
)
{
vector
<
SpeedSync
::
Score
>
step_scores
=
s
->
get_scores
();
scores
.
insert
(
scores
.
end
(),
step_scores
.
begin
(),
step_scores
.
end
());
}
/* output best result, or: if there is not a unique best result, average all best results */
double
best_quality
=
0
;
for
(
auto
score
:
scores
)
best_quality
=
max
(
best_quality
,
score
.
quality
);
double
best_speed
=
0
;
int
speed_count
=
0
;
for
(
auto
score
:
scores
)
{
const
double
factor
=
0.99
;
/* all matches which are closer than this are considered relevant */
if
(
score
.
quality
>=
best_quality
*
factor
)
{
best_speed
+=
score
.
speed
;
speed_count
++
;
}
}
if
(
speed_count
)
best_speed
/=
speed_count
;
if
(
print_results
)
{
printf
(
"detect_speed %.0f %f %f %f %.3f %.3f
\n
"
,
scan_params
.
seconds
,
best_speed
,
best_quality
,
100
*
fabs
(
best_speed
-
Params
::
detect_speed_hint
)
/
Params
::
detect_speed_hint
,
t1
-
t0
,
t2
-
t1
);
}
return
best_speed
;
}
static
double
get_clip_location
(
const
WavData
&
in_data
)
{
...
...
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