diff options
Diffstat (limited to 'media/libaom/src/av1/decoder/decodemv.c')
-rw-r--r-- | media/libaom/src/av1/decoder/decodemv.c | 483 |
1 files changed, 249 insertions, 234 deletions
diff --git a/media/libaom/src/av1/decoder/decodemv.c b/media/libaom/src/av1/decoder/decodemv.c index 551e4d5437..e97cec42cb 100644 --- a/media/libaom/src/av1/decoder/decodemv.c +++ b/media/libaom/src/av1/decoder/decodemv.c @@ -36,40 +36,57 @@ static PREDICTION_MODE read_intra_mode(aom_reader *r, aom_cdf_prob *cdf) { return (PREDICTION_MODE)aom_read_symbol(r, cdf, INTRA_MODES, ACCT_STR); } -static void read_cdef(AV1_COMMON *cm, aom_reader *r, MACROBLOCKD *const xd, - int mi_col, int mi_row) { - MB_MODE_INFO *const mbmi = xd->mi[0]; - if (cm->coded_lossless) return; - if (cm->allow_intrabc) { - assert(cm->cdef_bits == 0); +static void read_cdef(AV1_COMMON *cm, aom_reader *r, MACROBLOCKD *const xd) { + const int skip = xd->mi[0]->skip; + if (cm->features.coded_lossless) return; + if (cm->features.allow_intrabc) { + assert(cm->cdef_info.cdef_bits == 0); return; } - if (!(mi_col & (cm->seq_params.mib_size - 1)) && - !(mi_row & (cm->seq_params.mib_size - 1))) { // Top left? - xd->cdef_preset[0] = xd->cdef_preset[1] = xd->cdef_preset[2] = - xd->cdef_preset[3] = -1; + // At the start of a superblock, mark that we haven't yet read CDEF strengths + // for any of the CDEF units contained in this superblock. + const int sb_mask = (cm->seq_params.mib_size - 1); + const int mi_row_in_sb = (xd->mi_row & sb_mask); + const int mi_col_in_sb = (xd->mi_col & sb_mask); + if (mi_row_in_sb == 0 && mi_col_in_sb == 0) { + xd->cdef_transmitted[0] = xd->cdef_transmitted[1] = + xd->cdef_transmitted[2] = xd->cdef_transmitted[3] = false; } - // Read CDEF param at the first non-skip coding block - const int mask = (1 << (6 - MI_SIZE_LOG2)); - const int m = ~(mask - 1); - const int index = cm->seq_params.sb_size == BLOCK_128X128 - ? !!(mi_col & mask) + 2 * !!(mi_row & mask) + + // CDEF unit size is 64x64 irrespective of the superblock size. + const int cdef_size = 1 << (6 - MI_SIZE_LOG2); + + // Find index of this CDEF unit in this superblock. + const int index_mask = cdef_size; + const int cdef_unit_row_in_sb = ((xd->mi_row & index_mask) != 0); + const int cdef_unit_col_in_sb = ((xd->mi_col & index_mask) != 0); + const int index = (cm->seq_params.sb_size == BLOCK_128X128) + ? cdef_unit_col_in_sb + 2 * cdef_unit_row_in_sb : 0; - cm->mi_grid_visible[(mi_row & m) * cm->mi_stride + (mi_col & m)] - ->cdef_strength = xd->cdef_preset[index] = - xd->cdef_preset[index] == -1 && !mbmi->skip - ? aom_read_literal(r, cm->cdef_bits, ACCT_STR) - : xd->cdef_preset[index]; + + // Read CDEF strength from the first non-skip coding block in this CDEF unit. + if (!xd->cdef_transmitted[index] && !skip) { + // CDEF strength for this CDEF unit needs to be read into the MB_MODE_INFO + // of the 1st block in this CDEF unit. + const int first_block_mask = ~(cdef_size - 1); + CommonModeInfoParams *const mi_params = &cm->mi_params; + const int grid_idx = + get_mi_grid_idx(mi_params, xd->mi_row & first_block_mask, + xd->mi_col & first_block_mask); + MB_MODE_INFO *const mbmi = mi_params->mi_grid_base[grid_idx]; + mbmi->cdef_strength = + aom_read_literal(r, cm->cdef_info.cdef_bits, ACCT_STR); + xd->cdef_transmitted[index] = true; + } } static int read_delta_qindex(AV1_COMMON *cm, const MACROBLOCKD *xd, - aom_reader *r, MB_MODE_INFO *const mbmi, - int mi_col, int mi_row) { + aom_reader *r, MB_MODE_INFO *const mbmi) { int sign, abs, reduced_delta_qindex = 0; BLOCK_SIZE bsize = mbmi->sb_type; - const int b_col = mi_col & (cm->seq_params.mib_size - 1); - const int b_row = mi_row & (cm->seq_params.mib_size - 1); + const int b_col = xd->mi_col & (cm->seq_params.mib_size - 1); + const int b_row = xd->mi_row & (cm->seq_params.mib_size - 1); const int read_delta_q_flag = (b_col == 0 && b_row == 0); FRAME_CONTEXT *ec_ctx = xd->tile_ctx; @@ -129,20 +146,20 @@ static UV_PREDICTION_MODE read_intra_mode_uv(FRAME_CONTEXT *ec_ctx, return uv_mode; } -static int read_cfl_alphas(FRAME_CONTEXT *const ec_ctx, aom_reader *r, - int *signs_out) { - const int joint_sign = +static uint8_t read_cfl_alphas(FRAME_CONTEXT *const ec_ctx, aom_reader *r, + int8_t *signs_out) { + const int8_t joint_sign = aom_read_symbol(r, ec_ctx->cfl_sign_cdf, CFL_JOINT_SIGNS, "cfl:signs"); - int idx = 0; + uint8_t idx = 0; // Magnitudes are only coded for nonzero values if (CFL_SIGN_U(joint_sign) != CFL_SIGN_ZERO) { aom_cdf_prob *cdf_u = ec_ctx->cfl_alpha_cdf[CFL_CONTEXT_U(joint_sign)]; - idx = aom_read_symbol(r, cdf_u, CFL_ALPHABET_SIZE, "cfl:alpha_u") + idx = (uint8_t)aom_read_symbol(r, cdf_u, CFL_ALPHABET_SIZE, "cfl:alpha_u") << CFL_ALPHABET_SIZE_LOG2; } if (CFL_SIGN_V(joint_sign) != CFL_SIGN_ZERO) { aom_cdf_prob *cdf_v = ec_ctx->cfl_alpha_cdf[CFL_CONTEXT_V(joint_sign)]; - idx += aom_read_symbol(r, cdf_v, CFL_ALPHABET_SIZE, "cfl:alpha_v"); + idx += (uint8_t)aom_read_symbol(r, cdf_v, CFL_ALPHABET_SIZE, "cfl:alpha_v"); } *signs_out = joint_sign; return idx; @@ -183,7 +200,7 @@ static void read_drl_idx(FRAME_CONTEXT *ec_ctx, MACROBLOCKD *xd, if (mbmi->mode == NEWMV || mbmi->mode == NEW_NEWMV) { for (int idx = 0; idx < 2; ++idx) { if (xd->ref_mv_count[ref_frame_type] > idx + 1) { - uint8_t drl_ctx = av1_drl_ctx(xd->ref_mv_stack[ref_frame_type], idx); + uint8_t drl_ctx = av1_drl_ctx(xd->weight[ref_frame_type], idx); int drl_idx = aom_read_symbol(r, ec_ctx->drl_cdf[drl_ctx], 2, ACCT_STR); mbmi->ref_mv_idx = idx + drl_idx; if (!drl_idx) return; @@ -196,7 +213,7 @@ static void read_drl_idx(FRAME_CONTEXT *ec_ctx, MACROBLOCKD *xd, // mode is factored in. for (int idx = 1; idx < 3; ++idx) { if (xd->ref_mv_count[ref_frame_type] > idx + 1) { - uint8_t drl_ctx = av1_drl_ctx(xd->ref_mv_stack[ref_frame_type], idx); + uint8_t drl_ctx = av1_drl_ctx(xd->weight[ref_frame_type], idx); int drl_idx = aom_read_symbol(r, ec_ctx->drl_cdf[drl_ctx], 2, ACCT_STR); mbmi->ref_mv_idx = idx + drl_idx - 1; if (!drl_idx) return; @@ -207,11 +224,11 @@ static void read_drl_idx(FRAME_CONTEXT *ec_ctx, MACROBLOCKD *xd, static MOTION_MODE read_motion_mode(AV1_COMMON *cm, MACROBLOCKD *xd, MB_MODE_INFO *mbmi, aom_reader *r) { - if (cm->switchable_motion_mode == 0) return SIMPLE_TRANSLATION; + if (cm->features.switchable_motion_mode == 0) return SIMPLE_TRANSLATION; if (mbmi->skip_mode) return SIMPLE_TRANSLATION; - const MOTION_MODE last_motion_mode_allowed = - motion_mode_allowed(xd->global_motion, xd, mbmi, cm->allow_warped_motion); + const MOTION_MODE last_motion_mode_allowed = motion_mode_allowed( + xd->global_motion, xd, mbmi, cm->features.allow_warped_motion); int motion_mode; if (last_motion_mode_allowed == SIMPLE_TRANSLATION) return SIMPLE_TRANSLATION; @@ -260,9 +277,9 @@ int av1_neg_deinterleave(int diff, int ref, int max) { } static int read_segment_id(AV1_COMMON *const cm, const MACROBLOCKD *const xd, - int mi_row, int mi_col, aom_reader *r, int skip) { + aom_reader *r, int skip) { int cdf_num; - const int pred = av1_get_spatial_seg_pred(cm, xd, mi_row, mi_col, &cdf_num); + const int pred = av1_get_spatial_seg_pred(cm, xd, &cdf_num); if (skip) return pred; FRAME_CONTEXT *ec_ctx = xd->tile_ctx; @@ -286,8 +303,8 @@ static int dec_get_segment_id(const AV1_COMMON *cm, const uint8_t *segment_ids, for (int y = 0; y < y_mis; y++) for (int x = 0; x < x_mis; x++) - segment_id = - AOMMIN(segment_id, segment_ids[mi_offset + y * cm->mi_cols + x]); + segment_id = AOMMIN( + segment_id, segment_ids[mi_offset + y * cm->mi_params.mi_cols + x]); assert(segment_id >= 0 && segment_id < MAX_SEGMENTS); return segment_id; @@ -299,37 +316,40 @@ static void set_segment_id(AV1_COMMON *cm, int mi_offset, int x_mis, int y_mis, for (int y = 0; y < y_mis; y++) for (int x = 0; x < x_mis; x++) - cm->current_frame_seg_map[mi_offset + y * cm->mi_cols + x] = segment_id; + cm->cur_frame->seg_map[mi_offset + y * cm->mi_params.mi_cols + x] = + segment_id; } static int read_intra_segment_id(AV1_COMMON *const cm, - const MACROBLOCKD *const xd, int mi_row, - int mi_col, int bsize, aom_reader *r, - int skip) { + const MACROBLOCKD *const xd, int bsize, + aom_reader *r, int skip) { struct segmentation *const seg = &cm->seg; if (!seg->enabled) return 0; // Default for disabled segmentation - assert(seg->update_map && !seg->temporal_update); - const int mi_offset = mi_row * cm->mi_cols + mi_col; + const CommonModeInfoParams *const mi_params = &cm->mi_params; + const int mi_row = xd->mi_row; + const int mi_col = xd->mi_col; + const int mi_offset = mi_row * mi_params->mi_cols + mi_col; const int bw = mi_size_wide[bsize]; const int bh = mi_size_high[bsize]; - const int x_mis = AOMMIN(cm->mi_cols - mi_col, bw); - const int y_mis = AOMMIN(cm->mi_rows - mi_row, bh); - const int segment_id = read_segment_id(cm, xd, mi_row, mi_col, r, skip); + const int x_mis = AOMMIN(mi_params->mi_cols - mi_col, bw); + const int y_mis = AOMMIN(mi_params->mi_rows - mi_row, bh); + const int segment_id = read_segment_id(cm, xd, r, skip); set_segment_id(cm, mi_offset, x_mis, y_mis, segment_id); return segment_id; } -static void copy_segment_id(const AV1_COMMON *cm, +static void copy_segment_id(const CommonModeInfoParams *const mi_params, const uint8_t *last_segment_ids, uint8_t *current_segment_ids, int mi_offset, int x_mis, int y_mis) { for (int y = 0; y < y_mis; y++) for (int x = 0; x < x_mis; x++) - current_segment_ids[mi_offset + y * cm->mi_cols + x] = - last_segment_ids ? last_segment_ids[mi_offset + y * cm->mi_cols + x] - : 0; + current_segment_ids[mi_offset + y * mi_params->mi_cols + x] = + last_segment_ids + ? last_segment_ids[mi_offset + y * mi_params->mi_cols + x] + : 0; } static int get_predicted_segment_id(AV1_COMMON *const cm, int mi_offset, @@ -340,22 +360,24 @@ static int get_predicted_segment_id(AV1_COMMON *const cm, int mi_offset, } static int read_inter_segment_id(AV1_COMMON *const cm, MACROBLOCKD *const xd, - int mi_row, int mi_col, int preskip, - aom_reader *r) { + int preskip, aom_reader *r) { struct segmentation *const seg = &cm->seg; + const CommonModeInfoParams *const mi_params = &cm->mi_params; MB_MODE_INFO *const mbmi = xd->mi[0]; - const int mi_offset = mi_row * cm->mi_cols + mi_col; + const int mi_row = xd->mi_row; + const int mi_col = xd->mi_col; + const int mi_offset = mi_row * mi_params->mi_cols + mi_col; const int bw = mi_size_wide[mbmi->sb_type]; const int bh = mi_size_high[mbmi->sb_type]; // TODO(slavarnway): move x_mis, y_mis into xd ????? - const int x_mis = AOMMIN(cm->mi_cols - mi_col, bw); - const int y_mis = AOMMIN(cm->mi_rows - mi_row, bh); + const int x_mis = AOMMIN(mi_params->mi_cols - mi_col, bw); + const int y_mis = AOMMIN(mi_params->mi_rows - mi_row, bh); if (!seg->enabled) return 0; // Default for disabled segmentation if (!seg->update_map) { - copy_segment_id(cm, cm->last_frame_seg_map, cm->current_frame_seg_map, + copy_segment_id(mi_params, cm->last_frame_seg_map, cm->cur_frame->seg_map, mi_offset, x_mis, y_mis); return get_predicted_segment_id(cm, mi_offset, x_mis, y_mis); } @@ -364,12 +386,11 @@ static int read_inter_segment_id(AV1_COMMON *const cm, MACROBLOCKD *const xd, if (preskip) { if (!seg->segid_preskip) return 0; } else { - if (seg->segid_preskip) return mbmi->segment_id; if (mbmi->skip) { if (seg->temporal_update) { mbmi->seg_id_predicted = 0; } - segment_id = read_segment_id(cm, xd, mi_row, mi_col, r, 1); + segment_id = read_segment_id(cm, xd, r, 1); set_segment_id(cm, mi_offset, x_mis, y_mis, segment_id); return segment_id; } @@ -384,10 +405,10 @@ static int read_inter_segment_id(AV1_COMMON *const cm, MACROBLOCKD *const xd, if (mbmi->seg_id_predicted) { segment_id = get_predicted_segment_id(cm, mi_offset, x_mis, y_mis); } else { - segment_id = read_segment_id(cm, xd, mi_row, mi_col, r, 0); + segment_id = read_segment_id(cm, xd, r, 0); } } else { - segment_id = read_segment_id(cm, xd, mi_row, mi_col, r, 0); + segment_id = read_segment_id(cm, xd, r, 0); } set_segment_id(cm, mi_offset, x_mis, y_mis, segment_id); return segment_id; @@ -395,7 +416,7 @@ static int read_inter_segment_id(AV1_COMMON *const cm, MACROBLOCKD *const xd, static int read_skip_mode(AV1_COMMON *cm, const MACROBLOCKD *xd, int segment_id, aom_reader *r) { - if (!cm->skip_mode_flag) return 0; + if (!cm->current_frame.skip_mode_info.skip_mode_flag) return 0; if (segfeature_active(&cm->seg, segment_id, SEG_LVL_SKIP)) { return 0; @@ -539,11 +560,11 @@ static void read_palette_colors_uv(MACROBLOCKD *const xd, int bit_depth, } static void read_palette_mode_info(AV1_COMMON *const cm, MACROBLOCKD *const xd, - int mi_row, int mi_col, aom_reader *r) { + aom_reader *r) { const int num_planes = av1_num_planes(cm); MB_MODE_INFO *const mbmi = xd->mi[0]; const BLOCK_SIZE bsize = mbmi->sb_type; - assert(av1_allow_palette(cm->allow_screen_content_tools, bsize)); + assert(av1_allow_palette(cm->features.allow_screen_content_tools, bsize)); PALETTE_MODE_INFO *const pmi = &mbmi->palette_mode_info; const int bsize_ctx = av1_get_palette_bsize_ctx(bsize); @@ -560,9 +581,7 @@ static void read_palette_mode_info(AV1_COMMON *const cm, MACROBLOCKD *const xd, read_palette_colors_y(xd, cm->seq_params.bit_depth, pmi, r); } } - if (num_planes > 1 && mbmi->uv_mode == UV_DC_PRED && - is_chroma_reference(mi_row, mi_col, bsize, xd->plane[1].subsampling_x, - xd->plane[1].subsampling_y)) { + if (num_planes > 1 && mbmi->uv_mode == UV_DC_PRED && xd->is_chroma_ref) { const int palette_uv_mode_ctx = (pmi->palette_size[0] > 0); const int modev = aom_read_symbol( r, xd->tile_ctx->palette_uv_mode_cdf[palette_uv_mode_ctx], 2, ACCT_STR); @@ -602,9 +621,8 @@ static void read_filter_intra_mode_info(const AV1_COMMON *const cm, void av1_read_tx_type(const AV1_COMMON *const cm, MACROBLOCKD *xd, int blk_row, int blk_col, TX_SIZE tx_size, aom_reader *r) { MB_MODE_INFO *mbmi = xd->mi[0]; - const int txk_type_idx = - av1_get_txk_type_index(mbmi->sb_type, blk_row, blk_col); - TX_TYPE *tx_type = &mbmi->txk_type[txk_type_idx]; + uint8_t *tx_type = + &xd->tx_type_map[blk_row * xd->tx_type_map_stride + blk_col]; *tx_type = DCT_DCT; // No need to read transform type if block is skipped. @@ -612,16 +630,16 @@ void av1_read_tx_type(const AV1_COMMON *const cm, MACROBLOCKD *xd, int blk_row, return; // No need to read transform type for lossless mode(qindex==0). - const int qindex = - cm->seg.enabled ? xd->qindex[mbmi->segment_id] : cm->base_qindex; - if (qindex <= 0) return; + const int qindex = xd->qindex[mbmi->segment_id]; + if (qindex == 0) return; const int inter_block = is_inter_block(mbmi); - if (get_ext_tx_types(tx_size, inter_block, cm->reduced_tx_set_used) > 1) { - const TxSetType tx_set_type = - av1_get_ext_tx_set_type(tx_size, inter_block, cm->reduced_tx_set_used); + if (get_ext_tx_types(tx_size, inter_block, cm->features.reduced_tx_set_used) > + 1) { + const TxSetType tx_set_type = av1_get_ext_tx_set_type( + tx_size, inter_block, cm->features.reduced_tx_set_used); const int eset = - get_ext_tx_set(tx_size, inter_block, cm->reduced_tx_set_used); + get_ext_tx_set(tx_size, inter_block, cm->features.reduced_tx_set_used); // eset == 0 should correspond to a set with only DCT_DCT and // there is no need to read the tx_type assert(eset != 0); @@ -667,7 +685,7 @@ static INLINE int assign_dv(AV1_COMMON *cm, MACROBLOCKD *xd, int_mv *mv, } static void read_intrabc_info(AV1_COMMON *const cm, MACROBLOCKD *const xd, - int mi_row, int mi_col, aom_reader *r) { + aom_reader *r) { MB_MODE_INFO *const mbmi = xd->mi[0]; FRAME_CONTEXT *ec_ctx = xd->tile_ctx; mbmi->use_intrabc = aom_read_symbol(r, ec_ctx->intrabc_cdf, 2, ACCT_STR); @@ -680,10 +698,9 @@ static void read_intrabc_info(AV1_COMMON *const cm, MACROBLOCKD *const xd, int16_t inter_mode_ctx[MODE_CTX_REF_FRAMES]; int_mv ref_mvs[INTRA_FRAME + 1][MAX_MV_REF_CANDIDATES]; - int_mv global_mvs[REF_FRAMES]; av1_find_mv_refs(cm, xd, mbmi, INTRA_FRAME, xd->ref_mv_count, - xd->ref_mv_stack, ref_mvs, global_mvs, mi_row, mi_col, + xd->ref_mv_stack, xd->weight, ref_mvs, /*global_mvs=*/NULL, inter_mode_ctx); int_mv nearestmv, nearmv; @@ -691,17 +708,17 @@ static void read_intrabc_info(AV1_COMMON *const cm, MACROBLOCKD *const xd, av1_find_best_ref_mvs(0, ref_mvs[INTRA_FRAME], &nearestmv, &nearmv, 0); int_mv dv_ref = nearestmv.as_int == 0 ? nearmv : nearestmv; if (dv_ref.as_int == 0) - av1_find_ref_dv(&dv_ref, &xd->tile, cm->seq_params.mib_size, mi_row, - mi_col); + av1_find_ref_dv(&dv_ref, &xd->tile, cm->seq_params.mib_size, xd->mi_row); // Ref DV should not have sub-pel. int valid_dv = (dv_ref.as_mv.col & 7) == 0 && (dv_ref.as_mv.row & 7) == 0; dv_ref.as_mv.col = (dv_ref.as_mv.col >> 3) * 8; dv_ref.as_mv.row = (dv_ref.as_mv.row >> 3) * 8; - valid_dv = valid_dv && assign_dv(cm, xd, &mbmi->mv[0], &dv_ref, mi_row, - mi_col, bsize, r); + valid_dv = valid_dv && assign_dv(cm, xd, &mbmi->mv[0], &dv_ref, xd->mi_row, + xd->mi_col, bsize, r); if (!valid_dv) { // Intra bc motion vectors are not valid - signal corrupt frame - aom_merge_corrupted_flag(&xd->corrupted, 1); + aom_internal_error(xd->error_info, AOM_CODEC_CORRUPT_FRAME, + "Invalid intrabc dv"); } } } @@ -709,17 +726,20 @@ static void read_intrabc_info(AV1_COMMON *const cm, MACROBLOCKD *const xd, // If delta q is present, reads delta_q index. // Also reads delta_q loop filter levels, if present. static void read_delta_q_params(AV1_COMMON *const cm, MACROBLOCKD *const xd, - const int mi_row, const int mi_col, aom_reader *r) { - if (cm->delta_q_present_flag) { + DeltaQInfo *const delta_q_info = &cm->delta_q_info; + + if (delta_q_info->delta_q_present_flag) { MB_MODE_INFO *const mbmi = xd->mi[0]; xd->current_qindex += - read_delta_qindex(cm, xd, r, mbmi, mi_col, mi_row) * cm->delta_q_res; + read_delta_qindex(cm, xd, r, mbmi) * delta_q_info->delta_q_res; /* Normative: Clamp to [1,MAXQ] to not interfere with lossless mode */ xd->current_qindex = clamp(xd->current_qindex, 1, MAXQ); FRAME_CONTEXT *const ec_ctx = xd->tile_ctx; - if (cm->delta_lf_present_flag) { - if (cm->delta_lf_multi) { + if (delta_q_info->delta_lf_present_flag) { + const int mi_row = xd->mi_row; + const int mi_col = xd->mi_col; + if (delta_q_info->delta_lf_multi) { const int frame_lf_count = av1_num_planes(cm) > 1 ? FRAME_LF_COUNT : FRAME_LF_COUNT - 2; for (int lf_id = 0; lf_id < frame_lf_count; ++lf_id) { @@ -727,7 +747,7 @@ static void read_delta_q_params(AV1_COMMON *const cm, MACROBLOCKD *const xd, xd->delta_lf[lf_id] + read_delta_lflevel(cm, r, ec_ctx->delta_lf_multi_cdf[lf_id], mbmi, mi_col, mi_row) * - cm->delta_lf_res; + delta_q_info->delta_lf_res; mbmi->delta_lf[lf_id] = xd->delta_lf[lf_id] = clamp(tmp_lvl, -MAX_LOOP_FILTER, MAX_LOOP_FILTER); } @@ -735,7 +755,7 @@ static void read_delta_q_params(AV1_COMMON *const cm, MACROBLOCKD *const xd, const int tmp_lvl = xd->delta_lf_from_base + read_delta_lflevel(cm, r, ec_ctx->delta_lf_cdf, mbmi, mi_col, mi_row) * - cm->delta_lf_res; + delta_q_info->delta_lf_res; mbmi->delta_lf_from_base = xd->delta_lf_from_base = clamp(tmp_lvl, -MAX_LOOP_FILTER, MAX_LOOP_FILTER); } @@ -744,8 +764,7 @@ static void read_delta_q_params(AV1_COMMON *const cm, MACROBLOCKD *const xd, } static void read_intra_frame_mode_info(AV1_COMMON *const cm, - MACROBLOCKD *const xd, int mi_row, - int mi_col, aom_reader *r) { + MACROBLOCKD *const xd, aom_reader *r) { MB_MODE_INFO *const mbmi = xd->mi[0]; const MB_MODE_INFO *above_mi = xd->above_mbmi; const MB_MODE_INFO *left_mi = xd->left_mbmi; @@ -755,18 +774,16 @@ static void read_intra_frame_mode_info(AV1_COMMON *const cm, FRAME_CONTEXT *ec_ctx = xd->tile_ctx; if (seg->segid_preskip) - mbmi->segment_id = - read_intra_segment_id(cm, xd, mi_row, mi_col, bsize, r, 0); + mbmi->segment_id = read_intra_segment_id(cm, xd, bsize, r, 0); mbmi->skip = read_skip(cm, xd, mbmi->segment_id, r); if (!seg->segid_preskip) - mbmi->segment_id = - read_intra_segment_id(cm, xd, mi_row, mi_col, bsize, r, mbmi->skip); + mbmi->segment_id = read_intra_segment_id(cm, xd, bsize, r, mbmi->skip); - read_cdef(cm, r, xd, mi_col, mi_row); + read_cdef(cm, r, xd); - read_delta_q_params(cm, xd, mi_row, mi_col, r); + read_delta_q_params(cm, xd, r); mbmi->current_qindex = xd->current_qindex; @@ -776,12 +793,14 @@ static void read_intra_frame_mode_info(AV1_COMMON *const cm, mbmi->palette_mode_info.palette_size[1] = 0; mbmi->filter_intra_mode_info.use_filter_intra = 0; - xd->above_txfm_context = cm->above_txfm_context[xd->tile.tile_row] + mi_col; + const int mi_row = xd->mi_row; + const int mi_col = xd->mi_col; + xd->above_txfm_context = cm->above_contexts.txfm[xd->tile.tile_row] + mi_col; xd->left_txfm_context = xd->left_txfm_context_buffer + (mi_row & MAX_MIB_MASK); if (av1_allow_intrabc(cm)) { - read_intrabc_info(cm, xd, mi_row, mi_col, r); + read_intrabc_info(cm, xd, r); if (is_intrabc_block(mbmi)) return; } @@ -793,10 +812,7 @@ static void read_intra_frame_mode_info(AV1_COMMON *const cm, ? read_angle_delta(r, ec_ctx->angle_delta_cdf[mbmi->mode - V_PRED]) : 0; - if (!cm->seq_params.monochrome && - is_chroma_reference(mi_row, mi_col, bsize, xd->plane[1].subsampling_x, - xd->plane[1].subsampling_y)) { - xd->cfl.is_chroma_reference = 1; + if (!cm->seq_params.monochrome && xd->is_chroma_ref) { mbmi->uv_mode = read_intra_mode_uv(ec_ctx, r, is_cfl_allowed(xd), mbmi->mode); if (mbmi->uv_mode == UV_CFL_PRED) { @@ -810,12 +826,11 @@ static void read_intra_frame_mode_info(AV1_COMMON *const cm, } else { // Avoid decoding angle_info if there is is no chroma prediction mbmi->uv_mode = UV_DC_PRED; - xd->cfl.is_chroma_reference = 0; } xd->cfl.store_y = store_cfl_required(cm, xd); - if (av1_allow_palette(cm->allow_screen_content_tools, bsize)) - read_palette_mode_info(cm, xd, mi_row, mi_col, r); + if (av1_allow_palette(cm->features.allow_screen_content_tools, bsize)) + read_palette_mode_info(cm, xd, r); read_filter_intra_mode_info(cm, xd, r); } @@ -882,14 +897,14 @@ static REFERENCE_MODE read_block_reference_mode(AV1_COMMON *cm, const MACROBLOCKD *xd, aom_reader *r) { if (!is_comp_ref_allowed(xd->mi[0]->sb_type)) return SINGLE_REFERENCE; - if (cm->reference_mode == REFERENCE_MODE_SELECT) { + if (cm->current_frame.reference_mode == REFERENCE_MODE_SELECT) { const int ctx = av1_get_reference_mode_context(xd); const REFERENCE_MODE mode = (REFERENCE_MODE)aom_read_symbol( r, xd->tile_ctx->comp_inter_cdf[ctx], 2, ACCT_STR); return mode; // SINGLE_REFERENCE or COMPOUND_REFERENCE } else { - assert(cm->reference_mode == SINGLE_REFERENCE); - return cm->reference_mode; + assert(cm->current_frame.reference_mode == SINGLE_REFERENCE); + return cm->current_frame.reference_mode; } } @@ -907,8 +922,8 @@ static COMP_REFERENCE_TYPE read_comp_reference_type(const MACROBLOCKD *xd, static void set_ref_frames_for_skip_mode(AV1_COMMON *const cm, MV_REFERENCE_FRAME ref_frame[2]) { - ref_frame[0] = LAST_FRAME + cm->ref_frame_idx_0; - ref_frame[1] = LAST_FRAME + cm->ref_frame_idx_1; + ref_frame[0] = LAST_FRAME + cm->current_frame.skip_mode_info.ref_frame_idx_0; + ref_frame[1] = LAST_FRAME + cm->current_frame.skip_mode_info.ref_frame_idx_1; } // Read the referncence frame @@ -966,19 +981,19 @@ static void read_ref_frames(AV1_COMMON *const cm, MACROBLOCKD *const xd, // Decode forward references. if (!bit) { const int bit1 = READ_REF_BIT(comp_ref_p1); - ref_frame[!idx] = cm->comp_fwd_ref[bit1 ? 1 : 0]; + ref_frame[!idx] = bit1 ? LAST2_FRAME : LAST_FRAME; } else { const int bit2 = READ_REF_BIT(comp_ref_p2); - ref_frame[!idx] = cm->comp_fwd_ref[bit2 ? 3 : 2]; + ref_frame[!idx] = bit2 ? GOLDEN_FRAME : LAST3_FRAME; } // Decode backward references. const int bit_bwd = READ_REF_BIT(comp_bwdref_p); if (!bit_bwd) { const int bit1_bwd = READ_REF_BIT(comp_bwdref_p1); - ref_frame[idx] = cm->comp_bwd_ref[bit1_bwd]; + ref_frame[idx] = bit1_bwd ? ALTREF2_FRAME : BWDREF_FRAME; } else { - ref_frame[idx] = cm->comp_bwd_ref[2]; + ref_frame[idx] = ALTREF_FRAME; } } else if (mode == SINGLE_REFERENCE) { const int bit0 = READ_REF_BIT(single_ref_p1); @@ -1008,38 +1023,39 @@ static void read_ref_frames(AV1_COMMON *const cm, MACROBLOCKD *const xd, } } -static INLINE void read_mb_interp_filter(AV1_COMMON *const cm, - MACROBLOCKD *const xd, +static INLINE void read_mb_interp_filter(const MACROBLOCKD *const xd, + InterpFilter interp_filter, + bool enable_dual_filter, MB_MODE_INFO *const mbmi, aom_reader *r) { FRAME_CONTEXT *ec_ctx = xd->tile_ctx; if (!av1_is_interp_needed(xd)) { - set_default_interp_filters(mbmi, cm->interp_filter); + set_default_interp_filters(mbmi, interp_filter); return; } - if (cm->interp_filter != SWITCHABLE) { - mbmi->interp_filters = av1_broadcast_interp_filter(cm->interp_filter); + if (interp_filter != SWITCHABLE) { + mbmi->interp_filters = av1_broadcast_interp_filter(interp_filter); } else { InterpFilter ref0_filter[2] = { EIGHTTAP_REGULAR, EIGHTTAP_REGULAR }; for (int dir = 0; dir < 2; ++dir) { const int ctx = av1_get_pred_context_switchable_interp(xd, dir); ref0_filter[dir] = (InterpFilter)aom_read_symbol( r, ec_ctx->switchable_interp_cdf[ctx], SWITCHABLE_FILTERS, ACCT_STR); - if (cm->seq_params.enable_dual_filter == 0) { + if (!enable_dual_filter) { ref0_filter[1] = ref0_filter[0]; break; } } // The index system works as: (0, 1) -> (vertical, horizontal) filter types - mbmi->interp_filters = - av1_make_interp_filters(ref0_filter[0], ref0_filter[1]); + mbmi->interp_filters.as_filters.x_filter = ref0_filter[1]; + mbmi->interp_filters.as_filters.y_filter = ref0_filter[0]; } } -static void read_intra_block_mode_info(AV1_COMMON *const cm, const int mi_row, - const int mi_col, MACROBLOCKD *const xd, +static void read_intra_block_mode_info(AV1_COMMON *const cm, + MACROBLOCKD *const xd, MB_MODE_INFO *const mbmi, aom_reader *r) { const BLOCK_SIZE bsize = mbmi->sb_type; @@ -1056,11 +1072,7 @@ static void read_intra_block_mode_info(AV1_COMMON *const cm, const int mi_row, use_angle_delta && av1_is_directional_mode(mbmi->mode) ? read_angle_delta(r, ec_ctx->angle_delta_cdf[mbmi->mode - V_PRED]) : 0; - const int has_chroma = - is_chroma_reference(mi_row, mi_col, bsize, xd->plane[1].subsampling_x, - xd->plane[1].subsampling_y); - xd->cfl.is_chroma_reference = has_chroma; - if (!cm->seq_params.monochrome && has_chroma) { + if (!cm->seq_params.monochrome && xd->is_chroma_ref) { mbmi->uv_mode = read_intra_mode_uv(ec_ctx, r, is_cfl_allowed(xd), mbmi->mode); if (mbmi->uv_mode == UV_CFL_PRED) { @@ -1080,8 +1092,8 @@ static void read_intra_block_mode_info(AV1_COMMON *const cm, const int mi_row, mbmi->palette_mode_info.palette_size[0] = 0; mbmi->palette_mode_info.palette_size[1] = 0; - if (av1_allow_palette(cm->allow_screen_content_tools, bsize)) - read_palette_mode_info(cm, xd, mi_row, mi_col, r); + if (av1_allow_palette(cm->features.allow_screen_content_tools, bsize)) + read_palette_mode_info(cm, xd, r); read_filter_intra_mode_info(cm, xd, r); } @@ -1095,12 +1107,13 @@ static INLINE int assign_mv(AV1_COMMON *cm, MACROBLOCKD *xd, PREDICTION_MODE mode, MV_REFERENCE_FRAME ref_frame[2], int_mv mv[2], int_mv ref_mv[2], int_mv nearest_mv[2], - int_mv near_mv[2], int mi_row, int mi_col, - int is_compound, int allow_hp, aom_reader *r) { + int_mv near_mv[2], int is_compound, int allow_hp, + aom_reader *r) { FRAME_CONTEXT *ec_ctx = xd->tile_ctx; MB_MODE_INFO *mbmi = xd->mi[0]; BLOCK_SIZE bsize = mbmi->sb_type; - if (cm->cur_frame_force_integer_mv) { + FeatureFlags *const features = &cm->features; + if (features->cur_frame_force_integer_mv) { allow_hp = MV_SUBPEL_NONE; } switch (mode) { @@ -1118,11 +1131,11 @@ static INLINE int assign_mv(AV1_COMMON *cm, MACROBLOCKD *xd, break; } case GLOBALMV: { - mv[0].as_int = - gm_get_motion_vector(&cm->global_motion[ref_frame[0]], - cm->allow_high_precision_mv, bsize, mi_col, - mi_row, cm->cur_frame_force_integer_mv) - .as_int; + mv[0].as_int = gm_get_motion_vector(&cm->global_motion[ref_frame[0]], + features->allow_high_precision_mv, + bsize, xd->mi_col, xd->mi_row, + features->cur_frame_force_integer_mv) + .as_int; break; } case NEW_NEWMV: { @@ -1175,16 +1188,16 @@ static INLINE int assign_mv(AV1_COMMON *cm, MACROBLOCKD *xd, } case GLOBAL_GLOBALMV: { assert(is_compound); - mv[0].as_int = - gm_get_motion_vector(&cm->global_motion[ref_frame[0]], - cm->allow_high_precision_mv, bsize, mi_col, - mi_row, cm->cur_frame_force_integer_mv) - .as_int; - mv[1].as_int = - gm_get_motion_vector(&cm->global_motion[ref_frame[1]], - cm->allow_high_precision_mv, bsize, mi_col, - mi_row, cm->cur_frame_force_integer_mv) - .as_int; + mv[0].as_int = gm_get_motion_vector(&cm->global_motion[ref_frame[0]], + features->allow_high_precision_mv, + bsize, xd->mi_col, xd->mi_row, + features->cur_frame_force_integer_mv) + .as_int; + mv[1].as_int = gm_get_motion_vector(&cm->global_motion[ref_frame[1]], + features->allow_high_precision_mv, + bsize, xd->mi_col, xd->mi_row, + features->cur_frame_force_integer_mv) + .as_int; break; } default: { return 0; } @@ -1231,16 +1244,16 @@ static void dec_dump_logs(AV1_COMMON *cm, MB_MODE_INFO *const mbmi, int mi_row, } #define FRAME_TO_CHECK 11 - if (cm->current_video_frame == FRAME_TO_CHECK && cm->show_frame == 1) { + if (cm->current_frame.frame_number == FRAME_TO_CHECK && cm->show_frame == 1) { printf( "=== DECODER ===: " "Frame=%d, (mi_row,mi_col)=(%d,%d), skip_mode=%d, mode=%d, bsize=%d, " "show_frame=%d, mv[0]=(%d,%d), mv[1]=(%d,%d), ref[0]=%d, " "ref[1]=%d, motion_mode=%d, mode_ctx=%d, " "newmv_ctx=%d, zeromv_ctx=%d, refmv_ctx=%d, tx_size=%d\n", - cm->current_video_frame, mi_row, mi_col, mbmi->skip_mode, mbmi->mode, - mbmi->sb_type, cm->show_frame, mv[0].as_mv.row, mv[0].as_mv.col, - mv[1].as_mv.row, mv[1].as_mv.col, mbmi->ref_frame[0], + cm->current_frame.frame_number, mi_row, mi_col, mbmi->skip_mode, + mbmi->mode, mbmi->sb_type, cm->show_frame, mv[0].as_mv.row, + mv[0].as_mv.col, mv[1].as_mv.row, mv[1].as_mv.col, mbmi->ref_frame[0], mbmi->ref_frame[1], mbmi->motion_mode, mode_ctx, newmv_ctx, zeromv_ctx, refmv_ctx, mbmi->tx_size); } @@ -1249,11 +1262,12 @@ static void dec_dump_logs(AV1_COMMON *cm, MB_MODE_INFO *const mbmi, int mi_row, static void read_inter_block_mode_info(AV1Decoder *const pbi, MACROBLOCKD *const xd, - MB_MODE_INFO *const mbmi, int mi_row, - int mi_col, aom_reader *r) { + MB_MODE_INFO *const mbmi, + aom_reader *r) { AV1_COMMON *const cm = &pbi->common; + FeatureFlags *const features = &cm->features; const BLOCK_SIZE bsize = mbmi->sb_type; - const int allow_hp = cm->allow_high_precision_mv; + const int allow_hp = features->allow_high_precision_mv; int_mv nearestmv[2], nearmv[2]; int_mv ref_mvs[MODE_CTX_REF_FRAMES][MAX_MV_REF_CANDIDATES] = { { { 0 } } }; int16_t inter_mode_ctx[MODE_CTX_REF_FRAMES]; @@ -1269,12 +1283,10 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi, read_ref_frames(cm, xd, r, mbmi->segment_id, mbmi->ref_frame); const int is_compound = has_second_ref(mbmi); - MV_REFERENCE_FRAME ref_frame = av1_ref_frame_type(mbmi->ref_frame); - int_mv global_mvs[REF_FRAMES]; + const MV_REFERENCE_FRAME ref_frame = av1_ref_frame_type(mbmi->ref_frame); av1_find_mv_refs(cm, xd, mbmi, ref_frame, xd->ref_mv_count, xd->ref_mv_stack, - ref_mvs, global_mvs, mi_row, mi_col, inter_mode_ctx); + xd->weight, ref_mvs, /*global_mvs=*/NULL, inter_mode_ctx); - int mode_ctx = av1_mode_context_analyzer(inter_mode_ctx, mbmi->ref_frame); mbmi->ref_mv_idx = 0; if (mbmi->skip_mode) { @@ -1285,6 +1297,8 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi, segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_GLOBALMV)) { mbmi->mode = GLOBALMV; } else { + const int mode_ctx = + av1_mode_context_analyzer(inter_mode_ctx, mbmi->ref_frame); if (is_compound) mbmi->mode = read_inter_compound_mode(xd, r, mode_ctx); else @@ -1303,32 +1317,29 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi, if (!is_compound && mbmi->mode != GLOBALMV) { av1_find_best_ref_mvs(allow_hp, ref_mvs[mbmi->ref_frame[0]], &nearestmv[0], - &nearmv[0], cm->cur_frame_force_integer_mv); + &nearmv[0], features->cur_frame_force_integer_mv); } if (is_compound && mbmi->mode != GLOBAL_GLOBALMV) { - int ref_mv_idx = mbmi->ref_mv_idx + 1; + const int ref_mv_idx = mbmi->ref_mv_idx + 1; nearestmv[0] = xd->ref_mv_stack[ref_frame][0].this_mv; nearestmv[1] = xd->ref_mv_stack[ref_frame][0].comp_mv; nearmv[0] = xd->ref_mv_stack[ref_frame][ref_mv_idx].this_mv; nearmv[1] = xd->ref_mv_stack[ref_frame][ref_mv_idx].comp_mv; lower_mv_precision(&nearestmv[0].as_mv, allow_hp, - cm->cur_frame_force_integer_mv); + features->cur_frame_force_integer_mv); lower_mv_precision(&nearestmv[1].as_mv, allow_hp, - cm->cur_frame_force_integer_mv); + features->cur_frame_force_integer_mv); lower_mv_precision(&nearmv[0].as_mv, allow_hp, - cm->cur_frame_force_integer_mv); + features->cur_frame_force_integer_mv); lower_mv_precision(&nearmv[1].as_mv, allow_hp, - cm->cur_frame_force_integer_mv); + features->cur_frame_force_integer_mv); } else if (mbmi->ref_mv_idx > 0 && mbmi->mode == NEARMV) { - int_mv cur_mv = + nearmv[0] = xd->ref_mv_stack[mbmi->ref_frame[0]][1 + mbmi->ref_mv_idx].this_mv; - nearmv[0] = cur_mv; } - int_mv ref_mv[2]; - ref_mv[0] = nearestmv[0]; - ref_mv[1] = nearestmv[1]; + int_mv ref_mv[2] = { nearestmv[0], nearestmv[1] }; if (is_compound) { int ref_mv_idx = mbmi->ref_mv_idx; @@ -1351,16 +1362,12 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi, } } - if (mbmi->skip_mode) { - assert(mbmi->mode == NEAREST_NEARESTMV); - mbmi->mv[0].as_int = nearestmv[0].as_int; - mbmi->mv[1].as_int = nearestmv[1].as_int; - } else { - int mv_corrupted_flag = - !assign_mv(cm, xd, mbmi->mode, mbmi->ref_frame, mbmi->mv, ref_mv, - nearestmv, nearmv, mi_row, mi_col, is_compound, allow_hp, r); - aom_merge_corrupted_flag(&xd->corrupted, mv_corrupted_flag); - } + if (mbmi->skip_mode) assert(mbmi->mode == NEAREST_NEARESTMV); + + const int mv_corrupted_flag = + !assign_mv(cm, xd, mbmi->mode, mbmi->ref_frame, mbmi->mv, ref_mv, + nearestmv, nearmv, is_compound, allow_hp, r); + aom_merge_corrupted_flag(&xd->corrupted, mv_corrupted_flag); mbmi->use_wedge_interintra = 0; if (cm->seq_params.enable_interintra_compound && !mbmi->skip_mode && @@ -1377,13 +1384,12 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi, mbmi->angle_delta[PLANE_TYPE_Y] = 0; mbmi->angle_delta[PLANE_TYPE_UV] = 0; mbmi->filter_intra_mode_info.use_filter_intra = 0; - if (is_interintra_wedge_used(bsize)) { + if (av1_is_wedge_used(bsize)) { mbmi->use_wedge_interintra = aom_read_symbol( r, ec_ctx->wedge_interintra_cdf[bsize], 2, ACCT_STR); if (mbmi->use_wedge_interintra) { - mbmi->interintra_wedge_index = - aom_read_symbol(r, ec_ctx->wedge_idx_cdf[bsize], 16, ACCT_STR); - mbmi->interintra_wedge_sign = 0; + mbmi->interintra_wedge_index = (int8_t)aom_read_symbol( + r, ec_ctx->wedge_idx_cdf[bsize], MAX_WEDGE_TYPES, ACCT_STR); } } } @@ -1391,16 +1397,15 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi, for (int ref = 0; ref < 1 + has_second_ref(mbmi); ++ref) { const MV_REFERENCE_FRAME frame = mbmi->ref_frame[ref]; - RefBuffer *ref_buf = &cm->frame_refs[frame - LAST_FRAME]; - - xd->block_refs[ref] = ref_buf; + xd->block_ref_scale_factors[ref] = get_ref_scale_factors_const(cm, frame); } mbmi->motion_mode = SIMPLE_TRANSLATION; if (is_motion_variation_allowed_bsize(mbmi->sb_type) && !mbmi->skip_mode && - !has_second_ref(mbmi)) - mbmi->num_proj_ref = findSamples(cm, xd, mi_row, mi_col, pts, pts_inref); - av1_count_overlappable_neighbors(cm, xd, mi_row, mi_col); + !has_second_ref(mbmi)) { + mbmi->num_proj_ref = av1_findSamples(cm, xd, pts, pts_inref); + } + av1_count_overlappable_neighbors(cm, xd); if (mbmi->ref_frame[1] != INTRA_FRAME) mbmi->motion_mode = read_motion_mode(cm, xd, mbmi, r); @@ -1417,38 +1422,43 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi, if (masked_compound_used) { const int ctx_comp_group_idx = get_comp_group_idx_context(xd); - mbmi->comp_group_idx = aom_read_symbol( + mbmi->comp_group_idx = (uint8_t)aom_read_symbol( r, ec_ctx->comp_group_idx_cdf[ctx_comp_group_idx], 2, ACCT_STR); } if (mbmi->comp_group_idx == 0) { - if (cm->seq_params.enable_jnt_comp) { + if (cm->seq_params.order_hint_info.enable_dist_wtd_comp) { const int comp_index_ctx = get_comp_index_context(cm, xd); - mbmi->compound_idx = aom_read_symbol( + mbmi->compound_idx = (uint8_t)aom_read_symbol( r, ec_ctx->compound_index_cdf[comp_index_ctx], 2, ACCT_STR); + mbmi->interinter_comp.type = + mbmi->compound_idx ? COMPOUND_AVERAGE : COMPOUND_DISTWTD; } else { // Distance-weighted compound is disabled, so always use average mbmi->compound_idx = 1; + mbmi->interinter_comp.type = COMPOUND_AVERAGE; } } else { - assert(cm->reference_mode != SINGLE_REFERENCE && + assert(cm->current_frame.reference_mode != SINGLE_REFERENCE && is_inter_compound_mode(mbmi->mode) && mbmi->motion_mode == SIMPLE_TRANSLATION); assert(masked_compound_used); // compound_diffwtd, wedge - if (is_interinter_compound_used(COMPOUND_WEDGE, bsize)) + if (is_interinter_compound_used(COMPOUND_WEDGE, bsize)) { mbmi->interinter_comp.type = - 1 + aom_read_symbol(r, ec_ctx->compound_type_cdf[bsize], - COMPOUND_TYPES - 1, ACCT_STR); - else + COMPOUND_WEDGE + aom_read_symbol(r, + ec_ctx->compound_type_cdf[bsize], + MASKED_COMPOUND_TYPES, ACCT_STR); + } else { mbmi->interinter_comp.type = COMPOUND_DIFFWTD; + } if (mbmi->interinter_comp.type == COMPOUND_WEDGE) { assert(is_interinter_compound_used(COMPOUND_WEDGE, bsize)); - mbmi->interinter_comp.wedge_index = - aom_read_symbol(r, ec_ctx->wedge_idx_cdf[bsize], 16, ACCT_STR); - mbmi->interinter_comp.wedge_sign = aom_read_bit(r, ACCT_STR); + mbmi->interinter_comp.wedge_index = (int8_t)aom_read_symbol( + r, ec_ctx->wedge_idx_cdf[bsize], MAX_WEDGE_TYPES, ACCT_STR); + mbmi->interinter_comp.wedge_sign = (int8_t)aom_read_bit(r, ACCT_STR); } else { assert(mbmi->interinter_comp.type == COMPOUND_DIFFWTD); mbmi->interinter_comp.mask_type = @@ -1457,19 +1467,24 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi, } } - read_mb_interp_filter(cm, xd, mbmi, r); + read_mb_interp_filter(xd, features->interp_filter, + cm->seq_params.enable_dual_filter, mbmi, r); + + const int mi_row = xd->mi_row; + const int mi_col = xd->mi_col; if (mbmi->motion_mode == WARPED_CAUSAL) { mbmi->wm_params.wmtype = DEFAULT_WMTYPE; mbmi->wm_params.invalid = 0; - if (mbmi->num_proj_ref > 1) - mbmi->num_proj_ref = selectSamples(&mbmi->mv[0].as_mv, pts, pts_inref, - mbmi->num_proj_ref, bsize); + if (mbmi->num_proj_ref > 1) { + mbmi->num_proj_ref = av1_selectSamples(&mbmi->mv[0].as_mv, pts, pts_inref, + mbmi->num_proj_ref, bsize); + } - if (find_projection(mbmi->num_proj_ref, pts, pts_inref, bsize, - mbmi->mv[0].as_mv.row, mbmi->mv[0].as_mv.col, - &mbmi->wm_params, mi_row, mi_col)) { + if (av1_find_projection(mbmi->num_proj_ref, pts, pts_inref, bsize, + mbmi->mv[0].as_mv.row, mbmi->mv[0].as_mv.col, + &mbmi->wm_params, mi_row, mi_col)) { #if WARPED_MOTION_DEBUG printf("Warning: unexpected warped model from aomenc\n"); #endif @@ -1477,9 +1492,6 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi, } } - xd->cfl.is_chroma_reference = - is_chroma_reference(mi_row, mi_col, bsize, cm->seq_params.subsampling_x, - cm->seq_params.subsampling_y); xd->cfl.store_y = store_cfl_required(cm, xd); #if DEC_MISMATCH_DEBUG @@ -1488,15 +1500,14 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi, } static void read_inter_frame_mode_info(AV1Decoder *const pbi, - MACROBLOCKD *const xd, int mi_row, - int mi_col, aom_reader *r) { + MACROBLOCKD *const xd, aom_reader *r) { AV1_COMMON *const cm = &pbi->common; MB_MODE_INFO *const mbmi = xd->mi[0]; int inter_block = 1; mbmi->mv[0].as_int = 0; mbmi->mv[1].as_int = 0; - mbmi->segment_id = read_inter_segment_id(cm, xd, mi_row, mi_col, 1, r); + mbmi->segment_id = read_inter_segment_id(cm, xd, 1, r); mbmi->skip_mode = read_skip_mode(cm, xd, mbmi->segment_id, r); @@ -1505,30 +1516,32 @@ static void read_inter_frame_mode_info(AV1Decoder *const pbi, else mbmi->skip = read_skip(cm, xd, mbmi->segment_id, r); - mbmi->segment_id = read_inter_segment_id(cm, xd, mi_row, mi_col, 0, r); + if (!cm->seg.segid_preskip) + mbmi->segment_id = read_inter_segment_id(cm, xd, 0, r); - read_cdef(cm, r, xd, mi_col, mi_row); + read_cdef(cm, r, xd); - read_delta_q_params(cm, xd, mi_row, mi_col, r); + read_delta_q_params(cm, xd, r); if (!mbmi->skip_mode) inter_block = read_is_inter_block(cm, xd, mbmi->segment_id, r); mbmi->current_qindex = xd->current_qindex; - xd->above_txfm_context = cm->above_txfm_context[xd->tile.tile_row] + mi_col; + xd->above_txfm_context = + cm->above_contexts.txfm[xd->tile.tile_row] + xd->mi_col; xd->left_txfm_context = - xd->left_txfm_context_buffer + (mi_row & MAX_MIB_MASK); + xd->left_txfm_context_buffer + (xd->mi_row & MAX_MIB_MASK); if (inter_block) - read_inter_block_mode_info(pbi, xd, mbmi, mi_row, mi_col, r); + read_inter_block_mode_info(pbi, xd, mbmi, r); else - read_intra_block_mode_info(cm, mi_row, mi_col, xd, mbmi, r); + read_intra_block_mode_info(cm, xd, mbmi, r); } static void intra_copy_frame_mvs(AV1_COMMON *const cm, int mi_row, int mi_col, int x_mis, int y_mis) { - const int frame_mvs_stride = ROUND_POWER_OF_TWO(cm->mi_cols, 1); + const int frame_mvs_stride = ROUND_POWER_OF_TWO(cm->mi_params.mi_cols, 1); MV_REF *frame_mvs = cm->cur_frame->mvs + (mi_row >> 1) * frame_mvs_stride + (mi_col >> 1); x_mis = ROUND_POWER_OF_TWO(x_mis, 1); @@ -1544,17 +1557,19 @@ static void intra_copy_frame_mvs(AV1_COMMON *const cm, int mi_row, int mi_col, } } -void av1_read_mode_info(AV1Decoder *const pbi, MACROBLOCKD *xd, int mi_row, - int mi_col, aom_reader *r, int x_mis, int y_mis) { +void av1_read_mode_info(AV1Decoder *const pbi, MACROBLOCKD *xd, aom_reader *r, + int x_mis, int y_mis) { AV1_COMMON *const cm = &pbi->common; MB_MODE_INFO *const mi = xd->mi[0]; mi->use_intrabc = 0; if (frame_is_intra_only(cm)) { - read_intra_frame_mode_info(cm, xd, mi_row, mi_col, r); - intra_copy_frame_mvs(cm, mi_row, mi_col, x_mis, y_mis); + read_intra_frame_mode_info(cm, xd, r); + if (pbi->common.seq_params.order_hint_info.enable_ref_frame_mvs) + intra_copy_frame_mvs(cm, xd->mi_row, xd->mi_col, x_mis, y_mis); } else { - read_inter_frame_mode_info(pbi, xd, mi_row, mi_col, r); - av1_copy_frame_mvs(cm, mi, mi_row, mi_col, x_mis, y_mis); + read_inter_frame_mode_info(pbi, xd, r); + if (pbi->common.seq_params.order_hint_info.enable_ref_frame_mvs) + av1_copy_frame_mvs(cm, mi, xd->mi_row, xd->mi_col, x_mis, y_mis); } } |