Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Xiph.Org
aom-rav1e
Commits
c7ca3808
Commit
c7ca3808
authored
May 09, 2012
by
Jim Bankoski
Committed by
Gerrit Code Review
May 09, 2012
Browse files
Options
Browse Files
Download
Plain Diff
Merge "vp8e - boolcoder unit test"
parents
f86993f1
9851486b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
131 additions
and
0 deletions
+131
-0
vp8/encoder/boolcoder_test.cc
vp8/encoder/boolcoder_test.cc
+129
-0
vp8/vp8cx.mk
vp8/vp8cx.mk
+2
-0
No files found.
vp8/encoder/boolcoder_test.cc
0 → 100644
View file @
c7ca3808
/*
* Copyright (c) 2012 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
extern
"C"
{
#include "vp8/encoder/boolhuff.h"
#include "vp8/decoder/dboolhuff.h"
}
#include <math.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include "third_party/googletest/src/include/gtest/gtest.h"
typedef
unsigned
char
uint8_t
;
namespace
{
const
int
num_tests
=
10
;
class
ACMRandom
{
public:
ACMRandom
(
int
seed
)
{
Reset
(
seed
);}
void
Reset
(
int
seed
)
{
srand
(
seed
);
}
uint8_t
Rand8
(
void
)
{
return
(
rand
()
>>
8
)
&
0xff
;
}
int
PseudoUniform
(
int
range
)
{
return
(
rand
()
>>
8
)
%
range
;
}
int
operator
()(
int
n
)
{
return
PseudoUniform
(
n
);
}
static
int
DeterministicSeed
(
void
)
{
return
0xbaba
;
}
};
}
TEST
(
VP8
,
TestBitIO
)
{
ACMRandom
rnd
(
ACMRandom
::
DeterministicSeed
());
for
(
int
n
=
0
;
n
<
num_tests
;
++
n
)
{
for
(
int
method
=
0
;
method
<=
7
;
++
method
)
{
// we generate various proba
const
int
bits_to_test
=
1000
;
uint8_t
probas
[
bits_to_test
];
for
(
int
i
=
0
;
i
<
bits_to_test
;
++
i
)
{
const
int
parity
=
i
&
1
;
probas
[
i
]
=
(
method
==
0
)
?
0
:
(
method
==
1
)
?
255
:
(
method
==
2
)
?
128
:
(
method
==
3
)
?
rnd
.
Rand8
()
:
(
method
==
4
)
?
(
parity
?
0
:
255
)
:
// alternate between low and high proba:
(
method
==
5
)
?
(
parity
?
rnd
(
128
)
:
255
-
rnd
(
128
))
:
(
method
==
6
)
?
(
parity
?
rnd
(
64
)
:
255
-
rnd
(
64
))
:
(
parity
?
rnd
(
32
)
:
255
-
rnd
(
32
));
}
for
(
int
bit_method
=
0
;
bit_method
<=
3
;
++
bit_method
)
{
const
int
random_seed
=
6432
;
const
int
buffer_size
=
10000
;
ACMRandom
bit_rnd
(
random_seed
);
BOOL_CODER
bw
;
uint8_t
bw_buffer
[
buffer_size
];
vp8_start_encode
(
&
bw
,
bw_buffer
,
bw_buffer
+
buffer_size
);
int
bit
=
(
bit_method
==
0
)
?
0
:
(
bit_method
==
1
)
?
1
:
0
;
for
(
int
i
=
0
;
i
<
bits_to_test
;
++
i
)
{
if
(
bit_method
==
2
)
{
bit
=
(
i
&
1
);
}
else
if
(
bit_method
==
3
)
{
bit
=
bit_rnd
(
2
);
}
vp8_encode_bool
(
&
bw
,
bit
,
(
int
)
probas
[
i
]);
}
vp8_stop_encode
(
&
bw
);
BOOL_DECODER
br
;
vp8dx_start_decode
(
&
br
,
bw_buffer
,
buffer_size
);
bit_rnd
.
Reset
(
random_seed
);
for
(
int
i
=
0
;
i
<
bits_to_test
;
++
i
)
{
if
(
bit_method
==
2
)
{
bit
=
(
i
&
1
);
}
else
if
(
bit_method
==
3
)
{
bit
=
bit_rnd
(
2
);
}
GTEST_ASSERT_EQ
(
vp8dx_decode_bool
(
&
br
,
probas
[
i
]),
bit
)
<<
"pos: "
<<
i
<<
" / "
<<
bits_to_test
<<
" bit_method: "
<<
bit_method
<<
" method: "
<<
method
;
}
}
}
}
}
int
main
(
int
argc
,
char
**
argv
)
{
::
testing
::
InitGoogleTest
(
&
argc
,
argv
);
return
RUN_ALL_TESTS
();
}
vp8/vp8cx.mk
View file @
c7ca3808
...
...
@@ -87,6 +87,8 @@ VP8_CX_SRCS-yes += encoder/temporal_filter.c
VP8_CX_SRCS-$(CONFIG_MULTI_RES_ENCODING)
+=
encoder/mr_dissim.c
VP8_CX_SRCS-$(CONFIG_MULTI_RES_ENCODING)
+=
encoder/mr_dissim.h
VP8_CX_SRCS-$(CONFIG_UNIT_TESTS)
+=
encoder/boolcoder_test.cc
ifeq
($(CONFIG_REALTIME_ONLY),yes)
VP8_CX_SRCS_REMOVE-yes
+=
encoder/firstpass.c
VP8_CX_SRCS_REMOVE-yes
+=
encoder/temporal_filter.c
...
...
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