} else if (mode == 3) {
denoiser->denoiser_mode = kDenoiserOnYUVAggressive;
} else {
- denoiser->denoiser_mode = kDenoiserOnAdaptive;
+ denoiser->denoiser_mode = kDenoiserOnYUV;
}
if (denoiser->denoiser_mode != kDenoiserOnYUVAggressive) {
denoiser->denoise_pars.scale_sse_thresh = 1;
denoiser->denoise_pars.pickmode_mv_bias = 75;
denoiser->denoise_pars.qp_thresh = 85;
denoiser->denoise_pars.consec_zerolast = 15;
- denoiser->denoise_pars.spatial_blur = 20;
+ denoiser->denoise_pars.spatial_blur = 0;
}
}
// Bitrate thresholds and noise metric (nmse) thresholds for switching to
// aggressive mode.
// TODO(marpan): Adjust thresholds, including effect on resolution.
- denoiser->bitrate_threshold = 300000; // (bits/sec).
- denoiser->threshold_aggressive_mode = 35;
+ denoiser->bitrate_threshold = 400000; // (bits/sec).
+ denoiser->threshold_aggressive_mode = 80;
if (width * height > 1280 * 720) {
- denoiser->bitrate_threshold = 2000000;
- denoiser->threshold_aggressive_mode = 1400;
+ denoiser->bitrate_threshold = 2500000;
+ denoiser->threshold_aggressive_mode = 180;
} else if (width * height > 960 * 540) {
- denoiser->bitrate_threshold = 800000;
- denoiser->threshold_aggressive_mode = 150;
+ denoiser->bitrate_threshold = 1000000;
+ denoiser->threshold_aggressive_mode = 120;
} else if (width * height > 640 * 480) {
- denoiser->bitrate_threshold = 500000;
+ denoiser->bitrate_threshold = 600000;
denoiser->threshold_aggressive_mode = 100;
}
return 0;
// Only select blocks for computing nmse that have been encoded
// as ZERO LAST min_consec_zero_last frames in a row.
// Scale with number of temporal layers.
- int min_consec_zero_last = 8 / cpi->oxcf.number_of_layers;
+ int min_consec_zero_last = 12 / cpi->oxcf.number_of_layers;
// Decision is tested for changing the denoising mode every
// num_mode_change times this function is called. Note that this
// function called every 8 frames, so (8 * num_mode_change) is number
// of frames where denoising mode change is tested for switch.
- int num_mode_change = 15;
+ int num_mode_change = 20;
// Framerate factor, to compensate for larger mse at lower framerates.
// Use ref_framerate, which is full source framerate for temporal layers.
// TODO(marpan): Adjust this factor.
static const unsigned char const_source[16] = {
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128};
-
+ int bandwidth = (int)(cpi->target_bandwidth);
+ // For temporal layers, use full bandwidth (top layer).
+ if (cpi->oxcf.number_of_layers > 1) {
+ LAYER_CONTEXT *lc = &cpi->layer_context[cpi->oxcf.number_of_layers - 1];
+ bandwidth = (int)(lc->target_bandwidth);
+ }
// Loop through the Y plane, every skip blocks along rows and columns,
// summing the normalized mean square error, only for blocks that have
// been encoded as ZEROMV LAST at least min_consec_zero_last least frames in
if (total > 0 &&
(num_blocks > (tot_num_blocks >> 4))) {
// Update the recursive mean square source_diff.
+ total = (total << 8) / num_blocks;
if (cpi->denoiser.nmse_source_diff_count == 0) {
// First sample in new interval.
cpi->denoiser.nmse_source_diff = total;
cpi->denoiser.qp_avg = cm->base_qindex;
} else {
// For subsequent samples, use average with weight ~1/4 for new sample.
- cpi->denoiser.nmse_source_diff = (int)((total >> 2) +
- 3 * (cpi->denoiser.nmse_source_diff >> 2));
- cpi->denoiser.qp_avg = (int)((cm->base_qindex >> 2) +
- 3 * (cpi->denoiser.qp_avg >> 2));
+ cpi->denoiser.nmse_source_diff = (int)((total +
+ 3 * cpi->denoiser.nmse_source_diff) >> 2);
+ cpi->denoiser.qp_avg = (int)((cm->base_qindex +
+ 3 * cpi->denoiser.qp_avg) >> 2);
}
cpi->denoiser.nmse_source_diff_count++;
}
(cpi->denoiser.nmse_source_diff >
cpi->denoiser.threshold_aggressive_mode) &&
(cpi->denoiser.qp_avg < cpi->denoiser.qp_threshold_up &&
- cpi->target_bandwidth > cpi->denoiser.bitrate_threshold)) {
+ bandwidth > cpi->denoiser.bitrate_threshold)) {
vp8_denoiser_set_parameters(&cpi->denoiser, kDenoiserOnYUVAggressive);
} else {
// Check for going down: from aggressive to normal mode.
cpi->denoiser.threshold_aggressive_mode)) ||
((cpi->denoiser.denoiser_mode == kDenoiserOnYUVAggressive) &&
(cpi->denoiser.qp_avg > cpi->denoiser.qp_threshold_down ||
- cpi->target_bandwidth < cpi->denoiser.bitrate_threshold))) {
+ bandwidth < cpi->denoiser.bitrate_threshold))) {
vp8_denoiser_set_parameters(&cpi->denoiser, kDenoiserOnYUV);
}
}