Make segmentation compatible with scaling

Fallback on intra block when the segmentation doesn't allow to reference
a frame in scaling use case (e.g: after use of a segmentation map with
another dimension).

Change-Id: I4aa037f07ec3d18c96752e0d49f5afa4e8674d49
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index ff1d8dc..a0a44f0 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -281,6 +281,14 @@
 static void write_is_inter(const AV1_COMMON *cm, const MACROBLOCKD *xd,
                            int segment_id, aom_writer *w, const int is_inter) {
   if (!segfeature_active(&cm->seg, segment_id, SEG_LVL_REF_FRAME)) {
+    if (segfeature_active(&cm->seg, segment_id, SEG_LVL_SKIP)
+#if CONFIG_SEGMENT_GLOBALMV
+        || segfeature_active(&cm->seg, segment_id, SEG_LVL_GLOBALMV)
+#endif
+            )
+      if (!av1_is_valid_scale(&cm->frame_refs[0].sf))
+        return;  // LAST_FRAME not valid for reference
+
     const int ctx = av1_get_intra_inter_context(xd);
     FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
     aom_write_symbol(w, is_inter, ec_ctx->intra_inter_cdf[ctx], 2);