From 242c11d3795e2f947f1130bd41159e37a2754b10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arttu=20Yl=C3=A4-Outinen?= Date: Tue, 1 Aug 2017 14:34:44 +0300 Subject: [PATCH 1/2] Use deblock and SAO in tiles tests Reveals a bug in SAO when using tiles. --- tests/test_owf_wpp_tiles.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_owf_wpp_tiles.sh b/tests/test_owf_wpp_tiles.sh index d479c9e3..3f778539 100755 --- a/tests/test_owf_wpp_tiles.sh +++ b/tests/test_owf_wpp_tiles.sh @@ -7,10 +7,12 @@ set -eu . "${0%/*}/util.sh" -common_args='-p4 --rd=0 --no-rdoq --no-deblock --no-sao --no-signhide --subme=0 --pu-depth-inter=1-3 --pu-depth-intra=2-3' +common_args='-p4 --rd=0 --no-rdoq --no-signhide --subme=0 --deblock --sao --pu-depth-inter=1-3 --pu-depth-intra=2-3' valgrind_test 264x130 10 $common_args -r1 --owf=1 --threads=0 --no-wpp valgrind_test 264x130 10 $common_args -r1 --owf=0 --threads=0 --no-wpp valgrind_test 264x130 10 $common_args -r2 --owf=1 --threads=2 --wpp valgrind_test 264x130 10 $common_args -r2 --owf=0 --threads=2 --no-wpp valgrind_test 264x130 10 $common_args -r2 --owf=1 --threads=2 --tiles-height-split=u2 --no-wpp valgrind_test 264x130 10 $common_args -r2 --owf=0 --threads=2 --tiles-height-split=u2 --no-wpp +valgrind_test 512x512 3 $common_args -r2 --owf=1 --threads=2 --tiles=2x2 --no-wpp +valgrind_test 512x512 3 $common_args -r2 --owf=0 --threads=2 --tiles=2x2 --no-wpp From 24ecddd2a5d5cab599ad53589dfa288eff16a109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arttu=20Yl=C3=A4-Outinen?= Date: Tue, 1 Aug 2017 15:40:49 +0300 Subject: [PATCH 2/2] Fix wrong strides in SAO reconstruction Functions kvz_sao_reconstruct and encoder_sao_reconstruct used frame->width as the stride instead of frame->rec->stride when accessing frame->rec->data. This caused errors when using tiles and SAO. --- src/encoderstate.c | 10 +++++----- src/sao.c | 7 ++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/encoderstate.c b/src/encoderstate.c index dcbc3849..7f180c35 100644 --- a/src/encoderstate.c +++ b/src/encoderstate.c @@ -351,29 +351,29 @@ static void encoder_sao_reconstruct(const encoder_state_t *const state, // Copy pixels that will be filtered and bordering pixels from right and // below. const int from_index = (lcu->position_px.x + x_offsets[0]) + - (lcu->position_px.y + y_offsets[0]) * frame->width; + (lcu->position_px.y + y_offsets[0]) * frame->rec->stride; const int to_index = x_offsets[0] + y_offsets[0] * SAO_BUF_WIDTH; kvz_pixels_blit(&frame->rec->y[from_index], &sao_buf_y[to_index], width + border_right, height + border_below, - frame->width, + frame->rec->stride, SAO_BUF_WIDTH); if (state->encoder_control->chroma_format != KVZ_CSP_400) { const int from_index_c = (lcu->position_px.x + x_offsets[0])/2 + - (lcu->position_px.y + y_offsets[0])/2 * frame->width/2; + (lcu->position_px.y + y_offsets[0])/2 * frame->rec->stride/2; const int to_index_c = x_offsets[0]/2 + y_offsets[0]/2 * SAO_BUF_WIDTH_C; kvz_pixels_blit(&frame->rec->u[from_index_c], &sao_buf_u[to_index_c], width/2 + border_right, height/2 + border_below, - frame->width/2, + frame->rec->stride/2, SAO_BUF_WIDTH_C); kvz_pixels_blit(&frame->rec->v[from_index_c], &sao_buf_v[to_index_c], width/2 + border_right, height/2 + border_below, - frame->width/2, + frame->rec->stride/2, SAO_BUF_WIDTH_C); } diff --git a/src/sao.c b/src/sao.c index 016d8950..c7d20b26 100644 --- a/src/sao.c +++ b/src/sao.c @@ -291,7 +291,8 @@ void kvz_sao_reconstruct(const encoder_state_t *state, const int frame_width = frame->width >> shift; const int frame_height = frame->height >> shift; - kvz_pixel *output = &frame->rec->data[color][frame_x + frame_y * frame_width]; + const int frame_stride = frame->rec->stride >> shift; + kvz_pixel *output = &frame->rec->data[color][frame_x + frame_y * frame_stride]; if (sao->type == SAO_TYPE_EDGE) { const vector2d_t *offset = g_sao_edge_offsets[sao->eo_class]; @@ -317,7 +318,7 @@ void kvz_sao_reconstruct(const encoder_state_t *state, if (frame_y + offset[0].y < 0 || frame_y + offset[1].y < 0) { // Nothing to do for the topmost row. buffer += stride; - output += frame_width; + output += frame_stride; height -= 1; } } @@ -328,7 +329,7 @@ void kvz_sao_reconstruct(const encoder_state_t *state, output, sao, stride, - frame_width, + frame_stride, width, height, color);