diff options
author | sheu@chromium.org <sheu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-31 05:15:56 +0000 |
---|---|---|
committer | sheu@chromium.org <sheu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-31 05:15:56 +0000 |
commit | f2d27c8b347c41358f0f78e38759735e410dea98 (patch) | |
tree | f57db9ecf7f0a91d0105c998fa4e69cac893b73b /media/base/yuv_convert_unittest.cc | |
parent | 2771b1c10df9718860f95e8674914d9e0b490a06 (diff) | |
download | chromium_src-f2d27c8b347c41358f0f78e38759735e410dea98.zip chromium_src-f2d27c8b347c41358f0f78e38759735e410dea98.tar.gz chromium_src-f2d27c8b347c41358f0f78e38759735e410dea98.tar.bz2 |
Y coordinate calculation fixes for YUV conversion.
The present YUV conversion has bugs in that it:
* Does not account correctly for pixel centers (i.e.: a 2-high texture should
have pixel centers at 0.25 and 0.75)
* Interpolates the UV planes incorrectly for formats that have half-height UV
planes (e.g. YV12)
Note that YUV conversion is also incorrect in the X coordinate, but that's
going to be more involved (as it uses vector-optimized routines), and it's
likely going to be made a moot point anyways when we switch to using libYUV
for color converions. Punt for now.
BUG=chromium:158462
TEST=local build, run on x86, unittests
Review URL: https://chromiumcodereview.appspot.com/11337018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165103 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base/yuv_convert_unittest.cc')
-rw-r--r-- | media/base/yuv_convert_unittest.cc | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/media/base/yuv_convert_unittest.cc b/media/base/yuv_convert_unittest.cc index 153cad8..c57f715 100644 --- a/media/base/yuv_convert_unittest.cc +++ b/media/base/yuv_convert_unittest.cc @@ -170,6 +170,37 @@ class YUVScaleTest : public ::testing::TestWithParam<YUVScaleTestData> { scoped_array<uint8> rgb_bytes_; }; +TEST_P(YUVScaleTest, NoScale) { + media::ScaleYUVToRGB32(y_plane(), // Y + u_plane(), // U + v_plane(), // V + rgb_bytes_.get(), // RGB output + kSourceWidth, kSourceHeight, // Dimensions + kSourceWidth, kSourceHeight, // Dimensions + kSourceWidth, // YStride + kSourceWidth / 2, // UvStride + kSourceWidth * kBpp, // RgbStride + GetParam().yuv_type, + media::ROTATE_0, + GetParam().scale_filter); + + uint32 yuv_hash = DJB2Hash(rgb_bytes_.get(), kRGBSize, kDJB2HashSeed); + + media::ConvertYUVToRGB32(y_plane(), // Y + u_plane(), // U + v_plane(), // V + rgb_bytes_.get(), // RGB output + kSourceWidth, kSourceHeight, // Dimensions + kSourceWidth, // YStride + kSourceWidth / 2, // UVStride + kSourceWidth * kBpp, // RGBStride + GetParam().yuv_type); + + uint32 rgb_hash = DJB2Hash(rgb_bytes_.get(), kRGBSize, kDJB2HashSeed); + + EXPECT_EQ(yuv_hash, rgb_hash); +} + TEST_P(YUVScaleTest, Normal) { media::ScaleYUVToRGB32(y_plane(), // Y u_plane(), // U @@ -240,10 +271,10 @@ TEST_P(YUVScaleTest, OddWidthAndHeightNotCrash) { INSTANTIATE_TEST_CASE_P( YUVScaleFormats, YUVScaleTest, ::testing::Values( - YUVScaleTestData(media::YV12, media::FILTER_NONE, 4259656254u), - YUVScaleTestData(media::YV16, media::FILTER_NONE, 974965419u), - YUVScaleTestData(media::YV12, media::FILTER_BILINEAR, 2086305576u), - YUVScaleTestData(media::YV16, media::FILTER_BILINEAR, 3857179240u))); + YUVScaleTestData(media::YV12, media::FILTER_NONE, 4136904952u), + YUVScaleTestData(media::YV16, media::FILTER_NONE, 1501777547u), + YUVScaleTestData(media::YV12, media::FILTER_BILINEAR, 3164274689u), + YUVScaleTestData(media::YV16, media::FILTER_BILINEAR, 3095878046u))); // This tests a known worst case YUV value, and for overflow. TEST(YUVConvertTest, Clamp) { |