| 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 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 PARTITION_TYPE partition; | 456 PARTITION_TYPE partition; |
| 457 BLOCK_SIZE subsize, uv_subsize; | 457 BLOCK_SIZE subsize, uv_subsize; |
| 458 | 458 |
| 459 if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) | 459 if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) |
| 460 return; | 460 return; |
| 461 | 461 |
| 462 partition = read_partition(cm, xd, hbs, mi_row, mi_col, bsize, r); | 462 partition = read_partition(cm, xd, hbs, mi_row, mi_col, bsize, r); |
| 463 subsize = get_subsize(bsize, partition); | 463 subsize = get_subsize(bsize, partition); |
| 464 uv_subsize = ss_size_lookup[subsize][cm->subsampling_x][cm->subsampling_y]; | 464 uv_subsize = ss_size_lookup[subsize][cm->subsampling_x][cm->subsampling_y]; |
| 465 if (subsize >= BLOCK_8X8 && uv_subsize == BLOCK_INVALID) | 465 if (subsize >= BLOCK_8X8 && uv_subsize == BLOCK_INVALID) |
| 466 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, | 466 vpx_internal_error(xd->error_info, |
| 467 "Invalid block size."); | 467 VPX_CODEC_CORRUPT_FRAME, "Invalid block size."); |
| 468 if (subsize < BLOCK_8X8) { | 468 if (subsize < BLOCK_8X8) { |
| 469 decode_block(cm, xd, tile, mi_row, mi_col, r, subsize); | 469 decode_block(cm, xd, tile, mi_row, mi_col, r, subsize); |
| 470 } else { | 470 } else { |
| 471 switch (partition) { | 471 switch (partition) { |
| 472 case PARTITION_NONE: | 472 case PARTITION_NONE: |
| 473 decode_block(cm, xd, tile, mi_row, mi_col, r, subsize); | 473 decode_block(cm, xd, tile, mi_row, mi_col, r, subsize); |
| 474 break; | 474 break; |
| 475 case PARTITION_HORZ: | 475 case PARTITION_HORZ: |
| 476 decode_block(cm, xd, tile, mi_row, mi_col, r, subsize); | 476 decode_block(cm, xd, tile, mi_row, mi_col, r, subsize); |
| 477 if (mi_row + hbs < cm->mi_rows) | 477 if (mi_row + hbs < cm->mi_rows) |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 resize_context_buffers(cm, width, height); | 712 resize_context_buffers(cm, width, height); |
| 713 setup_display_size(cm, rb); | 713 setup_display_size(cm, rb); |
| 714 | 714 |
| 715 if (vp9_realloc_frame_buffer( | 715 if (vp9_realloc_frame_buffer( |
| 716 get_frame_new_buffer(cm), cm->width, cm->height, | 716 get_frame_new_buffer(cm), cm->width, cm->height, |
| 717 cm->subsampling_x, cm->subsampling_y, | 717 cm->subsampling_x, cm->subsampling_y, |
| 718 #if CONFIG_VP9_HIGHBITDEPTH | 718 #if CONFIG_VP9_HIGHBITDEPTH |
| 719 cm->use_highbitdepth, | 719 cm->use_highbitdepth, |
| 720 #endif | 720 #endif |
| 721 VP9_DEC_BORDER_IN_PIXELS, | 721 VP9_DEC_BORDER_IN_PIXELS, |
| 722 cm->byte_alignment, |
| 722 &cm->frame_bufs[cm->new_fb_idx].raw_frame_buffer, cm->get_fb_cb, | 723 &cm->frame_bufs[cm->new_fb_idx].raw_frame_buffer, cm->get_fb_cb, |
| 723 cm->cb_priv)) { | 724 cm->cb_priv)) { |
| 724 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, | 725 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, |
| 725 "Failed to allocate frame buffer"); | 726 "Failed to allocate frame buffer"); |
| 726 } | 727 } |
| 727 cm->frame_bufs[cm->new_fb_idx].buf.subsampling_x = cm->subsampling_x; | 728 cm->frame_bufs[cm->new_fb_idx].buf.subsampling_x = cm->subsampling_x; |
| 728 cm->frame_bufs[cm->new_fb_idx].buf.subsampling_y = cm->subsampling_y; | 729 cm->frame_bufs[cm->new_fb_idx].buf.subsampling_y = cm->subsampling_y; |
| 729 cm->frame_bufs[cm->new_fb_idx].buf.bit_depth = (unsigned int)cm->bit_depth; | 730 cm->frame_bufs[cm->new_fb_idx].buf.bit_depth = (unsigned int)cm->bit_depth; |
| 730 } | 731 } |
| 731 | 732 |
| 732 static INLINE int valid_ref_frame_img_fmt(vpx_bit_depth_t ref_bit_depth, | 733 static INLINE int valid_ref_frame_img_fmt(vpx_bit_depth_t ref_bit_depth, |
| 733 int ref_xss, int ref_yss, | 734 int ref_xss, int ref_yss, |
| 734 vpx_bit_depth_t this_bit_depth, | 735 vpx_bit_depth_t this_bit_depth, |
| 735 int this_xss, int this_yss) { | 736 int this_xss, int this_yss) { |
| 736 return ref_bit_depth == this_bit_depth && ref_xss == this_xss && | 737 return ref_bit_depth == this_bit_depth && ref_xss == this_xss && |
| 737 ref_yss == this_yss; | 738 ref_yss == this_yss; |
| 738 } | 739 } |
| 739 | 740 |
| 740 static void setup_frame_size_with_refs(VP9_COMMON *cm, | 741 static void setup_frame_size_with_refs(VP9_COMMON *cm, |
| 741 struct vp9_read_bit_buffer *rb) { | 742 struct vp9_read_bit_buffer *rb) { |
| 742 int width, height; | 743 int width, height; |
| 743 int found = 0, i; | 744 int found = 0, i; |
| 744 int has_valid_ref_frame = 0; | 745 int has_valid_ref_frame = 0; |
| 745 for (i = 0; i < REFS_PER_FRAME; ++i) { | 746 for (i = 0; i < REFS_PER_FRAME; ++i) { |
| 746 if (vp9_rb_read_bit(rb)) { | 747 if (vp9_rb_read_bit(rb)) { |
| 747 YV12_BUFFER_CONFIG *const buf = cm->frame_refs[i].buf; | 748 YV12_BUFFER_CONFIG *const buf = cm->frame_refs[i].buf; |
| 748 width = buf->y_crop_width; | 749 width = buf->y_crop_width; |
| 749 height = buf->y_crop_height; | 750 height = buf->y_crop_height; |
| 750 if (buf->corrupted) { | |
| 751 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, | |
| 752 "Frame reference is corrupt"); | |
| 753 } | |
| 754 found = 1; | 751 found = 1; |
| 755 break; | 752 break; |
| 756 } | 753 } |
| 757 } | 754 } |
| 758 | 755 |
| 759 if (!found) | 756 if (!found) |
| 760 vp9_read_frame_size(rb, &width, &height); | 757 vp9_read_frame_size(rb, &width, &height); |
| 761 | 758 |
| 762 if (width <= 0 || height <= 0) | 759 if (width <= 0 || height <= 0) |
| 763 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, | 760 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 790 resize_context_buffers(cm, width, height); | 787 resize_context_buffers(cm, width, height); |
| 791 setup_display_size(cm, rb); | 788 setup_display_size(cm, rb); |
| 792 | 789 |
| 793 if (vp9_realloc_frame_buffer( | 790 if (vp9_realloc_frame_buffer( |
| 794 get_frame_new_buffer(cm), cm->width, cm->height, | 791 get_frame_new_buffer(cm), cm->width, cm->height, |
| 795 cm->subsampling_x, cm->subsampling_y, | 792 cm->subsampling_x, cm->subsampling_y, |
| 796 #if CONFIG_VP9_HIGHBITDEPTH | 793 #if CONFIG_VP9_HIGHBITDEPTH |
| 797 cm->use_highbitdepth, | 794 cm->use_highbitdepth, |
| 798 #endif | 795 #endif |
| 799 VP9_DEC_BORDER_IN_PIXELS, | 796 VP9_DEC_BORDER_IN_PIXELS, |
| 797 cm->byte_alignment, |
| 800 &cm->frame_bufs[cm->new_fb_idx].raw_frame_buffer, cm->get_fb_cb, | 798 &cm->frame_bufs[cm->new_fb_idx].raw_frame_buffer, cm->get_fb_cb, |
| 801 cm->cb_priv)) { | 799 cm->cb_priv)) { |
| 802 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, | 800 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, |
| 803 "Failed to allocate frame buffer"); | 801 "Failed to allocate frame buffer"); |
| 804 } | 802 } |
| 805 cm->frame_bufs[cm->new_fb_idx].buf.subsampling_x = cm->subsampling_x; | 803 cm->frame_bufs[cm->new_fb_idx].buf.subsampling_x = cm->subsampling_x; |
| 806 cm->frame_bufs[cm->new_fb_idx].buf.subsampling_y = cm->subsampling_y; | 804 cm->frame_bufs[cm->new_fb_idx].buf.subsampling_y = cm->subsampling_y; |
| 807 cm->frame_bufs[cm->new_fb_idx].buf.bit_depth = (unsigned int)cm->bit_depth; | 805 cm->frame_bufs[cm->new_fb_idx].buf.bit_depth = (unsigned int)cm->bit_depth; |
| 808 } | 806 } |
| 809 | 807 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 const TileBuffer *const buf = &tile_buffers[tile_row][tile_col]; | 947 const TileBuffer *const buf = &tile_buffers[tile_row][tile_col]; |
| 950 tile_data = pbi->tile_data + tile_cols * tile_row + tile_col; | 948 tile_data = pbi->tile_data + tile_cols * tile_row + tile_col; |
| 951 tile_data->cm = cm; | 949 tile_data->cm = cm; |
| 952 tile_data->xd = pbi->mb; | 950 tile_data->xd = pbi->mb; |
| 953 tile_data->xd.corrupted = 0; | 951 tile_data->xd.corrupted = 0; |
| 954 vp9_tile_init(&tile, tile_data->cm, tile_row, tile_col); | 952 vp9_tile_init(&tile, tile_data->cm, tile_row, tile_col); |
| 955 setup_token_decoder(buf->data, data_end, buf->size, &cm->error, | 953 setup_token_decoder(buf->data, data_end, buf->size, &cm->error, |
| 956 &tile_data->bit_reader, pbi->decrypt_cb, | 954 &tile_data->bit_reader, pbi->decrypt_cb, |
| 957 pbi->decrypt_state); | 955 pbi->decrypt_state); |
| 958 init_macroblockd(cm, &tile_data->xd); | 956 init_macroblockd(cm, &tile_data->xd); |
| 959 vp9_zero(tile_data->xd.dqcoeff); | |
| 960 } | 957 } |
| 961 } | 958 } |
| 962 | 959 |
| 963 for (tile_row = 0; tile_row < tile_rows; ++tile_row) { | 960 for (tile_row = 0; tile_row < tile_rows; ++tile_row) { |
| 964 TileInfo tile; | 961 TileInfo tile; |
| 965 vp9_tile_set_row(&tile, cm, tile_row); | 962 vp9_tile_set_row(&tile, cm, tile_row); |
| 966 for (mi_row = tile.mi_row_start; mi_row < tile.mi_row_end; | 963 for (mi_row = tile.mi_row_start; mi_row < tile.mi_row_end; |
| 967 mi_row += MI_BLOCK_SIZE) { | 964 mi_row += MI_BLOCK_SIZE) { |
| 968 for (tile_col = 0; tile_col < tile_cols; ++tile_col) { | 965 for (tile_col = 0; tile_col < tile_cols; ++tile_col) { |
| 969 const int col = pbi->inv_tile_order ? | 966 const int col = pbi->inv_tile_order ? |
| 970 tile_cols - tile_col - 1 : tile_col; | 967 tile_cols - tile_col - 1 : tile_col; |
| 971 tile_data = pbi->tile_data + tile_cols * tile_row + col; | 968 tile_data = pbi->tile_data + tile_cols * tile_row + col; |
| 972 vp9_tile_set_col(&tile, tile_data->cm, col); | 969 vp9_tile_set_col(&tile, tile_data->cm, col); |
| 973 vp9_zero(tile_data->xd.left_context); | 970 vp9_zero(tile_data->xd.left_context); |
| 974 vp9_zero(tile_data->xd.left_seg_context); | 971 vp9_zero(tile_data->xd.left_seg_context); |
| 975 for (mi_col = tile.mi_col_start; mi_col < tile.mi_col_end; | 972 for (mi_col = tile.mi_col_start; mi_col < tile.mi_col_end; |
| 976 mi_col += MI_BLOCK_SIZE) { | 973 mi_col += MI_BLOCK_SIZE) { |
| 977 decode_partition(tile_data->cm, &tile_data->xd, &tile, mi_row, mi_col, | 974 decode_partition(tile_data->cm, &tile_data->xd, &tile, mi_row, mi_col, |
| 978 &tile_data->bit_reader, BLOCK_64X64); | 975 &tile_data->bit_reader, BLOCK_64X64); |
| 979 } | 976 } |
| 980 pbi->mb.corrupted |= tile_data->xd.corrupted; | 977 pbi->mb.corrupted |= tile_data->xd.corrupted; |
| 978 if (pbi->mb.corrupted) |
| 979 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, |
| 980 "Failed to decode tile data"); |
| 981 } | 981 } |
| 982 // Loopfilter one row. | 982 // Loopfilter one row. |
| 983 if (cm->lf.filter_level && !pbi->mb.corrupted) { | 983 if (cm->lf.filter_level) { |
| 984 const int lf_start = mi_row - MI_BLOCK_SIZE; | 984 const int lf_start = mi_row - MI_BLOCK_SIZE; |
| 985 LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1; | 985 LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1; |
| 986 | 986 |
| 987 // delay the loopfilter by 1 macroblock row. | 987 // delay the loopfilter by 1 macroblock row. |
| 988 if (lf_start < 0) continue; | 988 if (lf_start < 0) continue; |
| 989 | 989 |
| 990 // decoding has completed: finish up the loop filter in this thread. | 990 // decoding has completed: finish up the loop filter in this thread. |
| 991 if (mi_row + MI_BLOCK_SIZE >= cm->mi_rows) continue; | 991 if (mi_row + MI_BLOCK_SIZE >= cm->mi_rows) continue; |
| 992 | 992 |
| 993 winterface->sync(&pbi->lf_worker); | 993 winterface->sync(&pbi->lf_worker); |
| 994 lf_data->start = lf_start; | 994 lf_data->start = lf_start; |
| 995 lf_data->stop = mi_row; | 995 lf_data->stop = mi_row; |
| 996 if (pbi->max_threads > 1) { | 996 if (pbi->max_threads > 1) { |
| 997 winterface->launch(&pbi->lf_worker); | 997 winterface->launch(&pbi->lf_worker); |
| 998 } else { | 998 } else { |
| 999 winterface->execute(&pbi->lf_worker); | 999 winterface->execute(&pbi->lf_worker); |
| 1000 } | 1000 } |
| 1001 } | 1001 } |
| 1002 } | 1002 } |
| 1003 } | 1003 } |
| 1004 | 1004 |
| 1005 // Loopfilter remaining rows in the frame. | 1005 // Loopfilter remaining rows in the frame. |
| 1006 if (cm->lf.filter_level && !pbi->mb.corrupted) { | 1006 if (cm->lf.filter_level) { |
| 1007 LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1; | 1007 LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1; |
| 1008 winterface->sync(&pbi->lf_worker); | 1008 winterface->sync(&pbi->lf_worker); |
| 1009 lf_data->start = lf_data->stop; | 1009 lf_data->start = lf_data->stop; |
| 1010 lf_data->stop = cm->mi_rows; | 1010 lf_data->stop = cm->mi_rows; |
| 1011 winterface->execute(&pbi->lf_worker); | 1011 winterface->execute(&pbi->lf_worker); |
| 1012 } | 1012 } |
| 1013 | 1013 |
| 1014 // Get last tile data. | 1014 // Get last tile data. |
| 1015 tile_data = pbi->tile_data + tile_cols * tile_rows - 1; | 1015 tile_data = pbi->tile_data + tile_cols * tile_rows - 1; |
| 1016 | 1016 |
| 1017 return vp9_reader_find_end(&tile_data->bit_reader); | 1017 return vp9_reader_find_end(&tile_data->bit_reader); |
| 1018 } | 1018 } |
| 1019 | 1019 |
| 1020 static int tile_worker_hook(TileWorkerData *const tile_data, | 1020 static int tile_worker_hook(TileWorkerData *const tile_data, |
| 1021 const TileInfo *const tile) { | 1021 const TileInfo *const tile) { |
| 1022 int mi_row, mi_col; | 1022 int mi_row, mi_col; |
| 1023 | 1023 |
| 1024 if (setjmp(tile_data->error_info.jmp)) { |
| 1025 tile_data->error_info.setjmp = 0; |
| 1026 tile_data->xd.corrupted = 1; |
| 1027 return 0; |
| 1028 } |
| 1029 |
| 1030 tile_data->error_info.setjmp = 1; |
| 1031 tile_data->xd.error_info = &tile_data->error_info; |
| 1032 |
| 1024 for (mi_row = tile->mi_row_start; mi_row < tile->mi_row_end; | 1033 for (mi_row = tile->mi_row_start; mi_row < tile->mi_row_end; |
| 1025 mi_row += MI_BLOCK_SIZE) { | 1034 mi_row += MI_BLOCK_SIZE) { |
| 1026 vp9_zero(tile_data->xd.left_context); | 1035 vp9_zero(tile_data->xd.left_context); |
| 1027 vp9_zero(tile_data->xd.left_seg_context); | 1036 vp9_zero(tile_data->xd.left_seg_context); |
| 1028 for (mi_col = tile->mi_col_start; mi_col < tile->mi_col_end; | 1037 for (mi_col = tile->mi_col_start; mi_col < tile->mi_col_end; |
| 1029 mi_col += MI_BLOCK_SIZE) { | 1038 mi_col += MI_BLOCK_SIZE) { |
| 1030 decode_partition(tile_data->cm, &tile_data->xd, tile, | 1039 decode_partition(tile_data->cm, &tile_data->xd, tile, |
| 1031 mi_row, mi_col, &tile_data->bit_reader, BLOCK_64X64); | 1040 mi_row, mi_col, &tile_data->bit_reader, BLOCK_64X64); |
| 1032 } | 1041 } |
| 1033 } | 1042 } |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1143 TileBuffer *const buf = &tile_buffers[0][n]; | 1152 TileBuffer *const buf = &tile_buffers[0][n]; |
| 1144 | 1153 |
| 1145 tile_data->cm = cm; | 1154 tile_data->cm = cm; |
| 1146 tile_data->xd = pbi->mb; | 1155 tile_data->xd = pbi->mb; |
| 1147 tile_data->xd.corrupted = 0; | 1156 tile_data->xd.corrupted = 0; |
| 1148 vp9_tile_init(tile, tile_data->cm, 0, buf->col); | 1157 vp9_tile_init(tile, tile_data->cm, 0, buf->col); |
| 1149 setup_token_decoder(buf->data, data_end, buf->size, &cm->error, | 1158 setup_token_decoder(buf->data, data_end, buf->size, &cm->error, |
| 1150 &tile_data->bit_reader, pbi->decrypt_cb, | 1159 &tile_data->bit_reader, pbi->decrypt_cb, |
| 1151 pbi->decrypt_state); | 1160 pbi->decrypt_state); |
| 1152 init_macroblockd(cm, &tile_data->xd); | 1161 init_macroblockd(cm, &tile_data->xd); |
| 1153 vp9_zero(tile_data->xd.dqcoeff); | |
| 1154 | 1162 |
| 1155 worker->had_error = 0; | 1163 worker->had_error = 0; |
| 1156 if (i == num_workers - 1 || n == tile_cols - 1) { | 1164 if (i == num_workers - 1 || n == tile_cols - 1) { |
| 1157 winterface->execute(worker); | 1165 winterface->execute(worker); |
| 1158 } else { | 1166 } else { |
| 1159 winterface->launch(worker); | 1167 winterface->launch(worker); |
| 1160 } | 1168 } |
| 1161 | 1169 |
| 1162 if (buf->col == tile_cols - 1) { | 1170 if (buf->col == tile_cols - 1) { |
| 1163 final_worker = i; | 1171 final_worker = i; |
| 1164 } | 1172 } |
| 1165 | 1173 |
| 1166 ++n; | 1174 ++n; |
| 1167 } | 1175 } |
| 1168 | 1176 |
| 1169 for (; i > 0; --i) { | 1177 for (; i > 0; --i) { |
| 1170 VP9Worker *const worker = &pbi->tile_workers[i - 1]; | 1178 VP9Worker *const worker = &pbi->tile_workers[i - 1]; |
| 1179 // TODO(jzern): The tile may have specific error data associated with |
| 1180 // its vpx_internal_error_info which could be propagated to the main info |
| 1181 // in cm. Additionally once the threads have been synced and an error is |
| 1182 // detected, there's no point in continuing to decode tiles. |
| 1171 pbi->mb.corrupted |= !winterface->sync(worker); | 1183 pbi->mb.corrupted |= !winterface->sync(worker); |
| 1172 } | 1184 } |
| 1173 if (final_worker > -1) { | 1185 if (final_worker > -1) { |
| 1174 TileWorkerData *const tile_data = | 1186 TileWorkerData *const tile_data = |
| 1175 (TileWorkerData*)pbi->tile_workers[final_worker].data1; | 1187 (TileWorkerData*)pbi->tile_workers[final_worker].data1; |
| 1176 bit_reader_end = vp9_reader_find_end(&tile_data->bit_reader); | 1188 bit_reader_end = vp9_reader_find_end(&tile_data->bit_reader); |
| 1177 final_worker = -1; | 1189 final_worker = -1; |
| 1178 } | 1190 } |
| 1179 } | 1191 } |
| 1180 | 1192 |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1540 // showing a frame directly | 1552 // showing a frame directly |
| 1541 *p_data_end = data + (cm->profile <= PROFILE_2 ? 1 : 2); | 1553 *p_data_end = data + (cm->profile <= PROFILE_2 ? 1 : 2); |
| 1542 return; | 1554 return; |
| 1543 } | 1555 } |
| 1544 | 1556 |
| 1545 data += vp9_rb_bytes_read(&rb); | 1557 data += vp9_rb_bytes_read(&rb); |
| 1546 if (!read_is_valid(data, first_partition_size, data_end)) | 1558 if (!read_is_valid(data, first_partition_size, data_end)) |
| 1547 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, | 1559 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, |
| 1548 "Truncated packet or corrupt header length"); | 1560 "Truncated packet or corrupt header length"); |
| 1549 | 1561 |
| 1550 init_macroblockd(cm, &pbi->mb); | |
| 1551 | |
| 1552 cm->use_prev_frame_mvs = !cm->error_resilient_mode && | 1562 cm->use_prev_frame_mvs = !cm->error_resilient_mode && |
| 1553 cm->width == cm->last_width && | 1563 cm->width == cm->last_width && |
| 1554 cm->height == cm->last_height && | 1564 cm->height == cm->last_height && |
| 1555 !cm->intra_only && | 1565 !cm->intra_only && |
| 1556 cm->last_show_frame; | 1566 cm->last_show_frame; |
| 1557 | 1567 |
| 1558 setup_plane_dequants(cm, xd, cm->base_qindex); | 1568 setup_plane_dequants(cm, xd, cm->base_qindex); |
| 1559 vp9_setup_block_planes(xd, cm->subsampling_x, cm->subsampling_y); | 1569 vp9_setup_block_planes(xd, cm->subsampling_x, cm->subsampling_y); |
| 1560 | 1570 |
| 1561 *cm->fc = cm->frame_contexts[cm->frame_context_idx]; | 1571 *cm->fc = cm->frame_contexts[cm->frame_context_idx]; |
| 1572 if (!cm->fc->initialized) |
| 1573 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, |
| 1574 "Uninitialized entropy context."); |
| 1575 |
| 1562 vp9_zero(cm->counts); | 1576 vp9_zero(cm->counts); |
| 1563 vp9_zero(xd->dqcoeff); | |
| 1564 | 1577 |
| 1565 xd->corrupted = 0; | 1578 xd->corrupted = 0; |
| 1566 new_fb->corrupted = read_compressed_header(pbi, data, first_partition_size); | 1579 new_fb->corrupted = read_compressed_header(pbi, data, first_partition_size); |
| 1580 if (new_fb->corrupted) |
| 1581 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, |
| 1582 "Decode failed. Frame data header is corrupted."); |
| 1567 | 1583 |
| 1568 // TODO(jzern): remove frame_parallel_decoding_mode restriction for | 1584 // TODO(jzern): remove frame_parallel_decoding_mode restriction for |
| 1569 // single-frame tile decoding. | 1585 // single-frame tile decoding. |
| 1570 if (pbi->max_threads > 1 && tile_rows == 1 && tile_cols > 1 && | 1586 if (pbi->max_threads > 1 && tile_rows == 1 && tile_cols > 1 && |
| 1571 cm->frame_parallel_decoding_mode) { | 1587 cm->frame_parallel_decoding_mode) { |
| 1572 *p_data_end = decode_tiles_mt(pbi, data + first_partition_size, data_end); | 1588 *p_data_end = decode_tiles_mt(pbi, data + first_partition_size, data_end); |
| 1573 if (!xd->corrupted) { | 1589 if (!xd->corrupted) { |
| 1574 // If multiple threads are used to decode tiles, then we use those threads | 1590 // If multiple threads are used to decode tiles, then we use those threads |
| 1575 // to do parallel loopfiltering. | 1591 // to do parallel loopfiltering. |
| 1576 vp9_loop_filter_frame_mt(&pbi->lf_row_sync, new_fb, pbi->mb.plane, cm, | 1592 vp9_loop_filter_frame_mt(&pbi->lf_row_sync, new_fb, pbi->mb.plane, cm, |
| 1577 pbi->tile_workers, pbi->num_tile_workers, | 1593 pbi->tile_workers, pbi->num_tile_workers, |
| 1578 cm->lf.filter_level, 0); | 1594 cm->lf.filter_level, 0); |
| 1595 } else { |
| 1596 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, |
| 1597 "Decode failed. Frame data is corrupted."); |
| 1598 |
| 1579 } | 1599 } |
| 1580 } else { | 1600 } else { |
| 1581 *p_data_end = decode_tiles(pbi, data + first_partition_size, data_end); | 1601 *p_data_end = decode_tiles(pbi, data + first_partition_size, data_end); |
| 1582 } | 1602 } |
| 1583 | 1603 |
| 1584 new_fb->corrupted |= xd->corrupted; | 1604 new_fb->corrupted |= xd->corrupted; |
| 1585 | 1605 |
| 1586 if (!new_fb->corrupted) { | 1606 if (!new_fb->corrupted) { |
| 1587 if (!cm->error_resilient_mode && !cm->frame_parallel_decoding_mode) { | 1607 if (!cm->error_resilient_mode && !cm->frame_parallel_decoding_mode) { |
| 1588 vp9_adapt_coef_probs(cm); | 1608 vp9_adapt_coef_probs(cm); |
| 1589 | 1609 |
| 1590 if (!frame_is_intra_only(cm)) { | 1610 if (!frame_is_intra_only(cm)) { |
| 1591 vp9_adapt_mode_probs(cm); | 1611 vp9_adapt_mode_probs(cm); |
| 1592 vp9_adapt_mv_probs(cm, cm->allow_high_precision_mv); | 1612 vp9_adapt_mv_probs(cm, cm->allow_high_precision_mv); |
| 1593 } | 1613 } |
| 1594 } else { | 1614 } else { |
| 1595 debug_check_frame_counts(cm); | 1615 debug_check_frame_counts(cm); |
| 1596 } | 1616 } |
| 1597 } else { | 1617 } else { |
| 1598 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, | 1618 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, |
| 1599 "Decode failed. Frame data is corrupted."); | 1619 "Decode failed. Frame data is corrupted."); |
| 1600 } | 1620 } |
| 1601 | 1621 |
| 1602 if (cm->refresh_frame_context) | 1622 if (cm->refresh_frame_context) |
| 1603 cm->frame_contexts[cm->frame_context_idx] = *cm->fc; | 1623 cm->frame_contexts[cm->frame_context_idx] = *cm->fc; |
| 1604 } | 1624 } |
| OLD | NEW |