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

Unified Diff: Source/platform/image-decoders/jpeg/JPEGImageDecoderTest.cpp

Issue 418653002: Allowing YUV data to be retrieved from the JPEG Decoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added a unit test Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/image-decoders/jpeg/JPEGImageDecoderTest.cpp
diff --git a/Source/platform/image-decoders/jpeg/JPEGImageDecoderTest.cpp b/Source/platform/image-decoders/jpeg/JPEGImageDecoderTest.cpp
index 0fabc53c64dfa3772da4b4cdcf19a0d607b48b11..2b743ea157f46b5b8eeeb6feb562fe512e9bc949 100644
--- a/Source/platform/image-decoders/jpeg/JPEGImageDecoderTest.cpp
+++ b/Source/platform/image-decoders/jpeg/JPEGImageDecoderTest.cpp
@@ -79,6 +79,35 @@ void downsample(size_t maxDecodedBytes, unsigned* outputWidth, unsigned* outputH
EXPECT_EQ(IntSize(*outputWidth, *outputHeight), decoder->decodedSize());
}
+void readYUV(size_t maxDecodedBytes, unsigned* outputYWidth, unsigned* outputYHeight, unsigned* outputUVWidth, unsigned* outputUVHeight, const char* imageFilePath)
+{
+ RefPtr<SharedBuffer> data = readFile(imageFilePath);
+ ASSERT_TRUE(data.get());
+
+ OwnPtr<JPEGImageDecoder> decoder = createDecoder(maxDecodedBytes);
+ decoder->setData(data.get(), true);
+
+ OwnPtr<ImagePlanes> imagePlanes = adoptPtr(new ImagePlanes());
+ decoder->setImagePlanes(imagePlanes);
+ bool sizeIsAvailable = decoder->isSizeAvailable();
+ ASSERT_TRUE(sizeIsAvailable);
+
+ IntSize size = decoder->decodedSize();
+ IntSize ySize = decoder->decodedYUVSize(0);
+ IntSize uSize = decoder->decodedYUVSize(1);
+ IntSize vSize = decoder->decodedYUVSize(2);
+
+ ASSERT_TRUE(size.width() == ySize.width());
+ ASSERT_TRUE(size.height() == ySize.height());
+ ASSERT_TRUE(uSize.width() == vSize.width());
+ ASSERT_TRUE(uSize.height() == vSize.height());
+
+ *outputYWidth = ySize.width();
+ *outputYHeight = ySize.height();
+ *outputUVWidth = uSize.width();
+ *outputUVHeight = uSize.height();
+}
+
// Tests failure on a too big image.
TEST(JPEGImageDecoderTest, tooBig)
{
@@ -183,3 +212,14 @@ TEST(JPEGImageDecoderTest, upsample)
EXPECT_EQ(256u, outputWidth);
EXPECT_EQ(256u, outputHeight);
}
+
+TEST(JPEGImageDecoderTest, yuv)
+{
+ const char* jpegFile = "/LayoutTests/fast/images/resources/lenna.jpg"; // 256x256, YUV 4:2:0
+ unsigned outputYWidth, outputYHeight, outputUVWidth, outputUVHeight;
+ readYUV(1000 * 1000, &outputYWidth, &outputYHeight, &outputUVWidth, &outputUVHeight, jpegFile);
Stephen White 2014/07/25 18:25:10 Let's pull that out into a constant at the top-of-
+ EXPECT_EQ(256u, outputYWidth);
+ EXPECT_EQ(256u, outputYHeight);
+ EXPECT_EQ(128u, outputUVWidth);
+ EXPECT_EQ(128u, outputUVHeight);
+}
« no previous file with comments | « Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698