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

Side by Side Diff: media/base/video_frame_unittest.cc

Issue 2481343002: VideoFrame::AllocationSize test against odd values. (Closed)
Patch Set: #10 fix. Thanks DaleCurtis@. Created 4 years, 1 month 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/base/video_frame.cc ('k') | no next file » | 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 #include "media/base/video_frame.h" 5 #include "media/base/video_frame.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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 // Next create a frame that does not sub-sample UV. 422 // Next create a frame that does not sub-sample UV.
423 frame = VideoFrame::CreateFrame(PIXEL_FORMAT_YV24, odd_size, 423 frame = VideoFrame::CreateFrame(PIXEL_FORMAT_YV24, odd_size,
424 gfx::Rect(odd_size), odd_size, kTimestamp); 424 gfx::Rect(odd_size), odd_size, kTimestamp);
425 ASSERT_TRUE(frame.get()); 425 ASSERT_TRUE(frame.get());
426 // No sub-sampling for YV24 will mean odd width can remain odd since any pixel 426 // No sub-sampling for YV24 will mean odd width can remain odd since any pixel
427 // in the Y plane has a a corresponding pixel in the UV planes at the same 427 // in the Y plane has a a corresponding pixel in the UV planes at the same
428 // index. 428 // index.
429 EXPECT_EQ(677, frame->coded_size().width()); 429 EXPECT_EQ(677, frame->coded_size().width());
430 } 430 }
431 431
432 TEST(VideoFrame, AllocationSize_OddSize) {
433 const gfx::Size size(3, 5);
434 for (unsigned int i = 1u; i <= PIXEL_FORMAT_MAX; ++i) {
435 const VideoPixelFormat format = static_cast<VideoPixelFormat>(i);
436 const size_t allocation_size = VideoFrame::AllocationSize(format, size);
437 switch (format) {
438 case PIXEL_FORMAT_YUV444P9:
439 case PIXEL_FORMAT_YUV444P10:
440 case PIXEL_FORMAT_YUV444P12:
441 EXPECT_EQ(144u, allocation_size) << VideoPixelFormatToString(format);
442 break;
443 case PIXEL_FORMAT_YUV422P9:
444 case PIXEL_FORMAT_YUV422P10:
445 case PIXEL_FORMAT_YUV422P12:
446 EXPECT_EQ(96u, allocation_size) << VideoPixelFormatToString(format);
447 break;
448 case PIXEL_FORMAT_YV24:
449 case PIXEL_FORMAT_YUV420P9:
450 case PIXEL_FORMAT_YUV420P10:
451 case PIXEL_FORMAT_YUV420P12:
452 EXPECT_EQ(72u, allocation_size) << VideoPixelFormatToString(format);
453 break;
454 case PIXEL_FORMAT_UYVY:
455 case PIXEL_FORMAT_YUY2:
456 case PIXEL_FORMAT_YV16:
457 EXPECT_EQ(48u, allocation_size) << VideoPixelFormatToString(format);
458 break;
459 case PIXEL_FORMAT_YV12:
460 case PIXEL_FORMAT_I420:
461 case PIXEL_FORMAT_NV12:
462 case PIXEL_FORMAT_NV21:
463 case PIXEL_FORMAT_MT21:
464 EXPECT_EQ(36u, allocation_size) << VideoPixelFormatToString(format);
465 break;
466 case PIXEL_FORMAT_ARGB:
467 case PIXEL_FORMAT_XRGB:
468 case PIXEL_FORMAT_YV12A:
469 case PIXEL_FORMAT_RGB32:
470 EXPECT_EQ(60u, allocation_size) << VideoPixelFormatToString(format);
471 break;
472 case PIXEL_FORMAT_RGB24:
473 EXPECT_EQ(45u, allocation_size) << VideoPixelFormatToString(format);
474 break;
475 case PIXEL_FORMAT_Y16:
476 EXPECT_EQ(30u, allocation_size) << VideoPixelFormatToString(format);
477 break;
478 case PIXEL_FORMAT_Y8:
479 EXPECT_EQ(15u, allocation_size) << VideoPixelFormatToString(format);
480 break;
481 case PIXEL_FORMAT_MJPEG:
482 case PIXEL_FORMAT_UNKNOWN:
483 break;
484 }
485 }
486 }
487
432 TEST(VideoFrameMetadata, SetAndThenGetAllKeysForAllTypes) { 488 TEST(VideoFrameMetadata, SetAndThenGetAllKeysForAllTypes) {
433 VideoFrameMetadata metadata; 489 VideoFrameMetadata metadata;
434 490
435 for (int i = 0; i < VideoFrameMetadata::NUM_KEYS; ++i) { 491 for (int i = 0; i < VideoFrameMetadata::NUM_KEYS; ++i) {
436 const VideoFrameMetadata::Key key = static_cast<VideoFrameMetadata::Key>(i); 492 const VideoFrameMetadata::Key key = static_cast<VideoFrameMetadata::Key>(i);
437 493
438 EXPECT_FALSE(metadata.HasKey(key)); 494 EXPECT_FALSE(metadata.HasKey(key));
439 metadata.SetBoolean(key, true); 495 metadata.SetBoolean(key, true);
440 EXPECT_TRUE(metadata.HasKey(key)); 496 EXPECT_TRUE(metadata.HasKey(key));
441 bool bool_value = false; 497 bool bool_value = false;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 561
506 for (int i = 0; i < VideoFrameMetadata::NUM_KEYS; ++i) { 562 for (int i = 0; i < VideoFrameMetadata::NUM_KEYS; ++i) {
507 const VideoFrameMetadata::Key key = static_cast<VideoFrameMetadata::Key>(i); 563 const VideoFrameMetadata::Key key = static_cast<VideoFrameMetadata::Key>(i);
508 int value = -1; 564 int value = -1;
509 EXPECT_TRUE(result.GetInteger(key, &value)); 565 EXPECT_TRUE(result.GetInteger(key, &value));
510 EXPECT_EQ(i, value); 566 EXPECT_EQ(i, value);
511 } 567 }
512 } 568 }
513 569
514 } // namespace media 570 } // namespace media
OLDNEW
« no previous file with comments | « media/base/video_frame.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698