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

Side by Side Diff: cc/resources/video_resource_updater_unittest.cc

Issue 2969223002: [media]: Replace LUMINANCE_F16 by R16 for 9/10-bit h264 videos.
Patch Set: Fix in resource_format_utils Created 3 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
« no previous file with comments | « cc/resources/video_resource_updater.cc ('k') | cc/test/test_context_provider.cc » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "cc/resources/video_resource_updater.h" 5 #include "cc/resources/video_resource_updater.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 304
305 // Create the resource again, to test the path where the 305 // Create the resource again, to test the path where the
306 // resources are cached. 306 // resources are cached.
307 VideoFrameExternalResources resources2 = 307 VideoFrameExternalResources resources2 =
308 updater.CreateExternalResourcesFromVideoFrame(video_frame); 308 updater.CreateExternalResourcesFromVideoFrame(video_frame);
309 EXPECT_EQ(VideoFrameExternalResources::YUV_RESOURCE, resources2.type); 309 EXPECT_EQ(VideoFrameExternalResources::YUV_RESOURCE, resources2.type);
310 EXPECT_NEAR(resources2.multiplier, 2.0, 0.1); 310 EXPECT_NEAR(resources2.multiplier, 2.0, 0.1);
311 EXPECT_NEAR(resources2.offset, 0.5, 0.1); 311 EXPECT_NEAR(resources2.offset, 0.5, 0.1);
312 } 312 }
313 313
314 class VideoResourceUpdaterTestWithR16 : public VideoResourceUpdaterTest {
315 public:
316 VideoResourceUpdaterTestWithR16() : VideoResourceUpdaterTest() {
317 context3d_->set_support_texture_norm16(true);
318 }
319 };
320
321 TEST_F(VideoResourceUpdaterTestWithR16, HighBitFrame) {
322 bool use_stream_video_draw_quad = false;
323 VideoResourceUpdater updater(context_provider_.get(),
324 resource_provider3d_.get(),
325 use_stream_video_draw_quad);
326 updater.UseR16ForTesting(true);
327 resource_provider3d_->SetYUVHighbitResourceFormatForTesting(viz::R16_EXT);
328 scoped_refptr<media::VideoFrame> video_frame = CreateTestHighBitFrame();
329
330 VideoFrameExternalResources resources =
331 updater.CreateExternalResourcesFromVideoFrame(video_frame);
332 EXPECT_EQ(VideoFrameExternalResources::YUV_RESOURCE, resources.type);
333
334 // multiplier = (1 << shift) + 1.0 / (1 << (bits_per_channel - shift))
335 // where shift = 16 - bits_per_channel, and bits_per_channel = 10
336 EXPECT_NEAR(resources.multiplier, 64.0625, 0.1);
337 EXPECT_NEAR(resources.offset, 0.0, 0.1);
338
339 // Create the resource again, to test the path where the
340 // resources are cached.
341 VideoFrameExternalResources resources2 =
342 updater.CreateExternalResourcesFromVideoFrame(video_frame);
343 EXPECT_EQ(VideoFrameExternalResources::YUV_RESOURCE, resources2.type);
344 EXPECT_NEAR(resources2.multiplier, 64.0625, 0.1);
345 EXPECT_NEAR(resources2.offset, 0.0, 0.1);
346 }
347
314 TEST_F(VideoResourceUpdaterTest, HighBitFrameSoftwareCompositor) { 348 TEST_F(VideoResourceUpdaterTest, HighBitFrameSoftwareCompositor) {
315 bool use_stream_video_draw_quad = false; 349 bool use_stream_video_draw_quad = false;
316 VideoResourceUpdater updater(nullptr, resource_provider_software_.get(), 350 VideoResourceUpdater updater(nullptr, resource_provider_software_.get(),
317 use_stream_video_draw_quad); 351 use_stream_video_draw_quad);
318 scoped_refptr<media::VideoFrame> video_frame = CreateTestHighBitFrame(); 352 scoped_refptr<media::VideoFrame> video_frame = CreateTestHighBitFrame();
319 353
320 VideoFrameExternalResources resources = 354 VideoFrameExternalResources resources =
321 updater.CreateExternalResourcesFromVideoFrame(video_frame); 355 updater.CreateExternalResourcesFromVideoFrame(video_frame);
322 EXPECT_EQ(VideoFrameExternalResources::SOFTWARE_RESOURCE, resources.type); 356 EXPECT_EQ(VideoFrameExternalResources::SOFTWARE_RESOURCE, resources.type);
323 } 357 }
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 updater.CreateExternalResourcesFromVideoFrame(video_frame); 717 updater.CreateExternalResourcesFromVideoFrame(video_frame);
684 EXPECT_EQ(VideoFrameExternalResources::RGB_RESOURCE, resources.type); 718 EXPECT_EQ(VideoFrameExternalResources::RGB_RESOURCE, resources.type);
685 EXPECT_EQ(1u, resources.mailboxes.size()); 719 EXPECT_EQ(1u, resources.mailboxes.size());
686 EXPECT_EQ((GLenum)GL_TEXTURE_EXTERNAL_OES, resources.mailboxes[0].target()); 720 EXPECT_EQ((GLenum)GL_TEXTURE_EXTERNAL_OES, resources.mailboxes[0].target());
687 EXPECT_EQ(gfx::BufferFormat::YUV_420_BIPLANAR, resources.buffer_format); 721 EXPECT_EQ(gfx::BufferFormat::YUV_420_BIPLANAR, resources.buffer_format);
688 EXPECT_EQ(0, context3d_->TextureCreationCount()); 722 EXPECT_EQ(0, context3d_->TextureCreationCount());
689 } 723 }
690 724
691 } // namespace 725 } // namespace
692 } // namespace cc 726 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/video_resource_updater.cc ('k') | cc/test/test_context_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698