Commit de9089f5 authored by Yaowu Xu's avatar Yaowu Xu

Rename MI_BLOCK_SIZE and MI_MASK macros

Cherry picked from libvpx: 511da8cb

Change-Id: I4f4132235495adcd445690d8f060f607b755cacd
parent 6885324b
......@@ -12,9 +12,9 @@
#include "aom_dsp/aom_dsp_common.h"
int av1_clpf_maxbits(const AV1_COMMON *cm) {
return get_msb(ALIGN_POWER_OF_TWO(cm->mi_cols * MI_BLOCK_SIZE,
return get_msb(ALIGN_POWER_OF_TWO(cm->mi_cols * MAX_MIB_SIZE,
cm->clpf_size + 4) *
ALIGN_POWER_OF_TWO(cm->mi_rows * MI_BLOCK_SIZE,
ALIGN_POWER_OF_TWO(cm->mi_rows * MAX_MIB_SIZE,
cm->clpf_size + 4) >>
(cm->clpf_size * 2 + 8)) +
1;
......@@ -63,7 +63,7 @@ int av1_clpf_frame(const YV12_BUFFER_CONFIG *dst, const YV12_BUFFER_CONFIG *rec,
int xpos, ypos;
int stride_y = rec->y_stride;
int stride_c = rec->uv_stride;
const int bs = MI_BLOCK_SIZE;
const int bs = MAX_MIB_SIZE;
int num_fb_hor = (width + (1 << fb_size_log2) - bs) >> fb_size_log2;
int num_fb_ver = (height + (1 << fb_size_log2) - bs) >> fb_size_log2;
int block_index = 0;
......
......@@ -33,8 +33,8 @@ int sb_all_skip(const AV1_COMMON *const cm, int mi_row, int mi_col) {
int skip = 1;
maxc = cm->mi_cols - mi_col;
maxr = cm->mi_rows - mi_row;
if (maxr > MI_BLOCK_SIZE) maxr = MI_BLOCK_SIZE;
if (maxc > MI_BLOCK_SIZE) maxc = MI_BLOCK_SIZE;
if (maxr > MAX_MIB_SIZE) maxr = MAX_MIB_SIZE;
if (maxc > MAX_MIB_SIZE) maxc = MAX_MIB_SIZE;
for (r = 0; r < maxr; r++) {
for (c = 0; c < maxc; c++) {
skip = skip &&
......@@ -58,8 +58,8 @@ void av1_dering_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
int dec[3];
int pli;
int coeff_shift = AOMMAX(cm->bit_depth - 8, 0);
nvsb = (cm->mi_rows + MI_BLOCK_SIZE - 1) / MI_BLOCK_SIZE;
nhsb = (cm->mi_cols + MI_BLOCK_SIZE - 1) / MI_BLOCK_SIZE;
nvsb = (cm->mi_rows + MAX_MIB_SIZE - 1) / MAX_MIB_SIZE;
nhsb = (cm->mi_cols + MAX_MIB_SIZE - 1) / MAX_MIB_SIZE;
bskip = aom_malloc(sizeof(*bskip) * cm->mi_rows * cm->mi_cols);
av1_setup_dst_planes(xd->plane, frame, 0, 0);
for (pli = 0; pli < 3; pli++) {
......@@ -96,16 +96,16 @@ void av1_dering_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
for (sbc = 0; sbc < nhsb; sbc++) {
int level;
int nhb, nvb;
nhb = AOMMIN(MI_BLOCK_SIZE, cm->mi_cols - MI_BLOCK_SIZE * sbc);
nvb = AOMMIN(MI_BLOCK_SIZE, cm->mi_rows - MI_BLOCK_SIZE * sbr);
nhb = AOMMIN(MAX_MIB_SIZE, cm->mi_cols - MAX_MIB_SIZE * sbc);
nvb = AOMMIN(MAX_MIB_SIZE, cm->mi_rows - MAX_MIB_SIZE * sbr);
for (pli = 0; pli < 3; pli++) {
int16_t dst[MI_BLOCK_SIZE * MI_BLOCK_SIZE * 8 * 8];
int16_t dst[MAX_MIB_SIZE * MAX_MIB_SIZE * 8 * 8];
int threshold;
#if DERING_REFINEMENT
level = compute_level_from_index(
global_level,
cm->mi_grid_visible[MI_BLOCK_SIZE * sbr * cm->mi_stride +
MI_BLOCK_SIZE * sbc]
cm->mi_grid_visible[MAX_MIB_SIZE * sbr * cm->mi_stride +
MAX_MIB_SIZE * sbc]
->mbmi.dering_gain);
#else
level = global_level;
......@@ -113,31 +113,30 @@ void av1_dering_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
/* FIXME: This is a temporary hack that uses more conservative
deringing for chroma. */
if (pli) level = (level * 5 + 4) >> 3;
if (sb_all_skip(cm, sbr * MI_BLOCK_SIZE, sbc * MI_BLOCK_SIZE)) continue;
if (sb_all_skip(cm, sbr * MAX_MIB_SIZE, sbc * MAX_MIB_SIZE)) continue;
threshold = level << coeff_shift;
od_dering(
&OD_DERING_VTBL_C, dst, MI_BLOCK_SIZE * bsize[pli],
&src[pli][sbr * stride * bsize[pli] * MI_BLOCK_SIZE +
sbc * bsize[pli] * MI_BLOCK_SIZE],
stride, nhb, nvb, sbc, sbr, nhsb, nvsb, dec[pli], dir, pli,
&bskip[MI_BLOCK_SIZE * sbr * cm->mi_cols + MI_BLOCK_SIZE * sbc],
cm->mi_cols, threshold, OD_DERING_NO_CHECK_OVERLAP, coeff_shift);
od_dering(&OD_DERING_VTBL_C, dst, MAX_MIB_SIZE * bsize[pli],
&src[pli][sbr * stride * bsize[pli] * MAX_MIB_SIZE +
sbc * bsize[pli] * MAX_MIB_SIZE],
stride, nhb, nvb, sbc, sbr, nhsb, nvsb, dec[pli], dir, pli,
&bskip[MAX_MIB_SIZE * sbr * cm->mi_cols + MAX_MIB_SIZE * sbc],
cm->mi_cols, threshold, OD_DERING_NO_CHECK_OVERLAP,
coeff_shift);
for (r = 0; r < bsize[pli] * nvb; ++r) {
for (c = 0; c < bsize[pli] * nhb; ++c) {
#if CONFIG_AOM_HIGHBITDEPTH
if (cm->use_highbitdepth) {
CONVERT_TO_SHORTPTR(xd->plane[pli].dst.buf)
[xd->plane[pli].dst.stride *
(bsize[pli] * MI_BLOCK_SIZE * sbr + r) +
sbc * bsize[pli] * MI_BLOCK_SIZE + c] =
dst[r * MI_BLOCK_SIZE * bsize[pli] + c];
(bsize[pli] * MAX_MIB_SIZE * sbr + r) +
sbc * bsize[pli] * MAX_MIB_SIZE + c] =
dst[r * MAX_MIB_SIZE * bsize[pli] + c];
} else {
#endif
xd->plane[pli]
.dst.buf[xd->plane[pli].dst.stride *
(bsize[pli] * MI_BLOCK_SIZE * sbr + r) +
sbc * bsize[pli] * MI_BLOCK_SIZE + c] =
dst[r * MI_BLOCK_SIZE * bsize[pli] + c];
xd->plane[pli].dst.buf[xd->plane[pli].dst.stride *
(bsize[pli] * MAX_MIB_SIZE * sbr + r) +
sbc * bsize[pli] * MAX_MIB_SIZE + c] =
dst[r * MAX_MIB_SIZE * bsize[pli] + c];
#if CONFIG_AOM_HIGHBITDEPTH
}
#endif
......
......@@ -20,17 +20,22 @@ extern "C" {
#endif
#undef MAX_SB_SIZE
// Pixels per max superblock size
#define MAX_SB_SIZE_LOG2 6
#define MAX_SB_SIZE (1 << MAX_SB_SIZE_LOG2)
#define MAX_SB_SQUARE (MAX_SB_SIZE * MAX_SB_SIZE)
// Pixels per Mode Info (MI) unit
#define MI_SIZE_LOG2 3
#define MI_BLOCK_SIZE_LOG2 (MAX_SB_SIZE_LOG2 - MI_SIZE_LOG2) // 64 = 2^6
#define MI_SIZE (1 << MI_SIZE_LOG2)
#define MI_SIZE (1 << MI_SIZE_LOG2) // pixels per mi-unit
#define MI_BLOCK_SIZE (1 << MI_BLOCK_SIZE_LOG2) // mi-units per max block
// MI-units per max superblock (MI Block - MIB)
#define MAX_MIB_SIZE_LOG2 (MAX_SB_SIZE_LOG2 - MI_SIZE_LOG2)
#define MAX_MIB_SIZE (1 << MAX_MIB_SIZE_LOG2)
#define MI_MASK (MI_BLOCK_SIZE - 1)
// Mask to extract MI offset within max MIB
#define MAX_MIB_MASK (MAX_MIB_SIZE - 1)
// Bitstream profiles indicated by 2-3 bits in the uncompressed header.
// 00: Profile 0. 8-bit 4:2:0 only.
......
......@@ -854,11 +854,11 @@ void av1_setup_mask(AV1_COMMON *const cm, const int mi_row, const int mi_col,
const int shift_16_uv[] = { 0, 1, 4, 5 };
int i;
const int max_rows =
(mi_row + MI_BLOCK_SIZE > cm->mi_rows ? cm->mi_rows - mi_row
: MI_BLOCK_SIZE);
(mi_row + MAX_MIB_SIZE > cm->mi_rows ? cm->mi_rows - mi_row
: MAX_MIB_SIZE);
const int max_cols =
(mi_col + MI_BLOCK_SIZE > cm->mi_cols ? cm->mi_cols - mi_col
: MI_BLOCK_SIZE);
(mi_col + MAX_MIB_SIZE > cm->mi_cols ? cm->mi_cols - mi_col
: MAX_MIB_SIZE);
av1_zero(*lfm);
assert(mip[0] != NULL);
......@@ -982,7 +982,7 @@ void av1_setup_mask(AV1_COMMON *const cm, const int mi_row, const int mi_col,
lfm->above_uv[TX_4X4] &= ~above_border_uv;
// We do some special edge handling.
if (mi_row + MI_BLOCK_SIZE > cm->mi_rows) {
if (mi_row + MAX_MIB_SIZE > cm->mi_rows) {
const uint64_t rows = cm->mi_rows - mi_row;
// Each pixel inside the border gets a 1,
......@@ -1015,7 +1015,7 @@ void av1_setup_mask(AV1_COMMON *const cm, const int mi_row, const int mi_col,
}
}
if (mi_col + MI_BLOCK_SIZE > cm->mi_cols) {
if (mi_col + MAX_MIB_SIZE > cm->mi_cols) {
const uint64_t columns = cm->mi_cols - mi_col;
// Each pixel inside the border gets a 1, the multiply copies the border
......@@ -1165,21 +1165,21 @@ void av1_filter_block_plane_non420_ver(AV1_COMMON *cm,
const int row_step_stride = cm->mi_stride * row_step;
struct buf_2d *const dst = &plane->dst;
uint8_t *const dst0 = dst->buf;
unsigned int mask_16x16[MI_BLOCK_SIZE] = { 0 };
unsigned int mask_8x8[MI_BLOCK_SIZE] = { 0 };
unsigned int mask_4x4[MI_BLOCK_SIZE] = { 0 };
unsigned int mask_4x4_int[MI_BLOCK_SIZE] = { 0 };
uint8_t lfl[MI_BLOCK_SIZE * MI_BLOCK_SIZE];
unsigned int mask_16x16[MAX_MIB_SIZE] = { 0 };
unsigned int mask_8x8[MAX_MIB_SIZE] = { 0 };
unsigned int mask_4x4[MAX_MIB_SIZE] = { 0 };
unsigned int mask_4x4_int[MAX_MIB_SIZE] = { 0 };
uint8_t lfl[MAX_MIB_SIZE * MAX_MIB_SIZE];
int r, c;
for (r = 0; r < MI_BLOCK_SIZE && mi_row + r < cm->mi_rows; r += row_step) {
for (r = 0; r < MAX_MIB_SIZE && mi_row + r < cm->mi_rows; r += row_step) {
unsigned int mask_16x16_c = 0;
unsigned int mask_8x8_c = 0;
unsigned int mask_4x4_c = 0;
unsigned int border_mask;
// Determine the vertical edges that need filtering
for (c = 0; c < MI_BLOCK_SIZE && mi_col + c < cm->mi_cols; c += col_step) {
for (c = 0; c < MAX_MIB_SIZE && mi_col + c < cm->mi_cols; c += col_step) {
const MODE_INFO *mi = mi_8x8[c];
const BLOCK_SIZE sb_type = mi[0].mbmi.sb_type;
const int skip_this = mi[0].mbmi.skip && is_inter_block(&mi[0].mbmi);
......@@ -1289,14 +1289,14 @@ void av1_filter_block_plane_non420_hor(AV1_COMMON *cm,
const int row_step = 1 << ss_y;
struct buf_2d *const dst = &plane->dst;
uint8_t *const dst0 = dst->buf;
unsigned int mask_16x16[MI_BLOCK_SIZE] = { 0 };
unsigned int mask_8x8[MI_BLOCK_SIZE] = { 0 };
unsigned int mask_4x4[MI_BLOCK_SIZE] = { 0 };
unsigned int mask_4x4_int[MI_BLOCK_SIZE] = { 0 };
uint8_t lfl[MI_BLOCK_SIZE * MI_BLOCK_SIZE];
unsigned int mask_16x16[MAX_MIB_SIZE] = { 0 };
unsigned int mask_8x8[MAX_MIB_SIZE] = { 0 };
unsigned int mask_4x4[MAX_MIB_SIZE] = { 0 };
unsigned int mask_4x4_int[MAX_MIB_SIZE] = { 0 };
uint8_t lfl[MAX_MIB_SIZE * MAX_MIB_SIZE];
int r;
for (r = 0; r < MI_BLOCK_SIZE && mi_row + r < cm->mi_rows; r += row_step) {
for (r = 0; r < MAX_MIB_SIZE && mi_row + r < cm->mi_rows; r += row_step) {
const int skip_border_4x4_r = ss_y && mi_row + r == cm->mi_rows - 1;
const unsigned int mask_4x4_int_r = skip_border_4x4_r ? 0 : mask_4x4_int[r];
......@@ -1350,7 +1350,7 @@ void av1_filter_block_plane_ss00_ver(AV1_COMMON *const cm,
assert(plane->subsampling_x == 0 && plane->subsampling_y == 0);
// Vertical pass: do 2 rows at one time
for (r = 0; r < MI_BLOCK_SIZE && mi_row + r < cm->mi_rows; r += 2) {
for (r = 0; r < MAX_MIB_SIZE && mi_row + r < cm->mi_rows; r += 2) {
unsigned int mask_16x16_l = mask_16x16 & 0xffff;
unsigned int mask_8x8_l = mask_8x8 & 0xffff;
unsigned int mask_4x4_l = mask_4x4 & 0xffff;
......@@ -1396,7 +1396,7 @@ void av1_filter_block_plane_ss00_hor(AV1_COMMON *const cm,
assert(plane->subsampling_x == 0 && plane->subsampling_y == 0);
for (r = 0; r < MI_BLOCK_SIZE && mi_row + r < cm->mi_rows; r++) {
for (r = 0; r < MAX_MIB_SIZE && mi_row + r < cm->mi_rows; r++) {
unsigned int mask_16x16_r;
unsigned int mask_8x8_r;
unsigned int mask_4x4_r;
......@@ -1458,9 +1458,9 @@ void av1_filter_block_plane_ss11_ver(AV1_COMMON *const cm,
assert(plane->subsampling_x == 1 && plane->subsampling_y == 1);
// Vertical pass: do 2 rows at one time
for (r = 0; r < MI_BLOCK_SIZE && mi_row + r < cm->mi_rows; r += 4) {
for (r = 0; r < MAX_MIB_SIZE && mi_row + r < cm->mi_rows; r += 4) {
if (plane->plane_type == 1) {
for (c = 0; c < (MI_BLOCK_SIZE >> 1); c++) {
for (c = 0; c < (MAX_MIB_SIZE >> 1); c++) {
lfm->lfl_uv[(r << 1) + c] = lfm->lfl_y[(r << 3) + (c << 1)];
lfm->lfl_uv[((r + 2) << 1) + c] = lfm->lfl_y[((r + 2) << 3) + (c << 1)];
}
......@@ -1520,7 +1520,7 @@ void av1_filter_block_plane_ss11_hor(AV1_COMMON *const cm,
assert(plane->subsampling_x == 1 && plane->subsampling_y == 1);
for (r = 0; r < MI_BLOCK_SIZE && mi_row + r < cm->mi_rows; r += 2) {
for (r = 0; r < MAX_MIB_SIZE && mi_row + r < cm->mi_rows; r += 2) {
const int skip_border_4x4_r = mi_row + r == cm->mi_rows - 1;
const unsigned int mask_4x4_int_r =
skip_border_4x4_r ? 0 : (mask_4x4_int & 0xf);
......@@ -1585,10 +1585,10 @@ void av1_loop_filter_rows(YV12_BUFFER_CONFIG *frame_buffer, AV1_COMMON *cm,
#if CONFIG_PARALLEL_DEBLOCKING
// Filter all the vertical edges in the whole frame
for (mi_row = start; mi_row < stop; mi_row += MI_BLOCK_SIZE) {
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 += MI_BLOCK_SIZE) {
for (mi_col = 0; mi_col < cm->mi_cols; mi_col += MAX_MIB_SIZE) {
int plane;
av1_setup_dst_planes(planes, frame_buffer, mi_row, mi_col);
......@@ -1613,10 +1613,10 @@ void av1_loop_filter_rows(YV12_BUFFER_CONFIG *frame_buffer, AV1_COMMON *cm,
}
// Filter all the horizontal edges in the whole frame
for (mi_row = start; mi_row < stop; mi_row += MI_BLOCK_SIZE) {
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 += MI_BLOCK_SIZE) {
for (mi_col = 0; mi_col < cm->mi_cols; mi_col += MAX_MIB_SIZE) {
int plane;
av1_setup_dst_planes(planes, frame_buffer, mi_row, mi_col);
......@@ -1639,10 +1639,10 @@ void av1_loop_filter_rows(YV12_BUFFER_CONFIG *frame_buffer, AV1_COMMON *cm,
}
}
#else // CONFIG_PARALLEL_DEBLOCKING
for (mi_row = start; mi_row < stop; mi_row += MI_BLOCK_SIZE) {
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 += MI_BLOCK_SIZE) {
for (mi_col = 0; mi_col < cm->mi_cols; mi_col += MAX_MIB_SIZE) {
int plane;
av1_setup_dst_planes(planes, frame_buffer, mi_row, mi_col);
......
......@@ -399,7 +399,7 @@ static INLINE void ref_cnt_fb(RefCntBuffer *bufs, int *idx, int new_idx) {
}
static INLINE int mi_cols_aligned_to_sb(int n_mis) {
return ALIGN_POWER_OF_TWO(n_mis, MI_BLOCK_SIZE_LOG2);
return ALIGN_POWER_OF_TWO(n_mis, MAX_MIB_SIZE_LOG2);
}
static INLINE int frame_is_intra_only(const AV1_COMMON *const cm) {
......@@ -449,7 +449,7 @@ static INLINE void set_skip_context(MACROBLOCKD *xd, int mi_row, int mi_col) {
static INLINE int calc_mi_size(int len) {
// len is in mi units.
return len + MI_BLOCK_SIZE;
return len + MAX_MIB_SIZE;
}
static void set_plane_n4(MACROBLOCKD *const xd, int bw, int bh, int bwl,
......@@ -519,7 +519,8 @@ static INLINE void update_partition_context(MACROBLOCKD *xd, int mi_row,
int mi_col, BLOCK_SIZE subsize,
BLOCK_SIZE bsize) {
PARTITION_CONTEXT *const above_ctx = xd->above_seg_context + mi_col;
PARTITION_CONTEXT *const left_ctx = xd->left_seg_context + (mi_row & MI_MASK);
PARTITION_CONTEXT *const left_ctx =
xd->left_seg_context + (mi_row & MAX_MIB_MASK);
// num_4x4_blocks_wide_lookup[bsize] / 2
const int bs = num_8x8_blocks_wide_lookup[bsize];
......@@ -534,7 +535,8 @@ static INLINE void update_partition_context(MACROBLOCKD *xd, int mi_row,
static INLINE int partition_plane_context(const MACROBLOCKD *xd, int mi_row,
int mi_col, BLOCK_SIZE bsize) {
const PARTITION_CONTEXT *above_ctx = xd->above_seg_context + mi_col;
const PARTITION_CONTEXT *left_ctx = xd->left_seg_context + (mi_row & MI_MASK);
const PARTITION_CONTEXT *left_ctx =
xd->left_seg_context + (mi_row & MAX_MIB_MASK);
const int bsl = mi_width_log2_lookup[bsize];
int above = (*above_ctx >> bsl) & 1, left = (*left_ctx >> bsl) & 1;
......
......@@ -148,11 +148,11 @@ static int loop_filter_ver_row_worker(AV1LfSync *const lf_sync,
enum lf_path path = get_loop_filter_path(lf_data->y_only, lf_data->planes);
for (mi_row = lf_data->start; mi_row < lf_data->stop;
mi_row += lf_sync->num_workers * MI_BLOCK_SIZE) {
mi_row += lf_sync->num_workers * MAX_MIB_SIZE) {
MODE_INFO **const mi =
lf_data->cm->mi_grid_visible + mi_row * lf_data->cm->mi_stride;
for (mi_col = 0; mi_col < lf_data->cm->mi_cols; mi_col += MI_BLOCK_SIZE) {
for (mi_col = 0; mi_col < lf_data->cm->mi_cols; mi_col += MAX_MIB_SIZE) {
LOOP_FILTER_MASK lfm;
int plane;
......@@ -173,18 +173,18 @@ static int loop_filter_hor_row_worker(AV1LfSync *const lf_sync,
LFWorkerData *const lf_data) {
const int num_planes = lf_data->y_only ? 1 : MAX_MB_PLANE;
const int sb_cols =
mi_cols_aligned_to_sb(lf_data->cm->mi_cols) >> MI_BLOCK_SIZE_LOG2;
mi_cols_aligned_to_sb(lf_data->cm->mi_cols) >> MAX_MIB_SIZE_LOG2;
int mi_row, mi_col;
enum lf_path path = get_loop_filter_path(lf_data->y_only, lf_data->planes);
for (mi_row = lf_data->start; mi_row < lf_data->stop;
mi_row += lf_sync->num_workers * MI_BLOCK_SIZE) {
mi_row += lf_sync->num_workers * MAX_MIB_SIZE) {
MODE_INFO **const mi =
lf_data->cm->mi_grid_visible + mi_row * lf_data->cm->mi_stride;
for (mi_col = 0; mi_col < lf_data->cm->mi_cols; mi_col += MI_BLOCK_SIZE) {
const int r = mi_row >> MI_BLOCK_SIZE_LOG2;
const int c = mi_col >> MI_BLOCK_SIZE_LOG2;
for (mi_col = 0; mi_col < lf_data->cm->mi_cols; mi_col += MAX_MIB_SIZE) {
const int r = mi_row >> MAX_MIB_SIZE_LOG2;
const int c = mi_col >> MAX_MIB_SIZE_LOG2;
LOOP_FILTER_MASK lfm;
int plane;
......@@ -211,18 +211,18 @@ static int loop_filter_row_worker(AV1LfSync *const lf_sync,
LFWorkerData *const lf_data) {
const int num_planes = lf_data->y_only ? 1 : MAX_MB_PLANE;
const int sb_cols =
mi_cols_aligned_to_sb(lf_data->cm->mi_cols) >> MI_BLOCK_SIZE_LOG2;
mi_cols_aligned_to_sb(lf_data->cm->mi_cols) >> MAX_MIB_SIZE_LOG2;
int mi_row, mi_col;
enum lf_path path = get_loop_filter_path(lf_data->y_only, lf_data->planes);
for (mi_row = lf_data->start; mi_row < lf_data->stop;
mi_row += lf_sync->num_workers * MI_BLOCK_SIZE) {
mi_row += lf_sync->num_workers * MAX_MIB_SIZE) {
MODE_INFO **const mi =
lf_data->cm->mi_grid_visible + mi_row * lf_data->cm->mi_stride;
for (mi_col = 0; mi_col < lf_data->cm->mi_cols; mi_col += MI_BLOCK_SIZE) {
const int r = mi_row >> MI_BLOCK_SIZE_LOG2;
const int c = mi_col >> MI_BLOCK_SIZE_LOG2;
for (mi_col = 0; mi_col < lf_data->cm->mi_cols; mi_col += MAX_MIB_SIZE) {
const int r = mi_row >> MAX_MIB_SIZE_LOG2;
const int c = mi_col >> MAX_MIB_SIZE_LOG2;
LOOP_FILTER_MASK lfm;
int plane;
......@@ -254,7 +254,7 @@ static void loop_filter_rows_mt(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
AV1LfSync *lf_sync) {
const AVxWorkerInterface *const winterface = aom_get_worker_interface();
// Number of superblock rows and cols
const int sb_rows = mi_cols_aligned_to_sb(cm->mi_rows) >> MI_BLOCK_SIZE_LOG2;
const int sb_rows = mi_cols_aligned_to_sb(cm->mi_rows) >> MAX_MIB_SIZE_LOG2;
// Decoder may allocate more threads than number of tiles based on user's
// input.
const int tile_cols = 1 << cm->log2_tile_cols;
......@@ -291,7 +291,7 @@ static void loop_filter_rows_mt(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
// Loopfilter data
av1_loop_filter_data_reset(lf_data, frame, cm, planes);
lf_data->start = start + i * MI_BLOCK_SIZE;
lf_data->start = start + i * MAX_MIB_SIZE;
lf_data->stop = stop;
lf_data->y_only = y_only;
......@@ -320,7 +320,7 @@ static void loop_filter_rows_mt(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
// Loopfilter data
av1_loop_filter_data_reset(lf_data, frame, cm, planes);
lf_data->start = start + i * MI_BLOCK_SIZE;
lf_data->start = start + i * MAX_MIB_SIZE;
lf_data->stop = stop;
lf_data->y_only = y_only;
......@@ -350,7 +350,7 @@ static void loop_filter_rows_mt(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
// Loopfilter data
av1_loop_filter_data_reset(lf_data, frame, cm, planes);
lf_data->start = start + i * MI_BLOCK_SIZE;
lf_data->start = start + i * MAX_MIB_SIZE;
lf_data->stop = stop;
lf_data->y_only = y_only;
......
......@@ -17,8 +17,8 @@
#define MAX_TILE_WIDTH_B64 64
static int get_tile_offset(int idx, int mis, int log2) {
const int sb_cols = mi_cols_aligned_to_sb(mis) >> MI_BLOCK_SIZE_LOG2;
const int offset = ((idx * sb_cols) >> log2) << MI_BLOCK_SIZE_LOG2;
const int sb_cols = mi_cols_aligned_to_sb(mis) >> MAX_MIB_SIZE_LOG2;
const int offset = ((idx * sb_cols) >> log2) << MAX_MIB_SIZE_LOG2;
return AOMMIN(offset, mis);
}
......@@ -51,7 +51,7 @@ static int get_max_log2_tile_cols(const int sb64_cols) {
void av1_get_tile_n_bits(int mi_cols, int *min_log2_tile_cols,
int *max_log2_tile_cols) {
const int sb64_cols = mi_cols_aligned_to_sb(mi_cols) >> MI_BLOCK_SIZE_LOG2;
const int sb64_cols = mi_cols_aligned_to_sb(mi_cols) >> MAX_MIB_SIZE_LOG2;
*min_log2_tile_cols = get_min_log2_tile_cols(sb64_cols);
*max_log2_tile_cols = get_max_log2_tile_cols(sb64_cols);
assert(*min_log2_tile_cols <= *max_log2_tile_cols);
......
......@@ -566,7 +566,8 @@ static void decode_block(AV1Decoder *const pbi, MACROBLOCKD *const xd,
static INLINE int dec_partition_plane_context(const MACROBLOCKD *xd, int mi_row,
int mi_col, int bsl) {
const PARTITION_CONTEXT *above_ctx = xd->above_seg_context + mi_col;
const PARTITION_CONTEXT *left_ctx = xd->left_seg_context + (mi_row & MI_MASK);
const PARTITION_CONTEXT *left_ctx =
xd->left_seg_context + (mi_row & MAX_MIB_MASK);
int above = (*above_ctx >> bsl) & 1, left = (*left_ctx >> bsl) & 1;
// assert(bsl >= 0);
......@@ -578,7 +579,8 @@ static INLINE void dec_update_partition_context(MACROBLOCKD *xd, int mi_row,
int mi_col, BLOCK_SIZE subsize,
int bw) {
PARTITION_CONTEXT *const above_ctx = xd->above_seg_context + mi_col;
PARTITION_CONTEXT *const left_ctx = xd->left_seg_context + (mi_row & MI_MASK);
PARTITION_CONTEXT *const left_ctx =
xd->left_seg_context + (mi_row & MAX_MIB_MASK);
// update the partition context at the end notes. set partition bits
// of block sizes larger than the current one to be one, and partition
......@@ -1287,7 +1289,7 @@ static const uint8_t *decode_tiles(AV1Decoder *pbi, const uint8_t *data,
TileInfo tile;
av1_tile_set_row(&tile, cm, tile_row);
for (mi_row = tile.mi_row_start; mi_row < tile.mi_row_end;
mi_row += MI_BLOCK_SIZE) {
mi_row += MAX_MIB_SIZE) {
for (tile_col = 0; tile_col < tile_cols; ++tile_col) {
const int col =
pbi->inv_tile_order ? tile_cols - tile_col - 1 : tile_col;
......@@ -1296,7 +1298,7 @@ static const uint8_t *decode_tiles(AV1Decoder *pbi, const uint8_t *data,
av1_zero(tile_data->xd.left_context);
av1_zero(tile_data->xd.left_seg_context);
for (mi_col = tile.mi_col_start; mi_col < tile.mi_col_end;
mi_col += MI_BLOCK_SIZE) {
mi_col += MAX_MIB_SIZE) {
decode_partition(pbi, &tile_data->xd, mi_row, mi_col,
&tile_data->bit_reader, BLOCK_64X64, 4);
}
......@@ -1307,14 +1309,14 @@ static const uint8_t *decode_tiles(AV1Decoder *pbi, const uint8_t *data,
}
// Loopfilter one row.
if (cm->lf.filter_level && !cm->skip_loop_filter) {
const int lf_start = mi_row - MI_BLOCK_SIZE;
const int lf_start = mi_row - MAX_MIB_SIZE;
LFWorkerData *const lf_data = (LFWorkerData *)pbi->lf_worker.data1;
// delay the loopfilter by 1 macroblock row.
if (lf_start < 0) continue;
// decoding has completed: finish up the loop filter in this thread.
if (mi_row + MI_BLOCK_SIZE >= cm->mi_rows) continue;
if (mi_row + MAX_MIB_SIZE >= cm->mi_rows) continue;
winterface->sync(&pbi->lf_worker);
lf_data->start = lf_start;
......@@ -1329,7 +1331,7 @@ static const uint8_t *decode_tiles(AV1Decoder *pbi, const uint8_t *data,
// still be changed by the longest loopfilter of the next superblock
// row.
if (cm->frame_parallel_decode)
av1_frameworker_broadcast(pbi->cur_buf, mi_row << MI_BLOCK_SIZE_LOG2);
av1_frameworker_broadcast(pbi->cur_buf, mi_row << MAX_MIB_SIZE_LOG2);
}
}
......@@ -1368,11 +1370,11 @@ static int tile_worker_hook(TileWorkerData *const tile_data,
tile_data->xd.error_info = &tile_data->error_info;
for (mi_row = tile->mi_row_start; mi_row < tile->mi_row_end;
mi_row += MI_BLOCK_SIZE) {
mi_row += MAX_MIB_SIZE) {
av1_zero(tile_data->xd.left_context);
av1_zero(tile_data->xd.left_seg_context);
for (mi_col = tile->mi_col_start; mi_col < tile->mi_col_end;
mi_col += MI_BLOCK_SIZE) {
mi_col += MAX_MIB_SIZE) {
decode_partition(tile_data->pbi, &tile_data->xd, mi_row, mi_col,
&tile_data->bit_reader, BLOCK_64X64, 4);
}
......
......@@ -745,7 +745,7 @@ static int read_is_inter_block(AV1_COMMON *const cm, MACROBLOCKD *const xd,
static void fpm_sync(void *const data, int mi_row) {
AV1Decoder *const pbi = (AV1Decoder *)data;
av1_frameworker_wait(pbi->frame_worker_owner, pbi->common.prev_frame,
mi_row << MI_BLOCK_SIZE_LOG2);
mi_row << MAX_MIB_SIZE_LOG2);
}
static void read_inter_block_mode_info(AV1Decoder *const pbi,
......
......@@ -391,8 +391,8 @@ static void cyclic_refresh_update_map(AV1_COMP *const cpi) {
int i, block_count, bl_index, sb_rows, sb_cols, sbs_in_frame;
int xmis, ymis, x, y;
memset(seg_map, CR_SEGMENT_ID_BASE, cm->mi_rows * cm->mi_cols);
sb_cols = (cm->mi_cols + MI_BLOCK_SIZE - 1) / MI_BLOCK_SIZE;
sb_rows = (cm->mi_rows + MI_BLOCK_SIZE - 1) / MI_BLOCK_SIZE;
sb_cols = (cm->mi_cols + MAX_MIB_SIZE - 1) / MAX_MIB_SIZE;
sb_rows = (cm->mi_rows + MAX_MIB_SIZE - 1) / MAX_MIB_SIZE;
sbs_in_frame = sb_cols * sb_rows;
// Number of target blocks to get the q delta (segment 1).
block_count = cr->percent_refresh * cm->mi_rows * cm->mi_cols / 100;
......@@ -407,8 +407,8 @@ static void cyclic_refresh_update_map(AV1_COMP *const cpi) {
// Get the mi_row/mi_col corresponding to superblock index i.
int sb_row_index = (i / sb_cols);
int sb_col_index = i - sb_row_index * sb_cols;
int mi_row = sb_row_index * MI_BLOCK_SIZE;
int mi_col = sb_col_index * MI_BLOCK_SIZE;
int mi_row = sb_row_index * MAX_MIB_SIZE;
int mi_col = sb_col_index * MAX_MIB_SIZE;
int qindex_thresh =
cpi->oxcf.content == AOM_CONTENT_SCREEN
? av1_get_qindex(&cm->seg, CR_SEGMENT_ID_BOOST2, cm->base_qindex)
......
......@@ -926,10 +926,10 @@ static void write_modes(AV1_COMP *cpi, const TileInfo *const tile,
int mi_row, mi_col;
for (mi_row = tile->mi_row_start; mi_row < tile->mi_row_end;
mi_row += MI_BLOCK_SIZE) {
mi_row += MAX_MIB_SIZE) {
av1_zero(xd->left_seg_context);
for (mi_col = tile->mi_col_start; mi_col < tile->mi_col_end;
mi_col += MI_BLOCK_SIZE)
mi_col += MAX_MIB_SIZE)
write_modes_sb(cpi, tile, w, tok, tok_end, mi_row, mi_col, BLOCK_64X64);
}
}
......
......@@ -74,7 +74,7 @@ int av1_clpf_decision(int k, int l, const YV12_BUFFER_CONFIG *rec,
for (n = 0; n < w; n++) {
int xpos = (l << fb_size_log2) + n * block_size;
int ypos = (k << fb_size_log2) + m * block_size;
const int bs = MI_BLOCK_SIZE;
const int bs = MAX_MIB_SIZE;
if (!cm->mi_grid_visible[ypos / bs * cm->mi_stride + xpos / bs]
->mbmi.skip)
detect_clpf(rec->y_buffer, org->y_buffer, xpos, ypos, rec->y_crop_width,
......@@ -141,8 +141,8 @@ static int clpf_rdo(int y, int x, const YV12_BUFFER_CONFIG *rec,
for (n = 0; n < w; n++) {
int xpos = x + n * block_size;
int ypos = y + m * block_size;
if (!cm->mi_grid_visible[ypos / MI_BLOCK_SIZE * cm->mi_stride +
xpos / MI_BLOCK_SIZE]
if (!cm->mi_grid_visible[ypos / MAX_MIB_SIZE * cm->mi_stride +
xpos / MAX_MIB_SIZE]
->mbmi.skip) {
detect_multi_clpf(rec->y_buffer, org->y_buffer, xpos, ypos,
rec->y_crop_width, rec->y_crop_height, org->y_stride,
......@@ -167,7 +167,7 @@ void av1_clpf_test_frame(const YV12_BUFFER_CONFIG *rec,
int i, j, k, l;
int64_t best, sums[4][4];
int width = rec->y_crop_width, height = rec->y_crop_height;
const int bs = MI_BLOCK_SIZE;
const int bs = MAX_MIB_SIZE;
int fb_size_log2 = get_msb(MAX_FB_SIZE);
int num_fb_ver = (height + (1 << fb_size_log2) - bs) >> fb_size_log2;
int num_fb_hor = (width + (1 << fb_size_log2) - bs) >> fb_size_log2;
......
......@@ -1371,14 +1371,14 @@ static void restore_context(MACROBLOCK *const x, int mi_row, int mi_col,
(sizeof(ENTROPY_CONTEXT) * num_4x4_blocks_wide) >>
xd->plane[p].subsampling_x);
memcpy(xd->left_context[p] +
((mi_row & MI_MASK) * 2 >> xd->plane[p].subsampling_y),
((mi_row & MAX_MIB_MASK) * 2 >> xd->plane[p].subsampling_y),
l + num_4x4_blocks_high * p,
(sizeof(ENTROPY_CONTEXT) * num_4x4_blocks_high) >>
xd->plane[p].subsampling_y);
}
memcpy(xd->above_seg_context + mi_col, sa,
sizeof(*xd->above_seg_context) * mi_width);
memcpy(xd->left_seg_context + (mi_row & MI_MASK), sl,
memcpy(xd->left_seg_context + (mi_row & MAX_MIB_MASK), sl,
sizeof(xd->left_seg_context[0]) * mi_height);
}
......@@ -1402,13 +1402,13 @@ static void save_context(MACROBLOCK *const x, int mi_row, int mi_col,
xd->plane[p].subsampling_x);
memcpy(l + num_4x4_blocks_high * p,
xd->left_context[p] +
((mi_row & MI_MASK) * 2 >> xd->plane[p].subsampling_y),
((mi_row & MAX_MIB_MASK) * 2 >> xd->plane[p].subsampling_y),
(sizeof(ENTROPY_CONTEXT) * num_4x4_blocks_high) >>
xd->plane[p].subsampling_y);
}
memcpy(sa, xd->above_seg_context + mi_col,
sizeof(*xd->above_seg_context) * mi_width);
memcpy(sl, xd->left_seg_context + (mi_row & MI_MASK),
memcpy(sl, xd->left_seg_context + (mi_row & MAX_MIB_MASK),
sizeof(xd->left_seg_context[0]) * mi_height);
}
......@@ -1521,9 +1521,9 @@ static void set_partial_b64x64_partition(MODE_INFO *mi, int mis, int bh_in,
MODE_INFO **mi_8x8) {
int bh = bh_in;
int r, c;
for (r = 0; r < MI_BLOCK_SIZE; r += bh) {
for (r = 0; r < MAX_MIB_SIZE; r += bh) {
int bw = bw_in;
for (c = 0; c < MI_BLOCK_SIZE; c += bw) {
for (c = 0; c < MAX_MIB_SIZE; c += bw) {
const int index = r * mis + c;
mi_8x8[index] = mi + index;
mi_8x8[index]->mbmi.sb_type = find_partition_size(
......@@ -1552,10 +1552,10 @@ static void set_fixed_partitioning(AV1_COMP *cpi, const TileInfo *const tile,
assert((row8x8_remaining > 0) && (col8x8_remaining > 0));
// Apply the requested partition size to the SB64 if it is all "in image"
if ((col8x8_remaining >= MI_BLOCK_SIZE) &&
(row8x8_remaining >= MI_BLOCK_SIZE)) {
for (block_row = 0; block_row < MI_BLOCK_SIZE; block_row += bh) {
for (block_col = 0; block_col < MI_BLOCK_SIZE; block_col += bw) {
if ((col8x8_remaining >= MAX_MIB_SIZE) &&
(row8x8_remaining >= MAX_MIB_SIZE)) {
for (block_row = 0; block_row < MAX_MIB_SIZE; block_row += bh) {
for (block_col = 0; block_col < MAX_MIB_SIZE; block_col += bw) {
int index = block_row * mis + block_col;
mi_8x8[index] = mi_upper_left + index;
mi_8x8[index]->mbmi.sb_type = bsize;
......@@ -1848,8 +1848,8 @@ static void get_sb_partition_size_range(MACROBLOCKD *xd, MODE_INFO **mi_8x8,
BLOCK_SIZE *min_block_size,
BLOCK_SIZE *max_block_size,
int bs_hist[BLOCK_SIZES]) {
int sb_width_in_blocks = MI_BLOCK_SIZE;
int sb_height_in_blocks = MI_BLOCK_SIZE;
int sb_width_in_blocks = MAX_MIB_SIZE;
int sb_height_in_blocks = MAX_MIB_SIZE;
int i, j;
int index = 0;
......@@ -1906,13 +1906,13 @@ static void rd_auto_partition_range(AV1_COMP *cpi, const TileInfo *const tile,
}
// Find the min and max partition sizes used in the left SB64
if (left_in_image) {
MODE_INFO **left_sb64_mi = &mi[-MI_BLOCK_SIZE];
MODE_INFO **left_sb64_mi = &mi[-MAX_MIB_SIZE];
get_sb_partition_size_range(xd, left_sb64_mi, &min_size, &max_size,
bs_hist);
}
// Find the min and max partition sizes used in the above SB64.
if (above_in_image) {
MODE_INFO **above_sb64_mi = &mi[-xd->mi_stride * MI_BLOCK_SIZE];
MODE_INFO **above_sb64_mi = &mi[-xd->mi_stride * MAX_MIB_SIZE];
get_sb_partition_size_range(xd, above_sb64_mi, &min_size, &max_size,