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

Unified Diff: cc/resources/video_resource_updater.cc

Issue 2121043002: 16 bpp video stream capture, render and WebGL usage - Realsense R200 & SR300 support. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 2 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/resources/video_resource_updater.h ('k') | cc/test/data/intersecting_light_dark_squares_video.png » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/video_resource_updater.cc
diff --git a/cc/resources/video_resource_updater.cc b/cc/resources/video_resource_updater.cc
index 9fe434f3837211b63d4ded74b8b39ced0a398b20..adb1495bc6e55c112abade8976bef4de0f1e0dc0 100644
--- a/cc/resources/video_resource_updater.cc
+++ b/cc/resources/video_resource_updater.cc
@@ -70,6 +70,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:
@@ -90,7 +93,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;
}
@@ -313,7 +315,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) {
@@ -358,11 +359,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();
}
@@ -370,7 +369,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
@@ -378,7 +379,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
@@ -487,8 +489,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/.
@@ -515,6 +516,9 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForSoftwarePlanes(
// LUMINANCE_F16 uses half-floats, so we always need a conversion step.
if (plane_resource.resource_format() == LUMINANCE_F16) {
needs_conversion = true;
+ } 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.
@@ -557,6 +561,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.
@@ -615,7 +627,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;
}
@@ -732,6 +746,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;
}
« no previous file with comments | « cc/resources/video_resource_updater.h ('k') | cc/test/data/intersecting_light_dark_squares_video.png » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698