]> granicus.if.org Git - libvpx/commitdiff
vp9-svc: Fix to downsampling filter phase_shift.
authorMarco Paniconi <marpan@google.com>
Thu, 1 Mar 2018 17:45:11 +0000 (09:45 -0800)
committerMarco Paniconi <marpan@google.com>
Fri, 2 Mar 2018 16:55:18 +0000 (08:55 -0800)
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

vp9/encoder/vp9_svc_layercontext.c

index 389d48f210cc20685df35741783b0ff4b1ba3851..a7fe36fca6d2ce86bc46a74dd89cf4c1cd46f48f 100644 (file)
@@ -663,16 +663,17 @@ int vp9_one_pass_cbr_svc_start_layer(VP9_COMP *const cpi) {
                        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,