]> granicus.if.org Git - libvpx/commitdiff
VP9 SVC: fix crash on scaling partition.
authorJerome Jiang <jianj@google.com>
Tue, 27 Nov 2018 01:10:37 +0000 (17:10 -0800)
committerJerome Jiang <jianj@google.com>
Tue, 27 Nov 2018 02:34:12 +0000 (18:34 -0800)
When scaling up partition from lower resolution layer L, mi_row and
mi_col from L must be smaller than mi_rows and mi_cols from L.

Before this change, the condition was based on mi_rows from top layer
divided by 2, which is not necessarily equal to the mi_rows from lower
resolution layer.

Added variable in SVC structure to keep track of mi_rows and mi_cols
from each spatial layer.

Re-enable partition scaling for 1080p.

BUG=webm:1578

Change-Id: Icc1c701b095cfe0a92bfecca1ed39dbe21da12b6

vp9/encoder/vp9_encodeframe.c
vp9/encoder/vp9_speed_features.c
vp9/encoder/vp9_svc_layercontext.c
vp9/encoder/vp9_svc_layercontext.h

index d5d1d279e96f88f81f1f82ef48771ec921a2f6e9..98343f0d2436912ec42451091aabb054707674f7 100644 (file)
@@ -930,7 +930,9 @@ static int scale_partitioning_svc(VP9_COMP *cpi, MACROBLOCK *x, MACROBLOCKD *xd,
   PARTITION_TYPE partition_high;
 
   if (mi_row_high >= cm->mi_rows || mi_col_high >= cm->mi_cols) return 0;
-  if (mi_row >= (cm->mi_rows >> 1) || mi_col >= (cm->mi_cols >> 1)) return 0;
+  if (mi_row >= svc->mi_rows[svc->spatial_layer_id - 1] ||
+      mi_col >= svc->mi_cols[svc->spatial_layer_id - 1])
+    return 0;
 
   // Find corresponding (mi_col/mi_row) block down-scaled by 2x2.
   start_pos = mi_row * (svc->mi_stride[svc->spatial_layer_id - 1]) + mi_col;
@@ -5658,7 +5660,6 @@ static void encode_frame_internal(VP9_COMP *cpi) {
 
   xd->mi = cm->mi_grid_visible;
   xd->mi[0] = cm->mi;
-
   vp9_zero(*td->counts);
   vp9_zero(cpi->td.rd_counts);
 
index fbd24d0d2b0db9c848678257f4b0bdae6ce2066a..9b6c69a73fdfd954a441a6c827c4fc1d0c49bd1c 100644 (file)
@@ -713,8 +713,7 @@ static void set_rt_speed_feature_framesize_independent(
     // TODO(jianj): Investigate webm:1578
     if (cpi->use_svc && cpi->svc.use_partition_reuse &&
         cpi->svc.number_spatial_layers == 3 && cpi->svc.temporal_layer_id > 0 &&
-        cpi->oxcf.width * cpi->oxcf.height > 640 * 480 &&
-        cpi->oxcf.width * cpi->oxcf.height < 1920 * 1080)
+        cpi->oxcf.width * cpi->oxcf.height > 640 * 480)
       sf->svc_use_lowres_part = 1;
     // For SVC when golden is used as second temporal reference: to avoid
     // encode time increase only use this feature on base temporal layer.
index 033684e2e72497c17039ed70a6535882c4aa896d..c4c5b5a9fb63aacbd09fe8c0bdfc67011b026df4 100644 (file)
@@ -737,6 +737,8 @@ int vp9_one_pass_cbr_svc_start_layer(VP9_COMP *const cpi) {
   }
   svc->force_zero_mode_spatial_ref = 1;
   svc->mi_stride[svc->spatial_layer_id] = cpi->common.mi_stride;
+  svc->mi_rows[svc->spatial_layer_id] = cpi->common.mi_rows;
+  svc->mi_cols[svc->spatial_layer_id] = cpi->common.mi_cols;
 
   if (svc->temporal_layering_mode == VP9E_TEMPORAL_LAYERING_MODE_0212) {
     set_flags_and_fb_idx_for_temporal_mode3(cpi);
index 17d7a8a50e6253416fe6e95e572e9991e1cd85fd..31d95f9d6be6e94b05dead01dfda5555dc227293 100644 (file)
@@ -125,6 +125,8 @@ typedef struct SVC {
 
   BLOCK_SIZE *prev_partition_svc;
   int mi_stride[VPX_MAX_LAYERS];
+  int mi_rows[VPX_MAX_LAYERS];
+  int mi_cols[VPX_MAX_LAYERS];
 
   int first_layer_denoise;