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 #include <assert.h> | 11 #include <assert.h> |
12 | 12 |
13 #include "vp9/common/vp9_common.h" | 13 #include "vp9/common/vp9_common.h" |
14 #include "vp9/common/vp9_entropy.h" | 14 #include "vp9/common/vp9_entropy.h" |
15 #include "vp9/common/vp9_entropymode.h" | 15 #include "vp9/common/vp9_entropymode.h" |
16 #include "vp9/common/vp9_entropymv.h" | 16 #include "vp9/common/vp9_entropymv.h" |
17 #include "vp9/common/vp9_mvref_common.h" | 17 #include "vp9/common/vp9_mvref_common.h" |
18 #include "vp9/common/vp9_pred_common.h" | 18 #include "vp9/common/vp9_pred_common.h" |
19 #include "vp9/common/vp9_reconinter.h" | 19 #include "vp9/common/vp9_reconinter.h" |
20 #include "vp9/common/vp9_seg_common.h" | 20 #include "vp9/common/vp9_seg_common.h" |
21 | 21 |
22 #include "vp9/decoder/vp9_decodemv.h" | 22 #include "vp9/decoder/vp9_decodemv.h" |
23 #include "vp9/decoder/vp9_decodeframe.h" | 23 #include "vp9/decoder/vp9_decodeframe.h" |
24 #include "vp9/decoder/vp9_onyxd_int.h" | |
25 #include "vp9/decoder/vp9_reader.h" | 24 #include "vp9/decoder/vp9_reader.h" |
26 | 25 |
27 static MB_PREDICTION_MODE read_intra_mode(vp9_reader *r, const vp9_prob *p) { | 26 static MB_PREDICTION_MODE read_intra_mode(vp9_reader *r, const vp9_prob *p) { |
28 return (MB_PREDICTION_MODE)vp9_read_tree(r, vp9_intra_mode_tree, p); | 27 return (MB_PREDICTION_MODE)vp9_read_tree(r, vp9_intra_mode_tree, p); |
29 } | 28 } |
30 | 29 |
31 static MB_PREDICTION_MODE read_intra_mode_y(VP9_COMMON *cm, vp9_reader *r, | 30 static MB_PREDICTION_MODE read_intra_mode_y(VP9_COMMON *cm, vp9_reader *r, |
32 int size_group) { | 31 int size_group) { |
33 const MB_PREDICTION_MODE y_mode = read_intra_mode(r, | 32 const MB_PREDICTION_MODE y_mode = read_intra_mode(r, |
34 cm->fc.y_mode_prob[size_group]); | 33 cm->fc.y_mode_prob[size_group]); |
(...skipping 22 matching lines...) Expand all Loading... |
57 } | 56 } |
58 | 57 |
59 static int read_segment_id(vp9_reader *r, const struct segmentation *seg) { | 58 static int read_segment_id(vp9_reader *r, const struct segmentation *seg) { |
60 return vp9_read_tree(r, vp9_segment_tree, seg->tree_probs); | 59 return vp9_read_tree(r, vp9_segment_tree, seg->tree_probs); |
61 } | 60 } |
62 | 61 |
63 static TX_SIZE read_selected_tx_size(VP9_COMMON *cm, MACROBLOCKD *xd, | 62 static TX_SIZE read_selected_tx_size(VP9_COMMON *cm, MACROBLOCKD *xd, |
64 TX_SIZE max_tx_size, vp9_reader *r) { | 63 TX_SIZE max_tx_size, vp9_reader *r) { |
65 const int ctx = vp9_get_tx_size_context(xd); | 64 const int ctx = vp9_get_tx_size_context(xd); |
66 const vp9_prob *tx_probs = get_tx_probs(max_tx_size, ctx, &cm->fc.tx_probs); | 65 const vp9_prob *tx_probs = get_tx_probs(max_tx_size, ctx, &cm->fc.tx_probs); |
67 TX_SIZE tx_size = vp9_read(r, tx_probs[0]); | 66 int tx_size = vp9_read(r, tx_probs[0]); |
68 if (tx_size != TX_4X4 && max_tx_size >= TX_16X16) { | 67 if (tx_size != TX_4X4 && max_tx_size >= TX_16X16) { |
69 tx_size += vp9_read(r, tx_probs[1]); | 68 tx_size += vp9_read(r, tx_probs[1]); |
70 if (tx_size != TX_8X8 && max_tx_size >= TX_32X32) | 69 if (tx_size != TX_8X8 && max_tx_size >= TX_32X32) |
71 tx_size += vp9_read(r, tx_probs[2]); | 70 tx_size += vp9_read(r, tx_probs[2]); |
72 } | 71 } |
73 | 72 |
74 if (!cm->frame_parallel_decoding_mode) | 73 if (!cm->frame_parallel_decoding_mode) |
75 ++get_tx_counts(max_tx_size, ctx, &cm->counts.tx)[tx_size]; | 74 ++get_tx_counts(max_tx_size, ctx, &cm->counts.tx)[tx_size]; |
76 return tx_size; | 75 return (TX_SIZE)tx_size; |
77 } | 76 } |
78 | 77 |
79 static TX_SIZE read_tx_size(VP9_COMMON *cm, MACROBLOCKD *xd, TX_MODE tx_mode, | 78 static TX_SIZE read_tx_size(VP9_COMMON *cm, MACROBLOCKD *xd, TX_MODE tx_mode, |
80 BLOCK_SIZE bsize, int allow_select, vp9_reader *r) { | 79 BLOCK_SIZE bsize, int allow_select, vp9_reader *r) { |
81 const TX_SIZE max_tx_size = max_txsize_lookup[bsize]; | 80 const TX_SIZE max_tx_size = max_txsize_lookup[bsize]; |
82 if (allow_select && tx_mode == TX_MODE_SELECT && bsize >= BLOCK_8X8) | 81 if (allow_select && tx_mode == TX_MODE_SELECT && bsize >= BLOCK_8X8) |
83 return read_selected_tx_size(cm, xd, max_tx_size, r); | 82 return read_selected_tx_size(cm, xd, max_tx_size, r); |
84 else | 83 else |
85 return MIN(max_tx_size, tx_mode_to_biggest_tx_size[tx_mode]); | 84 return MIN(max_tx_size, tx_mode_to_biggest_tx_size[tx_mode]); |
86 } | 85 } |
(...skipping 11 matching lines...) Expand all Loading... |
98 | 97 |
99 for (y = 0; y < ymis; y++) | 98 for (y = 0; y < ymis; y++) |
100 for (x = 0; x < xmis; x++) | 99 for (x = 0; x < xmis; x++) |
101 cm->last_frame_seg_map[mi_offset + y * cm->mi_cols + x] = segment_id; | 100 cm->last_frame_seg_map[mi_offset + y * cm->mi_cols + x] = segment_id; |
102 } | 101 } |
103 | 102 |
104 static int read_intra_segment_id(VP9_COMMON *const cm, MACROBLOCKD *const xd, | 103 static int read_intra_segment_id(VP9_COMMON *const cm, MACROBLOCKD *const xd, |
105 int mi_row, int mi_col, | 104 int mi_row, int mi_col, |
106 vp9_reader *r) { | 105 vp9_reader *r) { |
107 struct segmentation *const seg = &cm->seg; | 106 struct segmentation *const seg = &cm->seg; |
108 const BLOCK_SIZE bsize = xd->mi_8x8[0]->mbmi.sb_type; | 107 const BLOCK_SIZE bsize = xd->mi[0]->mbmi.sb_type; |
109 int segment_id; | 108 int segment_id; |
110 | 109 |
111 if (!seg->enabled) | 110 if (!seg->enabled) |
112 return 0; // Default for disabled segmentation | 111 return 0; // Default for disabled segmentation |
113 | 112 |
114 if (!seg->update_map) | 113 if (!seg->update_map) |
115 return 0; | 114 return 0; |
116 | 115 |
117 segment_id = read_segment_id(r, seg); | 116 segment_id = read_segment_id(r, seg); |
118 set_segment_id(cm, bsize, mi_row, mi_col, segment_id); | 117 set_segment_id(cm, bsize, mi_row, mi_col, segment_id); |
119 return segment_id; | 118 return segment_id; |
120 } | 119 } |
121 | 120 |
122 static int read_inter_segment_id(VP9_COMMON *const cm, MACROBLOCKD *const xd, | 121 static int read_inter_segment_id(VP9_COMMON *const cm, MACROBLOCKD *const xd, |
123 int mi_row, int mi_col, vp9_reader *r) { | 122 int mi_row, int mi_col, vp9_reader *r) { |
124 struct segmentation *const seg = &cm->seg; | 123 struct segmentation *const seg = &cm->seg; |
125 MB_MODE_INFO *const mbmi = &xd->mi_8x8[0]->mbmi; | 124 MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; |
126 const BLOCK_SIZE bsize = mbmi->sb_type; | 125 const BLOCK_SIZE bsize = mbmi->sb_type; |
127 int predicted_segment_id, segment_id; | 126 int predicted_segment_id, segment_id; |
128 | 127 |
129 if (!seg->enabled) | 128 if (!seg->enabled) |
130 return 0; // Default for disabled segmentation | 129 return 0; // Default for disabled segmentation |
131 | 130 |
132 predicted_segment_id = vp9_get_segment_id(cm, cm->last_frame_seg_map, | 131 predicted_segment_id = vp9_get_segment_id(cm, cm->last_frame_seg_map, |
133 bsize, mi_row, mi_col); | 132 bsize, mi_row, mi_col); |
134 if (!seg->update_map) | 133 if (!seg->update_map) |
135 return predicted_segment_id; | 134 return predicted_segment_id; |
(...skipping 19 matching lines...) Expand all Loading... |
155 const int skip = vp9_read(r, cm->fc.skip_probs[ctx]); | 154 const int skip = vp9_read(r, cm->fc.skip_probs[ctx]); |
156 if (!cm->frame_parallel_decoding_mode) | 155 if (!cm->frame_parallel_decoding_mode) |
157 ++cm->counts.skip[ctx][skip]; | 156 ++cm->counts.skip[ctx][skip]; |
158 return skip; | 157 return skip; |
159 } | 158 } |
160 } | 159 } |
161 | 160 |
162 static void read_intra_frame_mode_info(VP9_COMMON *const cm, | 161 static void read_intra_frame_mode_info(VP9_COMMON *const cm, |
163 MACROBLOCKD *const xd, | 162 MACROBLOCKD *const xd, |
164 int mi_row, int mi_col, vp9_reader *r) { | 163 int mi_row, int mi_col, vp9_reader *r) { |
165 MODE_INFO *const mi = xd->mi_8x8[0]; | 164 MODE_INFO *const mi = xd->mi[0]; |
166 MB_MODE_INFO *const mbmi = &mi->mbmi; | 165 MB_MODE_INFO *const mbmi = &mi->mbmi; |
167 const MODE_INFO *above_mi = xd->mi_8x8[-cm->mode_info_stride]; | 166 const MODE_INFO *above_mi = xd->mi[-cm->mi_stride]; |
168 const MODE_INFO *left_mi = xd->left_available ? xd->mi_8x8[-1] : NULL; | 167 const MODE_INFO *left_mi = xd->left_available ? xd->mi[-1] : NULL; |
169 const BLOCK_SIZE bsize = mbmi->sb_type; | 168 const BLOCK_SIZE bsize = mbmi->sb_type; |
| 169 int i; |
170 | 170 |
171 mbmi->segment_id = read_intra_segment_id(cm, xd, mi_row, mi_col, r); | 171 mbmi->segment_id = read_intra_segment_id(cm, xd, mi_row, mi_col, r); |
172 mbmi->skip = read_skip(cm, xd, mbmi->segment_id, r); | 172 mbmi->skip = read_skip(cm, xd, mbmi->segment_id, r); |
173 mbmi->tx_size = read_tx_size(cm, xd, cm->tx_mode, bsize, 1, r); | 173 mbmi->tx_size = read_tx_size(cm, xd, cm->tx_mode, bsize, 1, r); |
174 mbmi->ref_frame[0] = INTRA_FRAME; | 174 mbmi->ref_frame[0] = INTRA_FRAME; |
175 mbmi->ref_frame[1] = NONE; | 175 mbmi->ref_frame[1] = NONE; |
176 | 176 |
177 if (bsize >= BLOCK_8X8) { | 177 switch (bsize) { |
178 const MB_PREDICTION_MODE A = vp9_above_block_mode(mi, above_mi, 0); | 178 case BLOCK_4X4: |
179 const MB_PREDICTION_MODE L = vp9_left_block_mode(mi, left_mi, 0); | 179 for (i = 0; i < 4; ++i) |
180 mbmi->mode = read_intra_mode(r, vp9_kf_y_mode_prob[A][L]); | 180 mi->bmi[i].as_mode = |
181 } else { | 181 read_intra_mode(r, get_y_mode_probs(mi, above_mi, left_mi, i)); |
182 // Only 4x4, 4x8, 8x4 blocks | 182 mbmi->mode = mi->bmi[3].as_mode; |
183 const int num_4x4_w = num_4x4_blocks_wide_lookup[bsize]; // 1 or 2 | 183 break; |
184 const int num_4x4_h = num_4x4_blocks_high_lookup[bsize]; // 1 or 2 | 184 case BLOCK_4X8: |
185 int idx, idy; | 185 mi->bmi[0].as_mode = mi->bmi[2].as_mode = |
186 | 186 read_intra_mode(r, get_y_mode_probs(mi, above_mi, left_mi, 0)); |
187 for (idy = 0; idy < 2; idy += num_4x4_h) { | 187 mi->bmi[1].as_mode = mi->bmi[3].as_mode = mbmi->mode = |
188 for (idx = 0; idx < 2; idx += num_4x4_w) { | 188 read_intra_mode(r, get_y_mode_probs(mi, above_mi, left_mi, 1)); |
189 const int ib = idy * 2 + idx; | 189 break; |
190 const MB_PREDICTION_MODE A = vp9_above_block_mode(mi, above_mi, ib); | 190 case BLOCK_8X4: |
191 const MB_PREDICTION_MODE L = vp9_left_block_mode(mi, left_mi, ib); | 191 mi->bmi[0].as_mode = mi->bmi[1].as_mode = |
192 const MB_PREDICTION_MODE b_mode = read_intra_mode(r, | 192 read_intra_mode(r, get_y_mode_probs(mi, above_mi, left_mi, 0)); |
193 vp9_kf_y_mode_prob[A][L]); | 193 mi->bmi[2].as_mode = mi->bmi[3].as_mode = mbmi->mode = |
194 mi->bmi[ib].as_mode = b_mode; | 194 read_intra_mode(r, get_y_mode_probs(mi, above_mi, left_mi, 2)); |
195 if (num_4x4_h == 2) | 195 break; |
196 mi->bmi[ib + 2].as_mode = b_mode; | 196 default: |
197 if (num_4x4_w == 2) | 197 mbmi->mode = read_intra_mode(r, |
198 mi->bmi[ib + 1].as_mode = b_mode; | 198 get_y_mode_probs(mi, above_mi, left_mi, 0)); |
199 } | |
200 } | |
201 | |
202 mbmi->mode = mi->bmi[3].as_mode; | |
203 } | 199 } |
204 | 200 |
205 mbmi->uv_mode = read_intra_mode(r, vp9_kf_uv_mode_prob[mbmi->mode]); | 201 mbmi->uv_mode = read_intra_mode(r, vp9_kf_uv_mode_prob[mbmi->mode]); |
206 } | 202 } |
207 | 203 |
208 static int read_mv_component(vp9_reader *r, | 204 static int read_mv_component(vp9_reader *r, |
209 const nmv_component *mvcomp, int usehp) { | 205 const nmv_component *mvcomp, int usehp) { |
210 int mag, d, fr, hp; | 206 int mag, d, fr, hp; |
211 const int sign = vp9_read(r, mvcomp->sign); | 207 const int sign = vp9_read(r, mvcomp->sign); |
212 const int mv_class = vp9_read_tree(r, vp9_mv_class_tree, mvcomp->classes); | 208 const int mv_class = vp9_read_tree(r, vp9_mv_class_tree, mvcomp->classes); |
(...skipping 21 matching lines...) Expand all Loading... |
234 : 1; | 230 : 1; |
235 | 231 |
236 // Result | 232 // Result |
237 mag = vp9_get_mv_mag(mv_class, (d << 3) | (fr << 1) | hp) + 1; | 233 mag = vp9_get_mv_mag(mv_class, (d << 3) | (fr << 1) | hp) + 1; |
238 return sign ? -mag : mag; | 234 return sign ? -mag : mag; |
239 } | 235 } |
240 | 236 |
241 static INLINE void read_mv(vp9_reader *r, MV *mv, const MV *ref, | 237 static INLINE void read_mv(vp9_reader *r, MV *mv, const MV *ref, |
242 const nmv_context *ctx, | 238 const nmv_context *ctx, |
243 nmv_context_counts *counts, int allow_hp) { | 239 nmv_context_counts *counts, int allow_hp) { |
244 const MV_JOINT_TYPE j = vp9_read_tree(r, vp9_mv_joint_tree, ctx->joints); | 240 const MV_JOINT_TYPE joint_type = |
| 241 (MV_JOINT_TYPE)vp9_read_tree(r, vp9_mv_joint_tree, ctx->joints); |
245 const int use_hp = allow_hp && vp9_use_mv_hp(ref); | 242 const int use_hp = allow_hp && vp9_use_mv_hp(ref); |
246 MV diff = {0, 0}; | 243 MV diff = {0, 0}; |
247 | 244 |
248 if (mv_joint_vertical(j)) | 245 if (mv_joint_vertical(joint_type)) |
249 diff.row = read_mv_component(r, &ctx->comps[0], use_hp); | 246 diff.row = read_mv_component(r, &ctx->comps[0], use_hp); |
250 | 247 |
251 if (mv_joint_horizontal(j)) | 248 if (mv_joint_horizontal(joint_type)) |
252 diff.col = read_mv_component(r, &ctx->comps[1], use_hp); | 249 diff.col = read_mv_component(r, &ctx->comps[1], use_hp); |
253 | 250 |
254 vp9_inc_mv(&diff, counts); | 251 vp9_inc_mv(&diff, counts); |
255 | 252 |
256 mv->row = ref->row + diff.row; | 253 mv->row = ref->row + diff.row; |
257 mv->col = ref->col + diff.col; | 254 mv->col = ref->col + diff.col; |
258 } | 255 } |
259 | 256 |
260 static REFERENCE_MODE read_block_reference_mode(VP9_COMMON *cm, | 257 static REFERENCE_MODE read_block_reference_mode(VP9_COMMON *cm, |
261 const MACROBLOCKD *xd, | 258 const MACROBLOCKD *xd, |
262 vp9_reader *r) { | 259 vp9_reader *r) { |
263 if (cm->reference_mode == REFERENCE_MODE_SELECT) { | 260 if (cm->reference_mode == REFERENCE_MODE_SELECT) { |
264 const int ctx = vp9_get_reference_mode_context(cm, xd); | 261 const int ctx = vp9_get_reference_mode_context(cm, xd); |
265 const int mode = vp9_read(r, cm->fc.comp_inter_prob[ctx]); | 262 const REFERENCE_MODE mode = |
| 263 (REFERENCE_MODE)vp9_read(r, cm->fc.comp_inter_prob[ctx]); |
266 if (!cm->frame_parallel_decoding_mode) | 264 if (!cm->frame_parallel_decoding_mode) |
267 ++cm->counts.comp_inter[ctx][mode]; | 265 ++cm->counts.comp_inter[ctx][mode]; |
268 return mode; // SINGLE_REFERENCE or COMPOUND_REFERENCE | 266 return mode; // SINGLE_REFERENCE or COMPOUND_REFERENCE |
269 } else { | 267 } else { |
270 return cm->reference_mode; | 268 return cm->reference_mode; |
271 } | 269 } |
272 } | 270 } |
273 | 271 |
274 // Read the referncence frame | 272 // Read the referncence frame |
275 static void read_ref_frames(VP9_COMMON *const cm, MACROBLOCKD *const xd, | 273 static void read_ref_frames(VP9_COMMON *const cm, MACROBLOCKD *const xd, |
276 vp9_reader *r, | 274 vp9_reader *r, |
277 int segment_id, MV_REFERENCE_FRAME ref_frame[2]) { | 275 int segment_id, MV_REFERENCE_FRAME ref_frame[2]) { |
278 FRAME_CONTEXT *const fc = &cm->fc; | 276 FRAME_CONTEXT *const fc = &cm->fc; |
279 FRAME_COUNTS *const counts = &cm->counts; | 277 FRAME_COUNTS *const counts = &cm->counts; |
280 | 278 |
281 if (vp9_segfeature_active(&cm->seg, segment_id, SEG_LVL_REF_FRAME)) { | 279 if (vp9_segfeature_active(&cm->seg, segment_id, SEG_LVL_REF_FRAME)) { |
282 ref_frame[0] = vp9_get_segdata(&cm->seg, segment_id, SEG_LVL_REF_FRAME); | 280 ref_frame[0] = (MV_REFERENCE_FRAME)vp9_get_segdata(&cm->seg, segment_id, |
| 281 SEG_LVL_REF_FRAME); |
283 ref_frame[1] = NONE; | 282 ref_frame[1] = NONE; |
284 } else { | 283 } else { |
285 const REFERENCE_MODE mode = read_block_reference_mode(cm, xd, r); | 284 const REFERENCE_MODE mode = read_block_reference_mode(cm, xd, r); |
286 // FIXME(rbultje) I'm pretty sure this breaks segmentation ref frame coding | 285 // FIXME(rbultje) I'm pretty sure this breaks segmentation ref frame coding |
287 if (mode == COMPOUND_REFERENCE) { | 286 if (mode == COMPOUND_REFERENCE) { |
288 const int idx = cm->ref_frame_sign_bias[cm->comp_fixed_ref]; | 287 const int idx = cm->ref_frame_sign_bias[cm->comp_fixed_ref]; |
289 const int ctx = vp9_get_pred_context_comp_ref_p(cm, xd); | 288 const int ctx = vp9_get_pred_context_comp_ref_p(cm, xd); |
290 const int bit = vp9_read(r, fc->comp_ref_prob[ctx]); | 289 const int bit = vp9_read(r, fc->comp_ref_prob[ctx]); |
291 if (!cm->frame_parallel_decoding_mode) | 290 if (!cm->frame_parallel_decoding_mode) |
292 ++counts->comp_ref[ctx][bit]; | 291 ++counts->comp_ref[ctx][bit]; |
(...skipping 18 matching lines...) Expand all Loading... |
311 } else { | 310 } else { |
312 assert(0 && "Invalid prediction mode."); | 311 assert(0 && "Invalid prediction mode."); |
313 } | 312 } |
314 } | 313 } |
315 } | 314 } |
316 | 315 |
317 | 316 |
318 static INLINE INTERP_FILTER read_switchable_interp_filter( | 317 static INLINE INTERP_FILTER read_switchable_interp_filter( |
319 VP9_COMMON *const cm, MACROBLOCKD *const xd, vp9_reader *r) { | 318 VP9_COMMON *const cm, MACROBLOCKD *const xd, vp9_reader *r) { |
320 const int ctx = vp9_get_pred_context_switchable_interp(xd); | 319 const int ctx = vp9_get_pred_context_switchable_interp(xd); |
321 const int type = vp9_read_tree(r, vp9_switchable_interp_tree, | 320 const INTERP_FILTER type = |
322 cm->fc.switchable_interp_prob[ctx]); | 321 (INTERP_FILTER)vp9_read_tree(r, vp9_switchable_interp_tree, |
| 322 cm->fc.switchable_interp_prob[ctx]); |
323 if (!cm->frame_parallel_decoding_mode) | 323 if (!cm->frame_parallel_decoding_mode) |
324 ++cm->counts.switchable_interp[ctx][type]; | 324 ++cm->counts.switchable_interp[ctx][type]; |
325 return type; | 325 return type; |
326 } | 326 } |
327 | 327 |
328 static void read_intra_block_mode_info(VP9_COMMON *const cm, MODE_INFO *mi, | 328 static void read_intra_block_mode_info(VP9_COMMON *const cm, MODE_INFO *mi, |
329 vp9_reader *r) { | 329 vp9_reader *r) { |
330 MB_MODE_INFO *const mbmi = &mi->mbmi; | 330 MB_MODE_INFO *const mbmi = &mi->mbmi; |
331 const BLOCK_SIZE bsize = mi->mbmi.sb_type; | 331 const BLOCK_SIZE bsize = mi->mbmi.sb_type; |
| 332 int i; |
332 | 333 |
333 mbmi->ref_frame[0] = INTRA_FRAME; | 334 mbmi->ref_frame[0] = INTRA_FRAME; |
334 mbmi->ref_frame[1] = NONE; | 335 mbmi->ref_frame[1] = NONE; |
335 | 336 |
336 if (bsize >= BLOCK_8X8) { | 337 switch (bsize) { |
337 mbmi->mode = read_intra_mode_y(cm, r, size_group_lookup[bsize]); | 338 case BLOCK_4X4: |
338 } else { | 339 for (i = 0; i < 4; ++i) |
339 // Only 4x4, 4x8, 8x4 blocks | 340 mi->bmi[i].as_mode = read_intra_mode_y(cm, r, 0); |
340 const int num_4x4_w = num_4x4_blocks_wide_lookup[bsize]; // 1 or 2 | 341 mbmi->mode = mi->bmi[3].as_mode; |
341 const int num_4x4_h = num_4x4_blocks_high_lookup[bsize]; // 1 or 2 | 342 break; |
342 int idx, idy; | 343 case BLOCK_4X8: |
343 | 344 mi->bmi[0].as_mode = mi->bmi[2].as_mode = read_intra_mode_y(cm, r, 0); |
344 for (idy = 0; idy < 2; idy += num_4x4_h) { | 345 mi->bmi[1].as_mode = mi->bmi[3].as_mode = mbmi->mode = |
345 for (idx = 0; idx < 2; idx += num_4x4_w) { | 346 read_intra_mode_y(cm, r, 0); |
346 const int ib = idy * 2 + idx; | 347 break; |
347 const int b_mode = read_intra_mode_y(cm, r, 0); | 348 case BLOCK_8X4: |
348 mi->bmi[ib].as_mode = b_mode; | 349 mi->bmi[0].as_mode = mi->bmi[1].as_mode = read_intra_mode_y(cm, r, 0); |
349 if (num_4x4_h == 2) | 350 mi->bmi[2].as_mode = mi->bmi[3].as_mode = mbmi->mode = |
350 mi->bmi[ib + 2].as_mode = b_mode; | 351 read_intra_mode_y(cm, r, 0); |
351 if (num_4x4_w == 2) | 352 break; |
352 mi->bmi[ib + 1].as_mode = b_mode; | 353 default: |
353 } | 354 mbmi->mode = read_intra_mode_y(cm, r, size_group_lookup[bsize]); |
354 } | |
355 mbmi->mode = mi->bmi[3].as_mode; | |
356 } | 355 } |
357 | 356 |
358 mbmi->uv_mode = read_intra_mode_uv(cm, r, mbmi->mode); | 357 mbmi->uv_mode = read_intra_mode_uv(cm, r, mbmi->mode); |
359 } | 358 } |
360 | 359 |
361 static INLINE int is_mv_valid(const MV *mv) { | 360 static INLINE int is_mv_valid(const MV *mv) { |
362 return mv->row > MV_LOW && mv->row < MV_UPP && | 361 return mv->row > MV_LOW && mv->row < MV_UPP && |
363 mv->col > MV_LOW && mv->col < MV_UPP; | 362 mv->col > MV_LOW && mv->col < MV_UPP; |
364 } | 363 } |
365 | 364 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 const int allow_hp = cm->allow_high_precision_mv; | 429 const int allow_hp = cm->allow_high_precision_mv; |
431 | 430 |
432 int_mv nearestmv[2], nearmv[2]; | 431 int_mv nearestmv[2], nearmv[2]; |
433 int inter_mode_ctx, ref, is_compound; | 432 int inter_mode_ctx, ref, is_compound; |
434 | 433 |
435 read_ref_frames(cm, xd, r, mbmi->segment_id, mbmi->ref_frame); | 434 read_ref_frames(cm, xd, r, mbmi->segment_id, mbmi->ref_frame); |
436 is_compound = has_second_ref(mbmi); | 435 is_compound = has_second_ref(mbmi); |
437 | 436 |
438 for (ref = 0; ref < 1 + is_compound; ++ref) { | 437 for (ref = 0; ref < 1 + is_compound; ++ref) { |
439 const MV_REFERENCE_FRAME frame = mbmi->ref_frame[ref]; | 438 const MV_REFERENCE_FRAME frame = mbmi->ref_frame[ref]; |
440 vp9_find_mv_refs(cm, xd, tile, mi, xd->last_mi, frame, mbmi->ref_mvs[frame], | 439 vp9_find_mv_refs(cm, xd, tile, mi, frame, mbmi->ref_mvs[frame], |
441 mi_row, mi_col); | 440 mi_row, mi_col); |
442 } | 441 } |
443 | 442 |
444 inter_mode_ctx = mbmi->mode_context[mbmi->ref_frame[0]]; | 443 inter_mode_ctx = mbmi->mode_context[mbmi->ref_frame[0]]; |
445 | 444 |
446 if (vp9_segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) { | 445 if (vp9_segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) { |
447 mbmi->mode = ZEROMV; | 446 mbmi->mode = ZEROMV; |
448 if (bsize < BLOCK_8X8) { | 447 if (bsize < BLOCK_8X8) { |
449 vpx_internal_error(&cm->error, VPX_CODEC_UNSUP_BITSTREAM, | 448 vpx_internal_error(&cm->error, VPX_CODEC_UNSUP_BITSTREAM, |
450 "Invalid usage of segement feature on small blocks"); | 449 "Invalid usage of segement feature on small blocks"); |
(...skipping 12 matching lines...) Expand all Loading... |
463 } | 462 } |
464 | 463 |
465 mbmi->interp_filter = (cm->interp_filter == SWITCHABLE) | 464 mbmi->interp_filter = (cm->interp_filter == SWITCHABLE) |
466 ? read_switchable_interp_filter(cm, xd, r) | 465 ? read_switchable_interp_filter(cm, xd, r) |
467 : cm->interp_filter; | 466 : cm->interp_filter; |
468 | 467 |
469 if (bsize < BLOCK_8X8) { | 468 if (bsize < BLOCK_8X8) { |
470 const int num_4x4_w = num_4x4_blocks_wide_lookup[bsize]; // 1 or 2 | 469 const int num_4x4_w = num_4x4_blocks_wide_lookup[bsize]; // 1 or 2 |
471 const int num_4x4_h = num_4x4_blocks_high_lookup[bsize]; // 1 or 2 | 470 const int num_4x4_h = num_4x4_blocks_high_lookup[bsize]; // 1 or 2 |
472 int idx, idy; | 471 int idx, idy; |
473 int b_mode; | 472 MB_PREDICTION_MODE b_mode; |
474 int_mv nearest_sub8x8[2], near_sub8x8[2]; | 473 int_mv nearest_sub8x8[2], near_sub8x8[2]; |
475 for (idy = 0; idy < 2; idy += num_4x4_h) { | 474 for (idy = 0; idy < 2; idy += num_4x4_h) { |
476 for (idx = 0; idx < 2; idx += num_4x4_w) { | 475 for (idx = 0; idx < 2; idx += num_4x4_w) { |
477 int_mv block[2]; | 476 int_mv block[2]; |
478 const int j = idy * 2 + idx; | 477 const int j = idy * 2 + idx; |
479 b_mode = read_inter_mode(cm, r, inter_mode_ctx); | 478 b_mode = read_inter_mode(cm, r, inter_mode_ctx); |
480 | 479 |
481 if (b_mode == NEARESTMV || b_mode == NEARMV) | 480 if (b_mode == NEARESTMV || b_mode == NEARMV) |
482 for (ref = 0; ref < 1 + is_compound; ++ref) | 481 for (ref = 0; ref < 1 + is_compound; ++ref) |
483 vp9_append_sub8x8_mvs_for_idx(cm, xd, tile, j, ref, mi_row, mi_col, | 482 vp9_append_sub8x8_mvs_for_idx(cm, xd, tile, j, ref, mi_row, mi_col, |
(...skipping 25 matching lines...) Expand all Loading... |
509 } else { | 508 } else { |
510 xd->corrupted |= !assign_mv(cm, mbmi->mode, mbmi->mv, nearestmv, | 509 xd->corrupted |= !assign_mv(cm, mbmi->mode, mbmi->mv, nearestmv, |
511 nearestmv, nearmv, is_compound, allow_hp, r); | 510 nearestmv, nearmv, is_compound, allow_hp, r); |
512 } | 511 } |
513 } | 512 } |
514 | 513 |
515 static void read_inter_frame_mode_info(VP9_COMMON *const cm, | 514 static void read_inter_frame_mode_info(VP9_COMMON *const cm, |
516 MACROBLOCKD *const xd, | 515 MACROBLOCKD *const xd, |
517 const TileInfo *const tile, | 516 const TileInfo *const tile, |
518 int mi_row, int mi_col, vp9_reader *r) { | 517 int mi_row, int mi_col, vp9_reader *r) { |
519 MODE_INFO *const mi = xd->mi_8x8[0]; | 518 MODE_INFO *const mi = xd->mi[0]; |
520 MB_MODE_INFO *const mbmi = &mi->mbmi; | 519 MB_MODE_INFO *const mbmi = &mi->mbmi; |
521 int inter_block; | 520 int inter_block; |
522 | 521 |
523 mbmi->mv[0].as_int = 0; | 522 mbmi->mv[0].as_int = 0; |
524 mbmi->mv[1].as_int = 0; | 523 mbmi->mv[1].as_int = 0; |
525 mbmi->segment_id = read_inter_segment_id(cm, xd, mi_row, mi_col, r); | 524 mbmi->segment_id = read_inter_segment_id(cm, xd, mi_row, mi_col, r); |
526 mbmi->skip = read_skip(cm, xd, mbmi->segment_id, r); | 525 mbmi->skip = read_skip(cm, xd, mbmi->segment_id, r); |
527 inter_block = read_is_inter_block(cm, xd, mbmi->segment_id, r); | 526 inter_block = read_is_inter_block(cm, xd, mbmi->segment_id, r); |
528 mbmi->tx_size = read_tx_size(cm, xd, cm->tx_mode, mbmi->sb_type, | 527 mbmi->tx_size = read_tx_size(cm, xd, cm->tx_mode, mbmi->sb_type, |
529 !mbmi->skip || !inter_block, r); | 528 !mbmi->skip || !inter_block, r); |
530 | 529 |
531 if (inter_block) | 530 if (inter_block) |
532 read_inter_block_mode_info(cm, xd, tile, mi, mi_row, mi_col, r); | 531 read_inter_block_mode_info(cm, xd, tile, mi, mi_row, mi_col, r); |
533 else | 532 else |
534 read_intra_block_mode_info(cm, mi, r); | 533 read_intra_block_mode_info(cm, mi, r); |
535 } | 534 } |
536 | 535 |
537 void vp9_read_mode_info(VP9_COMMON *cm, MACROBLOCKD *xd, | 536 void vp9_read_mode_info(VP9_COMMON *cm, MACROBLOCKD *xd, |
538 const TileInfo *const tile, | 537 const TileInfo *const tile, |
539 int mi_row, int mi_col, vp9_reader *r) { | 538 int mi_row, int mi_col, vp9_reader *r) { |
540 if (frame_is_intra_only(cm)) | 539 if (frame_is_intra_only(cm)) |
541 read_intra_frame_mode_info(cm, xd, mi_row, mi_col, r); | 540 read_intra_frame_mode_info(cm, xd, mi_row, mi_col, r); |
542 else | 541 else |
543 read_inter_frame_mode_info(cm, xd, tile, mi_row, mi_col, r); | 542 read_inter_frame_mode_info(cm, xd, tile, mi_row, mi_col, r); |
544 } | 543 } |
OLD | NEW |