diff options
Diffstat (limited to 'vp8/decoder')
-rw-r--r-- | vp8/decoder/dboolhuff.h | 50 | ||||
-rw-r--r-- | vp8/decoder/decodframe.c | 34 | ||||
-rw-r--r-- | vp8/decoder/detokenize.c | 8 | ||||
-rw-r--r-- | vp8/decoder/onyxd_if.c | 15 | ||||
-rw-r--r-- | vp8/decoder/onyxd_int.h | 6 | ||||
-rw-r--r-- | vp8/decoder/threading.c | 50 |
6 files changed, 87 insertions, 76 deletions
diff --git a/vp8/decoder/dboolhuff.h b/vp8/decoder/dboolhuff.h index a83e3f012..5f6b211ea 100644 --- a/vp8/decoder/dboolhuff.h +++ b/vp8/decoder/dboolhuff.h @@ -51,19 +51,26 @@ void vp8dx_bool_decoder_fill(BOOL_DECODER *br); #define VP8DX_BOOL_DECODER_FILL(_count,_value,_bufptr,_bufend) \ do \ { \ - int shift; \ - for(shift = VP8_BD_VALUE_SIZE - 8 - ((_count) + 8); shift >= 0; ) \ + int shift = VP8_BD_VALUE_SIZE - 8 - ((_count) + 8); \ + int loop_end, x; \ + size_t bits_left = ((_bufend)-(_bufptr))*CHAR_BIT; \ + \ + x = shift + CHAR_BIT - bits_left; \ + loop_end = 0; \ + if(x >= 0) \ { \ - if((_bufptr) >= (_bufend)) { \ - (_count) = VP8_LOTS_OF_BITS; \ - break; \ - } \ - (_count) += 8; \ + (_count) += VP8_LOTS_OF_BITS; \ + loop_end = x; \ + if(!bits_left) break; \ + } \ + while(shift >= loop_end) \ + { \ + (_count) += CHAR_BIT; \ (_value) |= (VP8_BD_VALUE)*(_bufptr)++ << shift; \ - shift -= 8; \ + shift -= CHAR_BIT; \ } \ } \ - while(0) + while(0) \ static int vp8dx_decode_bool(BOOL_DECODER *br, int probability) { @@ -119,18 +126,19 @@ static int vp8_decode_value(BOOL_DECODER *br, int bits) static int vp8dx_bool_error(BOOL_DECODER *br) { - /* Check if we have reached the end of the buffer. - * - * Variable 'count' stores the number of bits in the 'value' buffer, - * minus 8. So if count == 8, there are 16 bits available to be read. - * Normally, count is filled with 8 and one byte is filled into the - * value buffer. When we reach the end of the buffer, count is instead - * filled with VP8_LOTS_OF_BITS, 8 of which represent the last 8 real - * bits from the bitstream. So the last bit in the bitstream will be - * represented by count == VP8_LOTS_OF_BITS - 16. - */ - if ((br->count > VP8_BD_VALUE_SIZE) - && (br->count <= VP8_LOTS_OF_BITS - 16)) + /* Check if we have reached the end of the buffer. + * + * Variable 'count' stores the number of bits in the 'value' buffer, minus + * 8. The top byte is part of the algorithm, and the remainder is buffered + * to be shifted into it. So if count == 8, the top 16 bits of 'value' are + * occupied, 8 for the algorithm and 8 in the buffer. + * + * When reading a byte from the user's buffer, count is filled with 8 and + * one byte is filled into the value buffer. When we reach the end of the + * data, count is additionally filled with VP8_LOTS_OF_BITS. So when + * count == VP8_LOTS_OF_BITS - 1, the user's data has been exhausted. + */ + if ((br->count > VP8_BD_VALUE_SIZE) && (br->count < VP8_LOTS_OF_BITS)) { /* We have tried to decode bits after the end of * stream was encountered. diff --git a/vp8/decoder/decodframe.c b/vp8/decoder/decodframe.c index 82841e8b8..a585f774c 100644 --- a/vp8/decoder/decodframe.c +++ b/vp8/decoder/decodframe.c @@ -111,16 +111,17 @@ void mb_init_dequantizer(VP8D_COMP *pbi, MACROBLOCKD *xd) */ static void skip_recon_mb(VP8D_COMP *pbi, MACROBLOCKD *xd) { - if (xd->frame_type == KEY_FRAME || xd->mode_info_context->mbmi.ref_frame == INTRA_FRAME) + if (xd->mode_info_context->mbmi.ref_frame == INTRA_FRAME) { - - vp8_build_intra_predictors_mbuv_s(xd); + RECON_INVOKE(&pbi->common.rtcd.recon, build_intra_predictors_mbuv_s)(xd); RECON_INVOKE(&pbi->common.rtcd.recon, build_intra_predictors_mby_s)(xd); } else { - vp8_build_inter_predictors_mb_s(xd); + vp8_build_inter16x16_predictors_mb(xd, xd->dst.y_buffer, + xd->dst.u_buffer, xd->dst.v_buffer, + xd->dst.y_stride, xd->dst.uv_stride); } } @@ -195,11 +196,15 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd) clamp_mvs(xd); } - xd->mode_info_context->mbmi.dc_diff = 1; - - if (xd->mode_info_context->mbmi.mode != B_PRED && xd->mode_info_context->mbmi.mode != SPLITMV && eobtotal == 0) + eobtotal |= (xd->mode_info_context->mbmi.mode == B_PRED || + xd->mode_info_context->mbmi.mode == SPLITMV); + if (!eobtotal) { - xd->mode_info_context->mbmi.dc_diff = 0; + /* Special case: Force the loopfilter to skip when eobtotal and + * mb_skip_coeff are zero. + * */ + xd->mode_info_context->mbmi.mb_skip_coeff = 1; + skip_recon_mb(pbi, xd); return; } @@ -208,9 +213,9 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd) mb_init_dequantizer(pbi, xd); /* do prediction */ - if (xd->frame_type == KEY_FRAME || xd->mode_info_context->mbmi.ref_frame == INTRA_FRAME) + if (xd->mode_info_context->mbmi.ref_frame == INTRA_FRAME) { - vp8_build_intra_predictors_mbuv(xd); + RECON_INVOKE(&pbi->common.rtcd.recon, build_intra_predictors_mbuv)(xd); if (xd->mode_info_context->mbmi.mode != B_PRED) { @@ -218,6 +223,9 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd) build_intra_predictors_mby)(xd); } else { vp8_intra_prediction_down_copy(xd); + + + } } else @@ -229,6 +237,7 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd) if (xd->mode_info_context->mbmi.mode != B_PRED && xd->mode_info_context->mbmi.mode != SPLITMV) { BLOCKD *b = &xd->block[24]; + DEQUANT_INVOKE(&pbi->dequant, block)(b); /* do 2nd order transform on the dc block */ @@ -255,13 +264,14 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd) xd->predictor, xd->dst.y_buffer, xd->dst.y_stride, xd->eobs, xd->block[24].diff); } - else if ((xd->frame_type == KEY_FRAME || xd->mode_info_context->mbmi.ref_frame == INTRA_FRAME) && xd->mode_info_context->mbmi.mode == B_PRED) + else if (xd->mode_info_context->mbmi.mode == B_PRED) { for (i = 0; i < 16; i++) { BLOCKD *b = &xd->block[i]; - vp8_predict_intra4x4(b, b->bmi.mode, b->predictor); + RECON_INVOKE(RTCD_VTABLE(recon), intra4x4_predict) + (b, b->bmi.mode, b->predictor); if (xd->eobs[i] > 1) { diff --git a/vp8/decoder/detokenize.c b/vp8/decoder/detokenize.c index b2e0819b7..c22e0f28c 100644 --- a/vp8/decoder/detokenize.c +++ b/vp8/decoder/detokenize.c @@ -181,7 +181,7 @@ int vp8_decode_mb_tokens(VP8D_COMP *dx, MACROBLOCKD *x) { ENTROPY_CONTEXT *A = (ENTROPY_CONTEXT *)x->above_context; ENTROPY_CONTEXT *L = (ENTROPY_CONTEXT *)x->left_context; - const VP8_COMMON *const oc = & dx->common; + const FRAME_CONTEXT * const fc = &dx->common.fc; BOOL_DECODER *bc = x->current_bc; @@ -236,7 +236,7 @@ int vp8_decode_mb_tokens(VP8D_COMP *dx, MACROBLOCKD *x) range = bc->range; - coef_probs = oc->fc.coef_probs [type] [ 0 ] [0]; + coef_probs = fc->coef_probs [type] [ 0 ] [0]; BLOCK_LOOP: a = A + vp8_block2above[i]; @@ -348,7 +348,7 @@ BLOCK_FINISHED: type = 0; i = 0; stop = 16; - coef_probs = oc->fc.coef_probs [type] [ 0 ] [0]; + coef_probs = fc->coef_probs [type] [ 0 ] [0]; qcoeff_ptr -= (24*16 + 16); goto BLOCK_LOOP; } @@ -356,7 +356,7 @@ BLOCK_FINISHED: if (i == 16) { type = 2; - coef_probs = oc->fc.coef_probs [type] [ 0 ] [0]; + coef_probs = fc->coef_probs [type] [ 0 ] [0]; stop = 24; goto BLOCK_LOOP; } diff --git a/vp8/decoder/onyxd_if.c b/vp8/decoder/onyxd_if.c index ef2e00d61..1e83ab542 100644 --- a/vp8/decoder/onyxd_if.c +++ b/vp8/decoder/onyxd_if.c @@ -76,7 +76,6 @@ VP8D_PTR vp8dx_create_decompressor(VP8D_CONFIG *oxcf) pbi->common.current_video_frame = 0; pbi->ready_for_new_data = 1; - pbi->CPUFreq = 0; /*vp8_get_processor_freq();*/ #if CONFIG_MULTITHREAD pbi->max_threads = oxcf->max_threads; vp8_decoder_create_threads(pbi); @@ -252,7 +251,6 @@ int vp8dx_receive_compressed_data(VP8D_PTR ptr, unsigned long size, const unsign VP8D_COMP *pbi = (VP8D_COMP *) ptr; VP8_COMMON *cm = &pbi->common; int retcode = 0; - struct vpx_usec_timer timer; /*if(pbi->ready_for_new_data == 0) return -1;*/ @@ -317,8 +315,6 @@ int vp8dx_receive_compressed_data(VP8D_PTR ptr, unsigned long size, const unsign pbi->common.error.setjmp = 1; - vpx_usec_timer_start(&timer); - /*cm->current_video_frame++;*/ pbi->Source = source; pbi->source_sz = size; @@ -379,15 +375,9 @@ int vp8dx_receive_compressed_data(VP8D_PTR ptr, unsigned long size, const unsign if(pbi->common.filter_level) { - struct vpx_usec_timer lpftimer; - vpx_usec_timer_start(&lpftimer); /* Apply the loop filter if appropriate. */ - vp8_loop_filter_frame(cm, &pbi->mb, cm->filter_level); - vpx_usec_timer_mark(&lpftimer); - pbi->time_loop_filtering += vpx_usec_timer_elapsed(&lpftimer); - cm->last_frame_type = cm->frame_type; cm->last_filter_type = cm->filter_type; cm->last_sharpness_level = cm->sharpness_level; @@ -398,11 +388,6 @@ int vp8dx_receive_compressed_data(VP8D_PTR ptr, unsigned long size, const unsign vp8_clear_system_state(); - vpx_usec_timer_mark(&timer); - pbi->decode_microseconds = vpx_usec_timer_elapsed(&timer); - - pbi->time_decoding += pbi->decode_microseconds; - /*vp8_print_modes_and_motion_vectors( cm->mi, cm->mb_rows,cm->mb_cols, cm->current_video_frame);*/ if (cm->show_frame) diff --git a/vp8/decoder/onyxd_int.h b/vp8/decoder/onyxd_int.h index ac1e332e8..9b9175628 100644 --- a/vp8/decoder/onyxd_int.h +++ b/vp8/decoder/onyxd_int.h @@ -81,12 +81,6 @@ typedef struct VP8Decompressor const unsigned char *Source; unsigned int source_sz; - - unsigned int CPUFreq; - unsigned int decode_microseconds; - unsigned int time_decoding; - unsigned int time_loop_filtering; - #if CONFIG_MULTITHREAD /* variable for threading */ diff --git a/vp8/decoder/threading.c b/vp8/decoder/threading.c index 4cc7f534d..9ef85e9cd 100644 --- a/vp8/decoder/threading.c +++ b/vp8/decoder/threading.c @@ -108,21 +108,26 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd, int mb_row, int m clamp_mvs(xd); } - xd->mode_info_context->mbmi.dc_diff = 1; - - if (xd->mode_info_context->mbmi.mode != B_PRED && xd->mode_info_context->mbmi.mode != SPLITMV && eobtotal == 0) + eobtotal |= (xd->mode_info_context->mbmi.mode == B_PRED || + xd->mode_info_context->mbmi.mode == SPLITMV); + if (!eobtotal) { - xd->mode_info_context->mbmi.dc_diff = 0; + /* Special case: Force the loopfilter to skip when eobtotal and + * mb_skip_coeff are zero. + * */ + xd->mode_info_context->mbmi.mb_skip_coeff = 1; /*mt_skip_recon_mb(pbi, xd, mb_row, mb_col);*/ - if (xd->frame_type == KEY_FRAME || xd->mode_info_context->mbmi.ref_frame == INTRA_FRAME) + if (xd->mode_info_context->mbmi.ref_frame == INTRA_FRAME) { vp8mt_build_intra_predictors_mbuv_s(pbi, xd, mb_row, mb_col); vp8mt_build_intra_predictors_mby_s(pbi, xd, mb_row, mb_col); } else { - vp8_build_inter_predictors_mb_s(xd); + vp8_build_inter16x16_predictors_mb(xd, xd->dst.y_buffer, + xd->dst.u_buffer, xd->dst.v_buffer, + xd->dst.y_stride, xd->dst.uv_stride); } return; } @@ -322,6 +327,7 @@ static THREAD_FUNCTION thread_decoding_proc(void *p_data) if (pbi->common.filter_level) { + int skip_lf; if( mb_row != pc->mb_rows-1 ) { /* Save decoded MB last row data for next-row decoding */ @@ -349,6 +355,10 @@ static THREAD_FUNCTION thread_decoding_proc(void *p_data) /* update loopfilter info */ Segment = (alt_flt_enabled) ? xd->mode_info_context->mbmi.segment_id : 0; + skip_lf = (xd->mode_info_context->mbmi.mode != B_PRED && + xd->mode_info_context->mbmi.mode != SPLITMV && + xd->mode_info_context->mbmi.mb_skip_coeff); + filter_level = pbi->mt_baseline_filter_level[Segment]; /* Distance of Mb to the various image edges. * These are specified to 8th pel as they are always compared to values that are in 1/8th pel units @@ -360,17 +370,17 @@ static THREAD_FUNCTION thread_decoding_proc(void *p_data) if (filter_level) { if (mb_col > 0) - pc->lf_mbv(xd->dst.y_buffer, xd->dst.u_buffer, xd->dst.v_buffer, recon_y_stride, recon_uv_stride, &lfi[filter_level], pc->simpler_lpf); + pc->lf_mbv(xd->dst.y_buffer, xd->dst.u_buffer, xd->dst.v_buffer, recon_y_stride, recon_uv_stride, &lfi[filter_level]); - if (xd->mode_info_context->mbmi.dc_diff > 0) - pc->lf_bv(xd->dst.y_buffer, xd->dst.u_buffer, xd->dst.v_buffer, recon_y_stride, recon_uv_stride, &lfi[filter_level], pc->simpler_lpf); + if (!skip_lf) + pc->lf_bv(xd->dst.y_buffer, xd->dst.u_buffer, xd->dst.v_buffer, recon_y_stride, recon_uv_stride, &lfi[filter_level]); /* don't apply across umv border */ if (mb_row > 0) - pc->lf_mbh(xd->dst.y_buffer, xd->dst.u_buffer, xd->dst.v_buffer, recon_y_stride, recon_uv_stride, &lfi[filter_level], pc->simpler_lpf); + pc->lf_mbh(xd->dst.y_buffer, xd->dst.u_buffer, xd->dst.v_buffer, recon_y_stride, recon_uv_stride, &lfi[filter_level]); - if (xd->mode_info_context->mbmi.dc_diff > 0) - pc->lf_bh(xd->dst.y_buffer, xd->dst.u_buffer, xd->dst.v_buffer, recon_y_stride, recon_uv_stride, &lfi[filter_level], pc->simpler_lpf); + if (!skip_lf) + pc->lf_bh(xd->dst.y_buffer, xd->dst.u_buffer, xd->dst.v_buffer, recon_y_stride, recon_uv_stride, &lfi[filter_level]); } } @@ -816,6 +826,7 @@ void vp8mt_decode_mb_rows( VP8D_COMP *pbi, MACROBLOCKD *xd) if (pbi->common.filter_level) { + int skip_lf; /* Save decoded MB last row data for next-row decoding */ if(mb_row != pc->mb_rows-1) { @@ -843,6 +854,9 @@ void vp8mt_decode_mb_rows( VP8D_COMP *pbi, MACROBLOCKD *xd) /* update loopfilter info */ Segment = (alt_flt_enabled) ? xd->mode_info_context->mbmi.segment_id : 0; + skip_lf = (xd->mode_info_context->mbmi.mode != B_PRED && + xd->mode_info_context->mbmi.mode != SPLITMV && + xd->mode_info_context->mbmi.mb_skip_coeff); filter_level = pbi->mt_baseline_filter_level[Segment]; /* Distance of Mb to the various image edges. * These are specified to 8th pel as they are always compared to values that are in 1/8th pel units @@ -854,17 +868,17 @@ void vp8mt_decode_mb_rows( VP8D_COMP *pbi, MACROBLOCKD *xd) if (filter_level) { if (mb_col > 0) - pc->lf_mbv(xd->dst.y_buffer, xd->dst.u_buffer, xd->dst.v_buffer, recon_y_stride, recon_uv_stride, &lfi[filter_level], pc->simpler_lpf); + pc->lf_mbv(xd->dst.y_buffer, xd->dst.u_buffer, xd->dst.v_buffer, recon_y_stride, recon_uv_stride, &lfi[filter_level]); - if (xd->mode_info_context->mbmi.dc_diff > 0) - pc->lf_bv(xd->dst.y_buffer, xd->dst.u_buffer, xd->dst.v_buffer, recon_y_stride, recon_uv_stride, &lfi[filter_level], pc->simpler_lpf); + if (!skip_lf) + pc->lf_bv(xd->dst.y_buffer, xd->dst.u_buffer, xd->dst.v_buffer, recon_y_stride, recon_uv_stride, &lfi[filter_level]); /* don't apply across umv border */ if (mb_row > 0) - pc->lf_mbh(xd->dst.y_buffer, xd->dst.u_buffer, xd->dst.v_buffer, recon_y_stride, recon_uv_stride, &lfi[filter_level], pc->simpler_lpf); + pc->lf_mbh(xd->dst.y_buffer, xd->dst.u_buffer, xd->dst.v_buffer, recon_y_stride, recon_uv_stride, &lfi[filter_level]); - if (xd->mode_info_context->mbmi.dc_diff > 0) - pc->lf_bh(xd->dst.y_buffer, xd->dst.u_buffer, xd->dst.v_buffer, recon_y_stride, recon_uv_stride, &lfi[filter_level], pc->simpler_lpf); + if (!skip_lf) + pc->lf_bh(xd->dst.y_buffer, xd->dst.u_buffer, xd->dst.v_buffer, recon_y_stride, recon_uv_stride, &lfi[filter_level]); } } |