Move various things out of av1_get_compressed_data

In preparation for moving much of av1_get_compressed_data() to
av1_encode_strategy() I am performing refactoring and trying to reduce
its length.

* Move initialisation of current_frame_id to av1_create_compressor
* release_scaled_references() is moved to the location in
  encode_frame_to_data_rate() which deals with frame dropping
* Copying frame context to cm->cur_frame is moved to
  encode_frame_to_data_rate()
* EXT_TILE_DEBUG output moved to encode_frame_to_data_rate()
* Now un-needed initialisation of cpi->scaled_ref_buf[] is removed
* Remove unneeded "showable_frame &= !show_frame"

This forms part of wider restructuring and refactoring in order to
achieve a clean API separation at the entry to the low-level encoder.

BUG=aomedia:2244

Change-Id: I8ebeb29fb147c381984eb07f7a725def81f2a136
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 774efef..8682b62 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -2663,6 +2663,7 @@
   av1_rc_init(&cpi->oxcf, oxcf->pass, &cpi->rc);
 
   cm->current_frame.frame_number = 0;
+  cm->current_frame_id = -1;
   cpi->seq_params_locked = 0;
   cpi->partition_search_skippable_frame = 0;
   cpi->tile_data = NULL;
@@ -5370,6 +5371,7 @@
       current_frame->frame_type != KEY_FRAME) {
     if (av1_rc_drop_frame(cpi)) {
       av1_rc_postencode_update_drop_frame(cpi);
+      release_scaled_references(cpi);
       return AOM_CODEC_OK;
     }
   }
@@ -5537,6 +5539,21 @@
     *cm->fc = cpi->tile_data[largest_tile_id].tctx;
     av1_reset_cdf_symbol_counters(cm->fc);
   }
+  if (!cm->large_scale_tile) {
+    cm->cur_frame->frame_context = *cm->fc;
+  }
+#define EXT_TILE_DEBUG 0
+#if EXT_TILE_DEBUG
+  if (cm->large_scale_tile && oxcf->pass == 2) {
+    char fn[20] = "./fc";
+    fn[4] = current_frame->frame_number / 100 + '0';
+    fn[5] = (current_frame->frame_number % 100) / 10 + '0';
+    fn[6] = (current_frame->frame_number % 10) + '0';
+    fn[7] = '\0';
+    av1_print_frame_contexts(cm->fc, fn);
+  }
+#endif  // EXT_TILE_DEBUG
+#undef EXT_TILE_DEBUG
 
   if (cpi->refresh_golden_frame == 1)
     cpi->frame_flags |= FRAMEFLAGS_GOLDEN;
@@ -6704,7 +6721,6 @@
   struct lookahead_entry *source = NULL;
   int arf_src_index;
   int brf_src_index;
-  int i;
 
 #if CONFIG_BITSTREAM_DEBUG
   assert(cpi->oxcf.max_threads == 0 &&
@@ -6902,18 +6918,10 @@
     setup_frame_size(cpi);
   }
 
-  if (cpi->oxcf.pass != 0 || frame_is_intra_only(cm) == 1) {
-    for (i = 0; i < INTER_REFS_PER_FRAME; ++i) cpi->scaled_ref_buf[i] = NULL;
-  }
-
   cm->using_qmatrix = cpi->oxcf.using_qm;
   cm->min_qmlevel = cpi->oxcf.qm_minlevel;
   cm->max_qmlevel = cpi->oxcf.qm_maxlevel;
 
-  if (cm->seq_params.frame_id_numbers_present_flag && *time_stamp == 0) {
-    cpi->common.current_frame_id = -1;
-  }
-
   if (cpi->twopass.gf_group.index == 1 && cpi->oxcf.enable_tpl_model) {
     set_frame_size(cpi, cm->width, cm->height);
     setup_tpl_stats(cpi);
@@ -6931,30 +6939,6 @@
       return AOM_CODEC_ERROR;
   }
 
-  if (!cm->large_scale_tile) {
-    cm->cur_frame->frame_context = *cm->fc;
-  }
-
-#define EXT_TILE_DEBUG 0
-#if EXT_TILE_DEBUG
-  if (cm->large_scale_tile && oxcf->pass == 2) {
-    char fn[20] = "./fc";
-    fn[4] = current_frame->frame_number / 100 + '0';
-    fn[5] = (current_frame->frame_number % 100) / 10 + '0';
-    fn[6] = (current_frame->frame_number % 10) + '0';
-    fn[7] = '\0';
-    av1_print_frame_contexts(cm->fc, fn);
-  }
-#endif  // EXT_TILE_DEBUG
-#undef EXT_TILE_DEBUG
-
-  cm->showable_frame = !cm->show_frame && cm->showable_frame;
-
-  // No frame encoded, or frame was dropped, release scaled references.
-  if ((*size == 0) && (frame_is_intra_only(cm) == 0)) {
-    release_scaled_references(cpi);
-  }
-
   if (*size > 0) {
     cpi->droppable = is_frame_droppable(cpi);
   }