2
0

vp9_denoiser.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. #ifndef VP9_ENCODER_DENOISER_H_
  11. #define VP9_ENCODER_DENOISER_H_
  12. #include "vp9/encoder/vp9_block.h"
  13. #include "vp9/encoder/vp9_skin_detection.h"
  14. #include "vpx_scale/yv12config.h"
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. #define MOTION_MAGNITUDE_THRESHOLD (8 * 3)
  19. typedef enum vp9_denoiser_decision {
  20. COPY_BLOCK,
  21. FILTER_BLOCK,
  22. FILTER_ZEROMV_BLOCK
  23. } VP9_DENOISER_DECISION;
  24. typedef enum vp9_denoiser_level {
  25. kDenLowLow,
  26. kDenLow,
  27. kDenMedium,
  28. kDenHigh
  29. } VP9_DENOISER_LEVEL;
  30. typedef struct vp9_denoiser {
  31. YV12_BUFFER_CONFIG running_avg_y[MAX_REF_FRAMES];
  32. YV12_BUFFER_CONFIG mc_running_avg_y;
  33. YV12_BUFFER_CONFIG last_source;
  34. int increase_denoising;
  35. int frame_buffer_initialized;
  36. int reset;
  37. VP9_DENOISER_LEVEL denoising_level;
  38. VP9_DENOISER_LEVEL prev_denoising_level;
  39. } VP9_DENOISER;
  40. typedef struct {
  41. int64_t zero_last_cost_orig;
  42. int *ref_frame_cost;
  43. int_mv (*frame_mv)[MAX_REF_FRAMES];
  44. int reuse_inter_pred;
  45. TX_SIZE best_tx_size;
  46. PREDICTION_MODE best_mode;
  47. MV_REFERENCE_FRAME best_ref_frame;
  48. INTERP_FILTER best_pred_filter;
  49. uint8_t best_mode_skip_txfm;
  50. } VP9_PICKMODE_CTX_DEN;
  51. struct VP9_COMP;
  52. void vp9_denoiser_update_frame_info(VP9_DENOISER *denoiser,
  53. YV12_BUFFER_CONFIG src,
  54. FRAME_TYPE frame_type,
  55. int refresh_alt_ref_frame,
  56. int refresh_golden_frame,
  57. int refresh_last_frame, int resized);
  58. void vp9_denoiser_denoise(struct VP9_COMP *cpi, MACROBLOCK *mb, int mi_row,
  59. int mi_col, BLOCK_SIZE bs, PICK_MODE_CONTEXT *ctx,
  60. VP9_DENOISER_DECISION *denoiser_decision);
  61. void vp9_denoiser_reset_frame_stats(PICK_MODE_CONTEXT *ctx);
  62. void vp9_denoiser_update_frame_stats(MODE_INFO *mi, unsigned int sse,
  63. PREDICTION_MODE mode,
  64. PICK_MODE_CONTEXT *ctx);
  65. int vp9_denoiser_alloc(VP9_DENOISER *denoiser, int width, int height, int ssx,
  66. int ssy,
  67. #if CONFIG_VP9_HIGHBITDEPTH
  68. int use_highbitdepth,
  69. #endif
  70. int border);
  71. #if CONFIG_VP9_TEMPORAL_DENOISING
  72. // This function is used by both c and sse2 denoiser implementations.
  73. // Define it as a static function within the scope where vp9_denoiser.h
  74. // is referenced.
  75. static INLINE int total_adj_strong_thresh(BLOCK_SIZE bs,
  76. int increase_denoising) {
  77. return (1 << num_pels_log2_lookup[bs]) * (increase_denoising ? 3 : 2);
  78. }
  79. #endif
  80. void vp9_denoiser_free(VP9_DENOISER *denoiser);
  81. void vp9_denoiser_set_noise_level(VP9_DENOISER *denoiser, int noise_level);
  82. #ifdef __cplusplus
  83. } // extern "C"
  84. #endif
  85. #endif // VP9_ENCODER_DENOISER_H_