diff --git a/vpx_scale/generic/yv12extend.c b/vpx_scale/generic/yv12extend.c
index 60df0af56f173ab0d27ced8ef112b4cc71273976..cc8da2ac0b59208ef3b276611e493d2e35a04cdf 100644
--- a/vpx_scale/generic/yv12extend.c
+++ b/vpx_scale/generic/yv12extend.c
@@ -103,9 +103,9 @@ static void extend_frame(YV12_BUFFER_CONFIG *ybf,
   const int c_h = (ybf->y_crop_height + subsampling_y) >> subsampling_y;
   const int c_et = ext_size >> subsampling_y;
   const int c_el = ext_size >> subsampling_x;
-  const int c_eb = (ybf->border + ybf->y_height - ybf->y_crop_height +
+  const int c_eb = (ext_size + ybf->y_height - ybf->y_crop_height +
                     subsampling_y) >> subsampling_y;
-  const int c_er = (ybf->border + ybf->y_width - ybf->y_crop_width +
+  const int c_er = (ext_size + ybf->y_width - ybf->y_crop_width +
                     subsampling_x) >> subsampling_x;
 
   assert(ybf->y_height - ybf->y_crop_height < 16);