shithub: libvpx

Download patch

ref: cb338d452f81cb6004be662721a151faae06d737
parent: fc905edb3a0f0330957094b2836ef8bf03573e04
author: Jingning Han <[email protected]>
date: Mon Aug 27 11:58:41 EDT 2018

Properly update the raw_src_frame for psnr calculation

Update the raw_src_frame to be the current input source frame in
the show_existing_frame mode.

Change-Id: Ia8edf49ca948c45ffe6c60556756b36124ab092a

--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -3831,6 +3831,20 @@
 }
 #endif
 
+static INLINE void set_raw_source_frame(VP9_COMP *cpi) {
+#ifdef ENABLE_KF_DENOISE
+  if (is_spatial_denoise_enabled(cpi)) {
+    cpi->raw_source_frame = vp9_scale_if_required(
+        cm, &cpi->raw_unscaled_source, &cpi->raw_scaled_source,
+        (oxcf->pass == 0), EIGHTTAP, 0);
+  } else {
+    cpi->raw_source_frame = cpi->Source;
+  }
+#else
+  cpi->raw_source_frame = cpi->Source;
+#endif
+}
+
 static int encode_without_recode_loop(VP9_COMP *cpi, size_t *size,
                                       uint8_t *dest) {
   VP9_COMMON *const cm = &cpi->common;
@@ -3844,7 +3858,10 @@
           ? cpi->svc.downsample_filter_phase[cpi->svc.spatial_layer_id]
           : 0;
 
-  if (cm->show_existing_frame) return 1;
+  if (cm->show_existing_frame) {
+    if (is_psnr_calc_enabled(cpi)) set_raw_source_frame(cpi);
+    return 1;
+  }
 
   // Flag to check if its valid to compute the source sad (used for
   // scene detection and for superblock content state in CBR mode).
@@ -4123,7 +4140,10 @@
   int qrange_adj = 1;
 #endif
 
-  if (cm->show_existing_frame) return;
+  if (cm->show_existing_frame) {
+    if (is_psnr_calc_enabled(cpi)) set_raw_source_frame(cpi);
+    return;
+  }
 
   set_size_independent_vars(cpi);