2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
11 #include "webrtc/modules/utility/source/frame_scaler.h"
13 #ifdef WEBRTC_MODULE_UTILITY_VIDEO
15 #include "webrtc/common_video/libyuv/include/scaler.h"
19 FrameScaler::FrameScaler()
20 : scaler_(new Scaler()),
23 FrameScaler::~FrameScaler() {}
25 int FrameScaler::ResizeFrameIfNeeded(I420VideoFrame* video_frame,
28 if (video_frame->IsZeroSize()) {
32 if ((video_frame->width() != out_width) ||
33 (video_frame->height() != out_height)) {
34 // Set correct scale settings and scale |video_frame| into |scaled_frame_|.
35 scaler_->Set(video_frame->width(), video_frame->height(), out_width,
36 out_height, kI420, kI420, kScaleBox);
37 int ret = scaler_->Scale(*video_frame, &scaled_frame_);
42 scaled_frame_.set_render_time_ms(video_frame->render_time_ms());
43 scaled_frame_.set_timestamp(video_frame->timestamp());
44 video_frame->SwapFrame(&scaled_frame_);
51 #endif // WEBRTC_MODULE_UTILITY_VIDEO