Revert "Revert "Replace y_buffer_8bit with a downsampling pyramid""

This reverts commit db56a4efe445722b0dfc48d4d14a153b16cda170.

Reason for revert: Re-submit with two fixes:

* Add a function aom_is_pyramid_valid(), which checks the validity of
  an image pyramid while obeying the proper locking semantics.
  This avoids thread sanitizer warnings in debug mode.

* Properly allocate downsampling pyramids in the encoder in the
  following cases, which were previously missed:
  1) In aom_yv12_realloc_with_new_border(), which is used when scaling
     ref frames
  2) In av1_superres_post_encode(), which is used to upscale a superres
     encoded frame to its final size
  3) In av1_lookahead_push(), if we are reallocating a frame buffer due
     to the lookahead entry we fetched being too small

  This requires adding a "num_pyramid_levels" argument to
  aom_alloc_frame_buffer() and altering its callers appropriately.

BUG=aomedia:3362

Change-Id: Ib5188a3f5dc9be68acc638274c604ee938bebf0c
diff --git a/av1/encoder/superres_scale.c b/av1/encoder/superres_scale.c
index f439e70..5e1e289 100644
--- a/av1/encoder/superres_scale.c
+++ b/av1/encoder/superres_scale.c
@@ -403,7 +403,7 @@
   assert(!is_lossless_requested(&cpi->oxcf.rc_cfg));
   assert(!cm->features.all_lossless);
 
-  av1_superres_upscale(cm, NULL);
+  av1_superres_upscale(cm, NULL, cpi->image_pyramid_levels);
 
   // If regular resizing is occurring the source will need to be downscaled to
   // match the upscaled superres resolution. Otherwise the original source is