| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (c) 2010 The VP8 project authors. All Rights Reserved. | |
| 3 * | |
| 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 | |
| 6 * tree. An additional intellectual property rights grant can be found | |
| 7 * in the file PATENTS. All contributing project authors may | |
| 8 * be found in the AUTHORS file in the root of the source tree. | |
| 9 */ | |
| 10 | |
| 11 | |
| 12 #include "onyxd_int.h" | |
| 13 #include "entropymode.h" | |
| 14 #include "findnearmv.h" | |
| 15 | |
| 16 | |
| 17 int vp8_read_bmode(vp8_reader *bc, const vp8_prob *p) | |
| 18 { | |
| 19 const int i = vp8_treed_read(bc, vp8_bmode_tree, p); | |
| 20 | |
| 21 return i; | |
| 22 } | |
| 23 | |
| 24 | |
| 25 int vp8_read_ymode(vp8_reader *bc, const vp8_prob *p) | |
| 26 { | |
| 27 const int i = vp8_treed_read(bc, vp8_ymode_tree, p); | |
| 28 | |
| 29 return i; | |
| 30 } | |
| 31 | |
| 32 int vp8_kfread_ymode(vp8_reader *bc, const vp8_prob *p) | |
| 33 { | |
| 34 const int i = vp8_treed_read(bc, vp8_kf_ymode_tree, p); | |
| 35 | |
| 36 return i; | |
| 37 } | |
| 38 | |
| 39 | |
| 40 | |
| 41 int vp8_read_uv_mode(vp8_reader *bc, const vp8_prob *p) | |
| 42 { | |
| 43 const int i = vp8_treed_read(bc, vp8_uv_mode_tree, p); | |
| 44 | |
| 45 return i; | |
| 46 } | |
| 47 | |
| 48 void vp8_read_mb_features(vp8_reader *r, MB_MODE_INFO *mi, MACROBLOCKD *x) | |
| 49 { | |
| 50 // Is segmentation enabled | |
| 51 if (x->segmentation_enabled && x->update_mb_segmentation_map) | |
| 52 { | |
| 53 // If so then read the segment id. | |
| 54 if (vp8_read(r, x->mb_segment_tree_probs[0])) | |
| 55 mi->segment_id = (unsigned char)(2 + vp8_read(r, x->mb_segment_tree_
probs[2])); | |
| 56 else | |
| 57 mi->segment_id = (unsigned char)(vp8_read(r, x->mb_segment_tree_prob
s[1])); | |
| 58 } | |
| 59 } | |
| 60 | |
| 61 void vp8_kfread_modes(VP8D_COMP *pbi) | |
| 62 { | |
| 63 VP8_COMMON *const cp = & pbi->common; | |
| 64 vp8_reader *const bc = & pbi->bc; | |
| 65 | |
| 66 MODE_INFO *m = cp->mi; | |
| 67 const int ms = cp->mode_info_stride; | |
| 68 | |
| 69 int mb_row = -1; | |
| 70 vp8_prob prob_skip_false = 0; | |
| 71 | |
| 72 if (cp->mb_no_coeff_skip) | |
| 73 prob_skip_false = (vp8_prob)(vp8_read_literal(bc, 8)); | |
| 74 | |
| 75 while (++mb_row < cp->mb_rows) | |
| 76 { | |
| 77 int mb_col = -1; | |
| 78 | |
| 79 while (++mb_col < cp->mb_cols) | |
| 80 { | |
| 81 MB_PREDICTION_MODE y_mode; | |
| 82 | |
| 83 // Read the Macroblock segmentation map if it is being updated expli
citly this frame (reset to 0 above by default) | |
| 84 // By default on a key frame reset all MBs to segment 0 | |
| 85 m->mbmi.segment_id = 0; | |
| 86 | |
| 87 if (pbi->mb.update_mb_segmentation_map) | |
| 88 vp8_read_mb_features(bc, &m->mbmi, &pbi->mb); | |
| 89 | |
| 90 // Read the macroblock coeff skip flag if this feature is in use, el
se default to 0 | |
| 91 if (cp->mb_no_coeff_skip) | |
| 92 m->mbmi.mb_skip_coeff = vp8_read(bc, prob_skip_false); | |
| 93 else | |
| 94 m->mbmi.mb_skip_coeff = 0; | |
| 95 | |
| 96 y_mode = (MB_PREDICTION_MODE) vp8_kfread_ymode(bc, cp->kf_ymode_prob
); | |
| 97 | |
| 98 m->mbmi.ref_frame = INTRA_FRAME; | |
| 99 | |
| 100 if ((m->mbmi.mode = y_mode) == B_PRED) | |
| 101 { | |
| 102 int i = 0; | |
| 103 | |
| 104 do | |
| 105 { | |
| 106 const B_PREDICTION_MODE A = vp8_above_bmi(m, i, ms)->mode; | |
| 107 const B_PREDICTION_MODE L = vp8_left_bmi(m, i)->mode; | |
| 108 | |
| 109 m->bmi[i].mode = (B_PREDICTION_MODE) vp8_read_bmode(bc, cp->
kf_bmode_prob [A] [L]); | |
| 110 } | |
| 111 while (++i < 16); | |
| 112 } | |
| 113 else | |
| 114 { | |
| 115 int BMode; | |
| 116 int i = 0; | |
| 117 | |
| 118 switch (y_mode) | |
| 119 { | |
| 120 case DC_PRED: | |
| 121 BMode = B_DC_PRED; | |
| 122 break; | |
| 123 case V_PRED: | |
| 124 BMode = B_VE_PRED; | |
| 125 break; | |
| 126 case H_PRED: | |
| 127 BMode = B_HE_PRED; | |
| 128 break; | |
| 129 case TM_PRED: | |
| 130 BMode = B_TM_PRED; | |
| 131 break; | |
| 132 default: | |
| 133 BMode = B_DC_PRED; | |
| 134 break; | |
| 135 } | |
| 136 | |
| 137 do | |
| 138 { | |
| 139 m->bmi[i].mode = (B_PREDICTION_MODE)BMode; | |
| 140 } | |
| 141 while (++i < 16); | |
| 142 } | |
| 143 | |
| 144 (m++)->mbmi.uv_mode = (MB_PREDICTION_MODE)vp8_read_uv_mode(bc, cp->k
f_uv_mode_prob); | |
| 145 } | |
| 146 | |
| 147 m++; // skip the border | |
| 148 } | |
| 149 } | |
| OLD | NEW |