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
3c314c27
Commit
3c314c27
authored
Jun 03, 2020
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for shortcode.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
6be13df3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
99 additions
and
7 deletions
+99
-7
Makefile.am
src/Makefile.am
+4
-1
shortcode.cc
src/shortcode.cc
+16
-6
shortcode.hh
src/shortcode.hh
+3
-0
testshortcode.cc
src/testshortcode.cc
+76
-0
No files found.
src/Makefile.am
View file @
3c314c27
...
...
@@ -11,7 +11,7 @@ COMMON_LIBS = $(SNDFILE_LIBS) $(FFTW_LIBS) $(LIBGCRYPT_LIBS) $(LIBMPG123_LIBS)
audiowmark_SOURCES
=
audiowmark.cc wmget.cc wmadd.cc
$(COMMON_SRC)
audiowmark_LDFLAGS
=
$(COMMON_LIBS)
noinst_PROGRAMS
=
testconvcode testrandom testmp3 teststream testlimiter
noinst_PROGRAMS
=
testconvcode testrandom testmp3 teststream testlimiter
testshortcode
testconvcode_SOURCES
=
testconvcode.cc
$(COMMON_SRC)
testconvcode_LDFLAGS
=
$(COMMON_LIBS)
...
...
@@ -27,3 +27,6 @@ teststream_LDFLAGS = $(COMMON_LIBS)
testlimiter_SOURCES
=
testlimiter.cc
$(COMMON_SRC)
testlimiter_LDFLAGS
=
$(COMMON_LIBS)
testshortcode_SOURCES
=
testshortcode.cc
$(COMMON_SRC)
testshortcode_LDFLAGS
=
$(COMMON_LIBS)
src/shortcode.cc
View file @
3c314c27
...
...
@@ -87,7 +87,7 @@ code_decode_soft (ConvBlockType block_type, const std::vector<float>& coded_bits
}
vector
<
int
>
short_encode
(
ConvBlockType
block_type
,
const
vector
<
int
>&
in_bits
)
short_encode
_blk
(
const
vector
<
int
>&
in_bits
)
{
assert
(
gen_matrix
.
size
()
==
in_bits
.
size
());
...
...
@@ -104,7 +104,13 @@ short_encode (ConvBlockType block_type, const vector<int>& in_bits)
}
out_bits
.
push_back
(
x
);
}
return
conv_encode
(
block_type
,
out_bits
);
return
out_bits
;
}
vector
<
int
>
short_encode
(
ConvBlockType
block_type
,
const
vector
<
int
>&
in_bits
)
{
return
conv_encode
(
block_type
,
short_encode_blk
(
in_bits
));
}
size_t
...
...
@@ -116,10 +122,8 @@ short_code_size (ConvBlockType block_type, size_t msg_size)
}
vector
<
int
>
short_decode_
soft
(
ConvBlockType
block_type
,
const
std
::
vector
<
float
>&
coded_bits
,
float
*
error_out
)
short_decode_
blk
(
const
vector
<
int
>&
coded_bits
)
{
vector
<
int
>
xbits
=
conv_decode_soft
(
block_type
,
coded_bits
,
error_out
);
vector
<
int
>
out_bits
;
for
(
size_t
c
=
0
;
c
<
(
1
<<
gen_in_count
);
c
++
)
{
...
...
@@ -136,7 +140,7 @@ short_decode_soft (ConvBlockType block_type, const std::vector<float>& coded_bit
}
w
.
push_back
(
x
);
}
if
(
w
==
x
bits
)
if
(
w
==
coded_
bits
)
{
for
(
size_t
bit
=
0
;
bit
<
gen_in_count
;
bit
++
)
{
...
...
@@ -155,3 +159,9 @@ short_decode_soft (ConvBlockType block_type, const std::vector<float>& coded_bit
return
out_bits
;
}
vector
<
int
>
short_decode_soft
(
ConvBlockType
block_type
,
const
std
::
vector
<
float
>&
coded_bits
,
float
*
error_out
)
{
return
short_decode_blk
(
conv_decode_soft
(
block_type
,
coded_bits
,
error_out
));
}
src/shortcode.hh
View file @
3c314c27
...
...
@@ -31,4 +31,7 @@ size_t short_code_size (ConvBlockType block_type, size_t msg_size);
std
::
vector
<
int
>
short_encode
(
ConvBlockType
block_type
,
const
std
::
vector
<
int
>&
in_bits
);
std
::
vector
<
int
>
short_decode_soft
(
ConvBlockType
block_type
,
const
std
::
vector
<
float
>&
coded_bits
,
float
*
error_out
=
nullptr
);
std
::
vector
<
int
>
short_encode_blk
(
const
std
::
vector
<
int
>&
in_bits
);
std
::
vector
<
int
>
short_decode_blk
(
const
std
::
vector
<
int
>&
coded_bits
);
#endif
/* AUDIOWMARK_SHORT_CODE_HH */
src/testshortcode.cc
0 → 100644
View file @
3c314c27
/*
* Copyright (C) 2018-2020 Stefan Westerfeld
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <vector>
#include <sys/time.h>
#include <assert.h>
#include "shortcode.hh"
using
std
::
vector
;
using
std
::
string
;
static
double
gettime
()
{
timeval
tv
;
gettimeofday
(
&
tv
,
0
);
return
tv
.
tv_sec
+
tv
.
tv_usec
/
1000000.0
;
}
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
==
1
)
{
vector
<
int
>
in_bits
=
{
1
,
0
,
1
,
0
,
1
,
1
,
0
,
0
,
1
,
1
,
1
,
1
,
0
,
0
,
0
,
0
};
printf
(
"in: "
);
for
(
auto
b
:
in_bits
)
printf
(
"%d"
,
b
);
printf
(
"
\n
"
);
printf
(
"coded: "
);
vector
<
int
>
coded_bits
=
short_encode_blk
(
in_bits
);
for
(
auto
b
:
coded_bits
)
printf
(
"%d"
,
b
);
printf
(
"
\n
"
);
vector
<
int
>
decoded_bits
=
short_decode_blk
(
coded_bits
);
printf
(
"out: "
);
for
(
auto
b
:
decoded_bits
)
printf
(
"%d"
,
b
);
printf
(
"
\n
"
);
}
if
(
argc
==
2
&&
string
(
argv
[
1
])
==
"perf"
)
{
vector
<
int
>
in_bits
;
while
(
in_bits
.
size
()
!=
16
)
in_bits
.
push_back
(
rand
()
&
1
);
const
double
start_t
=
gettime
();
const
size_t
runs
=
20
;
for
(
size_t
i
=
0
;
i
<
runs
;
i
++
)
{
vector
<
int
>
out_bits
=
short_decode_blk
(
short_encode_blk
(
in_bits
));
assert
(
out_bits
==
in_bits
);
}
printf
(
"%.1f ms/block
\n
"
,
(
gettime
()
-
start_t
)
/
runs
*
1000.0
);
}
}
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