summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/vp8_ratectrl_rtc_test.cc7
-rw-r--r--test/vp9_ratectrl_rtc_test.cc15
-rw-r--r--vp8/vp8_ratectrl_rtc.cc11
-rw-r--r--vp8/vp8_ratectrl_rtc.h20
-rw-r--r--vp9/ratectrl_rtc.cc25
-rw-r--r--vp9/ratectrl_rtc.h31
-rw-r--r--vpx/internal/vpx_ratectrl_rtc.h3
7 files changed, 63 insertions, 49 deletions
diff --git a/test/vp8_ratectrl_rtc_test.cc b/test/vp8_ratectrl_rtc_test.cc
index 7410f3c01..56c26a99f 100644
--- a/test/vp8_ratectrl_rtc_test.cc
+++ b/test/vp8_ratectrl_rtc_test.cc
@@ -127,14 +127,15 @@ class Vp8RcInterfaceTest
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;
}
diff --git a/test/vp9_ratectrl_rtc_test.cc b/test/vp9_ratectrl_rtc_test.cc
index 1d1a78f43..cce73fcce 100644
--- a/test/vp9_ratectrl_rtc_test.cc
+++ b/test/vp9_ratectrl_rtc_test.cc
@@ -57,9 +57,11 @@ class RcInterfaceTest
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;
@@ -183,8 +185,9 @@ class RcInterfaceSvcTest : public ::libvpx_test::EncoderTest,
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) {
@@ -247,7 +250,7 @@ class RcInterfaceSvcTest : public ::libvpx_test::EncoderTest,
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]);
}
}
diff --git a/vp8/vp8_ratectrl_rtc.cc b/vp8/vp8_ratectrl_rtc.cc
index f3f42529d..c36cfea48 100644
--- a/vp8/vp8_ratectrl_rtc.cc
+++ b/vp8/vp8_ratectrl_rtc.cc
@@ -10,7 +10,9 @@
#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"
@@ -65,6 +67,13 @@ std::unique_ptr<VP8RateControlRTC> VP8RateControlRTC::Create(
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;
@@ -203,7 +212,7 @@ void VP8RateControlRTC::ComputeQP(const VP8FrameParamsQpRTC &frame_params) {
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) {
diff --git a/vp8/vp8_ratectrl_rtc.h b/vp8/vp8_ratectrl_rtc.h
index def7dd8f9..0e81592ec 100644
--- a/vp8/vp8_ratectrl_rtc.h
+++ b/vp8/vp8_ratectrl_rtc.h
@@ -12,23 +12,24 @@
#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;
};
@@ -36,12 +37,7 @@ class VP8RateControlRTC {
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
@@ -54,7 +50,7 @@ class VP8RateControlRTC {
private:
VP8RateControlRTC() {}
void InitRateControl(const VP8RateControlRtcConfig &cfg);
- VP8_COMP *cpi_;
+ struct VP8_COMP *cpi_;
int q_;
};
diff --git a/vp9/ratectrl_rtc.cc b/vp9/ratectrl_rtc.cc
index 02e50a857..944c526ac 100644
--- a/vp9/ratectrl_rtc.cc
+++ b/vp9/ratectrl_rtc.cc
@@ -48,6 +48,29 @@ std::unique_ptr<VP9RateControlRTC> VP9RateControlRTC::Create(
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;
@@ -157,7 +180,7 @@ void VP9RateControlRTC::ComputeQP(const VP9FrameParamsQpRTC &frame_params) {
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;
diff --git a/vp9/ratectrl_rtc.h b/vp9/ratectrl_rtc.h
index b209e4db6..162a04883 100644
--- a/vp9/ratectrl_rtc.h
+++ b/vp9/ratectrl_rtc.h
@@ -19,14 +19,14 @@
#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() {
@@ -53,7 +53,7 @@ struct VP9RateControlRtcConfig : public VpxRateControlRtcConfig {
};
struct VP9FrameParamsQpRTC {
- FRAME_TYPE frame_type;
+ RcFrameType frame_type;
int spatial_layer_id;
int temporal_layer_id;
};
@@ -90,28 +90,7 @@ 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);
// GetQP() needs to be called after ComputeQP() to get the latest QP
@@ -125,7 +104,7 @@ class VP9RateControlRTC {
private:
VP9RateControlRTC() {}
void InitRateControl(const VP9RateControlRtcConfig &cfg);
- VP9_COMP *cpi_;
+ struct VP9_COMP *cpi_;
};
} // namespace libvpx
diff --git a/vpx/internal/vpx_ratectrl_rtc.h b/vpx/internal/vpx_ratectrl_rtc.h
index 65398c654..33c57e219 100644
--- a/vpx/internal/vpx_ratectrl_rtc.h
+++ b/vpx/internal/vpx_ratectrl_rtc.h
@@ -14,6 +14,9 @@
#include "vpx/vpx_encoder.h"
namespace libvpx {
+
+enum class RcFrameType { kKeyFrame = 0, kInterFrame = 1 };
+
struct VpxRateControlRtcConfig {
public:
VpxRateControlRtcConfig() {