Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
7cb803ad
Commit
7cb803ad
authored
Oct 19, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test/test_pcm: use C++11 random instead of GLib
parent
8e063829
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
20 deletions
+28
-20
test_pcm_dither.cxx
test/test_pcm_dither.cxx
+1
-1
test_pcm_mix.cxx
test/test_pcm_mix.cxx
+2
-2
test_pcm_pack.cxx
test/test_pcm_pack.cxx
+1
-3
test_pcm_util.hxx
test/test_pcm_util.hxx
+22
-12
test_pcm_volume.cxx
test/test_pcm_volume.cxx
+2
-2
No files found.
test/test_pcm_dither.cxx
View file @
7cb803ad
...
...
@@ -25,7 +25,7 @@ void
PcmDitherTest
::
TestDither24
()
{
constexpr
unsigned
N
=
256
;
const
auto
src
=
TestDataBuffer
<
int32_t
,
N
>
(
Glib
RandomInt24
());
const
auto
src
=
TestDataBuffer
<
int32_t
,
N
>
(
RandomInt24
());
int16_t
dest
[
N
];
PcmDither
dither
;
...
...
test/test_pcm_mix.cxx
View file @
7cb803ad
...
...
@@ -22,7 +22,7 @@
#include "test_pcm_util.hxx"
#include "pcm/PcmMix.hxx"
template
<
typename
T
,
SampleFormat
format
,
typename
G
=
Glib
RandomInt
<
T
>>
template
<
typename
T
,
SampleFormat
format
,
typename
G
=
RandomInt
<
T
>>
static
void
TestPcmMix
(
G
g
=
G
())
{
...
...
@@ -72,7 +72,7 @@ PcmMixTest::TestMix16()
void
PcmMixTest
::
TestMix24
()
{
TestPcmMix
<
int32_t
,
SampleFormat
::
S24_P32
>
(
Glib
RandomInt24
());
TestPcmMix
<
int32_t
,
SampleFormat
::
S24_P32
>
(
RandomInt24
());
}
void
...
...
test/test_pcm_pack.cxx
View file @
7cb803ad
...
...
@@ -22,13 +22,11 @@
#include "pcm/PcmPack.hxx"
#include "system/ByteOrder.hxx"
#include <glib.h>
void
PcmPackTest
::
TestPack24
()
{
constexpr
unsigned
N
=
256
;
const
auto
src
=
TestDataBuffer
<
int32_t
,
N
>
(
Glib
RandomInt24
());
const
auto
src
=
TestDataBuffer
<
int32_t
,
N
>
(
RandomInt24
());
uint8_t
dest
[
N
*
3
];
pcm_pack_24
(
dest
,
src
.
begin
(),
src
.
end
());
...
...
test/test_pcm_util.hxx
View file @
7cb803ad
...
...
@@ -17,23 +17,28 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <glib.h>
#include <array>
#include <random>
#include <stddef.h>
#include <stdint.h>
template
<
typename
T
>
struct
GlibRandomInt
{
T
operator
()()
const
{
return
T
(
g_random_int
());
struct
RandomInt
{
typedef
std
::
minstd_rand
Engine
;
Engine
engine
;
static_assert
(
sizeof
(
T
)
<=
sizeof
(
Engine
::
result_type
),
"RNG result type too small"
);
T
operator
()()
{
return
T
(
random
());
}
};
struct
GlibRandomInt24
:
Glib
RandomInt
<
int32_t
>
{
int32_t
operator
()()
const
{
auto
t
=
Glib
RandomInt
::
operator
()();
struct
RandomInt24
:
RandomInt
<
int32_t
>
{
int32_t
operator
()()
{
auto
t
=
RandomInt
::
operator
()();
t
&=
0xffffff
;
if
(
t
&
0x800000
)
t
|=
0xff000000
;
...
...
@@ -41,9 +46,14 @@ struct GlibRandomInt24 : GlibRandomInt<int32_t> {
}
};
struct
GlibRandomFloat
{
float
operator
()()
const
{
return
g_random_double_range
(
-
1.0
,
1.0
);
struct
RandomFloat
{
std
::
mt19937
gen
;
std
::
uniform_real_distribution
<
float
>
dis
;
RandomFloat
()
:
gen
(
std
::
random_device
()()),
dis
(
-
1.0
,
1.0
)
{}
float
operator
()()
{
return
dis
(
gen
);
}
};
...
...
@@ -56,7 +66,7 @@ public:
using
std
::
array
<
T
,
N
>::
end
;
using
std
::
array
<
T
,
N
>::
operator
[];
template
<
typename
G
=
Glib
RandomInt
<
T
>>
template
<
typename
G
=
RandomInt
<
T
>>
TestDataBuffer
(
G
g
=
G
())
:
std
::
array
<
T
,
N
>
()
{
for
(
auto
&
i
:
*
this
)
i
=
g
();
...
...
test/test_pcm_volume.cxx
View file @
7cb803ad
...
...
@@ -94,7 +94,7 @@ PcmVolumeTest::TestVolume24()
{
constexpr
unsigned
N
=
256
;
static
int32_t
zero
[
N
];
const
auto
src
=
TestDataBuffer
<
int32_t
,
N
>
(
Glib
RandomInt24
());
const
auto
src
=
TestDataBuffer
<
int32_t
,
N
>
(
RandomInt24
());
int32_t
dest
[
N
];
...
...
@@ -158,7 +158,7 @@ PcmVolumeTest::TestVolumeFloat()
{
constexpr
unsigned
N
=
256
;
static
float
zero
[
N
];
const
auto
src
=
TestDataBuffer
<
float
,
N
>
(
Glib
RandomFloat
());
const
auto
src
=
TestDataBuffer
<
float
,
N
>
(
RandomFloat
());
float
dest
[
N
];
...
...
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