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 18 matching lines...) Expand all Loading... |
29 #include "vp9/common/vp9_reconinter.h" | 29 #include "vp9/common/vp9_reconinter.h" |
30 #include "vp9/common/vp9_seg_common.h" | 30 #include "vp9/common/vp9_seg_common.h" |
31 #include "vp9/common/vp9_thread.h" | 31 #include "vp9/common/vp9_thread.h" |
32 #include "vp9/common/vp9_tile_common.h" | 32 #include "vp9/common/vp9_tile_common.h" |
33 | 33 |
34 #include "vp9/decoder/vp9_decodeframe.h" | 34 #include "vp9/decoder/vp9_decodeframe.h" |
35 #include "vp9/decoder/vp9_detokenize.h" | 35 #include "vp9/decoder/vp9_detokenize.h" |
36 #include "vp9/decoder/vp9_decodemv.h" | 36 #include "vp9/decoder/vp9_decodemv.h" |
37 #include "vp9/decoder/vp9_decoder.h" | 37 #include "vp9/decoder/vp9_decoder.h" |
38 #include "vp9/decoder/vp9_dsubexp.h" | 38 #include "vp9/decoder/vp9_dsubexp.h" |
39 #include "vp9/decoder/vp9_dthread.h" | |
40 #include "vp9/decoder/vp9_read_bit_buffer.h" | 39 #include "vp9/decoder/vp9_read_bit_buffer.h" |
41 #include "vp9/decoder/vp9_reader.h" | 40 #include "vp9/decoder/vp9_reader.h" |
42 | 41 |
43 #define MAX_VP9_HEADER_SIZE 80 | 42 #define MAX_VP9_HEADER_SIZE 80 |
44 | 43 |
45 static int is_compound_reference_allowed(const VP9_COMMON *cm) { | 44 static int is_compound_reference_allowed(const VP9_COMMON *cm) { |
46 int i; | 45 int i; |
47 for (i = 1; i < REFS_PER_FRAME; ++i) | 46 for (i = 1; i < REFS_PER_FRAME; ++i) |
48 if (cm->ref_frame_sign_bias[i + 1] != cm->ref_frame_sign_bias[1]) | 47 if (cm->ref_frame_sign_bias[i + 1] != cm->ref_frame_sign_bias[1]) |
49 return 1; | 48 return 1; |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 #endif | 719 #endif |
721 VP9_DEC_BORDER_IN_PIXELS, | 720 VP9_DEC_BORDER_IN_PIXELS, |
722 cm->byte_alignment, | 721 cm->byte_alignment, |
723 &cm->frame_bufs[cm->new_fb_idx].raw_frame_buffer, cm->get_fb_cb, | 722 &cm->frame_bufs[cm->new_fb_idx].raw_frame_buffer, cm->get_fb_cb, |
724 cm->cb_priv)) { | 723 cm->cb_priv)) { |
725 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, | 724 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, |
726 "Failed to allocate frame buffer"); | 725 "Failed to allocate frame buffer"); |
727 } | 726 } |
728 cm->frame_bufs[cm->new_fb_idx].buf.subsampling_x = cm->subsampling_x; | 727 cm->frame_bufs[cm->new_fb_idx].buf.subsampling_x = cm->subsampling_x; |
729 cm->frame_bufs[cm->new_fb_idx].buf.subsampling_y = cm->subsampling_y; | 728 cm->frame_bufs[cm->new_fb_idx].buf.subsampling_y = cm->subsampling_y; |
| 729 cm->frame_bufs[cm->new_fb_idx].buf.color_space = |
| 730 (vpx_color_space_t)cm->color_space; |
730 cm->frame_bufs[cm->new_fb_idx].buf.bit_depth = (unsigned int)cm->bit_depth; | 731 cm->frame_bufs[cm->new_fb_idx].buf.bit_depth = (unsigned int)cm->bit_depth; |
731 } | 732 } |
732 | 733 |
733 static INLINE int valid_ref_frame_img_fmt(vpx_bit_depth_t ref_bit_depth, | 734 static INLINE int valid_ref_frame_img_fmt(vpx_bit_depth_t ref_bit_depth, |
734 int ref_xss, int ref_yss, | 735 int ref_xss, int ref_yss, |
735 vpx_bit_depth_t this_bit_depth, | 736 vpx_bit_depth_t this_bit_depth, |
736 int this_xss, int this_yss) { | 737 int this_xss, int this_yss) { |
737 return ref_bit_depth == this_bit_depth && ref_xss == this_xss && | 738 return ref_bit_depth == this_bit_depth && ref_xss == this_xss && |
738 ref_yss == this_yss; | 739 ref_yss == this_yss; |
739 } | 740 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 for (i = 0; i < REFS_PER_FRAME; ++i) { | 775 for (i = 0; i < REFS_PER_FRAME; ++i) { |
775 RefBuffer *const ref_frame = &cm->frame_refs[i]; | 776 RefBuffer *const ref_frame = &cm->frame_refs[i]; |
776 if (!valid_ref_frame_img_fmt( | 777 if (!valid_ref_frame_img_fmt( |
777 ref_frame->buf->bit_depth, | 778 ref_frame->buf->bit_depth, |
778 ref_frame->buf->subsampling_x, | 779 ref_frame->buf->subsampling_x, |
779 ref_frame->buf->subsampling_y, | 780 ref_frame->buf->subsampling_y, |
780 cm->bit_depth, | 781 cm->bit_depth, |
781 cm->subsampling_x, | 782 cm->subsampling_x, |
782 cm->subsampling_y)) | 783 cm->subsampling_y)) |
783 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, | 784 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, |
784 "Referenced frame has incompatible color space"); | 785 "Referenced frame has incompatible color format"); |
785 } | 786 } |
786 | 787 |
787 resize_context_buffers(cm, width, height); | 788 resize_context_buffers(cm, width, height); |
788 setup_display_size(cm, rb); | 789 setup_display_size(cm, rb); |
789 | 790 |
790 if (vp9_realloc_frame_buffer( | 791 if (vp9_realloc_frame_buffer( |
791 get_frame_new_buffer(cm), cm->width, cm->height, | 792 get_frame_new_buffer(cm), cm->width, cm->height, |
792 cm->subsampling_x, cm->subsampling_y, | 793 cm->subsampling_x, cm->subsampling_y, |
793 #if CONFIG_VP9_HIGHBITDEPTH | 794 #if CONFIG_VP9_HIGHBITDEPTH |
794 cm->use_highbitdepth, | 795 cm->use_highbitdepth, |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1218 cm->bit_depth = vp9_rb_read_bit(rb) ? VPX_BITS_12 : VPX_BITS_10; | 1219 cm->bit_depth = vp9_rb_read_bit(rb) ? VPX_BITS_12 : VPX_BITS_10; |
1219 #if CONFIG_VP9_HIGHBITDEPTH | 1220 #if CONFIG_VP9_HIGHBITDEPTH |
1220 cm->use_highbitdepth = 1; | 1221 cm->use_highbitdepth = 1; |
1221 #endif | 1222 #endif |
1222 } else { | 1223 } else { |
1223 cm->bit_depth = VPX_BITS_8; | 1224 cm->bit_depth = VPX_BITS_8; |
1224 #if CONFIG_VP9_HIGHBITDEPTH | 1225 #if CONFIG_VP9_HIGHBITDEPTH |
1225 cm->use_highbitdepth = 0; | 1226 cm->use_highbitdepth = 0; |
1226 #endif | 1227 #endif |
1227 } | 1228 } |
1228 cm->color_space = (COLOR_SPACE)vp9_rb_read_literal(rb, 3); | 1229 cm->color_space = vp9_rb_read_literal(rb, 3); |
1229 if (cm->color_space != SRGB) { | 1230 if (cm->color_space != VPX_CS_SRGB) { |
1230 vp9_rb_read_bit(rb); // [16,235] (including xvycc) vs [0,255] range | 1231 vp9_rb_read_bit(rb); // [16,235] (including xvycc) vs [0,255] range |
1231 if (cm->profile == PROFILE_1 || cm->profile == PROFILE_3) { | 1232 if (cm->profile == PROFILE_1 || cm->profile == PROFILE_3) { |
1232 cm->subsampling_x = vp9_rb_read_bit(rb); | 1233 cm->subsampling_x = vp9_rb_read_bit(rb); |
1233 cm->subsampling_y = vp9_rb_read_bit(rb); | 1234 cm->subsampling_y = vp9_rb_read_bit(rb); |
1234 if (cm->subsampling_x == 1 && cm->subsampling_y == 1) | 1235 if (cm->subsampling_x == 1 && cm->subsampling_y == 1) |
1235 vpx_internal_error(&cm->error, VPX_CODEC_UNSUP_BITSTREAM, | 1236 vpx_internal_error(&cm->error, VPX_CODEC_UNSUP_BITSTREAM, |
1236 "4:2:0 color not supported in profile 1 or 3"); | 1237 "4:2:0 color not supported in profile 1 or 3"); |
1237 if (vp9_rb_read_bit(rb)) | 1238 if (vp9_rb_read_bit(rb)) |
1238 vpx_internal_error(&cm->error, VPX_CODEC_UNSUP_BITSTREAM, | 1239 vpx_internal_error(&cm->error, VPX_CODEC_UNSUP_BITSTREAM, |
1239 "Reserved bit set"); | 1240 "Reserved bit set"); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1317 | 1318 |
1318 if (cm->intra_only) { | 1319 if (cm->intra_only) { |
1319 if (!vp9_read_sync_code(rb)) | 1320 if (!vp9_read_sync_code(rb)) |
1320 vpx_internal_error(&cm->error, VPX_CODEC_UNSUP_BITSTREAM, | 1321 vpx_internal_error(&cm->error, VPX_CODEC_UNSUP_BITSTREAM, |
1321 "Invalid frame sync code"); | 1322 "Invalid frame sync code"); |
1322 if (cm->profile > PROFILE_0) { | 1323 if (cm->profile > PROFILE_0) { |
1323 read_bitdepth_colorspace_sampling(cm, rb); | 1324 read_bitdepth_colorspace_sampling(cm, rb); |
1324 } else { | 1325 } else { |
1325 // NOTE: The intra-only frame header does not include the specification | 1326 // NOTE: The intra-only frame header does not include the specification |
1326 // of either the color format or color sub-sampling in profile 0. VP9 | 1327 // of either the color format or color sub-sampling in profile 0. VP9 |
1327 // specifies that the default color space should be YUV 4:2:0 in this | 1328 // specifies that the default color format should be YUV 4:2:0 in this |
1328 // case (normative). | 1329 // case (normative). |
1329 cm->color_space = BT_601; | 1330 cm->color_space = VPX_CS_BT_601; |
1330 cm->subsampling_y = cm->subsampling_x = 1; | 1331 cm->subsampling_y = cm->subsampling_x = 1; |
1331 cm->bit_depth = VPX_BITS_8; | 1332 cm->bit_depth = VPX_BITS_8; |
1332 #if CONFIG_VP9_HIGHBITDEPTH | 1333 #if CONFIG_VP9_HIGHBITDEPTH |
1333 cm->use_highbitdepth = 0; | 1334 cm->use_highbitdepth = 0; |
1334 #endif | 1335 #endif |
1335 } | 1336 } |
1336 | 1337 |
1337 pbi->refresh_frame_flags = vp9_rb_read_literal(rb, REF_FRAMES); | 1338 pbi->refresh_frame_flags = vp9_rb_read_literal(rb, REF_FRAMES); |
1338 setup_frame_size(cm, rb); | 1339 setup_frame_size(cm, rb); |
1339 pbi->need_resync = 0; | 1340 pbi->need_resync = 0; |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1582 "Decode failed. Frame data header is corrupted."); | 1583 "Decode failed. Frame data header is corrupted."); |
1583 | 1584 |
1584 // TODO(jzern): remove frame_parallel_decoding_mode restriction for | 1585 // TODO(jzern): remove frame_parallel_decoding_mode restriction for |
1585 // single-frame tile decoding. | 1586 // single-frame tile decoding. |
1586 if (pbi->max_threads > 1 && tile_rows == 1 && tile_cols > 1 && | 1587 if (pbi->max_threads > 1 && tile_rows == 1 && tile_cols > 1 && |
1587 cm->frame_parallel_decoding_mode) { | 1588 cm->frame_parallel_decoding_mode) { |
1588 *p_data_end = decode_tiles_mt(pbi, data + first_partition_size, data_end); | 1589 *p_data_end = decode_tiles_mt(pbi, data + first_partition_size, data_end); |
1589 if (!xd->corrupted) { | 1590 if (!xd->corrupted) { |
1590 // If multiple threads are used to decode tiles, then we use those threads | 1591 // If multiple threads are used to decode tiles, then we use those threads |
1591 // to do parallel loopfiltering. | 1592 // to do parallel loopfiltering. |
1592 vp9_loop_filter_frame_mt(&pbi->lf_row_sync, new_fb, pbi->mb.plane, cm, | 1593 vp9_loop_filter_frame_mt(new_fb, cm, pbi->mb.plane, cm->lf.filter_level, |
1593 pbi->tile_workers, pbi->num_tile_workers, | 1594 0, 0, pbi->tile_workers, pbi->num_tile_workers, |
1594 cm->lf.filter_level, 0); | 1595 &pbi->lf_row_sync); |
1595 } else { | 1596 } else { |
1596 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, | 1597 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, |
1597 "Decode failed. Frame data is corrupted."); | 1598 "Decode failed. Frame data is corrupted."); |
1598 | 1599 |
1599 } | 1600 } |
1600 } else { | 1601 } else { |
1601 *p_data_end = decode_tiles(pbi, data + first_partition_size, data_end); | 1602 *p_data_end = decode_tiles(pbi, data + first_partition_size, data_end); |
1602 } | 1603 } |
1603 | 1604 |
1604 new_fb->corrupted |= xd->corrupted; | 1605 new_fb->corrupted |= xd->corrupted; |
(...skipping 10 matching lines...) Expand all Loading... |
1615 debug_check_frame_counts(cm); | 1616 debug_check_frame_counts(cm); |
1616 } | 1617 } |
1617 } else { | 1618 } else { |
1618 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, | 1619 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, |
1619 "Decode failed. Frame data is corrupted."); | 1620 "Decode failed. Frame data is corrupted."); |
1620 } | 1621 } |
1621 | 1622 |
1622 if (cm->refresh_frame_context) | 1623 if (cm->refresh_frame_context) |
1623 cm->frame_contexts[cm->frame_context_idx] = *cm->fc; | 1624 cm->frame_contexts[cm->frame_context_idx] = *cm->fc; |
1624 } | 1625 } |
OLD | NEW |