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
36378658
Commit
36378658
authored
Dec 11, 2019
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid fprintf() for error reporting, use error() instead.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
e342441e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
27 deletions
+27
-27
audiowmark.cc
src/audiowmark.cc
+9
-9
mp3.cc
src/mp3.cc
+1
-1
random.cc
src/random.cc
+9
-9
wmadd.cc
src/wmadd.cc
+6
-6
wmget.cc
src/wmget.cc
+2
-2
No files found.
src/audiowmark.cc
View file @
36378658
...
...
@@ -284,7 +284,7 @@ gentest (const string& infile, const string& outfile)
Error
err
=
wav_data
.
load
(
infile
);
if
(
err
)
{
fprintf
(
stderr
,
"audiowmark: error loading %s: %s
\n
"
,
infile
.
c_str
(),
err
.
message
());
error
(
"audiowmark: error loading %s: %s
\n
"
,
infile
.
c_str
(),
err
.
message
());
return
1
;
}
const
vector
<
float
>&
in_signal
=
wav_data
.
samples
();
...
...
@@ -296,7 +296,7 @@ gentest (const string& infile, const string& outfile)
const
size_t
n_samples
=
165
*
wav_data
.
n_channels
()
*
wav_data
.
sample_rate
();
if
(
in_signal
.
size
()
<
(
offset
+
n_samples
))
{
fprintf
(
stderr
,
"audiowmark: input file %s too short
\n
"
,
infile
.
c_str
());
error
(
"audiowmark: input file %s too short
\n
"
,
infile
.
c_str
());
return
1
;
}
for
(
size_t
i
=
0
;
i
<
n_samples
;
i
++
)
...
...
@@ -307,7 +307,7 @@ gentest (const string& infile, const string& outfile)
err
=
out_wav_data
.
save
(
outfile
);
if
(
err
)
{
fprintf
(
stderr
,
"audiowmark: error saving %s: %s
\n
"
,
outfile
.
c_str
(),
err
.
message
());
error
(
"audiowmark: error saving %s: %s
\n
"
,
outfile
.
c_str
(),
err
.
message
());
return
1
;
}
return
0
;
...
...
@@ -320,7 +320,7 @@ cut_start (const string& infile, const string& outfile, const string& start_str)
Error
err
=
wav_data
.
load
(
infile
);
if
(
err
)
{
fprintf
(
stderr
,
"audiowmark: error loading %s: %s
\n
"
,
infile
.
c_str
(),
err
.
message
());
error
(
"audiowmark: error loading %s: %s
\n
"
,
infile
.
c_str
(),
err
.
message
());
return
1
;
}
...
...
@@ -335,7 +335,7 @@ cut_start (const string& infile, const string& outfile, const string& start_str)
err
=
out_wav_data
.
save
(
outfile
);
if
(
err
)
{
fprintf
(
stderr
,
"audiowmark: error saving %s: %s
\n
"
,
outfile
.
c_str
(),
err
.
message
());
error
(
"audiowmark: error saving %s: %s
\n
"
,
outfile
.
c_str
(),
err
.
message
());
return
1
;
}
return
0
;
...
...
@@ -380,7 +380,7 @@ test_subtract (const string& infile1, const string& infile2, const string& outfi
err
=
out_wav_data
.
save
(
outfile
);
if
(
err
)
{
fprintf
(
stderr
,
"audiowmark: error saving %s: %s
\n
"
,
outfile
.
c_str
(),
err
.
message
());
error
(
"audiowmark: error saving %s: %s
\n
"
,
outfile
.
c_str
(),
err
.
message
());
return
1
;
}
return
0
;
...
...
@@ -392,7 +392,7 @@ gen_key (const string& outfile)
FILE
*
f
=
fopen
(
outfile
.
c_str
(),
"w"
);
if
(
!
f
)
{
fprintf
(
stderr
,
"audiowmark: error writing to file %s
\n
"
,
outfile
.
c_str
());
error
(
"audiowmark: error writing to file %s
\n
"
,
outfile
.
c_str
());
return
1
;
}
fprintf
(
f
,
"# watermarking key for audiowmark
\n\n
key %s
\n
"
,
Random
::
gen_key
().
c_str
());
...
...
@@ -407,7 +407,7 @@ main (int argc, char **argv)
if
(
Params
::
have_key
>
1
)
{
fprintf
(
stderr
,
"audiowmark: watermark key can at most be set once (--key / --test-key option)
\n
"
);
error
(
"audiowmark: watermark key can at most be set once (--key / --test-key option)
\n
"
);
return
1
;
}
string
op
=
(
argc
>=
2
)
?
argv
[
1
]
:
""
;
...
...
@@ -442,7 +442,7 @@ main (int argc, char **argv)
}
else
{
fprintf
(
stderr
,
"audiowmark: error parsing commandline args (use audiowmark -h)
\n
"
);
error
(
"audiowmark: error parsing commandline args (use audiowmark -h)
\n
"
);
return
1
;
}
}
src/mp3.cc
View file @
36378658
...
...
@@ -32,7 +32,7 @@ mp3_init()
int
err
=
mpg123_init
();
if
(
err
!=
MPG123_OK
)
{
fprintf
(
stderr
,
"audiowmark: init mpg123 lib failed
\n
"
);
error
(
"audiowmark: init mpg123 lib failed
\n
"
);
exit
(
1
);
}
mpg123_init_ok
=
true
;
...
...
src/random.cc
View file @
36378658
...
...
@@ -20,7 +20,7 @@ gcrypt_init()
/* version check: start libgcrypt initialization */
if
(
!
gcry_check_version
(
GCRYPT_VERSION
))
{
fprintf
(
stderr
,
"audiowmark: libgcrypt version mismatch
\n
"
);
error
(
"audiowmark: libgcrypt version mismatch
\n
"
);
exit
(
1
);
}
...
...
@@ -144,11 +144,11 @@ Random::refill_buffer()
}
void
Random
::
die_on_error
(
const
char
*
func
,
gcry_error_t
err
or
)
Random
::
die_on_error
(
const
char
*
func
,
gcry_error_t
err
)
{
if
(
err
or
)
if
(
err
)
{
fprintf
(
stderr
,
"%s failed: %s/%s
\n
"
,
func
,
gcry_strsource
(
error
),
gcry_strerror
(
erro
r
));
error
(
"%s failed: %s/%s
\n
"
,
func
,
gcry_strsource
(
err
),
gcry_strerror
(
er
r
));
exit
(
1
);
/* can't recover here */
}
...
...
@@ -166,7 +166,7 @@ Random::load_global_key (const string& key_file)
FILE
*
f
=
fopen
(
key_file
.
c_str
(),
"r"
);
if
(
!
f
)
{
fprintf
(
stderr
,
"audiowmark: error opening key file: '%s'
\n
"
,
key_file
.
c_str
());
error
(
"audiowmark: error opening key file: '%s'
\n
"
,
key_file
.
c_str
());
exit
(
1
);
}
...
...
@@ -191,7 +191,7 @@ Random::load_global_key (const string& key_file)
vector
<
unsigned
char
>
key
=
hex_str_to_vec
(
match
[
1
].
str
());
if
(
key
.
size
()
!=
aes_key
.
size
())
{
fprintf
(
stderr
,
"audiowmark: wrong key length in key file '%s', line %d
\n
=> required key length is %zd bits
\n
"
,
key_file
.
c_str
(),
line
,
aes_key
.
size
()
*
8
);
error
(
"audiowmark: wrong key length in key file '%s', line %d
\n
=> required key length is %zd bits
\n
"
,
key_file
.
c_str
(),
line
,
aes_key
.
size
()
*
8
);
exit
(
1
);
}
aes_key
=
key
;
...
...
@@ -199,7 +199,7 @@ Random::load_global_key (const string& key_file)
}
else
{
fprintf
(
stderr
,
"audiowmark: parse error in key file '%s', line %d
\n
"
,
key_file
.
c_str
(),
line
);
error
(
"audiowmark: parse error in key file '%s', line %d
\n
"
,
key_file
.
c_str
(),
line
);
exit
(
1
);
}
line
++
;
...
...
@@ -208,12 +208,12 @@ Random::load_global_key (const string& key_file)
if
(
keys
>
1
)
{
fprintf
(
stderr
,
"audiowmark: key file '%s' contains more than one key
\n
"
,
key_file
.
c_str
());
error
(
"audiowmark: key file '%s' contains more than one key
\n
"
,
key_file
.
c_str
());
exit
(
1
);
}
if
(
keys
==
0
)
{
fprintf
(
stderr
,
"audiowmark: key file '%s' contains no key
\n
"
,
key_file
.
c_str
());
error
(
"audiowmark: key file '%s' contains no key
\n
"
,
key_file
.
c_str
());
exit
(
1
);
}
}
...
...
src/wmadd.cc
View file @
36378658
...
...
@@ -549,12 +549,12 @@ add_watermark (const string& infile, const string& outfile, const string& bits)
auto
bitvec
=
bit_str_to_vec
(
bits
);
if
(
bitvec
.
empty
())
{
fprintf
(
stderr
,
"audiowmark: cannot parse bits %s
\n
"
,
bits
.
c_str
());
error
(
"audiowmark: cannot parse bits %s
\n
"
,
bits
.
c_str
());
return
1
;
}
if
(
bitvec
.
size
()
>
Params
::
payload_size
)
{
fprintf
(
stderr
,
"audiowmark: number of bits in message '%s' larger than payload size
\n
"
,
bits
.
c_str
());
error
(
"audiowmark: number of bits in message '%s' larger than payload size
\n
"
,
bits
.
c_str
());
return
1
;
}
if
(
bitvec
.
size
()
<
Params
::
payload_size
)
...
...
@@ -592,13 +592,13 @@ add_watermark (const string& infile, const string& outfile, const string& bits)
err
=
mistream
->
open
(
infile
);
if
(
err
)
{
fprintf
(
stderr
,
"audiowmark: error opening mp3 %s: %s
\n
"
,
infile
.
c_str
(),
err
.
message
());
error
(
"audiowmark: error opening mp3 %s: %s
\n
"
,
infile
.
c_str
(),
err
.
message
());
return
1
;
}
}
else
if
(
err
)
{
fprintf
(
stderr
,
"audiowmark: error opening %s: %s
\n
"
,
infile
.
c_str
(),
err
.
message
());
error
(
"audiowmark: error opening %s: %s
\n
"
,
infile
.
c_str
(),
err
.
message
());
return
1
;
}
}
...
...
@@ -609,7 +609,7 @@ add_watermark (const string& infile, const string& outfile, const string& bits)
Error
err
=
ristream
->
open
(
infile
,
Params
::
raw_input_format
);
if
(
err
)
{
fprintf
(
stderr
,
"audiowmark: error opening %s: %s
\n
"
,
infile
.
c_str
(),
err
.
message
());
error
(
"audiowmark: error opening %s: %s
\n
"
,
infile
.
c_str
(),
err
.
message
());
return
1
;
}
}
...
...
@@ -634,7 +634,7 @@ add_watermark (const string& infile, const string& outfile, const string& bits)
Error
err
=
rostream
->
open
(
outfile
,
Params
::
raw_output_format
);
if
(
err
)
{
fprintf
(
stderr
,
"audiowmark: error opening %s: %s
\n
"
,
outfile
.
c_str
(),
err
.
message
());
error
(
"audiowmark: error opening %s: %s
\n
"
,
outfile
.
c_str
(),
err
.
message
());
return
1
;
}
}
...
...
src/wmget.cc
View file @
36378658
...
...
@@ -74,7 +74,7 @@ resample (const WavData& wav_data, int rate)
process_resampler
(
vresampler
,
in
,
out
);
return
WavData
(
out
,
wav_data
.
n_channels
(),
rate
,
wav_data
.
bit_depth
());
}
fprintf
(
stderr
,
"audiowmark: resampling from rate %d to rate %d not supported.
\n
"
,
wav_data
.
sample_rate
(),
rate
);
error
(
"audiowmark: resampling from rate %d to rate %d not supported.
\n
"
,
wav_data
.
sample_rate
(),
rate
);
exit
(
1
);
}
...
...
@@ -607,7 +607,7 @@ get_watermark (const string& infile, const string& orig_pattern)
Error
err
=
wav_data
.
load
(
infile
);
if
(
err
)
{
fprintf
(
stderr
,
"audiowmark: error loading %s: %s
\n
"
,
infile
.
c_str
(),
err
.
message
());
error
(
"audiowmark: error loading %s: %s
\n
"
,
infile
.
c_str
(),
err
.
message
());
return
1
;
}
...
...
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