Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Guillaume Martres
aom-rav1e
Commits
686b54ad
Commit
686b54ad
authored
Jun 11, 2014
by
Minghai Shang
Committed by
Gerrit Code Review
Jun 11, 2014
Browse files
Merge "[spatial svc]Combine first and second pass test to keep stats data in memory."
parents
5d35bc68
6b747766
Changes
3
Hide whitespace changes
Inline
Side-by-side
test/svc_test.cc
View file @
686b54ad
...
...
@@ -31,7 +31,6 @@ class SvcTest : public ::testing::Test {
SvcTest
()
:
codec_iface_
(
0
),
test_file_name_
(
"hantro_collage_w352h288.yuv"
),
stats_file_name_
(
"hantro_collage_w352h288.stat"
),
codec_initialized_
(
false
),
decoder_
(
0
)
{
memset
(
&
svc_
,
0
,
sizeof
(
svc_
));
...
...
@@ -74,7 +73,6 @@ class SvcTest : public ::testing::Test {
struct
vpx_codec_enc_cfg
codec_enc_
;
vpx_codec_iface_t
*
codec_iface_
;
std
::
string
test_file_name_
;
std
::
string
stats_file_name_
;
bool
codec_initialized_
;
Decoder
*
decoder_
;
};
...
...
@@ -364,7 +362,9 @@ TEST_F(SvcTest, GetLayerResolution) {
EXPECT_EQ
(
kHeight
*
8
/
16
,
layer_height
);
}
TEST_F
(
SvcTest
,
FirstPassEncode
)
{
TEST_F
(
SvcTest
,
TwoPassEncode
)
{
// First pass encode
std
::
string
stats_buf
;
svc_
.
spatial_layers
=
2
;
codec_enc_
.
g_pass
=
VPX_RC_FIRST_PASS
;
vpx_svc_set_scale_factors
(
&
svc_
,
"4/16,16/16"
);
...
...
@@ -383,50 +383,44 @@ TEST_F(SvcTest, FirstPassEncode) {
res
=
vpx_svc_encode
(
&
svc_
,
&
codec_
,
video
.
img
(),
video
.
pts
(),
video
.
duration
(),
VPX_DL_GOOD_QUALITY
);
ASSERT_EQ
(
VPX_CODEC_OK
,
res
);
EXPECT_GT
(
vpx_svc_get_rc_stats_buffer_size
(
&
svc_
),
0U
);
size_t
stats_size
=
vpx_svc_get_rc_stats_buffer_size
(
&
svc_
);
EXPECT_GT
(
stats_size
,
0U
);
const
char
*
stats_data
=
vpx_svc_get_rc_stats_buffer
(
&
svc_
);
ASSERT_TRUE
(
stats_data
!=
NULL
);
stats_buf
.
append
(
stats_data
,
stats_size
);
// FRAME 1
video
.
Next
();
res
=
vpx_svc_encode
(
&
svc_
,
&
codec_
,
video
.
img
(),
video
.
pts
(),
video
.
duration
(),
VPX_DL_GOOD_QUALITY
);
ASSERT_EQ
(
VPX_CODEC_OK
,
res
);
EXPECT_GT
(
vpx_svc_get_rc_stats_buffer_size
(
&
svc_
),
0U
);
stats_size
=
vpx_svc_get_rc_stats_buffer_size
(
&
svc_
);
EXPECT_GT
(
stats_size
,
0U
);
stats_data
=
vpx_svc_get_rc_stats_buffer
(
&
svc_
);
ASSERT_TRUE
(
stats_data
!=
NULL
);
stats_buf
.
append
(
stats_data
,
stats_size
);
// Flush encoder and test EOS packet
res
=
vpx_svc_encode
(
&
svc_
,
&
codec_
,
NULL
,
video
.
pts
(),
video
.
duration
(),
VPX_DL_GOOD_QUALITY
);
ASSERT_EQ
(
VPX_CODEC_OK
,
res
);
EXPECT_GT
(
vpx_svc_get_rc_stats_buffer_size
(
&
svc_
),
0U
);
}
TEST_F
(
SvcTest
,
SecondPassEncode
)
{
svc_
.
spatial_layers
=
2
;
codec_enc_
.
g_pass
=
VPX_RC_LAST_PASS
;
stats_size
=
vpx_svc_get_rc_stats_buffer_size
(
&
svc_
);
EXPECT_GT
(
stats_size
,
0U
);
stats_data
=
vpx_svc_get_rc_stats_buffer
(
&
svc_
);
ASSERT_TRUE
(
stats_data
!=
NULL
);
stats_buf
.
append
(
stats_data
,
stats_size
);
FILE
*
const
stats_file
=
libvpx_test
::
OpenTestDataFile
(
stats_file_name_
);
ASSERT_TRUE
(
stats_file
!=
NULL
)
<<
"Stats file open failed. Filename: "
<<
stats_file
;
// Tear down encoder
vpx_svc_release
(
&
svc_
);
vpx_codec_destroy
(
&
codec_
)
;
struct
vpx_fixed_buf
stats_buf
;
fseek
(
stats_file
,
0
,
SEEK_END
);
stats_buf
.
sz
=
static_cast
<
size_t
>
(
ftell
(
stats_file
));
fseek
(
stats_file
,
0
,
SEEK_SET
);
stats_buf
.
buf
=
malloc
(
stats_buf
.
sz
);
ASSERT_TRUE
(
stats_buf
.
buf
!=
NULL
);
const
size_t
bytes_read
=
fread
(
stats_buf
.
buf
,
1
,
stats_buf
.
sz
,
stats_file
);
ASSERT_EQ
(
bytes_read
,
stats_buf
.
sz
);
fclose
(
stats_file
);
codec_enc_
.
rc_twopass_stats_in
=
stats_buf
;
// Second pass encode
codec_enc_
.
g_pass
=
VPX_RC_LAST_PASS
;
codec_enc_
.
rc_twopass_stats_in
.
buf
=
&
stats_buf
[
0
];
codec_enc_
.
rc_twopass_stats_in
.
sz
=
stats_buf
.
size
();
vpx_codec_err_t
res
=
vpx_svc_init
(
&
svc_
,
&
codec_
,
vpx_codec_vp9_cx
(),
&
codec_enc_
);
res
=
vpx_svc_init
(
&
svc_
,
&
codec_
,
vpx_codec_vp9_cx
(),
&
codec_enc_
);
ASSERT_EQ
(
VPX_CODEC_OK
,
res
);
codec_initialized_
=
true
;
libvpx_test
::
I420VideoSource
video
(
test_file_name_
,
kWidth
,
kHeight
,
codec_enc_
.
g_timebase
.
den
,
codec_enc_
.
g_timebase
.
num
,
0
,
30
);
// FRAME 0
video
.
Begin
();
// This frame is a keyframe.
...
...
@@ -465,8 +459,6 @@ TEST_F(SvcTest, SecondPassEncode) {
static_cast
<
const
uint8_t
*>
(
vpx_svc_get_buffer
(
&
svc_
)),
vpx_svc_get_frame_size
(
&
svc_
));
ASSERT_EQ
(
VPX_CODEC_OK
,
res_dec
)
<<
decoder_
->
DecodeError
();
free
(
stats_buf
.
buf
);
}
}
// namespace
test/test-data.sha1
View file @
686b54ad
d5dfb0151c9051f8c85999255645d7a23916d3c0 hantro_collage_w352h288.yuv
998cec53307c94aa5835aaf8d5731f6a3c7c2e5a hantro_collage_w352h288.stat
b87815bf86020c592ccc7a846ba2e28ec8043902 hantro_odd.yuv
b1f1c3ec79114b9a0651af24ce634afb44a9a419 rush_hour_444.y4m
5184c46ddca8b1fadd16742e8500115bc8f749da vp80-00-comprehensive-001.ivf
...
...
test/test.mk
View file @
686b54ad
...
...
@@ -131,7 +131,6 @@ endif # CONFIG_SHARED
## TEST DATA
##
LIBVPX_TEST_DATA-$(CONFIG_ENCODERS)
+=
hantro_collage_w352h288.yuv
LIBVPX_TEST_DATA-$(CONFIG_ENCODERS)
+=
hantro_collage_w352h288.stat
LIBVPX_TEST_DATA-$(CONFIG_ENCODERS)
+=
hantro_odd.yuv
LIBVPX_TEST_DATA-$(CONFIG_VP9_ENCODER)
+=
rush_hour_444.y4m
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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