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
5a6230f7
Commit
5a6230f7
authored
Nov 28, 2018
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move FFT stuff to extra source file.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
c2d3e569
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
91 deletions
+2
-91
Makefile.am
src/Makefile.am
+1
-1
audiowmark.cc
src/audiowmark.cc
+1
-90
No files found.
src/Makefile.am
View file @
5a6230f7
bin_PROGRAMS
=
audiowmark
audiowmark_SOURCES
=
audiowmark.cc wavdata.cc
audiowmark_SOURCES
=
audiowmark.cc wavdata.cc
fft.cc
audiowmark_LDFLAGS
=
$(SNDFILE_LIBS)
$(FFTW_LIBS)
src/audiowmark.cc
View file @
5a6230f7
...
...
@@ -4,8 +4,7 @@
#include <random>
#include <complex>
#include <fftw3.h>
#include "fft.hh"
#include "wavdata.hh"
using
std
::
string
;
...
...
@@ -70,52 +69,6 @@ get_frame (WavData& wav_data, int f, int ch)
return
result
;
}
float
*
new_array_float
(
size_t
N
)
{
const
size_t
N_2
=
N
+
2
;
/* extra space for r2c extra complex output */
return
(
float
*
)
fftwf_malloc
(
sizeof
(
float
)
*
N_2
);
}
void
free_array_float
(
float
*
f
)
{
fftwf_free
(
f
);
}
void
fftar_float
(
size_t
N
,
float
*
in
,
float
*
out
)
{
static
fftwf_plan
plan
=
nullptr
;
// FIXME: should be one plan per fft size
if
(
!
plan
)
{
float
*
plan_in
=
new_array_float
(
N
);
float
*
plan_out
=
new_array_float
(
N
);
plan
=
fftwf_plan_dft_r2c_1d
(
N
,
plan_in
,
(
fftwf_complex
*
)
plan_out
,
FFTW_ESTIMATE
|
FFTW_PRESERVE_INPUT
);
// we add code for saving plans here, and use patient planning
}
fftwf_execute_dft_r2c
(
plan
,
in
,
(
fftwf_complex
*
)
out
);
}
void
fftsr_float
(
size_t
N
,
float
*
in
,
float
*
out
)
{
static
fftwf_plan
plan
=
nullptr
;
// FIXME: should be one plan per fft size
if
(
!
plan
)
{
float
*
plan_in
=
new_array_float
(
N
);
float
*
plan_out
=
new_array_float
(
N
);
plan
=
fftwf_plan_dft_c2r_1d
(
N
,
(
fftwf_complex
*
)
plan_in
,
plan_out
,
FFTW_ESTIMATE
|
FFTW_PRESERVE_INPUT
);
// we add code for saving plans here, and use patient planning
}
fftwf_execute_dft_c2r
(
plan
,
(
fftwf_complex
*
)
in
,
out
);
}
void
get_up_down
(
int
f
,
vector
<
int
>&
up
,
vector
<
int
>&
down
)
{
...
...
@@ -193,48 +146,6 @@ bit_vec_to_str (const vector<int>& bit_vec)
return
bit_str
;
}
vector
<
complex
<
float
>>
fft
(
const
vector
<
float
>&
in
)
{
vector
<
complex
<
float
>>
out
(
in
.
size
()
/
2
+
1
);
/* ensure memory is SSE-aligned (or other vectorized stuff) */
float
*
fft_in
=
new_array_float
(
in
.
size
());
float
*
fft_out
=
new_array_float
(
in
.
size
());
std
::
copy
(
in
.
begin
(),
in
.
end
(),
fft_in
);
fftar_float
(
in
.
size
(),
fft_in
,
fft_out
);
/* complex<float> vector and fft_out have the same layout in memory */
std
::
copy
(
fft_out
,
fft_out
+
out
.
size
()
*
2
,
reinterpret_cast
<
float
*>
(
&
out
[
0
]));
free_array_float
(
fft_out
);
free_array_float
(
fft_in
);
return
out
;
}
vector
<
float
>
ifft
(
const
vector
<
complex
<
float
>>&
in
)
{
vector
<
float
>
out
((
in
.
size
()
-
1
)
*
2
);
/* ensure memory is SSE-aligned (or other vectorized stuff) */
float
*
ifft_in
=
new_array_float
(
out
.
size
());
float
*
ifft_out
=
new_array_float
(
out
.
size
());
/* complex<float> vector and fft_out have the same layout in memory */
std
::
copy
(
in
.
begin
(),
in
.
end
(),
reinterpret_cast
<
complex
<
float
>
*>
(
ifft_in
));
fftsr_float
(
out
.
size
(),
ifft_in
,
ifft_out
);
std
::
copy
(
ifft_out
,
ifft_out
+
out
.
size
(),
&
out
[
0
]);
free_array_float
(
ifft_out
);
free_array_float
(
ifft_in
);
return
out
;
}
int
add_watermark
(
const
string
&
infile
,
const
string
&
outfile
,
const
string
&
bits
)
{
...
...
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