Chromium Code Reviews| Index: media/base/video_frame.cc |
| diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc |
| index 71bdcf4eb208ba904721d74f503102d868cd7ceb..0137932b69a6444df2f38283ff0be6556b285893 100644 |
| --- a/media/base/video_frame.cc |
| +++ b/media/base/video_frame.cc |
| @@ -31,6 +31,7 @@ scoped_refptr<VideoFrame> VideoFrame::CreateFrame( |
| frame->AllocateRGB(4u); |
| break; |
| case VideoFrame::YV12: |
| + case VideoFrame::YV12A: |
| case VideoFrame::YV16: |
| frame->AllocateYUV(); |
| break; |
| @@ -163,7 +164,8 @@ void VideoFrame::AllocateRGB(size_t bytes_per_pixel) { |
| } |
| void VideoFrame::AllocateYUV() { |
| - DCHECK(format_ == VideoFrame::YV12 || format_ == VideoFrame::YV16); |
| + DCHECK(format_ == VideoFrame::YV12 || format_ == VideoFrame::YV16 |
| + || format_ == VideoFrame::YV12A); |
|
fgalligan1
2013/02/12 01:20:58
Logical operators are typically at the end of the
vigneshv
2013/02/14 19:06:14
Done.
|
| // Align Y rows at least at 16 byte boundaries. The stride for both |
| // YV12 and YV16 is 1/2 of the stride of Y. For YV12, every row of bytes for |
| // U and V applies to two rows of Y (one byte of UV for 4 bytes of Y), so in |
| @@ -172,7 +174,10 @@ void VideoFrame::AllocateYUV() { |
| // YV16. We also round the height of the surface allocated to be an even |
| // 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. |
| + // applies to a full two rows of Y. YV12A is the same as YV12 but with a |
| + // following alpha plane that is aligned and sized in the same manner as the |
| + // Y plane. |
| + |
| size_t y_stride = RoundUp(row_bytes(VideoFrame::kYPlane), |
| kFrameSizeAlignment); |
| size_t uv_stride = RoundUp(row_bytes(VideoFrame::kUPlane), |
| @@ -181,9 +186,12 @@ void VideoFrame::AllocateYUV() { |
| // 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 uv_height = format_ == VideoFrame::YV12 ? y_height / 2 : y_height; |
| + size_t uv_height = (format_ == VideoFrame::YV12 |
| + || format_ == VideoFrame::YV12A) ? |
|
fgalligan1
2013/02/12 01:20:58
Logical operators are typically at the end of the
vigneshv
2013/02/14 19:06:14
Done.
|
| + y_height / 2 : y_height; |
|
fgalligan1
2013/02/12 01:20:58
indent 4
vigneshv
2013/02/14 19:06:14
Done.
|
| size_t y_bytes = y_height * y_stride; |
| size_t uv_bytes = uv_height * uv_stride; |
| + size_t a_bytes = format_ == VideoFrame::YV12A ? y_bytes : 0; |
| // The extra line of UV being allocated is because h264 chroma MC |
| // overreads by one line in some cases, see libavcodec/utils.c: |
| @@ -191,7 +199,7 @@ void VideoFrame::AllocateYUV() { |
| // put_h264_chroma_mc4_ssse3(). |
| uint8* data = reinterpret_cast<uint8*>( |
| base::AlignedAlloc( |
| - y_bytes + (uv_bytes * 2 + uv_stride) + kFrameSizePadding, |
| + y_bytes + (uv_bytes * 2 + uv_stride) + a_bytes + kFrameSizePadding, |
| kFrameAddressAlignment)); |
| no_longer_needed_cb_ = base::Bind(&ReleaseData, data); |
| COMPILE_ASSERT(0 == VideoFrame::kYPlane, y_plane_data_must_be_index_0); |
| @@ -201,6 +209,10 @@ void VideoFrame::AllocateYUV() { |
| strides_[VideoFrame::kYPlane] = y_stride; |
| strides_[VideoFrame::kUPlane] = uv_stride; |
| strides_[VideoFrame::kVPlane] = uv_stride; |
| + if(format_ == YV12A) { |
|
fgalligan1
2013/02/12 01:20:58
nit: space between if and (
vigneshv
2013/02/14 19:06:14
Done.
|
| + data_[VideoFrame::kAPlane] = data + y_bytes + (2 * uv_bytes); |
| + strides_[VideoFrame::kAPlane] = y_stride; |
| + } |
| } |
| VideoFrame::VideoFrame(VideoFrame::Format format, |
| @@ -233,6 +245,10 @@ bool VideoFrame::IsValidPlane(size_t plane) const { |
| case YV16: |
| return plane == kYPlane || plane == kUPlane || plane == kVPlane; |
| + case YV12A: |
| + return plane == kYPlane || plane == kUPlane || plane == kVPlane || |
| + plane == kAPlane; |
|
fgalligan1
2013/02/12 01:20:58
nit: 4 space indent
vigneshv
2013/02/14 19:06:14
Done.
|
| + |
| case NATIVE_TEXTURE: |
| NOTREACHED() << "NATIVE_TEXTUREs don't use plane-related methods!"; |
| return false; |
| @@ -262,7 +278,8 @@ int VideoFrame::row_bytes(size_t plane) const { |
| // Planar, 8bpp. |
| case YV12: |
| case YV16: |
| - if (plane == kYPlane) |
| + case YV12A: |
| + if (plane == kYPlane || plane == kAPlane) |
| return width; |
| return RoundUp(width, 2) / 2; |
| @@ -284,7 +301,8 @@ int VideoFrame::rows(size_t plane) const { |
| return height; |
| case YV12: |
| - if (plane == kYPlane) |
| + case YV12A: |
| + if (plane == kYPlane || plane == kAPlane) |
| return height; |
| return RoundUp(height, 2) / 2; |