VP9 denoiser bugfixes

s/stdint.h/vpx\/vpx_int.h

Added missing 'break;'s

Also included other minor changes, mostly cosmetic.

Change-Id: I852bba3e85e794f1d4af854c45c16a23a787e6a3
This commit is contained in:
Tim Kopp 2014-06-13 13:58:57 -07:00
parent 7820abe53c
commit 31c03b31fe

View File

@ -8,10 +8,10 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include <stdio.h>
#include <stdint.h>
#include "vp9/encoder/vp9_denoiser.h"
#include <assert.h>
#include "vpx_scale/yv12config.h"
#include "vpx/vpx_integer.h"
#include "vp9/encoder/vp9_denoiser.h"
static const int widths[] = {4, 4, 8, 8, 8, 16, 16, 16, 32, 32, 32, 64, 64};
static const int heights[] = {4, 8, 4, 8, 16, 8, 16, 32, 16, 32, 64, 32, 64};
@ -20,9 +20,10 @@ int vp9_denoiser_filter() {
return 0;
}
int update_running_avg(uint8_t *mc_avg, int mc_avg_stride, uint8_t *avg,
int avg_stride, uint8_t *sig, int sig_stride,
int increase_denoising, BLOCK_SIZE bs) {
static int update_running_avg(const uint8_t *mc_avg, int mc_avg_stride,
uint8_t *avg, int avg_stride,
const uint8_t *sig, int sig_stride,
int increase_denoising, BLOCK_SIZE bs) {
int r, c;
int diff, adj, absdiff;
int shift_inc1 = 0, shift_inc2 = 1;
@ -46,9 +47,11 @@ int update_running_avg(uint8_t *mc_avg, int mc_avg_stride, uint8_t *avg,
switch (absdiff) {
case 4: case 5: case 6: case 7:
adj = adj_val[0];
break;
case 8: case 9: case 10: case 11:
case 12: case 13: case 14: case 15:
adj = adj_val[1];
break;
default:
adj = adj_val[2];
}
@ -68,7 +71,8 @@ int update_running_avg(uint8_t *mc_avg, int mc_avg_stride, uint8_t *avg,
return total_adj;
}
uint8_t *block_start(uint8_t *framebuf, int stride, int mi_row, int mi_col) {
static uint8_t *block_start(uint8_t *framebuf, int stride,
int mi_row, int mi_col) {
return framebuf + (stride * mi_row * 8) + (mi_col * 8);
}
@ -82,7 +86,6 @@ void copy_block(uint8_t *dest, int dest_stride,
dest += dest_stride;
src += src_stride;
}
return;
}
void vp9_denoiser_denoise(VP9_DENOISER *denoiser, MACROBLOCK *mb,
@ -99,17 +102,17 @@ void vp9_denoiser_denoise(VP9_DENOISER *denoiser, MACROBLOCK *mb,
mb->plane[0].src.buf, mb->plane[0].src.stride, 0, bs);
if (decision == FILTER_BLOCK) {
// TODO(tkopp)
}
if (decision == COPY_BLOCK) {
copy_block(block_start(avg.y_buffer, avg.y_stride, mi_row, mi_col),
avg.y_stride, src.buf, src.stride, bs);
}
return;
}
void copy_frame(YV12_BUFFER_CONFIG dest, YV12_BUFFER_CONFIG src) {
static void copy_frame(YV12_BUFFER_CONFIG dest, const YV12_BUFFER_CONFIG src) {
int r, c;
uint8_t *srcbuf = src.y_buffer;
const uint8_t *srcbuf = src.y_buffer;
uint8_t *destbuf = dest.y_buffer;
assert(dest.y_width == src.y_width);
assert(dest.y_height == src.y_height);
@ -121,7 +124,6 @@ void copy_frame(YV12_BUFFER_CONFIG dest, YV12_BUFFER_CONFIG src) {
destbuf += dest.y_stride;
srcbuf += src.y_stride;
}
return;
}
void vp9_denoiser_update_frame_info(VP9_DENOISER *denoiser,
@ -130,14 +132,14 @@ void vp9_denoiser_update_frame_info(VP9_DENOISER *denoiser,
int refresh_alt_ref_frame,
int refresh_golden_frame,
int refresh_last_frame) {
int i;
if (frame_type == KEY_FRAME) {
int i;
copy_frame(denoiser->running_avg_y[LAST_FRAME], src);
for (i = 2; i < MAX_REF_FRAMES - 1; i++) {
copy_frame(denoiser->running_avg_y[i],
denoiser->running_avg_y[LAST_FRAME]);
}
} else { /* For non key frames */
} else { /* For non key frames */
if (refresh_alt_ref_frame) {
copy_frame(denoiser->running_avg_y[ALTREF_FRAME],
denoiser->running_avg_y[INTRA_FRAME]);
@ -151,22 +153,19 @@ void vp9_denoiser_update_frame_info(VP9_DENOISER *denoiser,
denoiser->running_avg_y[INTRA_FRAME]);
}
}
return;
}
void vp9_denoiser_update_frame_stats() {
return;
}
int vp9_denoiser_alloc(VP9_DENOISER *denoiser, int width, int height,
int ssx, int ssy, int border) {
int i, fail;
assert(denoiser);
assert(denoiser != NULL);
for (i = 0; i < MAX_REF_FRAMES; ++i) {
fail = vp9_alloc_frame_buffer(&denoiser->running_avg_y[i], width, height,
ssx, ssy, border);
ssx, ssy, border);
if (fail) {
vp9_denoiser_free(denoiser);
return 1;
@ -174,7 +173,7 @@ int vp9_denoiser_alloc(VP9_DENOISER *denoiser, int width, int height,
}
fail = vp9_alloc_frame_buffer(&denoiser->mc_running_avg_y, width, height,
ssx, ssy, border);
ssx, ssy, border);
if (fail) {
vp9_denoiser_free(denoiser);
return 1;
@ -185,6 +184,9 @@ int vp9_denoiser_alloc(VP9_DENOISER *denoiser, int width, int height,
void vp9_denoiser_free(VP9_DENOISER *denoiser) {
int i;
if (denoiser == NULL) {
return;
}
for (i = 0; i < MAX_REF_FRAMES; ++i) {
if (&denoiser->running_avg_y[i] != NULL) {
vp9_free_frame_buffer(&denoiser->running_avg_y[i]);
@ -193,6 +195,4 @@ void vp9_denoiser_free(VP9_DENOISER *denoiser) {
if (&denoiser->mc_running_avg_y != NULL) {
vp9_free_frame_buffer(&denoiser->mc_running_avg_y);
}
return;
}