Index: cc/resources/video_resource_updater.cc |
diff --git a/cc/resources/video_resource_updater.cc b/cc/resources/video_resource_updater.cc |
index c35d5d4273db362f72fb00b5fed805019470d5b3..c7fb815408544be4681c1b57ff1f2bff3bd0550b 100644 |
--- a/cc/resources/video_resource_updater.cc |
+++ b/cc/resources/video_resource_updater.cc |
@@ -69,6 +69,9 @@ VideoFrameExternalResources::ResourceType ResourceTypeForVideoFrame( |
break; |
} |
break; |
+ case media::PIXEL_FORMAT_Y16: |
+ return VideoFrameExternalResources::Y_RESOURCE; |
+ break; |
case media::PIXEL_FORMAT_YV12: |
case media::PIXEL_FORMAT_YV16: |
case media::PIXEL_FORMAT_YV24: |
@@ -89,7 +92,6 @@ VideoFrameExternalResources::ResourceType ResourceTypeForVideoFrame( |
case media::PIXEL_FORMAT_YUV422P12: |
case media::PIXEL_FORMAT_YUV444P12: |
case media::PIXEL_FORMAT_Y8: |
- case media::PIXEL_FORMAT_Y16: |
case media::PIXEL_FORMAT_UNKNOWN: |
break; |
} |
@@ -312,7 +314,6 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForSoftwarePlanes( |
scoped_refptr<media::VideoFrame> video_frame) { |
TRACE_EVENT0("cc", "VideoResourceUpdater::CreateForSoftwarePlanes"); |
const media::VideoPixelFormat input_frame_format = video_frame->format(); |
- |
// TODO(hubbe): Make this a video frame method. |
int bits_per_channel = 0; |
switch (input_frame_format) { |
@@ -357,11 +358,9 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForSoftwarePlanes( |
break; |
} |
- // TODO(dshwang): support PIXEL_FORMAT_Y16. crbug.com/624436 |
- DCHECK_NE(bits_per_channel, 16); |
- |
- // Only YUV software video frames are supported. |
- if (!media::IsYuvPlanar(input_frame_format)) { |
+ // Only YUV and Y16 software video frames are supported. |
+ const bool isYuvPlanar = media::IsYuvPlanar(input_frame_format); |
+ if (!(isYuvPlanar || input_frame_format == media::PIXEL_FORMAT_Y16)) { |
NOTREACHED() << media::VideoPixelFormatToString(input_frame_format); |
return VideoFrameExternalResources(); |
} |
@@ -369,7 +368,9 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForSoftwarePlanes( |
const bool software_compositor = context_provider_ == NULL; |
ResourceFormat output_resource_format = |
- resource_provider_->YuvResourceFormat(bits_per_channel); |
+ (input_frame_format == media::PIXEL_FORMAT_Y16) |
+ ? resource_provider_->Y16ResourceFormat() |
+ : resource_provider_->YuvResourceFormat(bits_per_channel); |
// If GPU compositing is enabled, but the output resource format |
// returned by the resource provider is RGBA_8888, then a GPU driver |
@@ -377,7 +378,8 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForSoftwarePlanes( |
// before texture upload. |
bool texture_needs_rgb_conversion = |
!software_compositor && |
- output_resource_format == ResourceFormat::RGBA_8888; |
+ output_resource_format == ResourceFormat::RGBA_8888 && |
+ input_frame_format != media::PIXEL_FORMAT_Y16; |
size_t output_plane_count = media::VideoFrame::NumPlanes(input_frame_format); |
// TODO(skaslev): If we're in software compositing mode, we do the YUV -> RGB |
@@ -486,8 +488,7 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForSoftwarePlanes( |
for (size_t i = 0; i < plane_resources.size(); ++i) { |
PlaneResource& plane_resource = *plane_resources[i]; |
// Update each plane's resource id with its content. |
- DCHECK_EQ(plane_resource.resource_format(), |
- resource_provider_->YuvResourceFormat(bits_per_channel)); |
+ DCHECK_EQ(plane_resource.resource_format(), output_resource_format); |
if (!plane_resource.Matches(video_frame->unique_id(), i)) { |
// TODO(hubbe): Move all conversion (and upload?) code to media/. |
@@ -542,6 +543,9 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForSoftwarePlanes( |
// 2 << 11 = 2048 would be 1.0 with our exponent. |
external_resources.multiplier = 2048.0 / max_input_value; |
} |
+ } else if (input_frame_format == media::PIXEL_FORMAT_Y16) { |
+ if (plane_resource.resource_format() == RGBA_8888) |
+ needs_conversion = true; |
} else if (bits_per_channel > 8) { |
// If bits_per_channel > 8 and we can't use LUMINANCE_F16, we need to |
// shift the data down and create an 8-bit texture. |
@@ -584,6 +588,14 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForSoftwarePlanes( |
video_frame->data(i) + (video_stride_bytes * row)); |
for (size_t i = 0; i < bytes_per_row; i++) |
dst[i] = src[i] >> shift; |
+ } else if (input_frame_format == media::PIXEL_FORMAT_Y16 && |
+ plane_resource.resource_format() == RGBA_8888) { |
+ uint32_t* dst = reinterpret_cast<uint32_t*>( |
+ &upload_pixels_[upload_image_stride * row]); |
+ const uint16_t* src = reinterpret_cast<uint16_t*>( |
+ video_frame->data(i) + (video_stride_bytes * row)); |
+ for (size_t i = 0; i < bytes_per_row / 4; ++i) |
+ *dst++ = *src++; |
} else { |
// Input and output are the same size and format, but |
// differ in stride, copy one row at a time. |
@@ -613,7 +625,9 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForSoftwarePlanes( |
&RecycleResource, AsWeakPtr(), plane_resource.resource_id())); |
} |
- external_resources.type = VideoFrameExternalResources::YUV_RESOURCE; |
+ external_resources.type = (input_frame_format == media::PIXEL_FORMAT_Y16) |
+ ? VideoFrameExternalResources::Y_RESOURCE |
+ : VideoFrameExternalResources::YUV_RESOURCE; |
return external_resources; |
} |
@@ -730,6 +744,9 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes( |
base::Bind(&ReturnTexture, AsWeakPtr(), video_frame)); |
} |
} |
+ |
+ external_resources.bits_per_channel = |
+ (video_frame->format() == media::PIXEL_FORMAT_Y16) ? 16 : 8; |
return external_resources; |
} |