From b56f3af7db6a6a8adf0b004f30b80368bebac690 Mon Sep 17 00:00:00 2001 From: Tim Kopp Date: Fri, 13 Jun 2014 12:43:52 -0700 Subject: [PATCH] Fixes in VP9 alloc, free, and COPY_FRAME case Change-Id: I1216f17e2206ef521fe219b6d72d8e41d1ba1147 --- vp9/encoder/vp9_denoiser.c | 25 +++++++++++++++++-------- vp9/encoder/vp9_denoiser.h | 3 +-- vp9/encoder/vp9_pickmode.c | 3 +-- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/vp9/encoder/vp9_denoiser.c b/vp9/encoder/vp9_denoiser.c index ae78b69b4..cc736f86b 100644 --- a/vp9/encoder/vp9_denoiser.c +++ b/vp9/encoder/vp9_denoiser.c @@ -69,7 +69,7 @@ int update_running_avg(uint8_t *mc_avg, int mc_avg_stride, uint8_t *avg, } uint8_t *block_start(uint8_t *framebuf, int stride, int mi_row, int mi_col) { - return framebuf + (stride * mi_row) + mi_col; + return framebuf + (stride * mi_row * 8) + (mi_col * 8); } void copy_block(uint8_t *dest, int dest_stride, @@ -85,8 +85,7 @@ void copy_block(uint8_t *dest, int dest_stride, return; } -void vp9_denoiser_denoise(VP9_DENOISER *denoiser, - MACROBLOCK *mb, MODE_INFO **grid, +void vp9_denoiser_denoise(VP9_DENOISER *denoiser, MACROBLOCK *mb, int mi_row, int mi_col, BLOCK_SIZE bs) { int decision = COPY_BLOCK; @@ -103,16 +102,26 @@ void vp9_denoiser_denoise(VP9_DENOISER *denoiser, } if (decision == COPY_BLOCK) { copy_block(block_start(avg.y_buffer, avg.y_stride, mi_row, mi_col), - avg.y_stride, - block_start(src.buf, src.stride, mi_row, mi_col), - src.stride, - bs); + avg.y_stride, src.buf, src.stride, bs); } return; } void copy_frame(YV12_BUFFER_CONFIG dest, YV12_BUFFER_CONFIG src) { - memcpy(dest.buffer_alloc, src.buffer_alloc, src.buffer_alloc_sz); + int r, c; + 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); + + for (r = 0; r < dest.y_height; ++r) { + for (c = 0; c < dest.y_width; ++c) { + destbuf[c] = srcbuf[c]; + } + destbuf += dest.y_stride; + srcbuf += src.y_stride; + } + return; } void vp9_denoiser_update_frame_info(VP9_DENOISER *denoiser, diff --git a/vp9/encoder/vp9_denoiser.h b/vp9/encoder/vp9_denoiser.h index 81fc7ebe5..18b9766a5 100644 --- a/vp9/encoder/vp9_denoiser.h +++ b/vp9/encoder/vp9_denoiser.h @@ -35,8 +35,7 @@ void vp9_denoiser_update_frame_info(VP9_DENOISER *denoiser, int refresh_golden_frame, int refresh_last_frame); -void vp9_denoiser_denoise(VP9_DENOISER *denoiser, - MACROBLOCK *mb, MODE_INFO **grid, +void vp9_denoiser_denoise(VP9_DENOISER *denoiser, MACROBLOCK *mb, int mi_row, int mi_col, BLOCK_SIZE bs); void vp9_denoiser_update_frame_stats(); diff --git a/vp9/encoder/vp9_pickmode.c b/vp9/encoder/vp9_pickmode.c index 3f4fcd1e1..bc3dfde4d 100644 --- a/vp9/encoder/vp9_pickmode.c +++ b/vp9/encoder/vp9_pickmode.c @@ -495,8 +495,7 @@ int64_t vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, } } #if CONFIG_DENOISING - vp9_denoiser_denoise(&cpi->denoiser, x, cpi->common.mi_grid_visible, mi_row, - mi_col, bsize); + vp9_denoiser_denoise(&cpi->denoiser, x, mi_row, mi_col, bsize); #endif return INT64_MAX;