aboutsummaryrefslogtreecommitdiff
path: root/vp9/ratectrl_rtc.h
diff options
context:
space:
mode:
Diffstat (limited to 'vp9/ratectrl_rtc.h')
-rw-r--r--vp9/ratectrl_rtc.h66
1 files changed, 24 insertions, 42 deletions
diff --git a/vp9/ratectrl_rtc.h b/vp9/ratectrl_rtc.h
index b209e4db6..85005c547 100644
--- a/vp9/ratectrl_rtc.h
+++ b/vp9/ratectrl_rtc.h
@@ -14,22 +14,20 @@
#include <cstdint>
#include <memory>
-#include "vp9/common/vp9_entropymode.h"
#include "vp9/common/vp9_enums.h"
-#include "vp9/common/vp9_onyxc_int.h"
#include "vp9/vp9_iface_common.h"
#include "vp9/encoder/vp9_aq_cyclicrefresh.h"
-#include "vp9/encoder/vp9_encoder.h"
-#include "vp9/encoder/vp9_firstpass.h"
#include "vp9/vp9_cx_iface.h"
#include "vpx/internal/vpx_ratectrl_rtc.h"
#include "vpx_mem/vpx_mem.h"
-namespace libvpx {
+struct VP9_COMP;
+namespace libvpx {
struct VP9RateControlRtcConfig : public VpxRateControlRtcConfig {
public:
VP9RateControlRtcConfig() {
+ ss_number_layers = 1;
vp9_zero(max_quantizers);
vp9_zero(min_quantizers);
vp9_zero(scaling_factor_den);
@@ -40,20 +38,21 @@ struct VP9RateControlRtcConfig : public VpxRateControlRtcConfig {
scaling_factor_den[0] = 1;
max_quantizers[0] = max_quantizer;
min_quantizers[0] = min_quantizer;
+ max_consec_drop = INT_MAX;
}
// Number of spatial layers
int ss_number_layers;
- // Number of temporal layers
- int ts_number_layers;
int max_quantizers[VPX_MAX_LAYERS];
int min_quantizers[VPX_MAX_LAYERS];
int scaling_factor_num[VPX_SS_MAX_LAYERS];
int scaling_factor_den[VPX_SS_MAX_LAYERS];
+ // This is only for SVC for now.
+ int max_consec_drop;
};
struct VP9FrameParamsQpRTC {
- FRAME_TYPE frame_type;
+ RcFrameType frame_type;
int spatial_layer_id;
int temporal_layer_id;
};
@@ -69,63 +68,46 @@ struct VP9SegmentationData {
// the encoder. To use this interface, you need to link with libvpxrc.a.
//
// #include "vp9/ratectrl_rtc.h"
-// VP9RateControlRTC rc_api;
// VP9RateControlRtcConfig cfg;
// VP9FrameParamsQpRTC frame_params;
//
// YourFunctionToInitializeConfig(cfg);
-// rc_api.InitRateControl(cfg);
+// std::unique_ptr<VP9RateControlRTC> rc_api = VP9RateControlRTC::Create(cfg);
// // start encoding
// while (frame_to_encode) {
// if (config_changed)
-// rc_api.UpdateRateControl(cfg);
+// rc_api->UpdateRateControl(cfg);
// YourFunctionToFillFrameParams(frame_params);
-// rc_api.ComputeQP(frame_params);
-// YourFunctionToUseQP(rc_api.GetQP());
-// YourFunctionToUseLoopfilter(rc_api.GetLoopfilterLevel());
+// rc_api->ComputeQP(frame_params);
+// YourFunctionToUseQP(rc_api->GetQP());
+// YourFunctionToUseLoopfilter(rc_api->GetLoopfilterLevel());
// // After encoding
-// rc_api.PostEncode(encoded_frame_size);
+// rc_api->PostEncode(encoded_frame_size, frame_params);
// }
class VP9RateControlRTC {
public:
static std::unique_ptr<VP9RateControlRTC> Create(
const VP9RateControlRtcConfig &cfg);
- ~VP9RateControlRTC() {
- if (cpi_) {
- if (cpi_->svc.number_spatial_layers > 1 ||
- cpi_->svc.number_temporal_layers > 1) {
- for (int sl = 0; sl < cpi_->svc.number_spatial_layers; sl++) {
- for (int tl = 0; tl < cpi_->svc.number_temporal_layers; tl++) {
- int layer = LAYER_IDS_TO_IDX(sl, tl, cpi_->oxcf.ts_number_layers);
- LAYER_CONTEXT *const lc = &cpi_->svc.layer_context[layer];
- vpx_free(lc->map);
- vpx_free(lc->last_coded_q_map);
- vpx_free(lc->consec_zero_mv);
- }
- }
- }
- if (cpi_->oxcf.aq_mode == CYCLIC_REFRESH_AQ) {
- vpx_free(cpi_->segmentation_map);
- cpi_->segmentation_map = NULL;
- vp9_cyclic_refresh_free(cpi_->cyclic_refresh);
- }
- vpx_free(cpi_);
- }
- }
+ ~VP9RateControlRTC();
- void UpdateRateControl(const VP9RateControlRtcConfig &rc_cfg);
+ bool UpdateRateControl(const VP9RateControlRtcConfig &rc_cfg);
// GetQP() needs to be called after ComputeQP() to get the latest QP
int GetQP() const;
int GetLoopfilterLevel() const;
bool GetSegmentationData(VP9SegmentationData *segmentation_data) const;
- void ComputeQP(const VP9FrameParamsQpRTC &frame_params);
+ // ComputeQP computes the QP if the frame is not dropped (kOk return),
+ // otherwise it returns kDrop and subsequent GetQP and PostEncodeUpdate
+ // are not to be called (vp9_rc_postencode_update_drop_frame is already
+ // called via ComputeQP if drop is decided).
+ FrameDropDecision ComputeQP(const VP9FrameParamsQpRTC &frame_params);
// Feedback to rate control with the size of current encoded frame
- void PostEncodeUpdate(uint64_t encoded_frame_size);
+ void PostEncodeUpdate(uint64_t encoded_frame_size,
+ const VP9FrameParamsQpRTC &frame_params);
private:
VP9RateControlRTC() {}
- void InitRateControl(const VP9RateControlRtcConfig &cfg);
- VP9_COMP *cpi_;
+ bool InitRateControl(const VP9RateControlRtcConfig &cfg);
+ struct VP9_COMP *cpi_;
};
} // namespace libvpx