1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
media / parsers / vp9_uncompressed_header_parser_unittest.cc [blame]
// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif
#include "media/parsers/vp9_uncompressed_header_parser.h"
#include "media/parsers/vp9_parser.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace media {
class Vp9UncompressedHeaderParserTest : public testing::Test {
public:
void SetupPastIndependence(Vp9FrameHeader* fhdr) {
vp9_uncompressed_header_parser_.SetupPastIndependence(fhdr);
}
const Vp9FrameContext& GetVp9DefaultFrameContextForTesting() const {
return vp9_uncompressed_header_parser_
.GetVp9DefaultFrameContextForTesting();
}
Vp9UncompressedHeaderParserTest()
: vp9_uncompressed_header_parser_((&vp9_parser_context_)) {}
protected:
const Vp9LoopFilterParams& GetLoopFilter() const {
return vp9_parser_context_.loop_filter();
}
Vp9Parser::Context vp9_parser_context_;
Vp9UncompressedHeaderParser vp9_uncompressed_header_parser_;
};
TEST_F(Vp9UncompressedHeaderParserTest, SetupPastIndependence) {
Vp9FrameHeader frame_header;
SetupPastIndependence(&frame_header);
EXPECT_EQ(0, frame_header.ref_frame_sign_bias[VP9_FRAME_INTRA]);
EXPECT_EQ(0, frame_header.ref_frame_sign_bias[VP9_FRAME_LAST]);
EXPECT_EQ(0, frame_header.ref_frame_sign_bias[VP9_FRAME_GOLDEN]);
EXPECT_EQ(0, frame_header.ref_frame_sign_bias[VP9_FRAME_ALTREF]);
// Verify ResetLoopfilter() result
const Vp9LoopFilterParams& lf = GetLoopFilter();
EXPECT_TRUE(lf.delta_enabled);
EXPECT_TRUE(lf.delta_update);
EXPECT_EQ(1, lf.ref_deltas[VP9_FRAME_INTRA]);
EXPECT_EQ(0, lf.ref_deltas[VP9_FRAME_LAST]);
EXPECT_EQ(-1, lf.ref_deltas[VP9_FRAME_GOLDEN]);
EXPECT_EQ(-1, lf.ref_deltas[VP9_FRAME_ALTREF]);
EXPECT_EQ(0, lf.mode_deltas[0]);
EXPECT_EQ(0, lf.mode_deltas[1]);
EXPECT_TRUE(frame_header.frame_context.IsValid());
static_assert(std::is_pod<Vp9FrameContext>::value,
"Vp9FrameContext is not POD, rewrite the next EXPECT_TRUE");
EXPECT_TRUE(std::memcmp(&frame_header.frame_context,
&GetVp9DefaultFrameContextForTesting(),
sizeof(GetVp9DefaultFrameContextForTesting())) == 0);
}
} // namespace media