Add control for delta q for uv. 0 by default.
Change-Id: Ib8ed160b1a5c9a61ba15985076f6c6f121477103
denoiser_offon_test_ = 0;
denoiser_offon_period_ = -1;
frame_parallel_decoding_mode_ = 1;
+ delta_q_uv_ = 0;
use_roi_ = false;
}
encoder->Control(VP9E_SET_AQ_MODE, 0);
}
+ if (delta_q_uv_ != 0) {
+ encoder->Control(VP9E_SET_DELTA_Q_UV, delta_q_uv_);
+ }
+
if (cfg_.ts_number_layers > 1) {
if (video->frame() == 0) {
encoder->Control(VP9E_SET_SVC, 1);
int denoiser_offon_test_;
int denoiser_offon_period_;
int frame_parallel_decoding_mode_;
+ int delta_q_uv_;
bool use_roi_;
vpx_roi_map_t roi_;
};
free(roi_.roi_map);
}
+// Params: speed setting, delta q UV.
+class DatarateTestVP9RealTimeDeltaQUV
+ : public DatarateTestVP9,
+ public ::libvpx_test::CodecTestWith2Params<int, int> {
+ public:
+ DatarateTestVP9RealTimeDeltaQUV() : DatarateTestVP9(GET_PARAM(0)) {}
+ virtual ~DatarateTestVP9RealTimeDeltaQUV() {}
+
+ protected:
+ virtual void SetUp() {
+ InitializeConfig();
+ SetMode(::libvpx_test::kRealTime);
+ set_cpu_used_ = GET_PARAM(1);
+ ResetModel();
+ }
+};
+
+TEST_P(DatarateTestVP9RealTimeDeltaQUV, DeltaQUV) {
+ cfg_.rc_buf_initial_sz = 500;
+ cfg_.rc_buf_optimal_sz = 500;
+ cfg_.rc_buf_sz = 1000;
+ cfg_.rc_dropframe_thresh = 0;
+ cfg_.rc_min_quantizer = 0;
+ cfg_.rc_max_quantizer = 63;
+ cfg_.rc_end_usage = VPX_CBR;
+ cfg_.g_lag_in_frames = 0;
+
+ ::libvpx_test::I420VideoSource video("niklas_640_480_30.yuv", 640, 480, 30, 1,
+ 0, 400);
+
+ cfg_.rc_target_bitrate = 450;
+ cfg_.g_w = 640;
+ cfg_.g_h = 480;
+
+ ResetModel();
+
+ delta_q_uv_ = GET_PARAM(2);
+
+ ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
+ ASSERT_GE(cfg_.rc_target_bitrate, effective_datarate_[0] * 0.90)
+ << " The datarate for the file exceeds the target!";
+
+ ASSERT_LE(cfg_.rc_target_bitrate, effective_datarate_[0] * 1.4)
+ << " The datarate for the file missed the target!";
+}
+
// Params: test mode, speed setting and index for bitrate array.
class DatarateTestVP9PostEncodeDrop
: public DatarateTestVP9,
VP9_INSTANTIATE_TEST_CASE(DatarateTestVP9RealTime, ::testing::Range(5, 10));
+VP9_INSTANTIATE_TEST_CASE(DatarateTestVP9RealTimeDeltaQUV,
+ ::testing::Range(5, 10),
+ ::testing::Values(-5, -10, -15));
+
VP9_INSTANTIATE_TEST_CASE(DatarateTestVP9PostEncodeDrop,
::testing::Range(5, 6));
cpi->oxcf.rc_mode == VPX_CBR &&
cm->frame_type != KEY_FRAME;
- vp9_set_quantizer(cm, q);
+ vp9_set_quantizer(cpi, q);
vp9_set_variance_partition_thresholds(cpi, q, 0);
setup_frame(cpi);
(cpi->rc.high_source_sad ||
(cpi->use_svc && svc->high_source_sad_superframe))) {
if (vp9_encodedframe_overshoot(cpi, -1, &q)) {
- vp9_set_quantizer(cm, q);
+ vp9_set_quantizer(cpi, q);
vp9_set_variance_partition_thresholds(cpi, q, 0);
}
}
// adjust some rate control parameters, and return to re-encode the frame.
if (vp9_encodedframe_overshoot(cpi, frame_size, &q)) {
vpx_clear_system_state();
- vp9_set_quantizer(cm, q);
+ vp9_set_quantizer(cpi, q);
vp9_set_variance_partition_thresholds(cpi, q, 0);
suppress_active_map(cpi);
// Turn-off cyclic refresh for re-encoded frame.
}
#endif
- vp9_set_quantizer(cm, q);
+ vp9_set_quantizer(cpi, q);
if (loop_count == 0) setup_frame(cpi);
int row_mt;
unsigned int motion_vector_unit_test;
+ int delta_q_uv;
} VP9EncoderConfig;
static INLINE int is_lossless_requested(const VP9EncoderConfig *cfg) {
#endif
set_first_pass_params(cpi);
- vp9_set_quantizer(cm, find_fp_qindex(cm->bit_depth));
+ vp9_set_quantizer(cpi, find_fp_qindex(cm->bit_depth));
vp9_setup_block_planes(&x->e_mbd, cm->subsampling_x, cm->subsampling_y);
vp9_init_plane_quantizers(cpi, &cpi->td.mb);
}
-void vp9_set_quantizer(VP9_COMMON *cm, int q) {
+void vp9_set_quantizer(VP9_COMP *cpi, int q) {
+ VP9_COMMON *cm = &cpi->common;
// quantizer has to be reinitialized with vp9_init_quantizer() if any
// delta_q changes.
cm->base_qindex = q;
cm->y_dc_delta_q = 0;
cm->uv_dc_delta_q = 0;
cm->uv_ac_delta_q = 0;
+ if (cpi->oxcf.delta_q_uv != 0) {
+ cm->uv_dc_delta_q = cm->uv_ac_delta_q = cpi->oxcf.delta_q_uv;
+ vp9_init_quantizer(cpi);
+ }
}
// Table that converts 0-63 Q-range values passed in outside to the Qindex
void vp9_init_quantizer(struct VP9_COMP *cpi);
-void vp9_set_quantizer(struct VP9Common *cm, int q);
+void vp9_set_quantizer(struct VP9_COMP *cm, int q);
int vp9_quantizer_to_qindex(int quantizer);
oxcf->min_gf_interval = extra_cfg->min_gf_interval;
oxcf->max_gf_interval = extra_cfg->max_gf_interval;
+ oxcf->delta_q_uv = 0;
+
oxcf->tuning = extra_cfg->tuning;
oxcf->content = extra_cfg->content;
return VPX_CODEC_OK;
}
+static vpx_codec_err_t ctrl_set_delta_q_uv(vpx_codec_alg_priv_t *ctx,
+ va_list args) {
+ int data = va_arg(args, int);
+ VP9_COMP *const cpi = ctx->cpi;
+ data = VPXMIN(VPXMAX(data, -20), 20);
+ cpi->oxcf.delta_q_uv = data;
+ return VPX_CODEC_OK;
+}
+
static vpx_codec_err_t ctrl_register_cx_callback(vpx_codec_alg_priv_t *ctx,
va_list args) {
vpx_codec_priv_output_cx_pkt_cb_pair_t *cbp =
{ VP9E_SET_SVC_FRAME_DROP_LAYER, ctrl_set_svc_frame_drop_layer },
{ VP9E_SET_SVC_GF_TEMPORAL_REF, ctrl_set_svc_gf_temporal_ref },
{ VP9E_SET_SVC_SPATIAL_LAYER_SYNC, ctrl_set_svc_spatial_layer_sync },
+ { VP9E_SET_DELTA_Q_UV, ctrl_set_delta_q_uv },
// Getters
{ VP8E_GET_LAST_QUANTIZER, ctrl_get_quantizer },
* Supported in codecs: VP9
*/
VP9E_SET_POSTENCODE_DROP,
+
+ /*!\brief Codec control function to set delta q for uv.
+ *
+ * Cap it at +/-20 for now.
+ *
+ * Supported in codecs: VP9
+ */
+ VP9E_SET_DELTA_Q_UV,
};
/*!\brief vpx 1-D scaling mode
VPX_CTRL_USE_TYPE(VP9E_SET_POSTENCODE_DROP, unsigned int)
#define VPX_CTRL_VP9E_SET_POSTENCODE_DROP
+VPX_CTRL_USE_TYPE(VP9E_SET_DELTA_Q_UV, int)
+#define VPX_CTRL_VP9E_SET_DELTA_Q_UV
+
/*!\endcond */
/*! @} - end defgroup vp8_encoder */
#ifdef __cplusplus