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

Side by Side Diff: remoting/base/codec_test.cc

Issue 9331003: Improving the decoder pipeline. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Integer ScaleRect Created 8 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | remoting/base/compressor_verbatim.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <deque> 5 #include <deque>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 std::deque<SkIRect> rects_; 116 std::deque<SkIRect> rects_;
117 117
118 DISALLOW_COPY_AND_ASSIGN(EncoderMessageTester); 118 DISALLOW_COPY_AND_ASSIGN(EncoderMessageTester);
119 }; 119 };
120 120
121 class DecoderTester { 121 class DecoderTester {
122 public: 122 public:
123 DecoderTester(Decoder* decoder) 123 DecoderTester(Decoder* decoder)
124 : strict_(false), 124 : strict_(false),
125 decoder_(decoder) { 125 decoder_(decoder) {
126 frame_ = media::VideoFrame::CreateFrame(media::VideoFrame::RGB32, 126 image_data_.reset(new uint8[kWidth * kHeight * kBytesPerPixel]);
127 kWidth, kHeight, 127 EXPECT_TRUE(image_data_.get());
128 base::TimeDelta(), 128 decoder_->Initialize(SkISize::Make(kWidth, kHeight));
129 base::TimeDelta());
130 EXPECT_TRUE(frame_.get());
131 decoder_->Initialize(frame_);
132 } 129 }
133 130
134 void Reset() { 131 void Reset() {
135 expected_region_.setEmpty(); 132 expected_region_.setEmpty();
136 update_region_.setEmpty(); 133 update_region_.setEmpty();
137 } 134 }
138 135
139 void ReceivedPacket(VideoPacket* packet) { 136 void ReceivedPacket(VideoPacket* packet) {
140 Decoder::DecodeResult result = decoder_->DecodePacket(packet); 137 Decoder::DecodeResult result = decoder_->DecodePacket(packet);
141 138
142 ASSERT_NE(Decoder::DECODE_ERROR, result); 139 ASSERT_NE(Decoder::DECODE_ERROR, result);
143 140
144 if (result == Decoder::DECODE_DONE) { 141 if (result == Decoder::DECODE_DONE) {
145 decoder_->GetUpdatedRegion(&update_region_); 142 decoder_->RenderFrame(SkISize::Make(kWidth, kHeight),
143 SkIRect::MakeXYWH(0, 0, kWidth, kHeight),
144 image_data_.get(),
145 kWidth * kBytesPerPixel,
146 &update_region_);
146 } 147 }
147 } 148 }
148 149
149 void set_strict(bool strict) { 150 void set_strict(bool strict) {
150 strict_ = strict; 151 strict_ = strict;
151 } 152 }
152 153
153 void set_capture_data(scoped_refptr<CaptureData> data) { 154 void set_capture_data(scoped_refptr<CaptureData> data) {
154 capture_data_ = data; 155 capture_data_ = data;
155 } 156 }
156 157
157 void AddRects(const SkIRect* rects, int count) { 158 void AddRects(const SkIRect* rects, int count) {
158 SkRegion new_rects; 159 SkRegion new_rects;
159 new_rects.setRects(rects, count); 160 new_rects.setRects(rects, count);
160 expected_region_.op(new_rects, SkRegion::kUnion_Op); 161 expected_region_.op(new_rects, SkRegion::kUnion_Op);
161 } 162 }
162 163
163 void VerifyResults() { 164 void VerifyResults() {
164 if (!strict_) 165 if (!strict_)
165 return; 166 return;
166 167
167 ASSERT_TRUE(capture_data_.get()); 168 ASSERT_TRUE(capture_data_.get());
168 169
169 // Test the content of the update region. 170 // Test the content of the update region.
170 EXPECT_EQ(expected_region_, update_region_); 171 EXPECT_EQ(expected_region_, update_region_);
171 for (SkRegion::Iterator i(update_region_); !i.done(); i.next()) { 172 for (SkRegion::Iterator i(update_region_); !i.done(); i.next()) {
172 EXPECT_EQ(frame_->stride(0), capture_data_->data_planes().strides[0]); 173 const int stride = kWidth * kBytesPerPixel;
173 const int stride = frame_->stride(0); 174 EXPECT_EQ(stride, capture_data_->data_planes().strides[0]);
174 const int offset = stride * i.rect().top() + 175 const int offset = stride * i.rect().top() +
175 kBytesPerPixel * i.rect().left(); 176 kBytesPerPixel * i.rect().left();
176 const uint8* original = capture_data_->data_planes().data[0] + offset; 177 const uint8* original = capture_data_->data_planes().data[0] + offset;
177 const uint8* decoded = frame_->data(0) + offset; 178 const uint8* decoded = image_data_.get() + offset;
178 const int row_size = kBytesPerPixel * i.rect().width(); 179 const int row_size = kBytesPerPixel * i.rect().width();
179 for (int y = 0; y < i.rect().height(); ++y) { 180 for (int y = 0; y < i.rect().height(); ++y) {
180 EXPECT_EQ(0, memcmp(original, decoded, row_size)) 181 EXPECT_EQ(0, memcmp(original, decoded, row_size))
181 << "Row " << y << " is different"; 182 << "Row " << y << " is different";
182 original += stride; 183 original += stride;
183 decoded += stride; 184 decoded += stride;
184 } 185 }
185 } 186 }
186 } 187 }
187 188
188 private: 189 private:
189 bool strict_; 190 bool strict_;
190 SkRegion expected_region_; 191 SkRegion expected_region_;
191 SkRegion update_region_; 192 SkRegion update_region_;
192 Decoder* decoder_; 193 Decoder* decoder_;
193 scoped_refptr<media::VideoFrame> frame_; 194 scoped_array<uint8> image_data_;
194 scoped_refptr<CaptureData> capture_data_; 195 scoped_refptr<CaptureData> capture_data_;
195 196
196 DISALLOW_COPY_AND_ASSIGN(DecoderTester); 197 DISALLOW_COPY_AND_ASSIGN(DecoderTester);
197 }; 198 };
198 199
199 // The EncoderTester provides a hook for retrieving the data, and passing the 200 // The EncoderTester provides a hook for retrieving the data, and passing the
200 // message to other subprograms for validaton. 201 // message to other subprograms for validaton.
201 class EncoderTester { 202 class EncoderTester {
202 public: 203 public:
203 EncoderTester(EncoderMessageTester* message_tester) 204 EncoderTester(EncoderMessageTester* message_tester)
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 kTestRects, 1); 343 kTestRects, 1);
343 TestEncodeDecodeRects(encoder, &encoder_tester, &decoder_tester, data, 344 TestEncodeDecodeRects(encoder, &encoder_tester, &decoder_tester, data,
344 kTestRects + 1, 1); 345 kTestRects + 1, 1);
345 TestEncodeDecodeRects(encoder, &encoder_tester, &decoder_tester, data, 346 TestEncodeDecodeRects(encoder, &encoder_tester, &decoder_tester, data,
346 kTestRects + 2, 1); 347 kTestRects + 2, 1);
347 TestEncodeDecodeRects(encoder, &encoder_tester, &decoder_tester, data, 348 TestEncodeDecodeRects(encoder, &encoder_tester, &decoder_tester, data,
348 kTestRects + 3, 2); 349 kTestRects + 3, 2);
349 } 350 }
350 351
351 } // namespace remoting 352 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | remoting/base/compressor_verbatim.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698