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