Use a temporary buffer to scale a screencast in OnFrameCaptured
BUG=3903 R=sergeyu@chromium.org Review URL: https://webrtc-codereview.appspot.com/23909005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7973 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
4c0544ab07
commit
086c8d5a02
@ -362,6 +362,10 @@ void VideoCapturer::OnFrameCaptured(VideoCapturer*,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#if !defined(DISABLE_YUV)
|
#if !defined(DISABLE_YUV)
|
||||||
|
|
||||||
|
// Use a temporary buffer to scale
|
||||||
|
rtc::scoped_ptr<uint8[]> scale_buffer;
|
||||||
|
|
||||||
if (IsScreencast()) {
|
if (IsScreencast()) {
|
||||||
int scaled_width, scaled_height;
|
int scaled_width, scaled_height;
|
||||||
if (screencast_max_pixels_ > 0) {
|
if (screencast_max_pixels_ > 0) {
|
||||||
@ -388,6 +392,8 @@ void VideoCapturer::OnFrameCaptured(VideoCapturer*,
|
|||||||
}
|
}
|
||||||
CapturedFrame* modified_frame =
|
CapturedFrame* modified_frame =
|
||||||
const_cast<CapturedFrame*>(captured_frame);
|
const_cast<CapturedFrame*>(captured_frame);
|
||||||
|
const int modified_frame_size = scaled_width * scaled_height * 4;
|
||||||
|
scale_buffer.reset(new uint8[modified_frame_size]);
|
||||||
// Compute new width such that width * height is less than maximum but
|
// Compute new width such that width * height is less than maximum but
|
||||||
// maintains original captured frame aspect ratio.
|
// maintains original captured frame aspect ratio.
|
||||||
// Round down width to multiple of 4 so odd width won't round up beyond
|
// Round down width to multiple of 4 so odd width won't round up beyond
|
||||||
@ -396,12 +402,13 @@ void VideoCapturer::OnFrameCaptured(VideoCapturer*,
|
|||||||
libyuv::ARGBScale(reinterpret_cast<const uint8*>(captured_frame->data),
|
libyuv::ARGBScale(reinterpret_cast<const uint8*>(captured_frame->data),
|
||||||
captured_frame->width * 4, captured_frame->width,
|
captured_frame->width * 4, captured_frame->width,
|
||||||
captured_frame->height,
|
captured_frame->height,
|
||||||
reinterpret_cast<uint8*>(modified_frame->data),
|
scale_buffer.get(),
|
||||||
scaled_width * 4, scaled_width, scaled_height,
|
scaled_width * 4, scaled_width, scaled_height,
|
||||||
libyuv::kFilterBilinear);
|
libyuv::kFilterBilinear);
|
||||||
modified_frame->width = scaled_width;
|
modified_frame->width = scaled_width;
|
||||||
modified_frame->height = scaled_height;
|
modified_frame->height = scaled_height;
|
||||||
modified_frame->data_size = scaled_width * 4 * scaled_height;
|
modified_frame->data_size = scaled_width * 4 * scaled_height;
|
||||||
|
modified_frame->data = scale_buffer.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user