]> granicus.if.org Git - libvpx/commitdiff
Added skeleton for VP9 denoiser
authorTim Kopp <tkopp@google.com>
Thu, 5 Jun 2014 21:00:08 +0000 (14:00 -0700)
committerTim Kopp <tkopp@google.com>
Thu, 12 Jun 2014 22:12:22 +0000 (15:12 -0700)
Change-Id: Iccf6ede4c4f85646b0f8daec47050ce93e267c90

configure
vp9/encoder/vp9_denoiser.c [new file with mode: 0644]
vp9/encoder/vp9_denoiser.h [new file with mode: 0644]
vp9/encoder/vp9_encoder.c
vp9/encoder/vp9_encoder.h
vp9/encoder/vp9_pickmode.c
vp9/vp9cx.mk

index 800553eb4cf34a7947f0b1c424b9dfac860415ca..9a7de73b181197126abf65a3664bf2a9500913d4 100755 (executable)
--- a/configure
+++ b/configure
@@ -272,6 +272,7 @@ EXPERIMENT_LIST="
     alpha
     multiple_arf
     spatial_svc
+    denoising
 "
 CONFIG_LIST="
     external_build
diff --git a/vp9/encoder/vp9_denoiser.c b/vp9/encoder/vp9_denoiser.c
new file mode 100644 (file)
index 0000000..687b4c2
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ *  Copyright (c) 2012 The WebM project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include "vp9/encoder/vp9_denoiser.h"
+#include "vpx_scale/yv12config.h"
+
+static const int widths[]  = {4, 4, 8, 8,  8, 16, 16, 16, 32, 32, 32, 64, 64};
+static const int heights[] = {4, 8, 4, 8, 16,  8, 16, 32, 16, 32, 64, 32, 64};
+
+int vp9_denoiser_filter() {
+  return 0;
+}
+
+void vp9_denoiser_denoise(VP9_DENOISER *denoiser,
+                          MACROBLOCK *mb, MODE_INFO **grid,
+                          int mi_row, int mi_col, BLOCK_SIZE bs) {
+  return;
+}
+
+void vp9_denoiser_update_frame_info(VP9_DENOISER *denoiser,
+                                    FRAME_TYPE frame_type,
+                                    int refresh_alt_ref_frame,
+                                    int refresh_golden_frame,
+                                    int refresh_last_frame) {
+  return;
+}
+
+void vp9_denoiser_update_frame_stats() {
+  return;
+}
+
+int vp9_denoiser_alloc(VP9_DENOISER *denoiser, int width, int height,
+                       int border) {
+  return 0;
+}
+
+void vp9_denoiser_free(VP9_DENOISER *denoiser) {
+  return;
+}
+
diff --git a/vp9/encoder/vp9_denoiser.h b/vp9/encoder/vp9_denoiser.h
new file mode 100644 (file)
index 0000000..a7a8d93
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ *  Copyright (c) 2012 The WebM project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef VP9_ENCODER_DENOISER_H_
+#define VP9_ENCODER_DENOISER_H_
+
+#include "vp9/encoder/vp9_block.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum vp9_denoiser_decision {
+  COPY_BLOCK,
+  FILTER_BLOCK
+};
+
+typedef struct vp9_denoiser {
+  struct buf_2d running_avg_y;
+  struct buf_2d mc_running_avg_y;
+} VP9_DENOISER;
+
+void vp9_denoiser_update_frame_info(VP9_DENOISER *denoiser,
+                                    FRAME_TYPE frame_type,
+                                    int refresh_alt_ref_frame,
+                                    int refresh_golden_frame,
+                                    int refresh_last_frame);
+
+void vp9_denoiser_denoise(VP9_DENOISER *denoiser,
+                          MACROBLOCK *mb, MODE_INFO **grid,
+                          int mi_row, int mi_col, BLOCK_SIZE bs);
+
+void vp9_denoiser_update_frame_stats();
+
+int vp9_denoiser_alloc(VP9_DENOISER *denoiser, int width, int height,
+                       int border);
+
+void vp9_denoiser_free(VP9_DENOISER *denoiser);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
+#endif  // VP9_ENCODER_DENOISER_H_
index aa7a91dc137f7a6bc34193b8209d8f7463c11678..eeee1f04f6ea05dfcb001ffd9d38fab334ded2fe 100644 (file)
@@ -680,6 +680,11 @@ void vp9_change_config(struct VP9_COMP *cpi, const VP9EncoderConfig *oxcf) {
 
   cpi->ext_refresh_frame_flags_pending = 0;
   cpi->ext_refresh_frame_context_pending = 0;
+
+#if CONFIG_DENOISING
+  vp9_denoiser_alloc(&(cpi->denoiser), cm->width, cm->height,
+                     VP9_ENC_BORDER_IN_PIXELS);
+#endif
 }
 
 #ifndef M_LOG2_E
