| OLD | NEW |
| 1 /* | 1 /* |
| 2 Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 | 11 |
| 12 #include "vp9/decoder/vp9_treereader.h" | 12 #include "vp9/decoder/vp9_treereader.h" |
| 13 #include "vp9/common/vp9_entropymv.h" | 13 #include "vp9/common/vp9_entropymv.h" |
| 14 #include "vp9/common/vp9_entropymode.h" | 14 #include "vp9/common/vp9_entropymode.h" |
| 15 #include "vp9/decoder/vp9_onyxd_int.h" | 15 #include "vp9/decoder/vp9_onyxd_int.h" |
| 16 #include "vp9/common/vp9_findnearmv.h" | 16 #include "vp9/common/vp9_findnearmv.h" |
| 17 | 17 #include "vp9/common/vp9_common.h" |
| 18 #include "vp9/common/vp9_seg_common.h" | 18 #include "vp9/common/vp9_seg_common.h" |
| 19 #include "vp9/common/vp9_pred_common.h" | 19 #include "vp9/common/vp9_pred_common.h" |
| 20 #include "vp9/common/vp9_entropy.h" | 20 #include "vp9/common/vp9_entropy.h" |
| 21 #include "vp9/decoder/vp9_decodemv.h" | 21 #include "vp9/decoder/vp9_decodemv.h" |
| 22 #include "vp9/common/vp9_mvref_common.h" | 22 #include "vp9/common/vp9_mvref_common.h" |
| 23 #if CONFIG_DEBUG | 23 #if CONFIG_DEBUG |
| 24 #include <assert.h> | 24 #include <assert.h> |
| 25 #endif | 25 #endif |
| 26 | 26 |
| 27 // #define DEBUG_DEC_MV | 27 // #define DEBUG_DEC_MV |
| (...skipping 16 matching lines...) Expand all Loading... |
| 44 } | 44 } |
| 45 | 45 |
| 46 static int read_kf_bmode(vp9_reader *bc, const vp9_prob *p) { | 46 static int read_kf_bmode(vp9_reader *bc, const vp9_prob *p) { |
| 47 return treed_read(bc, vp9_kf_bmode_tree, p); | 47 return treed_read(bc, vp9_kf_bmode_tree, p); |
| 48 } | 48 } |
| 49 | 49 |
| 50 static int read_ymode(vp9_reader *bc, const vp9_prob *p) { | 50 static int read_ymode(vp9_reader *bc, const vp9_prob *p) { |
| 51 return treed_read(bc, vp9_ymode_tree, p); | 51 return treed_read(bc, vp9_ymode_tree, p); |
| 52 } | 52 } |
| 53 | 53 |
| 54 #if CONFIG_SUPERBLOCKS | |
| 55 static int read_sb_ymode(vp9_reader *bc, const vp9_prob *p) { | 54 static int read_sb_ymode(vp9_reader *bc, const vp9_prob *p) { |
| 56 return treed_read(bc, vp9_sb_ymode_tree, p); | 55 return treed_read(bc, vp9_sb_ymode_tree, p); |
| 57 } | 56 } |
| 58 | 57 |
| 59 static int read_kf_sb_ymode(vp9_reader *bc, const vp9_prob *p) { | 58 static int read_kf_sb_ymode(vp9_reader *bc, const vp9_prob *p) { |
| 60 return treed_read(bc, vp9_uv_mode_tree, p); | 59 return treed_read(bc, vp9_uv_mode_tree, p); |
| 61 } | 60 } |
| 62 #endif | |
| 63 | 61 |
| 64 static int read_kf_mb_ymode(vp9_reader *bc, const vp9_prob *p) { | 62 static int read_kf_mb_ymode(vp9_reader *bc, const vp9_prob *p) { |
| 65 return treed_read(bc, vp9_kf_ymode_tree, p); | 63 return treed_read(bc, vp9_kf_ymode_tree, p); |
| 66 } | 64 } |
| 67 | 65 |
| 68 static int read_i8x8_mode(vp9_reader *bc, const vp9_prob *p) { | 66 static int read_i8x8_mode(vp9_reader *bc, const vp9_prob *p) { |
| 69 return treed_read(bc, vp9_i8x8_mode_tree, p); | 67 return treed_read(bc, vp9_i8x8_mode_tree, p); |
| 70 } | 68 } |
| 71 | 69 |
| 72 static int read_uv_mode(vp9_reader *bc, const vp9_prob *p) { | 70 static int read_uv_mode(vp9_reader *bc, const vp9_prob *p) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 VP9_COMMON *const cm = &pbi->common; | 113 VP9_COMMON *const cm = &pbi->common; |
| 116 const int mis = pbi->common.mode_info_stride; | 114 const int mis = pbi->common.mode_info_stride; |
| 117 int map_index = mb_row * pbi->common.mb_cols + mb_col; | 115 int map_index = mb_row * pbi->common.mb_cols + mb_col; |
| 118 MB_PREDICTION_MODE y_mode; | 116 MB_PREDICTION_MODE y_mode; |
| 119 | 117 |
| 120 // Read the Macroblock segmentation map if it is being updated explicitly | 118 // Read the Macroblock segmentation map if it is being updated explicitly |
| 121 // this frame (reset to 0 by default). | 119 // this frame (reset to 0 by default). |
| 122 m->mbmi.segment_id = 0; | 120 m->mbmi.segment_id = 0; |
| 123 if (pbi->mb.update_mb_segmentation_map) { | 121 if (pbi->mb.update_mb_segmentation_map) { |
| 124 read_mb_segid(bc, &m->mbmi, &pbi->mb); | 122 read_mb_segid(bc, &m->mbmi, &pbi->mb); |
| 125 pbi->common.last_frame_seg_map[map_index] = m->mbmi.segment_id; | 123 if (m->mbmi.sb_type) { |
| 124 const int nmbs = 1 << m->mbmi.sb_type; |
| 125 const int ymbs = MIN(cm->mb_rows - mb_row, nmbs); |
| 126 const int xmbs = MIN(cm->mb_cols - mb_col, nmbs); |
| 127 int x, y; |
| 128 |
| 129 for (y = 0; y < ymbs; y++) { |
| 130 for (x = 0; x < xmbs; x++) { |
| 131 cm->last_frame_seg_map[map_index + x + y * cm->mb_cols] = |
| 132 m->mbmi.segment_id; |
| 133 } |
| 134 } |
| 135 } else { |
| 136 cm->last_frame_seg_map[map_index] = m->mbmi.segment_id; |
| 137 } |
| 126 } | 138 } |
| 127 | 139 |
| 128 m->mbmi.mb_skip_coeff = 0; | 140 m->mbmi.mb_skip_coeff = 0; |
| 129 if (pbi->common.mb_no_coeff_skip && | 141 if (pbi->common.mb_no_coeff_skip && |
| 130 (!vp9_segfeature_active(&pbi->mb, | 142 (!vp9_segfeature_active(&pbi->mb, |
| 131 m->mbmi.segment_id, SEG_LVL_EOB) || | 143 m->mbmi.segment_id, SEG_LVL_EOB) || |
| 132 (vp9_get_segdata(&pbi->mb, | 144 (vp9_get_segdata(&pbi->mb, |
| 133 m->mbmi.segment_id, SEG_LVL_EOB) != 0))) { | 145 m->mbmi.segment_id, SEG_LVL_EOB) != 0))) { |
| 134 MACROBLOCKD *const xd = &pbi->mb; | 146 MACROBLOCKD *const xd = &pbi->mb; |
| 135 m->mbmi.mb_skip_coeff = | 147 m->mbmi.mb_skip_coeff = |
| 136 vp9_read(bc, vp9_get_pred_prob(cm, xd, PRED_MBSKIP)); | 148 vp9_read(bc, vp9_get_pred_prob(cm, xd, PRED_MBSKIP)); |
| 137 } else { | 149 } else { |
| 138 if (vp9_segfeature_active(&pbi->mb, | 150 if (vp9_segfeature_active(&pbi->mb, |
| 139 m->mbmi.segment_id, SEG_LVL_EOB) && | 151 m->mbmi.segment_id, SEG_LVL_EOB) && |
| 140 (vp9_get_segdata(&pbi->mb, | 152 (vp9_get_segdata(&pbi->mb, |
| 141 m->mbmi.segment_id, SEG_LVL_EOB) == 0)) { | 153 m->mbmi.segment_id, SEG_LVL_EOB) == 0)) { |
| 142 m->mbmi.mb_skip_coeff = 1; | 154 m->mbmi.mb_skip_coeff = 1; |
| 143 } else | 155 } else |
| 144 m->mbmi.mb_skip_coeff = 0; | 156 m->mbmi.mb_skip_coeff = 0; |
| 145 } | 157 } |
| 146 | 158 |
| 147 #if CONFIG_SUPERBLOCKS | 159 if (m->mbmi.sb_type) { |
| 148 if (m->mbmi.encoded_as_sb) { | |
| 149 y_mode = (MB_PREDICTION_MODE) read_kf_sb_ymode(bc, | 160 y_mode = (MB_PREDICTION_MODE) read_kf_sb_ymode(bc, |
| 150 pbi->common.sb_kf_ymode_prob[pbi->common.kf_ymode_probs_index]); | 161 pbi->common.sb_kf_ymode_prob[pbi->common.kf_ymode_probs_index]); |
| 151 } else | 162 } else { |
| 152 #endif | 163 y_mode = (MB_PREDICTION_MODE) read_kf_mb_ymode(bc, |
| 153 y_mode = (MB_PREDICTION_MODE) read_kf_mb_ymode(bc, | 164 pbi->common.kf_ymode_prob[pbi->common.kf_ymode_probs_index]); |
| 154 pbi->common.kf_ymode_prob[pbi->common.kf_ymode_probs_index]); | 165 } |
| 155 #if CONFIG_COMP_INTRA_PRED | |
| 156 m->mbmi.second_mode = (MB_PREDICTION_MODE)(DC_PRED - 1); | |
| 157 #endif | |
| 158 | 166 |
| 159 m->mbmi.ref_frame = INTRA_FRAME; | 167 m->mbmi.ref_frame = INTRA_FRAME; |
| 160 | 168 |
| 161 if ((m->mbmi.mode = y_mode) == B_PRED) { | 169 if ((m->mbmi.mode = y_mode) == B_PRED) { |
| 162 int i = 0; | 170 int i = 0; |
| 163 #if CONFIG_COMP_INTRA_PRED | |
| 164 int use_comp_pred = vp9_read(bc, DEFAULT_COMP_INTRA_PROB); | |
| 165 #endif | |
| 166 do { | 171 do { |
| 167 const B_PREDICTION_MODE A = above_block_mode(m, i, mis); | 172 const B_PREDICTION_MODE A = above_block_mode(m, i, mis); |
| 168 const B_PREDICTION_MODE L = left_block_mode(m, i); | 173 const B_PREDICTION_MODE L = left_block_mode(m, i); |
| 169 | 174 |
| 170 m->bmi[i].as_mode.first = | 175 m->bmi[i].as_mode.first = |
| 171 (B_PREDICTION_MODE) read_kf_bmode( | 176 (B_PREDICTION_MODE) read_kf_bmode( |
| 172 bc, pbi->common.kf_bmode_prob [A] [L]); | 177 bc, pbi->common.kf_bmode_prob [A] [L]); |
| 173 #if CONFIG_COMP_INTRA_PRED | |
| 174 if (use_comp_pred) { | |
| 175 m->bmi[i].as_mode.second = | |
| 176 (B_PREDICTION_MODE) read_kf_bmode( | |
| 177 bc, pbi->common.kf_bmode_prob [A] [L]); | |
| 178 } else { | |
| 179 m->bmi[i].as_mode.second = (B_PREDICTION_MODE)(B_DC_PRED - 1); | |
| 180 } | |
| 181 #endif | |
| 182 } while (++i < 16); | 178 } while (++i < 16); |
| 183 } | 179 } |
| 184 if ((m->mbmi.mode = y_mode) == I8X8_PRED) { | 180 if ((m->mbmi.mode = y_mode) == I8X8_PRED) { |
| 185 int i; | 181 int i; |
| 186 int mode8x8; | 182 int mode8x8; |
| 187 for (i = 0; i < 4; i++) { | 183 for (i = 0; i < 4; i++) { |
| 188 int ib = vp9_i8x8_block[i]; | 184 int ib = vp9_i8x8_block[i]; |
| 189 mode8x8 = read_i8x8_mode(bc, pbi->common.fc.i8x8_mode_prob); | 185 mode8x8 = read_i8x8_mode(bc, pbi->common.fc.i8x8_mode_prob); |
| 190 m->bmi[ib + 0].as_mode.first = mode8x8; | 186 m->bmi[ib + 0].as_mode.first = mode8x8; |
| 191 m->bmi[ib + 1].as_mode.first = mode8x8; | 187 m->bmi[ib + 1].as_mode.first = mode8x8; |
| 192 m->bmi[ib + 4].as_mode.first = mode8x8; | 188 m->bmi[ib + 4].as_mode.first = mode8x8; |
| 193 m->bmi[ib + 5].as_mode.first = mode8x8; | 189 m->bmi[ib + 5].as_mode.first = mode8x8; |
| 194 #if CONFIG_COMP_INTRA_PRED | |
| 195 m->bmi[ib + 0].as_mode.second = (MB_PREDICTION_MODE)(DC_PRED - 1); | |
| 196 m->bmi[ib + 1].as_mode.second = (MB_PREDICTION_MODE)(DC_PRED - 1); | |
| 197 m->bmi[ib + 4].as_mode.second = (MB_PREDICTION_MODE)(DC_PRED - 1); | |
| 198 m->bmi[ib + 5].as_mode.second = (MB_PREDICTION_MODE)(DC_PRED - 1); | |
| 199 #endif | |
| 200 } | 190 } |
| 201 } else | 191 } else |
| 202 m->mbmi.uv_mode = (MB_PREDICTION_MODE)read_uv_mode(bc, | 192 m->mbmi.uv_mode = (MB_PREDICTION_MODE)read_uv_mode(bc, |
| 203 pbi->common.kf_uv_mode_pr
ob[m->mbmi.mode]); | 193 pbi->common.kf_uv_mode_pr
ob[m->mbmi.mode]); |
| 204 #if CONFIG_COMP_INTRA_PRED | |
| 205 m->mbmi.second_uv_mode = (MB_PREDICTION_MODE)(DC_PRED - 1); | |
| 206 #endif | |
| 207 | 194 |
| 208 if (cm->txfm_mode == TX_MODE_SELECT && m->mbmi.mb_skip_coeff == 0 && | 195 if (cm->txfm_mode == TX_MODE_SELECT && m->mbmi.mb_skip_coeff == 0 && |
| 209 m->mbmi.mode <= I8X8_PRED) { | 196 m->mbmi.mode <= I8X8_PRED) { |
| 210 // FIXME(rbultje) code ternary symbol once all experiments are merged | 197 // FIXME(rbultje) code ternary symbol once all experiments are merged |
| 211 m->mbmi.txfm_size = vp9_read(bc, cm->prob_tx[0]); | 198 m->mbmi.txfm_size = vp9_read(bc, cm->prob_tx[0]); |
| 212 if (m->mbmi.txfm_size != TX_4X4 && m->mbmi.mode != I8X8_PRED) | 199 if (m->mbmi.txfm_size != TX_4X4 && m->mbmi.mode != I8X8_PRED) { |
| 213 m->mbmi.txfm_size += vp9_read(bc, cm->prob_tx[1]); | 200 m->mbmi.txfm_size += vp9_read(bc, cm->prob_tx[1]); |
| 201 if (m->mbmi.txfm_size != TX_8X8 && m->mbmi.sb_type) |
| 202 m->mbmi.txfm_size += vp9_read(bc, cm->prob_tx[2]); |
| 203 } |
| 204 } else if (cm->txfm_mode >= ALLOW_32X32 && m->mbmi.sb_type) { |
| 205 m->mbmi.txfm_size = TX_32X32; |
| 214 } else if (cm->txfm_mode >= ALLOW_16X16 && m->mbmi.mode <= TM_PRED) { | 206 } else if (cm->txfm_mode >= ALLOW_16X16 && m->mbmi.mode <= TM_PRED) { |
| 215 m->mbmi.txfm_size = TX_16X16; | 207 m->mbmi.txfm_size = TX_16X16; |
| 216 } else if (cm->txfm_mode >= ALLOW_8X8 && m->mbmi.mode != B_PRED) { | 208 } else if (cm->txfm_mode >= ALLOW_8X8 && m->mbmi.mode != B_PRED) { |
| 217 m->mbmi.txfm_size = TX_8X8; | 209 m->mbmi.txfm_size = TX_8X8; |
| 218 } else { | 210 } else { |
| 219 m->mbmi.txfm_size = TX_4X4; | 211 m->mbmi.txfm_size = TX_4X4; |
| 220 } | 212 } |
| 221 } | 213 } |
| 222 | 214 |
| 223 static int read_nmv_component(vp9_reader *r, | 215 static int read_nmv_component(vp9_reader *r, |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 // The reference frame for the mb is considered as correclty predicted | 463 // The reference frame for the mb is considered as correclty predicted |
| 472 // if it is signaled at the segment level for the purposes of the | 464 // if it is signaled at the segment level for the purposes of the |
| 473 // common prediction model | 465 // common prediction model |
| 474 vp9_set_pred_flag(xd, PRED_REF, 1); | 466 vp9_set_pred_flag(xd, PRED_REF, 1); |
| 475 ref_frame = vp9_get_pred_ref(cm, xd); | 467 ref_frame = vp9_get_pred_ref(cm, xd); |
| 476 } | 468 } |
| 477 | 469 |
| 478 return (MV_REFERENCE_FRAME)ref_frame; | 470 return (MV_REFERENCE_FRAME)ref_frame; |
| 479 } | 471 } |
| 480 | 472 |
| 481 #if CONFIG_SUPERBLOCKS | |
| 482 static MB_PREDICTION_MODE read_sb_mv_ref(vp9_reader *bc, const vp9_prob *p) { | 473 static MB_PREDICTION_MODE read_sb_mv_ref(vp9_reader *bc, const vp9_prob *p) { |
| 483 return (MB_PREDICTION_MODE) treed_read(bc, vp9_sb_mv_ref_tree, p); | 474 return (MB_PREDICTION_MODE) treed_read(bc, vp9_sb_mv_ref_tree, p); |
| 484 } | 475 } |
| 485 #endif | |
| 486 | 476 |
| 487 static MB_PREDICTION_MODE read_mv_ref(vp9_reader *bc, const vp9_prob *p) { | 477 static MB_PREDICTION_MODE read_mv_ref(vp9_reader *bc, const vp9_prob *p) { |
| 488 return (MB_PREDICTION_MODE) treed_read(bc, vp9_mv_ref_tree, p); | 478 return (MB_PREDICTION_MODE) treed_read(bc, vp9_mv_ref_tree, p); |
| 489 } | 479 } |
| 490 | 480 |
| 491 static B_PREDICTION_MODE sub_mv_ref(vp9_reader *bc, const vp9_prob *p) { | 481 static B_PREDICTION_MODE sub_mv_ref(vp9_reader *bc, const vp9_prob *p) { |
| 492 return (B_PREDICTION_MODE) treed_read(bc, vp9_sub_mv_ref_tree, p); | 482 return (B_PREDICTION_MODE) treed_read(bc, vp9_sub_mv_ref_tree, p); |
| 493 } | 483 } |
| 494 | 484 |
| 495 #ifdef VPX_MODE_COUNT | 485 #ifdef VPX_MODE_COUNT |
| (...skipping 29 matching lines...) Expand all Loading... |
| 525 | 515 |
| 526 static void mb_mode_mv_init(VP9D_COMP *pbi, vp9_reader *bc) { | 516 static void mb_mode_mv_init(VP9D_COMP *pbi, vp9_reader *bc) { |
| 527 VP9_COMMON *const cm = &pbi->common; | 517 VP9_COMMON *const cm = &pbi->common; |
| 528 nmv_context *const nmvc = &pbi->common.fc.nmvc; | 518 nmv_context *const nmvc = &pbi->common.fc.nmvc; |
| 529 MACROBLOCKD *const xd = &pbi->mb; | 519 MACROBLOCKD *const xd = &pbi->mb; |
| 530 | 520 |
| 531 if (cm->frame_type == KEY_FRAME) { | 521 if (cm->frame_type == KEY_FRAME) { |
| 532 if (!cm->kf_ymode_probs_update) | 522 if (!cm->kf_ymode_probs_update) |
| 533 cm->kf_ymode_probs_index = vp9_read_literal(bc, 3); | 523 cm->kf_ymode_probs_index = vp9_read_literal(bc, 3); |
| 534 } else { | 524 } else { |
| 535 #if CONFIG_PRED_FILTER | |
| 536 cm->pred_filter_mode = (vp9_prob)vp9_read_literal(bc, 2); | |
| 537 | |
| 538 if (cm->pred_filter_mode == 2) | |
| 539 cm->prob_pred_filter_off = (vp9_prob)vp9_read_literal(bc, 8); | |
| 540 #endif | |
| 541 if (cm->mcomp_filter_type == SWITCHABLE) | 525 if (cm->mcomp_filter_type == SWITCHABLE) |
| 542 read_switchable_interp_probs(pbi, bc); | 526 read_switchable_interp_probs(pbi, bc); |
| 543 #if CONFIG_COMP_INTERINTRA_PRED | 527 #if CONFIG_COMP_INTERINTRA_PRED |
| 544 if (cm->use_interintra) { | 528 if (cm->use_interintra) { |
| 545 if (vp9_read(bc, VP9_UPD_INTERINTRA_PROB)) | 529 if (vp9_read(bc, VP9_UPD_INTERINTRA_PROB)) |
| 546 cm->fc.interintra_prob = (vp9_prob)vp9_read_literal(bc, 8); | 530 cm->fc.interintra_prob = (vp9_prob)vp9_read_literal(bc, 8); |
| 547 } | 531 } |
| 548 #endif | 532 #endif |
| 549 // Decode the baseline probabilities for decoding reference frame | 533 // Decode the baseline probabilities for decoding reference frame |
| 550 cm->prob_intra_coded = (vp9_prob)vp9_read_literal(bc, 8); | 534 cm->prob_intra_coded = (vp9_prob)vp9_read_literal(bc, 8); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 565 } | 549 } |
| 566 | 550 |
| 567 if (vp9_read_bit(bc)) { | 551 if (vp9_read_bit(bc)) { |
| 568 int i = 0; | 552 int i = 0; |
| 569 | 553 |
| 570 do { | 554 do { |
| 571 cm->fc.ymode_prob[i] = (vp9_prob) vp9_read_literal(bc, 8); | 555 cm->fc.ymode_prob[i] = (vp9_prob) vp9_read_literal(bc, 8); |
| 572 } while (++i < VP9_YMODES - 1); | 556 } while (++i < VP9_YMODES - 1); |
| 573 } | 557 } |
| 574 | 558 |
| 575 #if CONFIG_SUPERBLOCKS | |
| 576 if (vp9_read_bit(bc)) { | 559 if (vp9_read_bit(bc)) { |
| 577 int i = 0; | 560 int i = 0; |
| 578 | 561 |
| 579 do { | 562 do { |
| 580 cm->fc.sb_ymode_prob[i] = (vp9_prob) vp9_read_literal(bc, 8); | 563 cm->fc.sb_ymode_prob[i] = (vp9_prob) vp9_read_literal(bc, 8); |
| 581 } while (++i < VP9_I32X32_MODES - 1); | 564 } while (++i < VP9_I32X32_MODES - 1); |
| 582 } | 565 } |
| 583 #endif | |
| 584 | |
| 585 #if CONFIG_NEW_MVREF | |
| 586 // Temp defaults probabilities for ecnoding the MV ref id signal | |
| 587 vpx_memset(xd->mb_mv_ref_id_probs, 192, sizeof(xd->mb_mv_ref_id_probs)); | |
| 588 #endif | |
| 589 | 566 |
| 590 read_nmvprobs(bc, nmvc, xd->allow_high_precision_mv); | 567 read_nmvprobs(bc, nmvc, xd->allow_high_precision_mv); |
| 591 } | 568 } |
| 592 } | 569 } |
| 593 | 570 |
| 594 // This function either reads the segment id for the current macroblock from | 571 // This function either reads the segment id for the current macroblock from |
| 595 // the bitstream or if the value is temporally predicted asserts the predicted | 572 // the bitstream or if the value is temporally predicted asserts the predicted |
| 596 // value | 573 // value |
| 597 static void read_mb_segment_id(VP9D_COMP *pbi, | 574 static void read_mb_segment_id(VP9D_COMP *pbi, |
| 598 int mb_row, int mb_col, | 575 int mb_row, int mb_col, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 626 } | 603 } |
| 627 // Else .... decode it explicitly | 604 // Else .... decode it explicitly |
| 628 else { | 605 else { |
| 629 read_mb_segid(bc, mbmi, xd); | 606 read_mb_segid(bc, mbmi, xd); |
| 630 } | 607 } |
| 631 } | 608 } |
| 632 // Normal unpredicted coding mode | 609 // Normal unpredicted coding mode |
| 633 else { | 610 else { |
| 634 read_mb_segid(bc, mbmi, xd); | 611 read_mb_segid(bc, mbmi, xd); |
| 635 } | 612 } |
| 636 #if CONFIG_SUPERBLOCKS | 613 if (mbmi->sb_type) { |
| 637 if (mbmi->encoded_as_sb) { | 614 const int nmbs = 1 << mbmi->sb_type; |
| 638 cm->last_frame_seg_map[index] = mbmi->segment_id; | 615 const int ymbs = MIN(cm->mb_rows - mb_row, nmbs); |
| 639 if (mb_col + 1 < cm->mb_cols) | 616 const int xmbs = MIN(cm->mb_cols - mb_col, nmbs); |
| 640 cm->last_frame_seg_map[index + 1] = mbmi->segment_id; | 617 int x, y; |
| 641 if (mb_row + 1 < cm->mb_rows) { | 618 |
| 642 cm->last_frame_seg_map[index + cm->mb_cols] = mbmi->segment_id; | 619 for (y = 0; y < ymbs; y++) { |
| 643 if (mb_col + 1 < cm->mb_cols) | 620 for (x = 0; x < xmbs; x++) { |
| 644 cm->last_frame_seg_map[index + cm->mb_cols + 1] = mbmi->segment_id; | 621 cm->last_frame_seg_map[index + x + y * cm->mb_cols] = |
| 622 mbmi->segment_id; |
| 623 } |
| 645 } | 624 } |
| 646 } else | 625 } else { |
| 647 #endif | |
| 648 { | |
| 649 cm->last_frame_seg_map[index] = mbmi->segment_id; | 626 cm->last_frame_seg_map[index] = mbmi->segment_id; |
| 650 } | 627 } |
| 651 } else { | 628 } else { |
| 652 #if CONFIG_SUPERBLOCKS | 629 if (mbmi->sb_type) { |
| 653 if (mbmi->encoded_as_sb) { | 630 const int nmbs = 1 << mbmi->sb_type; |
| 654 mbmi->segment_id = cm->last_frame_seg_map[index]; | 631 const int ymbs = MIN(cm->mb_rows - mb_row, nmbs); |
| 655 if (mb_col < cm->mb_cols - 1) | 632 const int xmbs = MIN(cm->mb_cols - mb_col, nmbs); |
| 656 mbmi->segment_id = mbmi->segment_id && | 633 unsigned segment_id = -1; |
| 657 cm->last_frame_seg_map[index + 1]; | 634 int x, y; |
| 658 if (mb_row < cm->mb_rows - 1) { | 635 |
| 659 mbmi->segment_id = mbmi->segment_id && | 636 for (y = 0; y < ymbs; y++) { |
| 660 cm->last_frame_seg_map[index + cm->mb_cols]; | 637 for (x = 0; x < xmbs; x++) { |
| 661 if (mb_col < cm->mb_cols - 1) | 638 segment_id = MIN(segment_id, |
| 662 mbmi->segment_id = mbmi->segment_id && | 639 cm->last_frame_seg_map[index + x + |
| 663 cm->last_frame_seg_map[index + cm->mb_cols + 1]; | 640 y * cm->mb_cols]); |
| 641 } |
| 664 } | 642 } |
| 665 } else | 643 mbmi->segment_id = segment_id; |
| 666 #endif | 644 } else { |
| 667 { | |
| 668 mbmi->segment_id = cm->last_frame_seg_map[index]; | 645 mbmi->segment_id = cm->last_frame_seg_map[index]; |
| 669 } | 646 } |
| 670 } | 647 } |
| 671 } else { | 648 } else { |
| 672 // The encoder explicitly sets the segment_id to 0 | 649 // The encoder explicitly sets the segment_id to 0 |
| 673 // when segmentation is disabled | 650 // when segmentation is disabled |
| 674 mbmi->segment_id = 0; | 651 mbmi->segment_id = 0; |
| 675 } | 652 } |
| 676 } | 653 } |
| 677 | 654 |
| 678 static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi, | 655 static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi, |
| 679 MODE_INFO *prev_mi, | 656 MODE_INFO *prev_mi, |
| 680 int mb_row, int mb_col, | 657 int mb_row, int mb_col, |
| 681 BOOL_DECODER* const bc) { | 658 BOOL_DECODER* const bc) { |
| 682 VP9_COMMON *const cm = &pbi->common; | 659 VP9_COMMON *const cm = &pbi->common; |
| 683 nmv_context *const nmvc = &pbi->common.fc.nmvc; | 660 nmv_context *const nmvc = &pbi->common.fc.nmvc; |
| 684 const int mis = pbi->common.mode_info_stride; | 661 const int mis = pbi->common.mode_info_stride; |
| 685 MACROBLOCKD *const xd = &pbi->mb; | 662 MACROBLOCKD *const xd = &pbi->mb; |
| 686 | 663 |
| 687 int_mv *const mv = &mbmi->mv[0]; | 664 int_mv *const mv = &mbmi->mv[0]; |
| 688 int mb_to_left_edge; | 665 int mb_to_left_edge; |
| 689 int mb_to_right_edge; | 666 int mb_to_right_edge; |
| 690 int mb_to_top_edge; | 667 int mb_to_top_edge; |
| 691 int mb_to_bottom_edge; | 668 int mb_to_bottom_edge; |
| 669 const int mb_size = 1 << mi->mbmi.sb_type; |
| 692 | 670 |
| 693 mb_to_top_edge = xd->mb_to_top_edge; | 671 mb_to_top_edge = xd->mb_to_top_edge; |
| 694 mb_to_bottom_edge = xd->mb_to_bottom_edge; | 672 mb_to_bottom_edge = xd->mb_to_bottom_edge; |
| 695 mb_to_top_edge -= LEFT_TOP_MARGIN; | 673 mb_to_top_edge -= LEFT_TOP_MARGIN; |
| 696 mb_to_bottom_edge += RIGHT_BOTTOM_MARGIN; | 674 mb_to_bottom_edge += RIGHT_BOTTOM_MARGIN; |
| 697 mbmi->need_to_clamp_mvs = 0; | 675 mbmi->need_to_clamp_mvs = 0; |
| 698 mbmi->need_to_clamp_secondmv = 0; | 676 mbmi->need_to_clamp_secondmv = 0; |
| 699 mbmi->second_ref_frame = NONE; | 677 mbmi->second_ref_frame = NONE; |
| 700 /* Distance of Mb to the various image edges. | 678 /* Distance of Mb to the various image edges. |
| 701 * These specified to 8th pel as they are always compared to MV values that ar
e in 1/8th pel units | 679 * These specified to 8th pel as they are always compared to MV values that ar
e in 1/8th pel units |
| 702 */ | 680 */ |
| 703 xd->mb_to_left_edge = | 681 xd->mb_to_left_edge = |
| 704 mb_to_left_edge = -((mb_col * 16) << 3); | 682 mb_to_left_edge = -((mb_col * 16) << 3); |
| 705 mb_to_left_edge -= LEFT_TOP_MARGIN; | 683 mb_to_left_edge -= LEFT_TOP_MARGIN; |
| 706 | 684 xd->mb_to_right_edge = |
| 707 #if CONFIG_SUPERBLOCKS | 685 mb_to_right_edge = ((pbi->common.mb_cols - mb_size - mb_col) * 16) << 3; |
| 708 if (mi->mbmi.encoded_as_sb) { | |
| 709 xd->mb_to_right_edge = | |
| 710 mb_to_right_edge = ((pbi->common.mb_cols - 2 - mb_col) * 16) << 3; | |
| 711 } else { | |
| 712 #endif | |
| 713 xd->mb_to_right_edge = | |
| 714 mb_to_right_edge = ((pbi->common.mb_cols - 1 - mb_col) * 16) << 3; | |
| 715 #if CONFIG_SUPERBLOCKS | |
| 716 } | |
| 717 #endif | |
| 718 mb_to_right_edge += RIGHT_BOTTOM_MARGIN; | 686 mb_to_right_edge += RIGHT_BOTTOM_MARGIN; |
| 719 | 687 |
| 720 // Make sure the MACROBLOCKD mode info pointer is pointed at the | 688 // Make sure the MACROBLOCKD mode info pointer is pointed at the |
| 721 // correct entry for the current macroblock. | 689 // correct entry for the current macroblock. |
| 722 xd->mode_info_context = mi; | 690 xd->mode_info_context = mi; |
| 723 xd->prev_mode_info_context = prev_mi; | 691 xd->prev_mode_info_context = prev_mi; |
| 724 | 692 |
| 725 // Read the macroblock segment id. | 693 // Read the macroblock segment id. |
| 726 read_mb_segment_id(pbi, mb_row, mb_col, bc); | 694 read_mb_segment_id(pbi, mb_row, mb_col, bc); |
| 727 | 695 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 749 mbmi->ref_frame = read_ref_frame(pbi, bc, mbmi->segment_id); | 717 mbmi->ref_frame = read_ref_frame(pbi, bc, mbmi->segment_id); |
| 750 | 718 |
| 751 // If reference frame is an Inter frame | 719 // If reference frame is an Inter frame |
| 752 if (mbmi->ref_frame) { | 720 if (mbmi->ref_frame) { |
| 753 int_mv nearest, nearby, best_mv; | 721 int_mv nearest, nearby, best_mv; |
| 754 int_mv nearest_second, nearby_second, best_mv_second; | 722 int_mv nearest_second, nearby_second, best_mv_second; |
| 755 vp9_prob mv_ref_p [VP9_MVREFS - 1]; | 723 vp9_prob mv_ref_p [VP9_MVREFS - 1]; |
| 756 | 724 |
| 757 int recon_y_stride, recon_yoffset; | 725 int recon_y_stride, recon_yoffset; |
| 758 int recon_uv_stride, recon_uvoffset; | 726 int recon_uv_stride, recon_uvoffset; |
| 727 MV_REFERENCE_FRAME ref_frame = mbmi->ref_frame; |
| 759 | 728 |
| 760 { | 729 { |
| 761 int ref_fb_idx; | 730 int ref_fb_idx; |
| 762 MV_REFERENCE_FRAME ref_frame = mbmi->ref_frame; | |
| 763 | 731 |
| 764 /* Select the appropriate reference frame for this MB */ | 732 /* Select the appropriate reference frame for this MB */ |
| 765 if (ref_frame == LAST_FRAME) | 733 if (ref_frame == LAST_FRAME) |
| 766 ref_fb_idx = cm->lst_fb_idx; | 734 ref_fb_idx = cm->lst_fb_idx; |
| 767 else if (ref_frame == GOLDEN_FRAME) | 735 else if (ref_frame == GOLDEN_FRAME) |
| 768 ref_fb_idx = cm->gld_fb_idx; | 736 ref_fb_idx = cm->gld_fb_idx; |
| 769 else | 737 else |
| 770 ref_fb_idx = cm->alt_fb_idx; | 738 ref_fb_idx = cm->alt_fb_idx; |
| 771 | 739 |
| 772 recon_y_stride = cm->yv12_fb[ref_fb_idx].y_stride ; | 740 recon_y_stride = cm->yv12_fb[ref_fb_idx].y_stride ; |
| 773 recon_uv_stride = cm->yv12_fb[ref_fb_idx].uv_stride; | 741 recon_uv_stride = cm->yv12_fb[ref_fb_idx].uv_stride; |
| 774 | 742 |
| 775 recon_yoffset = (mb_row * recon_y_stride * 16) + (mb_col * 16); | 743 recon_yoffset = (mb_row * recon_y_stride * 16) + (mb_col * 16); |
| 776 recon_uvoffset = (mb_row * recon_uv_stride * 8) + (mb_col * 8); | 744 recon_uvoffset = (mb_row * recon_uv_stride * 8) + (mb_col * 8); |
| 777 | 745 |
| 778 xd->pre.y_buffer = cm->yv12_fb[ref_fb_idx].y_buffer + recon_yoffset; | 746 xd->pre.y_buffer = cm->yv12_fb[ref_fb_idx].y_buffer + recon_yoffset; |
| 779 xd->pre.u_buffer = cm->yv12_fb[ref_fb_idx].u_buffer + recon_uvoffset; | 747 xd->pre.u_buffer = cm->yv12_fb[ref_fb_idx].u_buffer + recon_uvoffset; |
| 780 xd->pre.v_buffer = cm->yv12_fb[ref_fb_idx].v_buffer + recon_uvoffset; | 748 xd->pre.v_buffer = cm->yv12_fb[ref_fb_idx].v_buffer + recon_uvoffset; |
| 781 | 749 |
| 782 #ifdef DEC_DEBUG | 750 #ifdef DEC_DEBUG |
| 783 if (dec_debug) | 751 if (dec_debug) |
| 784 printf("%d %d\n", xd->mode_info_context->mbmi.mv[0].as_mv.row, | 752 printf("%d %d\n", xd->mode_info_context->mbmi.mv[0].as_mv.row, |
| 785 xd->mode_info_context->mbmi.mv[0].as_mv.col); | 753 xd->mode_info_context->mbmi.mv[0].as_mv.col); |
| 786 #endif | 754 #endif |
| 787 vp9_find_mv_refs(xd, mi, prev_mi, | 755 vp9_find_mv_refs(xd, mi, prev_mi, |
| 788 ref_frame, mbmi->ref_mvs[ref_frame], | 756 ref_frame, mbmi->ref_mvs[ref_frame], |
| 789 cm->ref_frame_sign_bias); | 757 cm->ref_frame_sign_bias); |
| 790 | 758 |
| 791 vp9_find_best_ref_mvs(xd, | |
| 792 xd->pre.y_buffer, | |
| 793 recon_y_stride, | |
| 794 mbmi->ref_mvs[ref_frame], | |
| 795 &best_mv, &nearest, &nearby); | |
| 796 | |
| 797 vp9_mv_ref_probs(&pbi->common, mv_ref_p, | 759 vp9_mv_ref_probs(&pbi->common, mv_ref_p, |
| 798 mbmi->mb_mode_context[ref_frame]); | 760 mbmi->mb_mode_context[ref_frame]); |
| 761 |
| 762 // Is the segment level mode feature enabled for this segment |
| 763 if (vp9_segfeature_active(xd, mbmi->segment_id, SEG_LVL_MODE)) { |
| 764 mbmi->mode = |
| 765 vp9_get_segdata(xd, mbmi->segment_id, SEG_LVL_MODE); |
| 766 } else { |
| 767 if (mbmi->sb_type) |
| 768 mbmi->mode = read_sb_mv_ref(bc, mv_ref_p); |
| 769 else |
| 770 mbmi->mode = read_mv_ref(bc, mv_ref_p); |
| 771 |
| 772 vp9_accum_mv_refs(&pbi->common, mbmi->mode, |
| 773 mbmi->mb_mode_context[ref_frame]); |
| 774 } |
| 775 |
| 776 if (mbmi->mode != ZEROMV) { |
| 777 vp9_find_best_ref_mvs(xd, |
| 778 xd->pre.y_buffer, |
| 779 recon_y_stride, |
| 780 mbmi->ref_mvs[ref_frame], |
| 781 &nearest, &nearby); |
| 782 |
| 783 best_mv.as_int = (mbmi->ref_mvs[ref_frame][0]).as_int; |
| 784 } |
| 785 |
| 799 #ifdef DEC_DEBUG | 786 #ifdef DEC_DEBUG |
| 800 if (dec_debug) | 787 if (dec_debug) |
| 801 printf("[D %d %d] %d %d %d %d\n", ref_frame, | 788 printf("[D %d %d] %d %d %d %d\n", ref_frame, |
| 802 mbmi->mb_mode_context[ref_frame], | 789 mbmi->mb_mode_context[ref_frame], |
| 803 mv_ref_p[0], mv_ref_p[1], mv_ref_p[2], mv_ref_p[3]); | 790 mv_ref_p[0], mv_ref_p[1], mv_ref_p[2], mv_ref_p[3]); |
| 804 #endif | 791 #endif |
| 805 } | 792 } |
| 806 | 793 |
| 807 // Is the segment level mode feature enabled for this segment | |
| 808 if (vp9_segfeature_active(xd, mbmi->segment_id, SEG_LVL_MODE)) { | |
| 809 mbmi->mode = | |
| 810 vp9_get_segdata(xd, mbmi->segment_id, SEG_LVL_MODE); | |
| 811 } else { | |
| 812 #if CONFIG_SUPERBLOCKS | |
| 813 if (mbmi->encoded_as_sb) { | |
| 814 mbmi->mode = read_sb_mv_ref(bc, mv_ref_p); | |
| 815 } else | |
| 816 #endif | |
| 817 mbmi->mode = read_mv_ref(bc, mv_ref_p); | |
| 818 | |
| 819 vp9_accum_mv_refs(&pbi->common, mbmi->mode, | |
| 820 mbmi->mb_mode_context[mbmi->ref_frame]); | |
| 821 } | |
| 822 | |
| 823 #if CONFIG_PRED_FILTER | |
| 824 if (mbmi->mode >= NEARESTMV && mbmi->mode < SPLITMV) { | |
| 825 // Is the prediction filter enabled | |
| 826 if (cm->pred_filter_mode == 2) | |
| 827 mbmi->pred_filter_enabled = | |
| 828 vp9_read(bc, cm->prob_pred_filter_off); | |
| 829 else | |
| 830 mbmi->pred_filter_enabled = cm->pred_filter_mode; | |
| 831 } | |
| 832 #endif | |
| 833 if (mbmi->mode >= NEARESTMV && mbmi->mode <= SPLITMV) | 794 if (mbmi->mode >= NEARESTMV && mbmi->mode <= SPLITMV) |
| 834 { | 795 { |
| 835 if (cm->mcomp_filter_type == SWITCHABLE) { | 796 if (cm->mcomp_filter_type == SWITCHABLE) { |
| 836 mbmi->interp_filter = vp9_switchable_interp[ | 797 mbmi->interp_filter = vp9_switchable_interp[ |
| 837 treed_read(bc, vp9_switchable_interp_tree, | 798 treed_read(bc, vp9_switchable_interp_tree, |
| 838 vp9_get_pred_probs(cm, xd, PRED_SWITCHABLE_INTERP))]; | 799 vp9_get_pred_probs(cm, xd, PRED_SWITCHABLE_INTERP))]; |
| 839 } else { | 800 } else { |
| 840 mbmi->interp_filter = cm->mcomp_filter_type; | 801 mbmi->interp_filter = cm->mcomp_filter_type; |
| 841 } | 802 } |
| 842 } | 803 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 870 xd->second_pre.u_buffer = | 831 xd->second_pre.u_buffer = |
| 871 cm->yv12_fb[second_ref_fb_idx].u_buffer + recon_uvoffset; | 832 cm->yv12_fb[second_ref_fb_idx].u_buffer + recon_uvoffset; |
| 872 xd->second_pre.v_buffer = | 833 xd->second_pre.v_buffer = |
| 873 cm->yv12_fb[second_ref_fb_idx].v_buffer + recon_uvoffset; | 834 cm->yv12_fb[second_ref_fb_idx].v_buffer + recon_uvoffset; |
| 874 | 835 |
| 875 vp9_find_mv_refs(xd, mi, prev_mi, | 836 vp9_find_mv_refs(xd, mi, prev_mi, |
| 876 mbmi->second_ref_frame, | 837 mbmi->second_ref_frame, |
| 877 mbmi->ref_mvs[mbmi->second_ref_frame], | 838 mbmi->ref_mvs[mbmi->second_ref_frame], |
| 878 cm->ref_frame_sign_bias); | 839 cm->ref_frame_sign_bias); |
| 879 | 840 |
| 880 vp9_find_best_ref_mvs(xd, | 841 if (mbmi->mode != ZEROMV) { |
| 881 xd->second_pre.y_buffer, | 842 vp9_find_best_ref_mvs(xd, |
| 882 recon_y_stride, | 843 xd->second_pre.y_buffer, |
| 883 mbmi->ref_mvs[mbmi->second_ref_frame], | 844 recon_y_stride, |
| 884 &best_mv_second, | 845 mbmi->ref_mvs[mbmi->second_ref_frame], |
| 885 &nearest_second, | 846 &nearest_second, |
| 886 &nearby_second); | 847 &nearby_second); |
| 848 best_mv_second = mbmi->ref_mvs[mbmi->second_ref_frame][0]; |
| 849 } |
| 887 } | 850 } |
| 888 | 851 |
| 889 } else { | 852 } else { |
| 890 #if CONFIG_COMP_INTERINTRA_PRED | 853 #if CONFIG_COMP_INTERINTRA_PRED |
| 891 if (pbi->common.use_interintra && | 854 if (pbi->common.use_interintra && |
| 892 mbmi->mode >= NEARESTMV && mbmi->mode < SPLITMV && | 855 mbmi->mode >= NEARESTMV && mbmi->mode < SPLITMV && |
| 893 mbmi->second_ref_frame == NONE) { | 856 mbmi->second_ref_frame == NONE) { |
| 894 mbmi->second_ref_frame = (vp9_read(bc, pbi->common.fc.interintra_prob) ? | 857 mbmi->second_ref_frame = (vp9_read(bc, pbi->common.fc.interintra_prob) ? |
| 895 INTRA_FRAME : NONE); | 858 INTRA_FRAME : NONE); |
| 896 // printf("-- %d (%d)\n", mbmi->second_ref_frame == INTRA_FRAME, | 859 // printf("-- %d (%d)\n", mbmi->second_ref_frame == INTRA_FRAME, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 909 #else | 872 #else |
| 910 mbmi->interintra_uv_mode = mbmi->interintra_mode; | 873 mbmi->interintra_uv_mode = mbmi->interintra_mode; |
| 911 #endif | 874 #endif |
| 912 // printf("** %d %d\n", | 875 // printf("** %d %d\n", |
| 913 // mbmi->interintra_mode, mbmi->interintra_uv_mode); | 876 // mbmi->interintra_mode, mbmi->interintra_uv_mode); |
| 914 } | 877 } |
| 915 } | 878 } |
| 916 #endif | 879 #endif |
| 917 } | 880 } |
| 918 | 881 |
| 882 #if CONFIG_NEW_MVREF |
| 883 // if ((mbmi->mode == NEWMV) || (mbmi->mode == SPLITMV)) |
| 884 if (mbmi->mode == NEWMV) { |
| 885 int best_index; |
| 886 MV_REFERENCE_FRAME ref_frame = mbmi->ref_frame; |
| 887 |
| 888 // Encode the index of the choice. |
| 889 best_index = |
| 890 vp9_read_mv_ref_id(bc, xd->mb_mv_ref_probs[ref_frame]); |
| 891 |
| 892 best_mv.as_int = mbmi->ref_mvs[ref_frame][best_index].as_int; |
| 893 |
| 894 if (mbmi->second_ref_frame > 0) { |
| 895 ref_frame = mbmi->second_ref_frame; |
| 896 |
| 897 // Encode the index of the choice. |
| 898 best_index = |
| 899 vp9_read_mv_ref_id(bc, xd->mb_mv_ref_probs[ref_frame]); |
| 900 best_mv_second.as_int = mbmi->ref_mvs[ref_frame][best_index].as_int; |
| 901 } |
| 902 } |
| 903 #endif |
| 904 |
| 919 mbmi->uv_mode = DC_PRED; | 905 mbmi->uv_mode = DC_PRED; |
| 920 switch (mbmi->mode) { | 906 switch (mbmi->mode) { |
| 921 case SPLITMV: { | 907 case SPLITMV: { |
| 922 const int s = mbmi->partitioning = | 908 const int s = mbmi->partitioning = |
| 923 treed_read(bc, vp9_mbsplit_tree, cm->fc.mbsplit_prob); | 909 treed_read(bc, vp9_mbsplit_tree, cm->fc.mbsplit_prob); |
| 924 const int num_p = vp9_mbsplit_count [s]; | 910 const int num_p = vp9_mbsplit_count [s]; |
| 925 int j = 0; | 911 int j = 0; |
| 926 cm->fc.mbsplit_counts[s]++; | 912 cm->fc.mbsplit_counts[s]++; |
| 927 | 913 |
| 928 mbmi->need_to_clamp_mvs = 0; | 914 mbmi->need_to_clamp_mvs = 0; |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1065 break; | 1051 break; |
| 1066 | 1052 |
| 1067 case ZEROMV: | 1053 case ZEROMV: |
| 1068 mv->as_int = 0; | 1054 mv->as_int = 0; |
| 1069 if (mbmi->second_ref_frame > 0) | 1055 if (mbmi->second_ref_frame > 0) |
| 1070 mbmi->mv[1].as_int = 0; | 1056 mbmi->mv[1].as_int = 0; |
| 1071 break; | 1057 break; |
| 1072 | 1058 |
| 1073 case NEWMV: | 1059 case NEWMV: |
| 1074 | 1060 |
| 1075 #if CONFIG_NEW_MVREF | |
| 1076 { | |
| 1077 int best_index; | |
| 1078 MV_REFERENCE_FRAME ref_frame = mbmi->ref_frame; | |
| 1079 | |
| 1080 // Encode the index of the choice. | |
| 1081 best_index = | |
| 1082 vp9_read_mv_ref_id(bc, xd->mb_mv_ref_id_probs[ref_frame]); | |
| 1083 | |
| 1084 best_mv.as_int = mbmi->ref_mvs[ref_frame][best_index].as_int; | |
| 1085 } | |
| 1086 #endif | |
| 1087 | |
| 1088 read_nmv(bc, &mv->as_mv, &best_mv.as_mv, nmvc); | 1061 read_nmv(bc, &mv->as_mv, &best_mv.as_mv, nmvc); |
| 1089 read_nmv_fp(bc, &mv->as_mv, &best_mv.as_mv, nmvc, | 1062 read_nmv_fp(bc, &mv->as_mv, &best_mv.as_mv, nmvc, |
| 1090 xd->allow_high_precision_mv); | 1063 xd->allow_high_precision_mv); |
| 1091 vp9_increment_nmv(&mv->as_mv, &best_mv.as_mv, &cm->fc.NMVcount, | 1064 vp9_increment_nmv(&mv->as_mv, &best_mv.as_mv, &cm->fc.NMVcount, |
| 1092 xd->allow_high_precision_mv); | 1065 xd->allow_high_precision_mv); |
| 1093 | 1066 |
| 1094 mv->as_mv.row += best_mv.as_mv.row; | 1067 mv->as_mv.row += best_mv.as_mv.row; |
| 1095 mv->as_mv.col += best_mv.as_mv.col; | 1068 mv->as_mv.col += best_mv.as_mv.col; |
| 1096 | 1069 |
| 1097 /* Don't need to check this on NEARMV and NEARESTMV modes | 1070 /* Don't need to check this on NEARMV and NEARESTMV modes |
| 1098 * since those modes clamp the MV. The NEWMV mode does not, | 1071 * since those modes clamp the MV. The NEWMV mode does not, |
| 1099 * so signal to the prediction stage whether special | 1072 * so signal to the prediction stage whether special |
| 1100 * handling may be required. | 1073 * handling may be required. |
| 1101 */ | 1074 */ |
| 1102 mbmi->need_to_clamp_mvs = check_mv_bounds(mv, | 1075 mbmi->need_to_clamp_mvs = check_mv_bounds(mv, |
| 1103 mb_to_left_edge, | 1076 mb_to_left_edge, |
| 1104 mb_to_right_edge, | 1077 mb_to_right_edge, |
| 1105 mb_to_top_edge, | 1078 mb_to_top_edge, |
| 1106 mb_to_bottom_edge); | 1079 mb_to_bottom_edge); |
| 1107 | 1080 |
| 1108 if (mbmi->second_ref_frame > 0) { | 1081 if (mbmi->second_ref_frame > 0) { |
| 1109 #if CONFIG_NEW_MVREF | |
| 1110 { | |
| 1111 int best_index; | |
| 1112 MV_REFERENCE_FRAME ref_frame = mbmi->second_ref_frame; | |
| 1113 | |
| 1114 // Encode the index of the choice. | |
| 1115 best_index = | |
| 1116 vp9_read_mv_ref_id(bc, xd->mb_mv_ref_id_probs[ref_frame]); | |
| 1117 best_mv_second.as_int = mbmi->ref_mvs[ref_frame][best_index].as_int; | |
| 1118 } | |
| 1119 #endif | |
| 1120 | |
| 1121 read_nmv(bc, &mbmi->mv[1].as_mv, &best_mv_second.as_mv, nmvc); | 1082 read_nmv(bc, &mbmi->mv[1].as_mv, &best_mv_second.as_mv, nmvc); |
| 1122 read_nmv_fp(bc, &mbmi->mv[1].as_mv, &best_mv_second.as_mv, nmvc, | 1083 read_nmv_fp(bc, &mbmi->mv[1].as_mv, &best_mv_second.as_mv, nmvc, |
| 1123 xd->allow_high_precision_mv); | 1084 xd->allow_high_precision_mv); |
| 1124 vp9_increment_nmv(&mbmi->mv[1].as_mv, &best_mv_second.as_mv, | 1085 vp9_increment_nmv(&mbmi->mv[1].as_mv, &best_mv_second.as_mv, |
| 1125 &cm->fc.NMVcount, xd->allow_high_precision_mv); | 1086 &cm->fc.NMVcount, xd->allow_high_precision_mv); |
| 1126 mbmi->mv[1].as_mv.row += best_mv_second.as_mv.row; | 1087 mbmi->mv[1].as_mv.row += best_mv_second.as_mv.row; |
| 1127 mbmi->mv[1].as_mv.col += best_mv_second.as_mv.col; | 1088 mbmi->mv[1].as_mv.col += best_mv_second.as_mv.col; |
| 1128 mbmi->need_to_clamp_secondmv |= | 1089 mbmi->need_to_clamp_secondmv |= |
| 1129 check_mv_bounds(&mbmi->mv[1], | 1090 check_mv_bounds(&mbmi->mv[1], |
| 1130 mb_to_left_edge, mb_to_right_edge, | 1091 mb_to_left_edge, mb_to_right_edge, |
| 1131 mb_to_top_edge, mb_to_bottom_edge); | 1092 mb_to_top_edge, mb_to_bottom_edge); |
| 1132 } | 1093 } |
| 1133 break; | 1094 break; |
| 1134 default: | 1095 default: |
| 1135 ; | 1096 ; |
| 1136 #if CONFIG_DEBUG | 1097 #if CONFIG_DEBUG |
| 1137 assert(0); | 1098 assert(0); |
| 1138 #endif | 1099 #endif |
| 1139 } | 1100 } |
| 1140 } else { | 1101 } else { |
| 1141 /* required for left and above block mv */ | 1102 /* required for left and above block mv */ |
| 1142 mbmi->mv[0].as_int = 0; | 1103 mbmi->mv[0].as_int = 0; |
| 1143 | 1104 |
| 1144 if (vp9_segfeature_active(xd, mbmi->segment_id, SEG_LVL_MODE)) { | 1105 if (vp9_segfeature_active(xd, mbmi->segment_id, SEG_LVL_MODE)) { |
| 1145 mbmi->mode = (MB_PREDICTION_MODE) | 1106 mbmi->mode = (MB_PREDICTION_MODE) |
| 1146 vp9_get_segdata(xd, mbmi->segment_id, SEG_LVL_MODE); | 1107 vp9_get_segdata(xd, mbmi->segment_id, SEG_LVL_MODE); |
| 1147 #if CONFIG_SUPERBLOCKS | 1108 } else if (mbmi->sb_type) { |
| 1148 } else if (mbmi->encoded_as_sb) { | |
| 1149 mbmi->mode = (MB_PREDICTION_MODE) | 1109 mbmi->mode = (MB_PREDICTION_MODE) |
| 1150 read_sb_ymode(bc, pbi->common.fc.sb_ymode_prob); | 1110 read_sb_ymode(bc, pbi->common.fc.sb_ymode_prob); |
| 1151 pbi->common.fc.sb_ymode_counts[mbmi->mode]++; | 1111 pbi->common.fc.sb_ymode_counts[mbmi->mode]++; |
| 1152 #endif | |
| 1153 } else { | 1112 } else { |
| 1154 mbmi->mode = (MB_PREDICTION_MODE) | 1113 mbmi->mode = (MB_PREDICTION_MODE) |
| 1155 read_ymode(bc, pbi->common.fc.ymode_prob); | 1114 read_ymode(bc, pbi->common.fc.ymode_prob); |
| 1156 pbi->common.fc.ymode_counts[mbmi->mode]++; | 1115 pbi->common.fc.ymode_counts[mbmi->mode]++; |
| 1157 } | 1116 } |
| 1158 #if CONFIG_COMP_INTRA_PRED | |
| 1159 mbmi->second_mode = (MB_PREDICTION_MODE)(DC_PRED - 1); | |
| 1160 #endif | |
| 1161 | 1117 |
| 1162 // If MB mode is BPRED read the block modes | 1118 // If MB mode is BPRED read the block modes |
| 1163 if (mbmi->mode == B_PRED) { | 1119 if (mbmi->mode == B_PRED) { |
| 1164 int j = 0; | 1120 int j = 0; |
| 1165 #if CONFIG_COMP_INTRA_PRED | |
| 1166 int use_comp_pred = vp9_read(bc, DEFAULT_COMP_INTRA_PROB); | |
| 1167 #endif | |
| 1168 do { | 1121 do { |
| 1169 int m; | 1122 int m; |
| 1170 m = mi->bmi[j].as_mode.first = (B_PREDICTION_MODE) | 1123 m = mi->bmi[j].as_mode.first = (B_PREDICTION_MODE) |
| 1171 read_bmode(bc, pbi->common.fc.bmode_prob); | 1124 read_bmode(bc, pbi->common.fc.bmode_prob); |
| 1172 #if CONFIG_NEWBINTRAMODES | 1125 #if CONFIG_NEWBINTRAMODES |
| 1173 if (m == B_CONTEXT_PRED) m -= CONTEXT_PRED_REPLACEMENTS; | 1126 if (m == B_CONTEXT_PRED) m -= CONTEXT_PRED_REPLACEMENTS; |
| 1174 #endif | 1127 #endif |
| 1175 pbi->common.fc.bmode_counts[m]++; | 1128 pbi->common.fc.bmode_counts[m]++; |
| 1176 #if CONFIG_COMP_INTRA_PRED | |
| 1177 if (use_comp_pred) { | |
| 1178 mi->bmi[j].as_mode.second = (B_PREDICTION_MODE)read_bmode(bc, pbi->com
mon.fc.bmode_prob); | |
| 1179 } else { | |
| 1180 mi->bmi[j].as_mode.second = (B_PREDICTION_MODE)(B_DC_PRED - 1); | |
| 1181 } | |
| 1182 #endif | |
| 1183 } while (++j < 16); | 1129 } while (++j < 16); |
| 1184 } | 1130 } |
| 1185 | 1131 |
| 1186 if (mbmi->mode == I8X8_PRED) { | 1132 if (mbmi->mode == I8X8_PRED) { |
| 1187 int i; | 1133 int i; |
| 1188 int mode8x8; | 1134 int mode8x8; |
| 1189 for (i = 0; i < 4; i++) { | 1135 for (i = 0; i < 4; i++) { |
| 1190 int ib = vp9_i8x8_block[i]; | 1136 int ib = vp9_i8x8_block[i]; |
| 1191 mode8x8 = read_i8x8_mode(bc, pbi->common.fc.i8x8_mode_prob); | 1137 mode8x8 = read_i8x8_mode(bc, pbi->common.fc.i8x8_mode_prob); |
| 1192 mi->bmi[ib + 0].as_mode.first = mode8x8; | 1138 mi->bmi[ib + 0].as_mode.first = mode8x8; |
| 1193 mi->bmi[ib + 1].as_mode.first = mode8x8; | 1139 mi->bmi[ib + 1].as_mode.first = mode8x8; |
| 1194 mi->bmi[ib + 4].as_mode.first = mode8x8; | 1140 mi->bmi[ib + 4].as_mode.first = mode8x8; |
| 1195 mi->bmi[ib + 5].as_mode.first = mode8x8; | 1141 mi->bmi[ib + 5].as_mode.first = mode8x8; |
| 1196 pbi->common.fc.i8x8_mode_counts[mode8x8]++; | 1142 pbi->common.fc.i8x8_mode_counts[mode8x8]++; |
| 1197 #if CONFIG_COMP_INTRA_PRED | |
| 1198 mi->bmi[ib + 0].as_mode.second = (MB_PREDICTION_MODE)(DC_PRED - 1); | |
| 1199 mi->bmi[ib + 1].as_mode.second = (MB_PREDICTION_MODE)(DC_PRED - 1); | |
| 1200 mi->bmi[ib + 4].as_mode.second = (MB_PREDICTION_MODE)(DC_PRED - 1); | |
| 1201 mi->bmi[ib + 5].as_mode.second = (MB_PREDICTION_MODE)(DC_PRED - 1); | |
| 1202 #endif | |
| 1203 } | 1143 } |
| 1204 } else { | 1144 } else { |
| 1205 mbmi->uv_mode = (MB_PREDICTION_MODE)read_uv_mode( | 1145 mbmi->uv_mode = (MB_PREDICTION_MODE)read_uv_mode( |
| 1206 bc, pbi->common.fc.uv_mode_prob[mbmi->mode]); | 1146 bc, pbi->common.fc.uv_mode_prob[mbmi->mode]); |
| 1207 pbi->common.fc.uv_mode_counts[mbmi->mode][mbmi->uv_mode]++; | 1147 pbi->common.fc.uv_mode_counts[mbmi->mode][mbmi->uv_mode]++; |
| 1208 } | 1148 } |
| 1209 | |
| 1210 #if CONFIG_COMP_INTRA_PRED | |
| 1211 mbmi->second_uv_mode = (MB_PREDICTION_MODE)(DC_PRED - 1); | |
| 1212 #endif | |
| 1213 } | 1149 } |
| 1214 | 1150 |
| 1215 if (cm->txfm_mode == TX_MODE_SELECT && mbmi->mb_skip_coeff == 0 && | 1151 if (cm->txfm_mode == TX_MODE_SELECT && mbmi->mb_skip_coeff == 0 && |
| 1216 ((mbmi->ref_frame == INTRA_FRAME && mbmi->mode <= I8X8_PRED) || | 1152 ((mbmi->ref_frame == INTRA_FRAME && mbmi->mode <= I8X8_PRED) || |
| 1217 (mbmi->ref_frame != INTRA_FRAME && !(mbmi->mode == SPLITMV && | 1153 (mbmi->ref_frame != INTRA_FRAME && !(mbmi->mode == SPLITMV && |
| 1218 mbmi->partitioning == PARTITIONING_4X4)))) { | 1154 mbmi->partitioning == PARTITIONING_4X4)))) { |
| 1219 // FIXME(rbultje) code ternary symbol once all experiments are merged | 1155 // FIXME(rbultje) code ternary symbol once all experiments are merged |
| 1220 mbmi->txfm_size = vp9_read(bc, cm->prob_tx[0]); | 1156 mbmi->txfm_size = vp9_read(bc, cm->prob_tx[0]); |
| 1221 if (mbmi->txfm_size != TX_4X4 && mbmi->mode != I8X8_PRED && | 1157 if (mbmi->txfm_size != TX_4X4 && mbmi->mode != I8X8_PRED && |
| 1222 mbmi->mode != SPLITMV) | 1158 mbmi->mode != SPLITMV) { |
| 1223 mbmi->txfm_size += vp9_read(bc, cm->prob_tx[1]); | 1159 mbmi->txfm_size += vp9_read(bc, cm->prob_tx[1]); |
| 1160 if (mbmi->sb_type && mbmi->txfm_size != TX_8X8) |
| 1161 mbmi->txfm_size += vp9_read(bc, cm->prob_tx[2]); |
| 1162 } |
| 1163 } else if (mbmi->sb_type && cm->txfm_mode >= ALLOW_32X32) { |
| 1164 mbmi->txfm_size = TX_32X32; |
| 1224 } else if (cm->txfm_mode >= ALLOW_16X16 && | 1165 } else if (cm->txfm_mode >= ALLOW_16X16 && |
| 1225 ((mbmi->ref_frame == INTRA_FRAME && mbmi->mode <= TM_PRED) || | 1166 ((mbmi->ref_frame == INTRA_FRAME && mbmi->mode <= TM_PRED) || |
| 1226 (mbmi->ref_frame != INTRA_FRAME && mbmi->mode != SPLITMV))) { | 1167 (mbmi->ref_frame != INTRA_FRAME && mbmi->mode != SPLITMV))) { |
| 1227 mbmi->txfm_size = TX_16X16; | 1168 mbmi->txfm_size = TX_16X16; |
| 1228 } else if (cm->txfm_mode >= ALLOW_8X8 && | 1169 } else if (cm->txfm_mode >= ALLOW_8X8 && |
| 1229 (!(mbmi->ref_frame == INTRA_FRAME && mbmi->mode == B_PRED) && | 1170 (!(mbmi->ref_frame == INTRA_FRAME && mbmi->mode == B_PRED) && |
| 1230 !(mbmi->ref_frame != INTRA_FRAME && mbmi->mode == SPLITMV && | 1171 !(mbmi->ref_frame != INTRA_FRAME && mbmi->mode == SPLITMV && |
| 1231 mbmi->partitioning == PARTITIONING_4X4))) { | 1172 mbmi->partitioning == PARTITIONING_4X4))) { |
| 1232 mbmi->txfm_size = TX_8X8; | 1173 mbmi->txfm_size = TX_8X8; |
| 1233 } else { | 1174 } else { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1253 int mb_col, | 1194 int mb_col, |
| 1254 BOOL_DECODER* const bc) { | 1195 BOOL_DECODER* const bc) { |
| 1255 MODE_INFO *mi = xd->mode_info_context; | 1196 MODE_INFO *mi = xd->mode_info_context; |
| 1256 MODE_INFO *prev_mi = xd->prev_mode_info_context; | 1197 MODE_INFO *prev_mi = xd->prev_mode_info_context; |
| 1257 | 1198 |
| 1258 if (pbi->common.frame_type == KEY_FRAME) | 1199 if (pbi->common.frame_type == KEY_FRAME) |
| 1259 kfread_modes(pbi, mi, mb_row, mb_col, bc); | 1200 kfread_modes(pbi, mi, mb_row, mb_col, bc); |
| 1260 else | 1201 else |
| 1261 read_mb_modes_mv(pbi, mi, &mi->mbmi, prev_mi, mb_row, mb_col, bc); | 1202 read_mb_modes_mv(pbi, mi, &mi->mbmi, prev_mi, mb_row, mb_col, bc); |
| 1262 } | 1203 } |
| OLD | NEW |