shithub: libvpx

Download patch

ref: 04db83211cd1607f51155c6a8e51381f45a441a5
parent: 7122eea6a42b136c6e4b59663847ba39e021b73a
author: angiebird <angiebird@google.com>
date: Mon Aug 10 11:59:30 EDT 2020

Correct the first pass motion vector scale

Change-Id: I005a648f7f9ead9d36a39330dfbb096919affb34

--- a/vp9/simple_encode.cc
+++ b/vp9/simple_encode.cc
@@ -167,7 +167,8 @@
 
 static void update_motion_vector_info(
     const MOTION_VECTOR_INFO *input_motion_vector_info, const int num_rows_4x4,
-    const int num_cols_4x4, MotionVectorInfo *output_motion_vector_info) {
+    const int num_cols_4x4, MotionVectorInfo *output_motion_vector_info,
+    int motion_vector_scale) {
   const int num_units_4x4 = num_rows_4x4 * num_cols_4x4;
   for (int i = 0; i < num_units_4x4; ++i) {
     const MV_REFERENCE_FRAME *in_ref_frame =
@@ -185,16 +186,16 @@
         mv_ref_frame_to_ref_frame_type(in_ref_frame[1]);
     output_motion_vector_info[i].mv_row[0] =
         (double)input_motion_vector_info[i].mv[0].as_mv.row /
-        kMotionVectorPrecision;
+        motion_vector_scale;
     output_motion_vector_info[i].mv_column[0] =
         (double)input_motion_vector_info[i].mv[0].as_mv.col /
-        kMotionVectorPrecision;
+        motion_vector_scale;
     output_motion_vector_info[i].mv_row[1] =
         (double)input_motion_vector_info[i].mv[1].as_mv.row /
-        kMotionVectorPrecision;
+        motion_vector_scale;
     output_motion_vector_info[i].mv_column[1] =
         (double)input_motion_vector_info[i].mv[1].as_mv.col /
-        kMotionVectorPrecision;
+        motion_vector_scale;
   }
 }
 
@@ -523,7 +524,8 @@
   update_motion_vector_info(encode_frame_info->motion_vector_info,
                             encode_frame_result->num_rows_4x4,
                             encode_frame_result->num_cols_4x4,
-                            &encode_frame_result->motion_vector_info[0]);
+                            &encode_frame_result->motion_vector_info[0],
+                            kMotionVectorSubPixelPrecision);
   update_frame_counts(&encode_frame_info->frame_counts,
                       &encode_frame_result->frame_counts);
   encode_frame_result_update_rq_history(&encode_frame_info->rq_history,
@@ -793,7 +795,8 @@
         // Get vp9 first pass motion vector info.
         std::vector<MotionVectorInfo> mv_info(num_rows_16x16 * num_cols_16x16);
         update_motion_vector_info(cpi->fp_motion_vector_info, num_rows_16x16,
-                                  num_cols_16x16, mv_info.data());
+                                  num_cols_16x16, mv_info.data(),
+                                  kMotionVectorFullPixelPrecision);
         fp_motion_vector_info_.push_back(mv_info);
       }
       impl_ptr_->first_pass_stats.push_back(vp9_get_frame_stats(&cpi->twopass));
--- a/vp9/simple_encode.h
+++ b/vp9/simple_encode.h
@@ -58,7 +58,8 @@
   int height;        // prediction block height
 };
 
-constexpr int kMotionVectorPrecision = 8;
+constexpr int kMotionVectorSubPixelPrecision = 8;
+constexpr int kMotionVectorFullPixelPrecision = 1;
 
 // In the first pass. The frame is split to 16x16 blocks.
 // This structure contains the information of each 16x16 block.