ref: b0959b8195fdca51afa51fb51cf06558fa9889a8
parent: 83269ff8ff1b17ebf5abffafd56d1bbf04420f21
parent: 52462bf7a8abd1af60105ef6e3e7e5886766985d
author: Tim Kopp <[email protected]>
date: Fri Jun 27 11:41:51 EDT 2014
Merge "VP9 denoiser: implemented update_frame_stats()"
--- a/vp9/encoder/vp9_denoiser.c
+++ b/vp9/encoder/vp9_denoiser.c
@@ -9,6 +9,7 @@
*/
#include <assert.h>
+#include <limits.h>
#include "vpx_scale/yv12config.h"
#include "vpx/vpx_integer.h"
#include "vp9/encoder/vp9_denoiser.h"
@@ -156,9 +157,27 @@
}
}
-void vp9_denoiser_update_frame_stats() {
+void vp9_denoiser_reset_frame_stats(VP9_DENOISER *denoiser) {
+ denoiser->zero_mv_sse = UINT_MAX;
+ denoiser->best_sse = UINT_MAX;
}
+void vp9_denoiser_update_frame_stats(VP9_DENOISER *denoiser, MB_MODE_INFO *mbmi,
+ unsigned int sse, PREDICTION_MODE mode) {
+ // TODO(tkopp): Use both MVs if possible
+ if (mbmi->mv[0].as_int == 0 && sse < denoiser->zero_mv_sse) {
+ denoiser->zero_mv_sse = sse;
+ denoiser->best_zeromv_reference_frame = mbmi->ref_frame[0];
+ }
+
+ if (mbmi->mv[0].as_int != 0 && sse < denoiser->best_sse) {
+ denoiser->best_sse = sse;
+ denoiser->best_sse_inter_mode = mode;
+ denoiser->best_sse_mv = mbmi->mv[0];
+ denoiser->best_reference_frame = mbmi->ref_frame[0];
+ }
+}
+
int vp9_denoiser_alloc(VP9_DENOISER *denoiser, int width, int height,
int ssx, int ssy, int border) {
int i, fail;
@@ -179,6 +198,8 @@
vp9_denoiser_free(denoiser);
return 1;
}
+
+ denoiser->increase_denoising = 0;
return 0;
}
--- a/vp9/encoder/vp9_denoiser.h
+++ b/vp9/encoder/vp9_denoiser.h
@@ -26,6 +26,14 @@
typedef struct vp9_denoiser {
YV12_BUFFER_CONFIG running_avg_y[MAX_REF_FRAMES];
YV12_BUFFER_CONFIG mc_running_avg_y;
+
+ unsigned int zero_mv_sse;
+ unsigned int best_sse;
+ int increase_denoising;
+ PREDICTION_MODE best_sse_inter_mode;
+ int_mv best_sse_mv;
+ MV_REFERENCE_FRAME best_reference_frame;
+ MV_REFERENCE_FRAME best_zeromv_reference_frame;
} VP9_DENOISER;
void vp9_denoiser_update_frame_info(VP9_DENOISER *denoiser,
@@ -38,7 +46,10 @@
void vp9_denoiser_denoise(VP9_DENOISER *denoiser, MACROBLOCK *mb,
int mi_row, int mi_col, BLOCK_SIZE bs);
-void vp9_denoiser_update_frame_stats();
+void vp9_denoiser_reset_frame_stats(VP9_DENOISER *denoiser);
+
+void vp9_denoiser_update_frame_stats(VP9_DENOISER *denoiser, MB_MODE_INFO *mbmi,
+ unsigned int sse, PREDICTION_MODE mode);
int vp9_denoiser_alloc(VP9_DENOISER *denoiser, int width, int height,
int ssx, int ssy, int border);
--- a/vp9/encoder/vp9_pickmode.c
+++ b/vp9/encoder/vp9_pickmode.c
@@ -352,6 +352,10 @@
PRED_BUFFER *this_mode_pred = NULL;
int i;
+#if CONFIG_DENOISING
+ vp9_denoiser_reset_frame_stats(&cpi->denoiser);
+#endif
+
if (cpi->sf.reuse_inter_pred_sby) {
for (i = 0; i < 3; i++) {
tmp[i].data = &pred_buf[pixels_in_block * i];
@@ -637,7 +641,7 @@
}
#if CONFIG_DENOISING
- vp9_denoiser_update_frame_stats();
+ vp9_denoiser_update_frame_stats(&cpi->denoiser, mbmi, sse_y, this_mode);
#endif
if (this_rd < best_rd || x->skip) {