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
a2f35b32
Commit
a2f35b32
authored
Dec 13, 2019
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reorder open in/out and info messages.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
53186bd1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
23 deletions
+32
-23
wmadd.cc
src/wmadd.cc
+32
-23
No files found.
src/wmadd.cc
View file @
a2f35b32
...
...
@@ -580,19 +580,11 @@ add_watermark (const string& infile, const string& outfile, const string& bits)
expanded_bitvec
.
push_back
(
bitvec
[
i
%
bitvec
.
size
()]);
bitvec
=
expanded_bitvec
;
}
info
(
"Input: %s
\n
"
,
infile
.
c_str
());
if
(
Params
::
input_format
==
Format
::
RAW
)
info_format
(
"Raw Input"
,
Params
::
raw_input_format
);
info
(
"Output: %s
\n
"
,
outfile
.
c_str
());
if
(
Params
::
output_format
==
Format
::
RAW
)
info_format
(
"Raw Output"
,
Params
::
raw_output_format
);
info
(
"Message: %s
\n
"
,
bit_vec_to_str
(
bitvec
).
c_str
());
info
(
"Strength: %.6g
\n\n
"
,
Params
::
water_delta
*
1000
);
/* add forward error correction, bitvec will now be a lot larger */
auto
bitvec_a
=
randomize_bit_order
(
conv_encode
(
ConvBlockType
::
a
,
bitvec
),
/* encode */
true
);
auto
bitvec_b
=
randomize_bit_order
(
conv_encode
(
ConvBlockType
::
b
,
bitvec
),
/* encode */
true
);
/* open input stream */
Error
err
;
std
::
unique_ptr
<
AudioInputStream
>
in_stream
=
AudioInputStream
::
create
(
infile
,
err
);
if
(
err
)
...
...
@@ -600,18 +592,8 @@ add_watermark (const string& infile, const string& outfile, const string& bits)
error
(
"audiowmark: error opening %s: %s
\n
"
,
infile
.
c_str
(),
err
.
message
());
return
1
;
}
if
(
in_stream
->
n_frames
()
==
AudioInputStream
::
N_FRAMES_UNKNOWN
)
{
info
(
"Time: unknown
\n
"
);
}
else
{
int
orig_seconds
=
in_stream
->
n_frames
()
/
in_stream
->
sample_rate
();
info
(
"Time: %d:%02d
\n
"
,
orig_seconds
/
60
,
orig_seconds
%
60
);
}
info
(
"Sample Rate: %d
\n
"
,
in_stream
->
sample_rate
());
info
(
"Channels: %d
\n
"
,
in_stream
->
n_channels
());
/* open output stream */
const
int
out_bit_depth
=
in_stream
->
bit_depth
()
>
16
?
24
:
16
;
std
::
unique_ptr
<
AudioOutputStream
>
out_stream
;
out_stream
=
AudioOutputStream
::
create
(
outfile
,
in_stream
->
n_channels
(),
in_stream
->
sample_rate
(),
out_bit_depth
,
in_stream
->
n_frames
(),
err
);
...
...
@@ -621,11 +603,40 @@ add_watermark (const string& infile, const string& outfile, const string& bits)
return
1
;
}
if
(
out_stream
->
sample_rate
()
!=
in_stream
->
sample_rate
())
/* sanity checks */
if
(
in_stream
->
sample_rate
()
!=
out_stream
->
sample_rate
())
{
error
(
"audiowmark: input sample rate (%d) and output sample rate (%d) don't match
\n
"
,
in_stream
->
sample_rate
(),
out_stream
->
sample_rate
());
return
1
;
}
if
(
in_stream
->
n_channels
()
!=
out_stream
->
n_channels
())
{
error
(
"audiowmark: input channels (%d) and output channels (%d) don't match
\n
"
,
in_stream
->
n_channels
(),
out_stream
->
n_channels
());
return
1
;
}
/* write some informational messages */
info
(
"Input: %s
\n
"
,
infile
.
c_str
());
if
(
Params
::
input_format
==
Format
::
RAW
)
info_format
(
"Raw Input"
,
Params
::
raw_input_format
);
info
(
"Output: %s
\n
"
,
outfile
.
c_str
());
if
(
Params
::
output_format
==
Format
::
RAW
)
info_format
(
"Raw Output"
,
Params
::
raw_output_format
);
info
(
"Message: %s
\n
"
,
bit_vec_to_str
(
bitvec
).
c_str
());
info
(
"Strength: %.6g
\n\n
"
,
Params
::
water_delta
*
1000
);
if
(
in_stream
->
n_frames
()
==
AudioInputStream
::
N_FRAMES_UNKNOWN
)
{
info
(
"Time: unknown
\n
"
);
}
else
{
int
orig_seconds
=
in_stream
->
n_frames
()
/
in_stream
->
sample_rate
();
info
(
"Time: %d:%02d
\n
"
,
orig_seconds
/
60
,
orig_seconds
%
60
);
}
info
(
"Sample Rate: %d
\n
"
,
in_stream
->
sample_rate
());
info
(
"Channels: %d
\n
"
,
in_stream
->
n_channels
());
vector
<
float
>
samples
;
const
int
n_channels
=
in_stream
->
n_channels
();
...
...
@@ -642,8 +653,6 @@ add_watermark (const string& infile, const string& outfile, const string& bits)
size_t
total_output_frames
=
0
;
while
(
true
)
{
Error
err
=
Error
::
Code
::
NONE
;
err
=
in_stream
->
read_frames
(
samples
,
Params
::
frame_size
);
if
(
err
)
{
...
...
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