Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: webrtc/modules/video_coding/codecs/vp8/reference_picture_selection_unittest.cc

Issue 2753783002: Delete VP8 feedback mode. (Closed)
Patch Set: Rebased. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "vpx/vp8cx.h"
12 #include "vpx/vpx_encoder.h"
13 #include "webrtc/modules/video_coding/codecs/vp8/reference_picture_selection.h"
14 #include "webrtc/test/gtest.h"
15
16 using webrtc::ReferencePictureSelection;
17
18 // The minimum time between reference frame updates. Should match the values
19 // set in reference_picture_selection.h
20 static const uint32_t kMinUpdateInterval = 10;
21 // The minimum time between decoder refreshes through restricted prediction.
22 // Should match the values set in reference_picture_selection.h
23 static const int kRtt = 10;
24
25 static const int kNoPropagationGolden =
26 VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
27 static const int kNoPropagationAltRef =
28 VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
29 static const int kPropagateGolden = VP8_EFLAG_FORCE_GF | VP8_EFLAG_NO_UPD_ARF |
30 VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_LAST;
31 static const int kPropagateAltRef = VP8_EFLAG_FORCE_ARF | VP8_EFLAG_NO_UPD_GF |
32 VP8_EFLAG_NO_REF_ARF |
33 VP8_EFLAG_NO_REF_LAST;
34 static const int kRefreshFromGolden =
35 VP8_EFLAG_NO_REF_LAST | VP8_EFLAG_NO_REF_ARF;
36 static const int kRefreshFromAltRef =
37 VP8_EFLAG_NO_REF_LAST | VP8_EFLAG_NO_REF_GF;
38
39 class TestRPS : public ::testing::Test {
40 protected:
41 virtual void SetUp() {
42 rps_.Init();
43 // Initialize with sending a key frame and acknowledging it.
44 rps_.EncodedKeyFrame(0);
45 rps_.ReceivedRPSI(0);
46 rps_.SetRtt(kRtt);
47 }
48
49 ReferencePictureSelection rps_;
50 };
51
52 TEST_F(TestRPS, TestPropagateReferenceFrames) {
53 // Should propagate the alt-ref reference.
54 uint32_t time = (4 * kMinUpdateInterval) / 3 + 1;
55 EXPECT_EQ(rps_.EncodeFlags(1, false, 90 * time), kPropagateAltRef);
56 rps_.ReceivedRPSI(1);
57 time += (4 * (time + kMinUpdateInterval)) / 3 + 1;
58 // Should propagate the golden reference.
59 EXPECT_EQ(rps_.EncodeFlags(2, false, 90 * time), kPropagateGolden);
60 rps_.ReceivedRPSI(2);
61 // Should propagate the alt-ref reference.
62 time = (4 * (time + kMinUpdateInterval)) / 3 + 1;
63 EXPECT_EQ(rps_.EncodeFlags(3, false, 90 * time), kPropagateAltRef);
64 rps_.ReceivedRPSI(3);
65 // Shouldn't propagate any reference frames (except last), and the established
66 // reference is alt-ref.
67 time = time + kMinUpdateInterval;
68 EXPECT_EQ(rps_.EncodeFlags(4, false, 90 * time), kNoPropagationAltRef);
69 }
70
71 TEST_F(TestRPS, TestDecoderRefresh) {
72 uint32_t time = kRtt + 1;
73 // No more than one refresh per RTT.
74 EXPECT_EQ(rps_.ReceivedSLI(90 * time), true);
75 time += 5;
76 EXPECT_EQ(rps_.ReceivedSLI(90 * time), false);
77 time += kRtt - 4;
78 EXPECT_EQ(rps_.ReceivedSLI(90 * time), true);
79 // Enough time have elapsed since the previous reference propagation, we will
80 // therefore get both a refresh from golden and a propagation of alt-ref.
81 EXPECT_EQ(rps_.EncodeFlags(5, true, 90 * time),
82 kRefreshFromGolden | kPropagateAltRef);
83 rps_.ReceivedRPSI(5);
84 time += kRtt + 1;
85 // Enough time for a new refresh, but not enough time for a reference
86 // propagation.
87 EXPECT_EQ(rps_.ReceivedSLI(90 * time), true);
88 EXPECT_EQ(rps_.EncodeFlags(6, true, 90 * time),
89 kRefreshFromAltRef | kNoPropagationAltRef);
90 }
91
92 TEST_F(TestRPS, TestWrap) {
93 EXPECT_EQ(rps_.ReceivedSLI(0xffffffff), true);
94 EXPECT_EQ(rps_.ReceivedSLI(1), false);
95 EXPECT_EQ(rps_.ReceivedSLI(90 * 100), true);
96
97 EXPECT_EQ(rps_.EncodeFlags(7, false, 0xffffffff), kPropagateAltRef);
98 EXPECT_EQ(rps_.EncodeFlags(8, false, 1), kNoPropagationGolden);
99 EXPECT_EQ(rps_.EncodeFlags(10, false, 90 * 100), kPropagateAltRef);
100 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698