| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010 The VP8 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 |
| 11 | 11 |
| 12 #include "onyxd_int.h" | 12 #include "onyxd_int.h" |
| 13 #include "header.h" | 13 #include "header.h" |
| 14 #include "reconintra.h" | 14 #include "reconintra.h" |
| 15 #include "reconintra4x4.h" | 15 #include "reconintra4x4.h" |
| 16 #include "recon.h" | 16 #include "recon.h" |
| 17 #include "reconinter.h" | 17 #include "reconinter.h" |
| 18 #include "dequantize.h" | 18 #include "dequantize.h" |
| 19 #include "detokenize.h" | 19 #include "detokenize.h" |
| 20 #include "invtrans.h" | 20 #include "invtrans.h" |
| 21 #include "alloccommon.h" | 21 #include "alloccommon.h" |
| 22 #include "entropymode.h" | 22 #include "entropymode.h" |
| 23 #include "quant_common.h" | 23 #include "quant_common.h" |
| 24 #include "vpx_scale/vpxscale.h" |
| 25 #include "vpx_scale/yv12extend.h" |
| 26 #include "setupintrarecon.h" |
| 24 | 27 |
| 25 #include "setupintrarecon.h" | |
| 26 #include "demode.h" | |
| 27 #include "decodemv.h" | 28 #include "decodemv.h" |
| 28 #include "extend.h" | 29 #include "extend.h" |
| 29 #include "vpx_mem/vpx_mem.h" | 30 #include "vpx_mem/vpx_mem.h" |
| 30 #include "idct.h" | 31 #include "idct.h" |
| 31 #include "dequantize.h" | 32 #include "dequantize.h" |
| 32 #include "predictdc.h" | 33 #include "predictdc.h" |
| 33 #include "threading.h" | 34 #include "threading.h" |
| 34 #include "decoderthreading.h" | 35 #include "decoderthreading.h" |
| 35 #include "dboolhuff.h" | 36 #include "dboolhuff.h" |
| 36 | 37 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 57 r = (rc >> 2); | 58 r = (rc >> 2); |
| 58 c = (rc & 3); | 59 c = (rc & 3); |
| 59 | 60 |
| 60 pc->Y1dequant[Q][r][c] = (short)vp8_ac_yquant(Q); | 61 pc->Y1dequant[Q][r][c] = (short)vp8_ac_yquant(Q); |
| 61 pc->Y2dequant[Q][r][c] = (short)vp8_ac2quant(Q, pc->y2ac_delta_q); | 62 pc->Y2dequant[Q][r][c] = (short)vp8_ac2quant(Q, pc->y2ac_delta_q); |
| 62 pc->UVdequant[Q][r][c] = (short)vp8_ac_uv_quant(Q, pc->uvac_delta_q)
; | 63 pc->UVdequant[Q][r][c] = (short)vp8_ac_uv_quant(Q, pc->uvac_delta_q)
; |
| 63 } | 64 } |
| 64 } | 65 } |
| 65 } | 66 } |
| 66 | 67 |
| 67 static void mb_init_dequantizer(VP8D_COMP *pbi, MACROBLOCKD *xd) | 68 void mb_init_dequantizer(VP8D_COMP *pbi, MACROBLOCKD *xd) |
| 68 { | 69 { |
| 69 int i; | 70 int i; |
| 70 int QIndex; | 71 int QIndex; |
| 71 MB_MODE_INFO *mbmi = &xd->mode_info_context->mbmi; | 72 MB_MODE_INFO *mbmi = &xd->mode_info_context->mbmi; |
| 72 VP8_COMMON *const pc = & pbi->common; | 73 VP8_COMMON *const pc = & pbi->common; |
| 73 | 74 |
| 74 // Decide whether to use the default or alternate baseline Q value. | 75 // Decide whether to use the default or alternate baseline Q value. |
| 75 if (xd->segmentation_enabled) | 76 if (xd->segmentation_enabled) |
| 76 { | 77 { |
| 77 // Abs Value | 78 // Abs Value |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 145 |
| 145 if (mv->row < (xd->mb_to_top_edge - (19 << 3))) | 146 if (mv->row < (xd->mb_to_top_edge - (19 << 3))) |
| 146 mv->row = xd->mb_to_top_edge - (16 << 3); | 147 mv->row = xd->mb_to_top_edge - (16 << 3); |
| 147 else if (mv->row > xd->mb_to_bottom_edge + (18 << 3)) | 148 else if (mv->row > xd->mb_to_bottom_edge + (18 << 3)) |
| 148 mv->row = xd->mb_to_bottom_edge + (16 << 3); | 149 mv->row = xd->mb_to_bottom_edge + (16 << 3); |
| 149 } | 150 } |
| 150 | 151 |
| 151 /* A version of the above function for chroma block MVs.*/ | 152 /* A version of the above function for chroma block MVs.*/ |
| 152 static void clamp_uvmv_to_umv_border(MV *mv, const MACROBLOCKD *xd) | 153 static void clamp_uvmv_to_umv_border(MV *mv, const MACROBLOCKD *xd) |
| 153 { | 154 { |
| 154 if (2*mv->col < (xd->mb_to_left_edge - (19 << 3))) | 155 mv->col = (2*mv->col < (xd->mb_to_left_edge - (19 << 3))) ? (xd->mb_to_left_
edge - (16 << 3)) >> 1 : mv->col; |
| 155 mv->col = (xd->mb_to_left_edge - (16 << 3)) >> 1; | 156 mv->col = (2*mv->col > xd->mb_to_right_edge + (18 << 3)) ? (xd->mb_to_right_
edge + (16 << 3)) >> 1 : mv->col; |
| 156 else if (2*mv->col > xd->mb_to_right_edge + (18 << 3)) | |
| 157 mv->col = (xd->mb_to_right_edge + (16 << 3)) >> 1; | |
| 158 | 157 |
| 159 if (2*mv->row < (xd->mb_to_top_edge - (19 << 3))) | 158 mv->row = (2*mv->row < (xd->mb_to_top_edge - (19 << 3))) ? (xd->mb_to_top_ed
ge - (16 << 3)) >> 1 : mv->row; |
| 160 mv->row = (xd->mb_to_top_edge - (16 << 3)) >> 1; | 159 mv->row = (2*mv->row > xd->mb_to_bottom_edge + (18 << 3)) ? (xd->mb_to_botto
m_edge + (16 << 3)) >> 1 : mv->row; |
| 161 else if (2*mv->row > xd->mb_to_bottom_edge + (18 << 3)) | |
| 162 mv->row = (xd->mb_to_bottom_edge + (16 << 3)) >> 1; | |
| 163 } | 160 } |
| 164 | 161 |
| 165 static void clamp_mvs(MACROBLOCKD *xd) | 162 void clamp_mvs(MACROBLOCKD *xd) |
| 166 { | 163 { |
| 167 if (xd->mode_info_context->mbmi.mode == SPLITMV) | 164 if (xd->mode_info_context->mbmi.mode == SPLITMV) |
| 168 { | 165 { |
| 169 int i; | 166 int i; |
| 170 | 167 |
| 171 for (i=0; i<16; i++) | 168 for (i=0; i<16; i++) |
| 172 clamp_mv_to_umv_border(&xd->block[i].bmi.mv.as_mv, xd); | 169 clamp_mv_to_umv_border(&xd->block[i].bmi.mv.as_mv, xd); |
| 173 for (i=16; i<24; i++) | 170 for (i=16; i<24; i++) |
| 174 clamp_uvmv_to_umv_border(&xd->block[i].bmi.mv.as_mv, xd); | 171 clamp_uvmv_to_umv_border(&xd->block[i].bmi.mv.as_mv, xd); |
| 175 } | 172 } |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 xd->predictor, xd->dst.y_buffer, | 288 xd->predictor, xd->dst.y_buffer, |
| 292 xd->dst.y_stride, xd->eobs); | 289 xd->dst.y_stride, xd->eobs); |
| 293 } | 290 } |
| 294 | 291 |
| 295 DEQUANT_INVOKE (&pbi->dequant, idct_add_uv_block) | 292 DEQUANT_INVOKE (&pbi->dequant, idct_add_uv_block) |
| 296 (xd->qcoeff+16*16, &xd->block[16].dequant[0][0], | 293 (xd->qcoeff+16*16, &xd->block[16].dequant[0][0], |
| 297 xd->predictor+16*16, xd->dst.u_buffer, xd->dst.v_buffer, | 294 xd->predictor+16*16, xd->dst.u_buffer, xd->dst.v_buffer, |
| 298 xd->dst.uv_stride, xd->eobs+16); | 295 xd->dst.uv_stride, xd->eobs+16); |
| 299 } | 296 } |
| 300 | 297 |
| 298 |
| 301 static int get_delta_q(vp8_reader *bc, int prev, int *q_update) | 299 static int get_delta_q(vp8_reader *bc, int prev, int *q_update) |
| 302 { | 300 { |
| 303 int ret_val = 0; | 301 int ret_val = 0; |
| 304 | 302 |
| 305 if (vp8_read_bit(bc)) | 303 if (vp8_read_bit(bc)) |
| 306 { | 304 { |
| 307 ret_val = vp8_read_literal(bc, 4); | 305 ret_val = vp8_read_literal(bc, 4); |
| 308 | 306 |
| 309 if (vp8_read_bit(bc)) | 307 if (vp8_read_bit(bc)) |
| 310 ret_val = -ret_val; | 308 ret_val = -ret_val; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 vp8_decode_macroblock(pbi, xd); | 393 vp8_decode_macroblock(pbi, xd); |
| 396 | 394 |
| 397 | 395 |
| 398 recon_yoffset += 16; | 396 recon_yoffset += 16; |
| 399 recon_uvoffset += 8; | 397 recon_uvoffset += 8; |
| 400 | 398 |
| 401 ++xd->mode_info_context; /* next mb */ | 399 ++xd->mode_info_context; /* next mb */ |
| 402 | 400 |
| 403 xd->above_context++; | 401 xd->above_context++; |
| 404 | 402 |
| 405 pbi->current_mb_col_main = mb_col; | |
| 406 } | 403 } |
| 407 | 404 |
| 408 // adjust to the next row of mbs | 405 // adjust to the next row of mbs |
| 409 vp8_extend_mb_row( | 406 vp8_extend_mb_row( |
| 410 &pc->yv12_fb[dst_fb_idx], | 407 &pc->yv12_fb[dst_fb_idx], |
| 411 xd->dst.y_buffer + 16, xd->dst.u_buffer + 8, xd->dst.v_buffer + 8 | 408 xd->dst.y_buffer + 16, xd->dst.u_buffer + 8, xd->dst.v_buffer + 8 |
| 412 ); | 409 ); |
| 413 | 410 |
| 414 ++xd->mode_info_context; /* skip prediction column */ | 411 ++xd->mode_info_context; /* skip prediction column */ |
| 415 | |
| 416 pbi->last_mb_row_decoded = mb_row; | |
| 417 } | 412 } |
| 418 | 413 |
| 419 | 414 |
| 420 static unsigned int read_partition_size(const unsigned char *cx_size) | 415 static unsigned int read_partition_size(const unsigned char *cx_size) |
| 421 { | 416 { |
| 422 const unsigned int size = | 417 const unsigned int size = |
| 423 cx_size[0] + (cx_size[1] << 8) + (cx_size[2] << 16); | 418 cx_size[0] + (cx_size[1] << 8) + (cx_size[2] << 16); |
| 424 return size; | 419 return size; |
| 425 } | 420 } |
| 426 | 421 |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 "Invalid frame sync code"); | 593 "Invalid frame sync code"); |
| 599 | 594 |
| 600 pc->Width = (data[3] | (data[4] << 8)) & 0x3fff; | 595 pc->Width = (data[3] | (data[4] << 8)) & 0x3fff; |
| 601 pc->horiz_scale = data[4] >> 6; | 596 pc->horiz_scale = data[4] >> 6; |
| 602 pc->Height = (data[5] | (data[6] << 8)) & 0x3fff; | 597 pc->Height = (data[5] | (data[6] << 8)) & 0x3fff; |
| 603 pc->vert_scale = data[6] >> 6; | 598 pc->vert_scale = data[6] >> 6; |
| 604 data += 7; | 599 data += 7; |
| 605 | 600 |
| 606 if (Width != pc->Width || Height != pc->Height) | 601 if (Width != pc->Width || Height != pc->Height) |
| 607 { | 602 { |
| 603 int prev_mb_rows = pc->mb_rows; |
| 604 |
| 608 if (pc->Width <= 0) | 605 if (pc->Width <= 0) |
| 609 { | 606 { |
| 610 pc->Width = Width; | 607 pc->Width = Width; |
| 611 vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME, | 608 vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME, |
| 612 "Invalid frame width"); | 609 "Invalid frame width"); |
| 613 } | 610 } |
| 614 | 611 |
| 615 if (pc->Height <= 0) | 612 if (pc->Height <= 0) |
| 616 { | 613 { |
| 617 pc->Height = Height; | 614 pc->Height = Height; |
| 618 vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME, | 615 vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME, |
| 619 "Invalid frame height"); | 616 "Invalid frame height"); |
| 620 } | 617 } |
| 621 | 618 |
| 622 if (vp8_alloc_frame_buffers(pc, pc->Width, pc->Height)) | 619 if (vp8_alloc_frame_buffers(pc, pc->Width, pc->Height)) |
| 623 vpx_internal_error(&pc->error, VPX_CODEC_MEM_ERROR, | 620 vpx_internal_error(&pc->error, VPX_CODEC_MEM_ERROR, |
| 624 "Failed to allocate frame buffers"); | 621 "Failed to allocate frame buffers"); |
| 622 |
| 623 #if CONFIG_MULTITHREAD |
| 624 if (pbi->b_multithreaded_rd) |
| 625 vp8mt_alloc_temp_buffers(pbi, pc->Width, prev_mb_rows); |
| 626 #endif |
| 625 } | 627 } |
| 626 } | 628 } |
| 627 | 629 |
| 628 if (pc->Width == 0 || pc->Height == 0) | 630 if (pc->Width == 0 || pc->Height == 0) |
| 629 { | 631 { |
| 630 return -1; | 632 return -1; |
| 631 } | 633 } |
| 632 | 634 |
| 633 init_frame(pbi); | 635 init_frame(pbi); |
| 634 | 636 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 *p = (vp8_prob)vp8_read_literal(bc, 8); | 821 *p = (vp8_prob)vp8_read_literal(bc, 8); |
| 820 | 822 |
| 821 } | 823 } |
| 822 } | 824 } |
| 823 } | 825 } |
| 824 | 826 |
| 825 vpx_memcpy(&xd->pre, &pc->yv12_fb[pc->lst_fb_idx], sizeof(YV12_BUFFER_CONFIG
)); | 827 vpx_memcpy(&xd->pre, &pc->yv12_fb[pc->lst_fb_idx], sizeof(YV12_BUFFER_CONFIG
)); |
| 826 vpx_memcpy(&xd->dst, &pc->yv12_fb[pc->new_fb_idx], sizeof(YV12_BUFFER_CONFIG
)); | 828 vpx_memcpy(&xd->dst, &pc->yv12_fb[pc->new_fb_idx], sizeof(YV12_BUFFER_CONFIG
)); |
| 827 | 829 |
| 828 // set up frame new frame for intra coded blocks | 830 // set up frame new frame for intra coded blocks |
| 829 vp8_setup_intra_recon(&pc->yv12_fb[pc->new_fb_idx]); | 831 if (!(pbi->b_multithreaded_rd) || pc->multi_token_partition == ONE_PARTITION
|| !(pc->filter_level)) |
| 832 vp8_setup_intra_recon(&pc->yv12_fb[pc->new_fb_idx]); |
| 830 | 833 |
| 831 vp8_setup_block_dptrs(xd); | 834 vp8_setup_block_dptrs(xd); |
| 832 | 835 |
| 833 vp8_build_block_doffsets(xd); | 836 vp8_build_block_doffsets(xd); |
| 834 | 837 |
| 835 // clear out the coeff buffer | 838 // clear out the coeff buffer |
| 836 vpx_memset(xd->qcoeff, 0, sizeof(xd->qcoeff)); | 839 vpx_memset(xd->qcoeff, 0, sizeof(xd->qcoeff)); |
| 837 | 840 |
| 838 // Read the mb_no_coeff_skip flag | 841 // Read the mb_no_coeff_skip flag |
| 839 pc->mb_no_coeff_skip = (int)vp8_read_bit(bc); | 842 pc->mb_no_coeff_skip = (int)vp8_read_bit(bc); |
| 840 | 843 |
| 841 if (pc->frame_type == KEY_FRAME) | 844 |
| 842 vp8_kfread_modes(pbi); | 845 vp8_decode_mode_mvs(pbi); |
| 843 else | |
| 844 vp8_decode_mode_mvs(pbi); | |
| 845 | 846 |
| 846 vpx_memset(pc->above_context, 0, sizeof(ENTROPY_CONTEXT_PLANES) * pc->mb_col
s); | 847 vpx_memset(pc->above_context, 0, sizeof(ENTROPY_CONTEXT_PLANES) * pc->mb_col
s); |
| 847 | 848 |
| 848 vpx_memcpy(&xd->block[0].bmi, &xd->mode_info_context->bmi[0], sizeof(B_MODE_
INFO)); | 849 vpx_memcpy(&xd->block[0].bmi, &xd->mode_info_context->bmi[0], sizeof(B_MODE_
INFO)); |
| 849 | 850 |
| 850 | |
| 851 if (pbi->b_multithreaded_lf && pc->filter_level != 0) | |
| 852 vp8_start_lfthread(pbi); | |
| 853 | |
| 854 if (pbi->b_multithreaded_rd && pc->multi_token_partition != ONE_PARTITION) | 851 if (pbi->b_multithreaded_rd && pc->multi_token_partition != ONE_PARTITION) |
| 855 { | 852 { |
| 856 vp8_mtdecode_mb_rows(pbi, xd); | 853 vp8mt_decode_mb_rows(pbi, xd); |
| 854 if(pbi->common.filter_level) |
| 855 { |
| 856 //vp8_mt_loop_filter_frame(pbi); //cm, &pbi->mb, cm->filter_level)
; |
| 857 |
| 858 pc->last_frame_type = pc->frame_type; |
| 859 pc->last_filter_type = pc->filter_type; |
| 860 pc->last_sharpness_level = pc->sharpness_level; |
| 861 } |
| 862 vp8_yv12_extend_frame_borders_ptr(&pc->yv12_fb[pc->new_fb_idx]); //cm
->frame_to_show); |
| 857 } | 863 } |
| 858 else | 864 else |
| 859 { | 865 { |
| 860 int ibc = 0; | 866 int ibc = 0; |
| 861 int num_part = 1 << pc->multi_token_partition; | 867 int num_part = 1 << pc->multi_token_partition; |
| 862 | 868 |
| 863 // Decode the individual macro block | 869 // Decode the individual macro block |
| 864 for (mb_row = 0; mb_row < pc->mb_rows; mb_row++) | 870 for (mb_row = 0; mb_row < pc->mb_rows; mb_row++) |
| 865 { | 871 { |
| 866 | 872 |
| 867 if (num_part > 1) | 873 if (num_part > 1) |
| 868 { | 874 { |
| 869 xd->current_bc = & pbi->mbc[ibc]; | 875 xd->current_bc = & pbi->mbc[ibc]; |
| 870 ibc++; | 876 ibc++; |
| 871 | 877 |
| 872 if (ibc == num_part) | 878 if (ibc == num_part) |
| 873 ibc = 0; | 879 ibc = 0; |
| 874 } | 880 } |
| 875 | 881 |
| 876 vp8_decode_mb_row(pbi, pc, mb_row, xd); | 882 vp8_decode_mb_row(pbi, pc, mb_row, xd); |
| 877 } | 883 } |
| 878 | |
| 879 pbi->last_mb_row_decoded = mb_row; | |
| 880 } | 884 } |
| 881 | 885 |
| 882 | 886 |
| 883 stop_token_decoder(pbi); | 887 stop_token_decoder(pbi); |
| 884 | 888 |
| 885 // vpx_log("Decoder: Frame Decoded, Size Roughly:%d bytes \n",bc->pos+pbi->
bc2.pos); | 889 // vpx_log("Decoder: Frame Decoded, Size Roughly:%d bytes \n",bc->pos+pbi->
bc2.pos); |
| 886 | 890 |
| 887 // If this was a kf or Gf note the Q used | 891 // If this was a kf or Gf note the Q used |
| 888 if ((pc->frame_type == KEY_FRAME) || | 892 if ((pc->frame_type == KEY_FRAME) || |
| 889 pc->refresh_golden_frame || pc->refresh_alt_ref_frame) | 893 pc->refresh_golden_frame || pc->refresh_alt_ref_frame) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 901 FILE *f = fopen("decompressor.VP8", "ab"); | 905 FILE *f = fopen("decompressor.VP8", "ab"); |
| 902 unsigned int size = pbi->bc2.pos + pbi->bc.pos + 8; | 906 unsigned int size = pbi->bc2.pos + pbi->bc.pos + 8; |
| 903 fwrite((void *) &size, 4, 1, f); | 907 fwrite((void *) &size, 4, 1, f); |
| 904 fwrite((void *) pbi->Source, size, 1, f); | 908 fwrite((void *) pbi->Source, size, 1, f); |
| 905 fclose(f); | 909 fclose(f); |
| 906 } | 910 } |
| 907 #endif | 911 #endif |
| 908 | 912 |
| 909 return 0; | 913 return 0; |
| 910 } | 914 } |
| OLD | NEW |