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
(cherry picked from commit e919a33cee15511db7dde74185414518f2bbf0df)
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index 3807fcb..4d37dce 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,
@@ -1996,6 +1987,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 0054cf7..d4b264d 100644
--- a/av1/encoder/encoder_utils.c
+++ b/av1/encoder/encoder_utils.c
@@ -1155,6 +1155,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 9ee7cab..e59c671 100644
--- a/av1/encoder/encoder_utils.h
+++ b/av1/encoder/encoder_utils.h
@@ -844,6 +844,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) {