shithub: libvpx

Download patch

ref: 4d8958d8dddb9104e006bc806a2607bd4ee71708
parent: 6cc33c1626028df5f504a9cf47d42d68a2fc9b1c
author: Marco Paniconi <marpan@google.com>
date: Thu Mar 1 04:45:11 EST 2018

vp9-svc: Fix to downsampling filter phase_shift.

Set phase_shift = 0 if the scale factors are
above 3/4. Removes artifact for scale factors
close to 1.

phase_shift = 8 is to get an averaging filter
(decimated pixel aligns to 8/16, midway between source pixels),
and only makes sense for scale factors multiples of
2 (1/2, 1/4,...).

Removes artifact for high scaling ratios.

Change-Id: Id0a85869d6c6156dda0032c697ded2de78fad6bd

--- a/vp9/encoder/vp9_svc_layercontext.c
+++ b/vp9/encoder/vp9_svc_layercontext.c
@@ -663,16 +663,17 @@
                        lc->scaling_factor_num, lc->scaling_factor_den, &width,
                        &height);
 
-  // For resolutions <= VGA: set phase of the filter = 8 (for symmetric
-  // averaging filter), use bilinear for now.
-  if (width * height <= 640 * 480) {
-    cpi->svc.downsample_filter_type[cpi->svc.spatial_layer_id] = BILINEAR;
-    // Use Eightap_smooth for low resolutions.
-    if (width * height <= 320 * 240)
-      cpi->svc.downsample_filter_type[cpi->svc.spatial_layer_id] =
-          EIGHTTAP_SMOOTH;
-    cpi->svc.downsample_filter_phase[cpi->svc.spatial_layer_id] = 8;
-  }
+  // Use Eightap_smooth for low resolutions.
+  if (width * height <= 320 * 240)
+    cpi->svc.downsample_filter_type[cpi->svc.spatial_layer_id] =
+        EIGHTTAP_SMOOTH;
+  // For scale factors > 0.75, set the phase to 0 (aligns decimated pixel
+  // to source pixel).
+  lc = &cpi->svc.layer_context[cpi->svc.spatial_layer_id *
+                                   cpi->svc.number_temporal_layers +
+                               cpi->svc.temporal_layer_id];
+  if (lc->scaling_factor_num > (3 * lc->scaling_factor_den) >> 2)
+    cpi->svc.downsample_filter_phase[cpi->svc.spatial_layer_id] = 0;
 
   // The usage of use_base_mv assumes down-scale of 2x2. For now, turn off use
   // of base motion vectors if spatial scale factors for any layers are not 2,