Prevent redundant down converting operation

Adds a flag "buf_8bit_valid" to indicate if buf_8bit is synchronized
with HBD buffer, the flag is then used to avoid possible redundant
operation in down conversion the hbd buffer to buf_8bit.

Also this commit also moves the operation to prepare source frame for
coding outside of recode loop to avoid duplicate operations there.

Change-Id: I67a1eb408b75bb734bd8a16fe6ffbd58c93a230f
diff --git a/aom_scale/yv12config.h b/aom_scale/yv12config.h
index 76bfe9d..dfbe126 100644
--- a/aom_scale/yv12config.h
+++ b/aom_scale/yv12config.h
@@ -59,6 +59,7 @@
   // If the frame is stored in a 16-bit buffer, this stores an 8-bit version
   // for use in global motion detection. It is allocated on-demand.
   uint8_t *y_buffer_8bit;
+  int buf_8bit_valid;
 #endif
 
   uint8_t *buffer_alloc;