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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 } | 323 } |
324 | 324 |
325 static void set_ref(VP9_COMMON *const cm, MACROBLOCKD *const xd, | 325 static void set_ref(VP9_COMMON *const cm, MACROBLOCKD *const xd, |
326 int idx, int mi_row, int mi_col) { | 326 int idx, int mi_row, int mi_col) { |
327 MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; | 327 MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; |
328 RefBuffer *ref_buffer = &cm->frame_refs[mbmi->ref_frame[idx] - LAST_FRAME]; | 328 RefBuffer *ref_buffer = &cm->frame_refs[mbmi->ref_frame[idx] - LAST_FRAME]; |
329 xd->block_refs[idx] = ref_buffer; | 329 xd->block_refs[idx] = ref_buffer; |
330 if (!vp9_is_valid_scale(&ref_buffer->sf)) | 330 if (!vp9_is_valid_scale(&ref_buffer->sf)) |
331 vpx_internal_error(&cm->error, VPX_CODEC_UNSUP_BITSTREAM, | 331 vpx_internal_error(&cm->error, VPX_CODEC_UNSUP_BITSTREAM, |
332 "Invalid scale factors"); | 332 "Invalid scale factors"); |
| 333 if (ref_buffer->buf->corrupted) |
| 334 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, |
| 335 "Block reference is corrupt"); |
333 vp9_setup_pre_planes(xd, idx, ref_buffer->buf, mi_row, mi_col, | 336 vp9_setup_pre_planes(xd, idx, ref_buffer->buf, mi_row, mi_col, |
334 &ref_buffer->sf); | 337 &ref_buffer->sf); |
335 xd->corrupted |= ref_buffer->buf->corrupted; | 338 xd->corrupted |= ref_buffer->buf->corrupted; |
336 } | 339 } |
337 | 340 |
338 static void decode_block(VP9_COMMON *const cm, MACROBLOCKD *const xd, | 341 static void decode_block(VP9_COMMON *const cm, MACROBLOCKD *const xd, |
339 const TileInfo *const tile, | 342 const TileInfo *const tile, |
340 int mi_row, int mi_col, | 343 int mi_row, int mi_col, |
341 vp9_reader *r, BLOCK_SIZE bsize) { | 344 vp9_reader *r, BLOCK_SIZE bsize) { |
342 const int less8x8 = bsize < BLOCK_8X8; | 345 const int less8x8 = bsize < BLOCK_8X8; |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 vp9_read_frame_size(rb, &cm->display_width, &cm->display_height); | 623 vp9_read_frame_size(rb, &cm->display_width, &cm->display_height); |
621 } | 624 } |
622 | 625 |
623 static void resize_context_buffers(VP9_COMMON *cm, int width, int height) { | 626 static void resize_context_buffers(VP9_COMMON *cm, int width, int height) { |
624 #if CONFIG_SIZE_LIMIT | 627 #if CONFIG_SIZE_LIMIT |
625 if (width > DECODE_WIDTH_LIMIT || height > DECODE_HEIGHT_LIMIT) | 628 if (width > DECODE_WIDTH_LIMIT || height > DECODE_HEIGHT_LIMIT) |
626 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, | 629 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, |
627 "Width and height beyond allowed size."); | 630 "Width and height beyond allowed size."); |
628 #endif | 631 #endif |
629 if (cm->width != width || cm->height != height) { | 632 if (cm->width != width || cm->height != height) { |
630 const int new_rows = ALIGN_POWER_OF_TWO(height, | 633 const int new_mi_rows = |
631 MI_SIZE_LOG2) >> MI_SIZE_LOG2; | 634 ALIGN_POWER_OF_TWO(height, MI_SIZE_LOG2) >> MI_SIZE_LOG2; |
632 const int new_cols = ALIGN_POWER_OF_TWO(width, | 635 const int new_mi_cols = |
633 MI_SIZE_LOG2) >> MI_SIZE_LOG2; | 636 ALIGN_POWER_OF_TWO(width, MI_SIZE_LOG2) >> MI_SIZE_LOG2; |
634 if (calc_mi_size(new_rows) * calc_mi_size(new_cols) > cm->mi_alloc_size) { | 637 |
| 638 // Allocations in vp9_alloc_context_buffers() depend on individual |
| 639 // dimensions as well as the overall size. |
| 640 if (new_mi_cols > cm->mi_cols || new_mi_rows > cm->mi_rows) { |
635 if (vp9_alloc_context_buffers(cm, width, height)) | 641 if (vp9_alloc_context_buffers(cm, width, height)) |
636 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, | 642 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, |
637 "Failed to allocate context buffers"); | 643 "Failed to allocate context buffers"); |
638 } else { | 644 } else { |
639 vp9_set_mb_mi(cm, width, height); | 645 vp9_set_mb_mi(cm, width, height); |
640 } | 646 } |
641 vp9_init_context_buffers(cm); | 647 vp9_init_context_buffers(cm); |
642 cm->width = width; | 648 cm->width = width; |
643 cm->height = height; | 649 cm->height = height; |
644 } | 650 } |
645 } | 651 } |
646 | 652 |
647 static void setup_frame_size(VP9_COMMON *cm, struct vp9_read_bit_buffer *rb) { | 653 static void setup_frame_size(VP9_COMMON *cm, struct vp9_read_bit_buffer *rb) { |
648 int width, height; | 654 int width, height; |
649 vp9_read_frame_size(rb, &width, &height); | 655 vp9_read_frame_size(rb, &width, &height); |
650 resize_context_buffers(cm, width, height); | 656 resize_context_buffers(cm, width, height); |
651 setup_display_size(cm, rb); | 657 setup_display_size(cm, rb); |
652 | 658 |
653 if (vp9_realloc_frame_buffer( | 659 if (vp9_realloc_frame_buffer( |
654 get_frame_new_buffer(cm), cm->width, cm->height, | 660 get_frame_new_buffer(cm), cm->width, cm->height, |
655 cm->subsampling_x, cm->subsampling_y, VP9_DEC_BORDER_IN_PIXELS, | 661 cm->subsampling_x, cm->subsampling_y, |
| 662 #if CONFIG_VP9_HIGHBITDEPTH |
| 663 cm->use_highbitdepth, |
| 664 #endif |
| 665 VP9_DEC_BORDER_IN_PIXELS, |
656 &cm->frame_bufs[cm->new_fb_idx].raw_frame_buffer, cm->get_fb_cb, | 666 &cm->frame_bufs[cm->new_fb_idx].raw_frame_buffer, cm->get_fb_cb, |
657 cm->cb_priv)) { | 667 cm->cb_priv)) { |
658 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, | 668 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, |
659 "Failed to allocate frame buffer"); | 669 "Failed to allocate frame buffer"); |
660 } | 670 } |
661 } | 671 } |
662 | 672 |
663 static void setup_frame_size_with_refs(VP9_COMMON *cm, | 673 static void setup_frame_size_with_refs(VP9_COMMON *cm, |
664 struct vp9_read_bit_buffer *rb) { | 674 struct vp9_read_bit_buffer *rb) { |
665 int width, height; | 675 int width, height; |
666 int found = 0, i; | 676 int found = 0, i; |
667 int has_valid_ref_frame = 0; | 677 int has_valid_ref_frame = 0; |
668 for (i = 0; i < REFS_PER_FRAME; ++i) { | 678 for (i = 0; i < REFS_PER_FRAME; ++i) { |
669 if (vp9_rb_read_bit(rb)) { | 679 if (vp9_rb_read_bit(rb)) { |
670 YV12_BUFFER_CONFIG *const buf = cm->frame_refs[i].buf; | 680 YV12_BUFFER_CONFIG *const buf = cm->frame_refs[i].buf; |
671 width = buf->y_crop_width; | 681 width = buf->y_crop_width; |
672 height = buf->y_crop_height; | 682 height = buf->y_crop_height; |
| 683 if (buf->corrupted) { |
| 684 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, |
| 685 "Frame reference is corrupt"); |
| 686 } |
673 found = 1; | 687 found = 1; |
674 break; | 688 break; |
675 } | 689 } |
676 } | 690 } |
677 | 691 |
678 if (!found) | 692 if (!found) |
679 vp9_read_frame_size(rb, &width, &height); | 693 vp9_read_frame_size(rb, &width, &height); |
680 | 694 |
681 if (width <=0 || height <= 0) | 695 if (width <=0 || height <= 0) |
682 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, | 696 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, |
683 "Invalid frame size"); | 697 "Invalid frame size"); |
684 | 698 |
685 // Check to make sure at least one of frames that this frame references | 699 // Check to make sure at least one of frames that this frame references |
686 // has valid dimensions. | 700 // has valid dimensions. |
687 for (i = 0; i < REFS_PER_FRAME; ++i) { | 701 for (i = 0; i < REFS_PER_FRAME; ++i) { |
688 RefBuffer *const ref_frame = &cm->frame_refs[i]; | 702 RefBuffer *const ref_frame = &cm->frame_refs[i]; |
689 has_valid_ref_frame |= valid_ref_frame_size(ref_frame->buf->y_crop_width, | 703 has_valid_ref_frame |= valid_ref_frame_size(ref_frame->buf->y_crop_width, |
690 ref_frame->buf->y_crop_height, | 704 ref_frame->buf->y_crop_height, |
691 width, height); | 705 width, height); |
692 } | 706 } |
693 if (!has_valid_ref_frame) | 707 if (!has_valid_ref_frame) |
694 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, | 708 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, |
695 "Referenced frame has invalid size"); | 709 "Referenced frame has invalid size"); |
696 | 710 |
697 resize_context_buffers(cm, width, height); | 711 resize_context_buffers(cm, width, height); |
698 setup_display_size(cm, rb); | 712 setup_display_size(cm, rb); |
699 | 713 |
700 if (vp9_realloc_frame_buffer( | 714 if (vp9_realloc_frame_buffer( |
701 get_frame_new_buffer(cm), cm->width, cm->height, | 715 get_frame_new_buffer(cm), cm->width, cm->height, |
702 cm->subsampling_x, cm->subsampling_y, VP9_DEC_BORDER_IN_PIXELS, | 716 cm->subsampling_x, cm->subsampling_y, |
| 717 #if CONFIG_VP9_HIGHBITDEPTH |
| 718 cm->use_highbitdepth, |
| 719 #endif |
| 720 VP9_DEC_BORDER_IN_PIXELS, |
703 &cm->frame_bufs[cm->new_fb_idx].raw_frame_buffer, cm->get_fb_cb, | 721 &cm->frame_bufs[cm->new_fb_idx].raw_frame_buffer, cm->get_fb_cb, |
704 cm->cb_priv)) { | 722 cm->cb_priv)) { |
705 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, | 723 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, |
706 "Failed to allocate frame buffer"); | 724 "Failed to allocate frame buffer"); |
707 } | 725 } |
708 } | 726 } |
709 | 727 |
710 static void setup_tile_info(VP9_COMMON *cm, struct vp9_read_bit_buffer *rb) { | 728 static void setup_tile_info(VP9_COMMON *cm, struct vp9_read_bit_buffer *rb) { |
711 int min_log2_tile_cols, max_log2_tile_cols, max_ones; | 729 int min_log2_tile_cols, max_log2_tile_cols, max_ones; |
712 vp9_get_tile_n_bits(cm->mi_cols, &min_log2_tile_cols, &max_log2_tile_cols); | 730 vp9_get_tile_n_bits(cm->mi_cols, &min_log2_tile_cols, &max_log2_tile_cols); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 vpx_memalign(32, sizeof(LFWorkerData))); | 823 vpx_memalign(32, sizeof(LFWorkerData))); |
806 pbi->lf_worker.hook = (VP9WorkerHook)vp9_loop_filter_worker; | 824 pbi->lf_worker.hook = (VP9WorkerHook)vp9_loop_filter_worker; |
807 if (pbi->max_threads > 1 && !winterface->reset(&pbi->lf_worker)) { | 825 if (pbi->max_threads > 1 && !winterface->reset(&pbi->lf_worker)) { |
808 vpx_internal_error(&cm->error, VPX_CODEC_ERROR, | 826 vpx_internal_error(&cm->error, VPX_CODEC_ERROR, |
809 "Loop filter thread creation failed"); | 827 "Loop filter thread creation failed"); |
810 } | 828 } |
811 } | 829 } |
812 | 830 |
813 if (cm->lf.filter_level) { | 831 if (cm->lf.filter_level) { |
814 LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1; | 832 LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1; |
| 833 // Be sure to sync as we might be resuming after a failed frame decode. |
| 834 winterface->sync(&pbi->lf_worker); |
815 lf_data->frame_buffer = get_frame_new_buffer(cm); | 835 lf_data->frame_buffer = get_frame_new_buffer(cm); |
816 lf_data->cm = cm; | 836 lf_data->cm = cm; |
817 vp9_copy(lf_data->planes, pbi->mb.plane); | 837 vp9_copy(lf_data->planes, pbi->mb.plane); |
818 lf_data->stop = 0; | 838 lf_data->stop = 0; |
819 lf_data->y_only = 0; | 839 lf_data->y_only = 0; |
820 vp9_loop_filter_frame_init(cm, cm->lf.filter_level); | 840 vp9_loop_filter_frame_init(cm, cm->lf.filter_level); |
821 } | 841 } |
822 | 842 |
823 assert(tile_rows <= 4); | 843 assert(tile_rows <= 4); |
824 assert(tile_cols <= (1 << 6)); | 844 assert(tile_cols <= (1 << 6)); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 vp9_zero(tile_data->xd.left_context); | 894 vp9_zero(tile_data->xd.left_context); |
875 vp9_zero(tile_data->xd.left_seg_context); | 895 vp9_zero(tile_data->xd.left_seg_context); |
876 for (mi_col = tile.mi_col_start; mi_col < tile.mi_col_end; | 896 for (mi_col = tile.mi_col_start; mi_col < tile.mi_col_end; |
877 mi_col += MI_BLOCK_SIZE) { | 897 mi_col += MI_BLOCK_SIZE) { |
878 decode_partition(tile_data->cm, &tile_data->xd, &tile, mi_row, mi_col, | 898 decode_partition(tile_data->cm, &tile_data->xd, &tile, mi_row, mi_col, |
879 &tile_data->bit_reader, BLOCK_64X64); | 899 &tile_data->bit_reader, BLOCK_64X64); |
880 } | 900 } |
881 pbi->mb.corrupted |= tile_data->xd.corrupted; | 901 pbi->mb.corrupted |= tile_data->xd.corrupted; |
882 } | 902 } |
883 // Loopfilter one row. | 903 // Loopfilter one row. |
884 if (cm->lf.filter_level) { | 904 if (cm->lf.filter_level && !pbi->mb.corrupted) { |
885 const int lf_start = mi_row - MI_BLOCK_SIZE; | 905 const int lf_start = mi_row - MI_BLOCK_SIZE; |
886 LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1; | 906 LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1; |
887 | 907 |
888 // delay the loopfilter by 1 macroblock row. | 908 // delay the loopfilter by 1 macroblock row. |
889 if (lf_start < 0) continue; | 909 if (lf_start < 0) continue; |
890 | 910 |
891 // decoding has completed: finish up the loop filter in this thread. | 911 // decoding has completed: finish up the loop filter in this thread. |
892 if (mi_row + MI_BLOCK_SIZE >= cm->mi_rows) continue; | 912 if (mi_row + MI_BLOCK_SIZE >= cm->mi_rows) continue; |
893 | 913 |
894 winterface->sync(&pbi->lf_worker); | 914 winterface->sync(&pbi->lf_worker); |
895 lf_data->start = lf_start; | 915 lf_data->start = lf_start; |
896 lf_data->stop = mi_row; | 916 lf_data->stop = mi_row; |
897 if (pbi->max_threads > 1) { | 917 if (pbi->max_threads > 1) { |
898 winterface->launch(&pbi->lf_worker); | 918 winterface->launch(&pbi->lf_worker); |
899 } else { | 919 } else { |
900 winterface->execute(&pbi->lf_worker); | 920 winterface->execute(&pbi->lf_worker); |
901 } | 921 } |
902 } | 922 } |
903 } | 923 } |
904 } | 924 } |
905 | 925 |
906 // Loopfilter remaining rows in the frame. | 926 // Loopfilter remaining rows in the frame. |
907 if (cm->lf.filter_level) { | 927 if (cm->lf.filter_level && !pbi->mb.corrupted) { |
908 LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1; | 928 LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1; |
909 winterface->sync(&pbi->lf_worker); | 929 winterface->sync(&pbi->lf_worker); |
910 lf_data->start = lf_data->stop; | 930 lf_data->start = lf_data->stop; |
911 lf_data->stop = cm->mi_rows; | 931 lf_data->stop = cm->mi_rows; |
912 winterface->execute(&pbi->lf_worker); | 932 winterface->execute(&pbi->lf_worker); |
913 } | 933 } |
914 | 934 |
915 // Get last tile data. | 935 // Get last tile data. |
916 tile_data = pbi->tile_data + tile_cols * tile_rows - 1; | 936 tile_data = pbi->tile_data + tile_cols * tile_rows - 1; |
917 | 937 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
986 CHECK_MEM_ERROR(cm, worker->data2, vpx_malloc(sizeof(TileInfo))); | 1006 CHECK_MEM_ERROR(cm, worker->data2, vpx_malloc(sizeof(TileInfo))); |
987 if (i < num_threads - 1 && !winterface->reset(worker)) { | 1007 if (i < num_threads - 1 && !winterface->reset(worker)) { |
988 vpx_internal_error(&cm->error, VPX_CODEC_ERROR, | 1008 vpx_internal_error(&cm->error, VPX_CODEC_ERROR, |
989 "Tile decoder thread creation failed"); | 1009 "Tile decoder thread creation failed"); |
990 } | 1010 } |
991 } | 1011 } |
992 } | 1012 } |
993 | 1013 |
994 // Reset tile decoding hook | 1014 // Reset tile decoding hook |
995 for (n = 0; n < num_workers; ++n) { | 1015 for (n = 0; n < num_workers; ++n) { |
| 1016 winterface->sync(&pbi->tile_workers[n]); |
996 pbi->tile_workers[n].hook = (VP9WorkerHook)tile_worker_hook; | 1017 pbi->tile_workers[n].hook = (VP9WorkerHook)tile_worker_hook; |
997 } | 1018 } |
998 | 1019 |
999 // Note: this memset assumes above_context[0], [1] and [2] | 1020 // Note: this memset assumes above_context[0], [1] and [2] |
1000 // are allocated as part of the same buffer. | 1021 // are allocated as part of the same buffer. |
1001 vpx_memset(cm->above_context, 0, | 1022 vpx_memset(cm->above_context, 0, |
1002 sizeof(*cm->above_context) * MAX_MB_PLANE * 2 * aligned_mi_cols); | 1023 sizeof(*cm->above_context) * MAX_MB_PLANE * 2 * aligned_mi_cols); |
1003 vpx_memset(cm->above_seg_context, 0, | 1024 vpx_memset(cm->above_seg_context, 0, |
1004 sizeof(*cm->above_seg_context) * aligned_mi_cols); | 1025 sizeof(*cm->above_seg_context) * aligned_mi_cols); |
1005 | 1026 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1089 int profile = vp9_rb_read_bit(rb); | 1110 int profile = vp9_rb_read_bit(rb); |
1090 profile |= vp9_rb_read_bit(rb) << 1; | 1111 profile |= vp9_rb_read_bit(rb) << 1; |
1091 if (profile > 2) | 1112 if (profile > 2) |
1092 profile += vp9_rb_read_bit(rb); | 1113 profile += vp9_rb_read_bit(rb); |
1093 return (BITSTREAM_PROFILE) profile; | 1114 return (BITSTREAM_PROFILE) profile; |
1094 } | 1115 } |
1095 | 1116 |
1096 static void read_bitdepth_colorspace_sampling( | 1117 static void read_bitdepth_colorspace_sampling( |
1097 VP9_COMMON *cm, struct vp9_read_bit_buffer *rb) { | 1118 VP9_COMMON *cm, struct vp9_read_bit_buffer *rb) { |
1098 if (cm->profile >= PROFILE_2) | 1119 if (cm->profile >= PROFILE_2) |
1099 cm->bit_depth = vp9_rb_read_bit(rb) ? BITS_12 : BITS_10; | 1120 cm->bit_depth = vp9_rb_read_bit(rb) ? VPX_BITS_12 : VPX_BITS_10; |
1100 cm->color_space = (COLOR_SPACE)vp9_rb_read_literal(rb, 3); | 1121 cm->color_space = (COLOR_SPACE)vp9_rb_read_literal(rb, 3); |
1101 if (cm->color_space != SRGB) { | 1122 if (cm->color_space != SRGB) { |
1102 vp9_rb_read_bit(rb); // [16,235] (including xvycc) vs [0,255] range | 1123 vp9_rb_read_bit(rb); // [16,235] (including xvycc) vs [0,255] range |
1103 if (cm->profile == PROFILE_1 || cm->profile == PROFILE_3) { | 1124 if (cm->profile == PROFILE_1 || cm->profile == PROFILE_3) { |
1104 cm->subsampling_x = vp9_rb_read_bit(rb); | 1125 cm->subsampling_x = vp9_rb_read_bit(rb); |
1105 cm->subsampling_y = vp9_rb_read_bit(rb); | 1126 cm->subsampling_y = vp9_rb_read_bit(rb); |
1106 if (cm->subsampling_x == 1 && cm->subsampling_y == 1) | 1127 if (cm->subsampling_x == 1 && cm->subsampling_y == 1) |
1107 vpx_internal_error(&cm->error, VPX_CODEC_UNSUP_BITSTREAM, | 1128 vpx_internal_error(&cm->error, VPX_CODEC_UNSUP_BITSTREAM, |
1108 "4:2:0 color not supported in profile 1 or 3"); | 1129 "4:2:0 color not supported in profile 1 or 3"); |
1109 if (vp9_rb_read_bit(rb)) | 1130 if (vp9_rb_read_bit(rb)) |
(...skipping 23 matching lines...) Expand all Loading... |
1133 size_t sz; | 1154 size_t sz; |
1134 int i; | 1155 int i; |
1135 | 1156 |
1136 cm->last_frame_type = cm->frame_type; | 1157 cm->last_frame_type = cm->frame_type; |
1137 | 1158 |
1138 if (vp9_rb_read_literal(rb, 2) != VP9_FRAME_MARKER) | 1159 if (vp9_rb_read_literal(rb, 2) != VP9_FRAME_MARKER) |
1139 vpx_internal_error(&cm->error, VPX_CODEC_UNSUP_BITSTREAM, | 1160 vpx_internal_error(&cm->error, VPX_CODEC_UNSUP_BITSTREAM, |
1140 "Invalid frame marker"); | 1161 "Invalid frame marker"); |
1141 | 1162 |
1142 cm->profile = vp9_read_profile(rb); | 1163 cm->profile = vp9_read_profile(rb); |
| 1164 |
1143 if (cm->profile >= MAX_PROFILES) | 1165 if (cm->profile >= MAX_PROFILES) |
1144 vpx_internal_error(&cm->error, VPX_CODEC_UNSUP_BITSTREAM, | 1166 vpx_internal_error(&cm->error, VPX_CODEC_UNSUP_BITSTREAM, |
1145 "Unsupported bitstream profile"); | 1167 "Unsupported bitstream profile"); |
1146 | 1168 |
1147 cm->show_existing_frame = vp9_rb_read_bit(rb); | 1169 cm->show_existing_frame = vp9_rb_read_bit(rb); |
1148 if (cm->show_existing_frame) { | 1170 if (cm->show_existing_frame) { |
1149 // Show an existing frame directly. | 1171 // Show an existing frame directly. |
1150 const int frame_to_show = cm->ref_frame_map[vp9_rb_read_literal(rb, 3)]; | 1172 const int frame_to_show = cm->ref_frame_map[vp9_rb_read_literal(rb, 3)]; |
1151 | 1173 |
1152 if (frame_to_show < 0 || cm->frame_bufs[frame_to_show].ref_count < 1) | 1174 if (frame_to_show < 0 || cm->frame_bufs[frame_to_show].ref_count < 1) |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1391 uint8_t clear_data[MAX_VP9_HEADER_SIZE]; | 1413 uint8_t clear_data[MAX_VP9_HEADER_SIZE]; |
1392 const size_t first_partition_size = read_uncompressed_header(pbi, | 1414 const size_t first_partition_size = read_uncompressed_header(pbi, |
1393 init_read_bit_buffer(pbi, &rb, data, data_end, clear_data)); | 1415 init_read_bit_buffer(pbi, &rb, data, data_end, clear_data)); |
1394 const int tile_rows = 1 << cm->log2_tile_rows; | 1416 const int tile_rows = 1 << cm->log2_tile_rows; |
1395 const int tile_cols = 1 << cm->log2_tile_cols; | 1417 const int tile_cols = 1 << cm->log2_tile_cols; |
1396 YV12_BUFFER_CONFIG *const new_fb = get_frame_new_buffer(cm); | 1418 YV12_BUFFER_CONFIG *const new_fb = get_frame_new_buffer(cm); |
1397 xd->cur_buf = new_fb; | 1419 xd->cur_buf = new_fb; |
1398 | 1420 |
1399 if (!first_partition_size) { | 1421 if (!first_partition_size) { |
1400 // showing a frame directly | 1422 // showing a frame directly |
1401 *p_data_end = data + 1; | 1423 *p_data_end = data + (cm->profile <= PROFILE_2 ? 1 : 2); |
1402 return; | 1424 return; |
1403 } | 1425 } |
1404 | 1426 |
1405 data += vp9_rb_bytes_read(&rb); | 1427 data += vp9_rb_bytes_read(&rb); |
1406 if (!read_is_valid(data, first_partition_size, data_end)) | 1428 if (!read_is_valid(data, first_partition_size, data_end)) |
1407 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, | 1429 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, |
1408 "Truncated packet or corrupt header length"); | 1430 "Truncated packet or corrupt header length"); |
1409 | 1431 |
1410 init_macroblockd(cm, &pbi->mb); | 1432 init_macroblockd(cm, &pbi->mb); |
1411 | 1433 |
(...skipping 10 matching lines...) Expand all Loading... |
1422 vp9_zero(xd->dqcoeff); | 1444 vp9_zero(xd->dqcoeff); |
1423 | 1445 |
1424 xd->corrupted = 0; | 1446 xd->corrupted = 0; |
1425 new_fb->corrupted = read_compressed_header(pbi, data, first_partition_size); | 1447 new_fb->corrupted = read_compressed_header(pbi, data, first_partition_size); |
1426 | 1448 |
1427 // TODO(jzern): remove frame_parallel_decoding_mode restriction for | 1449 // TODO(jzern): remove frame_parallel_decoding_mode restriction for |
1428 // single-frame tile decoding. | 1450 // single-frame tile decoding. |
1429 if (pbi->max_threads > 1 && tile_rows == 1 && tile_cols > 1 && | 1451 if (pbi->max_threads > 1 && tile_rows == 1 && tile_cols > 1 && |
1430 cm->frame_parallel_decoding_mode) { | 1452 cm->frame_parallel_decoding_mode) { |
1431 *p_data_end = decode_tiles_mt(pbi, data + first_partition_size, data_end); | 1453 *p_data_end = decode_tiles_mt(pbi, data + first_partition_size, data_end); |
1432 // If multiple threads are used to decode tiles, then we use those threads | 1454 if (!xd->corrupted) { |
1433 // to do parallel loopfiltering. | 1455 // If multiple threads are used to decode tiles, then we use those threads |
1434 vp9_loop_filter_frame_mt(new_fb, pbi, cm, cm->lf.filter_level, 0); | 1456 // to do parallel loopfiltering. |
| 1457 vp9_loop_filter_frame_mt(new_fb, pbi, cm, cm->lf.filter_level, 0); |
| 1458 } |
1435 } else { | 1459 } else { |
1436 *p_data_end = decode_tiles(pbi, data + first_partition_size, data_end); | 1460 *p_data_end = decode_tiles(pbi, data + first_partition_size, data_end); |
1437 } | 1461 } |
1438 | 1462 |
1439 new_fb->corrupted |= xd->corrupted; | 1463 new_fb->corrupted |= xd->corrupted; |
1440 | 1464 |
1441 if (!new_fb->corrupted) { | 1465 if (!new_fb->corrupted) { |
1442 if (!cm->error_resilient_mode && !cm->frame_parallel_decoding_mode) { | 1466 if (!cm->error_resilient_mode && !cm->frame_parallel_decoding_mode) { |
1443 vp9_adapt_coef_probs(cm); | 1467 vp9_adapt_coef_probs(cm); |
1444 | 1468 |
1445 if (!frame_is_intra_only(cm)) { | 1469 if (!frame_is_intra_only(cm)) { |
1446 vp9_adapt_mode_probs(cm); | 1470 vp9_adapt_mode_probs(cm); |
1447 vp9_adapt_mv_probs(cm, cm->allow_high_precision_mv); | 1471 vp9_adapt_mv_probs(cm, cm->allow_high_precision_mv); |
1448 } | 1472 } |
1449 } else { | 1473 } else { |
1450 debug_check_frame_counts(cm); | 1474 debug_check_frame_counts(cm); |
1451 } | 1475 } |
1452 } else { | 1476 } else { |
1453 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, | 1477 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, |
1454 "Decode failed. Frame data is corrupted."); | 1478 "Decode failed. Frame data is corrupted."); |
1455 } | 1479 } |
1456 | 1480 |
1457 if (cm->refresh_frame_context) | 1481 if (cm->refresh_frame_context) |
1458 cm->frame_contexts[cm->frame_context_idx] = cm->fc; | 1482 cm->frame_contexts[cm->frame_context_idx] = cm->fc; |
1459 } | 1483 } |
OLD | NEW |