summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwjia@chromium.org <wjia@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-19 18:43:28 +0000
committerwjia@chromium.org <wjia@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-19 18:43:28 +0000
commita14ee988dc90dede8e2852df18e527bf51eae928 (patch)
tree9f097a726129fc94b8af76bada86d30c5198bf90
parentf646080602203a48f56882e2548baabe82c28604 (diff)
downloadchromium_src-a14ee988dc90dede8e2852df18e527bf51eae928.zip
chromium_src-a14ee988dc90dede8e2852df18e527bf51eae928.tar.gz
chromium_src-a14ee988dc90dede8e2852df18e527bf51eae928.tar.bz2
Use libyuv::ConvertToI420 for all color formats in video capture on WIN
Reland https://codereview.chromium.org/116573005/ with fix for android_aosp build. Since libyuv has added support for image flipping (vertically) with negative src_height as indicator, we'd converge all color formats into one code path. And libyuv provides better performance. BUG= R=ronghuawu@chromium.org Review URL: https://codereview.chromium.org/118653004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@241894 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/browser/renderer_host/media/video_capture_controller.cc67
1 files changed, 25 insertions, 42 deletions
diff --git a/content/browser/renderer_host/media/video_capture_controller.cc b/content/browser/renderer_host/media/video_capture_controller.cc
index 1840af2..37aa27e 100644
--- a/content/browser/renderer_host/media/video_capture_controller.cc
+++ b/content/browser/renderer_host/media/video_capture_controller.cc
@@ -304,6 +304,7 @@ void VideoCaptureController::VideoCaptureDeviceClient::OnIncomingCapturedFrame(
if (!buffer)
return;
#if !defined(AVOID_LIBYUV_FOR_ANDROID_WEBVIEW)
+ bool flip = false;
uint8* yplane = reinterpret_cast<uint8*>(buffer->data());
uint8* uplane =
yplane +
@@ -352,6 +353,13 @@ void VideoCaptureController::VideoCaptureDeviceClient::OnIncomingCapturedFrame(
break;
case media::PIXEL_FORMAT_RGB24:
origin_colorspace = libyuv::FOURCC_RAW;
+#if defined(OS_WIN)
+ // TODO(wjia): Currently, for RGB24 on WIN, capture device always
+ // passes in positive src_width and src_height. Remove this hardcoded
+ // value when nagative src_height is supported. The negative src_height
+ // indicates that vertical flipping is needed.
+ flip = true;
+#endif
break;
case media::PIXEL_FORMAT_ARGB:
origin_colorspace = libyuv::FOURCC_ARGB;
@@ -363,48 +371,23 @@ void VideoCaptureController::VideoCaptureDeviceClient::OnIncomingCapturedFrame(
NOTREACHED();
}
- int need_convert_rgb24_on_win = false;
-#if defined(OS_WIN)
- // TODO(wjia): Use libyuv::ConvertToI420 since support for image inversion
- // (vertical flipping) has been added. Use negative src_height as indicator.
- if (frame_format.pixel_format == media::PIXEL_FORMAT_RGB24) {
- // Rotation is not supported in kRGB24 and OS_WIN case.
- DCHECK(!rotation);
- need_convert_rgb24_on_win = true;
- }
-#endif
- if (need_convert_rgb24_on_win) {
- int rgb_stride = -3 * (new_unrotated_width + chopped_width);
- const uint8* rgb_src =
- data + 3 * (new_unrotated_width + chopped_width) *
- (new_unrotated_height - 1 + chopped_height);
- media::ConvertRGB24ToYUV(rgb_src,
- yplane,
- uplane,
- vplane,
- new_unrotated_width,
- new_unrotated_height,
- rgb_stride,
- yplane_stride,
- uv_plane_stride);
- } else {
- libyuv::ConvertToI420(data,
- length,
- yplane,
- yplane_stride,
- uplane,
- uv_plane_stride,
- vplane,
- uv_plane_stride,
- crop_x,
- crop_y,
- new_unrotated_width + chopped_width,
- new_unrotated_height,
- new_unrotated_width,
- new_unrotated_height,
- rotation_mode,
- origin_colorspace);
- }
+ libyuv::ConvertToI420(data,
+ length,
+ yplane,
+ yplane_stride,
+ uplane,
+ uv_plane_stride,
+ vplane,
+ uv_plane_stride,
+ crop_x,
+ crop_y,
+ frame_format.frame_size.width(),
+ (flip ? -frame_format.frame_size.height() :
+ frame_format.frame_size.height()),
+ new_unrotated_width,
+ new_unrotated_height,
+ rotation_mode,
+ origin_colorspace);
#else
// Libyuv is not linked in for Android WebView builds, but video capture is
// not used in those builds either. Whenever libyuv is added in that build,