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 15 matching lines...) Expand all Loading... |
26 #include "vp9/common/vp9_quant_common.h" | 26 #include "vp9/common/vp9_quant_common.h" |
27 #include "vp9/common/vp9_reconintra.h" | 27 #include "vp9/common/vp9_reconintra.h" |
28 #include "vp9/common/vp9_reconinter.h" | 28 #include "vp9/common/vp9_reconinter.h" |
29 #include "vp9/common/vp9_seg_common.h" | 29 #include "vp9/common/vp9_seg_common.h" |
30 #include "vp9/common/vp9_tile_common.h" | 30 #include "vp9/common/vp9_tile_common.h" |
31 | 31 |
32 #include "vp9/decoder/vp9_decodeframe.h" | 32 #include "vp9/decoder/vp9_decodeframe.h" |
33 #include "vp9/decoder/vp9_detokenize.h" | 33 #include "vp9/decoder/vp9_detokenize.h" |
34 #include "vp9/decoder/vp9_decodemv.h" | 34 #include "vp9/decoder/vp9_decodemv.h" |
35 #include "vp9/decoder/vp9_dsubexp.h" | 35 #include "vp9/decoder/vp9_dsubexp.h" |
| 36 #include "vp9/decoder/vp9_dthread.h" |
36 #include "vp9/decoder/vp9_onyxd_int.h" | 37 #include "vp9/decoder/vp9_onyxd_int.h" |
37 #include "vp9/decoder/vp9_read_bit_buffer.h" | 38 #include "vp9/decoder/vp9_read_bit_buffer.h" |
38 #include "vp9/decoder/vp9_reader.h" | 39 #include "vp9/decoder/vp9_reader.h" |
39 #include "vp9/decoder/vp9_thread.h" | 40 #include "vp9/decoder/vp9_thread.h" |
40 | 41 |
41 typedef struct TileWorkerData { | |
42 VP9_COMMON *cm; | |
43 vp9_reader bit_reader; | |
44 DECLARE_ALIGNED(16, MACROBLOCKD, xd); | |
45 DECLARE_ALIGNED(16, int16_t, dqcoeff[MAX_MB_PLANE][64 * 64]); | |
46 } TileWorkerData; | |
47 | |
48 static int read_be32(const uint8_t *p) { | 42 static int read_be32(const uint8_t *p) { |
49 return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]; | 43 return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]; |
50 } | 44 } |
51 | 45 |
52 static int is_compound_reference_allowed(const VP9_COMMON *cm) { | 46 static int is_compound_reference_allowed(const VP9_COMMON *cm) { |
53 int i; | 47 int i; |
54 for (i = 1; i < REFS_PER_FRAME; ++i) | 48 for (i = 1; i < REFS_PER_FRAME; ++i) |
55 if (cm->ref_frame_sign_bias[i + 1] != cm->ref_frame_sign_bias[1]) | 49 if (cm->ref_frame_sign_bias[i + 1] != cm->ref_frame_sign_bias[1]) |
56 return 1; | 50 return 1; |
57 | 51 |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 int x, y; | 296 int x, y; |
303 uint8_t *dst; | 297 uint8_t *dst; |
304 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &x, &y); | 298 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &x, &y); |
305 dst = &pd->dst.buf[4 * y * pd->dst.stride + 4 * x]; | 299 dst = &pd->dst.buf[4 * y * pd->dst.stride + 4 * x]; |
306 | 300 |
307 vp9_predict_intra_block(xd, block >> (tx_size << 1), | 301 vp9_predict_intra_block(xd, block >> (tx_size << 1), |
308 b_width_log2(plane_bsize), tx_size, mode, | 302 b_width_log2(plane_bsize), tx_size, mode, |
309 dst, pd->dst.stride, dst, pd->dst.stride, | 303 dst, pd->dst.stride, dst, pd->dst.stride, |
310 x, y, plane); | 304 x, y, plane); |
311 | 305 |
312 if (!mi->mbmi.skip_coeff) { | 306 if (!mi->mbmi.skip) { |
313 const int eob = vp9_decode_block_tokens(cm, xd, plane, block, | 307 const int eob = vp9_decode_block_tokens(cm, xd, plane, block, |
314 plane_bsize, x, y, tx_size, | 308 plane_bsize, x, y, tx_size, |
315 args->r); | 309 args->r); |
316 inverse_transform_block(xd, plane, block, tx_size, dst, pd->dst.stride, | 310 inverse_transform_block(xd, plane, block, tx_size, dst, pd->dst.stride, |
317 eob); | 311 eob); |
318 } | 312 } |
319 } | 313 } |
320 | 314 |
321 struct inter_args { | 315 struct inter_args { |
322 VP9_COMMON *cm; | 316 VP9_COMMON *cm; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 | 390 |
397 set_offsets(cm, xd, tile, bsize, mi_row, mi_col); | 391 set_offsets(cm, xd, tile, bsize, mi_row, mi_col); |
398 vp9_read_mode_info(cm, xd, tile, mi_row, mi_col, r); | 392 vp9_read_mode_info(cm, xd, tile, mi_row, mi_col, r); |
399 | 393 |
400 if (less8x8) | 394 if (less8x8) |
401 bsize = BLOCK_8X8; | 395 bsize = BLOCK_8X8; |
402 | 396 |
403 // Has to be called after set_offsets | 397 // Has to be called after set_offsets |
404 mbmi = &xd->mi_8x8[0]->mbmi; | 398 mbmi = &xd->mi_8x8[0]->mbmi; |
405 | 399 |
406 if (mbmi->skip_coeff) { | 400 if (mbmi->skip) { |
407 reset_skip_context(xd, bsize); | 401 reset_skip_context(xd, bsize); |
408 } else { | 402 } else { |
409 if (cm->seg.enabled) | 403 if (cm->seg.enabled) |
410 setup_plane_dequants(cm, xd, vp9_get_qindex(&cm->seg, mbmi->segment_id, | 404 setup_plane_dequants(cm, xd, vp9_get_qindex(&cm->seg, mbmi->segment_id, |
411 cm->base_qindex)); | 405 cm->base_qindex)); |
412 } | 406 } |
413 | 407 |
414 if (!is_inter_block(mbmi)) { | 408 if (!is_inter_block(mbmi)) { |
415 struct intra_args arg = { cm, xd, r }; | 409 struct intra_args arg = { cm, xd, r }; |
416 foreach_transformed_block(xd, bsize, predict_and_reconstruct_intra_block, | 410 vp9_foreach_transformed_block(xd, bsize, |
417 &arg); | 411 predict_and_reconstruct_intra_block, &arg); |
418 } else { | 412 } else { |
419 // Setup | 413 // Setup |
420 set_ref(cm, xd, 0, mi_row, mi_col); | 414 set_ref(cm, xd, 0, mi_row, mi_col); |
421 if (has_second_ref(mbmi)) | 415 if (has_second_ref(mbmi)) |
422 set_ref(cm, xd, 1, mi_row, mi_col); | 416 set_ref(cm, xd, 1, mi_row, mi_col); |
423 | 417 |
424 xd->interp_kernel = vp9_get_interp_kernel(mbmi->interp_filter); | 418 xd->interp_kernel = vp9_get_interp_kernel(mbmi->interp_filter); |
425 | 419 |
426 // Prediction | 420 // Prediction |
427 vp9_dec_build_inter_predictors_sb(xd, mi_row, mi_col, bsize); | 421 vp9_dec_build_inter_predictors_sb(xd, mi_row, mi_col, bsize); |
428 | 422 |
429 // Reconstruction | 423 // Reconstruction |
430 if (!mbmi->skip_coeff) { | 424 if (!mbmi->skip) { |
431 int eobtotal = 0; | 425 int eobtotal = 0; |
432 struct inter_args arg = { cm, xd, r, &eobtotal }; | 426 struct inter_args arg = { cm, xd, r, &eobtotal }; |
433 foreach_transformed_block(xd, bsize, reconstruct_inter_block, &arg); | 427 vp9_foreach_transformed_block(xd, bsize, reconstruct_inter_block, &arg); |
434 if (!less8x8 && eobtotal == 0) | 428 if (!less8x8 && eobtotal == 0) |
435 mbmi->skip_coeff = 1; // skip loopfilter | 429 mbmi->skip = 1; // skip loopfilter |
436 } | 430 } |
437 } | 431 } |
438 | 432 |
439 xd->corrupted |= vp9_reader_has_error(r); | 433 xd->corrupted |= vp9_reader_has_error(r); |
440 } | 434 } |
441 | 435 |
442 static PARTITION_TYPE read_partition(VP9_COMMON *cm, MACROBLOCKD *xd, int hbs, | 436 static PARTITION_TYPE read_partition(VP9_COMMON *cm, MACROBLOCKD *xd, int hbs, |
443 int mi_row, int mi_col, BLOCK_SIZE bsize, | 437 int mi_row, int mi_col, BLOCK_SIZE bsize, |
444 vp9_reader *r) { | 438 vp9_reader *r) { |
445 const int ctx = partition_plane_context(xd->above_seg_context, | 439 const int ctx = partition_plane_context(xd->above_seg_context, |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, | 684 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, |
691 "Failed to allocate frame buffers"); | 685 "Failed to allocate frame buffers"); |
692 } | 686 } |
693 | 687 |
694 cm->width = width; | 688 cm->width = width; |
695 cm->height = height; | 689 cm->height = height; |
696 | 690 |
697 vp9_update_frame_size(cm); | 691 vp9_update_frame_size(cm); |
698 } | 692 } |
699 | 693 |
700 vp9_realloc_frame_buffer(get_frame_new_buffer(cm), cm->width, cm->height, | 694 if (vp9_realloc_frame_buffer( |
701 cm->subsampling_x, cm->subsampling_y, | 695 get_frame_new_buffer(cm), cm->width, cm->height, |
702 VP9_DEC_BORDER_IN_PIXELS); | 696 cm->subsampling_x, cm->subsampling_y, VP9_DEC_BORDER_IN_PIXELS, |
| 697 &cm->frame_bufs[cm->new_fb_idx].raw_frame_buffer, cm->get_fb_cb, |
| 698 cm->cb_priv)) { |
| 699 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, |
| 700 "Failed to allocate frame buffer"); |
| 701 } |
703 } | 702 } |
704 | 703 |
705 static void setup_frame_size(VP9D_COMP *pbi, | 704 static void setup_frame_size(VP9D_COMP *pbi, |
706 struct vp9_read_bit_buffer *rb) { | 705 struct vp9_read_bit_buffer *rb) { |
707 int width, height; | 706 int width, height; |
708 read_frame_size(rb, &width, &height); | 707 read_frame_size(rb, &width, &height); |
709 apply_frame_size(pbi, width, height); | 708 apply_frame_size(pbi, width, height); |
710 setup_display_size(&pbi->common, rb); | 709 setup_display_size(&pbi->common, rb); |
711 } | 710 } |
712 | 711 |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
975 if (num_workers > pbi->num_tile_workers) { | 974 if (num_workers > pbi->num_tile_workers) { |
976 int i; | 975 int i; |
977 CHECK_MEM_ERROR(cm, pbi->tile_workers, | 976 CHECK_MEM_ERROR(cm, pbi->tile_workers, |
978 vpx_realloc(pbi->tile_workers, | 977 vpx_realloc(pbi->tile_workers, |
979 num_workers * sizeof(*pbi->tile_workers))); | 978 num_workers * sizeof(*pbi->tile_workers))); |
980 for (i = pbi->num_tile_workers; i < num_workers; ++i) { | 979 for (i = pbi->num_tile_workers; i < num_workers; ++i) { |
981 VP9Worker *const worker = &pbi->tile_workers[i]; | 980 VP9Worker *const worker = &pbi->tile_workers[i]; |
982 ++pbi->num_tile_workers; | 981 ++pbi->num_tile_workers; |
983 | 982 |
984 vp9_worker_init(worker); | 983 vp9_worker_init(worker); |
985 worker->hook = (VP9WorkerHook)tile_worker_hook; | |
986 CHECK_MEM_ERROR(cm, worker->data1, | 984 CHECK_MEM_ERROR(cm, worker->data1, |
987 vpx_memalign(32, sizeof(TileWorkerData))); | 985 vpx_memalign(32, sizeof(TileWorkerData))); |
988 CHECK_MEM_ERROR(cm, worker->data2, vpx_malloc(sizeof(TileInfo))); | 986 CHECK_MEM_ERROR(cm, worker->data2, vpx_malloc(sizeof(TileInfo))); |
989 if (i < num_workers - 1 && !vp9_worker_reset(worker)) { | 987 if (i < num_workers - 1 && !vp9_worker_reset(worker)) { |
990 vpx_internal_error(&cm->error, VPX_CODEC_ERROR, | 988 vpx_internal_error(&cm->error, VPX_CODEC_ERROR, |
991 "Tile decoder thread creation failed"); | 989 "Tile decoder thread creation failed"); |
992 } | 990 } |
993 } | 991 } |
994 } | 992 } |
995 | 993 |
| 994 // Reset tile decoding hook |
| 995 for (n = 0; n < pbi->num_tile_workers; ++n) { |
| 996 pbi->tile_workers[n].hook = (VP9WorkerHook)tile_worker_hook; |
| 997 } |
| 998 |
996 // Note: this memset assumes above_context[0], [1] and [2] | 999 // Note: this memset assumes above_context[0], [1] and [2] |
997 // are allocated as part of the same buffer. | 1000 // are allocated as part of the same buffer. |
998 vpx_memset(pbi->above_context[0], 0, | 1001 vpx_memset(pbi->above_context[0], 0, |
999 sizeof(*pbi->above_context[0]) * MAX_MB_PLANE * | 1002 sizeof(*pbi->above_context[0]) * MAX_MB_PLANE * |
1000 2 * aligned_mi_cols); | 1003 2 * aligned_mi_cols); |
1001 vpx_memset(pbi->above_seg_context, 0, | 1004 vpx_memset(pbi->above_seg_context, 0, |
1002 sizeof(*pbi->above_seg_context) * aligned_mi_cols); | 1005 sizeof(*pbi->above_seg_context) * aligned_mi_cols); |
1003 | 1006 |
1004 // Load tile data into tile_buffers | 1007 // Load tile data into tile_buffers |
1005 for (n = 0; n < tile_cols; ++n) { | 1008 for (n = 0; n < tile_cols; ++n) { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1109 if (vp9_rb_read_literal(rb, 2) != VP9_FRAME_MARKER) | 1112 if (vp9_rb_read_literal(rb, 2) != VP9_FRAME_MARKER) |
1110 vpx_internal_error(&cm->error, VPX_CODEC_UNSUP_BITSTREAM, | 1113 vpx_internal_error(&cm->error, VPX_CODEC_UNSUP_BITSTREAM, |
1111 "Invalid frame marker"); | 1114 "Invalid frame marker"); |
1112 | 1115 |
1113 cm->version = vp9_rb_read_bit(rb); | 1116 cm->version = vp9_rb_read_bit(rb); |
1114 RESERVED; | 1117 RESERVED; |
1115 | 1118 |
1116 cm->show_existing_frame = vp9_rb_read_bit(rb); | 1119 cm->show_existing_frame = vp9_rb_read_bit(rb); |
1117 if (cm->show_existing_frame) { | 1120 if (cm->show_existing_frame) { |
1118 // Show an existing frame directly. | 1121 // Show an existing frame directly. |
1119 int frame_to_show = cm->ref_frame_map[vp9_rb_read_literal(rb, 3)]; | 1122 const int frame_to_show = cm->ref_frame_map[vp9_rb_read_literal(rb, 3)]; |
1120 ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->new_fb_idx, frame_to_show); | 1123 ref_cnt_fb(cm->frame_bufs, &cm->new_fb_idx, frame_to_show); |
1121 pbi->refresh_frame_flags = 0; | 1124 pbi->refresh_frame_flags = 0; |
1122 cm->lf.filter_level = 0; | 1125 cm->lf.filter_level = 0; |
1123 cm->show_frame = 1; | 1126 cm->show_frame = 1; |
1124 return 0; | 1127 return 0; |
1125 } | 1128 } |
1126 | 1129 |
1127 cm->frame_type = (FRAME_TYPE) vp9_rb_read_bit(rb); | 1130 cm->frame_type = (FRAME_TYPE) vp9_rb_read_bit(rb); |
1128 cm->show_frame = vp9_rb_read_bit(rb); | 1131 cm->show_frame = vp9_rb_read_bit(rb); |
1129 cm->error_resilient_mode = vp9_rb_read_bit(rb); | 1132 cm->error_resilient_mode = vp9_rb_read_bit(rb); |
1130 | 1133 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1170 | 1173 |
1171 pbi->refresh_frame_flags = vp9_rb_read_literal(rb, REF_FRAMES); | 1174 pbi->refresh_frame_flags = vp9_rb_read_literal(rb, REF_FRAMES); |
1172 setup_frame_size(pbi, rb); | 1175 setup_frame_size(pbi, rb); |
1173 } else { | 1176 } else { |
1174 pbi->refresh_frame_flags = vp9_rb_read_literal(rb, REF_FRAMES); | 1177 pbi->refresh_frame_flags = vp9_rb_read_literal(rb, REF_FRAMES); |
1175 | 1178 |
1176 for (i = 0; i < REFS_PER_FRAME; ++i) { | 1179 for (i = 0; i < REFS_PER_FRAME; ++i) { |
1177 const int ref = vp9_rb_read_literal(rb, REF_FRAMES_LOG2); | 1180 const int ref = vp9_rb_read_literal(rb, REF_FRAMES_LOG2); |
1178 const int idx = cm->ref_frame_map[ref]; | 1181 const int idx = cm->ref_frame_map[ref]; |
1179 cm->frame_refs[i].idx = idx; | 1182 cm->frame_refs[i].idx = idx; |
1180 cm->frame_refs[i].buf = &cm->yv12_fb[idx]; | 1183 cm->frame_refs[i].buf = &cm->frame_bufs[idx].buf; |
1181 cm->ref_frame_sign_bias[LAST_FRAME + i] = vp9_rb_read_bit(rb); | 1184 cm->ref_frame_sign_bias[LAST_FRAME + i] = vp9_rb_read_bit(rb); |
1182 } | 1185 } |
1183 | 1186 |
1184 setup_frame_size_with_refs(pbi, rb); | 1187 setup_frame_size_with_refs(pbi, rb); |
1185 | 1188 |
1186 cm->allow_high_precision_mv = vp9_rb_read_bit(rb); | 1189 cm->allow_high_precision_mv = vp9_rb_read_bit(rb); |
1187 cm->interp_filter = read_interp_filter(rb); | 1190 cm->interp_filter = read_interp_filter(rb); |
1188 | 1191 |
1189 for (i = 0; i < REFS_PER_FRAME; ++i) { | 1192 for (i = 0; i < REFS_PER_FRAME; ++i) { |
1190 RefBuffer *const ref_buf = &cm->frame_refs[i]; | 1193 RefBuffer *const ref_buf = &cm->frame_refs[i]; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1238 | 1241 |
1239 if (vp9_reader_init(&r, data, partition_size)) | 1242 if (vp9_reader_init(&r, data, partition_size)) |
1240 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, | 1243 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, |
1241 "Failed to allocate bool decoder 0"); | 1244 "Failed to allocate bool decoder 0"); |
1242 | 1245 |
1243 cm->tx_mode = xd->lossless ? ONLY_4X4 : read_tx_mode(&r); | 1246 cm->tx_mode = xd->lossless ? ONLY_4X4 : read_tx_mode(&r); |
1244 if (cm->tx_mode == TX_MODE_SELECT) | 1247 if (cm->tx_mode == TX_MODE_SELECT) |
1245 read_tx_mode_probs(&fc->tx_probs, &r); | 1248 read_tx_mode_probs(&fc->tx_probs, &r); |
1246 read_coef_probs(fc, cm->tx_mode, &r); | 1249 read_coef_probs(fc, cm->tx_mode, &r); |
1247 | 1250 |
1248 for (k = 0; k < MBSKIP_CONTEXTS; ++k) | 1251 for (k = 0; k < SKIP_CONTEXTS; ++k) |
1249 vp9_diff_update_prob(&r, &fc->mbskip_probs[k]); | 1252 vp9_diff_update_prob(&r, &fc->skip_probs[k]); |
1250 | 1253 |
1251 if (!frame_is_intra_only(cm)) { | 1254 if (!frame_is_intra_only(cm)) { |
1252 nmv_context *const nmvc = &fc->nmvc; | 1255 nmv_context *const nmvc = &fc->nmvc; |
1253 int i, j; | 1256 int i, j; |
1254 | 1257 |
1255 read_inter_mode_probs(fc, &r); | 1258 read_inter_mode_probs(fc, &r); |
1256 | 1259 |
1257 if (cm->interp_filter == SWITCHABLE) | 1260 if (cm->interp_filter == SWITCHABLE) |
1258 read_switchable_interp_probs(fc, &r); | 1261 read_switchable_interp_probs(fc, &r); |
1259 | 1262 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1314 sizeof(cm->counts.inter_mode))); | 1317 sizeof(cm->counts.inter_mode))); |
1315 assert(!memcmp(cm->counts.intra_inter, zero_counts.intra_inter, | 1318 assert(!memcmp(cm->counts.intra_inter, zero_counts.intra_inter, |
1316 sizeof(cm->counts.intra_inter))); | 1319 sizeof(cm->counts.intra_inter))); |
1317 assert(!memcmp(cm->counts.comp_inter, zero_counts.comp_inter, | 1320 assert(!memcmp(cm->counts.comp_inter, zero_counts.comp_inter, |
1318 sizeof(cm->counts.comp_inter))); | 1321 sizeof(cm->counts.comp_inter))); |
1319 assert(!memcmp(cm->counts.single_ref, zero_counts.single_ref, | 1322 assert(!memcmp(cm->counts.single_ref, zero_counts.single_ref, |
1320 sizeof(cm->counts.single_ref))); | 1323 sizeof(cm->counts.single_ref))); |
1321 assert(!memcmp(cm->counts.comp_ref, zero_counts.comp_ref, | 1324 assert(!memcmp(cm->counts.comp_ref, zero_counts.comp_ref, |
1322 sizeof(cm->counts.comp_ref))); | 1325 sizeof(cm->counts.comp_ref))); |
1323 assert(!memcmp(&cm->counts.tx, &zero_counts.tx, sizeof(cm->counts.tx))); | 1326 assert(!memcmp(&cm->counts.tx, &zero_counts.tx, sizeof(cm->counts.tx))); |
1324 assert(!memcmp(cm->counts.mbskip, zero_counts.mbskip, | 1327 assert(!memcmp(cm->counts.skip, zero_counts.skip, sizeof(cm->counts.skip))); |
1325 sizeof(cm->counts.mbskip))); | |
1326 assert(!memcmp(&cm->counts.mv, &zero_counts.mv, sizeof(cm->counts.mv))); | 1328 assert(!memcmp(&cm->counts.mv, &zero_counts.mv, sizeof(cm->counts.mv))); |
1327 } | 1329 } |
1328 #endif // NDEBUG | 1330 #endif // NDEBUG |
1329 | 1331 |
1330 int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { | 1332 int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { |
1331 int i; | 1333 int i; |
1332 VP9_COMMON *const cm = &pbi->common; | 1334 VP9_COMMON *const cm = &pbi->common; |
1333 MACROBLOCKD *const xd = &pbi->mb; | 1335 MACROBLOCKD *const xd = &pbi->mb; |
1334 | 1336 |
1335 const uint8_t *data = pbi->source; | 1337 const uint8_t *data = pbi->source; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1367 "Loop filter thread creation failed"); | 1369 "Loop filter thread creation failed"); |
1368 } | 1370 } |
1369 } | 1371 } |
1370 | 1372 |
1371 alloc_tile_storage(pbi, tile_rows, tile_cols); | 1373 alloc_tile_storage(pbi, tile_rows, tile_cols); |
1372 | 1374 |
1373 xd->mode_info_stride = cm->mode_info_stride; | 1375 xd->mode_info_stride = cm->mode_info_stride; |
1374 set_prev_mi(cm); | 1376 set_prev_mi(cm); |
1375 | 1377 |
1376 setup_plane_dequants(cm, xd, cm->base_qindex); | 1378 setup_plane_dequants(cm, xd, cm->base_qindex); |
1377 setup_block_dptrs(xd, cm->subsampling_x, cm->subsampling_y); | 1379 vp9_setup_block_planes(xd, cm->subsampling_x, cm->subsampling_y); |
1378 | 1380 |
1379 cm->fc = cm->frame_contexts[cm->frame_context_idx]; | 1381 cm->fc = cm->frame_contexts[cm->frame_context_idx]; |
1380 vp9_zero(cm->counts); | 1382 vp9_zero(cm->counts); |
1381 for (i = 0; i < MAX_MB_PLANE; ++i) | 1383 for (i = 0; i < MAX_MB_PLANE; ++i) |
1382 vpx_memset(xd->plane[i].dqcoeff, 0, 64 * 64 * sizeof(int16_t)); | 1384 vpx_memset(xd->plane[i].dqcoeff, 0, 64 * 64 * sizeof(int16_t)); |
1383 | 1385 |
1384 xd->corrupted = 0; | 1386 xd->corrupted = 0; |
1385 new_fb->corrupted = read_compressed_header(pbi, data, first_partition_size); | 1387 new_fb->corrupted = read_compressed_header(pbi, data, first_partition_size); |
1386 | 1388 |
1387 // TODO(jzern): remove frame_parallel_decoding_mode restriction for | 1389 // TODO(jzern): remove frame_parallel_decoding_mode restriction for |
1388 // single-frame tile decoding. | 1390 // single-frame tile decoding. |
1389 if (pbi->oxcf.max_threads > 1 && tile_rows == 1 && tile_cols > 1 && | 1391 if (pbi->oxcf.max_threads > 1 && tile_rows == 1 && tile_cols > 1 && |
1390 cm->frame_parallel_decoding_mode) { | 1392 cm->frame_parallel_decoding_mode) { |
1391 *p_data_end = decode_tiles_mt(pbi, data + first_partition_size); | 1393 *p_data_end = decode_tiles_mt(pbi, data + first_partition_size); |
1392 } else { | 1394 } else { |
1393 *p_data_end = decode_tiles(pbi, data + first_partition_size); | 1395 *p_data_end = decode_tiles(pbi, data + first_partition_size); |
1394 } | 1396 } |
1395 | 1397 |
1396 cm->last_width = cm->width; | |
1397 cm->last_height = cm->height; | |
1398 | |
1399 new_fb->corrupted |= xd->corrupted; | 1398 new_fb->corrupted |= xd->corrupted; |
1400 | 1399 |
1401 if (!pbi->decoded_key_frame) { | 1400 if (!pbi->decoded_key_frame) { |
1402 if (keyframe && !new_fb->corrupted) | 1401 if (keyframe && !new_fb->corrupted) |
1403 pbi->decoded_key_frame = 1; | 1402 pbi->decoded_key_frame = 1; |
1404 else | 1403 else |
1405 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, | 1404 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, |
1406 "A stream must start with a complete key frame"); | 1405 "A stream must start with a complete key frame"); |
1407 } | 1406 } |
1408 | 1407 |
1409 if (!cm->error_resilient_mode && !cm->frame_parallel_decoding_mode) { | 1408 if (!cm->error_resilient_mode && !cm->frame_parallel_decoding_mode) { |
1410 vp9_adapt_coef_probs(cm); | 1409 vp9_adapt_coef_probs(cm); |
1411 | 1410 |
1412 if (!frame_is_intra_only(cm)) { | 1411 if (!frame_is_intra_only(cm)) { |
1413 vp9_adapt_mode_probs(cm); | 1412 vp9_adapt_mode_probs(cm); |
1414 vp9_adapt_mv_probs(cm, cm->allow_high_precision_mv); | 1413 vp9_adapt_mv_probs(cm, cm->allow_high_precision_mv); |
1415 } | 1414 } |
1416 } else { | 1415 } else { |
1417 debug_check_frame_counts(cm); | 1416 debug_check_frame_counts(cm); |
1418 } | 1417 } |
1419 | 1418 |
1420 if (cm->refresh_frame_context) | 1419 if (cm->refresh_frame_context) |
1421 cm->frame_contexts[cm->frame_context_idx] = cm->fc; | 1420 cm->frame_contexts[cm->frame_context_idx] = cm->fc; |
1422 | 1421 |
1423 return 0; | 1422 return 0; |
1424 } | 1423 } |
OLD | NEW |