Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(455)

Side by Side Diff: source/libvpx/vp9/decoder/vp9_decodframe.c

Issue 23600008: libvpx: Pull from upstream (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « source/libvpx/vp9/decoder/vp9_decodemv.c ('k') | source/libvpx/vp9/decoder/vp9_detokenize.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 13 matching lines...) Expand all
24 #include "vp9/common/vp9_reconintra.h" 24 #include "vp9/common/vp9_reconintra.h"
25 #include "vp9/common/vp9_reconinter.h" 25 #include "vp9/common/vp9_reconinter.h"
26 #include "vp9/common/vp9_seg_common.h" 26 #include "vp9/common/vp9_seg_common.h"
27 #include "vp9/common/vp9_tile_common.h" 27 #include "vp9/common/vp9_tile_common.h"
28 28
29 #include "vp9/decoder/vp9_dboolhuff.h" 29 #include "vp9/decoder/vp9_dboolhuff.h"
30 #include "vp9/decoder/vp9_decodframe.h" 30 #include "vp9/decoder/vp9_decodframe.h"
31 #include "vp9/decoder/vp9_detokenize.h" 31 #include "vp9/decoder/vp9_detokenize.h"
32 #include "vp9/decoder/vp9_decodemv.h" 32 #include "vp9/decoder/vp9_decodemv.h"
33 #include "vp9/decoder/vp9_dsubexp.h" 33 #include "vp9/decoder/vp9_dsubexp.h"
34 #include "vp9/decoder/vp9_idct_blk.h"
34 #include "vp9/decoder/vp9_onyxd_int.h" 35 #include "vp9/decoder/vp9_onyxd_int.h"
35 #include "vp9/decoder/vp9_read_bit_buffer.h" 36 #include "vp9/decoder/vp9_read_bit_buffer.h"
37 #include "vp9/decoder/vp9_thread.h"
38 #include "vp9/decoder/vp9_treereader.h"
36 39
37 static int read_be32(const uint8_t *p) { 40 static int read_be32(const uint8_t *p) {
38 return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]; 41 return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
39 } 42 }
40 43
41 // len == 0 is not allowed 44 // len == 0 is not allowed
42 static int read_is_valid(const uint8_t *start, size_t len, const uint8_t *end) { 45 static int read_is_valid(const uint8_t *start, size_t len, const uint8_t *end) {
43 return start + len > start && start + len <= end; 46 return start + len > start && start + len <= end;
44 } 47 }
45 48
46 static int decode_unsigned_max(struct vp9_read_bit_buffer *rb, int max) { 49 static int decode_unsigned_max(struct vp9_read_bit_buffer *rb, int max) {
47 const int data = vp9_rb_read_literal(rb, get_unsigned_bits(max)); 50 const int data = vp9_rb_read_literal(rb, get_unsigned_bits(max));
48 return data > max ? max : data; 51 return data > max ? max : data;
49 } 52 }
50 53
51 static TX_MODE read_tx_mode(vp9_reader *r) { 54 static TX_MODE read_tx_mode(vp9_reader *r) {
52 TX_MODE tx_mode = vp9_read_literal(r, 2); 55 TX_MODE tx_mode = vp9_read_literal(r, 2);
53 if (tx_mode == ALLOW_32X32) 56 if (tx_mode == ALLOW_32X32)
54 tx_mode += vp9_read_bit(r); 57 tx_mode += vp9_read_bit(r);
55 return tx_mode; 58 return tx_mode;
56 } 59 }
57 60
58 static void read_tx_probs(struct tx_probs *tx_probs, vp9_reader *r) { 61 static void read_tx_probs(struct tx_probs *tx_probs, vp9_reader *r) {
59 int i, j; 62 int i, j;
60 63
61 for (i = 0; i < TX_SIZE_CONTEXTS; ++i) 64 for (i = 0; i < TX_SIZE_CONTEXTS; ++i)
62 for (j = 0; j < TX_SIZE_MAX_SB - 3; ++j) 65 for (j = 0; j < TX_SIZES - 3; ++j)
63 if (vp9_read(r, VP9_MODE_UPDATE_PROB)) 66 if (vp9_read(r, MODE_UPDATE_PROB))
64 vp9_diff_update_prob(r, &tx_probs->p8x8[i][j]); 67 vp9_diff_update_prob(r, &tx_probs->p8x8[i][j]);
65 68
66 for (i = 0; i < TX_SIZE_CONTEXTS; ++i) 69 for (i = 0; i < TX_SIZE_CONTEXTS; ++i)
67 for (j = 0; j < TX_SIZE_MAX_SB - 2; ++j) 70 for (j = 0; j < TX_SIZES - 2; ++j)
68 if (vp9_read(r, VP9_MODE_UPDATE_PROB)) 71 if (vp9_read(r, MODE_UPDATE_PROB))
69 vp9_diff_update_prob(r, &tx_probs->p16x16[i][j]); 72 vp9_diff_update_prob(r, &tx_probs->p16x16[i][j]);
70 73
71 for (i = 0; i < TX_SIZE_CONTEXTS; ++i) 74 for (i = 0; i < TX_SIZE_CONTEXTS; ++i)
72 for (j = 0; j < TX_SIZE_MAX_SB - 1; ++j) 75 for (j = 0; j < TX_SIZES - 1; ++j)
73 if (vp9_read(r, VP9_MODE_UPDATE_PROB)) 76 if (vp9_read(r, MODE_UPDATE_PROB))
74 vp9_diff_update_prob(r, &tx_probs->p32x32[i][j]); 77 vp9_diff_update_prob(r, &tx_probs->p32x32[i][j]);
75 } 78 }
76 79
77 static void init_dequantizer(VP9_COMMON *cm, MACROBLOCKD *xd) { 80 static void init_dequantizer(VP9_COMMON *cm, MACROBLOCKD *xd) {
78 int i; 81 int i;
79 const int segment_id = xd->mode_info_context->mbmi.segment_id; 82 const int segment_id = xd->mode_info_context->mbmi.segment_id;
80 xd->q_index = vp9_get_qindex(xd, segment_id, cm->base_qindex); 83 xd->q_index = vp9_get_qindex(&cm->seg, segment_id, cm->base_qindex);
81 84
82 xd->plane[0].dequant = cm->y_dequant[xd->q_index]; 85 xd->plane[0].dequant = cm->y_dequant[xd->q_index];
83 for (i = 1; i < MAX_MB_PLANE; i++) 86 for (i = 1; i < MAX_MB_PLANE; i++)
84 xd->plane[i].dequant = cm->uv_dequant[xd->q_index]; 87 xd->plane[i].dequant = cm->uv_dequant[xd->q_index];
85 } 88 }
86 89
87 static void decode_block(int plane, int block, BLOCK_SIZE_TYPE bsize, 90 static void decode_block(int plane, int block, BLOCK_SIZE plane_bsize,
88 int ss_txfrm_size, void *arg) { 91 TX_SIZE tx_size, void *arg) {
89 MACROBLOCKD* const xd = arg; 92 MACROBLOCKD* const xd = arg;
90 struct macroblockd_plane *pd = &xd->plane[plane]; 93 struct macroblockd_plane *const pd = &xd->plane[plane];
91 int16_t* const qcoeff = BLOCK_OFFSET(pd->qcoeff, block, 16); 94 int16_t* const qcoeff = BLOCK_OFFSET(pd->qcoeff, block);
92 const int stride = pd->dst.stride; 95 const int stride = pd->dst.stride;
93 const int eob = pd->eobs[block]; 96 const int eob = pd->eobs[block];
94 const int raster_block = txfrm_block_to_raster_block(xd, bsize, plane, 97 const int raster_block = txfrm_block_to_raster_block(plane_bsize, tx_size,
95 block, ss_txfrm_size); 98 block);
96 uint8_t* const dst = raster_block_offset_uint8(xd, bsize, plane, 99 uint8_t* const dst = raster_block_offset_uint8(plane_bsize, raster_block,
97 raster_block,
98 pd->dst.buf, stride); 100 pd->dst.buf, stride);
99 101 switch (tx_size) {
100 switch (ss_txfrm_size / 2) {
101 case TX_4X4: { 102 case TX_4X4: {
102 const TX_TYPE tx_type = get_tx_type_4x4(pd->plane_type, xd, raster_block); 103 const TX_TYPE tx_type = get_tx_type_4x4(pd->plane_type, xd, raster_block);
103 if (tx_type == DCT_DCT) 104 if (tx_type == DCT_DCT)
104 xd->itxm_add(qcoeff, dst, stride, eob); 105 xd->itxm_add(qcoeff, dst, stride, eob);
105 else 106 else
106 vp9_iht_add_c(tx_type, qcoeff, dst, stride, eob); 107 vp9_iht_add_c(tx_type, qcoeff, dst, stride, eob);
107 break; 108 break;
108 } 109 }
109 case TX_8X8: 110 case TX_8X8:
110 vp9_iht_add_8x8_c(get_tx_type_8x8(pd->plane_type, xd), qcoeff, dst, 111 vp9_iht_add_8x8_c(get_tx_type_8x8(pd->plane_type, xd), qcoeff, dst,
111 stride, eob); 112 stride, eob);
112 break; 113 break;
113 case TX_16X16: 114 case TX_16X16:
114 vp9_iht_add_16x16_c(get_tx_type_16x16(pd->plane_type, xd), qcoeff, dst, 115 vp9_iht_add_16x16_c(get_tx_type_16x16(pd->plane_type, xd), qcoeff, dst,
115 stride, eob); 116 stride, eob);
116 break; 117 break;
117 case TX_32X32: 118 case TX_32X32:
118 vp9_idct_add_32x32(qcoeff, dst, stride, eob); 119 vp9_idct_add_32x32(qcoeff, dst, stride, eob);
119 break; 120 break;
121 default:
122 assert(!"Invalid transform size");
120 } 123 }
121 } 124 }
122 125
123 static void decode_block_intra(int plane, int block, BLOCK_SIZE_TYPE bsize, 126 static void decode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize,
124 int ss_txfrm_size, void *arg) { 127 TX_SIZE tx_size, void *arg) {
125 MACROBLOCKD* const xd = arg; 128 MACROBLOCKD* const xd = arg;
126 struct macroblockd_plane *pd = &xd->plane[plane]; 129 struct macroblockd_plane *const pd = &xd->plane[plane];
127 MODE_INFO *const mi = xd->mode_info_context; 130 MODE_INFO *const mi = xd->mode_info_context;
128 131 const int raster_block = txfrm_block_to_raster_block(plane_bsize, tx_size,
129 const int raster_block = txfrm_block_to_raster_block(xd, bsize, plane, 132 block);
130 block, ss_txfrm_size); 133 uint8_t* const dst = raster_block_offset_uint8(plane_bsize, raster_block,
131 uint8_t* const dst = raster_block_offset_uint8(xd, bsize, plane,
132 raster_block,
133 pd->dst.buf, pd->dst.stride); 134 pd->dst.buf, pd->dst.stride);
134 const TX_SIZE tx_size = (TX_SIZE)(ss_txfrm_size / 2); 135 const MB_PREDICTION_MODE mode = (plane == 0)
135 int b_mode; 136 ? ((mi->mbmi.sb_type < BLOCK_8X8) ? mi->bmi[raster_block].as_mode
136 int plane_b_size; 137 : mi->mbmi.mode)
137 const int tx_ib = raster_block >> tx_size; 138 : mi->mbmi.uv_mode;
138 const int mode = plane == 0 ? mi->mbmi.mode
139 : mi->mbmi.uv_mode;
140
141 if (plane == 0 && mi->mbmi.sb_type < BLOCK_SIZE_SB8X8) {
142 assert(bsize == BLOCK_SIZE_SB8X8);
143 b_mode = mi->bmi[raster_block].as_mode;
144 } else {
145 b_mode = mode;
146 }
147 139
148 if (xd->mb_to_right_edge < 0 || xd->mb_to_bottom_edge < 0) 140 if (xd->mb_to_right_edge < 0 || xd->mb_to_bottom_edge < 0)
149 extend_for_intra(xd, plane, block, bsize, ss_txfrm_size); 141 extend_for_intra(xd, plane_bsize, plane, block, tx_size);
150 142
151 plane_b_size = b_width_log2(bsize) - pd->subsampling_x; 143 vp9_predict_intra_block(xd, raster_block >> tx_size,
152 vp9_predict_intra_block(xd, tx_ib, plane_b_size, tx_size, b_mode, 144 b_width_log2(plane_bsize), tx_size, mode,
153 dst, pd->dst.stride, 145 dst, pd->dst.stride, dst, pd->dst.stride);
154 dst, pd->dst.stride);
155 146
156 // Early exit if there are no coefficients 147 // Early exit if there are no coefficients
157 if (mi->mbmi.mb_skip_coeff) 148 if (mi->mbmi.skip_coeff)
158 return; 149 return;
159 150
160 decode_block(plane, block, bsize, ss_txfrm_size, arg); 151 decode_block(plane, block, plane_bsize, tx_size, arg);
161 } 152 }
162 153
163 static int decode_tokens(VP9D_COMP *pbi, BLOCK_SIZE_TYPE bsize, vp9_reader *r) { 154 static int decode_tokens(VP9D_COMP *pbi, BLOCK_SIZE bsize, vp9_reader *r) {
164 MACROBLOCKD *const xd = &pbi->mb; 155 MACROBLOCKD *const xd = &pbi->mb;
165 156
166 if (xd->mode_info_context->mbmi.mb_skip_coeff) { 157 if (xd->mode_info_context->mbmi.skip_coeff) {
167 vp9_reset_sb_tokens_context(xd, bsize); 158 reset_skip_context(xd, bsize);
168 return -1; 159 return -1;
169 } else { 160 } else {
170 if (xd->seg.enabled) 161 if (pbi->common.seg.enabled)
171 init_dequantizer(&pbi->common, xd); 162 init_dequantizer(&pbi->common, xd);
172 163
173 // TODO(dkovalev) if (!vp9_reader_has_error(r)) 164 // TODO(dkovalev) if (!vp9_reader_has_error(r))
174 return vp9_decode_tokens(pbi, r, bsize); 165 return vp9_decode_tokens(pbi, r, bsize);
175 } 166 }
176 } 167 }
177 168
178 static void set_offsets(VP9D_COMP *pbi, BLOCK_SIZE_TYPE bsize, 169 static void set_offsets(VP9D_COMP *pbi, BLOCK_SIZE bsize,
179 int mi_row, int mi_col) { 170 int mi_row, int mi_col) {
180 VP9_COMMON *const cm = &pbi->common; 171 VP9_COMMON *const cm = &pbi->common;
181 MACROBLOCKD *const xd = &pbi->mb; 172 MACROBLOCKD *const xd = &pbi->mb;
182 const int bh = 1 << mi_height_log2(bsize); 173 const int bh = 1 << mi_height_log2(bsize);
183 const int bw = 1 << mi_width_log2(bsize); 174 const int bw = 1 << mi_width_log2(bsize);
184 const int mi_idx = mi_row * cm->mode_info_stride + mi_col; 175 const int mi_idx = mi_row * cm->mode_info_stride + mi_col;
185 int i;
186 176
187 xd->mode_info_context = cm->mi + mi_idx; 177 xd->mode_info_context = cm->mi + mi_idx;
188 xd->mode_info_context->mbmi.sb_type = bsize; 178 xd->mode_info_context->mbmi.sb_type = bsize;
189 // Special case: if prev_mi is NULL, the previous mode info context 179 // Special case: if prev_mi is NULL, the previous mode info context
190 // cannot be used. 180 // cannot be used.
191 xd->prev_mode_info_context = cm->prev_mi ? cm->prev_mi + mi_idx : NULL; 181 xd->prev_mode_info_context = cm->prev_mi ? cm->prev_mi + mi_idx : NULL;
192 182
193 for (i = 0; i < MAX_MB_PLANE; i++) {
194 struct macroblockd_plane *pd = &xd->plane[i];
195 pd->above_context = cm->above_context[i] +
196 (mi_col * 2 >> pd->subsampling_x);
197 pd->left_context = cm->left_context[i] +
198 (((mi_row * 2) & 15) >> pd->subsampling_y);
199 }
200 183
184 set_skip_context(cm, xd, mi_row, mi_col);
201 set_partition_seg_context(cm, xd, mi_row, mi_col); 185 set_partition_seg_context(cm, xd, mi_row, mi_col);
202 186
203 // Distance of Mb to the various image edges. These are specified to 8th pel 187 // Distance of Mb to the various image edges. These are specified to 8th pel
204 // as they are always compared to values that are in 1/8th pel units 188 // as they are always compared to values that are in 1/8th pel units
205 set_mi_row_col(cm, xd, mi_row, bh, mi_col, bw); 189 set_mi_row_col(cm, xd, mi_row, bh, mi_col, bw);
206 190
207 setup_dst_planes(xd, &cm->yv12_fb[cm->new_fb_idx], mi_row, mi_col); 191 setup_dst_planes(xd, &cm->yv12_fb[cm->new_fb_idx], mi_row, mi_col);
208 } 192 }
209 193
210 static void set_ref(VP9D_COMP *pbi, int i, int mi_row, int mi_col) { 194 static void set_ref(VP9D_COMP *pbi, int i, int mi_row, int mi_col) {
211 VP9_COMMON *const cm = &pbi->common; 195 VP9_COMMON *const cm = &pbi->common;
212 MACROBLOCKD *const xd = &pbi->mb; 196 MACROBLOCKD *const xd = &pbi->mb;
213 MB_MODE_INFO *const mbmi = &xd->mode_info_context->mbmi; 197 MB_MODE_INFO *const mbmi = &xd->mode_info_context->mbmi;
214 const int ref = mbmi->ref_frame[i] - 1; 198 const int ref = mbmi->ref_frame[i] - LAST_FRAME;
199 const YV12_BUFFER_CONFIG *cfg = &cm->yv12_fb[cm->active_ref_idx[ref]];
200 const struct scale_factors *sf = &cm->active_ref_scale[ref];
201 if (!vp9_is_valid_scale(sf))
202 vpx_internal_error(&cm->error, VPX_CODEC_UNSUP_BITSTREAM,
203 "Invalid scale factors");
215 204
216 const YV12_BUFFER_CONFIG *cfg = &cm->yv12_fb[cm->active_ref_idx[ref]]; 205 xd->scale_factor[i] = *sf;
217 xd->scale_factor[i] = cm->active_ref_scale[ref]; 206 setup_pre_planes(xd, i, cfg, mi_row, mi_col, sf);
218 setup_pre_planes(xd, i, cfg, mi_row, mi_col, &xd->scale_factor[i]);
219 xd->corrupted |= cfg->corrupted; 207 xd->corrupted |= cfg->corrupted;
220 } 208 }
221 209
222 static void decode_modes_b(VP9D_COMP *pbi, int mi_row, int mi_col, 210 static void decode_modes_b(VP9D_COMP *pbi, int mi_row, int mi_col,
223 vp9_reader *r, BLOCK_SIZE_TYPE bsize) { 211 vp9_reader *r, BLOCK_SIZE bsize) {
224 VP9_COMMON *const cm = &pbi->common; 212 VP9_COMMON *const cm = &pbi->common;
225 MACROBLOCKD *const xd = &pbi->mb; 213 MACROBLOCKD *const xd = &pbi->mb;
226 const int less8x8 = bsize < BLOCK_SIZE_SB8X8; 214 const int less8x8 = bsize < BLOCK_8X8;
227 MB_MODE_INFO *mbmi; 215 MB_MODE_INFO *mbmi;
228 216
229 if (less8x8) 217 if (less8x8)
230 if (xd->ab_index > 0) 218 if (xd->ab_index > 0)
231 return; 219 return;
232 220
233 set_offsets(pbi, bsize, mi_row, mi_col); 221 set_offsets(pbi, bsize, mi_row, mi_col);
234 vp9_read_mode_info(pbi, mi_row, mi_col, r); 222 vp9_read_mode_info(pbi, mi_row, mi_col, r);
235 223
236 if (less8x8) 224 if (less8x8)
237 bsize = BLOCK_SIZE_SB8X8; 225 bsize = BLOCK_8X8;
238 226
239 // Has to be called after set_offsets 227 // Has to be called after set_offsets
240 mbmi = &xd->mode_info_context->mbmi; 228 mbmi = &xd->mode_info_context->mbmi;
241 229
242 if (mbmi->ref_frame[0] == INTRA_FRAME) { 230 if (!is_inter_block(mbmi)) {
243 // Intra reconstruction 231 // Intra reconstruction
244 decode_tokens(pbi, bsize, r); 232 decode_tokens(pbi, bsize, r);
245 foreach_transformed_block(xd, bsize, decode_block_intra, xd); 233 foreach_transformed_block(xd, bsize, decode_block_intra, xd);
246 } else { 234 } else {
247 // Inter reconstruction 235 // Inter reconstruction
248 int eobtotal; 236 int eobtotal;
249 237
250 set_ref(pbi, 0, mi_row, mi_col); 238 set_ref(pbi, 0, mi_row, mi_col);
251 if (mbmi->ref_frame[1] > INTRA_FRAME) 239 if (mbmi->ref_frame[1] > INTRA_FRAME)
252 set_ref(pbi, 1, mi_row, mi_col); 240 set_ref(pbi, 1, mi_row, mi_col);
(...skipping 10 matching lines...) Expand all
263 // skip loopfilter 251 // skip loopfilter
264 vp9_set_pred_flag_mbskip(cm, bsize, mi_row, mi_col, 1); 252 vp9_set_pred_flag_mbskip(cm, bsize, mi_row, mi_col, 1);
265 else if (eobtotal > 0) 253 else if (eobtotal > 0)
266 foreach_transformed_block(xd, bsize, decode_block, xd); 254 foreach_transformed_block(xd, bsize, decode_block, xd);
267 } 255 }
268 } 256 }
269 xd->corrupted |= vp9_reader_has_error(r); 257 xd->corrupted |= vp9_reader_has_error(r);
270 } 258 }
271 259
272 static void decode_modes_sb(VP9D_COMP *pbi, int mi_row, int mi_col, 260 static void decode_modes_sb(VP9D_COMP *pbi, int mi_row, int mi_col,
273 vp9_reader* r, BLOCK_SIZE_TYPE bsize) { 261 vp9_reader* r, BLOCK_SIZE bsize) {
274 VP9_COMMON *const pc = &pbi->common; 262 VP9_COMMON *const pc = &pbi->common;
275 MACROBLOCKD *const xd = &pbi->mb; 263 MACROBLOCKD *const xd = &pbi->mb;
276 int bs = (1 << mi_width_log2(bsize)) / 2, n; 264 const int bs = (1 << mi_width_log2(bsize)) / 2;
277 PARTITION_TYPE partition = PARTITION_NONE; 265 PARTITION_TYPE partition = PARTITION_NONE;
278 BLOCK_SIZE_TYPE subsize; 266 BLOCK_SIZE subsize;
279 267
280 if (mi_row >= pc->mi_rows || mi_col >= pc->mi_cols) 268 if (mi_row >= pc->mi_rows || mi_col >= pc->mi_cols)
281 return; 269 return;
282 270
283 if (bsize < BLOCK_SIZE_SB8X8) { 271 if (bsize < BLOCK_8X8) {
284 if (xd->ab_index != 0) 272 if (xd->ab_index != 0)
285 return; 273 return;
286 } else { 274 } else {
287 int pl; 275 int pl;
288 const int idx = check_bsize_coverage(pc, xd, mi_row, mi_col, bsize); 276 const int idx = check_bsize_coverage(bs, pc->mi_rows, pc->mi_cols,
277 mi_row, mi_col);
289 set_partition_seg_context(pc, xd, mi_row, mi_col); 278 set_partition_seg_context(pc, xd, mi_row, mi_col);
290 pl = partition_plane_context(xd, bsize); 279 pl = partition_plane_context(xd, bsize);
291 280
292 if (idx == 0) 281 if (idx == 0)
293 partition = treed_read(r, vp9_partition_tree, 282 partition = treed_read(r, vp9_partition_tree,
294 pc->fc.partition_prob[pc->frame_type][pl]); 283 pc->fc.partition_prob[pc->frame_type][pl]);
295 else if (idx > 0 && 284 else if (idx > 0 &&
296 !vp9_read(r, pc->fc.partition_prob[pc->frame_type][pl][idx])) 285 !vp9_read(r, pc->fc.partition_prob[pc->frame_type][pl][idx]))
297 partition = (idx == 1) ? PARTITION_HORZ : PARTITION_VERT; 286 partition = (idx == 1) ? PARTITION_HORZ : PARTITION_VERT;
298 else 287 else
(...skipping 14 matching lines...) Expand all
313 *(get_sb_index(xd, subsize)) = 1; 302 *(get_sb_index(xd, subsize)) = 1;
314 if (mi_row + bs < pc->mi_rows) 303 if (mi_row + bs < pc->mi_rows)
315 decode_modes_b(pbi, mi_row + bs, mi_col, r, subsize); 304 decode_modes_b(pbi, mi_row + bs, mi_col, r, subsize);
316 break; 305 break;
317 case PARTITION_VERT: 306 case PARTITION_VERT:
318 decode_modes_b(pbi, mi_row, mi_col, r, subsize); 307 decode_modes_b(pbi, mi_row, mi_col, r, subsize);
319 *(get_sb_index(xd, subsize)) = 1; 308 *(get_sb_index(xd, subsize)) = 1;
320 if (mi_col + bs < pc->mi_cols) 309 if (mi_col + bs < pc->mi_cols)
321 decode_modes_b(pbi, mi_row, mi_col + bs, r, subsize); 310 decode_modes_b(pbi, mi_row, mi_col + bs, r, subsize);
322 break; 311 break;
323 case PARTITION_SPLIT: 312 case PARTITION_SPLIT: {
313 int n;
324 for (n = 0; n < 4; n++) { 314 for (n = 0; n < 4; n++) {
325 int j = n >> 1, i = n & 0x01; 315 const int j = n >> 1, i = n & 1;
326 *(get_sb_index(xd, subsize)) = n; 316 *(get_sb_index(xd, subsize)) = n;
327 decode_modes_sb(pbi, mi_row + j * bs, mi_col + i * bs, r, subsize); 317 decode_modes_sb(pbi, mi_row + j * bs, mi_col + i * bs, r, subsize);
328 } 318 }
329 break; 319 } break;
330 default: 320 default:
331 assert(!"Invalid partition type"); 321 assert(!"Invalid partition type");
332 } 322 }
333 323
334 // update partition context 324 // update partition context
335 if (bsize >= BLOCK_SIZE_SB8X8 && 325 if (bsize >= BLOCK_8X8 &&
336 (bsize == BLOCK_SIZE_SB8X8 || partition != PARTITION_SPLIT)) { 326 (bsize == BLOCK_8X8 || partition != PARTITION_SPLIT)) {
337 set_partition_seg_context(pc, xd, mi_row, mi_col); 327 set_partition_seg_context(pc, xd, mi_row, mi_col);
338 update_partition_context(xd, subsize, bsize); 328 update_partition_context(xd, subsize, bsize);
339 } 329 }
340 } 330 }
341 331
342 static void setup_token_decoder(VP9D_COMP *pbi, 332 static void setup_token_decoder(VP9D_COMP *pbi,
343 const uint8_t *data, size_t read_size, 333 const uint8_t *data, size_t read_size,
344 vp9_reader *r) { 334 vp9_reader *r) {
345 VP9_COMMON *pc = &pbi->common; 335 VP9_COMMON *pc = &pbi->common;
346 const uint8_t *data_end = pbi->source + pbi->source_sz; 336 const uint8_t *data_end = pbi->source + pbi->source_sz;
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 cm->y_dc_delta_q == 0 && 478 cm->y_dc_delta_q == 0 &&
489 cm->uv_dc_delta_q == 0 && 479 cm->uv_dc_delta_q == 0 &&
490 cm->uv_ac_delta_q == 0; 480 cm->uv_ac_delta_q == 0;
491 481
492 xd->itxm_add = xd->lossless ? vp9_idct_add_lossless_c 482 xd->itxm_add = xd->lossless ? vp9_idct_add_lossless_c
493 : vp9_idct_add; 483 : vp9_idct_add;
494 } 484 }
495 485
496 static INTERPOLATIONFILTERTYPE read_interp_filter_type( 486 static INTERPOLATIONFILTERTYPE read_interp_filter_type(
497 struct vp9_read_bit_buffer *rb) { 487 struct vp9_read_bit_buffer *rb) {
488 const INTERPOLATIONFILTERTYPE literal_to_type[] = { EIGHTTAP_SMOOTH,
489 EIGHTTAP,
490 EIGHTTAP_SHARP };
498 return vp9_rb_read_bit(rb) ? SWITCHABLE 491 return vp9_rb_read_bit(rb) ? SWITCHABLE
499 : vp9_rb_read_literal(rb, 2); 492 : literal_to_type[vp9_rb_read_literal(rb, 2)];
500 } 493 }
501 494
502 static void read_frame_size(VP9_COMMON *cm, struct vp9_read_bit_buffer *rb, 495 static void read_frame_size(struct vp9_read_bit_buffer *rb,
503 int *width, int *height) { 496 int *width, int *height) {
504 const int w = vp9_rb_read_literal(rb, 16) + 1; 497 const int w = vp9_rb_read_literal(rb, 16) + 1;
505 const int h = vp9_rb_read_literal(rb, 16) + 1; 498 const int h = vp9_rb_read_literal(rb, 16) + 1;
506 *width = w; 499 *width = w;
507 *height = h; 500 *height = h;
508 } 501 }
509 502
510 static void setup_display_size(VP9D_COMP *pbi, struct vp9_read_bit_buffer *rb) { 503 static void setup_display_size(VP9_COMMON *cm, struct vp9_read_bit_buffer *rb) {
511 VP9_COMMON *const cm = &pbi->common;
512 cm->display_width = cm->width; 504 cm->display_width = cm->width;
513 cm->display_height = cm->height; 505 cm->display_height = cm->height;
514 if (vp9_rb_read_bit(rb)) 506 if (vp9_rb_read_bit(rb))
515 read_frame_size(cm, rb, &cm->display_width, &cm->display_height); 507 read_frame_size(rb, &cm->display_width, &cm->display_height);
516 } 508 }
517 509
518 static void apply_frame_size(VP9D_COMP *pbi, int width, int height) { 510 static void apply_frame_size(VP9D_COMP *pbi, int width, int height) {
519 VP9_COMMON *cm = &pbi->common; 511 VP9_COMMON *cm = &pbi->common;
520 512
521 if (cm->width != width || cm->height != height) { 513 if (cm->width != width || cm->height != height) {
522 if (!pbi->initial_width || !pbi->initial_height) { 514 if (!pbi->initial_width || !pbi->initial_height) {
523 if (vp9_alloc_frame_buffers(cm, width, height)) 515 if (vp9_alloc_frame_buffers(cm, width, height))
524 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, 516 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
525 "Failed to allocate frame buffers"); 517 "Failed to allocate frame buffers");
(...skipping 15 matching lines...) Expand all
541 vp9_update_frame_size(cm); 533 vp9_update_frame_size(cm);
542 } 534 }
543 535
544 vp9_realloc_frame_buffer(&cm->yv12_fb[cm->new_fb_idx], cm->width, cm->height, 536 vp9_realloc_frame_buffer(&cm->yv12_fb[cm->new_fb_idx], cm->width, cm->height,
545 cm->subsampling_x, cm->subsampling_y, 537 cm->subsampling_x, cm->subsampling_y,
546 VP9BORDERINPIXELS); 538 VP9BORDERINPIXELS);
547 } 539 }
548 540
549 static void setup_frame_size(VP9D_COMP *pbi, 541 static void setup_frame_size(VP9D_COMP *pbi,
550 struct vp9_read_bit_buffer *rb) { 542 struct vp9_read_bit_buffer *rb) {
551 VP9_COMMON *const cm = &pbi->common;
552 int width, height; 543 int width, height;
553 read_frame_size(cm, rb, &width, &height); 544 read_frame_size(rb, &width, &height);
554 setup_display_size(pbi, rb);
555 apply_frame_size(pbi, width, height); 545 apply_frame_size(pbi, width, height);
546 setup_display_size(&pbi->common, rb);
556 } 547 }
557 548
558 static void setup_frame_size_with_refs(VP9D_COMP *pbi, 549 static void setup_frame_size_with_refs(VP9D_COMP *pbi,
559 struct vp9_read_bit_buffer *rb) { 550 struct vp9_read_bit_buffer *rb) {
560 VP9_COMMON *const cm = &pbi->common; 551 VP9_COMMON *const cm = &pbi->common;
561 552
562 int width, height; 553 int width, height;
563 int found = 0, i; 554 int found = 0, i;
564 for (i = 0; i < ALLOWED_REFS_PER_FRAME; ++i) { 555 for (i = 0; i < ALLOWED_REFS_PER_FRAME; ++i) {
565 if (vp9_rb_read_bit(rb)) { 556 if (vp9_rb_read_bit(rb)) {
566 YV12_BUFFER_CONFIG *cfg = &cm->yv12_fb[cm->active_ref_idx[i]]; 557 YV12_BUFFER_CONFIG *cfg = &cm->yv12_fb[cm->active_ref_idx[i]];
567 width = cfg->y_crop_width; 558 width = cfg->y_crop_width;
568 height = cfg->y_crop_height; 559 height = cfg->y_crop_height;
569 found = 1; 560 found = 1;
570 break; 561 break;
571 } 562 }
572 } 563 }
573 564
574 if (!found) 565 if (!found)
575 read_frame_size(cm, rb, &width, &height); 566 read_frame_size(rb, &width, &height);
576 567
577 if (!width || !height) 568 if (!width || !height)
578 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, 569 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME,
579 "Referenced frame with invalid size"); 570 "Referenced frame with invalid size");
580 571
581 setup_display_size(pbi, rb);
582 apply_frame_size(pbi, width, height); 572 apply_frame_size(pbi, width, height);
573 setup_display_size(cm, rb);
583 } 574 }
584 575
585 static void decode_tile(VP9D_COMP *pbi, vp9_reader *r) { 576 static void decode_tile(VP9D_COMP *pbi, vp9_reader *r) {
577 const int num_threads = pbi->oxcf.max_threads;
586 VP9_COMMON *const pc = &pbi->common; 578 VP9_COMMON *const pc = &pbi->common;
587 int mi_row, mi_col; 579 int mi_row, mi_col;
580 YV12_BUFFER_CONFIG *const fb = &pc->yv12_fb[pc->new_fb_idx];
588 581
589 if (pbi->do_loopfilter_inline) { 582 if (pbi->do_loopfilter_inline) {
590 vp9_loop_filter_frame_init(pc, &pbi->mb, pbi->mb.lf.filter_level); 583 if (num_threads > 1) {
584 LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1;
585 lf_data->frame_buffer = fb;
586 lf_data->cm = pc;
587 lf_data->xd = pbi->mb;
588 lf_data->stop = 0;
589 lf_data->y_only = 0;
590 }
591 vp9_loop_filter_frame_init(pc, pc->lf.filter_level);
591 } 592 }
592 593
593 for (mi_row = pc->cur_tile_mi_row_start; mi_row < pc->cur_tile_mi_row_end; 594 for (mi_row = pc->cur_tile_mi_row_start; mi_row < pc->cur_tile_mi_row_end;
594 mi_row += MI_BLOCK_SIZE) { 595 mi_row += MI_BLOCK_SIZE) {
595 // For a SB there are 2 left contexts, each pertaining to a MB row within 596 // For a SB there are 2 left contexts, each pertaining to a MB row within
596 vpx_memset(&pc->left_context, 0, sizeof(pc->left_context)); 597 vp9_zero(pc->left_context);
597 vpx_memset(pc->left_seg_context, 0, sizeof(pc->left_seg_context)); 598 vp9_zero(pc->left_seg_context);
598 for (mi_col = pc->cur_tile_mi_col_start; mi_col < pc->cur_tile_mi_col_end; 599 for (mi_col = pc->cur_tile_mi_col_start; mi_col < pc->cur_tile_mi_col_end;
599 mi_col += MI_BLOCK_SIZE) { 600 mi_col += MI_BLOCK_SIZE) {
600 decode_modes_sb(pbi, mi_row, mi_col, r, BLOCK_SIZE_SB64X64); 601 decode_modes_sb(pbi, mi_row, mi_col, r, BLOCK_64X64);
601 } 602 }
602 603
603 if (pbi->do_loopfilter_inline) { 604 if (pbi->do_loopfilter_inline) {
604 YV12_BUFFER_CONFIG *const fb =
605 &pbi->common.yv12_fb[pbi->common.new_fb_idx];
606 // delay the loopfilter by 1 macroblock row. 605 // delay the loopfilter by 1 macroblock row.
607 const int lf_start = mi_row - MI_BLOCK_SIZE; 606 const int lf_start = mi_row - MI_BLOCK_SIZE;
608 if (lf_start < 0) continue; 607 if (lf_start < 0) continue;
609 vp9_loop_filter_rows(fb, pc, &pbi->mb, lf_start, mi_row, 0); 608
609 if (num_threads > 1) {
610 LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1;
611
612 // decoding has completed: finish up the loop filter in this thread.
613 if (mi_row + MI_BLOCK_SIZE >= pc->cur_tile_mi_row_end) continue;
614
615 vp9_worker_sync(&pbi->lf_worker);
616 lf_data->start = lf_start;
617 lf_data->stop = mi_row;
618 pbi->lf_worker.hook = vp9_loop_filter_worker;
619 vp9_worker_launch(&pbi->lf_worker);
620 } else {
621 vp9_loop_filter_rows(fb, pc, &pbi->mb, lf_start, mi_row, 0);
622 }
610 } 623 }
611 } 624 }
612 625
613 if (pbi->do_loopfilter_inline) { 626 if (pbi->do_loopfilter_inline) {
614 YV12_BUFFER_CONFIG *const fb = &pbi->common.yv12_fb[pbi->common.new_fb_idx]; 627 int lf_start;
628 if (num_threads > 1) {
629 LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1;
630
631 vp9_worker_sync(&pbi->lf_worker);
632 lf_start = lf_data->stop;
633 } else {
634 lf_start = mi_row - MI_BLOCK_SIZE;
635 }
615 vp9_loop_filter_rows(fb, pc, &pbi->mb, 636 vp9_loop_filter_rows(fb, pc, &pbi->mb,
616 mi_row - MI_BLOCK_SIZE, pc->mi_rows, 0); 637 lf_start, pc->mi_rows, 0);
617 } 638 }
618 } 639 }
619 640
620 static void setup_tile_info(VP9_COMMON *cm, struct vp9_read_bit_buffer *rb) { 641 static void setup_tile_info(VP9_COMMON *cm, struct vp9_read_bit_buffer *rb) {
621 int min_log2_tile_cols, max_log2_tile_cols, max_ones; 642 int min_log2_tile_cols, max_log2_tile_cols, max_ones;
622 vp9_get_tile_n_bits(cm->mi_cols, &min_log2_tile_cols, &max_log2_tile_cols); 643 vp9_get_tile_n_bits(cm->mi_cols, &min_log2_tile_cols, &max_log2_tile_cols);
623 644
624 // columns 645 // columns
625 max_ones = max_log2_tile_cols - min_log2_tile_cols; 646 max_ones = max_log2_tile_cols - min_log2_tile_cols;
626 cm->log2_tile_cols = min_log2_tile_cols; 647 cm->log2_tile_cols = min_log2_tile_cols;
(...skipping 13 matching lines...) Expand all
640 661
641 const uint8_t *const data_end = pbi->source + pbi->source_sz; 662 const uint8_t *const data_end = pbi->source + pbi->source_sz;
642 const int aligned_mi_cols = mi_cols_aligned_to_sb(pc->mi_cols); 663 const int aligned_mi_cols = mi_cols_aligned_to_sb(pc->mi_cols);
643 const int tile_cols = 1 << pc->log2_tile_cols; 664 const int tile_cols = 1 << pc->log2_tile_cols;
644 const int tile_rows = 1 << pc->log2_tile_rows; 665 const int tile_rows = 1 << pc->log2_tile_rows;
645 int tile_row, tile_col; 666 int tile_row, tile_col;
646 667
647 // Note: this memset assumes above_context[0], [1] and [2] 668 // Note: this memset assumes above_context[0], [1] and [2]
648 // are allocated as part of the same buffer. 669 // are allocated as part of the same buffer.
649 vpx_memset(pc->above_context[0], 0, 670 vpx_memset(pc->above_context[0], 0,
650 sizeof(ENTROPY_CONTEXT) * 2 * MAX_MB_PLANE * aligned_mi_cols); 671 sizeof(ENTROPY_CONTEXT) * MAX_MB_PLANE * (2 * aligned_mi_cols));
651 672
652 vpx_memset(pc->above_seg_context, 0, 673 vpx_memset(pc->above_seg_context, 0,
653 sizeof(PARTITION_CONTEXT) * aligned_mi_cols); 674 sizeof(PARTITION_CONTEXT) * aligned_mi_cols);
654 675
655 if (pbi->oxcf.inv_tile_order) { 676 if (pbi->oxcf.inv_tile_order) {
656 const uint8_t *data_ptr2[4][1 << 6]; 677 const uint8_t *data_ptr2[4][1 << 6];
657 vp9_reader bc_bak = {0}; 678 vp9_reader bc_bak = {0};
658 679
659 // pre-initialize the offsets, we're going to read in inverse order 680 // pre-initialize the offsets, we're going to read in inverse order
660 data_ptr2[0][0] = data; 681 data_ptr2[0][0] = data;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 "Invalid frame marker"); 799 "Invalid frame marker");
779 800
780 cm->version = vp9_rb_read_bit(rb); 801 cm->version = vp9_rb_read_bit(rb);
781 RESERVED; 802 RESERVED;
782 803
783 if (vp9_rb_read_bit(rb)) { 804 if (vp9_rb_read_bit(rb)) {
784 // show an existing frame directly 805 // show an existing frame directly
785 int frame_to_show = cm->ref_frame_map[vp9_rb_read_literal(rb, 3)]; 806 int frame_to_show = cm->ref_frame_map[vp9_rb_read_literal(rb, 3)];
786 ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->new_fb_idx, frame_to_show); 807 ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->new_fb_idx, frame_to_show);
787 pbi->refresh_frame_flags = 0; 808 pbi->refresh_frame_flags = 0;
788 xd->lf.filter_level = 0; 809 cm->lf.filter_level = 0;
789 return 0; 810 return 0;
790 } 811 }
791 812
792 cm->frame_type = (FRAME_TYPE) vp9_rb_read_bit(rb); 813 cm->frame_type = (FRAME_TYPE) vp9_rb_read_bit(rb);
793 cm->show_frame = vp9_rb_read_bit(rb); 814 cm->show_frame = vp9_rb_read_bit(rb);
794 cm->error_resilient_mode = vp9_rb_read_bit(rb); 815 cm->error_resilient_mode = vp9_rb_read_bit(rb);
795 816
796 if (cm->frame_type == KEY_FRAME) { 817 if (cm->frame_type == KEY_FRAME) {
797 int csp; 818 int csp;
798 819
(...skipping 30 matching lines...) Expand all
829 850
830 cm->reset_frame_context = cm->error_resilient_mode ? 851 cm->reset_frame_context = cm->error_resilient_mode ?
831 0 : vp9_rb_read_literal(rb, 2); 852 0 : vp9_rb_read_literal(rb, 2);
832 853
833 if (cm->intra_only) { 854 if (cm->intra_only) {
834 check_sync_code(cm, rb); 855 check_sync_code(cm, rb);
835 856
836 pbi->refresh_frame_flags = vp9_rb_read_literal(rb, NUM_REF_FRAMES); 857 pbi->refresh_frame_flags = vp9_rb_read_literal(rb, NUM_REF_FRAMES);
837 setup_frame_size(pbi, rb); 858 setup_frame_size(pbi, rb);
838 } else { 859 } else {
839 pbi->refresh_frame_flags = vp9_rb_read_literal(rb, NUM_REF_FRAMES); 860 pbi->refresh_frame_flags = vp9_rb_read_literal(rb, NUM_REF_FRAMES);
840 861
841 for (i = 0; i < ALLOWED_REFS_PER_FRAME; ++i) { 862 for (i = 0; i < ALLOWED_REFS_PER_FRAME; ++i) {
842 const int ref = vp9_rb_read_literal(rb, NUM_REF_FRAMES_LOG2); 863 const int ref = vp9_rb_read_literal(rb, NUM_REF_FRAMES_LOG2);
843 cm->active_ref_idx[i] = cm->ref_frame_map[ref]; 864 cm->active_ref_idx[i] = cm->ref_frame_map[ref];
844 cm->ref_frame_sign_bias[LAST_FRAME + i] = vp9_rb_read_bit(rb); 865 cm->ref_frame_sign_bias[LAST_FRAME + i] = vp9_rb_read_bit(rb);
845 } 866 }
846 867
847 setup_frame_size_with_refs(pbi, rb); 868 setup_frame_size_with_refs(pbi, rb);
848 869
849 xd->allow_high_precision_mv = vp9_rb_read_bit(rb); 870 xd->allow_high_precision_mv = vp9_rb_read_bit(rb);
(...skipping 10 matching lines...) Expand all
860 cm->refresh_frame_context = vp9_rb_read_bit(rb); 881 cm->refresh_frame_context = vp9_rb_read_bit(rb);
861 cm->frame_parallel_decoding_mode = vp9_rb_read_bit(rb); 882 cm->frame_parallel_decoding_mode = vp9_rb_read_bit(rb);
862 } else { 883 } else {
863 cm->refresh_frame_context = 0; 884 cm->refresh_frame_context = 0;
864 cm->frame_parallel_decoding_mode = 1; 885 cm->frame_parallel_decoding_mode = 1;
865 } 886 }
866 887
867 cm->frame_context_idx = vp9_rb_read_literal(rb, NUM_FRAME_CONTEXTS_LOG2); 888 cm->frame_context_idx = vp9_rb_read_literal(rb, NUM_FRAME_CONTEXTS_LOG2);
868 889
869 if (cm->frame_type == KEY_FRAME || cm->error_resilient_mode || cm->intra_only) 890 if (cm->frame_type == KEY_FRAME || cm->error_resilient_mode || cm->intra_only)
870 vp9_setup_past_independence(cm, xd); 891 vp9_setup_past_independence(cm);
871 892
872 setup_loopfilter(&xd->lf, rb); 893 setup_loopfilter(&cm->lf, rb);
873 setup_quantization(pbi, rb); 894 setup_quantization(pbi, rb);
874 setup_segmentation(&xd->seg, rb); 895 setup_segmentation(&cm->seg, rb);
875 896
876 setup_tile_info(cm, rb); 897 setup_tile_info(cm, rb);
877 898
878 return vp9_rb_read_literal(rb, 16); 899 return vp9_rb_read_literal(rb, 16);
879 } 900 }
880 901
881 static int read_compressed_header(VP9D_COMP *pbi, const uint8_t *data, 902 static int read_compressed_header(VP9D_COMP *pbi, const uint8_t *data,
882 size_t partition_size) { 903 size_t partition_size) {
883 VP9_COMMON *const cm = &pbi->common; 904 VP9_COMMON *const cm = &pbi->common;
884 MACROBLOCKD *const xd = &pbi->mb; 905 MACROBLOCKD *const xd = &pbi->mb;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 947
927 if (!first_partition_size) { 948 if (!first_partition_size) {
928 // showing a frame directly 949 // showing a frame directly
929 *p_data_end = data + 1; 950 *p_data_end = data + 1;
930 return 0; 951 return 0;
931 } 952 }
932 data += vp9_rb_bytes_read(&rb); 953 data += vp9_rb_bytes_read(&rb);
933 xd->corrupted = 0; 954 xd->corrupted = 0;
934 new_fb->corrupted = 0; 955 new_fb->corrupted = 0;
935 pbi->do_loopfilter_inline = 956 pbi->do_loopfilter_inline =
936 (pc->log2_tile_rows | pc->log2_tile_cols) == 0 && pbi->mb.lf.filter_level; 957 (pc->log2_tile_rows | pc->log2_tile_cols) == 0 && pc->lf.filter_level;
937 958
938 if (!pbi->decoded_key_frame && !keyframe) 959 if (!pbi->decoded_key_frame && !keyframe)
939 return -1; 960 return -1;
940 961
941 if (!read_is_valid(data, first_partition_size, data_end)) 962 if (!read_is_valid(data, first_partition_size, data_end))
942 vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME, 963 vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
943 "Truncated packet or corrupt header length"); 964 "Truncated packet or corrupt header length");
944 965
945 xd->mode_info_context = pc->mi; 966 xd->mode_info_context = pc->mi;
946 xd->prev_mode_info_context = pc->prev_mi; 967 xd->prev_mode_info_context = pc->prev_mi;
947 xd->mode_info_stride = pc->mode_info_stride; 968 xd->mode_info_stride = pc->mode_info_stride;
948 969
949 init_dequantizer(pc, &pbi->mb); 970 init_dequantizer(pc, &pbi->mb);
950 971
951 if (!keyframe) 972 if (!keyframe)
952 vp9_setup_interp_filters(xd, pc->mcomp_filter_type, pc); 973 vp9_setup_interp_filters(xd, pc->mcomp_filter_type, pc);
953 974
954 pc->fc = pc->frame_contexts[pc->frame_context_idx]; 975 pc->fc = pc->frame_contexts[pc->frame_context_idx];
955 976
956 vp9_zero(pc->counts); 977 vp9_zero(pc->counts);
957 978
958 // Initialize xd pointers. Any reference should do for xd->pre, so use 0.
959 setup_pre_planes(xd, 0, &pc->yv12_fb[pc->active_ref_idx[0]], 0, 0, NULL);
960 setup_dst_planes(xd, new_fb, 0, 0);
961
962 new_fb->corrupted |= read_compressed_header(pbi, data, first_partition_size); 979 new_fb->corrupted |= read_compressed_header(pbi, data, first_partition_size);
963 980
964 // Create the segmentation map structure and set to 0
965 if (!pc->last_frame_seg_map)
966 CHECK_MEM_ERROR(pc, pc->last_frame_seg_map,
967 vpx_calloc((pc->mi_rows * pc->mi_cols), 1));
968
969 setup_block_dptrs(xd, pc->subsampling_x, pc->subsampling_y); 981 setup_block_dptrs(xd, pc->subsampling_x, pc->subsampling_y);
970 982
971 // clear out the coeff buffer 983 // clear out the coeff buffer
972 for (i = 0; i < MAX_MB_PLANE; ++i) 984 for (i = 0; i < MAX_MB_PLANE; ++i)
973 vp9_zero(xd->plane[i].qcoeff); 985 vp9_zero(xd->plane[i].qcoeff);
974 986
975 set_prev_mi(pc); 987 set_prev_mi(pc);
976 988
977 *p_data_end = decode_tiles(pbi, data + first_partition_size); 989 *p_data_end = decode_tiles(pbi, data + first_partition_size);
978 990
979 pc->last_width = pc->width; 991 pc->last_width = pc->width;
980 pc->last_height = pc->height; 992 pc->last_height = pc->height;
981 993
982 new_fb->corrupted |= xd->corrupted; 994 new_fb->corrupted |= xd->corrupted;
983 995
984 if (!pbi->decoded_key_frame) { 996 if (!pbi->decoded_key_frame) {
985 if (keyframe && !new_fb->corrupted) 997 if (keyframe && !new_fb->corrupted)
986 pbi->decoded_key_frame = 1; 998 pbi->decoded_key_frame = 1;
987 else 999 else
988 vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME, 1000 vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
989 "A stream must start with a complete key frame"); 1001 "A stream must start with a complete key frame");
990 } 1002 }
991 1003
992 if (!pc->error_resilient_mode && !pc->frame_parallel_decoding_mode) { 1004 if (!pc->error_resilient_mode && !pc->frame_parallel_decoding_mode) {
993 vp9_adapt_coef_probs(pc); 1005 vp9_adapt_coef_probs(pc);
994 1006
995 if (!keyframe && !pc->intra_only) { 1007 if (!keyframe && !pc->intra_only) {
996 vp9_adapt_mode_probs(pc); 1008 vp9_adapt_mode_probs(pc);
997 vp9_adapt_mode_context(pc);
998 vp9_adapt_mv_probs(pc, xd->allow_high_precision_mv); 1009 vp9_adapt_mv_probs(pc, xd->allow_high_precision_mv);
999 } 1010 }
1000 } 1011 }
1001 1012
1002 if (pc->refresh_frame_context) 1013 if (pc->refresh_frame_context)
1003 pc->frame_contexts[pc->frame_context_idx] = pc->fc; 1014 pc->frame_contexts[pc->frame_context_idx] = pc->fc;
1004 1015
1005 return 0; 1016 return 0;
1006 } 1017 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/decoder/vp9_decodemv.c ('k') | source/libvpx/vp9/decoder/vp9_detokenize.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698