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

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

Issue 10877014: Moved the video encoders/decoders to the codec directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 8 years, 4 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 | « remoting/base/encoder_vp8.cc ('k') | remoting/client/rectangle_update_decoder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <limits>
6 #include <vector>
7
8 #include "base/bind.h"
9 #include "base/callback.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "remoting/base/capture_data.h"
12 #include "remoting/base/codec_test.h"
13 #include "remoting/base/encoder_vp8.h"
14 #include "remoting/proto/video.pb.h"
15 #include "testing/gtest/include/gtest/gtest.h"
16
17 namespace {
18
19 const int kIntMax = std::numeric_limits<int>::max();
20
21 } // namespace
22
23 namespace remoting {
24
25 TEST(EncoderVp8Test, TestEncoder) {
26 EncoderVp8 encoder;
27 TestEncoder(&encoder, false);
28 }
29
30 class EncoderCallback {
31 public:
32 void DataAvailable(scoped_ptr<VideoPacket> packet) {
33 }
34 };
35
36 // Test that calling Encode with a differently-sized CaptureData does not
37 // leak memory.
38 TEST(EncoderVp8Test, TestSizeChangeNoLeak) {
39 int height = 1000;
40 int width = 1000;
41 const int kBytesPerPixel = 4;
42
43 EncoderVp8 encoder;
44 EncoderCallback callback;
45
46 std::vector<uint8> buffer(width * height * kBytesPerPixel);
47 DataPlanes planes;
48 planes.data[0] = &buffer.front();
49 planes.strides[0] = width;
50
51 scoped_refptr<CaptureData> capture_data(new CaptureData(
52 planes, SkISize::Make(width, height), media::VideoFrame::RGB32));
53 encoder.Encode(capture_data, false,
54 base::Bind(&EncoderCallback::DataAvailable,
55 base::Unretained(&callback)));
56
57 height /= 2;
58 capture_data = new CaptureData(planes, SkISize::Make(width, height),
59 media::VideoFrame::RGB32);
60 encoder.Encode(capture_data, false,
61 base::Bind(&EncoderCallback::DataAvailable,
62 base::Unretained(&callback)));
63 }
64
65 class EncoderDpiCallback {
66 public:
67 void DataAvailable(scoped_ptr<VideoPacket> packet) {
68 EXPECT_EQ(packet->format().x_dpi(), 96);
69 EXPECT_EQ(packet->format().y_dpi(), 97);
70 }
71 };
72
73 // Test that the DPI information is correctly propagated from the CaptureData
74 // to the VideoPacket.
75 TEST(EncoderVp8Test, TestDpiPropagation) {
76 int height = 32;
77 int width = 32;
78 const int kBytesPerPixel = 4;
79
80 EncoderVp8 encoder;
81 EncoderDpiCallback callback;
82
83 std::vector<uint8> buffer(width * height * kBytesPerPixel);
84 DataPlanes planes;
85 planes.data[0] = &buffer.front();
86 planes.strides[0] = width;
87
88 scoped_refptr<CaptureData> capture_data(new CaptureData(
89 planes, SkISize::Make(width, height), media::VideoFrame::RGB32));
90 capture_data->set_dpi(SkIPoint::Make(96, 97));
91 encoder.Encode(capture_data, false,
92 base::Bind(&EncoderDpiCallback::DataAvailable,
93 base::Unretained(&callback)));
94 }
95
96 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/base/encoder_vp8.cc ('k') | remoting/client/rectangle_update_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698