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 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 xd->plane[i].dequant = cm->uv_dequant[q_index]; | 189 xd->plane[i].dequant = cm->uv_dequant[q_index]; |
190 } | 190 } |
191 | 191 |
192 static void inverse_transform_block(MACROBLOCKD* xd, int plane, int block, | 192 static void inverse_transform_block(MACROBLOCKD* xd, int plane, int block, |
193 TX_SIZE tx_size, uint8_t *dst, int stride, | 193 TX_SIZE tx_size, uint8_t *dst, int stride, |
194 int eob) { | 194 int eob) { |
195 struct macroblockd_plane *const pd = &xd->plane[plane]; | 195 struct macroblockd_plane *const pd = &xd->plane[plane]; |
196 if (eob > 0) { | 196 if (eob > 0) { |
197 TX_TYPE tx_type = DCT_DCT; | 197 TX_TYPE tx_type = DCT_DCT; |
198 tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); | 198 tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); |
| 199 #if CONFIG_VP9_HIGHBITDEPTH |
| 200 if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { |
| 201 if (xd->lossless) { |
| 202 tx_type = DCT_DCT; |
| 203 vp9_highbd_iwht4x4_add(dqcoeff, dst, stride, eob, xd->bd); |
| 204 } else { |
| 205 const PLANE_TYPE plane_type = pd->plane_type; |
| 206 switch (tx_size) { |
| 207 case TX_4X4: |
| 208 tx_type = get_tx_type_4x4(plane_type, xd, block); |
| 209 vp9_highbd_iht4x4_add(tx_type, dqcoeff, dst, stride, eob, xd->bd); |
| 210 break; |
| 211 case TX_8X8: |
| 212 tx_type = get_tx_type(plane_type, xd); |
| 213 vp9_highbd_iht8x8_add(tx_type, dqcoeff, dst, stride, eob, xd->bd); |
| 214 break; |
| 215 case TX_16X16: |
| 216 tx_type = get_tx_type(plane_type, xd); |
| 217 vp9_highbd_iht16x16_add(tx_type, dqcoeff, dst, stride, eob, xd->bd); |
| 218 break; |
| 219 case TX_32X32: |
| 220 tx_type = DCT_DCT; |
| 221 vp9_highbd_idct32x32_add(dqcoeff, dst, stride, eob, xd->bd); |
| 222 break; |
| 223 default: |
| 224 assert(0 && "Invalid transform size"); |
| 225 } |
| 226 } |
| 227 } else { |
| 228 if (xd->lossless) { |
| 229 tx_type = DCT_DCT; |
| 230 vp9_iwht4x4_add(dqcoeff, dst, stride, eob); |
| 231 } else { |
| 232 const PLANE_TYPE plane_type = pd->plane_type; |
| 233 switch (tx_size) { |
| 234 case TX_4X4: |
| 235 tx_type = get_tx_type_4x4(plane_type, xd, block); |
| 236 vp9_iht4x4_add(tx_type, dqcoeff, dst, stride, eob); |
| 237 break; |
| 238 case TX_8X8: |
| 239 tx_type = get_tx_type(plane_type, xd); |
| 240 vp9_iht8x8_add(tx_type, dqcoeff, dst, stride, eob); |
| 241 break; |
| 242 case TX_16X16: |
| 243 tx_type = get_tx_type(plane_type, xd); |
| 244 vp9_iht16x16_add(tx_type, dqcoeff, dst, stride, eob); |
| 245 break; |
| 246 case TX_32X32: |
| 247 tx_type = DCT_DCT; |
| 248 vp9_idct32x32_add(dqcoeff, dst, stride, eob); |
| 249 break; |
| 250 default: |
| 251 assert(0 && "Invalid transform size"); |
| 252 return; |
| 253 } |
| 254 } |
| 255 } |
| 256 #else |
199 if (xd->lossless) { | 257 if (xd->lossless) { |
200 tx_type = DCT_DCT; | 258 tx_type = DCT_DCT; |
201 vp9_iwht4x4_add(dqcoeff, dst, stride, eob); | 259 vp9_iwht4x4_add(dqcoeff, dst, stride, eob); |
202 } else { | 260 } else { |
203 const PLANE_TYPE plane_type = pd->plane_type; | 261 const PLANE_TYPE plane_type = pd->plane_type; |
204 switch (tx_size) { | 262 switch (tx_size) { |
205 case TX_4X4: | 263 case TX_4X4: |
206 tx_type = get_tx_type_4x4(plane_type, xd, block); | 264 tx_type = get_tx_type_4x4(plane_type, xd, block); |
207 vp9_iht4x4_add(tx_type, dqcoeff, dst, stride, eob); | 265 vp9_iht4x4_add(tx_type, dqcoeff, dst, stride, eob); |
208 break; | 266 break; |
209 case TX_8X8: | 267 case TX_8X8: |
210 tx_type = get_tx_type(plane_type, xd); | 268 tx_type = get_tx_type(plane_type, xd); |
211 vp9_iht8x8_add(tx_type, dqcoeff, dst, stride, eob); | 269 vp9_iht8x8_add(tx_type, dqcoeff, dst, stride, eob); |
212 break; | 270 break; |
213 case TX_16X16: | 271 case TX_16X16: |
214 tx_type = get_tx_type(plane_type, xd); | 272 tx_type = get_tx_type(plane_type, xd); |
215 vp9_iht16x16_add(tx_type, dqcoeff, dst, stride, eob); | 273 vp9_iht16x16_add(tx_type, dqcoeff, dst, stride, eob); |
216 break; | 274 break; |
217 case TX_32X32: | 275 case TX_32X32: |
218 tx_type = DCT_DCT; | 276 tx_type = DCT_DCT; |
219 vp9_idct32x32_add(dqcoeff, dst, stride, eob); | 277 vp9_idct32x32_add(dqcoeff, dst, stride, eob); |
220 break; | 278 break; |
221 default: | 279 default: |
222 assert(0 && "Invalid transform size"); | 280 assert(0 && "Invalid transform size"); |
| 281 return; |
223 } | 282 } |
224 } | 283 } |
| 284 #endif // CONFIG_VP9_HIGHBITDEPTH |
225 | 285 |
226 if (eob == 1) { | 286 if (eob == 1) { |
227 vpx_memset(dqcoeff, 0, 2 * sizeof(dqcoeff[0])); | 287 vpx_memset(dqcoeff, 0, 2 * sizeof(dqcoeff[0])); |
228 } else { | 288 } else { |
229 if (tx_type == DCT_DCT && tx_size <= TX_16X16 && eob <= 10) | 289 if (tx_type == DCT_DCT && tx_size <= TX_16X16 && eob <= 10) |
230 vpx_memset(dqcoeff, 0, 4 * (4 << tx_size) * sizeof(dqcoeff[0])); | 290 vpx_memset(dqcoeff, 0, 4 * (4 << tx_size) * sizeof(dqcoeff[0])); |
231 else if (tx_size == TX_32X32 && eob <= 34) | 291 else if (tx_size == TX_32X32 && eob <= 34) |
232 vpx_memset(dqcoeff, 0, 256 * sizeof(dqcoeff[0])); | 292 vpx_memset(dqcoeff, 0, 256 * sizeof(dqcoeff[0])); |
233 else | 293 else |
234 vpx_memset(dqcoeff, 0, (16 << (tx_size << 1)) * sizeof(dqcoeff[0])); | 294 vpx_memset(dqcoeff, 0, (16 << (tx_size << 1)) * sizeof(dqcoeff[0])); |
(...skipping 16 matching lines...) Expand all Loading... |
251 struct macroblockd_plane *const pd = &xd->plane[plane]; | 311 struct macroblockd_plane *const pd = &xd->plane[plane]; |
252 MODE_INFO *const mi = xd->mi[0].src_mi; | 312 MODE_INFO *const mi = xd->mi[0].src_mi; |
253 const PREDICTION_MODE mode = (plane == 0) ? get_y_mode(mi, block) | 313 const PREDICTION_MODE mode = (plane == 0) ? get_y_mode(mi, block) |
254 : mi->mbmi.uv_mode; | 314 : mi->mbmi.uv_mode; |
255 int x, y; | 315 int x, y; |
256 uint8_t *dst; | 316 uint8_t *dst; |
257 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &x, &y); | 317 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &x, &y); |
258 dst = &pd->dst.buf[4 * y * pd->dst.stride + 4 * x]; | 318 dst = &pd->dst.buf[4 * y * pd->dst.stride + 4 * x]; |
259 | 319 |
260 vp9_predict_intra_block(xd, block >> (tx_size << 1), | 320 vp9_predict_intra_block(xd, block >> (tx_size << 1), |
261 b_width_log2(plane_bsize), tx_size, mode, | 321 b_width_log2_lookup[plane_bsize], tx_size, mode, |
262 dst, pd->dst.stride, dst, pd->dst.stride, | 322 dst, pd->dst.stride, dst, pd->dst.stride, |
263 x, y, plane); | 323 x, y, plane); |
264 | 324 |
265 if (!mi->mbmi.skip) { | 325 if (!mi->mbmi.skip) { |
266 const int eob = vp9_decode_block_tokens(cm, xd, plane, block, | 326 const int eob = vp9_decode_block_tokens(cm, xd, plane, block, |
267 plane_bsize, x, y, tx_size, | 327 plane_bsize, x, y, tx_size, |
268 args->r); | 328 args->r); |
269 inverse_transform_block(xd, plane, block, tx_size, dst, pd->dst.stride, | 329 inverse_transform_block(xd, plane, block, tx_size, dst, pd->dst.stride, |
270 eob); | 330 eob); |
271 } | 331 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 set_skip_context(xd, mi_row, mi_col); | 377 set_skip_context(xd, mi_row, mi_col); |
318 | 378 |
319 // Distance of Mb to the various image edges. These are specified to 8th pel | 379 // Distance of Mb to the various image edges. These are specified to 8th pel |
320 // as they are always compared to values that are in 1/8th pel units | 380 // as they are always compared to values that are in 1/8th pel units |
321 set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw, cm->mi_rows, cm->mi_cols); | 381 set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw, cm->mi_rows, cm->mi_cols); |
322 | 382 |
323 vp9_setup_dst_planes(xd->plane, get_frame_new_buffer(cm), mi_row, mi_col); | 383 vp9_setup_dst_planes(xd->plane, get_frame_new_buffer(cm), mi_row, mi_col); |
324 return &xd->mi[0].mbmi; | 384 return &xd->mi[0].mbmi; |
325 } | 385 } |
326 | 386 |
327 static void set_ref(VP9_COMMON *const cm, MACROBLOCKD *const xd, | |
328 int idx, int mi_row, int mi_col) { | |
329 MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi; | |
330 RefBuffer *ref_buffer = &cm->frame_refs[mbmi->ref_frame[idx] - LAST_FRAME]; | |
331 xd->block_refs[idx] = ref_buffer; | |
332 if (!vp9_is_valid_scale(&ref_buffer->sf)) | |
333 vpx_internal_error(&cm->error, VPX_CODEC_UNSUP_BITSTREAM, | |
334 "Invalid scale factors"); | |
335 if (ref_buffer->buf->corrupted) | |
336 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, | |
337 "Block reference is corrupt"); | |
338 vp9_setup_pre_planes(xd, idx, ref_buffer->buf, mi_row, mi_col, | |
339 &ref_buffer->sf); | |
340 xd->corrupted |= ref_buffer->buf->corrupted; | |
341 } | |
342 | |
343 static void decode_block(VP9_COMMON *const cm, MACROBLOCKD *const xd, | 387 static void decode_block(VP9_COMMON *const cm, MACROBLOCKD *const xd, |
344 const TileInfo *const tile, | 388 const TileInfo *const tile, |
345 int mi_row, int mi_col, | 389 int mi_row, int mi_col, |
346 vp9_reader *r, BLOCK_SIZE bsize) { | 390 vp9_reader *r, BLOCK_SIZE bsize) { |
347 const int less8x8 = bsize < BLOCK_8X8; | 391 const int less8x8 = bsize < BLOCK_8X8; |
348 MB_MODE_INFO *mbmi = set_offsets(cm, xd, tile, bsize, mi_row, mi_col); | 392 MB_MODE_INFO *mbmi = set_offsets(cm, xd, tile, bsize, mi_row, mi_col); |
349 vp9_read_mode_info(cm, xd, tile, mi_row, mi_col, r); | 393 vp9_read_mode_info(cm, xd, tile, mi_row, mi_col, r); |
350 | 394 |
351 if (less8x8) | 395 if (less8x8) |
352 bsize = BLOCK_8X8; | 396 bsize = BLOCK_8X8; |
353 | 397 |
354 if (mbmi->skip) { | 398 if (mbmi->skip) { |
355 reset_skip_context(xd, bsize); | 399 reset_skip_context(xd, bsize); |
356 } else { | 400 } else { |
357 if (cm->seg.enabled) | 401 if (cm->seg.enabled) |
358 setup_plane_dequants(cm, xd, vp9_get_qindex(&cm->seg, mbmi->segment_id, | 402 setup_plane_dequants(cm, xd, vp9_get_qindex(&cm->seg, mbmi->segment_id, |
359 cm->base_qindex)); | 403 cm->base_qindex)); |
360 } | 404 } |
361 | 405 |
362 if (!is_inter_block(mbmi)) { | 406 if (!is_inter_block(mbmi)) { |
363 struct intra_args arg = { cm, xd, r }; | 407 struct intra_args arg = { cm, xd, r }; |
364 vp9_foreach_transformed_block(xd, bsize, | 408 vp9_foreach_transformed_block(xd, bsize, |
365 predict_and_reconstruct_intra_block, &arg); | 409 predict_and_reconstruct_intra_block, &arg); |
366 } else { | 410 } else { |
367 // Setup | |
368 set_ref(cm, xd, 0, mi_row, mi_col); | |
369 if (has_second_ref(mbmi)) | |
370 set_ref(cm, xd, 1, mi_row, mi_col); | |
371 | |
372 // Prediction | 411 // Prediction |
373 vp9_dec_build_inter_predictors_sb(xd, mi_row, mi_col, bsize); | 412 vp9_dec_build_inter_predictors_sb(xd, mi_row, mi_col, bsize); |
374 | 413 |
375 // Reconstruction | 414 // Reconstruction |
376 if (!mbmi->skip) { | 415 if (!mbmi->skip) { |
377 int eobtotal = 0; | 416 int eobtotal = 0; |
378 struct inter_args arg = { cm, xd, r, &eobtotal }; | 417 struct inter_args arg = { cm, xd, r, &eobtotal }; |
379 vp9_foreach_transformed_block(xd, bsize, reconstruct_inter_block, &arg); | 418 vp9_foreach_transformed_block(xd, bsize, reconstruct_inter_block, &arg); |
380 if (!less8x8 && eobtotal == 0) | 419 if (!less8x8 && eobtotal == 0) |
381 mbmi->skip = 1; // skip loopfilter | 420 mbmi->skip = 1; // skip loopfilter |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 } | 624 } |
586 | 625 |
587 static void setup_quantization(VP9_COMMON *const cm, MACROBLOCKD *const xd, | 626 static void setup_quantization(VP9_COMMON *const cm, MACROBLOCKD *const xd, |
588 struct vp9_read_bit_buffer *rb) { | 627 struct vp9_read_bit_buffer *rb) { |
589 int update = 0; | 628 int update = 0; |
590 | 629 |
591 cm->base_qindex = vp9_rb_read_literal(rb, QINDEX_BITS); | 630 cm->base_qindex = vp9_rb_read_literal(rb, QINDEX_BITS); |
592 update |= read_delta_q(rb, &cm->y_dc_delta_q); | 631 update |= read_delta_q(rb, &cm->y_dc_delta_q); |
593 update |= read_delta_q(rb, &cm->uv_dc_delta_q); | 632 update |= read_delta_q(rb, &cm->uv_dc_delta_q); |
594 update |= read_delta_q(rb, &cm->uv_ac_delta_q); | 633 update |= read_delta_q(rb, &cm->uv_ac_delta_q); |
595 if (update) | 634 if (update || cm->bit_depth != cm->dequant_bit_depth) { |
596 vp9_init_dequantizer(cm); | 635 vp9_init_dequantizer(cm); |
| 636 cm->dequant_bit_depth = cm->bit_depth; |
| 637 } |
597 | 638 |
598 xd->lossless = cm->base_qindex == 0 && | 639 xd->lossless = cm->base_qindex == 0 && |
599 cm->y_dc_delta_q == 0 && | 640 cm->y_dc_delta_q == 0 && |
600 cm->uv_dc_delta_q == 0 && | 641 cm->uv_dc_delta_q == 0 && |
601 cm->uv_ac_delta_q == 0; | 642 cm->uv_ac_delta_q == 0; |
| 643 #if CONFIG_VP9_HIGHBITDEPTH |
| 644 xd->bd = (int)cm->bit_depth; |
| 645 #endif |
602 } | 646 } |
603 | 647 |
604 static INTERP_FILTER read_interp_filter(struct vp9_read_bit_buffer *rb) { | 648 static INTERP_FILTER read_interp_filter(struct vp9_read_bit_buffer *rb) { |
605 const INTERP_FILTER literal_to_filter[] = { EIGHTTAP_SMOOTH, | 649 const INTERP_FILTER literal_to_filter[] = { EIGHTTAP_SMOOTH, |
606 EIGHTTAP, | 650 EIGHTTAP, |
607 EIGHTTAP_SHARP, | 651 EIGHTTAP_SHARP, |
608 BILINEAR }; | 652 BILINEAR }; |
609 return vp9_rb_read_bit(rb) ? SWITCHABLE | 653 return vp9_rb_read_bit(rb) ? SWITCHABLE |
610 : literal_to_filter[vp9_rb_read_literal(rb, 2)]; | 654 : literal_to_filter[vp9_rb_read_literal(rb, 2)]; |
611 } | 655 } |
612 | 656 |
613 void vp9_read_frame_size(struct vp9_read_bit_buffer *rb, | 657 void vp9_read_frame_size(struct vp9_read_bit_buffer *rb, |
614 int *width, int *height) { | 658 int *width, int *height) { |
615 const int w = vp9_rb_read_literal(rb, 16) + 1; | 659 *width = vp9_rb_read_literal(rb, 16) + 1; |
616 const int h = vp9_rb_read_literal(rb, 16) + 1; | 660 *height = vp9_rb_read_literal(rb, 16) + 1; |
617 *width = w; | |
618 *height = h; | |
619 } | 661 } |
620 | 662 |
621 static void setup_display_size(VP9_COMMON *cm, struct vp9_read_bit_buffer *rb) { | 663 static void setup_display_size(VP9_COMMON *cm, struct vp9_read_bit_buffer *rb) { |
622 cm->display_width = cm->width; | 664 cm->display_width = cm->width; |
623 cm->display_height = cm->height; | 665 cm->display_height = cm->height; |
624 if (vp9_rb_read_bit(rb)) | 666 if (vp9_rb_read_bit(rb)) |
625 vp9_read_frame_size(rb, &cm->display_width, &cm->display_height); | 667 vp9_read_frame_size(rb, &cm->display_width, &cm->display_height); |
626 } | 668 } |
627 | 669 |
628 static void resize_context_buffers(VP9_COMMON *cm, int width, int height) { | 670 static void resize_context_buffers(VP9_COMMON *cm, int width, int height) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 cm->subsampling_x, cm->subsampling_y, | 705 cm->subsampling_x, cm->subsampling_y, |
664 #if CONFIG_VP9_HIGHBITDEPTH | 706 #if CONFIG_VP9_HIGHBITDEPTH |
665 cm->use_highbitdepth, | 707 cm->use_highbitdepth, |
666 #endif | 708 #endif |
667 VP9_DEC_BORDER_IN_PIXELS, | 709 VP9_DEC_BORDER_IN_PIXELS, |
668 &cm->frame_bufs[cm->new_fb_idx].raw_frame_buffer, cm->get_fb_cb, | 710 &cm->frame_bufs[cm->new_fb_idx].raw_frame_buffer, cm->get_fb_cb, |
669 cm->cb_priv)) { | 711 cm->cb_priv)) { |
670 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, | 712 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, |
671 "Failed to allocate frame buffer"); | 713 "Failed to allocate frame buffer"); |
672 } | 714 } |
| 715 cm->frame_bufs[cm->new_fb_idx].buf.subsampling_x = cm->subsampling_x; |
| 716 cm->frame_bufs[cm->new_fb_idx].buf.subsampling_y = cm->subsampling_y; |
673 cm->frame_bufs[cm->new_fb_idx].buf.bit_depth = (unsigned int)cm->bit_depth; | 717 cm->frame_bufs[cm->new_fb_idx].buf.bit_depth = (unsigned int)cm->bit_depth; |
674 } | 718 } |
675 | 719 |
676 static INLINE int valid_ref_frame_img_fmt(vpx_bit_depth_t ref_bit_depth, | 720 static INLINE int valid_ref_frame_img_fmt(vpx_bit_depth_t ref_bit_depth, |
677 int ref_xss, int ref_yss, | 721 int ref_xss, int ref_yss, |
678 vpx_bit_depth_t this_bit_depth, | 722 vpx_bit_depth_t this_bit_depth, |
679 int this_xss, int this_yss) { | 723 int this_xss, int this_yss) { |
680 return ref_bit_depth == this_bit_depth && ref_xss == this_xss && | 724 return ref_bit_depth == this_bit_depth && ref_xss == this_xss && |
681 ref_yss == this_yss; | 725 ref_yss == this_yss; |
682 } | 726 } |
(...skipping 13 matching lines...) Expand all Loading... |
696 "Frame reference is corrupt"); | 740 "Frame reference is corrupt"); |
697 } | 741 } |
698 found = 1; | 742 found = 1; |
699 break; | 743 break; |
700 } | 744 } |
701 } | 745 } |
702 | 746 |
703 if (!found) | 747 if (!found) |
704 vp9_read_frame_size(rb, &width, &height); | 748 vp9_read_frame_size(rb, &width, &height); |
705 | 749 |
706 if (width <=0 || height <= 0) | 750 if (width <= 0 || height <= 0) |
707 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, | 751 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, |
708 "Invalid frame size"); | 752 "Invalid frame size"); |
709 | 753 |
710 // Check to make sure at least one of frames that this frame references | 754 // Check to make sure at least one of frames that this frame references |
711 // has valid dimensions. | 755 // has valid dimensions. |
712 for (i = 0; i < REFS_PER_FRAME; ++i) { | 756 for (i = 0; i < REFS_PER_FRAME; ++i) { |
713 RefBuffer *const ref_frame = &cm->frame_refs[i]; | 757 RefBuffer *const ref_frame = &cm->frame_refs[i]; |
714 has_valid_ref_frame |= valid_ref_frame_size(ref_frame->buf->y_crop_width, | 758 has_valid_ref_frame |= valid_ref_frame_size(ref_frame->buf->y_crop_width, |
715 ref_frame->buf->y_crop_height, | 759 ref_frame->buf->y_crop_height, |
716 width, height); | 760 width, height); |
717 } | 761 } |
718 if (!has_valid_ref_frame) | 762 if (!has_valid_ref_frame) |
719 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, | 763 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, |
720 "Referenced frame has invalid size"); | 764 "Referenced frame has invalid size"); |
721 for (i = 0; i < REFS_PER_FRAME; ++i) { | 765 for (i = 0; i < REFS_PER_FRAME; ++i) { |
722 RefBuffer *const ref_frame = &cm->frame_refs[i]; | 766 RefBuffer *const ref_frame = &cm->frame_refs[i]; |
723 if (!valid_ref_frame_img_fmt( | 767 if (!valid_ref_frame_img_fmt( |
724 ref_frame->buf->bit_depth, | 768 ref_frame->buf->bit_depth, |
725 ref_frame->buf->uv_crop_width < ref_frame->buf->y_crop_width, | 769 ref_frame->buf->subsampling_x, |
726 ref_frame->buf->uv_crop_height < ref_frame->buf->y_crop_height, | 770 ref_frame->buf->subsampling_y, |
727 cm->bit_depth, | 771 cm->bit_depth, |
728 cm->subsampling_x, | 772 cm->subsampling_x, |
729 cm->subsampling_y)) | 773 cm->subsampling_y)) |
730 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, | 774 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, |
731 "Referenced frame has incompatible color space"); | 775 "Referenced frame has incompatible color space"); |
732 } | 776 } |
733 | 777 |
734 resize_context_buffers(cm, width, height); | 778 resize_context_buffers(cm, width, height); |
735 setup_display_size(cm, rb); | 779 setup_display_size(cm, rb); |
736 | 780 |
737 if (vp9_realloc_frame_buffer( | 781 if (vp9_realloc_frame_buffer( |
738 get_frame_new_buffer(cm), cm->width, cm->height, | 782 get_frame_new_buffer(cm), cm->width, cm->height, |
739 cm->subsampling_x, cm->subsampling_y, | 783 cm->subsampling_x, cm->subsampling_y, |
740 #if CONFIG_VP9_HIGHBITDEPTH | 784 #if CONFIG_VP9_HIGHBITDEPTH |
741 cm->use_highbitdepth, | 785 cm->use_highbitdepth, |
742 #endif | 786 #endif |
743 VP9_DEC_BORDER_IN_PIXELS, | 787 VP9_DEC_BORDER_IN_PIXELS, |
744 &cm->frame_bufs[cm->new_fb_idx].raw_frame_buffer, cm->get_fb_cb, | 788 &cm->frame_bufs[cm->new_fb_idx].raw_frame_buffer, cm->get_fb_cb, |
745 cm->cb_priv)) { | 789 cm->cb_priv)) { |
746 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, | 790 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, |
747 "Failed to allocate frame buffer"); | 791 "Failed to allocate frame buffer"); |
748 } | 792 } |
| 793 cm->frame_bufs[cm->new_fb_idx].buf.subsampling_x = cm->subsampling_x; |
| 794 cm->frame_bufs[cm->new_fb_idx].buf.subsampling_y = cm->subsampling_y; |
749 cm->frame_bufs[cm->new_fb_idx].buf.bit_depth = (unsigned int)cm->bit_depth; | 795 cm->frame_bufs[cm->new_fb_idx].buf.bit_depth = (unsigned int)cm->bit_depth; |
750 } | 796 } |
751 | 797 |
752 static void setup_tile_info(VP9_COMMON *cm, struct vp9_read_bit_buffer *rb) { | 798 static void setup_tile_info(VP9_COMMON *cm, struct vp9_read_bit_buffer *rb) { |
753 int min_log2_tile_cols, max_log2_tile_cols, max_ones; | 799 int min_log2_tile_cols, max_log2_tile_cols, max_ones; |
754 vp9_get_tile_n_bits(cm->mi_cols, &min_log2_tile_cols, &max_log2_tile_cols); | 800 vp9_get_tile_n_bits(cm->mi_cols, &min_log2_tile_cols, &max_log2_tile_cols); |
755 | 801 |
756 // columns | 802 // columns |
757 max_ones = max_log2_tile_cols - min_log2_tile_cols; | 803 max_ones = max_log2_tile_cols - min_log2_tile_cols; |
758 cm->log2_tile_cols = min_log2_tile_cols; | 804 cm->log2_tile_cols = min_log2_tile_cols; |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1132 BITSTREAM_PROFILE vp9_read_profile(struct vp9_read_bit_buffer *rb) { | 1178 BITSTREAM_PROFILE vp9_read_profile(struct vp9_read_bit_buffer *rb) { |
1133 int profile = vp9_rb_read_bit(rb); | 1179 int profile = vp9_rb_read_bit(rb); |
1134 profile |= vp9_rb_read_bit(rb) << 1; | 1180 profile |= vp9_rb_read_bit(rb) << 1; |
1135 if (profile > 2) | 1181 if (profile > 2) |
1136 profile += vp9_rb_read_bit(rb); | 1182 profile += vp9_rb_read_bit(rb); |
1137 return (BITSTREAM_PROFILE) profile; | 1183 return (BITSTREAM_PROFILE) profile; |
1138 } | 1184 } |
1139 | 1185 |
1140 static void read_bitdepth_colorspace_sampling( | 1186 static void read_bitdepth_colorspace_sampling( |
1141 VP9_COMMON *cm, struct vp9_read_bit_buffer *rb) { | 1187 VP9_COMMON *cm, struct vp9_read_bit_buffer *rb) { |
1142 if (cm->profile >= PROFILE_2) | 1188 if (cm->profile >= PROFILE_2) { |
1143 cm->bit_depth = vp9_rb_read_bit(rb) ? VPX_BITS_12 : VPX_BITS_10; | 1189 cm->bit_depth = vp9_rb_read_bit(rb) ? VPX_BITS_12 : VPX_BITS_10; |
| 1190 #if CONFIG_VP9_HIGHBITDEPTH |
| 1191 cm->use_highbitdepth = 1; |
| 1192 #endif |
| 1193 } else { |
| 1194 cm->bit_depth = VPX_BITS_8; |
| 1195 #if CONFIG_VP9_HIGHBITDEPTH |
| 1196 cm->use_highbitdepth = 0; |
| 1197 #endif |
| 1198 } |
1144 cm->color_space = (COLOR_SPACE)vp9_rb_read_literal(rb, 3); | 1199 cm->color_space = (COLOR_SPACE)vp9_rb_read_literal(rb, 3); |
1145 if (cm->color_space != SRGB) { | 1200 if (cm->color_space != SRGB) { |
1146 vp9_rb_read_bit(rb); // [16,235] (including xvycc) vs [0,255] range | 1201 vp9_rb_read_bit(rb); // [16,235] (including xvycc) vs [0,255] range |
1147 if (cm->profile == PROFILE_1 || cm->profile == PROFILE_3) { | 1202 if (cm->profile == PROFILE_1 || cm->profile == PROFILE_3) { |
1148 cm->subsampling_x = vp9_rb_read_bit(rb); | 1203 cm->subsampling_x = vp9_rb_read_bit(rb); |
1149 cm->subsampling_y = vp9_rb_read_bit(rb); | 1204 cm->subsampling_y = vp9_rb_read_bit(rb); |
1150 if (cm->subsampling_x == 1 && cm->subsampling_y == 1) | 1205 if (cm->subsampling_x == 1 && cm->subsampling_y == 1) |
1151 vpx_internal_error(&cm->error, VPX_CODEC_UNSUP_BITSTREAM, | 1206 vpx_internal_error(&cm->error, VPX_CODEC_UNSUP_BITSTREAM, |
1152 "4:2:0 color not supported in profile 1 or 3"); | 1207 "4:2:0 color not supported in profile 1 or 3"); |
1153 if (vp9_rb_read_bit(rb)) | 1208 if (vp9_rb_read_bit(rb)) |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1237 "Invalid frame sync code"); | 1292 "Invalid frame sync code"); |
1238 if (cm->profile > PROFILE_0) { | 1293 if (cm->profile > PROFILE_0) { |
1239 read_bitdepth_colorspace_sampling(cm, rb); | 1294 read_bitdepth_colorspace_sampling(cm, rb); |
1240 } else { | 1295 } else { |
1241 // NOTE: The intra-only frame header does not include the specification | 1296 // NOTE: The intra-only frame header does not include the specification |
1242 // of either the color format or color sub-sampling in profile 0. VP9 | 1297 // of either the color format or color sub-sampling in profile 0. VP9 |
1243 // specifies that the default color space should be YUV 4:2:0 in this | 1298 // specifies that the default color space should be YUV 4:2:0 in this |
1244 // case (normative). | 1299 // case (normative). |
1245 cm->color_space = BT_601; | 1300 cm->color_space = BT_601; |
1246 cm->subsampling_y = cm->subsampling_x = 1; | 1301 cm->subsampling_y = cm->subsampling_x = 1; |
| 1302 cm->bit_depth = VPX_BITS_8; |
| 1303 #if CONFIG_VP9_HIGHBITDEPTH |
| 1304 cm->use_highbitdepth = 0; |
| 1305 #endif |
1247 } | 1306 } |
1248 | 1307 |
1249 pbi->refresh_frame_flags = vp9_rb_read_literal(rb, REF_FRAMES); | 1308 pbi->refresh_frame_flags = vp9_rb_read_literal(rb, REF_FRAMES); |
1250 setup_frame_size(cm, rb); | 1309 setup_frame_size(cm, rb); |
1251 pbi->need_resync = 0; | 1310 pbi->need_resync = 0; |
1252 } else { | 1311 } else { |
1253 pbi->refresh_frame_flags = vp9_rb_read_literal(rb, REF_FRAMES); | 1312 pbi->refresh_frame_flags = vp9_rb_read_literal(rb, REF_FRAMES); |
1254 for (i = 0; i < REFS_PER_FRAME; ++i) { | 1313 for (i = 0; i < REFS_PER_FRAME; ++i) { |
1255 const int ref = vp9_rb_read_literal(rb, REF_FRAMES_LOG2); | 1314 const int ref = vp9_rb_read_literal(rb, REF_FRAMES_LOG2); |
1256 const int idx = cm->ref_frame_map[ref]; | 1315 const int idx = cm->ref_frame_map[ref]; |
(...skipping 20 matching lines...) Expand all Loading... |
1277 vp9_setup_scale_factors_for_frame(&ref_buf->sf, | 1336 vp9_setup_scale_factors_for_frame(&ref_buf->sf, |
1278 ref_buf->buf->y_crop_width, | 1337 ref_buf->buf->y_crop_width, |
1279 ref_buf->buf->y_crop_height, | 1338 ref_buf->buf->y_crop_height, |
1280 cm->width, cm->height); | 1339 cm->width, cm->height); |
1281 #endif | 1340 #endif |
1282 if (vp9_is_scaled(&ref_buf->sf)) | 1341 if (vp9_is_scaled(&ref_buf->sf)) |
1283 vp9_extend_frame_borders(ref_buf->buf); | 1342 vp9_extend_frame_borders(ref_buf->buf); |
1284 } | 1343 } |
1285 } | 1344 } |
1286 } | 1345 } |
| 1346 #if CONFIG_VP9_HIGHBITDEPTH |
| 1347 get_frame_new_buffer(cm)->bit_depth = cm->bit_depth; |
| 1348 #endif |
1287 | 1349 |
1288 if (pbi->need_resync) { | 1350 if (pbi->need_resync) { |
1289 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, | 1351 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, |
1290 "Keyframe / intra-only frame required to reset decoder" | 1352 "Keyframe / intra-only frame required to reset decoder" |
1291 " state"); | 1353 " state"); |
1292 } | 1354 } |
1293 | 1355 |
1294 if (!cm->error_resilient_mode) { | 1356 if (!cm->error_resilient_mode) { |
1295 cm->refresh_frame_context = vp9_rb_read_bit(rb); | 1357 cm->refresh_frame_context = vp9_rb_read_bit(rb); |
1296 cm->frame_parallel_decoding_mode = vp9_rb_read_bit(rb); | 1358 cm->frame_parallel_decoding_mode = vp9_rb_read_bit(rb); |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1513 debug_check_frame_counts(cm); | 1575 debug_check_frame_counts(cm); |
1514 } | 1576 } |
1515 } else { | 1577 } else { |
1516 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, | 1578 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, |
1517 "Decode failed. Frame data is corrupted."); | 1579 "Decode failed. Frame data is corrupted."); |
1518 } | 1580 } |
1519 | 1581 |
1520 if (cm->refresh_frame_context) | 1582 if (cm->refresh_frame_context) |
1521 cm->frame_contexts[cm->frame_context_idx] = cm->fc; | 1583 cm->frame_contexts[cm->frame_context_idx] = cm->fc; |
1522 } | 1584 } |
OLD | NEW |