vpx/vp8/encoder/denoising.h
Yunqing Wang 64075c9b01 Encoder denoiser performance improvement
The denoiser function was modified to reduce the computational
complexity.

1. The denoiser c function modification:
The original implementation calculated pixel's filter_coefficient
based on the pixel value difference between current raw frame and last
denoised raw frame, and stored them in lookup tables. For each pixel c,
find its coefficient using
    filter_coefficient[c] = LUT[abs_diff[c]];
and then apply filtering operation for the pixel.

The denoising filter costed about 12% of encoding time when it was
turned on, and half of the time was spent on finding coefficients in
lookup tables. In order to simplify the process, a short cut was taken.
The pixel adjustments vs. pixel diff value were calculated ahead of time.
    adjustment = filtered_value - current_raw
               = (filter_coefficient * diff + 128) >> 8

The adjustment vs. diff curve becomes flat very quick when diff increases.
This allowed us to use only several levels to get a close approximation
of the curve. Following the denoiser algorithm, the adjustments are
further modified according to how big the motion magnitude is.

2. The sse2 function was rewritten.

This change made denoiser filter function 3x faster, and improved the
encoder performance by 7% ~ 10% with the denoiser on.

Change-Id: I93a4308963b8e80c7307f96ffa8b8c667425bf50
2012-08-31 13:48:13 -07:00

43 lines
1.2 KiB
C

/*
* 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 VP8_ENCODER_DENOISING_H_
#define VP8_ENCODER_DENOISING_H_
#include "block.h"
#define SUM_DIFF_THRESHOLD (16 * 16 * 2)
#define MOTION_MAGNITUDE_THRESHOLD (8*3)
enum vp8_denoiser_decision
{
COPY_BLOCK,
FILTER_BLOCK
};
typedef struct vp8_denoiser
{
YV12_BUFFER_CONFIG yv12_running_avg[MAX_REF_FRAMES];
YV12_BUFFER_CONFIG yv12_mc_running_avg;
} VP8_DENOISER;
int vp8_denoiser_allocate(VP8_DENOISER *denoiser, int width, int height);
void vp8_denoiser_free(VP8_DENOISER *denoiser);
void vp8_denoiser_denoise_mb(VP8_DENOISER *denoiser,
MACROBLOCK *x,
unsigned int best_sse,
unsigned int zero_mv_sse,
int recon_yoffset,
int recon_uvoffset);
#endif /* VP8_ENCODER_DENOISING_H_ */