Fix: Make REFERENCE_BUFFER and AOM_HIGHBITDEPTH work together

BUG=aomedia:99

Change-Id: I36c3c3728500e0eefb7c56720a467e8754b85009
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 81122c7..58e60db 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -4653,9 +4653,14 @@
     * wraparound) */
     int FidLen = FRAME_ID_LENGTH_MINUS7 + 7;
     if (cm->current_frame_id == -1) {
-      /* quasi-random initialization of current_frame_id for a key frame */
-      int lsb = cpi->Source->y_buffer[0] & 0xff;
-      int msb = cpi->Source->y_buffer[1] & 0xff;
+/* quasi-random initialization of current_frame_id for a key frame */
+#if CONFIG_AOM_HIGHBITDEPTH
+      int lsb = CONVERT_TO_SHORTPTR(cpi->Source->y_buffer)[0] & 0xff;
+      int msb = CONVERT_TO_SHORTPTR(cpi->Source->y_buffer)[1] & 0xff;
+#else
+      int lsb = cpi->Source->y_buffer[0];
+      int msb = cpi->Source->y_buffer[1];
+#endif
       cm->current_frame_id = ((msb << 8) + lsb) % (1 << FidLen);
     } else {
       cm->current_frame_id =