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 "vp9/encoder/vp9_skin_detection.h" 16 #include "vpx_scale/yv12config.h" 17 18 #ifdef __cplusplus 19 extern "C" { 20 #endif 21 22 #define MOTION_MAGNITUDE_THRESHOLD (8 * 3) 23 24 typedef enum vp9_denoiser_decision { 25 COPY_BLOCK, 26 FILTER_BLOCK 27 } VP9_DENOISER_DECISION; 28 29 typedef struct vp9_denoiser { 30 YV12_BUFFER_CONFIG running_avg_y[MAX_REF_FRAMES]; 31 YV12_BUFFER_CONFIG mc_running_avg_y; 32 YV12_BUFFER_CONFIG last_source; 33 int increase_denoising; 34 int frame_buffer_initialized; 35 int denoising_on; 36 int noise_estimate; 37 int thresh_noise_estimate; 38 int noise_estimate_count; 39 } VP9_DENOISER; 40 41 struct VP9_COMP; 42 43 void vp9_denoiser_update_frame_info(VP9_DENOISER *denoiser, 44 YV12_BUFFER_CONFIG src, 45 FRAME_TYPE frame_type, 46 int refresh_alt_ref_frame, 47 int refresh_golden_frame, 48 int refresh_last_frame, 49 int resized); 50 51 void vp9_denoiser_denoise(VP9_DENOISER *denoiser, MACROBLOCK *mb, 52 int mi_row, int mi_col, BLOCK_SIZE bs, 53 PICK_MODE_CONTEXT *ctx); 54 55 void vp9_denoiser_reset_frame_stats(PICK_MODE_CONTEXT *ctx); 56 57 void vp9_denoiser_update_frame_stats(MB_MODE_INFO *mbmi, 58 unsigned int sse, PREDICTION_MODE mode, 59 PICK_MODE_CONTEXT *ctx); 60 61 int vp9_denoiser_alloc(VP9_DENOISER *denoiser, int width, int height, 62 int ssx, int ssy, 63 #if CONFIG_VP9_HIGHBITDEPTH 64 int use_highbitdepth, 65 #endif 66 int border); 67 68 #if CONFIG_VP9_TEMPORAL_DENOISING 69 // This function is used by both c and sse2 denoiser implementations. 70 // Define it as a static function within the scope where vp9_denoiser.h 71 // is referenced. 72 static int total_adj_strong_thresh(BLOCK_SIZE bs, int increase_denoising) { 73 return (1 << num_pels_log2_lookup[bs]) * (increase_denoising ? 3 : 2); 74 } 75 #endif 76 77 void vp9_denoiser_free(VP9_DENOISER *denoiser); 78 79 void vp9_denoiser_init_noise_estimate(VP9_DENOISER *denoiser, 80 int width, 81 int height); 82 83 void vp9_denoiser_update_noise_estimate(struct VP9_COMP *const cpi); 84 85 #ifdef __cplusplus 86 } // extern "C" 87 #endif 88 89 #endif // VP9_ENCODER_DENOISER_H_ 90