188b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org/*
288b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org *  Copyright (c) 2012 The WebM project authors. All Rights Reserved.
388b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org *
488b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org *  Use of this source code is governed by a BSD-style license
588b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org *  that can be found in the LICENSE file in the root of the source
688b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org *  tree. An additional intellectual property rights grant can be found
788b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org *  in the file PATENTS.  All contributing project authors may
888b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org *  be found in the AUTHORS file in the root of the source tree.
988b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org */
1088b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org
1188b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org#ifndef VP9_ENCODER_DENOISER_H_
1288b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org#define VP9_ENCODER_DENOISER_H_
1388b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org
1488b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org#include "vp9/encoder/vp9_block.h"
1588b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org#include "vpx_scale/yv12config.h"
1688b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org
1788b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org#ifdef __cplusplus
1888b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.orgextern "C" {
1988b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org#endif
2088b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org
2187997d490ae52aa962a985c95b3cddf7f8832641johannkoenig@chromium.org#define MOTION_MAGNITUDE_THRESHOLD (8 * 3)
22d95585fb0ec024f6abd96f7b02e0df58019d46afjohannkoenig@chromium.org
23e2064011d36b2008099446503f28e64d445060ecjohannkoenig@chromium.orgtypedef enum vp9_denoiser_decision {
2488b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org  COPY_BLOCK,
2588b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org  FILTER_BLOCK
26e2064011d36b2008099446503f28e64d445060ecjohannkoenig@chromium.org} VP9_DENOISER_DECISION;
2788b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org
2888b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.orgtypedef struct vp9_denoiser {
2988b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org  YV12_BUFFER_CONFIG running_avg_y[MAX_REF_FRAMES];
3088b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org  YV12_BUFFER_CONFIG mc_running_avg_y;
31e2064011d36b2008099446503f28e64d445060ecjohannkoenig@chromium.org  int increase_denoising;
3288b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org} VP9_DENOISER;
3388b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org
3488b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.orgvoid vp9_denoiser_update_frame_info(VP9_DENOISER *denoiser,
3588b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org                                    YV12_BUFFER_CONFIG src,
3688b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org                                    FRAME_TYPE frame_type,
3788b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org                                    int refresh_alt_ref_frame,
3888b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org                                    int refresh_golden_frame,
3988b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org                                    int refresh_last_frame);
4088b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org
4188b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.orgvoid vp9_denoiser_denoise(VP9_DENOISER *denoiser, MACROBLOCK *mb,
42ac4e313c19203132648a2a271703b6ee76fe4284johannkoenig@chromium.org                          int mi_row, int mi_col, BLOCK_SIZE bs,
43ac4e313c19203132648a2a271703b6ee76fe4284johannkoenig@chromium.org                          PICK_MODE_CONTEXT *ctx);
4488b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org
45ac4e313c19203132648a2a271703b6ee76fe4284johannkoenig@chromium.orgvoid vp9_denoiser_reset_frame_stats(PICK_MODE_CONTEXT *ctx);
46e2064011d36b2008099446503f28e64d445060ecjohannkoenig@chromium.org
47d95585fb0ec024f6abd96f7b02e0df58019d46afjohannkoenig@chromium.orgvoid vp9_denoiser_update_frame_stats(MB_MODE_INFO *mbmi,
48ac4e313c19203132648a2a271703b6ee76fe4284johannkoenig@chromium.org                                     unsigned int sse, PREDICTION_MODE mode,
49ac4e313c19203132648a2a271703b6ee76fe4284johannkoenig@chromium.org                                     PICK_MODE_CONTEXT *ctx);
5088b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org
5188b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.orgint vp9_denoiser_alloc(VP9_DENOISER *denoiser, int width, int height,
52d95585fb0ec024f6abd96f7b02e0df58019d46afjohannkoenig@chromium.org                       int ssx, int ssy,
53d95585fb0ec024f6abd96f7b02e0df58019d46afjohannkoenig@chromium.org#if CONFIG_VP9_HIGHBITDEPTH
54d95585fb0ec024f6abd96f7b02e0df58019d46afjohannkoenig@chromium.org                       int use_highbitdepth,
55d95585fb0ec024f6abd96f7b02e0df58019d46afjohannkoenig@chromium.org#endif
56d95585fb0ec024f6abd96f7b02e0df58019d46afjohannkoenig@chromium.org                       int border);
5788b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org
5888b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.orgvoid vp9_denoiser_free(VP9_DENOISER *denoiser);
5988b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org
6088b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org#ifdef __cplusplus
6188b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org}  // extern "C"
6288b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org#endif
6388b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org
6488b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org#endif  // VP9_ENCODER_DENOISER_H_
65