Index: media/base/video_frame.cc |
diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc |
index 3d764103f1965397fd1fff8c26d24f63df827609..2374638ac6784bf88014241fd04770a4779c2630 100644 |
--- a/media/base/video_frame.cc |
+++ b/media/base/video_frame.cc |
@@ -4,6 +4,7 @@ |
#include "media/base/video_frame.h" |
+#include "base/bits.h" |
#include "base/logging.h" |
#include "base/string_piece.h" |
#include "media/base/limits.h" |
@@ -113,12 +114,6 @@ scoped_refptr<VideoFrame> VideoFrame::CreateBlackFrame(const gfx::Size& size) { |
return CreateColorFrame(size, kBlackY, kBlackUV, kBlackUV, kZero); |
} |
-static inline size_t RoundUp(size_t value, size_t alignment) { |
- // Check that |alignment| is a power of 2. |
- DCHECK((alignment + (alignment - 1)) == (alignment | (alignment - 1))); |
- return ((value + (alignment - 1)) & ~(alignment-1)); |
-} |
- |
static const int kFrameSizeAlignment = 16; |
// Allows faster SIMD YUV convert. Also, FFmpeg overreads/-writes occasionally. |
static const int kFramePadBytes = 15; |
@@ -126,9 +121,10 @@ static const int kFramePadBytes = 15; |
void VideoFrame::AllocateRGB(size_t bytes_per_pixel) { |
// Round up to align at least at a 16-byte boundary for each row. |
// This is sufficient for MMX and SSE2 reads (movq/movdqa). |
- size_t bytes_per_row = RoundUp(coded_size_.width(), |
- kFrameSizeAlignment) * bytes_per_pixel; |
- size_t aligned_height = RoundUp(coded_size_.height(), kFrameSizeAlignment); |
+ size_t bytes_per_row = base::bits::RoundUp( |
+ coded_size_.width(), kFrameSizeAlignment) * bytes_per_pixel; |
+ size_t aligned_height = base::bits::RoundUp( |
+ coded_size_.height(), kFrameSizeAlignment); |
strides_[VideoFrame::kRGBPlane] = bytes_per_row; |
#if !defined(OS_ANDROID) |
// TODO(dalecurtis): use DataAligned or so, so this #ifdef hackery |
@@ -153,14 +149,15 @@ void VideoFrame::AllocateYUV() { |
// number to avoid any potential of faulting by code that attempts to access |
// the Y values of the final row, but assumes that the last row of U & V |
// applies to a full two rows of Y. |
- size_t y_stride = RoundUp(row_bytes(VideoFrame::kYPlane), |
- kFrameSizeAlignment); |
- size_t uv_stride = RoundUp(row_bytes(VideoFrame::kUPlane), |
- kFrameSizeAlignment); |
+ size_t y_stride = base::bits::RoundUp(row_bytes(VideoFrame::kYPlane), |
+ kFrameSizeAlignment); |
+ size_t uv_stride = base::bits::RoundUp(row_bytes(VideoFrame::kUPlane), |
+ kFrameSizeAlignment); |
// The *2 here is because some formats (e.g. h264) allow interlaced coding, |
// and then the size needs to be a multiple of two macroblocks (vertically). |
// See libavcodec/utils.c:avcodec_align_dimensions2(). |
- size_t y_height = RoundUp(coded_size_.height(), kFrameSizeAlignment * 2); |
+ size_t y_height = base::bits::RoundUp(coded_size_.height(), |
+ kFrameSizeAlignment * 2); |
size_t uv_height = format_ == VideoFrame::YV12 ? y_height / 2 : y_height; |
size_t y_bytes = y_height * y_stride; |
size_t uv_bytes = uv_height * uv_stride; |
@@ -260,7 +257,7 @@ int VideoFrame::row_bytes(size_t plane) const { |
case YV16: |
if (plane == kYPlane) |
return width; |
- return RoundUp(width, 2) / 2; |
+ return base::bits::RoundUp(width, 2) / 2; |
default: |
break; |
@@ -282,7 +279,7 @@ int VideoFrame::rows(size_t plane) const { |
case YV12: |
if (plane == kYPlane) |
return height; |
- return RoundUp(height, 2) / 2; |
+ return base::bits::RoundUp(height, 2) / 2; |
default: |
break; |