Replace ref frame scaling with a better version

Uses a better non-normative scaler to scale reference frames.

Change-Id: I44b689c8328d6e6fd467c70c9b6b789874818153
diff --git a/av1/common/scale.c b/av1/common/scale.c
index d8a8bcc..d5ccdfe 100644
--- a/av1/common/scale.c
+++ b/av1/common/scale.c
@@ -16,8 +16,8 @@
 
 // Note: Expect val to be in q4 precision
 static INLINE int scaled_x(int val, const struct scale_factors *sf) {
-  const int off = (sf->x_scale_fp - (1 << REF_SCALE_SHIFT))
-                  << (SUBPEL_BITS - 1);
+  const int off =
+      (sf->x_scale_fp - (1 << REF_SCALE_SHIFT)) * (1 << (SUBPEL_BITS - 1));
   const int64_t tval = (int64_t)val * sf->x_scale_fp + off;
   return (int)ROUND_POWER_OF_TWO_SIGNED_64(tval,
                                            REF_SCALE_SHIFT - SCALE_EXTRA_BITS);
@@ -25,8 +25,8 @@
 
 // Note: Expect val to be in q4 precision
 static INLINE int scaled_y(int val, const struct scale_factors *sf) {
-  const int off = (sf->y_scale_fp - (1 << REF_SCALE_SHIFT))
-                  << (SUBPEL_BITS - 1);
+  const int off =
+      (sf->y_scale_fp - (1 << REF_SCALE_SHIFT)) * (1 << (SUBPEL_BITS - 1));
   const int64_t tval = (int64_t)val * sf->y_scale_fp + off;
   return (int)ROUND_POWER_OF_TWO_SIGNED_64(tval,
                                            REF_SCALE_SHIFT - SCALE_EXTRA_BITS);
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index fb50d45..91ee497 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -2841,6 +2841,7 @@
 }
 #endif  // OUTPUT_YUV_REC
 
+/*
 #if CONFIG_HIGHBITDEPTH
 static void scale_and_extend_frame(const YV12_BUFFER_CONFIG *src,
                                    YV12_BUFFER_CONFIG *dst, int planes,
@@ -2908,6 +2909,7 @@
   else
     aom_extend_frame_borders(dst);
 }
+*/
 
 #if CONFIG_GLOBAL_MOTION
 #define GM_RECODE_LOOP_NUM4X4_FACTOR 192
@@ -3346,8 +3348,10 @@
                   cm->byte_alignment, NULL, NULL, NULL))
             aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
                                "Failed to allocate frame buffer");
-          scale_and_extend_frame(ref, &new_fb_ptr->buf, MAX_MB_PLANE,
-                                 (int)cm->bit_depth);
+          av1_resize_and_extend_frame(ref, &new_fb_ptr->buf,
+                                      (int)cm->bit_depth);
+          // scale_and_extend_frame(ref, &new_fb_ptr->buf, MAX_MB_PLANE,
+          //                        (int)cm->bit_depth);
           cpi->scaled_ref_idx[ref_frame - 1] = new_fb;
           alloc_frame_mvs(cm, new_fb);
         }
@@ -3370,7 +3374,8 @@
                                        NULL, NULL, NULL))
             aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
                                "Failed to allocate frame buffer");
-          scale_and_extend_frame(ref, &new_fb_ptr->buf, MAX_MB_PLANE);
+          av1_resize_and_extend_frame(ref, &new_fb_ptr->buf);
+          // scale_and_extend_frame(ref, &new_fb_ptr->buf, MAX_MB_PLANE);
           cpi->scaled_ref_idx[ref_frame - 1] = new_fb;
           alloc_frame_mvs(cm, new_fb);
         }