ref: 69e9a3949870cdc3e18b93a4451867c18a3cf8fc
parent: 7c4aed2ccc4dacf7cb79838d40a961b13cdc4659
parent: 45ce790711d0b3bdcc1dc60589731939c3d1b749
author: Marco Paniconi <[email protected]>
date: Thu Aug 9 18:30:07 EDT 2018
Merge "vp9-svc: Fix for scene detection for SVC"
--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -2636,6 +2636,8 @@
if (cpi->svc.spatial_layer_id == 0 && src_width == last_src_width &&
src_height == last_src_height) {
YV12_BUFFER_CONFIG *frames[MAX_LAG_BUFFERS] = { NULL };
+ int num_mi_cols = cm->mi_cols;
+ int num_mi_rows = cm->mi_rows;
int start_frame = 0;
int frames_to_buffer = 1;
int frame = 0;
@@ -2650,6 +2652,12 @@
min_thresh = 65000;
thresh = 2.1f;
}
+ if (cpi->use_svc && cpi->svc.number_spatial_layers > 1) {
+ const int aligned_width = ALIGN_POWER_OF_TWO(src_width, MI_SIZE_LOG2);
+ const int aligned_height = ALIGN_POWER_OF_TWO(src_height, MI_SIZE_LOG2);
+ num_mi_cols = aligned_width >> MI_SIZE_LOG2;
+ num_mi_rows = aligned_height >> MI_SIZE_LOG2;
+ }
if (cpi->oxcf.lag_in_frames > 0) {
frames_to_buffer = (cm->current_video_frame == 1)
? (int)vp9_lookahead_depth(cpi->lookahead) - 1
@@ -2696,8 +2704,8 @@
uint64_t avg_sad = 0;
uint64_t tmp_sad = 0;
int num_samples = 0;
- int sb_cols = (cm->mi_cols + MI_BLOCK_SIZE - 1) / MI_BLOCK_SIZE;
- int sb_rows = (cm->mi_rows + MI_BLOCK_SIZE - 1) / MI_BLOCK_SIZE;
+ int sb_cols = (num_mi_cols + MI_BLOCK_SIZE - 1) / MI_BLOCK_SIZE;
+ int sb_rows = (num_mi_rows + MI_BLOCK_SIZE - 1) / MI_BLOCK_SIZE;
if (cpi->oxcf.lag_in_frames > 0) {
src_y = frames[frame]->y_buffer;
src_ystride = frames[frame]->y_stride;
@@ -2733,7 +2741,7 @@
if (avg_sad >
VPXMAX(min_thresh,
(unsigned int)(rc->avg_source_sad[0] * thresh)) &&
- rc->frames_since_key > 1 &&
+ rc->frames_since_key > 1 + cpi->svc.number_spatial_layers &&
num_zero_temp_sad < 3 * (num_samples >> 2))
rc->high_source_sad = 1;
else