diff options
Diffstat (limited to 'vp9/encoder')
-rw-r--r-- | vp9/encoder/vp9_bitstream.c | 14 | ||||
-rw-r--r-- | vp9/encoder/vp9_encodeframe.c | 53 | ||||
-rw-r--r-- | vp9/encoder/vp9_encodemb.c | 16 | ||||
-rw-r--r-- | vp9/encoder/vp9_encodemb.h | 2 | ||||
-rw-r--r-- | vp9/encoder/vp9_firstpass.c | 27 | ||||
-rw-r--r-- | vp9/encoder/vp9_mbgraph.c | 24 | ||||
-rw-r--r-- | vp9/encoder/vp9_mcomp.c | 9 | ||||
-rw-r--r-- | vp9/encoder/vp9_onyx_if.c | 8 | ||||
-rw-r--r-- | vp9/encoder/vp9_pickmode.c | 8 | ||||
-rw-r--r-- | vp9/encoder/vp9_ratectrl.c | 1 | ||||
-rw-r--r-- | vp9/encoder/vp9_rdopt.c | 51 | ||||
-rw-r--r-- | vp9/encoder/vp9_temporal_filter.c | 8 | ||||
-rw-r--r-- | vp9/encoder/vp9_tokenize.c | 2 | ||||
-rw-r--r-- | vp9/encoder/vp9_vaq.c | 44 |
14 files changed, 126 insertions, 141 deletions
diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c index c8f334f4b..01ee92fab 100644 --- a/vp9/encoder/vp9_bitstream.c +++ b/vp9/encoder/vp9_bitstream.c @@ -104,13 +104,13 @@ static void write_selected_tx_size(const VP9_COMP *cpi, MODE_INFO *m, } } -static int write_skip_coeff(const VP9_COMP *cpi, int segment_id, MODE_INFO *m, - vp9_writer *w) { +static int write_skip(const VP9_COMP *cpi, int segment_id, MODE_INFO *m, + vp9_writer *w) { const MACROBLOCKD *const xd = &cpi->mb.e_mbd; if (vp9_segfeature_active(&cpi->common.seg, segment_id, SEG_LVL_SKIP)) { return 1; } else { - const int skip = m->mbmi.skip_coeff; + const int skip = m->mbmi.skip; vp9_write(w, skip, vp9_get_skip_prob(&cpi->common, xd)); return skip; } @@ -253,7 +253,7 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc) { const MV_REFERENCE_FRAME sec_rf = mi->ref_frame[1]; const MB_PREDICTION_MODE mode = mi->mode; const int segment_id = mi->segment_id; - int skip_coeff; + int skip; const BLOCK_SIZE bsize = mi->sb_type; const int allow_hp = cm->allow_high_precision_mv; @@ -273,14 +273,14 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc) { } } - skip_coeff = write_skip_coeff(cpi, segment_id, m, bc); + skip = write_skip(cpi, segment_id, m, bc); if (!vp9_segfeature_active(seg, segment_id, SEG_LVL_REF_FRAME)) vp9_write(bc, rf != INTRA_FRAME, vp9_get_intra_inter_prob(cm, xd)); if (bsize >= BLOCK_8X8 && cm->tx_mode == TX_MODE_SELECT && !(rf != INTRA_FRAME && - (skip_coeff || vp9_segfeature_active(seg, segment_id, SEG_LVL_SKIP)))) { + (skip || vp9_segfeature_active(seg, segment_id, SEG_LVL_SKIP)))) { write_selected_tx_size(cpi, m, mi->tx_size, bsize, bc); } @@ -382,7 +382,7 @@ static void write_mb_modes_kf(const VP9_COMP *cpi, MODE_INFO **mi_8x8, if (seg->update_map) write_segment_id(bc, seg, m->mbmi.segment_id); - write_skip_coeff(cpi, segment_id, m, bc); + write_skip(cpi, segment_id, m, bc); if (m->mbmi.sb_type >= BLOCK_8X8 && cm->tx_mode == TX_MODE_SELECT) write_selected_tx_size(cpi, m, m->mbmi.tx_size, m->mbmi.sb_type, bc); diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c index 879436aa7..2ae375fad 100644 --- a/vp9/encoder/vp9_encodeframe.c +++ b/vp9/encoder/vp9_encodeframe.c @@ -345,7 +345,6 @@ static void select_in_frame_q_segment(VP9_COMP *cpi, int mi_row, int mi_col, int output_enabled, int projected_rate) { VP9_COMMON *const cm = &cpi->common; - int target_rate = cpi->rc.sb64_target_rate << 8; // convert to bits << 8 const int mi_offset = mi_row * cm->mi_cols + mi_col; const int bw = num_8x8_blocks_wide_lookup[BLOCK_64X64]; @@ -362,11 +361,10 @@ static void select_in_frame_q_segment(VP9_COMP *cpi, } else { // Rate depends on fraction of a SB64 in frame (xmis * ymis / bw * bh). // It is converted to bits * 256 units - target_rate = (cpi->rc.sb64_target_rate * xmis * ymis * 256) / (bw * bh); + const int target_rate = (cpi->rc.sb64_target_rate * xmis * ymis * 256) / + (bw * bh); if (projected_rate < (target_rate / 4)) { - segment = 2; - } else if (projected_rate < (target_rate / 2)) { segment = 1; } else { segment = 0; @@ -660,14 +658,25 @@ static void rd_pick_sb_modes(VP9_COMP *cpi, const TileInfo *const tile, x->skip_recode = 0; // Set to zero to make sure we do not use the previous encoded frame stats - xd->mi_8x8[0]->mbmi.skip_coeff = 0; + xd->mi_8x8[0]->mbmi.skip = 0; x->source_variance = get_sby_perpixel_variance(cpi, x, bsize); if (cpi->oxcf.aq_mode == VARIANCE_AQ) { const int energy = bsize <= BLOCK_16X16 ? x->mb_energy : vp9_block_energy(cpi, x, bsize); - xd->mi_8x8[0]->mbmi.segment_id = vp9_vaq_segment_id(energy); + + if (cm->frame_type == KEY_FRAME || + cpi->refresh_alt_ref_frame || + (cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref)) { + xd->mi_8x8[0]->mbmi.segment_id = vp9_vaq_segment_id(energy); + } else { + const uint8_t *const map = cm->seg.update_map ? cpi->segmentation_map + : cm->last_frame_seg_map; + xd->mi_8x8[0]->mbmi.segment_id = + vp9_get_segment_id(cm, map, bsize, mi_row, mi_col); + } + rdmult_ratio = vp9_vaq_rdmult_ratio(energy); vp9_mb_init_quantizer(cpi, x); } @@ -681,11 +690,12 @@ static void rd_pick_sb_modes(VP9_COMP *cpi, const TileInfo *const tile, } else if (cpi->oxcf.aq_mode == COMPLEXITY_AQ) { const int mi_offset = mi_row * cm->mi_cols + mi_col; unsigned char complexity = cpi->complexity_map[mi_offset]; - const int is_edge = (mi_row == 0) || (mi_row == (cm->mi_rows - 1)) || - (mi_col == 0) || (mi_col == (cm->mi_cols - 1)); + const int is_edge = (mi_row <= 1) || (mi_row >= (cm->mi_rows - 2)) || + (mi_col <= 1) || (mi_col >= (cm->mi_cols - 2)); - if (!is_edge && (complexity > 128)) + if (!is_edge && (complexity > 128)) { x->rdmult = x->rdmult + ((x->rdmult * (complexity - 128)) / 256); + } } // Find best coding mode & reconstruct the MB so it is available @@ -709,6 +719,9 @@ static void rd_pick_sb_modes(VP9_COMP *cpi, const TileInfo *const tile, *totalrate = round(*totalrate * rdmult_ratio); } } + else if (cpi->oxcf.aq_mode == COMPLEXITY_AQ) { + x->rdmult = orig_rdmult; + } } static void update_stats(VP9_COMP *cpi) { @@ -1029,6 +1042,7 @@ static int sb_has_motion(const VP9_COMMON *cm, MODE_INFO **prev_mi_8x8) { } return 0; } + static void update_state_rt(VP9_COMP *cpi, PICK_MODE_CONTEXT *ctx, BLOCK_SIZE bsize, int output_enabled) { int i; @@ -1897,7 +1911,11 @@ static void rd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile, restore_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize); } - + // TODO(jbb): This code added so that we avoid static analysis + // warning related to the fact that best_rd isn't used after this + // point. This code should be refactored so that the duplicate + // checks occur in some sub function and thus are used... + (void) best_rd; *rate = best_rate; *dist = best_dist; @@ -2083,7 +2101,7 @@ static int get_skip_flag(MODE_INFO **mi_8x8, int mis, int ymbs, int xmbs) { for (y = 0; y < ymbs; y++) { for (x = 0; x < xmbs; x++) { - if (!mi_8x8[y * mis + x]->mbmi.skip_coeff) + if (!mi_8x8[y * mis + x]->mbmi.skip) return 0; } } @@ -2242,7 +2260,7 @@ static void set_mode_info(MB_MODE_INFO *mbmi, BLOCK_SIZE bsize, mbmi->ref_frame[1] = INTRA_FRAME; mbmi->tx_size = max_txsize_lookup[bsize]; mbmi->uv_mode = mode; - mbmi->skip_coeff = 0; + mbmi->skip = 0; mbmi->sb_type = bsize; mbmi->segment_id = 0; } @@ -2341,9 +2359,8 @@ static void encode_rtc_sb_row(VP9_COMP *cpi, const TileInfo *const tile, const int idx_str = cm->mode_info_stride * mi_row + mi_col; MODE_INFO **mi_8x8 = cm->mi_grid_visible + idx_str; - cpi->mb.source_variance = UINT_MAX; - set_offsets(cpi, tile, mi_row, mi_col, BLOCK_64X64); + set_partitioning(cpi, tile, mi_8x8, mi_row, mi_col); rtc_use_partition(cpi, tile, mi_8x8, tp, mi_row, mi_col, BLOCK_64X64, &dummy_rate, &dummy_dist, 1); @@ -2719,7 +2736,7 @@ static void encode_superblock(VP9_COMP *cpi, TOKENEXTRA **t, int output_enabled, if (!is_inter_block(mbmi)) { int plane; - mbmi->skip_coeff = 1; + mbmi->skip = 1; for (plane = 0; plane < MAX_MB_PLANE; ++plane) vp9_encode_intra_block_plane(x, MAX(bsize, BLOCK_8X8), plane); if (output_enabled) @@ -2738,11 +2755,11 @@ static void encode_superblock(VP9_COMP *cpi, TOKENEXTRA **t, int output_enabled, if (!is_inter_block(mbmi)) { vp9_tokenize_sb(cpi, t, !output_enabled, MAX(bsize, BLOCK_8X8)); } else if (!x->skip) { - mbmi->skip_coeff = 1; + mbmi->skip = 1; vp9_encode_sb(x, MAX(bsize, BLOCK_8X8)); vp9_tokenize_sb(cpi, t, !output_enabled, MAX(bsize, BLOCK_8X8)); } else { - mbmi->skip_coeff = 1; + mbmi->skip = 1; if (output_enabled) cm->counts.skip[vp9_get_skip_context(xd)][1]++; reset_skip_context(xd, MAX(bsize, BLOCK_8X8)); @@ -2752,7 +2769,7 @@ static void encode_superblock(VP9_COMP *cpi, TOKENEXTRA **t, int output_enabled, if (cm->tx_mode == TX_MODE_SELECT && mbmi->sb_type >= BLOCK_8X8 && !(is_inter_block(mbmi) && - (mbmi->skip_coeff || + (mbmi->skip || vp9_segfeature_active(&cm->seg, segment_id, SEG_LVL_SKIP)))) { ++get_tx_counts(max_txsize_lookup[bsize], vp9_get_tx_size_context(xd), &cm->counts.tx)[mbmi->tx_size]; diff --git a/vp9/encoder/vp9_encodemb.c b/vp9/encoder/vp9_encodemb.c index ad28f318a..8770107d2 100644 --- a/vp9/encoder/vp9_encodemb.c +++ b/vp9/encoder/vp9_encodemb.c @@ -32,7 +32,7 @@ struct optimize_ctx { struct encode_b_args { MACROBLOCK *x; struct optimize_ctx *ctx; - unsigned char *skip_coeff; + unsigned char *skip; }; void vp9_subtract_block_c(int rows, int cols, @@ -439,7 +439,7 @@ static void encode_block(int plane, int block, BLOCK_SIZE plane_bsize, } if (p->eobs[block]) - *(args->skip_coeff) = 0; + *(args->skip) = 0; if (x->skip_encode || p->eobs[block] == 0) return; @@ -489,7 +489,7 @@ void vp9_encode_sby(MACROBLOCK *x, BLOCK_SIZE bsize) { MACROBLOCKD *const xd = &x->e_mbd; struct optimize_ctx ctx; MB_MODE_INFO *mbmi = &xd->mi_8x8[0]->mbmi; - struct encode_b_args arg = {x, &ctx, &mbmi->skip_coeff}; + struct encode_b_args arg = {x, &ctx, &mbmi->skip}; vp9_subtract_sby(x, bsize); if (x->optimize) @@ -503,7 +503,7 @@ void vp9_encode_sb(MACROBLOCK *x, BLOCK_SIZE bsize) { MACROBLOCKD *const xd = &x->e_mbd; struct optimize_ctx ctx; MB_MODE_INFO *mbmi = &xd->mi_8x8[0]->mbmi; - struct encode_b_args arg = {x, &ctx, &mbmi->skip_coeff}; + struct encode_b_args arg = {x, &ctx, &mbmi->skip}; if (!x->skip_recode) vp9_subtract_sb(x, bsize); @@ -648,20 +648,20 @@ static void encode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize, assert(0); } if (*eob) - *(args->skip_coeff) = 0; + *(args->skip) = 0; } void vp9_encode_block_intra(MACROBLOCK *x, int plane, int block, BLOCK_SIZE plane_bsize, TX_SIZE tx_size, - unsigned char *skip_coeff) { - struct encode_b_args arg = {x, NULL, skip_coeff}; + unsigned char *skip) { + struct encode_b_args arg = {x, NULL, skip}; encode_block_intra(plane, block, plane_bsize, tx_size, &arg); } void vp9_encode_intra_block_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane) { const MACROBLOCKD *const xd = &x->e_mbd; - struct encode_b_args arg = {x, NULL, &xd->mi_8x8[0]->mbmi.skip_coeff}; + struct encode_b_args arg = {x, NULL, &xd->mi_8x8[0]->mbmi.skip}; vp9_foreach_transformed_block_in_plane(xd, bsize, plane, encode_block_intra, &arg); diff --git a/vp9/encoder/vp9_encodemb.h b/vp9/encoder/vp9_encodemb.h index cf7097dde..515935f9b 100644 --- a/vp9/encoder/vp9_encodemb.h +++ b/vp9/encoder/vp9_encodemb.h @@ -32,7 +32,7 @@ void vp9_subtract_sb(MACROBLOCK *x, BLOCK_SIZE bsize); void vp9_encode_block_intra(MACROBLOCK *x, int plane, int block, BLOCK_SIZE plane_bsize, TX_SIZE tx_size, - unsigned char *skip_coeff); + unsigned char *skip); void vp9_encode_intra_block_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane); diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c index 3e04c2faf..bf9dd3ec5 100644 --- a/vp9/encoder/vp9_firstpass.c +++ b/vp9/encoder/vp9_firstpass.c @@ -1566,13 +1566,7 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) { (i >= MIN_GF_INTERVAL) && // for real scene cuts (not forced kfs) dont allow arf very near kf. (rc->next_key_frame_forced || - (i <= (rc->frames_to_key - MIN_GF_INTERVAL))) && - ((next_frame.pcnt_inter > 0.75) || - (next_frame.pcnt_second_ref > 0.5)) && - ((mv_in_out_accumulator / (double)i > -0.2) || - (mv_in_out_accumulator > -2.0)) && - (boost_score > 100)) { - + (i <= (rc->frames_to_key - MIN_GF_INTERVAL)))) { // Alternative boost calculation for alt ref rc->gfu_boost = calc_arf_boost(cpi, 0, (i - 1), (i - 1), &f_boost, &b_boost); @@ -1926,8 +1920,6 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) { double kf_mod_err = 0.0; double kf_group_err = 0.0; - double kf_group_intra_err = 0.0; - double kf_group_coded_err = 0.0; double recent_loop_decay[8] = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}; RATE_CONTROL *const rc = &cpi->rc; @@ -1965,12 +1957,6 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) { // Accumulate kf group error kf_group_err += calculate_modified_err(cpi, this_frame); - // These figures keep intra and coded error counts for all frames including - // key frames in the group. The effect of the key frame itself can be - // subtracted out using the first_frame data collected above. - kf_group_intra_err += this_frame->intra_error; - kf_group_coded_err += this_frame->coded_error; - // load a the next frame's stats last_frame = *this_frame; input_stats(twopass, this_frame); @@ -2030,15 +2016,11 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) { reset_fpf_position(twopass, start_position); kf_group_err = 0; - kf_group_intra_err = 0; - kf_group_coded_err = 0; // Rescan to get the correct error data for the forced kf group for (i = 0; i < rc->frames_to_key; i++) { // Accumulate kf group errors kf_group_err += calculate_modified_err(cpi, &tmp_frame); - kf_group_intra_err += tmp_frame.intra_error; - kf_group_coded_err += tmp_frame.coded_error; // Load the next frame's stats. input_stats(twopass, &tmp_frame); @@ -2054,12 +2036,6 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) { if (twopass->stats_in >= twopass->stats_in_end) { // Accumulate kf group error kf_group_err += calculate_modified_err(cpi, this_frame); - - // These figures keep intra and coded error counts for all frames including - // key frames in the group. The effect of the key frame itself can be - // subtracted out using the first_frame data collected above. - kf_group_intra_err += this_frame->intra_error; - kf_group_coded_err += this_frame->coded_error; } // Calculate the number of bits that should be assigned to the kf group. @@ -2089,7 +2065,6 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) { // frames use inter blocks. decay_accumulator = 1.0; boost_score = 0.0; - loop_decay_rate = 1.00; // Starting decay rate // Scan through the kf group collating various stats. for (i = 0; i < rc->frames_to_key; i++) { diff --git a/vp9/encoder/vp9_mbgraph.c b/vp9/encoder/vp9_mbgraph.c index c50098678..7eacda217 100644 --- a/vp9/encoder/vp9_mbgraph.c +++ b/vp9/encoder/vp9_mbgraph.c @@ -29,7 +29,6 @@ static unsigned int do_16x16_motion_iteration(VP9_COMP *cpi, MACROBLOCK *const x = &cpi->mb; MACROBLOCKD *const xd = &x->e_mbd; vp9_variance_fn_ptr_t v_fn_ptr = cpi->fn_ptr[BLOCK_16X16]; - unsigned int best_err; const int tmp_col_min = x->mv_col_min; const int tmp_col_max = x->mv_col_max; @@ -48,27 +47,22 @@ static unsigned int do_16x16_motion_iteration(VP9_COMP *cpi, ref_full.row = ref_mv->row >> 3; /*cpi->sf.search_method == HEX*/ - best_err = vp9_hex_search(x, &ref_full, step_param, x->errorperbit, - 0, &v_fn_ptr, 0, ref_mv, dst_mv); + vp9_hex_search(x, &ref_full, step_param, x->errorperbit, 0, &v_fn_ptr, 0, + ref_mv, dst_mv); // Try sub-pixel MC // if (bestsme > error_thresh && bestsme < INT_MAX) { int distortion; unsigned int sse; - best_err = cpi->find_fractional_mv_step( - x, dst_mv, ref_mv, - cpi->common.allow_high_precision_mv, - x->errorperbit, &v_fn_ptr, - 0, cpi->sf.subpel_iters_per_step, NULL, NULL, - & distortion, &sse); + cpi->find_fractional_mv_step( + x, dst_mv, ref_mv, cpi->common.allow_high_precision_mv, x->errorperbit, + &v_fn_ptr, 0, cpi->sf.subpel_iters_per_step, NULL, NULL, &distortion, + &sse); } vp9_set_mbmode_and_mvs(xd, NEWMV, dst_mv); vp9_build_inter_predictors_sby(xd, mb_row, mb_col, BLOCK_16X16); - best_err = vp9_sad16x16(x->plane[0].src.buf, x->plane[0].src.stride, - xd->plane[0].dst.buf, xd->plane[0].dst.stride, - INT_MAX); /* restore UMV window */ x->mv_col_min = tmp_col_min; @@ -76,7 +70,9 @@ static unsigned int do_16x16_motion_iteration(VP9_COMP *cpi, x->mv_row_min = tmp_row_min; x->mv_row_max = tmp_row_max; - return best_err; + return vp9_sad16x16(x->plane[0].src.buf, x->plane[0].src.stride, + xd->plane[0].dst.buf, xd->plane[0].dst.stride, + INT_MAX); } static int do_16x16_motion_search(VP9_COMP *cpi, const int_mv *ref_mv, @@ -355,7 +351,7 @@ static void separate_arf_mbs(VP9_COMP *cpi) { for (mi_col = 0; mi_col < cm->mi_cols; mi_col++) { // If any of the blocks in the sequence failed then the MB // goes in segment 0 - if (arf_not_zz[mi_row/2*cm->mb_cols + mi_col/2]) { + if (arf_not_zz[mi_row / 2 * cm->mb_cols + mi_col / 2]) { ncnt[0]++; cpi->segmentation_map[mi_row * cm->mi_cols + mi_col] = 0; } else { diff --git a/vp9/encoder/vp9_mcomp.c b/vp9/encoder/vp9_mcomp.c index 3b8ec186e..62b33e4b9 100644 --- a/vp9/encoder/vp9_mcomp.c +++ b/vp9/encoder/vp9_mcomp.c @@ -349,6 +349,10 @@ int vp9_find_best_sub_pixel_tree(const MACROBLOCK *x, tr = br; tc = bc; } + // These lines insure static analysis doesn't warn that + // tr and tc aren't used after the above point. + (void) tr; + (void) tc; bestmv->row = br; bestmv->col = bc; @@ -452,6 +456,11 @@ int vp9_find_best_sub_pixel_comp_tree(const MACROBLOCK *x, tr = br; tc = bc; } + // These lines insure static analysis doesn't warn that + // tr and tc aren't used after the above point. + (void) tr; + (void) tc; + bestmv->row = br; bestmv->col = bc; diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c index e97235591..cef7e0403 100644 --- a/vp9/encoder/vp9_onyx_if.c +++ b/vp9/encoder/vp9_onyx_if.c @@ -96,7 +96,7 @@ FILE *keyfile; void vp9_init_quantizer(VP9_COMP *cpi); static const double in_frame_q_adj_ratio[MAX_SEGMENTS] = - {1.0, 1.5, 2.0, 1.0, 1.0, 1.0, 1.0, 1.0}; + {1.0, 2.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}; static INLINE void Scale2Ratio(int mode, int *hr, int *hs) { switch (mode) { @@ -267,7 +267,6 @@ static void setup_in_frame_q_adj(VP9_COMP *cpi) { // Clear down the complexity map used for rd vpx_memset(cpi->complexity_map, 0, cm->mi_rows * cm->mi_cols); - // Enable segmentation vp9_enable_segmentation((VP9_PTR)cpi); vp9_clearall_segfeatures(seg); @@ -278,7 +277,7 @@ static void setup_in_frame_q_adj(VP9_COMP *cpi) { vp9_disable_segfeature(seg, 0, SEG_LVL_ALT_Q); // Use some of the segments for in frame Q adjustment - for (segment = 1; segment < 3; segment++) { + for (segment = 1; segment < 2; segment++) { qindex_delta = vp9_compute_qdelta_by_rate(cpi, cm->base_qindex, in_frame_q_adj_ratio[segment]); @@ -3707,8 +3706,9 @@ int vp9_get_compressed_data(VP9_PTR ptr, unsigned int *frame_flags, xd->interp_kernel = vp9_get_interp_kernel( DEFAULT_INTERP_FILTER == SWITCHABLE ? EIGHTTAP : DEFAULT_INTERP_FILTER); - if (cpi->oxcf.aq_mode == VARIANCE_AQ) + if (cpi->oxcf.aq_mode == VARIANCE_AQ) { vp9_vaq_init(); + } if (cpi->use_svc) { SvcEncode(cpi, size, dest, frame_flags); diff --git a/vp9/encoder/vp9_pickmode.c b/vp9/encoder/vp9_pickmode.c index 3b4a7f6e4..6fed3d576 100644 --- a/vp9/encoder/vp9_pickmode.c +++ b/vp9/encoder/vp9_pickmode.c @@ -98,10 +98,8 @@ static int full_pixel_motion_search(VP9_COMP *cpi, MACROBLOCK *x, mvp_full.col >>= 3; mvp_full.row >>= 3; - bestsme = vp9_full_pixel_diamond(cpi, x, &mvp_full, step_param, - sadpb, further_steps, 1, - &cpi->fn_ptr[bsize], - &ref_mv.as_mv, tmp_mv); + vp9_full_pixel_diamond(cpi, x, &mvp_full, step_param, sadpb, further_steps, 1, + &cpi->fn_ptr[bsize], &ref_mv.as_mv, tmp_mv); x->mv_col_min = tmp_col_min; x->mv_col_max = tmp_col_max; @@ -172,7 +170,7 @@ int64_t vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, tx_mode_to_biggest_tx_size[cpi->common.tx_mode]); mbmi->interp_filter = cpi->common.interp_filter == SWITCHABLE ? EIGHTTAP : cpi->common.interp_filter; - mbmi->skip_coeff = 0; + mbmi->skip = 0; mbmi->segment_id = 0; for (ref_frame = LAST_FRAME; ref_frame <= LAST_FRAME ; ++ref_frame) { diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c index 9afa0647d..2427dbe74 100644 --- a/vp9/encoder/vp9_ratectrl.c +++ b/vp9/encoder/vp9_ratectrl.c @@ -846,7 +846,6 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi, int q; if (frame_is_intra_only(cm)) { - active_best_quality = rc->best_quality; #if !CONFIG_MULTIPLE_ARF // Handle the special case for key frames forced when we have75 reached // the maximum key frame interval. Here force the Q to a range diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c index 6d26e64f6..aed4de5f4 100644 --- a/vp9/encoder/vp9_rdopt.c +++ b/vp9/encoder/vp9_rdopt.c @@ -68,7 +68,7 @@ struct rdcost_block_args { int64_t this_rd; int64_t best_rd; int skip; - const int16_t *scan, *nb; + const scan_order *so; }; const MODE_DEFINITION vp9_mode_order[MAX_MODES] = { @@ -635,7 +635,7 @@ static void rate_block(int plane, int block, BLOCK_SIZE plane_bsize, args->rate = cost_coeffs(args->x, plane, block, args->t_above + x_idx, args->t_left + y_idx, tx_size, - args->scan, args->nb); + args->so->scan, args->so->neighbors); } static void block_rd_txfm(int plane, int block, BLOCK_SIZE plane_bsize, @@ -650,8 +650,7 @@ static void block_rd_txfm(int plane, int block, BLOCK_SIZE plane_bsize, return; if (!is_inter_block(mbmi)) - vp9_encode_block_intra(x, plane, block, plane_bsize, tx_size, - &mbmi->skip_coeff); + vp9_encode_block_intra(x, plane, block, plane_bsize, tx_size, &mbmi->skip); else vp9_xform_quant(x, plane, block, plane_bsize, tx_size); @@ -710,49 +709,40 @@ void vp9_get_entropy_contexts(TX_SIZE tx_size, } } -static void init_rdcost_stack(MACROBLOCK *x, const int64_t ref_rdcost, - struct rdcost_block_args *arg) { - vpx_memset(arg, 0, sizeof(struct rdcost_block_args)); - arg->x = x; - arg->best_rd = ref_rdcost; -} - static void txfm_rd_in_plane(MACROBLOCK *x, int *rate, int64_t *distortion, int *skippable, int64_t *sse, int64_t ref_best_rd, int plane, BLOCK_SIZE bsize, TX_SIZE tx_size) { - struct rdcost_block_args rd_stack; MACROBLOCKD *const xd = &x->e_mbd; struct macroblockd_plane *const pd = &xd->plane[plane]; const BLOCK_SIZE bs = get_plane_block_size(bsize, pd); const int num_4x4_w = num_4x4_blocks_wide_lookup[bs]; const int num_4x4_h = num_4x4_blocks_high_lookup[bs]; - const scan_order *so; + struct rdcost_block_args args = { 0 }; + args.x = x; + args.best_rd = ref_best_rd; - init_rdcost_stack(x, ref_best_rd, &rd_stack); if (plane == 0) xd->mi_8x8[0]->mbmi.tx_size = tx_size; - vp9_get_entropy_contexts(tx_size, rd_stack.t_above, rd_stack.t_left, + vp9_get_entropy_contexts(tx_size, args.t_above, args.t_left, pd->above_context, pd->left_context, num_4x4_w, num_4x4_h); - so = get_scan(xd, tx_size, pd->plane_type, 0); - rd_stack.scan = so->scan; - rd_stack.nb = so->neighbors; + args.so = get_scan(xd, tx_size, pd->plane_type, 0); vp9_foreach_transformed_block_in_plane(xd, bsize, plane, - block_rd_txfm, &rd_stack); - if (rd_stack.skip) { + block_rd_txfm, &args); + if (args.skip) { *rate = INT_MAX; *distortion = INT64_MAX; *sse = INT64_MAX; *skippable = 0; } else { - *distortion = rd_stack.this_dist; - *rate = rd_stack.this_rate; - *sse = rd_stack.this_sse; + *distortion = args.this_dist; + *rate = args.this_rate; + *sse = args.this_sse; *skippable = vp9_is_skippable_in_plane(x, bsize, plane); } } @@ -787,7 +777,10 @@ static void choose_txfm_size_from_rd(VP9_COMP *cpi, MACROBLOCK *x, MACROBLOCKD *const xd = &x->e_mbd; MB_MODE_INFO *const mbmi = &xd->mi_8x8[0]->mbmi; vp9_prob skip_prob = vp9_get_skip_prob(cm, xd); - int64_t rd[TX_SIZES][2]; + int64_t rd[TX_SIZES][2] = {{INT64_MAX, INT64_MAX}, + {INT64_MAX, INT64_MAX}, + {INT64_MAX, INT64_MAX}, + {INT64_MAX, INT64_MAX}}; int n, m; int s0, s1; const TX_SIZE max_mode_tx_size = tx_mode_to_biggest_tx_size[cm->tx_mode]; @@ -862,7 +855,10 @@ static void choose_txfm_size_from_modelrd(VP9_COMP *cpi, MACROBLOCK *x, MACROBLOCKD *const xd = &x->e_mbd; MB_MODE_INFO *const mbmi = &xd->mi_8x8[0]->mbmi; vp9_prob skip_prob = vp9_get_skip_prob(cm, xd); - int64_t rd[TX_SIZES][2]; + int64_t rd[TX_SIZES][2] = {{INT64_MAX, INT64_MAX}, + {INT64_MAX, INT64_MAX}, + {INT64_MAX, INT64_MAX}, + {INT64_MAX, INT64_MAX}}; int n, m; int s0, s1; double scale_rd[TX_SIZES] = {1.73, 1.44, 1.20, 1.00}; @@ -4109,11 +4105,6 @@ int64_t vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi, MACROBLOCK *x, if (tmp_rd == INT64_MAX) continue; } else { - if (cm->interp_filter == SWITCHABLE) { - int rs = get_switchable_rate(x); - tmp_best_rdu -= RDCOST(x->rdmult, x->rddiv, rs, 0); - } - tmp_rd = tmp_best_rdu; total_sse = tmp_best_sse; rate = tmp_best_rate; rate_y = tmp_best_ratey; diff --git a/vp9/encoder/vp9_temporal_filter.c b/vp9/encoder/vp9_temporal_filter.c index ca11dda1e..004047773 100644 --- a/vp9/encoder/vp9_temporal_filter.c +++ b/vp9/encoder/vp9_temporal_filter.c @@ -29,7 +29,6 @@ #include "vpx_scale/vpx_scale.h" #define ALT_REF_MC_ENABLED 1 // dis/enable MC in AltRef filtering -#define ALT_REF_SUBPEL_ENABLED 1 // dis/enable subpel in MC AltRef filtering static void temporal_filter_predictors_mb_c(MACROBLOCKD *xd, uint8_t *y_mb_ptr, @@ -160,11 +159,9 @@ static int temporal_filter_find_matching_mb_c(VP9_COMP *cpi, /*cpi->sf.search_method == HEX*/ // Ignore mv costing by sending NULL pointer instead of cost arrays - bestsme = vp9_hex_search(x, &best_ref_mv1_full, step_param, sadpb, 1, - &cpi->fn_ptr[BLOCK_16X16], - 0, &best_ref_mv1, ref_mv); + vp9_hex_search(x, &best_ref_mv1_full, step_param, sadpb, 1, + &cpi->fn_ptr[BLOCK_16X16], 0, &best_ref_mv1, ref_mv); -#if ALT_REF_SUBPEL_ENABLED // Try sub-pixel MC? // if (bestsme > error_thresh && bestsme < INT_MAX) { @@ -180,7 +177,6 @@ static int temporal_filter_find_matching_mb_c(VP9_COMP *cpi, NULL, NULL, &distortion, &sse); } -#endif // Restore input state x->plane[0].src = src; diff --git a/vp9/encoder/vp9_tokenize.c b/vp9/encoder/vp9_tokenize.c index 0f68d83c5..510ef7878 100644 --- a/vp9/encoder/vp9_tokenize.c +++ b/vp9/encoder/vp9_tokenize.c @@ -314,7 +314,7 @@ void vp9_tokenize_sb(VP9_COMP *cpi, TOKENEXTRA **t, int dry_run, const int skip_inc = !vp9_segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP); struct tokenize_b_args arg = {cpi, xd, t, cpi->mb.token_cache}; - if (mbmi->skip_coeff) { + if (mbmi->skip) { if (!dry_run) cm->counts.skip[ctx][1] += skip_inc; reset_skip_context(xd, bsize); diff --git a/vp9/encoder/vp9_vaq.c b/vp9/encoder/vp9_vaq.c index 1f9cb8709..acd7c416e 100644 --- a/vp9/encoder/vp9_vaq.c +++ b/vp9/encoder/vp9_vaq.c @@ -19,8 +19,8 @@ #include "vp9/encoder/vp9_segmentation.h" #include "vp9/common/vp9_systemdependent.h" -#define ENERGY_MIN (-3) -#define ENERGY_MAX (3) +#define ENERGY_MIN (-1) +#define ENERGY_MAX (1) #define ENERGY_SPAN (ENERGY_MAX - ENERGY_MIN + 1) #define ENERGY_IN_BOUNDS(energy)\ assert((energy) >= ENERGY_MIN && (energy) <= ENERGY_MAX) @@ -65,7 +65,7 @@ void vp9_vaq_init() { vp9_clear_system_state(); // __asm emms; - base_ratio = 1.8; + base_ratio = 1.5; for (i = ENERGY_MIN; i <= ENERGY_MAX; i++) { Q_RATIO(i) = pow(base_ratio, i/3.0); @@ -80,30 +80,34 @@ void vp9_vaq_frame_setup(VP9_COMP *cpi) { cm->y_dc_delta_q); int i; - vp9_enable_segmentation((VP9_PTR)cpi); - vp9_clearall_segfeatures(seg); + if (cm->frame_type == KEY_FRAME || + cpi->refresh_alt_ref_frame || + (cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref)) { + vp9_enable_segmentation((VP9_PTR)cpi); + vp9_clearall_segfeatures(seg); - seg->abs_delta = SEGMENT_DELTADATA; + seg->abs_delta = SEGMENT_DELTADATA; - vp9_clear_system_state(); // __asm emms; + vp9_clear_system_state(); // __asm emms; - for (i = ENERGY_MIN; i <= ENERGY_MAX; i++) { - int qindex_delta, segment_rdmult; + for (i = ENERGY_MIN; i <= ENERGY_MAX; i++) { + int qindex_delta, segment_rdmult; - if (Q_RATIO(i) == 1) { - // No need to enable SEG_LVL_ALT_Q for this segment - RDMULT_RATIO(i) = 1; - continue; - } + if (Q_RATIO(i) == 1) { + // No need to enable SEG_LVL_ALT_Q for this segment + RDMULT_RATIO(i) = 1; + continue; + } - qindex_delta = vp9_compute_qdelta(cpi, base_q, base_q * Q_RATIO(i)); - vp9_set_segdata(seg, SEGMENT_ID(i), SEG_LVL_ALT_Q, qindex_delta); - vp9_enable_segfeature(seg, SEGMENT_ID(i), SEG_LVL_ALT_Q); + qindex_delta = vp9_compute_qdelta(cpi, base_q, base_q * Q_RATIO(i)); + vp9_set_segdata(seg, SEGMENT_ID(i), SEG_LVL_ALT_Q, qindex_delta); + vp9_enable_segfeature(seg, SEGMENT_ID(i), SEG_LVL_ALT_Q); - segment_rdmult = vp9_compute_rd_mult(cpi, cm->base_qindex + qindex_delta + - cm->y_dc_delta_q); + segment_rdmult = vp9_compute_rd_mult(cpi, cm->base_qindex + qindex_delta + + cm->y_dc_delta_q); - RDMULT_RATIO(i) = (double) segment_rdmult / base_rdmult; + RDMULT_RATIO(i) = (double) segment_rdmult / base_rdmult; + } } } |