Commit 9efbaf9c authored by Cheng Chen's avatar Cheng Chen

Improve readability for experiment UV_LVL

Add asserts for switch.
Add helper functions to make selection of plane functions readable.
Remove extra { such that brackets match.

Change-Id: I048f3e5e0822bf1669fdcbedb84a0255139df686
parent 497d1951
......@@ -289,6 +289,27 @@ int64_t aom_highbd_get_v_sse(const YV12_BUFFER_CONFIG *a,
}
#endif // CONFIG_HIGHBITDEPTH
int64_t aom_get_sse_plane(const YV12_BUFFER_CONFIG *a,
const YV12_BUFFER_CONFIG *b, int plane, int highbd) {
#if CONFIG_HIGHBITDEPTH
if (highbd) {
switch (plane) {
case 0: return aom_highbd_get_y_sse(a, b);
case 1: return aom_highbd_get_u_sse(a, b);
case 2: return aom_highbd_get_v_sse(a, b);
default: assert(plane >= 0 && plane <= 2); return 0;
}
}
#endif
(void)highbd;
switch (plane) {
case 0: return aom_get_y_sse(a, b);
case 1: return aom_get_u_sse(a, b);
case 2: return aom_get_v_sse(a, b);
default: assert(plane >= 0 && plane <= 2); return 0;
}
}
#if CONFIG_HIGHBITDEPTH
void aom_calc_highbd_psnr(const YV12_BUFFER_CONFIG *a,
const YV12_BUFFER_CONFIG *b, PSNR_STATS *psnr,
......
......@@ -47,6 +47,8 @@ int64_t aom_get_v_sse_part(const YV12_BUFFER_CONFIG *a,
const YV12_BUFFER_CONFIG *b, int hstart, int width,
int vstart, int height);
int64_t aom_get_v_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b);
int64_t aom_get_sse_plane(const YV12_BUFFER_CONFIG *a,
const YV12_BUFFER_CONFIG *b, int plane, int highbd);
#if CONFIG_HIGHBITDEPTH
int64_t aom_highbd_get_y_sse_part(const YV12_BUFFER_CONFIG *a,
const YV12_BUFFER_CONFIG *b, int hstart,
......
......@@ -1910,8 +1910,8 @@ static void filter_selectively_vert(
orig_pos[i] = -1;
}
int direct = pick_min_grad_direct(src, left_filt_len, row, col, width,
height, pitch, 1, 0);
const int direct = pick_min_grad_direct(src, left_filt_len, row, col,
width, height, pitch, 1, 0);
pick_filter_block_vert(src, block, orig_pos, left_filt_len, row, col,
width, height, pitch, pivot, line_length, 1,
......@@ -1940,8 +1940,8 @@ static void filter_selectively_vert(
orig_pos[i] = -1;
}
int direct = pick_min_grad_direct(src, 4, row, col + 4, width, height,
pitch, 1, 0);
const int direct = pick_min_grad_direct(src, 4, row, col + 4, width,
height, pitch, 1, 0);
pick_filter_block_vert(src, block, orig_pos, 4, row, col + 4, width,
height, pitch, pivot, line_length, 1, direct);
......@@ -2927,7 +2927,7 @@ static void av1_filter_block_plane_vert(
if (params.filter_length) {
const int filt_len = params.filter_length == 16 ? 8 : 4;
int direct =
const int direct =
pick_min_grad_direct(src, filt_len, curr_y, curr_x, width, height,
dst_stride, unit, vert_or_horz);
......@@ -2987,7 +2987,7 @@ static void av1_filter_block_plane_vert(
orig_pos[i] = -1;
}
int direct =
const int direct =
pick_min_grad_direct(src, 4, curr_y, curr_x + 4, width, height,
dst_stride, unit, vert_or_horz);
......@@ -3113,7 +3113,7 @@ static void av1_filter_block_plane_horz(
if (params.filter_length) {
const int filt_len = params.filter_length == 16 ? 8 : 4;
int direct =
const int direct =
pick_min_grad_direct(src, filt_len, curr_y, curr_x, width, height,
dst_stride, unit, vert_or_horz);
......@@ -3173,7 +3173,7 @@ static void av1_filter_block_plane_horz(
orig_pos[i] = -1;
}
int direct =
const int direct =
pick_min_grad_direct(src, 4, curr_y + 4, curr_x, width, height,
dst_stride, unit, vert_or_horz);
......@@ -3269,8 +3269,11 @@ void av1_loop_filter_rows(YV12_BUFFER_CONFIG *frame_buffer, AV1_COMMON *cm,
const int plane_end = plane_start + 1;
#else
const int num_planes = y_only ? 1 : MAX_MB_PLANE;
const int plane_start = 0;
const int plane_end = num_planes;
#endif // CONFIG_UV_LVL
int mi_row, mi_col;
int plane;
#if CONFIG_VAR_TX || CONFIG_EXT_PARTITION || CONFIG_EXT_PARTITION_TYPES || \
CONFIG_CB4X4
......@@ -3288,15 +3291,9 @@ void av1_loop_filter_rows(YV12_BUFFER_CONFIG *frame_buffer, AV1_COMMON *cm,
<< TX_UNIT_HIGH_LOG2);
#endif // CONFIG_VAR_TX
for (mi_col = 0; mi_col < cm->mi_cols; mi_col += cm->mib_size) {
int plane;
av1_setup_dst_planes(planes, cm->sb_size, frame_buffer, mi_row, mi_col);
#if CONFIG_UV_LVL
for (plane = plane_start; plane < plane_end; ++plane) {
#else
for (plane = 0; plane < num_planes; ++plane) {
#endif // CONFIG_UV_LVL
av1_filter_block_plane_non420_ver(cm, &planes[plane], mi + mi_col,
mi_row, mi_col, plane);
av1_filter_block_plane_non420_hor(cm, &planes[plane], mi + mi_col,
......@@ -3310,13 +3307,8 @@ void av1_loop_filter_rows(YV12_BUFFER_CONFIG *frame_buffer, AV1_COMMON *cm,
for (mi_row = start; mi_row < stop; mi_row += MAX_MIB_SIZE) {
for (mi_col = 0; mi_col < cm->mi_cols; mi_col += MAX_MIB_SIZE) {
av1_setup_dst_planes(planes, cm->sb_size, frame_buffer, mi_row, mi_col);
#if CONFIG_UV_LVL
for (int plane_idx = plane_start; plane_idx < plane_end; ++plane_idx) {
#else
for (int plane_idx = 0; plane_idx < num_planes; plane_idx += 1) {
#endif // CONFIG_UV_LVL
av1_filter_block_plane_vert(cm, plane_idx, &planes[plane_idx], mi_row,
mi_col);
for (plane = plane_start; plane < plane_end; ++plane) {
av1_filter_block_plane_vert(cm, plane, &planes[plane], mi_row, mi_col);
}
}
}
......@@ -3325,13 +3317,8 @@ void av1_loop_filter_rows(YV12_BUFFER_CONFIG *frame_buffer, AV1_COMMON *cm,
for (mi_row = start; mi_row < stop; mi_row += MAX_MIB_SIZE) {
for (mi_col = 0; mi_col < cm->mi_cols; mi_col += MAX_MIB_SIZE) {
av1_setup_dst_planes(planes, cm->sb_size, frame_buffer, mi_row, mi_col);
#if CONFIG_UV_LVL
for (int plane_idx = plane_start; plane_idx < plane_end; ++plane_idx) {
#else
for (int plane_idx = 0; plane_idx < num_planes; plane_idx += 1) {
#endif // CONFIG_UV_LVL
av1_filter_block_plane_horz(cm, plane_idx, &planes[plane_idx], mi_row,
mi_col);
for (plane = plane_start; plane < plane_end; ++plane) {
av1_filter_block_plane_horz(cm, plane, &planes[plane], mi_row, mi_col);
}
}
}
......@@ -3344,9 +3331,8 @@ void av1_loop_filter_rows(YV12_BUFFER_CONFIG *frame_buffer, AV1_COMMON *cm,
for (mi_col = 0; mi_col < cm->mi_cols; mi_col += MAX_MIB_SIZE) {
av1_setup_dst_planes(planes, cm->sb_size, frame_buffer, mi_row, mi_col);
// filter all vertical edges in every 64x64 super block
for (int plane_idx = 0; plane_idx < num_planes; plane_idx += 1) {
av1_filter_block_plane_vert(cm, plane_idx, planes + plane_idx, mi_row,
mi_col);
for (plane = plane_start; plane < plane_end; plane += 1) {
av1_filter_block_plane_vert(cm, plane, &planes[plane], mi_row, mi_col);
}
}
}
......@@ -3354,9 +3340,8 @@ void av1_loop_filter_rows(YV12_BUFFER_CONFIG *frame_buffer, AV1_COMMON *cm,
for (mi_col = 0; mi_col < cm->mi_cols; mi_col += MAX_MIB_SIZE) {
av1_setup_dst_planes(planes, cm->sb_size, frame_buffer, mi_row, mi_col);
// filter all horizontal edges in every 64x64 super block
for (int plane_idx = 0; plane_idx < num_planes; plane_idx += 1) {
av1_filter_block_plane_horz(cm, plane_idx, planes + plane_idx, mi_row,
mi_col);
for (plane = plane_start; plane < plane_end; plane += 1) {
av1_filter_block_plane_horz(cm, plane, &planes[plane], mi_row, mi_col);
}
}
}
......@@ -3376,8 +3361,6 @@ void av1_loop_filter_rows(YV12_BUFFER_CONFIG *frame_buffer, AV1_COMMON *cm,
for (mi_row = start; mi_row < stop; mi_row += MAX_MIB_SIZE) {
MODE_INFO **mi = cm->mi_grid_visible + mi_row * cm->mi_stride;
for (mi_col = 0; mi_col < cm->mi_cols; mi_col += MAX_MIB_SIZE) {
int plane;
av1_setup_dst_planes(planes, cm->sb_size, frame_buffer, mi_row, mi_col);
// TODO(JBB): Make setup_mask work for non 420.
......
......@@ -27,6 +27,16 @@
#include "av1/encoder/encoder.h"
#include "av1/encoder/picklpf.h"
static void yv12_copy_plane(const YV12_BUFFER_CONFIG *src_bc,
YV12_BUFFER_CONFIG *dst_bc, int plane) {
switch (plane) {
case 0: aom_yv12_copy_y(src_bc, dst_bc); break;
case 1: aom_yv12_copy_u(src_bc, dst_bc); break;
case 2: aom_yv12_copy_v(src_bc, dst_bc); break;
default: assert(plane >= 0 && plane <= 2); break;
}
}
int av1_get_max_filter_level(const AV1_COMP *cpi) {
if (cpi->oxcf.pass == 2) {
return cpi->twopass.section_intra_rating > 8 ? MAX_LOOP_FILTER * 3 / 4
......@@ -49,6 +59,7 @@ static int64_t try_filter_frame(const YV12_BUFFER_CONFIG *sd,
#if CONFIG_VAR_TX || CONFIG_EXT_PARTITION || CONFIG_CB4X4
#if CONFIG_UV_LVL
assert(plane >= 0 && plane <= 2);
av1_loop_filter_frame(cm->frame_to_show, cm, &cpi->td.mb.e_mbd, filt_level,
plane, partial_frame);
#else
......@@ -65,52 +76,21 @@ static int64_t try_filter_frame(const YV12_BUFFER_CONFIG *sd,
1, partial_frame);
#endif
#if CONFIG_UV_LVL
int highbd = 0;
#if CONFIG_HIGHBITDEPTH
if (cm->use_highbitdepth) {
if (plane == 0)
filt_err = aom_highbd_get_y_sse(sd, cm->frame_to_show);
else if (plane == 1)
filt_err = aom_highbd_get_u_sse(sd, cm->frame_to_show);
else
filt_err = aom_highbd_get_v_sse(sd, cm->frame_to_show);
} else {
if (plane == 0)
filt_err = aom_get_y_sse(sd, cm->frame_to_show);
else if (plane == 1)
filt_err = aom_get_u_sse(sd, cm->frame_to_show);
else
filt_err = aom_get_v_sse(sd, cm->frame_to_show);
}
#else
if (plane == 0)
filt_err = aom_get_y_sse(sd, cm->frame_to_show);
else if (plane == 1)
filt_err = aom_get_u_sse(sd, cm->frame_to_show);
else
filt_err = aom_get_v_sse(sd, cm->frame_to_show);
highbd = cm->use_highbitdepth;
#endif // CONFIG_HIGHBITDEPTH
#if CONFIG_UV_LVL
filt_err = aom_get_sse_plane(sd, cm->frame_to_show, plane, highbd);
// Re-instate the unfiltered frame
if (plane == 0)
aom_yv12_copy_y(&cpi->last_frame_uf, cm->frame_to_show);
else if (plane == 1)
aom_yv12_copy_u(&cpi->last_frame_uf, cm->frame_to_show);
else
aom_yv12_copy_v(&cpi->last_frame_uf, cm->frame_to_show);
#else
#if CONFIG_HIGHBITDEPTH
if (cm->use_highbitdepth) {
filt_err = aom_highbd_get_y_sse(sd, cm->frame_to_show);
} else {
filt_err = aom_get_y_sse(sd, cm->frame_to_show);
}
yv12_copy_plane(&cpi->last_frame_uf, cm->frame_to_show, plane);
#else
filt_err = aom_get_y_sse(sd, cm->frame_to_show);
#endif // CONFIG_HIGHBITDEPTH
filt_err = aom_get_sse_plane(sd, cm->frame_to_show, 0, highbd);
// Re-instate the unfiltered frame
aom_yv12_copy_y(&cpi->last_frame_uf, cm->frame_to_show);
yv12_copy_plane(&cpi->last_frame_uf, cm->frame_to_show, 0);
#endif // CONFIG_UV_LVL
return filt_err;
......@@ -140,7 +120,7 @@ int av1_search_filter_level(const YV12_BUFFER_CONFIG *sd, AV1_COMP *cpi,
case 0: lvl = lf->filter_level; break;
case 1: lvl = lf->filter_level_u; break;
case 2: lvl = lf->filter_level_v; break;
default: lvl = lf->filter_level; break;
default: assert(plane >= 0 && plane <= 2); return 0;
}
int filt_mid = clamp(lvl, min_filter_level, max_filter_level);
#else
......@@ -154,12 +134,7 @@ int av1_search_filter_level(const YV12_BUFFER_CONFIG *sd, AV1_COMP *cpi,
memset(ss_err, 0xFF, sizeof(ss_err));
#if CONFIG_UV_LVL
if (plane == 0)
aom_yv12_copy_y(cm->frame_to_show, &cpi->last_frame_uf);
else if (plane == 1)
aom_yv12_copy_u(cm->frame_to_show, &cpi->last_frame_uf);
else if (plane == 2)
aom_yv12_copy_v(cm->frame_to_show, &cpi->last_frame_uf);
yv12_copy_plane(cm->frame_to_show, &cpi->last_frame_uf, plane);
#else
// Make a copy of the unfiltered / processed recon buffer
aom_yv12_copy_y(cm->frame_to_show, &cpi->last_frame_uf);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment