encoder->Control(VP8E_SET_CPUUSED, -6);
encoder->Control(VP8E_SET_RTC_EXTERNAL_RATECTRL, 1);
encoder->Control(VP8E_SET_MAX_INTRA_BITRATE_PCT, 1000);
- } else if (frame_params_.frame_type == INTER_FRAME) {
+ } else if (frame_params_.frame_type == libvpx::RcFrameType::kInterFrame) {
// Disable golden frame update.
frame_flags_ |= VP8_EFLAG_NO_UPD_GF;
frame_flags_ |= VP8_EFLAG_NO_UPD_ARF;
}
}
- frame_params_.frame_type =
- video->frame() % key_interval_ == 0 ? KEY_FRAME : INTER_FRAME;
+ frame_params_.frame_type = video->frame() % key_interval_ == 0
+ ? libvpx::RcFrameType::kKeyFrame
+ : libvpx::RcFrameType::kInterFrame;
encoder_exit_ = video->frame() == test_video_.frames;
}
encoder->Control(VP8E_SET_MAX_INTRA_BITRATE_PCT, 1000);
encoder->Control(VP9E_SET_RTC_EXTERNAL_RATECTRL, 1);
}
- frame_params_.frame_type =
- video->frame() % key_interval_ == 0 ? KEY_FRAME : INTER_FRAME;
- if (rc_cfg_.rc_mode == VPX_CBR && frame_params_.frame_type == INTER_FRAME) {
+ frame_params_.frame_type = video->frame() % key_interval_ == 0
+ ? libvpx::RcFrameType::kKeyFrame
+ : libvpx::RcFrameType::kInterFrame;
+ if (rc_cfg_.rc_mode == VPX_CBR &&
+ frame_params_.frame_type == libvpx::RcFrameType::kInterFrame) {
// Disable golden frame update.
frame_flags_ |= VP8_EFLAG_NO_UPD_GF;
frame_flags_ |= VP8_EFLAG_NO_UPD_ARF;
encoder->Control(VP9E_SET_SVC, 1);
encoder->Control(VP9E_SET_SVC_PARAMETERS, &svc_params_);
}
- frame_params_.frame_type =
- video->frame() % key_interval_ == 0 ? KEY_FRAME : INTER_FRAME;
+ frame_params_.frame_type = video->frame() % key_interval_ == 0
+ ? libvpx::RcFrameType::kKeyFrame
+ : libvpx::RcFrameType::kInterFrame;
encoder_exit_ = video->frame() == kNumFrames;
current_superframe_ = video->frame();
if (dynamic_spatial_layers_ == 1) {
else
frame_params_.temporal_layer_id = 0;
rc_api_->ComputeQP(frame_params_);
- frame_params_.frame_type = INTER_FRAME;
+ frame_params_.frame_type = libvpx::RcFrameType::kInterFrame;
rc_api_->PostEncodeUpdate(sizes_[sl]);
}
}
#include <math.h>
#include <new>
+#include "vp8/common/common.h"
#include "vp8/vp8_ratectrl_rtc.h"
+#include "vp8/encoder/onyx_int.h"
#include "vp8/encoder/ratectrl.h"
#include "vpx_ports/system_state.h"
return rc_api;
}
+VP8RateControlRTC::~VP8RateControlRTC() {
+ if (cpi_) {
+ vpx_free(cpi_->gf_active_flags);
+ vpx_free(cpi_);
+ }
+}
+
void VP8RateControlRTC::InitRateControl(const VP8RateControlRtcConfig &rc_cfg) {
VP8_COMMON *cm = &cpi_->common;
VP8_CONFIG *oxcf = &cpi_->oxcf;
vp8_restore_layer_context(cpi_, layer);
vp8_new_framerate(cpi_, cpi_->layer_context[layer].framerate);
}
- cm->frame_type = frame_params.frame_type;
+ cm->frame_type = static_cast<FRAME_TYPE>(frame_params.frame_type);
cm->refresh_golden_frame = (cm->frame_type == KEY_FRAME) ? 1 : 0;
cm->refresh_alt_ref_frame = (cm->frame_type == KEY_FRAME) ? 1 : 0;
if (cm->frame_type == KEY_FRAME && cpi_->common.current_video_frame > 0) {
#define VPX_VP8_RATECTRL_RTC_H_
#include <cstdint>
+#include <cstring>
#include <memory>
-#include "vp8/encoder/onyx_int.h"
-#include "vp8/common/common.h"
#include "vpx/internal/vpx_ratectrl_rtc.h"
+struct VP8_COMP;
+
namespace libvpx {
struct VP8RateControlRtcConfig : public VpxRateControlRtcConfig {
public:
VP8RateControlRtcConfig() {
- vp8_zero(layer_target_bitrate);
- vp8_zero(ts_rate_decimator);
+ memset(&layer_target_bitrate, 0, sizeof(layer_target_bitrate));
+ memset(&ts_rate_decimator, 0, sizeof(ts_rate_decimator));
}
};
struct VP8FrameParamsQpRTC {
- FRAME_TYPE frame_type;
+ RcFrameType frame_type;
int temporal_layer_id;
};
public:
static std::unique_ptr<VP8RateControlRTC> Create(
const VP8RateControlRtcConfig &cfg);
- ~VP8RateControlRTC() {
- if (cpi_) {
- vpx_free(cpi_->gf_active_flags);
- vpx_free(cpi_);
- }
- }
+ ~VP8RateControlRTC();
void UpdateRateControl(const VP8RateControlRtcConfig &rc_cfg);
// GetQP() needs to be called after ComputeQP() to get the latest QP
private:
VP8RateControlRTC() {}
void InitRateControl(const VP8RateControlRtcConfig &cfg);
- VP8_COMP *cpi_;
+ struct VP8_COMP *cpi_;
int q_;
};
return rc_api;
}
+VP9RateControlRTC::~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_);
+ }
+}
+
void VP9RateControlRTC::InitRateControl(const VP9RateControlRtcConfig &rc_cfg) {
VP9_COMMON *cm = &cpi_->common;
VP9EncoderConfig *oxcf = &cpi_->oxcf;
cm->height = height;
}
vp9_set_mb_mi(cm, cm->width, cm->height);
- cm->frame_type = frame_params.frame_type;
+ cm->frame_type = static_cast<FRAME_TYPE>(frame_params.frame_type);
// This is needed to ensure key frame does not get unset in rc_get_svc_params.
cpi_->frame_flags = (cm->frame_type == KEY_FRAME) ? FRAMEFLAGS_KEY : 0;
cpi_->refresh_golden_frame = (cm->frame_type == KEY_FRAME) ? 1 : 0;
#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() {
};
struct VP9FrameParamsQpRTC {
- FRAME_TYPE frame_type;
+ RcFrameType frame_type;
int spatial_layer_id;
int temporal_layer_id;
};
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);
// GetQP() needs to be called after ComputeQP() to get the latest QP
private:
VP9RateControlRTC() {}
void InitRateControl(const VP9RateControlRtcConfig &cfg);
- VP9_COMP *cpi_;
+ struct VP9_COMP *cpi_;
};
} // namespace libvpx
#include "vpx/vpx_encoder.h"
namespace libvpx {
+
+enum class RcFrameType { kKeyFrame = 0, kInterFrame = 1 };
+
struct VpxRateControlRtcConfig {
public:
VpxRateControlRtcConfig() {