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

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

Issue 2481343002: VideoFrame::AllocationSize test against odd values. (Closed)
Patch Set: 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 | « no previous file | media/base/video_frame_unittest.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 (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 <algorithm> 7 #include <algorithm>
8 #include <climits> 8 #include <climits>
9 9
10 #include "base/atomic_sequence_num.h" 10 #include "base/atomic_sequence_num.h"
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 } 508 }
509 509
510 // static 510 // static
511 gfx::Size VideoFrame::PlaneSize(VideoPixelFormat format, 511 gfx::Size VideoFrame::PlaneSize(VideoPixelFormat format,
512 size_t plane, 512 size_t plane,
513 const gfx::Size& coded_size) { 513 const gfx::Size& coded_size) {
514 DCHECK(IsValidPlane(plane, format)); 514 DCHECK(IsValidPlane(plane, format));
515 515
516 int width = coded_size.width(); 516 int width = coded_size.width();
517 int height = coded_size.height(); 517 int height = coded_size.height();
518 if (format != PIXEL_FORMAT_ARGB) { 518 switch (format) {
519 // Align to multiple-of-two size overall. This ensures that non-subsampled 519 case PIXEL_FORMAT_ARGB:
520 // planes can be addressed by pixel with the same scaling as the subsampled 520 case PIXEL_FORMAT_XRGB:
521 // planes. 521 case PIXEL_FORMAT_RGB24:
522 width = RoundUp(width, 2); 522 case PIXEL_FORMAT_RGB32:
523 height = RoundUp(height, 2); 523 case PIXEL_FORMAT_Y8:
524 case PIXEL_FORMAT_Y16:
525 break;
526 default:
DaleCurtis 2016/11/07 21:53:06 Should this just list all the other formats to avo
aleksandar.stojiljkovic 2016/11/07 22:27:25 Done.
527 // Align to multiple-of-two size overall. This ensures that non-subsampled
528 // planes can be addressed by pixel with the same scaling as the
529 // subsampled planes.
530 width = RoundUp(width, 2);
531 height = RoundUp(height, 2);
532 break;
524 } 533 }
525 534
526 const gfx::Size subsample = SampleSize(format, plane); 535 const gfx::Size subsample = SampleSize(format, plane);
527 DCHECK(width % subsample.width() == 0); 536 DCHECK(width % subsample.width() == 0);
528 DCHECK(height % subsample.height() == 0); 537 DCHECK(height % subsample.height() == 0);
529 return gfx::Size(BytesPerElement(format, plane) * width / subsample.width(), 538 return gfx::Size(BytesPerElement(format, plane) * width / subsample.width(),
530 height / subsample.height()); 539 height / subsample.height());
531 } 540 }
532 541
533 // static 542 // static
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 if (zero_initialize_memory) 1118 if (zero_initialize_memory)
1110 memset(data, 0, data_size); 1119 memset(data, 0, data_size);
1111 1120
1112 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) 1121 for (size_t plane = 0; plane < NumPlanes(format_); ++plane)
1113 data_[plane] = data + offset[plane]; 1122 data_[plane] = data + offset[plane];
1114 1123
1115 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); 1124 AddDestructionObserver(base::Bind(&base::AlignedFree, data));
1116 } 1125 }
1117 1126
1118 } // namespace media 1127 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/base/video_frame_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698