OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <math.h> | 5 #include <math.h> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "ui/gfx/codec/jpeg_codec.h" | 9 #include "ui/gfx/codec/jpeg_codec.h" |
10 | 10 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 "\x28\x29\x2a\x35\x36\x37\x38\x39\x3a\x43\x44\x45\x46\x47\x48\x49" | 47 "\x28\x29\x2a\x35\x36\x37\x38\x39\x3a\x43\x44\x45\x46\x47\x48\x49" |
48 "\x4a\x53\x54\x55\x56\x57\x58\x59\x5a\x63\x64\x65\x66\x67\x68\x69" | 48 "\x4a\x53\x54\x55\x56\x57\x58\x59\x5a\x63\x64\x65\x66\x67\x68\x69" |
49 "\x6a\x73\x74\x75\x76\x77\x78\x79\x7a\x82\x83\x84\x85\x86\x87\x88" | 49 "\x6a\x73\x74\x75\x76\x77\x78\x79\x7a\x82\x83\x84\x85\x86\x87\x88" |
50 "\x89\x8a\x92\x93\x94\x95\x96\x97\x98\x99\x9a\xa2\xa3\xa4\xa5\xa6" | 50 "\x89\x8a\x92\x93\x94\x95\x96\x97\x98\x99\x9a\xa2\xa3\xa4\xa5\xa6" |
51 "\xa7\xa8\xa9\xaa\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xc2\xc3\xc4" | 51 "\xa7\xa8\xa9\xaa\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xc2\xc3\xc4" |
52 "\xc5\xc6\xc7\xc8\xc9\xca\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xe2" | 52 "\xc5\xc6\xc7\xc8\xc9\xca\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xe2" |
53 "\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9" | 53 "\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9" |
54 "\xfa\xff\xda\x00\x0c\x03\x01\x00\x02\x11\x03\x11\x00\x3f\x00\xf9" | 54 "\xfa\xff\xda\x00\x0c\x03\x01\x00\x02\x11\x03\x11\x00\x3f\x00\xf9" |
55 "\xd2\x8a\x28\xaf\xc3\x0f\xf5\x4c\xff\xd9"; | 55 "\xd2\x8a\x28\xaf\xc3\x0f\xf5\x4c\xff\xd9"; |
56 | 56 |
57 // A typical Motion JPEG frame which do not have DHT markers. | |
58 const uint8 kMotionJPEGFrame[] = | |
59 "\xff\xd8\xff\xe0\x00\x10\x4a\x46\x49\x46\x00\x01\x01\x01\x00\x60" | |
60 "\x00\x60\x00\x00\xff\xdb\x00\x43\x00\x02\x01\x01\x02\x01\x01\x02" | |
61 "\x02\x02\x02\x02\x02\x02\x02\x03\x05\x03\x03\x03\x03\x03\x06\x04" | |
62 "\x04\x03\x05\x07\x06\x07\x07\x07\x06\x07\x07\x08\x09\x0b\x09\x08" | |
63 "\x08\x0a\x08\x07\x07\x0a\x0d\x0a\x0a\x0b\x0c\x0c\x0c\x0c\x07\x09" | |
64 "\x0e\x0f\x0d\x0c\x0e\x0b\x0c\x0c\x0c\xff\xdb\x00\x43\x01\x02\x02" | |
65 "\x02\x03\x03\x03\x06\x03\x03\x06\x0c\x08\x07\x08\x0c\x0c\x0c\x0c" | |
66 "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c" | |
67 "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c" | |
68 "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\xff\xc0" | |
69 "\x00\x11\x08\x00\x40\x00\x40\x03\x01\x22\x00\x02\x11\x01\x03\x11" | |
70 "\x01\xff\xda\x00\x0c\x03\x01\x00\x02\x11\x03\x11\x00\x3f\x00\xf8" | |
71 "\xbe\x8a\x28\xaf\xe5\x33\xfd\xfc\x0a\x28\xa2\x80\x0a\x28\xa2\x80" | |
72 "\x0a\x28\xa2\x80\x0a\x28\xa2\x80\x0a\x28\xa2\x80\x0a\x28\xa2\x80" | |
73 "\x0a\x28\xa2\x80\x0a\x28\xa2\x80\x0a\x28\xa2\x80\x0a\x28\xa2\x80" | |
74 "\x0a\x28\xa2\x80\x0a\x28\xa2\x80\x0a\x28\xa2\x80\x0a\x28\xa2\x80" | |
75 "\x0a\x28\xa2\x80\x3f\xff\xd9"; | |
76 | |
77 } // namespace | 57 } // namespace |
78 | 58 |
79 namespace gfx { | 59 namespace gfx { |
80 | 60 |
81 // out of 100, this indicates how compressed it will be, this should be changed | 61 // out of 100, this indicates how compressed it will be, this should be changed |
82 // with jpeg equality threshold | 62 // with jpeg equality threshold |
83 // static int jpeg_quality = 75; // FIXME(brettw) | 63 // static int jpeg_quality = 75; // FIXME(brettw) |
84 static int jpeg_quality = 100; | 64 static int jpeg_quality = 100; |
85 | 65 |
86 // The threshold of average color differences where we consider two images | 66 // The threshold of average color differences where we consider two images |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 arraysize(kTopSitesMigrationTestImage), | 207 arraysize(kTopSitesMigrationTestImage), |
228 JPEGCodec::FORMAT_RGB, &output, | 208 JPEGCodec::FORMAT_RGB, &output, |
229 &outw, &outh); | 209 &outw, &outh); |
230 | 210 |
231 JPEGCodec::Decode(kTopSitesMigrationTestImage, | 211 JPEGCodec::Decode(kTopSitesMigrationTestImage, |
232 arraysize(kTopSitesMigrationTestImage), | 212 arraysize(kTopSitesMigrationTestImage), |
233 JPEGCodec::FORMAT_RGBA, &output, | 213 JPEGCodec::FORMAT_RGBA, &output, |
234 &outw, &outh); | 214 &outw, &outh); |
235 } | 215 } |
236 | 216 |
237 // Test that we can decode a motion JPEG frame. | |
238 TEST(JPEGCodec, DecodeMotionJPEG) { | |
239 std::vector<unsigned char> output; | |
240 int outw, outh; | |
241 ASSERT_TRUE(JPEGCodec::Decode(kMotionJPEGFrame, | |
242 arraysize(kMotionJPEGFrame), | |
243 JPEGCodec::FORMAT_RGB, &output, | |
244 &outw, &outh)); | |
245 EXPECT_EQ(64, outw); | |
246 EXPECT_EQ(64, outh); | |
247 | |
248 ASSERT_TRUE(JPEGCodec::Decode(kMotionJPEGFrame, | |
249 arraysize(kMotionJPEGFrame), | |
250 JPEGCodec::FORMAT_RGBA, &output, | |
251 &outw, &outh)); | |
252 EXPECT_EQ(64, outw); | |
253 EXPECT_EQ(64, outh); | |
254 } | |
255 | |
256 } // namespace gfx | 217 } // namespace gfx |
OLD | NEW |