• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2012 The WebM project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef VP9_ENCODER_DENOISER_H_
12 #define VP9_ENCODER_DENOISER_H_
13 
14 #include "vp9/encoder/vp9_block.h"
15 #include "vpx_scale/yv12config.h"
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 #define MOTION_MAGNITUDE_THRESHOLD (8 * 3)
22 
23 typedef enum vp9_denoiser_decision {
24   COPY_BLOCK,
25   FILTER_BLOCK
26 } VP9_DENOISER_DECISION;
27 
28 typedef struct vp9_denoiser {
29   YV12_BUFFER_CONFIG running_avg_y[MAX_REF_FRAMES];
30   YV12_BUFFER_CONFIG mc_running_avg_y;
31   int increase_denoising;
32   int frame_buffer_initialized;
33 } VP9_DENOISER;
34 
35 void vp9_denoiser_update_frame_info(VP9_DENOISER *denoiser,
36                                     YV12_BUFFER_CONFIG src,
37                                     FRAME_TYPE frame_type,
38                                     int refresh_alt_ref_frame,
39                                     int refresh_golden_frame,
40                                     int refresh_last_frame);
41 
42 void vp9_denoiser_denoise(VP9_DENOISER *denoiser, MACROBLOCK *mb,
43                           int mi_row, int mi_col, BLOCK_SIZE bs,
44                           PICK_MODE_CONTEXT *ctx);
45 
46 void vp9_denoiser_reset_frame_stats(PICK_MODE_CONTEXT *ctx);
47 
48 void vp9_denoiser_update_frame_stats(MB_MODE_INFO *mbmi,
49                                      unsigned int sse, PREDICTION_MODE mode,
50                                      PICK_MODE_CONTEXT *ctx);
51 
52 int vp9_denoiser_alloc(VP9_DENOISER *denoiser, int width, int height,
53                        int ssx, int ssy,
54 #if CONFIG_VP9_HIGHBITDEPTH
55                        int use_highbitdepth,
56 #endif
57                        int border);
58 
59 #if CONFIG_VP9_TEMPORAL_DENOISING
60 // This function is used by both c and sse2 denoiser implementations.
61 // Define it as a static function within the scope where vp9_denoiser.h
62 // is referenced.
total_adj_strong_thresh(BLOCK_SIZE bs,int increase_denoising)63 static int total_adj_strong_thresh(BLOCK_SIZE bs, int increase_denoising) {
64   return (1 << num_pels_log2_lookup[bs]) * (increase_denoising ? 3 : 2);
65 }
66 #endif
67 
68 void vp9_denoiser_free(VP9_DENOISER *denoiser);
69 
70 #ifdef __cplusplus
71 }  // extern "C"
72 #endif
73 
74 #endif  // VP9_ENCODER_DENOISER_H_
75