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

Side by Side Diff: media/gpu/video_decode_accelerator_unittest.cc

Issue 2927893002: Remove FORMAT_RGB from gfx::PngCodec (Closed)
Patch Set: Compile fixes Created 3 years, 6 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
« no previous file with comments | « media/gpu/rendering_helper.cc ('k') | ui/gfx/codec/png_codec.h » ('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 // The bulk of this file is support code; sorry about that. Here's an overview 5 // The bulk of this file is support code; sorry about that. Here's an overview
6 // to hopefully help readers of this code: 6 // to hopefully help readers of this code:
7 // - RenderingHelper is charged with interacting with X11/{EGL/GLES2,GLX/GL} or 7 // - RenderingHelper is charged with interacting with X11/{EGL/GLES2,GLX/GL} or
8 // Win/EGL. 8 // Win/EGL.
9 // - ClientState is an enum for the state of the decode client used by the test. 9 // - ClientState is an enum for the state of the decode client used by the test.
10 // - ClientStateNotification is a barrier abstraction that allows the test code 10 // - ClientStateNotification is a barrier abstraction that allows the test code
(...skipping 1509 matching lines...) Expand 10 before | Expand all | Expand 10 after
1520 LOG(INFO) << "Decoder " << i << " fps: " << client->frames_per_second(); 1520 LOG(INFO) << "Decoder " << i << " fps: " << client->frames_per_second();
1521 if (!render_as_thumbnails) { 1521 if (!render_as_thumbnails) {
1522 int min_fps = suppress_rendering ? video_file->min_fps_no_render 1522 int min_fps = suppress_rendering ? video_file->min_fps_no_render
1523 : video_file->min_fps_render; 1523 : video_file->min_fps_render;
1524 if (min_fps > 0 && !test_reuse_delay) 1524 if (min_fps > 0 && !test_reuse_delay)
1525 EXPECT_GT(client->frames_per_second(), min_fps); 1525 EXPECT_GT(client->frames_per_second(), min_fps);
1526 } 1526 }
1527 } 1527 }
1528 1528
1529 if (render_as_thumbnails) { 1529 if (render_as_thumbnails) {
1530 std::vector<unsigned char> rgb; 1530 std::vector<unsigned char> rgba;
1531 bool alpha_solid;
1532 base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC, 1531 base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC,
1533 base::WaitableEvent::InitialState::NOT_SIGNALED); 1532 base::WaitableEvent::InitialState::NOT_SIGNALED);
1534 g_env->GetRenderingTaskRunner()->PostTask( 1533 g_env->GetRenderingTaskRunner()->PostTask(
1535 FROM_HERE, base::Bind(&RenderingHelper::GetThumbnailsAsRGB, 1534 FROM_HERE,
1536 base::Unretained(&rendering_helper_), &rgb, 1535 base::Bind(&RenderingHelper::GetThumbnailsAsRGBA,
1537 &alpha_solid, &done)); 1536 base::Unretained(&rendering_helper_), &rgba, &done));
1538 done.Wait(); 1537 done.Wait();
1539 1538
1539 std::vector<unsigned char> rgb;
1540 size_t num_pixels = rgba.size() / 4;
1541
1542 rgb.resize(num_pixels * 3);
1543 // Drop the alpha channel, but check as we go that it is all 0xff.
1544 bool solid = true;
1545 unsigned char* rgb_ptr = &rgb[0];
1546 unsigned char* rgba_ptr = &rgba[0];
1547 for (size_t i = 0; i < num_pixels; i++) {
1548 *rgb_ptr++ = *rgba_ptr++;
1549 *rgb_ptr++ = *rgba_ptr++;
1550 *rgb_ptr++ = *rgba_ptr++;
1551 solid = solid && (*rgba_ptr == 0xff);
1552 rgba_ptr++;
1553 }
1554
1555 EXPECT_EQ(solid, true) << "RGBA frame had incorrect alpha";
1556
1540 std::vector<std::string> golden_md5s; 1557 std::vector<std::string> golden_md5s;
1541 std::string md5_string = base::MD5String( 1558 std::string md5_string = base::MD5String(
1542 base::StringPiece(reinterpret_cast<char*>(&rgb[0]), rgb.size())); 1559 base::StringPiece(reinterpret_cast<char*>(&rgb[0]), rgb.size()));
1543 ReadGoldenThumbnailMD5s(test_video_files_[0].get(), &golden_md5s); 1560 ReadGoldenThumbnailMD5s(test_video_files_[0].get(), &golden_md5s);
1544 std::vector<std::string>::iterator match = 1561 std::vector<std::string>::iterator match =
1545 find(golden_md5s.begin(), golden_md5s.end(), md5_string); 1562 find(golden_md5s.begin(), golden_md5s.end(), md5_string);
1546 if (match == golden_md5s.end()) { 1563 if (match == golden_md5s.end()) {
1547 // Convert raw RGB into PNG for export. 1564 // Convert raw RGBA into PNG for export.
1548 std::vector<unsigned char> png; 1565 std::vector<unsigned char> png;
1549 gfx::PNGCodec::Encode(&rgb[0], 1566 gfx::PNGCodec::Encode(&rgba[0], gfx::PNGCodec::FORMAT_RGBA,
1550 gfx::PNGCodec::FORMAT_RGB,
1551 kThumbnailsPageSize, 1567 kThumbnailsPageSize,
1552 kThumbnailsPageSize.width() * 3, 1568 kThumbnailsPageSize.width() * 4, true,
1553 true, 1569 std::vector<gfx::PNGCodec::Comment>(), &png);
1554 std::vector<gfx::PNGCodec::Comment>(),
1555 &png);
1556 1570
1557 LOG(ERROR) << "Unknown thumbnails MD5: " << md5_string; 1571 LOG(ERROR) << "Unknown thumbnails MD5: " << md5_string;
1558 1572
1559 base::FilePath filepath(test_video_files_[0]->file_name); 1573 base::FilePath filepath(test_video_files_[0]->file_name);
1560 if (!g_thumbnail_output_dir.empty() && 1574 if (!g_thumbnail_output_dir.empty() &&
1561 base::DirectoryExists(g_thumbnail_output_dir)) { 1575 base::DirectoryExists(g_thumbnail_output_dir)) {
1562 // Write bad thumbnails image to where --thumbnail_output_dir assigned. 1576 // Write bad thumbnails image to where --thumbnail_output_dir assigned.
1563 filepath = g_thumbnail_output_dir.Append(filepath.BaseName()); 1577 filepath = g_thumbnail_output_dir.Append(filepath.BaseName());
1564 } else { 1578 } else {
1565 // Fallback to write to test data directory. 1579 // Fallback to write to test data directory.
1566 // Note: test data directory is not writable by vda_unittest while 1580 // Note: test data directory is not writable by vda_unittest while
1567 // running by autotest. It should assign its resultsdir as output 1581 // running by autotest. It should assign its resultsdir as output
1568 // directory. 1582 // directory.
1569 filepath = GetTestDataFile(filepath); 1583 filepath = GetTestDataFile(filepath);
1570 } 1584 }
1571 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".bad_thumbnails")); 1585 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".bad_thumbnails"));
1572 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".png")); 1586 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".png"));
1573 LOG(INFO) << "Write bad thumbnails image to: " 1587 LOG(INFO) << "Write bad thumbnails image to: "
1574 << filepath.value().c_str(); 1588 << filepath.value().c_str();
1575 int num_bytes = base::WriteFile( 1589 int num_bytes = base::WriteFile(
1576 filepath, reinterpret_cast<char*>(&png[0]), png.size()); 1590 filepath, reinterpret_cast<char*>(&png[0]), png.size());
1577 EXPECT_EQ(num_bytes, static_cast<int>(png.size())); 1591 EXPECT_EQ(num_bytes, static_cast<int>(png.size()));
1578 } 1592 }
1579 EXPECT_NE(match, golden_md5s.end()); 1593 EXPECT_NE(match, golden_md5s.end());
1580 EXPECT_EQ(alpha_solid, true) << "RGBA frame had incorrect alpha";
1581 } 1594 }
1582 1595
1583 // Output the frame delivery time to file 1596 // Output the frame delivery time to file
1584 // We can only make performance/correctness assertions if the decoder was 1597 // We can only make performance/correctness assertions if the decoder was
1585 // allowed to finish. 1598 // allowed to finish.
1586 if (g_output_log != NULL && delete_decoder_state >= CS_FLUSHED) { 1599 if (g_output_log != NULL && delete_decoder_state >= CS_FLUSHED) {
1587 base::File output_file( 1600 base::File output_file(
1588 base::FilePath(g_output_log), 1601 base::FilePath(g_output_log),
1589 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); 1602 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE);
1590 for (size_t i = 0; i < num_concurrent_decoders; ++i) { 1603 for (size_t i = 0; i < num_concurrent_decoders; ++i) {
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
1918 media::g_thumbnail_output_dir = base::FilePath(it->second.c_str()); 1931 media::g_thumbnail_output_dir = base::FilePath(it->second.c_str());
1919 } 1932 }
1920 } 1933 }
1921 1934
1922 base::ShadowingAtExitManager at_exit_manager; 1935 base::ShadowingAtExitManager at_exit_manager;
1923 1936
1924 return base::LaunchUnitTestsSerially( 1937 return base::LaunchUnitTestsSerially(
1925 argc, argv, 1938 argc, argv,
1926 base::Bind(&media::VDATestSuite::Run, base::Unretained(&test_suite))); 1939 base::Bind(&media::VDATestSuite::Run, base::Unretained(&test_suite)));
1927 } 1940 }
OLDNEW
« no previous file with comments | « media/gpu/rendering_helper.cc ('k') | ui/gfx/codec/png_codec.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698