| Index: webrtc/media/base/videoframefactory.cc
|
| diff --git a/webrtc/media/base/videoframefactory.cc b/webrtc/media/base/videoframefactory.cc
|
| index 23925bda56abefb096d71250f0531878478fc532..338daa2174275af167c4bde53dbaba8a34f3c295 100644
|
| --- a/webrtc/media/base/videoframefactory.cc
|
| +++ b/webrtc/media/base/videoframefactory.cc
|
| @@ -15,6 +15,56 @@
|
|
|
| namespace cricket {
|
|
|
| +// For backwards compatiblity, default implementation in terms of old methods.
|
| +// TODO(nisse): Delete when Chrome's subclass is updated.
|
| +std::unique_ptr<VideoFrame> VideoFrameFactory::CreateScaledFrame(
|
| + const CapturedFrame* input_frame,
|
| + int dst_width,
|
| + int dst_height) const {
|
| + // Size of the used portion of the input frame.
|
| + int crop_width = input_frame->width;
|
| + int crop_height = input_frame->height;
|
| +
|
| + // Cropp the input frame, if needed to preserve aspect ratio.
|
| + long aspect_diff = static_cast<long>(crop_width) * dst_height -
|
| + static_cast<long>(crop_height) * dst_width;
|
| + if (aspect_diff > 0) {
|
| + // Horizontal crop.
|
| +
|
| + // TODO(nisse): Old code carried a comment saying that MJPG can
|
| + // only be cropped vertically, and disabled horizontal cropping in
|
| + // that case. Still needed?
|
| + crop_width -= aspect_diff / dst_height;
|
| + RTC_DCHECK(crop_width > 0);
|
| + } else if (aspect_diff < 0) {
|
| + // Vertical crop.
|
| + crop_height -= (-aspect_diff) / dst_width;
|
| + RTC_DCHECK(crop_height > 0);
|
| + }
|
| + return CreateScaledCroppedFrame(
|
| + input_frame,
|
| + (input_frame->width - crop_width) / 2,
|
| + (input_frame->height - crop_height) / 2,
|
| + crop_width, crop_height,
|
| + dst_width, dst_height);
|
| +}
|
| +
|
| +// For backwards compatibility, default implementation in terms of old
|
| +// methods. Ignores the position of the cropping window, and leaves it
|
| +// up to CreateAliasedFrame.
|
| +// TODO(nisse): Delete when Chrome's subclass is updated.
|
| +std::unique_ptr<VideoFrame> VideoFrameFactory::CreateScaledCroppedFrame(
|
| + const CapturedFrame* input_frame,
|
| + int crop_x,
|
| + int crop_y,
|
| + int crop_width,
|
| + int crop_height,
|
| + int dst_width,
|
| + int dst_height) const {
|
| + return std::unique_ptr<VideoFrame>(CreateAliasedFrame(
|
| + input_frame, crop_width, crop_height, dst_width, dst_height));
|
| +}
|
| +
|
| VideoFrame* VideoFrameFactory::CreateAliasedFrame(
|
| const CapturedFrame* input_frame,
|
| int cropped_input_width,
|
|
|