@@ -1085,6 +1090,10 @@ void vp9_remove_compressor(VP9_COMP *cpi) {
 #endif
   }
 
+#if CONFIG_DENOISING
+  vp9_denoiser_free(&(cpi->denoiser));
+#endif
+
   dealloc_compressor_data(cpi);
   vpx_free(cpi->tok);
 
@@ -1547,6 +1556,13 @@ void vp9_update_reference_frames(VP9_COMP *cpi) {
     ref_cnt_fb(cm->frame_bufs,
                &cm->ref_frame_map[cpi->lst_fb_idx], cm->new_fb_idx);
   }
+#if CONFIG_DENOISING
+  vp9_denoiser_update_frame_info(&cpi->denoiser,
+                                cpi->common.frame_type,
+                                cpi->refresh_alt_ref_frame,
+                                cpi->refresh_golden_frame,
+                                cpi->refresh_last_frame);
+#endif
 }
 
 static void loopfilter_frame(VP9_COMP *cpi, VP9_COMMON *cm) {
index 6b0e228ca33776b8153d0644b61bc4903ed78b35..4364939b1104eece9e5f08f36b68d2e187521b95 100644 (file)
@@ -36,6 +36,9 @@
 #include "vp9/encoder/vp9_svc_layercontext.h"
 #include "vp9/encoder/vp9_tokenize.h"
 #include "vp9/encoder/vp9_variance.h"
+#if CONFIG_DENOISING
+#include "vp9/encoder/vp9_denoiser.h"
+#endif
 
 #ifdef __cplusplus
 extern "C" {
@@ -526,6 +529,10 @@ typedef struct VP9_COMP {
   int this_frame_weight;
   int max_arf_level;
 #endif
+
+#if CONFIG_DENOISING
+  VP9_DENOISER denoiser;
+#endif
 } VP9_COMP;
 
 void vp9_initialize_enc();
index 4b0b85ad445542b225ef31fc1835a69093117cc2..e3f9d3bf198525d89b6bb62ba6160c3c2de8999d 100644 (file)
@@ -438,6 +438,10 @@ int64_t vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
         }
       }
 
+#if CONFIG_DENOISING
+    vp9_denoiser_update_frame_stats();
+#endif
+
       if (this_rd < best_rd || x->skip) {
         best_rd = this_rd;
         *returnrate = rate;
@@ -453,6 +457,7 @@ int64_t vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
     }
   }
 
+
   mbmi->mode = best_mode;
   mbmi->interp_filter = best_pred_filter;
   mbmi->ref_frame[0] = best_ref_frame;
@@ -488,6 +493,10 @@ int64_t vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
       }
     }
   }
+#if CONFIG_DENOISING
+  vp9_denoiser_denoise(&cpi->denoiser, x, cpi->common.mi_grid_visible, mi_row,
+                       mi_col, bsize);
+#endif
 
   return INT64_MAX;
 }
index a44ffc1ca0b4402ddd65988ed0ac30ab2c11710f..9dbb6781017f518013f511b25cf59c574248caa3 100644 (file)
@@ -23,6 +23,8 @@ VP9_CX_SRCS-yes += encoder/vp9_context_tree.h
 VP9_CX_SRCS-yes += encoder/vp9_cost.h
 VP9_CX_SRCS-yes += encoder/vp9_cost.c
 VP9_CX_SRCS-yes += encoder/vp9_dct.c
+VP9_CX_SRCS-$(CONFIG_DENOISING) += encoder/vp9_denoiser.c
+VP9_CX_SRCS-$(CONFIG_DENOISING) += encoder/vp9_denoiser.h
 VP9_CX_SRCS-yes += encoder/vp9_encodeframe.c
 VP9_CX_SRCS-yes += encoder/vp9_encodeframe.h
 VP9_CX_SRCS-yes += encoder/vp9_encodemb.c