SUPERRES recode loop: save and restore MV stats.

Smart motion vector precision was added in this patch:
https://aomedia-review.googlesource.com/c/aom/+/101241

This saves MV stats of each frame, and uses that to predict MV precision
for next frame.

For SUPERRES_AUTO mode, we need to save/restore these stats for fullres
and superres encode tries, so that these tries (for the same frame)
don't affect each other.

With this, PSNR of fullres try is identical to baseline for most
encodes. (Unless VBR mode picks slightly different qindex, due to
extra bits needed for superres mode in frame header).

BDRate baseline vs SUPERRES_AUTO mode for hdres2, VBR mode:
- Before = 0.216 (worst clip: +1.79)
- After  = 0.142 (worst clip: +0.80)

BUG=aomedia:2844

Change-Id: Ia6c5df01d8a04180128aebfc3f5d7f216874c656
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index 55a7869..ffefb09 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -79,15 +79,6 @@
   int den;           // fraction denominator
 } aom_rational64_t;  // alias for struct aom_rational
 
-typedef struct {
-#if CONFIG_SUPERRES_IN_RECODE
-  struct loopfilter lf;
-  CdefInfo cdef_info;
-  YV12_BUFFER_CONFIG copy_buffer;
-  RATE_CONTROL rc;
-#endif  // CONFIG_SUPERRES_IN_RECODE
-} CODING_CONTEXT;
-
 enum {
   NORMAL = 0,
   FOURFIVE = 1,
@@ -1912,6 +1903,16 @@
 } MV_STATS;
 
 typedef struct {
+#if CONFIG_SUPERRES_IN_RECODE
+  struct loopfilter lf;
+  CdefInfo cdef_info;
+  YV12_BUFFER_CONFIG copy_buffer;
+  RATE_CONTROL rc;
+  MV_STATS mv_stats;
+#endif  // CONFIG_SUPERRES_IN_RECODE
+} CODING_CONTEXT;
+
+typedef struct {
   int frame_width;
   int frame_height;
   int mi_rows;
diff --git a/av1/encoder/encoder_utils.c b/av1/encoder/encoder_utils.c
index 2fc970a..ea8c6ce 100644
--- a/av1/encoder/encoder_utils.c
+++ b/av1/encoder/encoder_utils.c
@@ -1260,6 +1260,7 @@
   cc->lf = cm->lf;
   cc->cdef_info = cm->cdef_info;
   cc->rc = cpi->rc;
+  cc->mv_stats = cpi->mv_stats;
 }
 
 void av1_save_all_coding_context(AV1_COMP *cpi) {
diff --git a/av1/encoder/encoder_utils.h b/av1/encoder/encoder_utils.h
index e42bdb4..6a1d8fe 100644
--- a/av1/encoder/encoder_utils.h
+++ b/av1/encoder/encoder_utils.h
@@ -843,6 +843,7 @@
   cm->lf = cc->lf;
   cm->cdef_info = cc->cdef_info;
   cpi->rc = cc->rc;
+  cpi->mv_stats = cc->mv_stats;
 }
 
 static AOM_INLINE void release_copy_buffer(CODING_CONTEXT *cc) {