Commit 5e16d397 authored by James Zern's avatar James Zern

vpx_dsp_common: add VPX prefix to MIN/MAX

prevents redeclaration warnings;
vp8 has its own define which will be resolved in a future commit

Change-Id: Ic941fef3dd4262fcdce48b73075fe6b375f11c9c
parent 205532f3
......@@ -238,7 +238,7 @@ static INLINE TX_SIZE get_uv_tx_size_impl(TX_SIZE y_tx_size, BLOCK_SIZE bsize,
return TX_4X4;
} else {
const BLOCK_SIZE plane_bsize = ss_size_lookup[bsize][xss][yss];
return MIN(y_tx_size, max_txsize_lookup[plane_bsize]);
return VPXMIN(y_tx_size, max_txsize_lookup[plane_bsize]);
}
}
......
......@@ -35,7 +35,7 @@ static const uint8_t num_8x8_blocks_wide_lookup[BLOCK_SIZES] =
static const uint8_t num_8x8_blocks_high_lookup[BLOCK_SIZES] =
{1, 1, 1, 1, 2, 1, 2, 4, 2, 4, 8, 4, 8};
// MIN(3, MIN(b_width_log2(bsize), b_height_log2(bsize)))
// VPXMIN(3, VPXMIN(b_width_log2(bsize), b_height_log2(bsize)))
static const uint8_t size_group_lookup[BLOCK_SIZES] =
{0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3};
......
......@@ -1588,7 +1588,7 @@ void vp10_loop_filter_frame(YV12_BUFFER_CONFIG *frame,
if (partial_frame && cm->mi_rows > 8) {
start_mi_row = cm->mi_rows >> 1;
start_mi_row &= 0xfffffff8;
mi_rows_to_filter = MAX(cm->mi_rows / 8, 8);
mi_rows_to_filter = VPXMAX(cm->mi_rows / 8, 8);
}
end_mi_row = start_mi_row + mi_rows_to_filter;
vp10_loop_filter_frame_init(cm, frame_filter_level);
......
......@@ -625,7 +625,7 @@ static void swap_mi_and_prev_mi(VP10_COMMON *cm) {
int vp10_post_proc_frame(struct VP10Common *cm,
YV12_BUFFER_CONFIG *dest, vp10_ppflags_t *ppflags) {
const int q = MIN(105, cm->lf.filter_level * 2);
const int q = VPXMIN(105, cm->lf.filter_level * 2);
const int flags = ppflags->post_proc_flag;
YV12_BUFFER_CONFIG *const ppbuf = &cm->post_proc_buffer;
struct postproc_state *const ppstate = &cm->postproc_state;
......
......@@ -24,14 +24,14 @@ static INLINE int get_segment_id(const VP10_COMMON *cm,
const int mi_offset = mi_row * cm->mi_cols + mi_col;
const int bw = num_8x8_blocks_wide_lookup[bsize];
const int bh = num_8x8_blocks_high_lookup[bsize];
const int xmis = MIN(cm->mi_cols - mi_col, bw);
const int ymis = MIN(cm->mi_rows - mi_row, bh);
const int xmis = VPXMIN(cm->mi_cols - mi_col, bw);
const int ymis = VPXMIN(cm->mi_rows - mi_row, bh);
int x, y, segment_id = MAX_SEGMENTS;
for (y = 0; y < ymis; ++y)
for (x = 0; x < xmis; ++x)
segment_id = MIN(segment_id,
segment_ids[mi_offset + y * cm->mi_cols + x]);
segment_id =
VPXMIN(segment_id, segment_ids[mi_offset + y * cm->mi_cols + x]);
assert(segment_id >= 0 && segment_id < MAX_SEGMENTS);
return segment_id;
......
......@@ -165,7 +165,7 @@ static void loop_filter_rows_mt(YV12_BUFFER_CONFIG *frame,
// Decoder may allocate more threads than number of tiles based on user's
// input.
const int tile_cols = 1 << cm->log2_tile_cols;
const int num_workers = MIN(nworkers, tile_cols);
const int num_workers = VPXMIN(nworkers, tile_cols);
int i;
if (!lf_sync->sync_range || sb_rows != lf_sync->rows ||
......@@ -229,7 +229,7 @@ void vp10_loop_filter_frame_mt(YV12_BUFFER_CONFIG *frame,
if (partial_frame && cm->mi_rows > 8) {
start_mi_row = cm->mi_rows >> 1;
start_mi_row &= 0xfffffff8;
mi_rows_to_filter = MAX(cm->mi_rows / 8, 8);
mi_rows_to_filter = VPXMAX(cm->mi_rows / 8, 8);
}
end_mi_row = start_mi_row + mi_rows_to_filter;
vp10_loop_filter_frame_init(cm, frame_filter_level);
......
......@@ -18,7 +18,7 @@
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;
return MIN(offset, mis);
return VPXMIN(offset, mis);
}
void vp10_tile_set_row(TileInfo *tile, const VP10_COMMON *cm, int row) {
......
......@@ -624,7 +624,7 @@ static void dec_build_inter_predictors(VP10Decoder *const pbi, MACROBLOCKD *xd,
// pixels of each superblock row can be changed by next superblock row.
if (pbi->frame_parallel_decode)
vp10_frameworker_wait(pbi->frame_worker_owner, ref_frame_buf,
MAX(0, (y1 + 7)) << (plane == 0 ? 0 : 1));
VPXMAX(0, (y1 + 7)) << (plane == 0 ? 0 : 1));
// Skip border extension if block is inside the frame.
if (x0 < 0 || x0 > frame_width - 1 || x1 < 0 || x1 > frame_width - 1 ||
......@@ -652,7 +652,7 @@ static void dec_build_inter_predictors(VP10Decoder *const pbi, MACROBLOCKD *xd,
if (pbi->frame_parallel_decode) {
const int y1 = (y0_16 + (h - 1) * ys) >> SUBPEL_BITS;
vp10_frameworker_wait(pbi->frame_worker_owner, ref_frame_buf,
MAX(0, (y1 + 7)) << (plane == 0 ? 0 : 1));
VPXMAX(0, (y1 + 7)) << (plane == 0 ? 0 : 1));
}
}
#if CONFIG_VP9_HIGHBITDEPTH
......@@ -723,8 +723,8 @@ static void dec_build_inter_predictors_sb(VP10Decoder *const pbi,
static INLINE TX_SIZE dec_get_uv_tx_size(const MB_MODE_INFO *mbmi,
int n4_wl, int n4_hl) {
// get minimum log2 num4x4s dimension
const int x = MIN(n4_wl, n4_hl);
return MIN(mbmi->tx_size, x);
const int x = VPXMIN(n4_wl, n4_hl);
return VPXMIN(mbmi->tx_size, x);
}
static INLINE void dec_reset_skip_context(MACROBLOCKD *xd) {
......@@ -785,8 +785,8 @@ static void decode_block(VP10Decoder *const pbi, MACROBLOCKD *const xd,
const int less8x8 = bsize < BLOCK_8X8;
const int bw = 1 << (bwl - 1);
const int bh = 1 << (bhl - 1);
const int x_mis = MIN(bw, cm->mi_cols - mi_col);
const int y_mis = MIN(bh, cm->mi_rows - mi_row);
const int x_mis = VPXMIN(bw, cm->mi_cols - mi_col);
const int y_mis = VPXMIN(bh, cm->mi_rows - mi_row);
MB_MODE_INFO *mbmi = set_offsets(cm, xd, bsize, mi_row, mi_col,
bw, bh, x_mis, y_mis, bwl, bhl);
......@@ -1570,7 +1570,7 @@ static const uint8_t *decode_tiles_mt(VP10Decoder *pbi,
const int aligned_mi_cols = mi_cols_aligned_to_sb(cm->mi_cols);
const int tile_cols = 1 << cm->log2_tile_cols;
const int tile_rows = 1 << cm->log2_tile_rows;
const int num_workers = MIN(pbi->max_threads & ~1, tile_cols);
const int num_workers = VPXMIN(pbi->max_threads & ~1, tile_cols);
TileBuffer tile_buffers[1][1 << 6];
int n;
int final_worker = -1;
......@@ -1637,7 +1637,7 @@ static const uint8_t *decode_tiles_mt(VP10Decoder *pbi,
int group_start = 0;
while (group_start < tile_cols) {
const TileBuffer largest = tile_buffers[0][group_start];
const int group_end = MIN(group_start + num_workers, tile_cols) - 1;
const int group_end = VPXMIN(group_start + num_workers, tile_cols) - 1;
memmove(tile_buffers[0] + group_start, tile_buffers[0] + group_start + 1,
(group_end - group_start) * sizeof(tile_buffers[0][0]));
tile_buffers[0][group_end] = largest;
......@@ -2069,7 +2069,7 @@ static struct vpx_read_bit_buffer *init_read_bit_buffer(
rb->error_handler = error_handler;
rb->error_handler_data = &pbi->common;
if (pbi->decrypt_cb) {
const int n = (int)MIN(MAX_VP9_HEADER_SIZE, data_end - data);
const int n = (int)VPXMIN(MAX_VP9_HEADER_SIZE, data_end - data);
pbi->decrypt_cb(pbi->decrypt_state, data, clear_data, n);
rb->bit_buffer = clear_data;
rb->bit_buffer_end = clear_data + n;
......
......@@ -87,7 +87,7 @@ static TX_SIZE read_tx_size(VP10_COMMON *cm, MACROBLOCKD *xd,
if (allow_select && tx_mode == TX_MODE_SELECT && bsize >= BLOCK_8X8)
return read_selected_tx_size(cm, xd, max_tx_size, r);
else
return MIN(max_tx_size, tx_mode_to_biggest_tx_size[tx_mode]);
return VPXMIN(max_tx_size, tx_mode_to_biggest_tx_size[tx_mode]);
}
static int dec_get_segment_id(const VP10_COMMON *cm, const uint8_t *segment_ids,
......@@ -96,8 +96,8 @@ static int dec_get_segment_id(const VP10_COMMON *cm, const uint8_t *segment_ids,
for (y = 0; y < y_mis; y++)
for (x = 0; x < x_mis; x++)
segment_id = MIN(segment_id,
segment_ids[mi_offset + y * cm->mi_cols + x]);
segment_id =
VPXMIN(segment_id, segment_ids[mi_offset + y * cm->mi_cols + x]);
assert(segment_id >= 0 && segment_id < MAX_SEGMENTS);
return segment_id;
......@@ -156,8 +156,8 @@ static int read_inter_segment_id(VP10_COMMON *const cm, MACROBLOCKD *const xd,
const int bh = xd->plane[0].n4_h >> 1;
// TODO(slavarnway): move x_mis, y_mis into xd ?????
const int x_mis = MIN(cm->mi_cols - mi_col, bw);
const int y_mis = MIN(cm->mi_rows - mi_row, bh);
const int x_mis = VPXMIN(cm->mi_cols - mi_col, bw);
const int y_mis = VPXMIN(cm->mi_rows - mi_row, bh);
if (!seg->enabled)
return 0; // Default for disabled segmentation
......@@ -212,8 +212,8 @@ static void read_intra_frame_mode_info(VP10_COMMON *const cm,
const int bh = xd->plane[0].n4_h >> 1;
// TODO(slavarnway): move x_mis, y_mis into xd ?????
const int x_mis = MIN(cm->mi_cols - mi_col, bw);
const int y_mis = MIN(cm->mi_rows - mi_row, bh);
const int x_mis = VPXMIN(cm->mi_cols - mi_col, bw);
const int y_mis = VPXMIN(cm->mi_rows - mi_row, bh);
mbmi->segment_id = read_intra_segment_id(cm, mi_offset, x_mis, y_mis, r);
mbmi->skip = read_skip(cm, xd, mbmi->segment_id, r);
......
......@@ -117,8 +117,8 @@ void vp10_caq_select_segment(VP10_COMP *cpi, MACROBLOCK *mb, BLOCK_SIZE bs,
const int mi_offset = mi_row * cm->mi_cols + mi_col;
const int bw = num_8x8_blocks_wide_lookup[BLOCK_64X64];
const int bh = num_8x8_blocks_high_lookup[BLOCK_64X64];
const int xmis = MIN(cm->mi_cols - mi_col, num_8x8_blocks_wide_lookup[bs]);
const int ymis = MIN(cm->mi_rows - mi_row, num_8x8_blocks_high_lookup[bs]);
const int xmis = VPXMIN(cm->mi_cols - mi_col, num_8x8_blocks_wide_lookup[bs]);
const int ymis = VPXMIN(cm->mi_rows - mi_row, num_8x8_blocks_high_lookup[bs]);
int x, y;
int i;
unsigned char segment;
......@@ -136,7 +136,7 @@ void vp10_caq_select_segment(VP10_COMP *cpi, MACROBLOCK *mb, BLOCK_SIZE bs,
vpx_clear_system_state();
low_var_thresh = (cpi->oxcf.pass == 2)
? MAX(cpi->twopass.mb_av_energy, MIN_DEFAULT_LV_THRESH)
? VPXMAX(cpi->twopass.mb_av_energy, MIN_DEFAULT_LV_THRESH)
: DEFAULT_LV_THRESH;
vp10_setup_src_planes(mb, cpi->Source, mi_row, mi_col);
......
......@@ -220,8 +220,8 @@ void vp10_cyclic_refresh_update_segment(VP10_COMP *const cpi,
CYCLIC_REFRESH *const cr = cpi->cyclic_refresh;
const int bw = num_8x8_blocks_wide_lookup[bsize];
const int bh = num_8x8_blocks_high_lookup[bsize];
const int xmis = MIN(cm->mi_cols - mi_col, bw);
const int ymis = MIN(cm->mi_rows - mi_row, bh);
const int xmis = VPXMIN(cm->mi_cols - mi_col, bw);
const int ymis = VPXMIN(cm->mi_rows - mi_row, bh);
const int block_index = mi_row * cm->mi_cols + mi_col;
const int refresh_this_block = candidate_refresh_aq(cr, mbmi, rate, dist,
bsize);
......@@ -413,10 +413,10 @@ static void cyclic_refresh_update_map(VP10_COMP *const cpi) {
assert(mi_col >= 0 && mi_col < cm->mi_cols);
bl_index = mi_row * cm->mi_cols + mi_col;
// Loop through all 8x8 blocks in superblock and update map.
xmis = MIN(cm->mi_cols - mi_col,
num_8x8_blocks_wide_lookup[BLOCK_64X64]);
ymis = MIN(cm->mi_rows - mi_row,
num_8x8_blocks_high_lookup[BLOCK_64X64]);
xmis =
VPXMIN(cm->mi_cols - mi_col, num_8x8_blocks_wide_lookup[BLOCK_64X64]);
ymis =
VPXMIN(cm->mi_rows - mi_row, num_8x8_blocks_high_lookup[BLOCK_64X64]);
for (y = 0; y < ymis; y++) {
for (x = 0; x < xmis; x++) {
const int bl_index2 = bl_index + y * cm->mi_cols + x;
......@@ -545,8 +545,9 @@ void vp10_cyclic_refresh_setup(VP10_COMP *const cpi) {
// Set a more aggressive (higher) q delta for segment BOOST2.
qindex_delta = compute_deltaq(
cpi, cm->base_qindex, MIN(CR_MAX_RATE_TARGET_RATIO,
0.1 * cr->rate_boost_fac * cr->rate_ratio_qdelta));
cpi, cm->base_qindex,
VPXMIN(CR_MAX_RATE_TARGET_RATIO,
0.1 * cr->rate_boost_fac * cr->rate_ratio_qdelta));
cr->qindex_delta[2] = qindex_delta;
vp10_set_segdata(seg, CR_SEGMENT_ID_BOOST2, SEG_LVL_ALT_Q, qindex_delta);
......
......@@ -815,7 +815,7 @@ static void encode_segmentation(VP10_COMMON *cm, MACROBLOCKD *xd,
static void encode_txfm_probs(VP10_COMMON *cm, vpx_writer *w,
FRAME_COUNTS *counts) {
// Mode
vpx_write_literal(w, MIN(cm->tx_mode, ALLOW_32X32), 2);
vpx_write_literal(w, VPXMIN(cm->tx_mode, ALLOW_32X32), 2);
if (cm->tx_mode >= ALLOW_32X32)
vpx_write_bit(w, cm->tx_mode == TX_MODE_SELECT);
......
......@@ -124,10 +124,10 @@ int vp10_denoiser_filter_c(const uint8_t *sig, int sig_stride,
adj = adj_val[2];
}
if (diff > 0) {
avg[c] = MIN(UINT8_MAX, sig[c] + adj);
avg[c] = VPXMIN(UINT8_MAX, sig[c] + adj);
total_adj += adj;
} else {
avg[c] = MAX(0, sig[c] - adj);
avg[c] = VPXMAX(0, sig[c] - adj);
total_adj -= adj;
}
}
......@@ -164,13 +164,13 @@ int vp10_denoiser_filter_c(const uint8_t *sig, int sig_stride,
// Diff positive means we made positive adjustment above
// (in first try/attempt), so now make negative adjustment to bring
// denoised signal down.
avg[c] = MAX(0, avg[c] - adj);
avg[c] = VPXMAX(0, avg[c] - adj);
total_adj -= adj;
} else {
// Diff negative means we made negative adjustment above
// (in first try/attempt), so now make positive adjustment to bring
// denoised signal up.
avg[c] = MIN(UINT8_MAX, avg[c] + adj);
avg[c] = VPXMIN(UINT8_MAX, avg[c] + adj);
total_adj += adj;
}
}
......
......@@ -978,8 +978,8 @@ static void update_state(VP10_COMP *cpi, ThreadData *td,
const struct segmentation *const seg = &cm->seg;
const int bw = num_8x8_blocks_wide_lookup[mi->mbmi.sb_type];
const int bh = num_8x8_blocks_high_lookup[mi->mbmi.sb_type];
const int x_mis = MIN(bw, cm->mi_cols - mi_col);
const int y_mis = MIN(bh, cm->mi_rows - mi_row);
const int x_mis = VPXMIN(bw, cm->mi_cols - mi_col);
const int y_mis = VPXMIN(bh, cm->mi_rows - mi_row);
MV_REF *const frame_mvs =
cm->cur_frame->mvs + mi_row * cm->mi_cols + mi_col;
int w, h;
......@@ -1131,8 +1131,8 @@ static void set_mode_info_seg_skip(MACROBLOCK *x, TX_MODE tx_mode,
mbmi->sb_type = bsize;
mbmi->mode = ZEROMV;
mbmi->tx_size = MIN(max_txsize_lookup[bsize],
tx_mode_to_biggest_tx_size[tx_mode]);
mbmi->tx_size = VPXMIN(max_txsize_lookup[bsize],
tx_mode_to_biggest_tx_size[tx_mode]);
mbmi->skip = 1;
mbmi->uv_mode = DC_PRED;
mbmi->ref_frame[0] = LAST_FRAME;
......@@ -1495,7 +1495,7 @@ static BLOCK_SIZE find_partition_size(BLOCK_SIZE bsize,
int rows_left, int cols_left,
int *bh, int *bw) {
if (rows_left <= 0 || cols_left <= 0) {
return MIN(bsize, BLOCK_8X8);
return VPXMIN(bsize, BLOCK_8X8);
} else {
for (; bsize > 0; bsize -= 3) {
*bh = num_8x8_blocks_high_lookup[bsize];
......@@ -1869,8 +1869,8 @@ static void get_sb_partition_size_range(MACROBLOCKD *xd, MODE_INFO **mi_8x8,
MODE_INFO *mi = mi_8x8[index+j];
BLOCK_SIZE sb_type = mi ? mi->mbmi.sb_type : 0;
bs_hist[sb_type]++;
*min_block_size = MIN(*min_block_size, sb_type);
*max_block_size = MAX(*max_block_size, sb_type);
*min_block_size = VPXMIN(*min_block_size, sb_type);
*max_block_size = VPXMAX(*max_block_size, sb_type);
}
index += xd->mi_stride;
}
......@@ -1947,8 +1947,8 @@ static void rd_auto_partition_range(VP10_COMP *cpi, const TileInfo *const tile,
if (vp10_active_edge_sb(cpi, mi_row, mi_col)) {
min_size = BLOCK_4X4;
} else {
min_size = MIN(cpi->sf.rd_auto_partition_min_limit,
MIN(min_size, max_size));
min_size =
VPXMIN(cpi->sf.rd_auto_partition_min_limit, VPXMIN(min_size, max_size));
}
// When use_square_partition_only is true, make sure at least one square
......@@ -1984,8 +1984,8 @@ static void set_partition_range(VP10_COMMON *cm, MACROBLOCKD *xd,
for (idx = 0; idx < mi_width; ++idx) {
mi = prev_mi[idy * cm->mi_stride + idx];
bs = mi ? mi->mbmi.sb_type : bsize;
min_size = MIN(min_size, bs);
max_size = MAX(max_size, bs);
min_size = VPXMIN(min_size, bs);
max_size = VPXMAX(max_size, bs);
}
}
}
......@@ -1994,8 +1994,8 @@ static void set_partition_range(VP10_COMMON *cm, MACROBLOCKD *xd,
for (idy = 0; idy < mi_height; ++idy) {
mi = xd->mi[idy * cm->mi_stride - 1];
bs = mi ? mi->mbmi.sb_type : bsize;
min_size = MIN(min_size, bs);
max_size = MAX(max_size, bs);
min_size = VPXMIN(min_size, bs);
max_size = VPXMAX(max_size, bs);
}
}
......@@ -2003,8 +2003,8 @@ static void set_partition_range(VP10_COMMON *cm, MACROBLOCKD *xd,
for (idx = 0; idx < mi_width; ++idx) {
mi = xd->mi[idx - cm->mi_stride];
bs = mi ? mi->mbmi.sb_type : bsize;
min_size = MIN(min_size, bs);
max_size = MAX(max_size, bs);
min_size = VPXMIN(min_size, bs);
max_size = VPXMAX(max_size, bs);
}
}
......@@ -2169,9 +2169,9 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td,
int mb_row = mi_row >> 1;
int mb_col = mi_col >> 1;
int mb_row_end =
MIN(mb_row + num_16x16_blocks_high_lookup[bsize], cm->mb_rows);
VPXMIN(mb_row + num_16x16_blocks_high_lookup[bsize], cm->mb_rows);
int mb_col_end =
MIN(mb_col + num_16x16_blocks_wide_lookup[bsize], cm->mb_cols);
VPXMIN(mb_col + num_16x16_blocks_wide_lookup[bsize], cm->mb_cols);
int r, c;
// compute a complexity measure, basically measure inconsistency of motion
......@@ -2260,9 +2260,9 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td,
int mb_row = mi_row >> 1;
int mb_col = mi_col >> 1;
int mb_row_end =
MIN(mb_row + num_16x16_blocks_high_lookup[bsize], cm->mb_rows);
VPXMIN(mb_row + num_16x16_blocks_high_lookup[bsize], cm->mb_rows);
int mb_col_end =
MIN(mb_col + num_16x16_blocks_wide_lookup[bsize], cm->mb_cols);
VPXMIN(mb_col + num_16x16_blocks_wide_lookup[bsize], cm->mb_cols);
int r, c;
int skip = 1;
......@@ -2887,7 +2887,7 @@ static void encode_frame_internal(VP10_COMP *cpi) {
#endif
// If allowed, encoding tiles in parallel with one thread handling one tile.
if (MIN(cpi->oxcf.max_threads, 1 << cm->log2_tile_cols) > 1)
if (VPXMIN(cpi->oxcf.max_threads, 1 << cm->log2_tile_cols) > 1)
vp10_encode_tiles_mt(cpi);
else
encode_tiles(cpi);
......@@ -3102,10 +3102,10 @@ static void encode_superblock(VP10_COMP *cpi, ThreadData *td,
int plane;
mbmi->skip = 1;
for (plane = 0; plane < MAX_MB_PLANE; ++plane)
vp10_encode_intra_block_plane(x, MAX(bsize, BLOCK_8X8), plane);
vp10_encode_intra_block_plane(x, VPXMAX(bsize, BLOCK_8X8), plane);
if (output_enabled)
sum_intra_stats(td->counts, mi);
vp10_tokenize_sb(cpi, td, t, !output_enabled, MAX(bsize, BLOCK_8X8));
vp10_tokenize_sb(cpi, td, t, !output_enabled, VPXMAX(bsize, BLOCK_8X8));
} else {
int ref;
const int is_compound = has_second_ref(mbmi);
......@@ -3118,12 +3118,14 @@ static void encode_superblock(VP10_COMP *cpi, ThreadData *td,
&xd->block_refs[ref]->sf);
}
if (!(cpi->sf.reuse_inter_pred_sby && ctx->pred_pixel_ready) || seg_skip)
vp10_build_inter_predictors_sby(xd, mi_row, mi_col, MAX(bsize, BLOCK_8X8));
vp10_build_inter_predictors_sby(xd, mi_row, mi_col,
VPXMAX(bsize, BLOCK_8X8));
vp10_build_inter_predictors_sbuv(xd, mi_row, mi_col, MAX(bsize, BLOCK_8X8));
vp10_build_inter_predictors_sbuv(xd, mi_row, mi_col,
VPXMAX(bsize, BLOCK_8X8));
vp10_encode_sb(x, MAX(bsize, BLOCK_8X8));
vp10_tokenize_sb(cpi, td, t, !output_enabled, MAX(bsize, BLOCK_8X8));
vp10_encode_sb(x, VPXMAX(bsize, BLOCK_8X8));
vp10_tokenize_sb(cpi, td, t, !output_enabled, VPXMAX(bsize, BLOCK_8X8));
}
if (output_enabled) {
......@@ -3137,8 +3139,8 @@ static void encode_superblock(VP10_COMP *cpi, ThreadData *td,
TX_SIZE tx_size;
// The new intra coding scheme requires no change of transform size
if (is_inter_block(&mi->mbmi)) {
tx_size = MIN(tx_mode_to_biggest_tx_size[cm->tx_mode],
max_txsize_lookup[bsize]);
tx_size = VPXMIN(tx_mode_to_biggest_tx_size[cm->tx_mode],
max_txsize_lookup[bsize]);
} else {
tx_size = (bsize >= BLOCK_8X8) ? mbmi->tx_size : TX_4X4;
}
......
......@@ -216,8 +216,8 @@ void vp10_encode_mv(VP10_COMP* cpi, vpx_writer* w,
// If auto_mv_step_size is enabled then keep track of the largest
// motion vector component used.
if (cpi->sf.mv.auto_mv_step_size) {
unsigned int maxv = MAX(abs(mv->row), abs(mv->col)) >> 3;
cpi->max_mv_magnitude = MAX(maxv, cpi->max_mv_magnitude);
unsigned int maxv = VPXMAX(abs(mv->row), abs(mv->col)) >> 3;
cpi->max_mv_magnitude = VPXMAX(maxv, cpi->max_mv_magnitude);
}
}
......
......@@ -1492,8 +1492,8 @@ void vp10_change_config(struct VP10_COMP *cpi, const VP10EncoderConfig *oxcf) {
// Under a configuration change, where maximum_buffer_size may change,
// keep buffer level clipped to the maximum allowed buffer size.
rc->bits_off_target = MIN(rc->bits_off_target, rc->maximum_buffer_size);
rc->buffer_level = MIN(rc->buffer_level, rc->maximum_buffer_size);
rc->bits_off_target = VPXMIN(rc->bits_off_target, rc->maximum_buffer_size);
rc->buffer_level = VPXMIN(rc->buffer_level, rc->maximum_buffer_size);
// Set up frame rate and related parameters rate control values.
vp10_new_framerate(cpi, cpi->framerate);
......@@ -2615,7 +2615,7 @@ static int scale_down(VP10_COMP *cpi, int q) {
if (rc->frame_size_selector == UNSCALED &&
q >= rc->rf_level_maxq[gf_group->rf_level[gf_group->index]]) {
const int max_size_thresh = (int)(rate_thresh_mult[SCALE_STEP1]
* MAX(rc->this_frame_target, rc->avg_frame_bandwidth));
* VPXMAX(rc->this_frame_target, rc->avg_frame_bandwidth));
scale = rc->projected_frame_size > max_size_thresh ? 1 : 0;
}
return scale;
......@@ -2998,7 +2998,7 @@ static void output_frame_level_debug_stats(VP10_COMP *cpi) {
static void set_mv_search_params(VP10_COMP *cpi) {
const VP10_COMMON *const cm = &cpi->common;
const unsigned int max_mv_def = MIN(cm->width, cm->height);
const unsigned int max_mv_def = VPXMIN(cm->width, cm->height);
// Default based on max resolution.
cpi->mv_step_param = vp10_init_search_range(max_mv_def);
......@@ -3013,8 +3013,8 @@ static void set_mv_search_params(VP10_COMP *cpi) {
// Allow mv_steps to correspond to twice the max mv magnitude found
// in the previous frame, capped by the default max_mv_magnitude based
// on resolution.
cpi->mv_step_param =
vp10_init_search_range(MIN(max_mv_def, 2 * cpi->max_mv_magnitude));
cpi->mv_step_param = vp10_init_search_range(
VPXMIN(max_mv_def, 2 * cpi->max_mv_magnitude));
}
cpi->max_mv_magnitude = 0;
}
......@@ -3386,7 +3386,7 @@ static void encode_with_recode_loop(VP10_COMP *cpi,
// Adjust Q
q = (int)((q * high_err_target) / kf_err);
q = MIN(q, (q_high + q_low) >> 1);
q = VPXMIN(q, (q_high + q_low) >> 1);
} else if (kf_err < low_err_target &&
rc->projected_frame_size >= frame_under_shoot_limit) {
// The key frame is much better than the previous frame
......@@ -3395,7 +3395,7 @@ static void encode_with_recode_loop(VP10_COMP *cpi,
// Adjust Q
q = (int)((q * low_err_target) / kf_err);
q = MIN(q, (q_high + q_low + 1) >> 1);
q = VPXMIN(q, (q_high + q_low + 1) >> 1);
}
// Clamp Q to upper and lower limits:
......@@ -3404,7 +3404,7 @@ static void encode_with_recode_loop(VP10_COMP *cpi,
loop = q != last_q;
} else if (recode_loop_test(
cpi, frame_over_shoot_limit, frame_under_shoot_limit,
q, MAX(q_high, top_index), bottom_index)) {
q, VPXMAX(q_high, top_index), bottom_index)) {
// Is the projected frame size out of range and are we allowed
// to attempt to recode.
int last_q = q;
......@@ -3446,12 +3446,12 @@ static void encode_with_recode_loop(VP10_COMP *cpi,
vp10_rc_update_rate_correction_factors(cpi);
q = vp10_rc_regulate_q(cpi, rc->this_frame_target,
bottom_index, MAX(q_high, top_index));
bottom_index, VPXMAX(q_high, top_index));
while (q < q_low && retries < 10) {
vp10_rc_update_rate_correction_factors(cpi);
q = vp10_rc_regulate_q(cpi, rc->this_frame_target,
bottom_index, MAX(q_high, top_index));
bottom_index, VPXMAX(q_high, top_index));
retries++;
}
}
......@@ -4030,8 +4030,8 @@ static void adjust_frame_rate(VP10_COMP *cpi,
// Average this frame's rate into the last second's average
// frame rate. If we haven't seen 1 second yet, then average
// over the whole interval seen.
const double interval = MIN((double)(source->ts_end
- cpi->first_time_stamp_ever), 10000000.0);
const double interval = VPXMIN(
(double)(source->ts_end - cpi->first_time_stamp_ever), 10000000.0);
double avg_duration = 10000000.0 / cpi->framerate;
avg_duration *= (interval - avg_duration + this_duration);
avg_duration /= interval;
......@@ -4095,7 +4095,7 @@ static void adjust_image_stat(double y, double u, double v, double all,
s->stat[U] += u;
s->stat[V] += v;
s->stat[ALL] += all;
s->worst = MIN(s->worst, all);
s->worst = VPXMIN(s->worst, all);
}
#endif // CONFIG_INTERNAL_STATS
......@@ -4425,7 +4425,7 @@ int vp10_get_compressed_data(VP10_COMP *cpi, unsigned int *frame_flags,
frame_ssim2 = vpx_calc_ssim(orig, recon, &weight);
#endif // CONFIG_VP9_HIGHBITDEPTH
cpi->worst_ssim= MIN(cpi->worst_ssim, frame_ssim2);
cpi->worst_ssim= VPXMIN(cpi->worst_ssim, frame_ssim2);
cpi->summed_quality += frame_ssim2 * weight;
cpi->summed_weights += weight;
......@@ -4462,7 +4462,8 @@ int vp10_get_compressed_data(VP10_COMP *cpi, unsigned int *frame_flags,
cpi->Source->y_buffer, cpi->Source->y_stride,
cm->frame_to_show->y_buffer, cm->frame_to_show->y_stride,
cpi->Source->y_width, cpi->Source->y_height);
cpi->worst_blockiness = MAX(cpi->worst_blockiness, frame_blockiness);
cpi->worst_blockiness =
VPXMAX(cpi->worst_blockiness, frame_blockiness);
cpi->total_blockiness += frame_blockiness;
}
}
......@@ -4482,8 +4483,8 @@ int vp10_get_compressed_data(VP10_COMP *cpi, unsigned int *frame_flags,
double consistency = vpx_sse_to_psnr(samples, peak,
(double)cpi->total_inconsistency);
if (consistency > 0.0)
cpi->worst_consistency = MIN(cpi->worst_consistency,
consistency);
cpi->worst_consistency =
VPXMIN(cpi->worst_consistency, consistency);
cpi->total_inconsistency += this_inconsistency;
}
}
......
......@@ -67,7 +67,7 @@ void vp10_encode_tiles_mt(VP10_COMP *cpi) {
VP10_COMMON *const cm = &cpi->common;
const int tile_cols = 1 << cm->log2_tile_cols;
const VPxWorkerInterface *const winterface = vpx_get_worker_interface();
const int num_workers = MIN(cpi->oxcf.max_threads, tile_cols);
const int num_workers = VPXMIN(cpi->oxcf.max_threads, tile_cols);
int i;
vp10_init_tile_data(cpi);
......@@ -80,7 +80,7 @@ void vp10_encode_tiles_mt(VP10_COMP *cpi) {
// resolution.
if (cpi->use_svc) {
int max_tile_cols = get_max_tile_cols(cpi);
allocated_workers = MIN(cpi->oxcf.max_threads, max_tile_cols);
allocated_workers = VPXMIN(cpi->oxcf.max_threads, max_tile_cols);
}
CHECK_MEM_ERROR(cm, cpi->workers,
......
......@@ -111,10 +111,12 @@ void vp10_copy_and_extend_frame(const YV12_BUFFER_CONFIG *src,
// Motion estimation may use src block variance with the block size up
// to 64x64, so the right and bottom need to be extended to 64 multiple
// or up to 16, whichever is greater.
const int er_y = MAX(src->y_width + 16, ALIGN_POWER_OF_TWO(src->y_width, 6))
- src->y_crop_width;
const int eb_y = MAX(src->y_height + 16, ALIGN_POWER_OF_TWO(src->y_height, 6))
- src->y_crop_height;
const int er_y =
VPXMAX(src->y_width + 16, ALIGN_POWER_OF_TWO(src->y_width, 6)) -
src->y_crop_width;
const int eb_y =
VPXMAX(src->y_height + 16, ALIGN_POWER_OF_TWO(src->y_height, 6)) -
src->y_crop_height;
const int uv_width_subsampling = (src->uv_width != src->y_width);
const int uv_height_subsampling = (src->uv_height != src->y_height);
const int et_uv = et_y >> uv_height_subsampling;
......
This diff is collapsed.
......@@ -41,7 +41,7 @@ static unsigned int do_16x16_motion_iteration(VP10_COMP *cpi,
// Further step/diamond searches as necessary
int step_param = mv_sf->reduce_first_step_size;
step_param = MIN(step_param, MAX_MVSEARCH_STEPS - 2);
step_param = VPXMIN(step_param, MAX_MVSEARCH_STEPS - 2);
vp10_set_mv_search_range(x, ref_mv);
......
......@@ -37,10 +37,10 @@ void vp10_set_mv_search_range(MACROBLOCK *x, const MV *mv) {
int col_max = (mv->col >> 3) + MAX_FULL_PEL_VAL;
int row_max = (mv->row >> 3) + MAX_FULL_PEL_VAL;
col_min = MAX(col_min, (MV_LOW >> 3) + 1);
row_min = MAX(row_min, (MV_LOW >> 3) + 1);
col_max = MIN(col_max, (MV_UPP >> 3) - 1);
row_max = MIN(row_max, (MV_UPP >> 3) - 1);
col_min = VPXMAX(col_min, (MV_LOW >> 3) + 1);
row_min = VPXMAX(row_min, (MV_LOW >> 3) + 1);
col_max = VPXMIN(col_max, (MV_UPP >> 3) - 1);
row_max = VPXMIN(row_max, (MV_UPP >> 3) - 1);
// Get intersection of UMV window and valid MV window to reduce # of checks
// in diamond search.
......@@ -57,12 +57,12 @@ void vp10_set_mv_search_range(MACROBLOCK *x, const MV *mv) {
int vp10_init_search_range(int size) {
int sr = 0;
// Minimum search size no matter what the passed in value.
size = MAX(16, size);
size = VPXMAX(16, size);
while ((size << sr) < MAX_FULL_PEL_VAL)
sr++;
sr = MIN(sr, MAX_MVSEARCH_STEPS - 2);
sr = VPXMIN(sr, MAX_MVSEARCH_STEPS - 2);
return sr;
}
......@@ -297,10 +297,10 @@ static INLINE const uint8_t *pre(const uint8_t *buf, int stride, int r, int c) {
int br = bestmv->row * 8; \
int bc = bestmv->col * 8; \
int hstep = 4; \
const int minc = MAX(x->mv_col_min * 8, ref_mv->col - MV_MAX); \
const int maxc = MIN(x->mv_col_max * 8, ref_mv->col + MV_MAX); \
const int minr = MAX(x->mv_row_min * 8, ref_mv->row - MV_MAX); \
const int maxr = MIN(x->mv_row_max * 8, ref_mv->row + MV_MAX); \
const int minc = VPXMAX(x->mv_col_min * 8, ref_mv->col - MV_MAX); \
const int maxc = VPXMIN(x->mv_col_max * 8, ref_mv->col + MV_MAX); \
const int minr = VPXMAX(x->mv_row_min * 8, ref_mv->row - MV_MAX); \
const int maxr = VPXMIN(x->mv_row_max * 8, ref_mv->row + MV_MAX); \
int tr = br; \
int tc = bc; \
\
......@@ -668,10 +668,10 @@ int vp10_find_best_sub_pixel_tree(const MACROBLOCK *x,
int bc = bestmv->col * 8;