Index: source/libvpx/vp9/encoder/vp9_encodeframe.c |
diff --git a/source/libvpx/vp9/encoder/vp9_encodeframe.c b/source/libvpx/vp9/encoder/vp9_encodeframe.c |
index e7f14eb7e5f9aa1f4ed422e7897fd79910c887d5..d02d48c8eb4fac97bea69e49a50da10261d8c72c 100644 |
--- a/source/libvpx/vp9/encoder/vp9_encodeframe.c |
+++ b/source/libvpx/vp9/encoder/vp9_encodeframe.c |
@@ -18,6 +18,7 @@ |
#include "vpx_ports/mem.h" |
#include "vpx_ports/vpx_timer.h" |
+#include "vpx_ports/system_state.h" |
#include "vp9/common/vp9_common.h" |
#include "vp9/common/vp9_entropy.h" |
@@ -29,7 +30,6 @@ |
#include "vp9/common/vp9_reconintra.h" |
#include "vp9/common/vp9_reconinter.h" |
#include "vp9/common/vp9_seg_common.h" |
-#include "vp9/common/vp9_systemdependent.h" |
#include "vp9/common/vp9_tile_common.h" |
#include "vp9/encoder/vp9_aq_complexity.h" |
@@ -717,7 +717,8 @@ static int choose_partitioning(VP9_COMP *cpi, |
yv12_g = get_ref_frame_buffer(cpi, GOLDEN_FRAME); |
} |
- if (yv12_g && yv12_g != yv12) { |
+ if (yv12_g && yv12_g != yv12 && |
+ (cpi->ref_frame_flags & VP9_GOLD_FLAG)) { |
vp9_setup_pre_planes(xd, 0, yv12_g, mi_row, mi_col, |
&cm->frame_refs[GOLDEN_FRAME - 1].sf); |
y_sad_g = cpi->fn_ptr[bsize].sdf(x->plane[0].src.buf, |
@@ -978,8 +979,8 @@ static void update_state(VP9_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; |
@@ -1046,7 +1047,7 @@ static void update_state(VP9_COMP *cpi, ThreadData *td, |
x->skip = ctx->skip; |
memcpy(x->zcoeff_blk[mbmi->tx_size], ctx->zcoeff_blk, |
- sizeof(uint8_t) * ctx->num_4x4_blk); |
+ sizeof(ctx->zcoeff_blk[0]) * ctx->num_4x4_blk); |
if (!output_enabled) |
return; |
@@ -1131,8 +1132,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; |
@@ -1152,7 +1153,7 @@ static int set_segment_rdmult(VP9_COMP *const cpi, |
int segment_qindex; |
VP9_COMMON *const cm = &cpi->common; |
vp9_init_plane_quantizers(cpi, x); |
- vp9_clear_system_state(); |
+ vpx_clear_system_state(); |
segment_qindex = vp9_get_qindex(&cm->seg, segment_id, |
cm->base_qindex); |
return vp9_compute_rd_mult(cpi, segment_qindex + cm->y_dc_delta_q); |
@@ -1173,7 +1174,7 @@ static void rd_pick_sb_modes(VP9_COMP *cpi, |
const AQ_MODE aq_mode = cpi->oxcf.aq_mode; |
int i, orig_rdmult; |
- vp9_clear_system_state(); |
+ vpx_clear_system_state(); |
// Use the lower precision, but faster, 32x32 fdct for mode selection. |
x->use_lp32x32fdct = 1; |
@@ -1495,7 +1496,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]; |
@@ -1671,8 +1672,8 @@ static void update_state_rt(VP9_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); |
*(xd->mi[0]) = ctx->mic; |
*(x->mbmi_ext) = ctx->mbmi_ext; |
@@ -1740,7 +1741,7 @@ static void encode_b_rt(VP9_COMP *cpi, ThreadData *td, |
if (cpi->oxcf.noise_sensitivity > 0 && output_enabled && |
cpi->common.frame_type != KEY_FRAME) { |
vp9_denoiser_denoise(&cpi->denoiser, x, mi_row, mi_col, |
- MAX(BLOCK_8X8, bsize), ctx); |
+ VPXMAX(BLOCK_8X8, bsize), ctx); |
} |
#endif |
@@ -2132,8 +2133,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; |
} |
@@ -2210,8 +2211,8 @@ static void rd_auto_partition_range(VP9_COMP *cpi, const TileInfo *const tile, |
if (vp9_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 |
@@ -2247,8 +2248,8 @@ static void set_partition_range(VP9_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); |
} |
} |
} |
@@ -2257,8 +2258,8 @@ static void set_partition_range(VP9_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); |
} |
} |
@@ -2266,8 +2267,8 @@ static void set_partition_range(VP9_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); |
} |
} |
@@ -2432,9 +2433,9 @@ static void rd_pick_partition(VP9_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 |
@@ -2523,9 +2524,9 @@ static void rd_pick_partition(VP9_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; |
@@ -3645,7 +3646,7 @@ static int set_var_thresh_from_histogram(VP9_COMP *cpi) { |
const int last_stride = cpi->Last_Source->y_stride; |
// Pick cutoff threshold |
- const int cutoff = (MIN(cm->width, cm->height) >= 720) ? |
+ const int cutoff = (VPXMIN(cm->width, cm->height) >= 720) ? |
(cm->MBs * VAR_HIST_LARGE_CUT_OFF / 100) : |
(cm->MBs * VAR_HIST_SMALL_CUT_OFF / 100); |
DECLARE_ALIGNED(16, int, hist[VAR_HIST_BINS]); |
@@ -3925,7 +3926,9 @@ static void encode_frame_internal(VP9_COMP *cpi) { |
} |
vp9_zero(x->zcoeff_blk); |
- if (cm->frame_type != KEY_FRAME && cpi->rc.frames_since_golden == 0) |
+ if (cm->frame_type != KEY_FRAME && |
+ cpi->rc.frames_since_golden == 0 && |
+ !cpi->use_svc) |
cpi->ref_frame_flags &= (~VP9_GOLD_FLAG); |
if (sf->partition_search_type == SOURCE_VAR_BASED_PARTITION) |
@@ -3944,7 +3947,7 @@ static void encode_frame_internal(VP9_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) |
vp9_encode_tiles_mt(cpi); |
else |
encode_tiles(cpi); |
@@ -4155,19 +4158,18 @@ static void encode_superblock(VP9_COMP *cpi, ThreadData *td, |
if (x->skip_encode) |
return; |
- set_ref_ptrs(cm, xd, mbmi->ref_frame[0], mbmi->ref_frame[1]); |
- |
if (!is_inter_block(mbmi)) { |
int plane; |
mbmi->skip = 1; |
for (plane = 0; plane < MAX_MB_PLANE; ++plane) |
- vp9_encode_intra_block_plane(x, MAX(bsize, BLOCK_8X8), plane); |
+ vp9_encode_intra_block_plane(x, VPXMAX(bsize, BLOCK_8X8), plane); |
if (output_enabled) |
sum_intra_stats(td->counts, mi); |
- vp9_tokenize_sb(cpi, td, t, !output_enabled, MAX(bsize, BLOCK_8X8)); |
+ vp9_tokenize_sb(cpi, td, t, !output_enabled, VPXMAX(bsize, BLOCK_8X8)); |
} else { |
int ref; |
const int is_compound = has_second_ref(mbmi); |
+ set_ref_ptrs(cm, xd, mbmi->ref_frame[0], mbmi->ref_frame[1]); |
for (ref = 0; ref < 1 + is_compound; ++ref) { |
YV12_BUFFER_CONFIG *cfg = get_ref_frame_buffer(cpi, |
mbmi->ref_frame[ref]); |
@@ -4176,12 +4178,14 @@ static void encode_superblock(VP9_COMP *cpi, ThreadData *td, |
&xd->block_refs[ref]->sf); |
} |
if (!(cpi->sf.reuse_inter_pred_sby && ctx->pred_pixel_ready) || seg_skip) |
- vp9_build_inter_predictors_sby(xd, mi_row, mi_col, MAX(bsize, BLOCK_8X8)); |
+ vp9_build_inter_predictors_sby(xd, mi_row, mi_col, |
+ VPXMAX(bsize, BLOCK_8X8)); |
- vp9_build_inter_predictors_sbuv(xd, mi_row, mi_col, MAX(bsize, BLOCK_8X8)); |
+ vp9_build_inter_predictors_sbuv(xd, mi_row, mi_col, |
+ VPXMAX(bsize, BLOCK_8X8)); |
- vp9_encode_sb(x, MAX(bsize, BLOCK_8X8)); |
- vp9_tokenize_sb(cpi, td, t, !output_enabled, MAX(bsize, BLOCK_8X8)); |
+ vp9_encode_sb(x, VPXMAX(bsize, BLOCK_8X8)); |
+ vp9_tokenize_sb(cpi, td, t, !output_enabled, VPXMAX(bsize, BLOCK_8X8)); |
} |
if (output_enabled) { |
@@ -4195,8 +4199,8 @@ static void encode_superblock(VP9_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; |
} |