2014-09-12 11:51:47 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef WEBRTC_MODULES_VIDEO_CODING_UTILITY_QUALITY_SCALER_H_
|
|
|
|
|
#define WEBRTC_MODULES_VIDEO_CODING_UTILITY_QUALITY_SCALER_H_
|
|
|
|
|
|
|
|
|
|
#include "webrtc/common_video/libyuv/include/scaler.h"
|
2015-04-21 15:30:11 -07:00
|
|
|
#include "webrtc/modules/video_coding/utility/include/moving_average.h"
|
2014-09-12 11:51:47 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
2015-05-21 11:12:02 -07:00
|
|
|
const int kDefaultLowQpDenominator = 3;
|
2014-09-12 11:51:47 +00:00
|
|
|
class QualityScaler {
|
|
|
|
|
public:
|
|
|
|
|
struct Resolution {
|
|
|
|
|
int width;
|
|
|
|
|
int height;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
QualityScaler();
|
2015-05-21 11:12:02 -07:00
|
|
|
void Init(int low_qp_threshold);
|
2015-04-21 15:30:11 -07:00
|
|
|
void SetMinResolution(int min_width, int min_height);
|
2014-09-12 11:51:47 +00:00
|
|
|
void ReportFramerate(int framerate);
|
2015-05-21 11:12:02 -07:00
|
|
|
void ReportQP(int qp);
|
2015-04-21 15:30:11 -07:00
|
|
|
void ReportDroppedFrame();
|
|
|
|
|
void Reset(int framerate, int bitrate, int width, int height);
|
2014-09-12 11:51:47 +00:00
|
|
|
Resolution GetScaledResolution(const I420VideoFrame& frame);
|
|
|
|
|
const I420VideoFrame& GetScaledFrame(const I420VideoFrame& frame);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void AdjustScale(bool up);
|
|
|
|
|
void ClearSamples();
|
|
|
|
|
|
|
|
|
|
Scaler scaler_;
|
|
|
|
|
I420VideoFrame scaled_frame_;
|
|
|
|
|
|
|
|
|
|
size_t num_samples_;
|
|
|
|
|
int low_qp_threshold_;
|
2015-04-21 15:30:11 -07:00
|
|
|
MovingAverage<int> framedrop_percent_;
|
2015-05-21 11:12:02 -07:00
|
|
|
MovingAverage<int> average_qp_;
|
2014-09-12 11:51:47 +00:00
|
|
|
|
|
|
|
|
int downscale_shift_;
|
2015-04-21 15:30:11 -07:00
|
|
|
int min_width_;
|
|
|
|
|
int min_height_;
|
2014-09-12 11:51:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
|
|
|
|
#endif // WEBRTC_MODULES_VIDEO_CODING_UTILITY_QUALITY_SCALER_H_
|