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
07fd966c
Commit
07fd966c
authored
Mar 15, 2020
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use SyncFinder::Mode instead of SyncFinder::BlockLength for clarity.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
ee975505
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
wmget.cc
src/wmget.cc
+10
-10
No files found.
src/wmget.cc
View file @
07fd966c
...
@@ -198,7 +198,7 @@ normalize_sync_quality (double raw_quality)
...
@@ -198,7 +198,7 @@ normalize_sync_quality (double raw_quality)
class
SyncFinder
class
SyncFinder
{
{
public
:
public
:
enum
class
BlockLength
{
NORMAL
,
LONG
};
enum
class
Mode
{
BLOCK
,
CLIP
};
private
:
private
:
struct
FrameBit
struct
FrameBit
...
@@ -210,14 +210,14 @@ private:
...
@@ -210,14 +210,14 @@ private:
vector
<
vector
<
FrameBit
>>
sync_bits
;
vector
<
vector
<
FrameBit
>>
sync_bits
;
void
void
init_up_down
(
const
WavData
&
wav_data
,
BlockLength
block_length
)
init_up_down
(
const
WavData
&
wav_data
,
Mode
mode
)
{
{
sync_bits
.
clear
();
sync_bits
.
clear
();
// "long" blocks consist of two "normal" blocks, which means
// "long" blocks consist of two "normal" blocks, which means
// the sync bits pattern is repeated after the end of the first block
// the sync bits pattern is repeated after the end of the first block
const
int
first_block_end
=
mark_sync_frame_count
()
+
mark_data_frame_count
();
const
int
first_block_end
=
mark_sync_frame_count
()
+
mark_data_frame_count
();
const
int
block_count
=
block_length
==
BlockLength
::
LONG
?
2
:
1
;
const
int
block_count
=
mode
==
Mode
::
CLIP
?
2
:
1
;
size_t
n_bands
=
Params
::
max_band
-
Params
::
min_band
+
1
;
size_t
n_bands
=
Params
::
max_band
-
Params
::
min_band
+
1
;
UpDownGen
up_down_gen
(
Random
::
Stream
::
sync_up_down
);
UpDownGen
up_down_gen
(
Random
::
Stream
::
sync_up_down
);
...
@@ -355,7 +355,7 @@ public:
...
@@ -355,7 +355,7 @@ public:
ConvBlockType
block_type
;
ConvBlockType
block_type
;
};
};
vector
<
Score
>
vector
<
Score
>
search
(
const
WavData
&
wav_data
,
BlockLength
block_length
)
search
(
const
WavData
&
wav_data
,
Mode
mode
)
{
{
vector
<
Score
>
result_scores
;
vector
<
Score
>
result_scores
;
vector
<
Score
>
sync_scores
;
vector
<
Score
>
sync_scores
;
...
@@ -372,7 +372,7 @@ public:
...
@@ -372,7 +372,7 @@ public:
return
result_scores
;
return
result_scores
;
}
}
init_up_down
(
wav_data
,
block_length
);
init_up_down
(
wav_data
,
mode
);
scan_silence
(
wav_data
);
scan_silence
(
wav_data
);
vector
<
float
>
fft_db
;
vector
<
float
>
fft_db
;
...
@@ -382,7 +382,7 @@ public:
...
@@ -382,7 +382,7 @@ public:
size_t
n_bands
=
Params
::
max_band
-
Params
::
min_band
+
1
;
size_t
n_bands
=
Params
::
max_band
-
Params
::
min_band
+
1
;
int
total_frame_count
=
mark_sync_frame_count
()
+
mark_data_frame_count
();
int
total_frame_count
=
mark_sync_frame_count
()
+
mark_data_frame_count
();
const
int
first_block_end
=
total_frame_count
;
const
int
first_block_end
=
total_frame_count
;
if
(
block_length
==
BlockLength
::
LONG
)
if
(
mode
==
Mode
::
CLIP
)
total_frame_count
*=
2
;
total_frame_count
*=
2
;
for
(
size_t
sync_shift
=
0
;
sync_shift
<
Params
::
frame_size
;
sync_shift
+=
Params
::
sync_search_step
)
for
(
size_t
sync_shift
=
0
;
sync_shift
<
Params
::
frame_size
;
sync_shift
+=
Params
::
sync_search_step
)
{
{
...
@@ -405,7 +405,7 @@ public:
...
@@ -405,7 +405,7 @@ public:
for
(
size_t
f
=
0
;
f
<
mark_sync_frame_count
();
f
++
)
for
(
size_t
f
=
0
;
f
<
mark_sync_frame_count
();
f
++
)
{
{
want_frames
[
sync_frame_pos
(
f
)]
=
1
;
want_frames
[
sync_frame_pos
(
f
)]
=
1
;
if
(
block_length
==
BlockLength
::
LONG
)
if
(
mode
==
Mode
::
CLIP
)
want_frames
[
first_block_end
+
sync_frame_pos
(
f
)]
=
1
;
want_frames
[
first_block_end
+
sync_frame_pos
(
f
)]
=
1
;
}
}
...
@@ -442,7 +442,7 @@ public:
...
@@ -442,7 +442,7 @@ public:
}
}
}
}
}
}
if
(
block_length
==
BlockLength
::
LONG
)
if
(
mode
==
Mode
::
CLIP
)
{
{
std
::
sort
(
n_best
.
begin
(),
n_best
.
end
(),
[](
NBest
&
nb1
,
NBest
&
nb2
)
{
return
nb1
.
quality
>
nb2
.
quality
;
});
std
::
sort
(
n_best
.
begin
(),
n_best
.
end
(),
[](
NBest
&
nb1
,
NBest
&
nb2
)
{
return
nb1
.
quality
>
nb2
.
quality
;
});
if
(
n_best
.
size
()
>
5
)
if
(
n_best
.
size
()
>
5
)
...
@@ -661,7 +661,7 @@ public:
...
@@ -661,7 +661,7 @@ public:
int
total_count
=
0
;
int
total_count
=
0
;
SyncFinder
sync_finder
;
SyncFinder
sync_finder
;
sync_scores
=
sync_finder
.
search
(
wav_data
,
SyncFinder
::
BlockLength
::
NORMAL
);
sync_scores
=
sync_finder
.
search
(
wav_data
,
SyncFinder
::
Mode
::
BLOCK
);
vector
<
float
>
raw_bit_vec_all
(
conv_code_size
(
ConvBlockType
::
ab
,
Params
::
payload_size
));
vector
<
float
>
raw_bit_vec_all
(
conv_code_size
(
ConvBlockType
::
ab
,
Params
::
payload_size
));
vector
<
int
>
raw_bit_vec_norm
(
2
);
vector
<
int
>
raw_bit_vec_norm
(
2
);
...
@@ -791,7 +791,7 @@ class ClipDecoder
...
@@ -791,7 +791,7 @@ class ClipDecoder
run_padded
(
const
WavData
&
wav_data
,
ResultSet
&
result_set
,
double
time_offset_sec
)
run_padded
(
const
WavData
&
wav_data
,
ResultSet
&
result_set
,
double
time_offset_sec
)
{
{
SyncFinder
sync_finder
;
SyncFinder
sync_finder
;
vector
<
SyncFinder
::
Score
>
sync_scores
=
sync_finder
.
search
(
wav_data
,
SyncFinder
::
BlockLength
::
LONG
);
vector
<
SyncFinder
::
Score
>
sync_scores
=
sync_finder
.
search
(
wav_data
,
SyncFinder
::
Mode
::
CLIP
);
FFTAnalyzer
fft_analyzer
(
wav_data
.
n_channels
());
FFTAnalyzer
fft_analyzer
(
wav_data
.
n_channels
());
for
(
auto
sync_score
:
sync_scores
)
for
(
auto
sync_score
:
sync_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