Refactor av1_cdef_frame()
Make the pixel offset scalable with mode_info block size. Change-Id: I2cd16be64240c613adf6222a7addbda5db267579
This commit is contained in:
Родитель
f791e631c7
Коммит
9cf0c9cde7
|
@ -119,7 +119,8 @@ void av1_cdef_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
|
|||
int dir[OD_DERING_NBLOCKS][OD_DERING_NBLOCKS] = { { 0 } };
|
||||
int var[OD_DERING_NBLOCKS][OD_DERING_NBLOCKS] = { { 0 } };
|
||||
int stride;
|
||||
int bsize[3];
|
||||
int mi_wide_l2[3];
|
||||
int mi_high_l2[3];
|
||||
int dec[3];
|
||||
int pli;
|
||||
int dering_left;
|
||||
|
@ -137,16 +138,19 @@ void av1_cdef_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
|
|||
curr_row_dering = prev_row_dering + nhsb + 2;
|
||||
for (pli = 0; pli < nplanes; pli++) {
|
||||
dec[pli] = xd->plane[pli].subsampling_x;
|
||||
bsize[pli] = OD_DERING_SIZE_LOG2 - dec[pli];
|
||||
mi_wide_l2[pli] = MI_SIZE_LOG2 - xd->plane[pli].subsampling_x;
|
||||
mi_high_l2[pli] = MI_SIZE_LOG2 - xd->plane[pli].subsampling_y;
|
||||
}
|
||||
stride = (cm->mi_cols << bsize[0]) + 2 * OD_FILT_HBORDER;
|
||||
stride = (cm->mi_cols << MI_SIZE_LOG2) + 2 * OD_FILT_HBORDER;
|
||||
for (pli = 0; pli < nplanes; pli++) {
|
||||
linebuf[pli] = aom_malloc(sizeof(*linebuf) * OD_FILT_VBORDER * stride);
|
||||
}
|
||||
for (sbr = 0; sbr < nvsb; sbr++) {
|
||||
for (pli = 0; pli < nplanes; pli++) {
|
||||
for (r = 0; r < (MAX_MIB_SIZE << bsize[pli]) + 2 * OD_FILT_VBORDER; r++) {
|
||||
for (c = 0; c < OD_FILT_HBORDER; c++) {
|
||||
const int block_height =
|
||||
(MAX_MIB_SIZE << mi_high_l2[pli]) + 2 * OD_FILT_VBORDER;
|
||||
for (r = 0; r < block_height; ++r) {
|
||||
for (c = 0; c < OD_FILT_HBORDER; ++c) {
|
||||
colbuf[pli][r][c] = OD_DERING_VERY_LARGE;
|
||||
}
|
||||
}
|
||||
|
@ -218,20 +222,24 @@ void av1_cdef_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
|
|||
level = 0;
|
||||
clpf_strength = uv_clpf_strength;
|
||||
}
|
||||
|
||||
if (sbc == nhsb - 1)
|
||||
cend = (nhb << bsize[pli]);
|
||||
cend = (nhb << mi_wide_l2[pli]);
|
||||
else
|
||||
cend = (nhb << bsize[pli]) + OD_FILT_HBORDER;
|
||||
cend = (nhb << mi_wide_l2[pli]) + OD_FILT_HBORDER;
|
||||
|
||||
if (sbr == nvsb - 1)
|
||||
rend = (nvb << bsize[pli]);
|
||||
rend = (nvb << mi_high_l2[pli]);
|
||||
else
|
||||
rend = (nvb << bsize[pli]) + OD_FILT_VBORDER;
|
||||
coffset = sbc * MAX_MIB_SIZE << bsize[pli];
|
||||
rend = (nvb << mi_high_l2[pli]) + OD_FILT_VBORDER;
|
||||
|
||||
coffset = sbc * MAX_MIB_SIZE << mi_wide_l2[pli];
|
||||
if (sbc == nhsb - 1) {
|
||||
/* On the last superblock column, fill in the right border with
|
||||
OD_DERING_VERY_LARGE to avoid filtering with the outside. */
|
||||
for (r = 0; r < rend + OD_FILT_VBORDER; r++) {
|
||||
for (c = cend; c < (nhb << bsize[pli]) + OD_FILT_HBORDER; ++c) {
|
||||
for (r = 0; r < rend + OD_FILT_VBORDER; ++r) {
|
||||
const int block_width = (nhb << mi_wide_l2[pli]) + OD_FILT_HBORDER;
|
||||
for (c = cend; c < block_width; ++c) {
|
||||
src[r * OD_FILT_BSTRIDE + c + OD_FILT_HBORDER] =
|
||||
OD_DERING_VERY_LARGE;
|
||||
}
|
||||
|
@ -240,8 +248,10 @@ void av1_cdef_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
|
|||
if (sbr == nvsb - 1) {
|
||||
/* On the last superblock row, fill in the bottom border with
|
||||
OD_DERING_VERY_LARGE to avoid filtering with the outside. */
|
||||
for (r = rend; r < rend + OD_FILT_VBORDER; r++) {
|
||||
for (c = 0; c < (nhb << bsize[pli]) + 2 * OD_FILT_HBORDER; c++) {
|
||||
for (r = rend; r < rend + OD_FILT_VBORDER; ++r) {
|
||||
const int block_width =
|
||||
(nhb << mi_wide_l2[pli]) + 2 * OD_FILT_HBORDER;
|
||||
for (c = 0; c < block_width; ++c) {
|
||||
src[(r + OD_FILT_VBORDER) * OD_FILT_BSTRIDE + c] =
|
||||
OD_DERING_VERY_LARGE;
|
||||
}
|
||||
|
@ -253,24 +263,24 @@ void av1_cdef_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
|
|||
cm,
|
||||
&src[OD_FILT_VBORDER * OD_FILT_BSTRIDE + OD_FILT_HBORDER + cstart],
|
||||
OD_FILT_BSTRIDE, xd->plane[pli].dst.buf,
|
||||
(MAX_MIB_SIZE << bsize[pli]) * sbr, coffset + cstart,
|
||||
(MAX_MIB_SIZE << mi_wide_l2[pli]) * sbr, coffset + cstart,
|
||||
xd->plane[pli].dst.stride, rend, cend - cstart);
|
||||
if (!prev_row_dering[sbc]) {
|
||||
copy_sb8_16(cm, &src[OD_FILT_HBORDER], OD_FILT_BSTRIDE,
|
||||
xd->plane[pli].dst.buf,
|
||||
(MAX_MIB_SIZE << bsize[pli]) * sbr - OD_FILT_VBORDER,
|
||||
(MAX_MIB_SIZE << mi_wide_l2[pli]) * sbr - OD_FILT_VBORDER,
|
||||
coffset, xd->plane[pli].dst.stride, OD_FILT_VBORDER,
|
||||
nhb << bsize[pli]);
|
||||
nhb << mi_wide_l2[pli]);
|
||||
} else if (sbr > 0) {
|
||||
for (r = 0; r < OD_FILT_VBORDER; r++) {
|
||||
for (c = 0; c < nhb << bsize[pli]; c++) {
|
||||
for (c = 0; c < (nhb << mi_wide_l2[pli]); c++) {
|
||||
src[r * OD_FILT_BSTRIDE + c + OD_FILT_HBORDER] =
|
||||
linebuf[pli][r * stride + coffset + c];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (r = 0; r < OD_FILT_VBORDER; r++) {
|
||||
for (c = 0; c < nhb << bsize[pli]; c++) {
|
||||
for (c = 0; c < (nhb << mi_wide_l2[pli]); c++) {
|
||||
src[r * OD_FILT_BSTRIDE + c + OD_FILT_HBORDER] =
|
||||
OD_DERING_VERY_LARGE;
|
||||
}
|
||||
|
@ -278,7 +288,7 @@ void av1_cdef_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
|
|||
}
|
||||
if (!prev_row_dering[sbc - 1]) {
|
||||
copy_sb8_16(cm, src, OD_FILT_BSTRIDE, xd->plane[pli].dst.buf,
|
||||
(MAX_MIB_SIZE << bsize[pli]) * sbr - OD_FILT_VBORDER,
|
||||
(MAX_MIB_SIZE << mi_wide_l2[pli]) * sbr - OD_FILT_VBORDER,
|
||||
coffset - OD_FILT_HBORDER, xd->plane[pli].dst.stride,
|
||||
OD_FILT_VBORDER, OD_FILT_HBORDER);
|
||||
} else if (sbr > 0 && sbc > 0) {
|
||||
|
@ -297,23 +307,24 @@ void av1_cdef_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
|
|||
}
|
||||
}
|
||||
if (!prev_row_dering[sbc + 1]) {
|
||||
copy_sb8_16(cm, &src[OD_FILT_HBORDER + (nhb << bsize[pli])],
|
||||
copy_sb8_16(cm, &src[OD_FILT_HBORDER + (nhb << mi_high_l2[pli])],
|
||||
OD_FILT_BSTRIDE, xd->plane[pli].dst.buf,
|
||||
(MAX_MIB_SIZE << bsize[pli]) * sbr - OD_FILT_VBORDER,
|
||||
coffset + (nhb << bsize[pli]), xd->plane[pli].dst.stride,
|
||||
OD_FILT_VBORDER, OD_FILT_HBORDER);
|
||||
(MAX_MIB_SIZE << mi_wide_l2[pli]) * sbr - OD_FILT_VBORDER,
|
||||
coffset + (nhb << mi_wide_l2[pli]),
|
||||
xd->plane[pli].dst.stride, OD_FILT_VBORDER,
|
||||
OD_FILT_HBORDER);
|
||||
} else if (sbr > 0 && sbc < nhsb - 1) {
|
||||
for (r = 0; r < OD_FILT_VBORDER; r++) {
|
||||
for (c = nhb << bsize[pli];
|
||||
c < (nhb << bsize[pli]) + OD_FILT_HBORDER; c++) {
|
||||
for (c = nhb << mi_wide_l2[pli];
|
||||
c < (nhb << mi_wide_l2[pli]) + OD_FILT_HBORDER; c++) {
|
||||
src[r * OD_FILT_BSTRIDE + c + OD_FILT_HBORDER] =
|
||||
linebuf[pli][r * stride + coffset + c];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (r = 0; r < OD_FILT_VBORDER; r++) {
|
||||
for (c = nhb << bsize[pli];
|
||||
c < (nhb << bsize[pli]) + OD_FILT_HBORDER; c++) {
|
||||
for (c = nhb << mi_wide_l2[pli];
|
||||
c < (nhb << mi_wide_l2[pli]) + OD_FILT_HBORDER; c++) {
|
||||
src[r * OD_FILT_BSTRIDE + c + OD_FILT_HBORDER] =
|
||||
OD_DERING_VERY_LARGE;
|
||||
}
|
||||
|
@ -333,36 +344,38 @@ void av1_cdef_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
|
|||
/* Saving pixels in case we need to dering the superblock on the
|
||||
right. */
|
||||
colbuf[pli][r][c] =
|
||||
src[r * OD_FILT_BSTRIDE + c + (nhb << bsize[pli])];
|
||||
src[r * OD_FILT_BSTRIDE + c + (nhb << mi_wide_l2[pli])];
|
||||
}
|
||||
}
|
||||
copy_sb8_16(cm, &linebuf[pli][coffset], stride, xd->plane[pli].dst.buf,
|
||||
(MAX_MIB_SIZE << bsize[pli]) * (sbr + 1) - OD_FILT_VBORDER,
|
||||
coffset, xd->plane[pli].dst.stride, OD_FILT_VBORDER,
|
||||
(nhb << bsize[pli]));
|
||||
copy_sb8_16(
|
||||
cm, &linebuf[pli][coffset], stride, xd->plane[pli].dst.buf,
|
||||
(MAX_MIB_SIZE << mi_wide_l2[pli]) * (sbr + 1) - OD_FILT_VBORDER,
|
||||
coffset, xd->plane[pli].dst.stride, OD_FILT_VBORDER,
|
||||
(nhb << mi_wide_l2[pli]));
|
||||
|
||||
if (level == 0 && clpf_strength == 0) continue;
|
||||
#if CONFIG_AOM_HIGHBITDEPTH
|
||||
if (cm->use_highbitdepth) {
|
||||
od_dering((uint8_t *)&CONVERT_TO_SHORTPTR(
|
||||
xd->plane[pli]
|
||||
.dst.buf)[xd->plane[pli].dst.stride *
|
||||
(MAX_MIB_SIZE * sbr << bsize[pli]) +
|
||||
(sbc * MAX_MIB_SIZE << bsize[pli])],
|
||||
xd->plane[pli].dst.stride, dst,
|
||||
&src[OD_FILT_VBORDER * OD_FILT_BSTRIDE + OD_FILT_HBORDER],
|
||||
dec[pli], dir, NULL, var, pli, dlist, dering_count, level,
|
||||
clpf_strength, clpf_damping, coeff_shift, 0, 1);
|
||||
} else {
|
||||
#endif
|
||||
od_dering(
|
||||
&xd->plane[pli].dst.buf[xd->plane[pli].dst.stride *
|
||||
(MAX_MIB_SIZE * sbr << bsize[pli]) +
|
||||
(sbc * MAX_MIB_SIZE << bsize[pli])],
|
||||
(uint8_t *)&CONVERT_TO_SHORTPTR(
|
||||
xd->plane[pli]
|
||||
.dst.buf)[xd->plane[pli].dst.stride *
|
||||
(MAX_MIB_SIZE * sbr << mi_wide_l2[pli]) +
|
||||
(sbc * MAX_MIB_SIZE << mi_wide_l2[pli])],
|
||||
xd->plane[pli].dst.stride, dst,
|
||||
&src[OD_FILT_VBORDER * OD_FILT_BSTRIDE + OD_FILT_HBORDER],
|
||||
dec[pli], dir, NULL, var, pli, dlist, dering_count, level,
|
||||
clpf_strength, clpf_damping, coeff_shift, 0, 0);
|
||||
clpf_strength, clpf_damping, coeff_shift, 0, 1);
|
||||
} else {
|
||||
#endif
|
||||
od_dering(&xd->plane[pli]
|
||||
.dst.buf[xd->plane[pli].dst.stride *
|
||||
(MAX_MIB_SIZE * sbr << mi_wide_l2[pli]) +
|
||||
(sbc * MAX_MIB_SIZE << mi_wide_l2[pli])],
|
||||
xd->plane[pli].dst.stride, dst,
|
||||
&src[OD_FILT_VBORDER * OD_FILT_BSTRIDE + OD_FILT_HBORDER],
|
||||
dec[pli], dir, NULL, var, pli, dlist, dering_count, level,
|
||||
clpf_strength, clpf_damping, coeff_shift, 0, 0);
|
||||
|
||||
#if CONFIG_AOM_HIGHBITDEPTH
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче