| 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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 memset(dqcoeff, 0, 4 * (4 << tx_size) * sizeof(dqcoeff[0])); | 283 memset(dqcoeff, 0, 4 * (4 << tx_size) * sizeof(dqcoeff[0])); |
| 284 else if (tx_size == TX_32X32 && eob <= 34) | 284 else if (tx_size == TX_32X32 && eob <= 34) |
| 285 memset(dqcoeff, 0, 256 * sizeof(dqcoeff[0])); | 285 memset(dqcoeff, 0, 256 * sizeof(dqcoeff[0])); |
| 286 else | 286 else |
| 287 memset(dqcoeff, 0, (16 << (tx_size << 1)) * sizeof(dqcoeff[0])); | 287 memset(dqcoeff, 0, (16 << (tx_size << 1)) * sizeof(dqcoeff[0])); |
| 288 } | 288 } |
| 289 } | 289 } |
| 290 } | 290 } |
| 291 | 291 |
| 292 struct intra_args { | 292 struct intra_args { |
| 293 VP9_COMMON *cm; | |
| 294 MACROBLOCKD *xd; | 293 MACROBLOCKD *xd; |
| 295 FRAME_COUNTS *counts; | |
| 296 vp9_reader *r; | 294 vp9_reader *r; |
| 297 int seg_id; | 295 int seg_id; |
| 298 }; | 296 }; |
| 299 | 297 |
| 300 static void predict_and_reconstruct_intra_block(int plane, int block, | 298 static void predict_and_reconstruct_intra_block(int plane, int block, |
| 301 BLOCK_SIZE plane_bsize, | 299 BLOCK_SIZE plane_bsize, |
| 302 TX_SIZE tx_size, void *arg) { | 300 TX_SIZE tx_size, void *arg) { |
| 303 struct intra_args *const args = (struct intra_args *)arg; | 301 struct intra_args *const args = (struct intra_args *)arg; |
| 304 VP9_COMMON *const cm = args->cm; | |
| 305 MACROBLOCKD *const xd = args->xd; | 302 MACROBLOCKD *const xd = args->xd; |
| 306 struct macroblockd_plane *const pd = &xd->plane[plane]; | 303 struct macroblockd_plane *const pd = &xd->plane[plane]; |
| 307 MODE_INFO *const mi = xd->mi[0]; | 304 MODE_INFO *const mi = xd->mi[0]; |
| 308 const PREDICTION_MODE mode = (plane == 0) ? get_y_mode(mi, block) | 305 const PREDICTION_MODE mode = (plane == 0) ? get_y_mode(mi, block) |
| 309 : mi->mbmi.uv_mode; | 306 : mi->mbmi.uv_mode; |
| 310 int x, y; | 307 int x, y; |
| 311 uint8_t *dst; | 308 uint8_t *dst; |
| 312 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &x, &y); | 309 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &x, &y); |
| 313 dst = &pd->dst.buf[4 * y * pd->dst.stride + 4 * x]; | 310 dst = &pd->dst.buf[4 * y * pd->dst.stride + 4 * x]; |
| 314 | 311 |
| 315 vp9_predict_intra_block(xd, block >> (tx_size << 1), | 312 vp9_predict_intra_block(xd, block >> (tx_size << 1), |
| 316 b_width_log2_lookup[plane_bsize], tx_size, mode, | 313 b_width_log2_lookup[plane_bsize], tx_size, mode, |
| 317 dst, pd->dst.stride, dst, pd->dst.stride, | 314 dst, pd->dst.stride, dst, pd->dst.stride, |
| 318 x, y, plane); | 315 x, y, plane); |
| 319 | 316 |
| 320 if (!mi->mbmi.skip) { | 317 if (!mi->mbmi.skip) { |
| 321 const int eob = vp9_decode_block_tokens(cm, xd, args->counts, plane, block, | 318 const int eob = vp9_decode_block_tokens(xd, plane, block, |
| 322 plane_bsize, x, y, tx_size, | 319 plane_bsize, x, y, tx_size, |
| 323 args->r, args->seg_id); | 320 args->r, args->seg_id); |
| 324 inverse_transform_block(xd, plane, block, tx_size, dst, pd->dst.stride, | 321 inverse_transform_block(xd, plane, block, tx_size, dst, pd->dst.stride, |
| 325 eob); | 322 eob); |
| 326 } | 323 } |
| 327 } | 324 } |
| 328 | 325 |
| 329 struct inter_args { | 326 struct inter_args { |
| 330 VP9_COMMON *cm; | |
| 331 MACROBLOCKD *xd; | 327 MACROBLOCKD *xd; |
| 332 vp9_reader *r; | 328 vp9_reader *r; |
| 333 FRAME_COUNTS *counts; | |
| 334 int *eobtotal; | 329 int *eobtotal; |
| 335 int seg_id; | 330 int seg_id; |
| 336 }; | 331 }; |
| 337 | 332 |
| 338 static void reconstruct_inter_block(int plane, int block, | 333 static void reconstruct_inter_block(int plane, int block, |
| 339 BLOCK_SIZE plane_bsize, | 334 BLOCK_SIZE plane_bsize, |
| 340 TX_SIZE tx_size, void *arg) { | 335 TX_SIZE tx_size, void *arg) { |
| 341 struct inter_args *args = (struct inter_args *)arg; | 336 struct inter_args *args = (struct inter_args *)arg; |
| 342 VP9_COMMON *const cm = args->cm; | |
| 343 MACROBLOCKD *const xd = args->xd; | 337 MACROBLOCKD *const xd = args->xd; |
| 344 struct macroblockd_plane *const pd = &xd->plane[plane]; | 338 struct macroblockd_plane *const pd = &xd->plane[plane]; |
| 345 int x, y, eob; | 339 int x, y, eob; |
| 346 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &x, &y); | 340 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &x, &y); |
| 347 eob = vp9_decode_block_tokens(cm, xd, args->counts, plane, block, plane_bsize, | 341 eob = vp9_decode_block_tokens(xd, plane, block, plane_bsize, |
| 348 x, y, tx_size, args->r, args->seg_id); | 342 x, y, tx_size, args->r, args->seg_id); |
| 349 inverse_transform_block(xd, plane, block, tx_size, | 343 inverse_transform_block(xd, plane, block, tx_size, |
| 350 &pd->dst.buf[4 * y * pd->dst.stride + 4 * x], | 344 &pd->dst.buf[4 * y * pd->dst.stride + 4 * x], |
| 351 pd->dst.stride, eob); | 345 pd->dst.stride, eob); |
| 352 *args->eobtotal += eob; | 346 *args->eobtotal += eob; |
| 353 } | 347 } |
| 354 | 348 |
| 355 static MB_MODE_INFO *set_offsets(VP9_COMMON *const cm, MACROBLOCKD *const xd, | 349 static MB_MODE_INFO *set_offsets(VP9_COMMON *const cm, MACROBLOCKD *const xd, |
| 356 const TileInfo *const tile, | 350 const TileInfo *const tile, |
| 357 BLOCK_SIZE bsize, int mi_row, int mi_col) { | 351 BLOCK_SIZE bsize, int mi_row, int mi_col) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 374 | 368 |
| 375 // Distance of Mb to the various image edges. These are specified to 8th pel | 369 // Distance of Mb to the various image edges. These are specified to 8th pel |
| 376 // as they are always compared to values that are in 1/8th pel units | 370 // as they are always compared to values that are in 1/8th pel units |
| 377 set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw, cm->mi_rows, cm->mi_cols); | 371 set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw, cm->mi_rows, cm->mi_cols); |
| 378 | 372 |
| 379 vp9_setup_dst_planes(xd->plane, get_frame_new_buffer(cm), mi_row, mi_col); | 373 vp9_setup_dst_planes(xd->plane, get_frame_new_buffer(cm), mi_row, mi_col); |
| 380 return &xd->mi[0]->mbmi; | 374 return &xd->mi[0]->mbmi; |
| 381 } | 375 } |
| 382 | 376 |
| 383 static void decode_block(VP9Decoder *const pbi, MACROBLOCKD *const xd, | 377 static void decode_block(VP9Decoder *const pbi, MACROBLOCKD *const xd, |
| 384 FRAME_COUNTS *counts, | |
| 385 const TileInfo *const tile, | 378 const TileInfo *const tile, |
| 386 int mi_row, int mi_col, | 379 int mi_row, int mi_col, |
| 387 vp9_reader *r, BLOCK_SIZE bsize) { | 380 vp9_reader *r, BLOCK_SIZE bsize) { |
| 388 VP9_COMMON *const cm = &pbi->common; | 381 VP9_COMMON *const cm = &pbi->common; |
| 389 const int less8x8 = bsize < BLOCK_8X8; | 382 const int less8x8 = bsize < BLOCK_8X8; |
| 390 MB_MODE_INFO *mbmi = set_offsets(cm, xd, tile, bsize, mi_row, mi_col); | 383 MB_MODE_INFO *mbmi = set_offsets(cm, xd, tile, bsize, mi_row, mi_col); |
| 391 vp9_read_mode_info(pbi, xd, counts, tile, mi_row, mi_col, r); | 384 |
| 385 if (bsize >= BLOCK_8X8 && (cm->subsampling_x || cm->subsampling_y)) { |
| 386 const BLOCK_SIZE uv_subsize = |
| 387 ss_size_lookup[bsize][cm->subsampling_x][cm->subsampling_y]; |
| 388 if (uv_subsize == BLOCK_INVALID) |
| 389 vpx_internal_error(xd->error_info, |
| 390 VPX_CODEC_CORRUPT_FRAME, "Invalid block size."); |
| 391 } |
| 392 |
| 393 vp9_read_mode_info(pbi, xd, tile, mi_row, mi_col, r); |
| 392 | 394 |
| 393 if (less8x8) | 395 if (less8x8) |
| 394 bsize = BLOCK_8X8; | 396 bsize = BLOCK_8X8; |
| 395 | 397 |
| 396 if (mbmi->skip) { | 398 if (mbmi->skip) { |
| 397 reset_skip_context(xd, bsize); | 399 reset_skip_context(xd, bsize); |
| 398 } | 400 } |
| 399 | 401 |
| 400 if (!is_inter_block(mbmi)) { | 402 if (!is_inter_block(mbmi)) { |
| 401 struct intra_args arg = {cm, xd, counts, r, mbmi->segment_id}; | 403 struct intra_args arg = {xd, r, mbmi->segment_id}; |
| 402 vp9_foreach_transformed_block(xd, bsize, | 404 vp9_foreach_transformed_block(xd, bsize, |
| 403 predict_and_reconstruct_intra_block, &arg); | 405 predict_and_reconstruct_intra_block, &arg); |
| 404 } else { | 406 } else { |
| 405 // Prediction | 407 // Prediction |
| 406 vp9_dec_build_inter_predictors_sb(pbi, xd, mi_row, mi_col, bsize); | 408 vp9_dec_build_inter_predictors_sb(pbi, xd, mi_row, mi_col, bsize); |
| 407 | 409 |
| 408 // Reconstruction | 410 // Reconstruction |
| 409 if (!mbmi->skip) { | 411 if (!mbmi->skip) { |
| 410 int eobtotal = 0; | 412 int eobtotal = 0; |
| 411 struct inter_args arg = {cm, xd, r, counts, &eobtotal, mbmi->segment_id}; | 413 struct inter_args arg = {xd, r, &eobtotal, mbmi->segment_id}; |
| 412 vp9_foreach_transformed_block(xd, bsize, reconstruct_inter_block, &arg); | 414 vp9_foreach_transformed_block(xd, bsize, reconstruct_inter_block, &arg); |
| 413 if (!less8x8 && eobtotal == 0) | 415 if (!less8x8 && eobtotal == 0) |
| 414 mbmi->skip = 1; // skip loopfilter | 416 mbmi->skip = 1; // skip loopfilter |
| 415 } | 417 } |
| 416 } | 418 } |
| 417 | 419 |
| 418 xd->corrupted |= vp9_reader_has_error(r); | 420 xd->corrupted |= vp9_reader_has_error(r); |
| 419 } | 421 } |
| 420 | 422 |
| 421 static PARTITION_TYPE read_partition(VP9_COMMON *cm, MACROBLOCKD *xd, | 423 static PARTITION_TYPE read_partition(VP9_COMMON *cm, MACROBLOCKD *xd, |
| 422 FRAME_COUNTS *counts, int hbs, | 424 int hbs, |
| 423 int mi_row, int mi_col, BLOCK_SIZE bsize, | 425 int mi_row, int mi_col, BLOCK_SIZE bsize, |
| 424 vp9_reader *r) { | 426 vp9_reader *r) { |
| 425 const int ctx = partition_plane_context(xd, mi_row, mi_col, bsize); | 427 const int ctx = partition_plane_context(xd, mi_row, mi_col, bsize); |
| 426 const vp9_prob *const probs = get_partition_probs(cm, ctx); | 428 const vp9_prob *const probs = get_partition_probs(cm, ctx); |
| 427 const int has_rows = (mi_row + hbs) < cm->mi_rows; | 429 const int has_rows = (mi_row + hbs) < cm->mi_rows; |
| 428 const int has_cols = (mi_col + hbs) < cm->mi_cols; | 430 const int has_cols = (mi_col + hbs) < cm->mi_cols; |
| 431 FRAME_COUNTS *counts = xd->counts; |
| 429 PARTITION_TYPE p; | 432 PARTITION_TYPE p; |
| 430 | 433 |
| 431 if (has_rows && has_cols) | 434 if (has_rows && has_cols) |
| 432 p = (PARTITION_TYPE)vp9_read_tree(r, vp9_partition_tree, probs); | 435 p = (PARTITION_TYPE)vp9_read_tree(r, vp9_partition_tree, probs); |
| 433 else if (!has_rows && has_cols) | 436 else if (!has_rows && has_cols) |
| 434 p = vp9_read(r, probs[1]) ? PARTITION_SPLIT : PARTITION_HORZ; | 437 p = vp9_read(r, probs[1]) ? PARTITION_SPLIT : PARTITION_HORZ; |
| 435 else if (has_rows && !has_cols) | 438 else if (has_rows && !has_cols) |
| 436 p = vp9_read(r, probs[2]) ? PARTITION_SPLIT : PARTITION_VERT; | 439 p = vp9_read(r, probs[2]) ? PARTITION_SPLIT : PARTITION_VERT; |
| 437 else | 440 else |
| 438 p = PARTITION_SPLIT; | 441 p = PARTITION_SPLIT; |
| 439 | 442 |
| 440 if (!cm->frame_parallel_decoding_mode) | 443 if (counts) |
| 441 ++counts->partition[ctx][p]; | 444 ++counts->partition[ctx][p]; |
| 442 | 445 |
| 443 return p; | 446 return p; |
| 444 } | 447 } |
| 445 | 448 |
| 446 static void decode_partition(VP9Decoder *const pbi, MACROBLOCKD *const xd, | 449 static void decode_partition(VP9Decoder *const pbi, MACROBLOCKD *const xd, |
| 447 FRAME_COUNTS *counts, | |
| 448 const TileInfo *const tile, | 450 const TileInfo *const tile, |
| 449 int mi_row, int mi_col, | 451 int mi_row, int mi_col, |
| 450 vp9_reader* r, BLOCK_SIZE bsize) { | 452 vp9_reader* r, BLOCK_SIZE bsize) { |
| 451 VP9_COMMON *const cm = &pbi->common; | 453 VP9_COMMON *const cm = &pbi->common; |
| 452 const int hbs = num_8x8_blocks_wide_lookup[bsize] / 2; | 454 const int hbs = num_8x8_blocks_wide_lookup[bsize] / 2; |
| 453 PARTITION_TYPE partition; | 455 PARTITION_TYPE partition; |
| 454 BLOCK_SIZE subsize, uv_subsize; | 456 BLOCK_SIZE subsize; |
| 455 | 457 |
| 456 if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) | 458 if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) |
| 457 return; | 459 return; |
| 458 | 460 |
| 459 partition = read_partition(cm, xd, counts, hbs, mi_row, mi_col, bsize, r); | 461 partition = read_partition(cm, xd, hbs, mi_row, mi_col, bsize, r); |
| 460 subsize = get_subsize(bsize, partition); | 462 subsize = get_subsize(bsize, partition); |
| 461 uv_subsize = ss_size_lookup[subsize][cm->subsampling_x][cm->subsampling_y]; | 463 if (bsize == BLOCK_8X8) { |
| 462 if (subsize >= BLOCK_8X8 && uv_subsize == BLOCK_INVALID) | 464 decode_block(pbi, xd, tile, mi_row, mi_col, r, subsize); |
| 463 vpx_internal_error(xd->error_info, | |
| 464 VPX_CODEC_CORRUPT_FRAME, "Invalid block size."); | |
| 465 if (subsize < BLOCK_8X8) { | |
| 466 decode_block(pbi, xd, counts, tile, mi_row, mi_col, r, subsize); | |
| 467 } else { | 465 } else { |
| 468 switch (partition) { | 466 switch (partition) { |
| 469 case PARTITION_NONE: | 467 case PARTITION_NONE: |
| 470 decode_block(pbi, xd, counts, tile, mi_row, mi_col, r, subsize); | 468 decode_block(pbi, xd, tile, mi_row, mi_col, r, subsize); |
| 471 break; | 469 break; |
| 472 case PARTITION_HORZ: | 470 case PARTITION_HORZ: |
| 473 decode_block(pbi, xd, counts, tile, mi_row, mi_col, r, subsize); | 471 decode_block(pbi, xd, tile, mi_row, mi_col, r, subsize); |
| 474 if (mi_row + hbs < cm->mi_rows) | 472 if (mi_row + hbs < cm->mi_rows) |
| 475 decode_block(pbi, xd, counts, tile, mi_row + hbs, mi_col, r, subsize); | 473 decode_block(pbi, xd, tile, mi_row + hbs, mi_col, r, subsize); |
| 476 break; | 474 break; |
| 477 case PARTITION_VERT: | 475 case PARTITION_VERT: |
| 478 decode_block(pbi, xd, counts, tile, mi_row, mi_col, r, subsize); | 476 decode_block(pbi, xd, tile, mi_row, mi_col, r, subsize); |
| 479 if (mi_col + hbs < cm->mi_cols) | 477 if (mi_col + hbs < cm->mi_cols) |
| 480 decode_block(pbi, xd, counts, tile, mi_row, mi_col + hbs, r, subsize); | 478 decode_block(pbi, xd, tile, mi_row, mi_col + hbs, r, subsize); |
| 481 break; | 479 break; |
| 482 case PARTITION_SPLIT: | 480 case PARTITION_SPLIT: |
| 483 decode_partition(pbi, xd, counts, tile, mi_row, mi_col, r, subsize); | 481 decode_partition(pbi, xd, tile, mi_row, mi_col, r, subsize); |
| 484 decode_partition(pbi, xd, counts, tile, mi_row, mi_col + hbs, r, | 482 decode_partition(pbi, xd, tile, mi_row, mi_col + hbs, r, subsize); |
| 485 subsize); | 483 decode_partition(pbi, xd, tile, mi_row + hbs, mi_col, r, subsize); |
| 486 decode_partition(pbi, xd, counts, tile, mi_row + hbs, mi_col, r, | 484 decode_partition(pbi, xd, tile, mi_row + hbs, mi_col + hbs, r, subsize); |
| 487 subsize); | |
| 488 decode_partition(pbi, xd, counts, tile, mi_row + hbs, mi_col + hbs, r, | |
| 489 subsize); | |
| 490 break; | 485 break; |
| 491 default: | 486 default: |
| 492 assert(0 && "Invalid partition type"); | 487 assert(0 && "Invalid partition type"); |
| 493 } | 488 } |
| 494 } | 489 } |
| 495 | 490 |
| 496 // update partition context | 491 // update partition context |
| 497 if (bsize >= BLOCK_8X8 && | 492 if (bsize >= BLOCK_8X8 && |
| 498 (bsize == BLOCK_8X8 || partition != PARTITION_SPLIT)) | 493 (bsize == BLOCK_8X8 || partition != PARTITION_SPLIT)) |
| 499 update_partition_context(xd, mi_row, mi_col, subsize, bsize); | 494 update_partition_context(xd, mi_row, mi_col, subsize, bsize); |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 924 VP9_COMMON *const cm = &pbi->common; | 919 VP9_COMMON *const cm = &pbi->common; |
| 925 const VP9WorkerInterface *const winterface = vp9_get_worker_interface(); | 920 const VP9WorkerInterface *const winterface = vp9_get_worker_interface(); |
| 926 const int aligned_cols = mi_cols_aligned_to_sb(cm->mi_cols); | 921 const int aligned_cols = mi_cols_aligned_to_sb(cm->mi_cols); |
| 927 const int tile_cols = 1 << cm->log2_tile_cols; | 922 const int tile_cols = 1 << cm->log2_tile_cols; |
| 928 const int tile_rows = 1 << cm->log2_tile_rows; | 923 const int tile_rows = 1 << cm->log2_tile_rows; |
| 929 TileBuffer tile_buffers[4][1 << 6]; | 924 TileBuffer tile_buffers[4][1 << 6]; |
| 930 int tile_row, tile_col; | 925 int tile_row, tile_col; |
| 931 int mi_row, mi_col; | 926 int mi_row, mi_col; |
| 932 TileData *tile_data = NULL; | 927 TileData *tile_data = NULL; |
| 933 | 928 |
| 934 if (cm->lf.filter_level && pbi->lf_worker.data1 == NULL) { | 929 if (cm->lf.filter_level && !cm->skip_loop_filter && |
| 930 pbi->lf_worker.data1 == NULL) { |
| 935 CHECK_MEM_ERROR(cm, pbi->lf_worker.data1, | 931 CHECK_MEM_ERROR(cm, pbi->lf_worker.data1, |
| 936 vpx_memalign(32, sizeof(LFWorkerData))); | 932 vpx_memalign(32, sizeof(LFWorkerData))); |
| 937 pbi->lf_worker.hook = (VP9WorkerHook)vp9_loop_filter_worker; | 933 pbi->lf_worker.hook = (VP9WorkerHook)vp9_loop_filter_worker; |
| 938 if (pbi->max_threads > 1 && !winterface->reset(&pbi->lf_worker)) { | 934 if (pbi->max_threads > 1 && !winterface->reset(&pbi->lf_worker)) { |
| 939 vpx_internal_error(&cm->error, VPX_CODEC_ERROR, | 935 vpx_internal_error(&cm->error, VPX_CODEC_ERROR, |
| 940 "Loop filter thread creation failed"); | 936 "Loop filter thread creation failed"); |
| 941 } | 937 } |
| 942 } | 938 } |
| 943 | 939 |
| 944 if (cm->lf.filter_level) { | 940 if (cm->lf.filter_level && !cm->skip_loop_filter) { |
| 945 LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1; | 941 LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1; |
| 946 // Be sure to sync as we might be resuming after a failed frame decode. | 942 // Be sure to sync as we might be resuming after a failed frame decode. |
| 947 winterface->sync(&pbi->lf_worker); | 943 winterface->sync(&pbi->lf_worker); |
| 948 vp9_loop_filter_data_reset(lf_data, get_frame_new_buffer(cm), cm, | 944 vp9_loop_filter_data_reset(lf_data, get_frame_new_buffer(cm), cm, |
| 949 pbi->mb.plane); | 945 pbi->mb.plane); |
| 950 } | 946 } |
| 951 | 947 |
| 952 assert(tile_rows <= 4); | 948 assert(tile_rows <= 4); |
| 953 assert(tile_cols <= (1 << 6)); | 949 assert(tile_cols <= (1 << 6)); |
| 954 | 950 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 974 | 970 |
| 975 // Load all tile information into tile_data. | 971 // Load all tile information into tile_data. |
| 976 for (tile_row = 0; tile_row < tile_rows; ++tile_row) { | 972 for (tile_row = 0; tile_row < tile_rows; ++tile_row) { |
| 977 for (tile_col = 0; tile_col < tile_cols; ++tile_col) { | 973 for (tile_col = 0; tile_col < tile_cols; ++tile_col) { |
| 978 TileInfo tile; | 974 TileInfo tile; |
| 979 const TileBuffer *const buf = &tile_buffers[tile_row][tile_col]; | 975 const TileBuffer *const buf = &tile_buffers[tile_row][tile_col]; |
| 980 tile_data = pbi->tile_data + tile_cols * tile_row + tile_col; | 976 tile_data = pbi->tile_data + tile_cols * tile_row + tile_col; |
| 981 tile_data->cm = cm; | 977 tile_data->cm = cm; |
| 982 tile_data->xd = pbi->mb; | 978 tile_data->xd = pbi->mb; |
| 983 tile_data->xd.corrupted = 0; | 979 tile_data->xd.corrupted = 0; |
| 980 tile_data->xd.counts = cm->frame_parallel_decoding_mode ? |
| 981 NULL : &cm->counts; |
| 984 vp9_tile_init(&tile, tile_data->cm, tile_row, tile_col); | 982 vp9_tile_init(&tile, tile_data->cm, tile_row, tile_col); |
| 985 setup_token_decoder(buf->data, data_end, buf->size, &cm->error, | 983 setup_token_decoder(buf->data, data_end, buf->size, &cm->error, |
| 986 &tile_data->bit_reader, pbi->decrypt_cb, | 984 &tile_data->bit_reader, pbi->decrypt_cb, |
| 987 pbi->decrypt_state); | 985 pbi->decrypt_state); |
| 988 init_macroblockd(cm, &tile_data->xd); | 986 init_macroblockd(cm, &tile_data->xd); |
| 989 } | 987 } |
| 990 } | 988 } |
| 991 | 989 |
| 992 for (tile_row = 0; tile_row < tile_rows; ++tile_row) { | 990 for (tile_row = 0; tile_row < tile_rows; ++tile_row) { |
| 993 TileInfo tile; | 991 TileInfo tile; |
| 994 vp9_tile_set_row(&tile, cm, tile_row); | 992 vp9_tile_set_row(&tile, cm, tile_row); |
| 995 for (mi_row = tile.mi_row_start; mi_row < tile.mi_row_end; | 993 for (mi_row = tile.mi_row_start; mi_row < tile.mi_row_end; |
| 996 mi_row += MI_BLOCK_SIZE) { | 994 mi_row += MI_BLOCK_SIZE) { |
| 997 for (tile_col = 0; tile_col < tile_cols; ++tile_col) { | 995 for (tile_col = 0; tile_col < tile_cols; ++tile_col) { |
| 998 const int col = pbi->inv_tile_order ? | 996 const int col = pbi->inv_tile_order ? |
| 999 tile_cols - tile_col - 1 : tile_col; | 997 tile_cols - tile_col - 1 : tile_col; |
| 1000 tile_data = pbi->tile_data + tile_cols * tile_row + col; | 998 tile_data = pbi->tile_data + tile_cols * tile_row + col; |
| 1001 vp9_tile_set_col(&tile, tile_data->cm, col); | 999 vp9_tile_set_col(&tile, tile_data->cm, col); |
| 1002 vp9_zero(tile_data->xd.left_context); | 1000 vp9_zero(tile_data->xd.left_context); |
| 1003 vp9_zero(tile_data->xd.left_seg_context); | 1001 vp9_zero(tile_data->xd.left_seg_context); |
| 1004 for (mi_col = tile.mi_col_start; mi_col < tile.mi_col_end; | 1002 for (mi_col = tile.mi_col_start; mi_col < tile.mi_col_end; |
| 1005 mi_col += MI_BLOCK_SIZE) { | 1003 mi_col += MI_BLOCK_SIZE) { |
| 1006 decode_partition(pbi, &tile_data->xd, &cm->counts, &tile, mi_row, | 1004 decode_partition(pbi, &tile_data->xd, &tile, mi_row, |
| 1007 mi_col, &tile_data->bit_reader, BLOCK_64X64); | 1005 mi_col, &tile_data->bit_reader, BLOCK_64X64); |
| 1008 } | 1006 } |
| 1009 pbi->mb.corrupted |= tile_data->xd.corrupted; | 1007 pbi->mb.corrupted |= tile_data->xd.corrupted; |
| 1010 if (pbi->mb.corrupted) | 1008 if (pbi->mb.corrupted) |
| 1011 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, | 1009 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, |
| 1012 "Failed to decode tile data"); | 1010 "Failed to decode tile data"); |
| 1013 } | 1011 } |
| 1014 // Loopfilter one row. | 1012 // Loopfilter one row. |
| 1015 if (cm->lf.filter_level) { | 1013 if (cm->lf.filter_level && !cm->skip_loop_filter) { |
| 1016 const int lf_start = mi_row - MI_BLOCK_SIZE; | 1014 const int lf_start = mi_row - MI_BLOCK_SIZE; |
| 1017 LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1; | 1015 LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1; |
| 1018 | 1016 |
| 1019 // delay the loopfilter by 1 macroblock row. | 1017 // delay the loopfilter by 1 macroblock row. |
| 1020 if (lf_start < 0) continue; | 1018 if (lf_start < 0) continue; |
| 1021 | 1019 |
| 1022 // decoding has completed: finish up the loop filter in this thread. | 1020 // decoding has completed: finish up the loop filter in this thread. |
| 1023 if (mi_row + MI_BLOCK_SIZE >= cm->mi_rows) continue; | 1021 if (mi_row + MI_BLOCK_SIZE >= cm->mi_rows) continue; |
| 1024 | 1022 |
| 1025 winterface->sync(&pbi->lf_worker); | 1023 winterface->sync(&pbi->lf_worker); |
| 1026 lf_data->start = lf_start; | 1024 lf_data->start = lf_start; |
| 1027 lf_data->stop = mi_row; | 1025 lf_data->stop = mi_row; |
| 1028 if (pbi->max_threads > 1) { | 1026 if (pbi->max_threads > 1) { |
| 1029 winterface->launch(&pbi->lf_worker); | 1027 winterface->launch(&pbi->lf_worker); |
| 1030 } else { | 1028 } else { |
| 1031 winterface->execute(&pbi->lf_worker); | 1029 winterface->execute(&pbi->lf_worker); |
| 1032 } | 1030 } |
| 1033 } | 1031 } |
| 1034 // After loopfiltering, the last 7 row pixels in each superblock row may | 1032 // After loopfiltering, the last 7 row pixels in each superblock row may |
| 1035 // still be changed by the longest loopfilter of the next superblock | 1033 // still be changed by the longest loopfilter of the next superblock |
| 1036 // row. | 1034 // row. |
| 1037 if (pbi->frame_parallel_decode) | 1035 if (pbi->frame_parallel_decode) |
| 1038 vp9_frameworker_broadcast(pbi->cur_buf, | 1036 vp9_frameworker_broadcast(pbi->cur_buf, |
| 1039 mi_row << MI_BLOCK_SIZE_LOG2); | 1037 mi_row << MI_BLOCK_SIZE_LOG2); |
| 1040 } | 1038 } |
| 1041 } | 1039 } |
| 1042 | 1040 |
| 1043 // Loopfilter remaining rows in the frame. | 1041 // Loopfilter remaining rows in the frame. |
| 1044 if (cm->lf.filter_level) { | 1042 if (cm->lf.filter_level && !cm->skip_loop_filter) { |
| 1045 LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1; | 1043 LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1; |
| 1046 winterface->sync(&pbi->lf_worker); | 1044 winterface->sync(&pbi->lf_worker); |
| 1047 lf_data->start = lf_data->stop; | 1045 lf_data->start = lf_data->stop; |
| 1048 lf_data->stop = cm->mi_rows; | 1046 lf_data->stop = cm->mi_rows; |
| 1049 winterface->execute(&pbi->lf_worker); | 1047 winterface->execute(&pbi->lf_worker); |
| 1050 } | 1048 } |
| 1051 | 1049 |
| 1052 // Get last tile data. | 1050 // Get last tile data. |
| 1053 tile_data = pbi->tile_data + tile_cols * tile_rows - 1; | 1051 tile_data = pbi->tile_data + tile_cols * tile_rows - 1; |
| 1054 | 1052 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1069 | 1067 |
| 1070 tile_data->error_info.setjmp = 1; | 1068 tile_data->error_info.setjmp = 1; |
| 1071 tile_data->xd.error_info = &tile_data->error_info; | 1069 tile_data->xd.error_info = &tile_data->error_info; |
| 1072 | 1070 |
| 1073 for (mi_row = tile->mi_row_start; mi_row < tile->mi_row_end; | 1071 for (mi_row = tile->mi_row_start; mi_row < tile->mi_row_end; |
| 1074 mi_row += MI_BLOCK_SIZE) { | 1072 mi_row += MI_BLOCK_SIZE) { |
| 1075 vp9_zero(tile_data->xd.left_context); | 1073 vp9_zero(tile_data->xd.left_context); |
| 1076 vp9_zero(tile_data->xd.left_seg_context); | 1074 vp9_zero(tile_data->xd.left_seg_context); |
| 1077 for (mi_col = tile->mi_col_start; mi_col < tile->mi_col_end; | 1075 for (mi_col = tile->mi_col_start; mi_col < tile->mi_col_end; |
| 1078 mi_col += MI_BLOCK_SIZE) { | 1076 mi_col += MI_BLOCK_SIZE) { |
| 1079 decode_partition(tile_data->pbi, &tile_data->xd, &tile_data->counts, | 1077 decode_partition(tile_data->pbi, &tile_data->xd, |
| 1080 tile, mi_row, mi_col, &tile_data->bit_reader, | 1078 tile, mi_row, mi_col, &tile_data->bit_reader, |
| 1081 BLOCK_64X64); | 1079 BLOCK_64X64); |
| 1082 } | 1080 } |
| 1083 } | 1081 } |
| 1084 return !tile_data->xd.corrupted; | 1082 return !tile_data->xd.corrupted; |
| 1085 } | 1083 } |
| 1086 | 1084 |
| 1087 // sorts in descending order | 1085 // sorts in descending order |
| 1088 static int compare_tile_buffers(const void *a, const void *b) { | 1086 static int compare_tile_buffers(const void *a, const void *b) { |
| 1089 const TileBuffer *const buf1 = (const TileBuffer*)a; | 1087 const TileBuffer *const buf1 = (const TileBuffer*)a; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1193 int i; | 1191 int i; |
| 1194 for (i = 0; i < num_workers && n < tile_cols; ++i) { | 1192 for (i = 0; i < num_workers && n < tile_cols; ++i) { |
| 1195 VP9Worker *const worker = &pbi->tile_workers[i]; | 1193 VP9Worker *const worker = &pbi->tile_workers[i]; |
| 1196 TileWorkerData *const tile_data = (TileWorkerData*)worker->data1; | 1194 TileWorkerData *const tile_data = (TileWorkerData*)worker->data1; |
| 1197 TileInfo *const tile = (TileInfo*)worker->data2; | 1195 TileInfo *const tile = (TileInfo*)worker->data2; |
| 1198 TileBuffer *const buf = &tile_buffers[0][n]; | 1196 TileBuffer *const buf = &tile_buffers[0][n]; |
| 1199 | 1197 |
| 1200 tile_data->pbi = pbi; | 1198 tile_data->pbi = pbi; |
| 1201 tile_data->xd = pbi->mb; | 1199 tile_data->xd = pbi->mb; |
| 1202 tile_data->xd.corrupted = 0; | 1200 tile_data->xd.corrupted = 0; |
| 1201 tile_data->xd.counts = cm->frame_parallel_decoding_mode ? |
| 1202 0 : &tile_data->counts; |
| 1203 vp9_tile_init(tile, cm, 0, buf->col); | 1203 vp9_tile_init(tile, cm, 0, buf->col); |
| 1204 setup_token_decoder(buf->data, data_end, buf->size, &cm->error, | 1204 setup_token_decoder(buf->data, data_end, buf->size, &cm->error, |
| 1205 &tile_data->bit_reader, pbi->decrypt_cb, | 1205 &tile_data->bit_reader, pbi->decrypt_cb, |
| 1206 pbi->decrypt_state); | 1206 pbi->decrypt_state); |
| 1207 init_macroblockd(cm, &tile_data->xd); | 1207 init_macroblockd(cm, &tile_data->xd); |
| 1208 | 1208 |
| 1209 worker->had_error = 0; | 1209 worker->had_error = 0; |
| 1210 if (i == num_workers - 1 || n == tile_cols - 1) { | 1210 if (i == num_workers - 1 || n == tile_cols - 1) { |
| 1211 winterface->execute(worker); | 1211 winterface->execute(worker); |
| 1212 } else { | 1212 } else { |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1656 "Uninitialized entropy context."); | 1656 "Uninitialized entropy context."); |
| 1657 | 1657 |
| 1658 vp9_zero(cm->counts); | 1658 vp9_zero(cm->counts); |
| 1659 | 1659 |
| 1660 xd->corrupted = 0; | 1660 xd->corrupted = 0; |
| 1661 new_fb->corrupted = read_compressed_header(pbi, data, first_partition_size); | 1661 new_fb->corrupted = read_compressed_header(pbi, data, first_partition_size); |
| 1662 if (new_fb->corrupted) | 1662 if (new_fb->corrupted) |
| 1663 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, | 1663 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, |
| 1664 "Decode failed. Frame data header is corrupted."); | 1664 "Decode failed. Frame data header is corrupted."); |
| 1665 | 1665 |
| 1666 if (cm->lf.filter_level) { | 1666 if (cm->lf.filter_level && !cm->skip_loop_filter) { |
| 1667 vp9_loop_filter_frame_init(cm, cm->lf.filter_level); | 1667 vp9_loop_filter_frame_init(cm, cm->lf.filter_level); |
| 1668 } | 1668 } |
| 1669 | 1669 |
| 1670 // If encoded in frame parallel mode, frame context is ready after decoding | 1670 // If encoded in frame parallel mode, frame context is ready after decoding |
| 1671 // the frame header. | 1671 // the frame header. |
| 1672 if (pbi->frame_parallel_decode && cm->frame_parallel_decoding_mode) { | 1672 if (pbi->frame_parallel_decode && cm->frame_parallel_decoding_mode) { |
| 1673 VP9Worker *const worker = pbi->frame_worker_owner; | 1673 VP9Worker *const worker = pbi->frame_worker_owner; |
| 1674 FrameWorkerData *const frame_worker_data = worker->data1; | 1674 FrameWorkerData *const frame_worker_data = worker->data1; |
| 1675 if (cm->refresh_frame_context) { | 1675 if (cm->refresh_frame_context) { |
| 1676 context_updated = 1; | 1676 context_updated = 1; |
| 1677 cm->frame_contexts[cm->frame_context_idx] = *cm->fc; | 1677 cm->frame_contexts[cm->frame_context_idx] = *cm->fc; |
| 1678 } | 1678 } |
| 1679 vp9_frameworker_lock_stats(worker); | 1679 vp9_frameworker_lock_stats(worker); |
| 1680 pbi->cur_buf->row = -1; | 1680 pbi->cur_buf->row = -1; |
| 1681 pbi->cur_buf->col = -1; | 1681 pbi->cur_buf->col = -1; |
| 1682 frame_worker_data->frame_context_ready = 1; | 1682 frame_worker_data->frame_context_ready = 1; |
| 1683 // Signal the main thread that context is ready. | 1683 // Signal the main thread that context is ready. |
| 1684 vp9_frameworker_signal_stats(worker); | 1684 vp9_frameworker_signal_stats(worker); |
| 1685 vp9_frameworker_unlock_stats(worker); | 1685 vp9_frameworker_unlock_stats(worker); |
| 1686 } | 1686 } |
| 1687 | 1687 |
| 1688 if (pbi->max_threads > 1 && tile_rows == 1 && tile_cols > 1) { | 1688 if (pbi->max_threads > 1 && tile_rows == 1 && tile_cols > 1) { |
| 1689 // Multi-threaded tile decoder | 1689 // Multi-threaded tile decoder |
| 1690 *p_data_end = decode_tiles_mt(pbi, data + first_partition_size, data_end); | 1690 *p_data_end = decode_tiles_mt(pbi, data + first_partition_size, data_end); |
| 1691 if (!xd->corrupted) { | 1691 if (!xd->corrupted) { |
| 1692 // If multiple threads are used to decode tiles, then we use those threads | 1692 if (!cm->skip_loop_filter) { |
| 1693 // to do parallel loopfiltering. | 1693 // If multiple threads are used to decode tiles, then we use those |
| 1694 vp9_loop_filter_frame_mt(new_fb, cm, pbi->mb.plane, cm->lf.filter_level, | 1694 // threads to do parallel loopfiltering. |
| 1695 0, 0, pbi->tile_workers, pbi->num_tile_workers, | 1695 vp9_loop_filter_frame_mt(new_fb, cm, pbi->mb.plane, |
| 1696 &pbi->lf_row_sync); | 1696 cm->lf.filter_level, 0, 0, pbi->tile_workers, |
| 1697 pbi->num_tile_workers, &pbi->lf_row_sync); |
| 1698 } |
| 1697 } else { | 1699 } else { |
| 1698 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, | 1700 vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, |
| 1699 "Decode failed. Frame data is corrupted."); | 1701 "Decode failed. Frame data is corrupted."); |
| 1700 | 1702 |
| 1701 } | 1703 } |
| 1702 } else { | 1704 } else { |
| 1703 *p_data_end = decode_tiles(pbi, data + first_partition_size, data_end); | 1705 *p_data_end = decode_tiles(pbi, data + first_partition_size, data_end); |
| 1704 } | 1706 } |
| 1705 | 1707 |
| 1706 if (!xd->corrupted) { | 1708 if (!xd->corrupted) { |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2066 } else { | 2068 } else { |
| 2067 const MV mv = mi->mbmi.mv[ref].as_mv; | 2069 const MV mv = mi->mbmi.mv[ref].as_mv; |
| 2068 dec_build_inter_predictors(pbi, xd, plane, bw, bh, | 2070 dec_build_inter_predictors(pbi, xd, plane, bw, bh, |
| 2069 0, 0, bw, bh, mi_x, mi_y, kernel, | 2071 0, 0, bw, bh, mi_x, mi_y, kernel, |
| 2070 sf, pre_buf, dst_buf, &mv, ref_frame_buf, | 2072 sf, pre_buf, dst_buf, &mv, ref_frame_buf, |
| 2071 is_scaled, ref); | 2073 is_scaled, ref); |
| 2072 } | 2074 } |
| 2073 } | 2075 } |
| 2074 } | 2076 } |
| 2075 } | 2077 } |
| OLD | NEW |