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 |
11 | 11 |
12 #include <limits.h> | 12 #include <limits.h> |
13 | 13 |
14 #include "vpx_mem/vpx_mem.h" | 14 #include "vpx_mem/vpx_mem.h" |
15 | 15 |
16 #include "vp9/common/vp9_pred_common.h" | 16 #include "vp9/common/vp9_pred_common.h" |
17 #include "vp9/common/vp9_tile_common.h" | 17 #include "vp9/common/vp9_tile_common.h" |
18 | 18 |
| 19 #include "vp9/encoder/vp9_cost.h" |
19 #include "vp9/encoder/vp9_segmentation.h" | 20 #include "vp9/encoder/vp9_segmentation.h" |
20 | 21 |
21 void vp9_enable_segmentation(struct segmentation *seg) { | 22 void vp9_enable_segmentation(struct segmentation *seg) { |
22 seg->enabled = 1; | 23 seg->enabled = 1; |
23 seg->update_map = 1; | 24 seg->update_map = 1; |
24 seg->update_data = 1; | 25 seg->update_data = 1; |
25 } | 26 } |
26 | 27 |
27 void vp9_disable_segmentation(struct segmentation *seg) { | 28 void vp9_disable_segmentation(struct segmentation *seg) { |
28 seg->enabled = 0; | 29 seg->enabled = 0; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 int (*temporal_predictor_count)[2], | 126 int (*temporal_predictor_count)[2], |
126 int *t_unpred_seg_counts, | 127 int *t_unpred_seg_counts, |
127 int bw, int bh, int mi_row, int mi_col) { | 128 int bw, int bh, int mi_row, int mi_col) { |
128 VP9_COMMON *const cm = &cpi->common; | 129 VP9_COMMON *const cm = &cpi->common; |
129 MACROBLOCKD *const xd = &cpi->mb.e_mbd; | 130 MACROBLOCKD *const xd = &cpi->mb.e_mbd; |
130 int segment_id; | 131 int segment_id; |
131 | 132 |
132 if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) | 133 if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) |
133 return; | 134 return; |
134 | 135 |
135 xd->mi_8x8 = mi_8x8; | 136 xd->mi = mi_8x8; |
136 segment_id = xd->mi_8x8[0]->mbmi.segment_id; | 137 segment_id = xd->mi[0]->mbmi.segment_id; |
137 | 138 |
138 set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw, cm->mi_rows, cm->mi_cols); | 139 set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw, cm->mi_rows, cm->mi_cols); |
139 | 140 |
140 // Count the number of hits on each segment with no prediction | 141 // Count the number of hits on each segment with no prediction |
141 no_pred_segcounts[segment_id]++; | 142 no_pred_segcounts[segment_id]++; |
142 | 143 |
143 // Temporal prediction not allowed on key frames | 144 // Temporal prediction not allowed on key frames |
144 if (cm->frame_type != KEY_FRAME) { | 145 if (cm->frame_type != KEY_FRAME) { |
145 const BLOCK_SIZE bsize = mi_8x8[0]->mbmi.sb_type; | 146 const BLOCK_SIZE bsize = mi_8x8[0]->mbmi.sb_type; |
146 // Test to see if the segment id matches the predicted value. | 147 // Test to see if the segment id matches the predicted value. |
147 const int pred_segment_id = vp9_get_segment_id(cm, cm->last_frame_seg_map, | 148 const int pred_segment_id = vp9_get_segment_id(cm, cm->last_frame_seg_map, |
148 bsize, mi_row, mi_col); | 149 bsize, mi_row, mi_col); |
149 const int pred_flag = pred_segment_id == segment_id; | 150 const int pred_flag = pred_segment_id == segment_id; |
150 const int pred_context = vp9_get_pred_context_seg_id(xd); | 151 const int pred_context = vp9_get_pred_context_seg_id(xd); |
151 | 152 |
152 // Store the prediction status for this mb and update counts | 153 // Store the prediction status for this mb and update counts |
153 // as appropriate | 154 // as appropriate |
154 xd->mi_8x8[0]->mbmi.seg_id_predicted = pred_flag; | 155 xd->mi[0]->mbmi.seg_id_predicted = pred_flag; |
155 temporal_predictor_count[pred_context][pred_flag]++; | 156 temporal_predictor_count[pred_context][pred_flag]++; |
156 | 157 |
157 if (!pred_flag) | 158 if (!pred_flag) |
158 // Update the "unpredicted" segment count | 159 // Update the "unpredicted" segment count |
159 t_unpred_seg_counts[segment_id]++; | 160 t_unpred_seg_counts[segment_id]++; |
160 } | 161 } |
161 } | 162 } |
162 | 163 |
163 static void count_segs_sb(VP9_COMP *cpi, const TileInfo *const tile, | 164 static void count_segs_sb(VP9_COMP *cpi, const TileInfo *const tile, |
164 MODE_INFO **mi_8x8, | 165 MODE_INFO **mi_8x8, |
165 int *no_pred_segcounts, | 166 int *no_pred_segcounts, |
166 int (*temporal_predictor_count)[2], | 167 int (*temporal_predictor_count)[2], |
167 int *t_unpred_seg_counts, | 168 int *t_unpred_seg_counts, |
168 int mi_row, int mi_col, | 169 int mi_row, int mi_col, |
169 BLOCK_SIZE bsize) { | 170 BLOCK_SIZE bsize) { |
170 const VP9_COMMON *const cm = &cpi->common; | 171 const VP9_COMMON *const cm = &cpi->common; |
171 const int mis = cm->mode_info_stride; | 172 const int mis = cm->mi_stride; |
172 int bw, bh; | 173 int bw, bh; |
173 const int bs = num_8x8_blocks_wide_lookup[bsize], hbs = bs / 2; | 174 const int bs = num_8x8_blocks_wide_lookup[bsize], hbs = bs / 2; |
174 | 175 |
175 if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) | 176 if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) |
176 return; | 177 return; |
177 | 178 |
178 bw = num_8x8_blocks_wide_lookup[mi_8x8[0]->mbmi.sb_type]; | 179 bw = num_8x8_blocks_wide_lookup[mi_8x8[0]->mbmi.sb_type]; |
179 bh = num_8x8_blocks_high_lookup[mi_8x8[0]->mbmi.sb_type]; | 180 bh = num_8x8_blocks_high_lookup[mi_8x8[0]->mbmi.sb_type]; |
180 | 181 |
181 if (bw == bs && bh == bs) { | 182 if (bw == bs && bh == bs) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 int i, tile_col, mi_row, mi_col; | 222 int i, tile_col, mi_row, mi_col; |
222 | 223 |
223 int temporal_predictor_count[PREDICTION_PROBS][2] = { { 0 } }; | 224 int temporal_predictor_count[PREDICTION_PROBS][2] = { { 0 } }; |
224 int no_pred_segcounts[MAX_SEGMENTS] = { 0 }; | 225 int no_pred_segcounts[MAX_SEGMENTS] = { 0 }; |
225 int t_unpred_seg_counts[MAX_SEGMENTS] = { 0 }; | 226 int t_unpred_seg_counts[MAX_SEGMENTS] = { 0 }; |
226 | 227 |
227 vp9_prob no_pred_tree[SEG_TREE_PROBS]; | 228 vp9_prob no_pred_tree[SEG_TREE_PROBS]; |
228 vp9_prob t_pred_tree[SEG_TREE_PROBS]; | 229 vp9_prob t_pred_tree[SEG_TREE_PROBS]; |
229 vp9_prob t_nopred_prob[PREDICTION_PROBS]; | 230 vp9_prob t_nopred_prob[PREDICTION_PROBS]; |
230 | 231 |
231 const int mis = cm->mode_info_stride; | 232 const int mis = cm->mi_stride; |
232 MODE_INFO **mi_ptr, **mi; | 233 MODE_INFO **mi_ptr, **mi; |
233 | 234 |
234 // Set default state for the segment tree probabilities and the | 235 // Set default state for the segment tree probabilities and the |
235 // temporal coding probabilities | 236 // temporal coding probabilities |
236 vpx_memset(seg->tree_probs, 255, sizeof(seg->tree_probs)); | 237 vpx_memset(seg->tree_probs, 255, sizeof(seg->tree_probs)); |
237 vpx_memset(seg->pred_probs, 255, sizeof(seg->pred_probs)); | 238 vpx_memset(seg->pred_probs, 255, sizeof(seg->pred_probs)); |
238 | 239 |
239 // First of all generate stats regarding how well the last segment map | 240 // First of all generate stats regarding how well the last segment map |
240 // predicts this one | 241 // predicts this one |
241 for (tile_col = 0; tile_col < 1 << cm->log2_tile_cols; tile_col++) { | 242 for (tile_col = 0; tile_col < 1 << cm->log2_tile_cols; tile_col++) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 } | 292 } |
292 | 293 |
293 void vp9_reset_segment_features(struct segmentation *seg) { | 294 void vp9_reset_segment_features(struct segmentation *seg) { |
294 // Set up default state for MB feature flags | 295 // Set up default state for MB feature flags |
295 seg->enabled = 0; | 296 seg->enabled = 0; |
296 seg->update_map = 0; | 297 seg->update_map = 0; |
297 seg->update_data = 0; | 298 seg->update_data = 0; |
298 vpx_memset(seg->tree_probs, 255, sizeof(seg->tree_probs)); | 299 vpx_memset(seg->tree_probs, 255, sizeof(seg->tree_probs)); |
299 vp9_clearall_segfeatures(seg); | 300 vp9_clearall_segfeatures(seg); |
300 } | 301 } |
OLD | NEW |