OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 segcounts[5] * vp9_cost_one(probs[5]); | 104 segcounts[5] * vp9_cost_one(probs[5]); |
105 if (c67 > 0) | 105 if (c67 > 0) |
106 cost += segcounts[6] * vp9_cost_zero(probs[6]) + | 106 cost += segcounts[6] * vp9_cost_zero(probs[6]) + |
107 segcounts[7] * vp9_cost_one(probs[6]); | 107 segcounts[7] * vp9_cost_one(probs[6]); |
108 } | 108 } |
109 | 109 |
110 return cost; | 110 return cost; |
111 } | 111 } |
112 | 112 |
113 static void count_segs(const VP9_COMMON *cm, MACROBLOCKD *xd, | 113 static void count_segs(const VP9_COMMON *cm, MACROBLOCKD *xd, |
114 const TileInfo *tile, MODE_INFO **mi, | 114 const TileInfo *tile, MODE_INFO *mi, |
115 int *no_pred_segcounts, | 115 int *no_pred_segcounts, |
116 int (*temporal_predictor_count)[2], | 116 int (*temporal_predictor_count)[2], |
117 int *t_unpred_seg_counts, | 117 int *t_unpred_seg_counts, |
118 int bw, int bh, int mi_row, int mi_col) { | 118 int bw, int bh, int mi_row, int mi_col) { |
119 int segment_id; | 119 int segment_id; |
120 | 120 |
121 if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) | 121 if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) |
122 return; | 122 return; |
123 | 123 |
124 xd->mi = mi; | 124 xd->mi = mi; |
125 segment_id = xd->mi[0]->mbmi.segment_id; | 125 segment_id = xd->mi[0].src_mi->mbmi.segment_id; |
126 | 126 |
127 set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw, cm->mi_rows, cm->mi_cols); | 127 set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw, cm->mi_rows, cm->mi_cols); |
128 | 128 |
129 // Count the number of hits on each segment with no prediction | 129 // Count the number of hits on each segment with no prediction |
130 no_pred_segcounts[segment_id]++; | 130 no_pred_segcounts[segment_id]++; |
131 | 131 |
132 // Temporal prediction not allowed on key frames | 132 // Temporal prediction not allowed on key frames |
133 if (cm->frame_type != KEY_FRAME) { | 133 if (cm->frame_type != KEY_FRAME) { |
134 const BLOCK_SIZE bsize = xd->mi[0]->mbmi.sb_type; | 134 const BLOCK_SIZE bsize = xd->mi[0].src_mi->mbmi.sb_type; |
135 // Test to see if the segment id matches the predicted value. | 135 // Test to see if the segment id matches the predicted value. |
136 const int pred_segment_id = vp9_get_segment_id(cm, cm->last_frame_seg_map, | 136 const int pred_segment_id = vp9_get_segment_id(cm, cm->last_frame_seg_map, |
137 bsize, mi_row, mi_col); | 137 bsize, mi_row, mi_col); |
138 const int pred_flag = pred_segment_id == segment_id; | 138 const int pred_flag = pred_segment_id == segment_id; |
139 const int pred_context = vp9_get_pred_context_seg_id(xd); | 139 const int pred_context = vp9_get_pred_context_seg_id(xd); |
140 | 140 |
141 // Store the prediction status for this mb and update counts | 141 // Store the prediction status for this mb and update counts |
142 // as appropriate | 142 // as appropriate |
143 xd->mi[0]->mbmi.seg_id_predicted = pred_flag; | 143 xd->mi[0].src_mi->mbmi.seg_id_predicted = pred_flag; |
144 temporal_predictor_count[pred_context][pred_flag]++; | 144 temporal_predictor_count[pred_context][pred_flag]++; |
145 | 145 |
146 // Update the "unpredicted" segment count | 146 // Update the "unpredicted" segment count |
147 if (!pred_flag) | 147 if (!pred_flag) |
148 t_unpred_seg_counts[segment_id]++; | 148 t_unpred_seg_counts[segment_id]++; |
149 } | 149 } |
150 } | 150 } |
151 | 151 |
152 static void count_segs_sb(const VP9_COMMON *cm, MACROBLOCKD *xd, | 152 static void count_segs_sb(const VP9_COMMON *cm, MACROBLOCKD *xd, |
153 const TileInfo *tile, MODE_INFO **mi, | 153 const TileInfo *tile, MODE_INFO *mi, |
154 int *no_pred_segcounts, | 154 int *no_pred_segcounts, |
155 int (*temporal_predictor_count)[2], | 155 int (*temporal_predictor_count)[2], |
156 int *t_unpred_seg_counts, | 156 int *t_unpred_seg_counts, |
157 int mi_row, int mi_col, | 157 int mi_row, int mi_col, |
158 BLOCK_SIZE bsize) { | 158 BLOCK_SIZE bsize) { |
159 const int mis = cm->mi_stride; | 159 const int mis = cm->mi_stride; |
160 int bw, bh; | 160 int bw, bh; |
161 const int bs = num_8x8_blocks_wide_lookup[bsize], hbs = bs / 2; | 161 const int bs = num_8x8_blocks_wide_lookup[bsize], hbs = bs / 2; |
162 | 162 |
163 if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) | 163 if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) |
164 return; | 164 return; |
165 | 165 |
166 bw = num_8x8_blocks_wide_lookup[mi[0]->mbmi.sb_type]; | 166 bw = num_8x8_blocks_wide_lookup[mi[0].src_mi->mbmi.sb_type]; |
167 bh = num_8x8_blocks_high_lookup[mi[0]->mbmi.sb_type]; | 167 bh = num_8x8_blocks_high_lookup[mi[0].src_mi->mbmi.sb_type]; |
168 | 168 |
169 if (bw == bs && bh == bs) { | 169 if (bw == bs && bh == bs) { |
170 count_segs(cm, xd, tile, mi, no_pred_segcounts, temporal_predictor_count, | 170 count_segs(cm, xd, tile, mi, no_pred_segcounts, temporal_predictor_count, |
171 t_unpred_seg_counts, bs, bs, mi_row, mi_col); | 171 t_unpred_seg_counts, bs, bs, mi_row, mi_col); |
172 } else if (bw == bs && bh < bs) { | 172 } else if (bw == bs && bh < bs) { |
173 count_segs(cm, xd, tile, mi, no_pred_segcounts, temporal_predictor_count, | 173 count_segs(cm, xd, tile, mi, no_pred_segcounts, temporal_predictor_count, |
174 t_unpred_seg_counts, bs, hbs, mi_row, mi_col); | 174 t_unpred_seg_counts, bs, hbs, mi_row, mi_col); |
175 count_segs(cm, xd, tile, mi + hbs * mis, no_pred_segcounts, | 175 count_segs(cm, xd, tile, mi + hbs * mis, no_pred_segcounts, |
176 temporal_predictor_count, t_unpred_seg_counts, bs, hbs, | 176 temporal_predictor_count, t_unpred_seg_counts, bs, hbs, |
177 mi_row + hbs, mi_col); | 177 mi_row + hbs, mi_col); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 | 217 |
218 // Set default state for the segment tree probabilities and the | 218 // Set default state for the segment tree probabilities and the |
219 // temporal coding probabilities | 219 // temporal coding probabilities |
220 vpx_memset(seg->tree_probs, 255, sizeof(seg->tree_probs)); | 220 vpx_memset(seg->tree_probs, 255, sizeof(seg->tree_probs)); |
221 vpx_memset(seg->pred_probs, 255, sizeof(seg->pred_probs)); | 221 vpx_memset(seg->pred_probs, 255, sizeof(seg->pred_probs)); |
222 | 222 |
223 // First of all generate stats regarding how well the last segment map | 223 // First of all generate stats regarding how well the last segment map |
224 // predicts this one | 224 // predicts this one |
225 for (tile_col = 0; tile_col < 1 << cm->log2_tile_cols; tile_col++) { | 225 for (tile_col = 0; tile_col < 1 << cm->log2_tile_cols; tile_col++) { |
226 TileInfo tile; | 226 TileInfo tile; |
227 MODE_INFO **mi_ptr; | 227 MODE_INFO *mi_ptr; |
228 vp9_tile_init(&tile, cm, 0, tile_col); | 228 vp9_tile_init(&tile, cm, 0, tile_col); |
229 | 229 |
230 mi_ptr = cm->mi_grid_visible + tile.mi_col_start; | 230 mi_ptr = cm->mi + tile.mi_col_start; |
231 for (mi_row = 0; mi_row < cm->mi_rows; | 231 for (mi_row = 0; mi_row < cm->mi_rows; |
232 mi_row += 8, mi_ptr += 8 * cm->mi_stride) { | 232 mi_row += 8, mi_ptr += 8 * cm->mi_stride) { |
233 MODE_INFO **mi = mi_ptr; | 233 MODE_INFO *mi = mi_ptr; |
234 for (mi_col = tile.mi_col_start; mi_col < tile.mi_col_end; | 234 for (mi_col = tile.mi_col_start; mi_col < tile.mi_col_end; |
235 mi_col += 8, mi += 8) | 235 mi_col += 8, mi += 8) |
236 count_segs_sb(cm, xd, &tile, mi, no_pred_segcounts, | 236 count_segs_sb(cm, xd, &tile, mi, no_pred_segcounts, |
237 temporal_predictor_count, t_unpred_seg_counts, | 237 temporal_predictor_count, t_unpred_seg_counts, |
238 mi_row, mi_col, BLOCK_64X64); | 238 mi_row, mi_col, BLOCK_64X64); |
239 } | 239 } |
240 } | 240 } |
241 | 241 |
242 // Work out probability tree for coding segments without prediction | 242 // Work out probability tree for coding segments without prediction |
243 // and the cost. | 243 // and the cost. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 } | 276 } |
277 | 277 |
278 void vp9_reset_segment_features(struct segmentation *seg) { | 278 void vp9_reset_segment_features(struct segmentation *seg) { |
279 // Set up default state for MB feature flags | 279 // Set up default state for MB feature flags |
280 seg->enabled = 0; | 280 seg->enabled = 0; |
281 seg->update_map = 0; | 281 seg->update_map = 0; |
282 seg->update_data = 0; | 282 seg->update_data = 0; |
283 vpx_memset(seg->tree_probs, 255, sizeof(seg->tree_probs)); | 283 vpx_memset(seg->tree_probs, 255, sizeof(seg->tree_probs)); |
284 vp9_clearall_segfeatures(seg); | 284 vp9_clearall_segfeatures(seg); |
285 } | 285 } |
OLD | NEW |