| Index: source/libvpx/vp9/encoder/vp9_rdopt.c
|
| ===================================================================
|
| --- source/libvpx/vp9/encoder/vp9_rdopt.c (revision 278778)
|
| +++ source/libvpx/vp9/encoder/vp9_rdopt.c (working copy)
|
| @@ -9,7 +9,6 @@
|
| */
|
|
|
| #include <assert.h>
|
| -#include <limits.h>
|
| #include <math.h>
|
| #include <stdio.h>
|
|
|
| @@ -22,7 +21,6 @@
|
| #include "vp9/common/vp9_entropymode.h"
|
| #include "vp9/common/vp9_idct.h"
|
| #include "vp9/common/vp9_mvref_common.h"
|
| -#include "vp9/common/vp9_pragmas.h"
|
| #include "vp9/common/vp9_pred_common.h"
|
| #include "vp9/common/vp9_quant_common.h"
|
| #include "vp9/common/vp9_reconinter.h"
|
| @@ -242,6 +240,31 @@
|
| cpi->mb.sadperbit4 = sad_per_bit4lut[qindex];
|
| }
|
|
|
| +static void swap_block_ptr(MACROBLOCK *x, PICK_MODE_CONTEXT *ctx,
|
| + int m, int n, int min_plane, int max_plane) {
|
| + int i;
|
| +
|
| + for (i = min_plane; i < max_plane; ++i) {
|
| + struct macroblock_plane *const p = &x->plane[i];
|
| + struct macroblockd_plane *const pd = &x->e_mbd.plane[i];
|
| +
|
| + p->coeff = ctx->coeff_pbuf[i][m];
|
| + p->qcoeff = ctx->qcoeff_pbuf[i][m];
|
| + pd->dqcoeff = ctx->dqcoeff_pbuf[i][m];
|
| + p->eobs = ctx->eobs_pbuf[i][m];
|
| +
|
| + ctx->coeff_pbuf[i][m] = ctx->coeff_pbuf[i][n];
|
| + ctx->qcoeff_pbuf[i][m] = ctx->qcoeff_pbuf[i][n];
|
| + ctx->dqcoeff_pbuf[i][m] = ctx->dqcoeff_pbuf[i][n];
|
| + ctx->eobs_pbuf[i][m] = ctx->eobs_pbuf[i][n];
|
| +
|
| + ctx->coeff_pbuf[i][n] = p->coeff;
|
| + ctx->qcoeff_pbuf[i][n] = p->qcoeff;
|
| + ctx->dqcoeff_pbuf[i][n] = pd->dqcoeff;
|
| + ctx->eobs_pbuf[i][n] = p->eobs;
|
| + }
|
| +}
|
| +
|
| static void set_block_thresholds(const VP9_COMMON *cm, RD_OPT *rd) {
|
| int i, bsize, segment_id;
|
|
|
| @@ -288,8 +311,8 @@
|
| x->errorperbit = rd->RDMULT / RD_MULT_EPB_RATIO;
|
| x->errorperbit += (x->errorperbit == 0);
|
|
|
| - x->select_txfm_size = (cpi->sf.tx_size_search_method == USE_LARGESTALL &&
|
| - cm->frame_type != KEY_FRAME) ? 0 : 1;
|
| + x->select_tx_size = (cpi->sf.tx_size_search_method == USE_LARGESTALL &&
|
| + cm->frame_type != KEY_FRAME) ? 0 : 1;
|
|
|
| set_block_thresholds(cm, rd);
|
|
|
| @@ -297,7 +320,7 @@
|
| fill_token_costs(x->token_costs, cm->fc.coef_probs);
|
|
|
| for (i = 0; i < PARTITION_CONTEXTS; i++)
|
| - vp9_cost_tokens(x->partition_cost[i], get_partition_probs(cm, i),
|
| + vp9_cost_tokens(cpi->partition_cost[i], get_partition_probs(cm, i),
|
| vp9_partition_tree);
|
| }
|
|
|
| @@ -773,11 +796,11 @@
|
| }
|
| }
|
|
|
| -static void choose_largest_txfm_size(VP9_COMP *cpi, MACROBLOCK *x,
|
| - int *rate, int64_t *distortion,
|
| - int *skip, int64_t *sse,
|
| - int64_t ref_best_rd,
|
| - BLOCK_SIZE bs) {
|
| +static void choose_largest_tx_size(VP9_COMP *cpi, MACROBLOCK *x,
|
| + int *rate, int64_t *distortion,
|
| + int *skip, int64_t *sse,
|
| + int64_t ref_best_rd,
|
| + BLOCK_SIZE bs) {
|
| const TX_SIZE max_tx_size = max_txsize_lookup[bs];
|
| VP9_COMMON *const cm = &cpi->common;
|
| const TX_SIZE largest_tx_size = tx_mode_to_biggest_tx_size[cm->tx_mode];
|
| @@ -792,12 +815,12 @@
|
| cpi->tx_stepdown_count[0]++;
|
| }
|
|
|
| -static void choose_txfm_size_from_rd(VP9_COMP *cpi, MACROBLOCK *x,
|
| - int (*r)[2], int *rate,
|
| - int64_t *d, int64_t *distortion,
|
| - int *s, int *skip,
|
| - int64_t tx_cache[TX_MODES],
|
| - BLOCK_SIZE bs) {
|
| +static void choose_tx_size_from_rd(VP9_COMP *cpi, MACROBLOCK *x,
|
| + int (*r)[2], int *rate,
|
| + int64_t *d, int64_t *distortion,
|
| + int *s, int *skip,
|
| + int64_t tx_cache[TX_MODES],
|
| + BLOCK_SIZE bs) {
|
| const TX_SIZE max_tx_size = max_txsize_lookup[bs];
|
| VP9_COMMON *const cm = &cpi->common;
|
| MACROBLOCKD *const xd = &x->e_mbd;
|
| @@ -875,12 +898,12 @@
|
| return (int64_t) (RDCOST(rdmult, rddiv, rate, dist) * scale);
|
| }
|
|
|
| -static void choose_txfm_size_from_modelrd(VP9_COMP *cpi, MACROBLOCK *x,
|
| - int (*r)[2], int *rate,
|
| - int64_t *d, int64_t *distortion,
|
| - int *s, int *skip, int64_t *sse,
|
| - int64_t ref_best_rd,
|
| - BLOCK_SIZE bs) {
|
| +static void choose_tx_size_from_modelrd(VP9_COMP *cpi, MACROBLOCK *x,
|
| + int (*r)[2], int *rate,
|
| + int64_t *d, int64_t *distortion,
|
| + int *s, int *skip, int64_t *sse,
|
| + int64_t ref_best_rd,
|
| + BLOCK_SIZE bs) {
|
| const TX_SIZE max_tx_size = max_txsize_lookup[bs];
|
| VP9_COMMON *const cm = &cpi->common;
|
| MACROBLOCKD *const xd = &x->e_mbd;
|
| @@ -964,28 +987,20 @@
|
|
|
| if (cpi->sf.tx_size_search_method == USE_LARGESTALL || xd->lossless) {
|
| vpx_memset(txfm_cache, 0, TX_MODES * sizeof(int64_t));
|
| - choose_largest_txfm_size(cpi, x, rate, distortion, skip, sse,
|
| - ref_best_rd, bs);
|
| + choose_largest_tx_size(cpi, x, rate, distortion, skip, sse, ref_best_rd,
|
| + bs);
|
| if (psse)
|
| *psse = sse[mbmi->tx_size];
|
| return;
|
| }
|
|
|
| - if (cpi->sf.tx_size_search_method == USE_LARGESTINTRA_MODELINTER) {
|
| - for (tx_size = TX_4X4; tx_size <= max_tx_size; ++tx_size)
|
| - model_rd_for_sb_y_tx(cpi, bs, tx_size, x, xd,
|
| - &r[tx_size][0], &d[tx_size], &s[tx_size]);
|
| - choose_txfm_size_from_modelrd(cpi, x, r, rate, d, distortion, s,
|
| - skip, sse, ref_best_rd, bs);
|
| - } else {
|
| - for (tx_size = TX_4X4; tx_size <= max_tx_size; ++tx_size)
|
| - txfm_rd_in_plane(x, &r[tx_size][0], &d[tx_size],
|
| - &s[tx_size], &sse[tx_size],
|
| - ref_best_rd, 0, bs, tx_size,
|
| - cpi->sf.use_fast_coef_costing);
|
| - choose_txfm_size_from_rd(cpi, x, r, rate, d, distortion, s,
|
| - skip, txfm_cache, bs);
|
| - }
|
| + for (tx_size = TX_4X4; tx_size <= max_tx_size; ++tx_size)
|
| + txfm_rd_in_plane(x, &r[tx_size][0], &d[tx_size], &s[tx_size],
|
| + &sse[tx_size], ref_best_rd, 0, bs, tx_size,
|
| + cpi->sf.use_fast_coef_costing);
|
| + choose_tx_size_from_rd(cpi, x, r, rate, d, distortion, s,
|
| + skip, txfm_cache, bs);
|
| +
|
| if (psse)
|
| *psse = sse[mbmi->tx_size];
|
| }
|
| @@ -1002,8 +1017,8 @@
|
| assert(bs == mbmi->sb_type);
|
| if (cpi->sf.tx_size_search_method != USE_FULL_RD || xd->lossless) {
|
| vpx_memset(txfm_cache, 0, TX_MODES * sizeof(int64_t));
|
| - choose_largest_txfm_size(cpi, x, rate, distortion, skip, sse,
|
| - ref_best_rd, bs);
|
| + choose_largest_tx_size(cpi, x, rate, distortion, skip, sse, ref_best_rd,
|
| + bs);
|
| } else {
|
| int r[TX_SIZES][2], s[TX_SIZES];
|
| int64_t d[TX_SIZES];
|
| @@ -1013,8 +1028,8 @@
|
| &s[tx_size], &sse[tx_size],
|
| ref_best_rd, 0, bs, tx_size,
|
| cpi->sf.use_fast_coef_costing);
|
| - choose_txfm_size_from_rd(cpi, x, r, rate, d, distortion, s,
|
| - skip, txfm_cache, bs);
|
| + choose_tx_size_from_rd(cpi, x, r, rate, d, distortion, s, skip, txfm_cache,
|
| + bs);
|
| }
|
| if (psse)
|
| *psse = sse[mbmi->tx_size];
|
| @@ -1262,9 +1277,6 @@
|
| MODE_INFO *above_mi = xd->mi[-xd->mi_stride];
|
| MODE_INFO *left_mi = xd->left_available ? xd->mi[-1] : NULL;
|
|
|
| - if (!(cpi->sf.intra_y_mode_mask[max_txsize_lookup[bsize]] & (1 << mode)))
|
| - continue;
|
| -
|
| if (cpi->common.frame_type == KEY_FRAME) {
|
| const PREDICTION_MODE A = vp9_above_block_mode(mic, above_mi, 0);
|
| const PREDICTION_MODE L = vp9_left_block_mode(mic, left_mi, 0);
|
| @@ -1315,7 +1327,7 @@
|
| int64_t ref_best_rd) {
|
| MACROBLOCKD *const xd = &x->e_mbd;
|
| MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
|
| - TX_SIZE uv_txfm_size = get_uv_tx_size(mbmi);
|
| + const TX_SIZE uv_tx_size = get_uv_tx_size(mbmi);
|
| int plane;
|
| int pnrate = 0, pnskip = 1;
|
| int64_t pndist = 0, pnsse = 0;
|
| @@ -1336,7 +1348,7 @@
|
|
|
| for (plane = 1; plane < MAX_MB_PLANE; ++plane) {
|
| txfm_rd_in_plane(x, &pnrate, &pndist, &pnskip, &pnsse,
|
| - ref_best_rd, plane, bsize, uv_txfm_size,
|
| + ref_best_rd, plane, bsize, uv_tx_size,
|
| cpi->sf.use_fast_coef_costing);
|
| if (pnrate == INT_MAX)
|
| goto term;
|
| @@ -1388,27 +1400,8 @@
|
| *rate_tokenonly = this_rate_tokenonly;
|
| *distortion = this_distortion;
|
| *skippable = s;
|
| - if (!x->select_txfm_size) {
|
| - int i;
|
| - struct macroblock_plane *const p = x->plane;
|
| - struct macroblockd_plane *const pd = xd->plane;
|
| - for (i = 1; i < MAX_MB_PLANE; ++i) {
|
| - p[i].coeff = ctx->coeff_pbuf[i][2];
|
| - p[i].qcoeff = ctx->qcoeff_pbuf[i][2];
|
| - pd[i].dqcoeff = ctx->dqcoeff_pbuf[i][2];
|
| - p[i].eobs = ctx->eobs_pbuf[i][2];
|
| -
|
| - ctx->coeff_pbuf[i][2] = ctx->coeff_pbuf[i][0];
|
| - ctx->qcoeff_pbuf[i][2] = ctx->qcoeff_pbuf[i][0];
|
| - ctx->dqcoeff_pbuf[i][2] = ctx->dqcoeff_pbuf[i][0];
|
| - ctx->eobs_pbuf[i][2] = ctx->eobs_pbuf[i][0];
|
| -
|
| - ctx->coeff_pbuf[i][0] = p[i].coeff;
|
| - ctx->qcoeff_pbuf[i][0] = p[i].qcoeff;
|
| - ctx->dqcoeff_pbuf[i][0] = pd[i].dqcoeff;
|
| - ctx->eobs_pbuf[i][0] = p[i].eobs;
|
| - }
|
| - }
|
| + if (!x->select_tx_size)
|
| + swap_block_ptr(x, ctx, 2, 0, 1, MAX_MB_PLANE);
|
| }
|
| }
|
|
|
| @@ -1671,9 +1664,9 @@
|
| static int check_best_zero_mv(
|
| const VP9_COMP *cpi, const uint8_t mode_context[MAX_REF_FRAMES],
|
| int_mv frame_mv[MB_MODE_COUNT][MAX_REF_FRAMES],
|
| - int disable_inter_mode_mask, int this_mode,
|
| + int inter_mode_mask, int this_mode,
|
| const MV_REFERENCE_FRAME ref_frames[2]) {
|
| - if (!(disable_inter_mode_mask & (1 << INTER_OFFSET(ZEROMV))) &&
|
| + if ((inter_mode_mask & (1 << ZEROMV)) &&
|
| (this_mode == NEARMV || this_mode == NEARESTMV || this_mode == ZEROMV) &&
|
| frame_mv[this_mode][ref_frames[0]].as_int == 0 &&
|
| (ref_frames[1] == NONE ||
|
| @@ -1739,7 +1732,7 @@
|
| ENTROPY_CONTEXT t_above[2], t_left[2];
|
| int subpelmv = 1, have_ref = 0;
|
| const int has_second_rf = has_second_ref(mbmi);
|
| - const int disable_inter_mode_mask = cpi->sf.disable_inter_mode_mask[bsize];
|
| + const int inter_mode_mask = cpi->sf.inter_mode_mask[bsize];
|
|
|
| vp9_zero(*bsi);
|
|
|
| @@ -1788,11 +1781,11 @@
|
|
|
| mode_idx = INTER_OFFSET(this_mode);
|
| bsi->rdstat[i][mode_idx].brdcost = INT64_MAX;
|
| - if (disable_inter_mode_mask & (1 << mode_idx))
|
| + if (!(inter_mode_mask & (1 << this_mode)))
|
| continue;
|
|
|
| if (!check_best_zero_mv(cpi, mbmi->mode_context, frame_mv,
|
| - disable_inter_mode_mask,
|
| + inter_mode_mask,
|
| this_mode, mbmi->ref_frame))
|
| continue;
|
|
|
| @@ -1830,7 +1823,7 @@
|
| else
|
| max_mv = MAX(abs(bsi->mvp.as_mv.row), abs(bsi->mvp.as_mv.col)) >> 3;
|
|
|
| - if (cpi->sf.auto_mv_step_size && cm->show_frame) {
|
| + if (cpi->sf.mv.auto_mv_step_size && cm->show_frame) {
|
| // Take wtd average of the step_params based on the last frame's
|
| // max mv magnitude and the best ref mvs of the current block for
|
| // the given reference.
|
| @@ -1844,8 +1837,8 @@
|
| mvp_full.col = bsi->mvp.as_mv.col >> 3;
|
|
|
| if (cpi->sf.adaptive_motion_search && cm->show_frame) {
|
| - mvp_full.row = x->pred_mv[mbmi->ref_frame[0]].as_mv.row >> 3;
|
| - mvp_full.col = x->pred_mv[mbmi->ref_frame[0]].as_mv.col >> 3;
|
| + mvp_full.row = x->pred_mv[mbmi->ref_frame[0]].row >> 3;
|
| + mvp_full.col = x->pred_mv[mbmi->ref_frame[0]].col >> 3;
|
| step_param = MAX(step_param, 8);
|
| }
|
|
|
| @@ -1854,9 +1847,9 @@
|
|
|
| vp9_set_mv_search_range(x, &bsi->ref_mv[0]->as_mv);
|
|
|
| - bestsme = full_pixel_search(cpi, x, bsize, &mvp_full, step_param,
|
| - sadpb, &bsi->ref_mv[0]->as_mv, new_mv,
|
| - INT_MAX, 1);
|
| + bestsme = vp9_full_pixel_search(cpi, x, bsize, &mvp_full, step_param,
|
| + sadpb, &bsi->ref_mv[0]->as_mv, new_mv,
|
| + INT_MAX, 1);
|
|
|
| // Should we do a full search (best quality only)
|
| if (is_best_mode(cpi->oxcf.mode)) {
|
| @@ -1885,8 +1878,8 @@
|
| &bsi->ref_mv[0]->as_mv,
|
| cm->allow_high_precision_mv,
|
| x->errorperbit, &cpi->fn_ptr[bsize],
|
| - cpi->sf.subpel_force_stop,
|
| - cpi->sf.subpel_iters_per_step,
|
| + cpi->sf.mv.subpel_force_stop,
|
| + cpi->sf.mv.subpel_iters_per_step,
|
| x->nmvjointcost, x->mvcost,
|
| &distortion,
|
| &x->pred_sse[mbmi->ref_frame[0]]);
|
| @@ -1896,7 +1889,7 @@
|
| }
|
|
|
| if (cpi->sf.adaptive_motion_search)
|
| - x->pred_mv[mbmi->ref_frame[0]].as_mv = *new_mv;
|
| + x->pred_mv[mbmi->ref_frame[0]] = *new_mv;
|
|
|
| // restore src pointers
|
| mi_buf_restore(x, orig_src, orig_pre);
|
| @@ -2102,14 +2095,14 @@
|
| cpi->common.show_frame &&
|
| block_size < cpi->sf.max_partition_size);
|
|
|
| - int_mv pred_mv[3];
|
| - pred_mv[0] = mbmi->ref_mvs[ref_frame][0];
|
| - pred_mv[1] = mbmi->ref_mvs[ref_frame][1];
|
| + MV pred_mv[3];
|
| + pred_mv[0] = mbmi->ref_mvs[ref_frame][0].as_mv;
|
| + pred_mv[1] = mbmi->ref_mvs[ref_frame][1].as_mv;
|
| pred_mv[2] = x->pred_mv[ref_frame];
|
|
|
| // Get the sad for each candidate reference mv
|
| for (i = 0; i < num_mv_refs; i++) {
|
| - this_mv.as_int = pred_mv[i].as_int;
|
| + this_mv.as_mv = pred_mv[i];
|
|
|
| max_mv = MAX(max_mv,
|
| MAX(abs(this_mv.as_mv.row), abs(this_mv.as_mv.col)) >> 3);
|
| @@ -2125,8 +2118,7 @@
|
|
|
| // Find sad for current vector.
|
| this_sad = cpi->fn_ptr[block_size].sdf(src_y_ptr, x->plane[0].src.stride,
|
| - ref_y_ptr, ref_y_stride,
|
| - 0x7fffffff);
|
| + ref_y_ptr, ref_y_stride);
|
|
|
| // Note if it is the best so far.
|
| if (this_sad < best_sad) {
|
| @@ -2204,8 +2196,6 @@
|
|
|
| static void store_coding_context(MACROBLOCK *x, PICK_MODE_CONTEXT *ctx,
|
| int mode_index,
|
| - int_mv *ref_mv,
|
| - int_mv *second_ref_mv,
|
| int64_t comp_pred_diff[REFERENCE_MODES],
|
| const int64_t tx_size_diff[TX_MODES],
|
| int64_t best_filter_diff[SWITCHABLE_FILTER_CONTEXTS]) {
|
| @@ -2216,10 +2206,6 @@
|
| ctx->skip = x->skip;
|
| ctx->best_mode_index = mode_index;
|
| ctx->mic = *xd->mi[0];
|
| -
|
| - ctx->best_ref_mv[0].as_int = ref_mv->as_int;
|
| - ctx->best_ref_mv[1].as_int = second_ref_mv->as_int;
|
| -
|
| ctx->single_pred_diff = (int)comp_pred_diff[SINGLE_REFERENCE];
|
| ctx->comp_pred_diff = (int)comp_pred_diff[COMPOUND_REFERENCE];
|
| ctx->hybrid_pred_diff = (int)comp_pred_diff[REFERENCE_MODE_SELECT];
|
| @@ -2332,7 +2318,7 @@
|
| MV pred_mv[3];
|
| pred_mv[0] = mbmi->ref_mvs[ref][0].as_mv;
|
| pred_mv[1] = mbmi->ref_mvs[ref][1].as_mv;
|
| - pred_mv[2] = x->pred_mv[ref].as_mv;
|
| + pred_mv[2] = x->pred_mv[ref];
|
|
|
| if (scaled_ref_frame) {
|
| int i;
|
| @@ -2349,7 +2335,7 @@
|
|
|
| // Work out the size of the first step in the mv step search.
|
| // 0 here is maximum length first step. 1 is MAX >> 1 etc.
|
| - if (cpi->sf.auto_mv_step_size && cm->show_frame) {
|
| + if (cpi->sf.mv.auto_mv_step_size && cm->show_frame) {
|
| // Take wtd average of the step_params based on the last frame's
|
| // max mv magnitude and that based on the best ref mvs of the current
|
| // block for the given reference.
|
| @@ -2377,7 +2363,8 @@
|
|
|
| for (i = LAST_FRAME; i <= ALTREF_FRAME && cm->show_frame; ++i) {
|
| if ((x->pred_mv_sad[ref] >> 3) > x->pred_mv_sad[i]) {
|
| - x->pred_mv[ref].as_int = 0;
|
| + x->pred_mv[ref].row = 0;
|
| + x->pred_mv[ref].col = 0;
|
| tmp_mv->as_int = INVALID_MV;
|
|
|
| if (scaled_ref_frame) {
|
| @@ -2395,8 +2382,8 @@
|
| mvp_full.col >>= 3;
|
| mvp_full.row >>= 3;
|
|
|
| - bestsme = full_pixel_search(cpi, x, bsize, &mvp_full, step_param, sadpb,
|
| - &ref_mv, &tmp_mv->as_mv, INT_MAX, 1);
|
| + bestsme = vp9_full_pixel_search(cpi, x, bsize, &mvp_full, step_param, sadpb,
|
| + &ref_mv, &tmp_mv->as_mv, INT_MAX, 1);
|
|
|
| x->mv_col_min = tmp_col_min;
|
| x->mv_col_max = tmp_col_max;
|
| @@ -2409,8 +2396,8 @@
|
| cm->allow_high_precision_mv,
|
| x->errorperbit,
|
| &cpi->fn_ptr[bsize],
|
| - cpi->sf.subpel_force_stop,
|
| - cpi->sf.subpel_iters_per_step,
|
| + cpi->sf.mv.subpel_force_stop,
|
| + cpi->sf.mv.subpel_iters_per_step,
|
| x->nmvjointcost, x->mvcost,
|
| &dis, &x->pred_sse[ref]);
|
| }
|
| @@ -2418,7 +2405,7 @@
|
| x->nmvjointcost, x->mvcost, MV_COST_WEIGHT);
|
|
|
| if (cpi->sf.adaptive_motion_search && cm->show_frame)
|
| - x->pred_mv[ref].as_int = tmp_mv->as_int;
|
| + x->pred_mv[ref] = tmp_mv->as_mv;
|
|
|
| if (scaled_ref_frame) {
|
| int i;
|
| @@ -2534,7 +2521,7 @@
|
| cpi->common.allow_high_precision_mv,
|
| x->errorperbit,
|
| &cpi->fn_ptr[bsize],
|
| - 0, cpi->sf.subpel_iters_per_step,
|
| + 0, cpi->sf.mv.subpel_iters_per_step,
|
| x->nmvjointcost, x->mvcost,
|
| &dis, &sse, second_pred,
|
| pw, ph);
|
| @@ -2812,7 +2799,8 @@
|
| *rate2 += vp9_get_switchable_rate(cpi);
|
|
|
| if (!is_comp_pred) {
|
| - if (!x->in_active_map) {
|
| + if (!x->in_active_map ||
|
| + vp9_segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
|
| if (psse)
|
| *psse = 0;
|
| *distortion = 0;
|
| @@ -2931,30 +2919,6 @@
|
| return this_rd; // if 0, this will be re-calculated by caller
|
| }
|
|
|
| -static void swap_block_ptr(MACROBLOCK *x, PICK_MODE_CONTEXT *ctx,
|
| - int max_plane) {
|
| - struct macroblock_plane *const p = x->plane;
|
| - struct macroblockd_plane *const pd = x->e_mbd.plane;
|
| - int i;
|
| -
|
| - for (i = 0; i < max_plane; ++i) {
|
| - p[i].coeff = ctx->coeff_pbuf[i][1];
|
| - p[i].qcoeff = ctx->qcoeff_pbuf[i][1];
|
| - pd[i].dqcoeff = ctx->dqcoeff_pbuf[i][1];
|
| - p[i].eobs = ctx->eobs_pbuf[i][1];
|
| -
|
| - ctx->coeff_pbuf[i][1] = ctx->coeff_pbuf[i][0];
|
| - ctx->qcoeff_pbuf[i][1] = ctx->qcoeff_pbuf[i][0];
|
| - ctx->dqcoeff_pbuf[i][1] = ctx->dqcoeff_pbuf[i][0];
|
| - ctx->eobs_pbuf[i][1] = ctx->eobs_pbuf[i][0];
|
| -
|
| - ctx->coeff_pbuf[i][0] = p[i].coeff;
|
| - ctx->qcoeff_pbuf[i][0] = p[i].qcoeff;
|
| - ctx->dqcoeff_pbuf[i][0] = pd[i].dqcoeff;
|
| - ctx->eobs_pbuf[i][0] = p[i].eobs;
|
| - }
|
| -}
|
| -
|
| void vp9_rd_pick_intra_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
|
| int *returnrate, int64_t *returndist,
|
| BLOCK_SIZE bsize,
|
| @@ -3012,11 +2976,6 @@
|
| ctx->mic = *xd->mi[0];
|
| }
|
|
|
| -static INLINE int rd_less_than_thresh(int64_t best_rd, int thresh,
|
| - int thresh_fact) {
|
| - return best_rd < ((int64_t)thresh * thresh_fact >> 5) || thresh == INT_MAX;
|
| -}
|
| -
|
| // Updating rd_thresh_freq_fact[] here means that the different
|
| // partition/block sizes are handled independently based on the best
|
| // choice for the current partition. It may well be better to keep a scaled
|
| @@ -3094,7 +3053,7 @@
|
| const int mode_search_skip_flags = cpi->sf.mode_search_skip_flags;
|
| const int intra_y_mode_mask =
|
| cpi->sf.intra_y_mode_mask[max_txsize_lookup[bsize]];
|
| - int disable_inter_mode_mask = cpi->sf.disable_inter_mode_mask[bsize];
|
| + int inter_mode_mask = cpi->sf.inter_mode_mask[bsize];
|
| vp9_zero(best_mbmode);
|
| x->skip_encode = cpi->sf.skip_encode_frame && x->q_index < QIDX_SKIP_THRESH;
|
|
|
| @@ -3158,8 +3117,8 @@
|
| // If the segment skip feature is enabled....
|
| // then do nothing if the current mode is not allowed..
|
| if (vp9_segfeature_active(seg, segment_id, SEG_LVL_SKIP)) {
|
| - const int inter_non_zero_mode_mask = 0x1F7F7;
|
| - mode_skip_mask |= inter_non_zero_mode_mask;
|
| + mode_skip_mask = ~(1 << THR_ZEROMV);
|
| + inter_mode_mask = (1 << ZEROMV);
|
| }
|
|
|
| // Disable this drop out case if the ref frame
|
| @@ -3193,7 +3152,11 @@
|
| }
|
|
|
| if (bsize > cpi->sf.max_intra_bsize) {
|
| - mode_skip_mask |= 0xFF30808;
|
| + const int all_intra_modes = (1 << THR_DC) | (1 << THR_TM) |
|
| + (1 << THR_H_PRED) | (1 << THR_V_PRED) | (1 << THR_D135_PRED) |
|
| + (1 << THR_D207_PRED) | (1 << THR_D153_PRED) | (1 << THR_D63_PRED) |
|
| + (1 << THR_D117_PRED) | (1 << THR_D45_PRED);
|
| + mode_skip_mask |= all_intra_modes;
|
| }
|
|
|
| if (!x->in_active_map) {
|
| @@ -3207,7 +3170,8 @@
|
| mode_index = THR_ZEROMV;
|
| mode_skip_mask = ~(1 << mode_index);
|
| mode_skip_start = MAX_MODES;
|
| - disable_inter_mode_mask = 0;
|
| + inter_mode_mask = (1 << NEARESTMV) | (1 << NEARMV) | (1 << ZEROMV) |
|
| + (1 << NEWMV);
|
| }
|
|
|
| for (mode_index = 0; mode_index < MAX_MODES; ++mode_index) {
|
| @@ -3249,13 +3213,12 @@
|
|
|
| // Test best rd so far against threshold for trying this mode.
|
| if (rd_less_than_thresh(best_rd, rd_threshes[mode_index],
|
| - rd_thresh_freq_fact[mode_index]))
|
| + rd_thresh_freq_fact[mode_index]))
|
| continue;
|
|
|
| this_mode = vp9_mode_order[mode_index].mode;
|
| ref_frame = vp9_mode_order[mode_index].ref_frame[0];
|
| - if (ref_frame != INTRA_FRAME &&
|
| - disable_inter_mode_mask & (1 << INTER_OFFSET(this_mode)))
|
| + if (ref_frame != INTRA_FRAME && !(inter_mode_mask & (1 << this_mode)))
|
| continue;
|
| second_ref_frame = vp9_mode_order[mode_index].ref_frame[1];
|
|
|
| @@ -3304,7 +3267,7 @@
|
| !vp9_segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
|
| const MV_REFERENCE_FRAME ref_frames[2] = {ref_frame, second_ref_frame};
|
| if (!check_best_zero_mv(cpi, mbmi->mode_context, frame_mv,
|
| - disable_inter_mode_mask, this_mode, ref_frames))
|
| + inter_mode_mask, this_mode, ref_frames))
|
| continue;
|
| }
|
| }
|
| @@ -3475,8 +3438,8 @@
|
| best_rd = this_rd;
|
| best_mbmode = *mbmi;
|
| best_skip2 = this_skip2;
|
| - if (!x->select_txfm_size)
|
| - swap_block_ptr(x, ctx, max_plane);
|
| + if (!x->select_tx_size)
|
| + swap_block_ptr(x, ctx, 1, 0, 0, max_plane);
|
| vpx_memcpy(ctx->zcoeff_blk, x->zcoeff_blk[mbmi->tx_size],
|
| sizeof(uint8_t) * ctx->num_4x4_blk);
|
|
|
| @@ -3642,9 +3605,6 @@
|
|
|
| set_ref_ptrs(cm, xd, mbmi->ref_frame[0], mbmi->ref_frame[1]);
|
| store_coding_context(x, ctx, best_mode_index,
|
| - &mbmi->ref_mvs[mbmi->ref_frame[0]][0],
|
| - &mbmi->ref_mvs[mbmi->ref_frame[1] < 0 ? 0 :
|
| - mbmi->ref_frame[1]][0],
|
| best_pred_diff, best_tx_diff, best_filter_diff);
|
|
|
| return best_rd;
|
| @@ -3693,7 +3653,6 @@
|
| int_mv seg_mvs[4][MAX_REF_FRAMES];
|
| b_mode_info best_bmodes[4];
|
| int best_skip2 = 0;
|
| - int ref_frame_mask = 0;
|
| int mode_skip_mask = 0;
|
|
|
| x->skip_encode = cpi->sf.skip_encode_frame && x->q_index < QIDX_SKIP_THRESH;
|
| @@ -3728,17 +3687,6 @@
|
| frame_mv[ZEROMV][ref_frame].as_int = 0;
|
| }
|
|
|
| - for (ref_frame = LAST_FRAME;
|
| - ref_frame <= ALTREF_FRAME && cpi->sf.reference_masking; ++ref_frame) {
|
| - int i;
|
| - for (i = LAST_FRAME; i <= ALTREF_FRAME; ++i) {
|
| - if ((x->pred_mv_sad[ref_frame] >> 1) > x->pred_mv_sad[i]) {
|
| - ref_frame_mask |= (1 << ref_frame);
|
| - break;
|
| - }
|
| - }
|
| - }
|
| -
|
| for (ref_index = 0; ref_index < MAX_REFS; ++ref_index) {
|
| int mode_excluded = 0;
|
| int64_t this_rd = INT64_MAX;
|
| @@ -3833,11 +3781,6 @@
|
| vp9_get_segdata(seg, segment_id, SEG_LVL_REF_FRAME) !=
|
| (int)ref_frame) {
|
| continue;
|
| - // If the segment skip feature is enabled....
|
| - // then do nothing if the current mode is not allowed..
|
| - } else if (vp9_segfeature_active(seg, segment_id, SEG_LVL_SKIP) &&
|
| - ref_frame != INTRA_FRAME) {
|
| - continue;
|
| // Disable this drop out case if the ref frame
|
| // segment level feature is enabled for this segment. This is to
|
| // prevent the possibility that we end up unable to pick any mode.
|
| @@ -4062,15 +4005,10 @@
|
| }
|
|
|
| if (!disable_skip) {
|
| - // Test for the condition where skip block will be activated
|
| - // because there are no non zero coefficients and make any
|
| - // necessary adjustment for rate. Ignore if skip is coded at
|
| - // segment level as the cost wont have been added in.
|
| - // Is Mb level skip allowed (i.e. not coded at segment level).
|
| - const int mb_skip_allowed = !vp9_segfeature_active(seg, segment_id,
|
| - SEG_LVL_SKIP);
|
| + // Skip is never coded at the segment level for sub8x8 blocks and instead
|
| + // always coded in the bitstream at the mode info level.
|
|
|
| - if (mb_skip_allowed && ref_frame != INTRA_FRAME && !xd->lossless) {
|
| + if (ref_frame != INTRA_FRAME && !xd->lossless) {
|
| if (RDCOST(x->rdmult, x->rddiv, rate_y + rate_uv, distortion2) <
|
| RDCOST(x->rdmult, x->rddiv, 0, total_sse)) {
|
| // Add in the cost of the no skip flag.
|
| @@ -4085,7 +4023,7 @@
|
| rate_uv = 0;
|
| this_skip2 = 1;
|
| }
|
| - } else if (mb_skip_allowed) {
|
| + } else {
|
| // Add in the cost of the no skip flag.
|
| rate2 += vp9_cost_bit(vp9_get_skip_prob(cm, xd), 0);
|
| }
|
| @@ -4130,8 +4068,8 @@
|
| RDCOST(x->rdmult, x->rddiv, rate_uv, distortion_uv);
|
| best_mbmode = *mbmi;
|
| best_skip2 = this_skip2;
|
| - if (!x->select_txfm_size)
|
| - swap_block_ptr(x, ctx, max_plane);
|
| + if (!x->select_tx_size)
|
| + swap_block_ptr(x, ctx, 1, 0, 0, max_plane);
|
| vpx_memcpy(ctx->zcoeff_blk, x->zcoeff_blk[TX_4X4],
|
| sizeof(uint8_t) * ctx->num_4x4_blk);
|
|
|
| @@ -4275,9 +4213,6 @@
|
|
|
| set_ref_ptrs(cm, xd, mbmi->ref_frame[0], mbmi->ref_frame[1]);
|
| store_coding_context(x, ctx, best_ref_index,
|
| - &mbmi->ref_mvs[mbmi->ref_frame[0]][0],
|
| - &mbmi->ref_mvs[mbmi->ref_frame[1] < 0 ? 0 :
|
| - mbmi->ref_frame[1]][0],
|
| best_pred_diff, best_tx_diff, best_filter_diff);
|
|
|
| return best_rd;
|
|
|