diff options
Diffstat (limited to 'vp9/decoder')
-rw-r--r-- | vp9/decoder/vp9_decodemv.c | 49 | ||||
-rw-r--r-- | vp9/decoder/vp9_decodframe.c | 47 | ||||
-rw-r--r-- | vp9/decoder/vp9_detokenize.c | 36 | ||||
-rw-r--r-- | vp9/decoder/vp9_onyxd_if.c | 19 |
4 files changed, 52 insertions, 99 deletions
diff --git a/vp9/decoder/vp9_decodemv.c b/vp9/decoder/vp9_decodemv.c index 0df2e079f..f1d0e7a79 100644 --- a/vp9/decoder/vp9_decodemv.c +++ b/vp9/decoder/vp9_decodemv.c @@ -98,7 +98,7 @@ static void set_segment_id(VP9_COMMON *cm, MB_MODE_INFO *mbmi, int mb_row, int mb_col, int segment_id) { const int mb_index = mb_row * cm->mb_cols + mb_col; const BLOCK_SIZE_TYPE sb_type = mbmi->sb_type; - if (sb_type) { + if (sb_type > BLOCK_SIZE_MB16X16) { const int bw = 1 << mb_width_log2(sb_type); const int bh = 1 << mb_height_log2(sb_type); const int ymbs = MIN(cm->mb_rows - mb_row, bh); @@ -116,6 +116,17 @@ static void set_segment_id(VP9_COMMON *cm, MB_MODE_INFO *mbmi, } } +static TX_SIZE select_txfm_size(VP9_COMMON *cm, vp9_reader *r, + int allow_16x16, int allow_32x32) { + TX_SIZE txfm_size = vp9_read(r, cm->prob_tx[0]); // TX_4X4 or >TX_4X4 + if (txfm_size != TX_4X4 && allow_16x16) { + txfm_size += vp9_read(r, cm->prob_tx[1]); // TX_8X8 or >TX_8X8 + if (txfm_size != TX_8X8 && allow_32x32) + txfm_size += vp9_read(r, cm->prob_tx[2]); // TX_16X16 or >TX_16X16 + } + return txfm_size; +} + extern const int vp9_i8x8_block[4]; static void kfread_modes(VP9D_COMP *pbi, MODE_INFO *m, int mb_row, int mb_col, @@ -138,7 +149,7 @@ static void kfread_modes(VP9D_COMP *pbi, MODE_INFO *m, m->mbmi.mb_skip_coeff = vp9_read(r, vp9_get_pred_prob(cm, xd, PRED_MBSKIP)); // luma mode - m->mbmi.mode = m->mbmi.sb_type ? + m->mbmi.mode = m->mbmi.sb_type > BLOCK_SIZE_MB16X16 ? read_kf_sb_ymode(r, cm->sb_kf_ymode_prob[cm->kf_ymode_probs_index]): read_kf_mb_ymode(r, cm->kf_ymode_prob[cm->kf_ymode_probs_index]); @@ -174,15 +185,11 @@ static void kfread_modes(VP9D_COMP *pbi, MODE_INFO *m, } if (cm->txfm_mode == TX_MODE_SELECT && - m->mbmi.mb_skip_coeff == 0 && + !m->mbmi.mb_skip_coeff && m->mbmi.mode <= I8X8_PRED) { - // FIXME(rbultje) code ternary symbol once all experiments are merged - m->mbmi.txfm_size = vp9_read(r, cm->prob_tx[0]); - if (m->mbmi.txfm_size != TX_4X4 && m->mbmi.mode != I8X8_PRED) { - m->mbmi.txfm_size += vp9_read(r, cm->prob_tx[1]); - if (m->mbmi.txfm_size != TX_8X8 && m->mbmi.sb_type >= BLOCK_SIZE_SB32X32) - m->mbmi.txfm_size += vp9_read(r, cm->prob_tx[2]); - } + const int allow_16x16 = m->mbmi.mode != I8X8_PRED; + const int allow_32x32 = m->mbmi.sb_type >= BLOCK_SIZE_SB32X32; + m->mbmi.txfm_size = select_txfm_size(cm, r, allow_16x16, allow_32x32); } else if (cm->txfm_mode >= ALLOW_32X32 && m->mbmi.sb_type >= BLOCK_SIZE_SB32X32) { m->mbmi.txfm_size = TX_32X32; @@ -195,6 +202,7 @@ static void kfread_modes(VP9D_COMP *pbi, MODE_INFO *m, } } + static int read_nmv_component(vp9_reader *r, int rv, const nmv_component *mvcomp) { @@ -601,7 +609,8 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi, const int use_prev_in_find_mv_refs = cm->width == cm->last_width && cm->height == cm->last_height && - !cm->error_resilient_mode; + !cm->error_resilient_mode && + cm->last_show_frame; int mb_to_left_edge, mb_to_right_edge, mb_to_top_edge, mb_to_bottom_edge; @@ -668,7 +677,8 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi, if (vp9_segfeature_active(xd, mbmi->segment_id, SEG_LVL_SKIP)) { mbmi->mode = ZEROMV; } else { - mbmi->mode = mbmi->sb_type ? read_sb_mv_ref(r, mv_ref_p) + mbmi->mode = mbmi->sb_type > BLOCK_SIZE_MB16X16 ? + read_sb_mv_ref(r, mv_ref_p) : read_mv_ref(r, mv_ref_p); vp9_accum_mv_refs(cm, mbmi->mode, mbmi->mb_mode_context[ref_frame]); } @@ -932,7 +942,7 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi, // required for left and above block mv mv0->as_int = 0; - if (mbmi->sb_type) { + if (mbmi->sb_type > BLOCK_SIZE_MB16X16) { mbmi->mode = read_sb_ymode(r, cm->fc.sb_ymode_prob); cm->fc.sb_ymode_counts[mbmi->mode]++; } else { @@ -979,14 +989,9 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi, ((mbmi->ref_frame == INTRA_FRAME && mbmi->mode <= I8X8_PRED) || (mbmi->ref_frame != INTRA_FRAME && !(mbmi->mode == SPLITMV && mbmi->partitioning == PARTITIONING_4X4)))) { - // FIXME(rbultje) code ternary symbol once all experiments are merged - mbmi->txfm_size = vp9_read(r, cm->prob_tx[0]); - if (mbmi->txfm_size != TX_4X4 && mbmi->mode != I8X8_PRED && - mbmi->mode != SPLITMV) { - mbmi->txfm_size += vp9_read(r, cm->prob_tx[1]); - if (mbmi->sb_type >= BLOCK_SIZE_SB32X32 && mbmi->txfm_size != TX_8X8) - mbmi->txfm_size += vp9_read(r, cm->prob_tx[2]); - } + const int allow_16x16 = mbmi->mode != I8X8_PRED && mbmi->mode != SPLITMV; + const int allow_32x32 = mbmi->sb_type >= BLOCK_SIZE_SB32X32; + mbmi->txfm_size = select_txfm_size(cm, r, allow_16x16, allow_32x32); } else if (mbmi->sb_type >= BLOCK_SIZE_SB32X32 && cm->txfm_mode >= ALLOW_32X32) { mbmi->txfm_size = TX_32X32; @@ -1035,7 +1040,7 @@ void vp9_decode_mb_mode_mv(VP9D_COMP* const pbi, cm->active_ref_scale); } - if (mbmi->sb_type) { + if (mbmi->sb_type > BLOCK_SIZE_MB16X16) { const int bw = 1 << mb_width_log2(mbmi->sb_type); const int bh = 1 << mb_height_log2(mbmi->sb_type); const int y_mbs = MIN(bh, cm->mb_rows - mb_row); diff --git a/vp9/decoder/vp9_decodframe.c b/vp9/decoder/vp9_decodframe.c index 91aca6f54..c1c0d23ab 100644 --- a/vp9/decoder/vp9_decodframe.c +++ b/vp9/decoder/vp9_decodframe.c @@ -663,7 +663,7 @@ static void decode_mb(VP9D_COMP *pbi, MACROBLOCKD *xd, const MB_PREDICTION_MODE mode = xd->mode_info_context->mbmi.mode; const int tx_size = xd->mode_info_context->mbmi.txfm_size; - assert(!xd->mode_info_context->mbmi.sb_type); + assert(xd->mode_info_context->mbmi.sb_type == BLOCK_SIZE_MB16X16); //mode = xd->mode_info_context->mbmi.mode; if (pbi->common.frame_type != KEY_FRAME) @@ -771,11 +771,6 @@ static int get_delta_q(vp9_reader *r, int *dq) { return old_value != *dq; } -#ifdef PACKET_TESTING -#include <stdio.h> -FILE *vpxlog = 0; -#endif - static void set_offsets(VP9D_COMP *pbi, BLOCK_SIZE_TYPE bsize, int mb_row, int mb_col) { const int bh = 1 << mb_height_log2(bsize); @@ -1001,7 +996,7 @@ static void read_zpc_probs_common(VP9_COMMON *cm, static void read_zpc_probs(VP9_COMMON *cm, vp9_reader* bc) { read_zpc_probs_common(cm, bc, TX_4X4); - if (cm->txfm_mode != ONLY_4X4) + if (cm->txfm_mode > ONLY_4X4) read_zpc_probs_common(cm, bc, TX_8X8); if (cm->txfm_mode > ALLOW_8X8) read_zpc_probs_common(cm, bc, TX_16X16); @@ -1055,7 +1050,7 @@ static void read_coef_probs(VP9D_COMP *pbi, vp9_reader *r) { read_coef_probs_common(pbi, r, fc->coef_probs_4x4, TX_4X4); - if (mode != ONLY_4X4) + if (mode > ONLY_4X4) read_coef_probs_common(pbi, r, fc->coef_probs_8x8, TX_8X8); if (mode > ALLOW_8X8) @@ -1078,10 +1073,12 @@ static void update_frame_size(VP9D_COMP *pbi) { memset(cm->mip, 0, (cm->mb_cols + 1) * (cm->mb_rows + 1) * sizeof(MODE_INFO)); vp9_update_mode_info_border(cm, cm->mip); + vp9_update_mode_info_border(cm, cm->prev_mip); cm->mi = cm->mip + cm->mode_info_stride + 1; cm->prev_mi = cm->prev_mip + cm->mode_info_stride + 1; vp9_update_mode_info_in_image(cm, cm->mi); + vp9_update_mode_info_in_image(cm, cm->prev_mi); } static void setup_segmentation(VP9_COMMON *pc, MACROBLOCKD *xd, vp9_reader *r) { @@ -1421,7 +1418,7 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { const uint8_t *data = pbi->source; const uint8_t *data_end = data + pbi->source_sz; size_t first_partition_size = 0; - int i, corrupt_tokens = 0; + int i; // printf("Decoding frame %d\n", pc->current_video_frame); @@ -1481,6 +1478,8 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { pc->clamp_type = (CLAMP_TYPE)vp9_read_bit(&header_bc); pc->error_resilient_mode = vp9_read_bit(&header_bc); + xd->lossless = vp9_read_bit(&header_bc); + setup_loopfilter(pc, xd, &header_bc); // Dummy read for now @@ -1549,7 +1548,6 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { setup_pred_probs(pc, &header_bc); - xd->lossless = vp9_read_bit(&header_bc); pc->txfm_mode = xd->lossless ? ONLY_4X4 : read_txfm_mode(&header_bc); if (pc->txfm_mode == TX_MODE_SELECT) { pc->prob_tx[0] = vp9_read_prob(&header_bc); @@ -1571,16 +1569,6 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { } #endif - if (0) { - FILE *z = fopen("decodestats.stt", "a"); - fprintf(z, "%6d F:%d,R:%d,Q:%d\n", - pc->current_video_frame, - pc->frame_type, - pbi->refresh_frame_flags, - pc->base_qindex); - fclose(z); - } - update_frame_context(pbi); read_coef_probs(pbi, &header_bc); @@ -1614,7 +1602,6 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { vp9_decode_mode_mvs_init(pbi, &header_bc); decode_tiles(pbi, data, first_partition_size, &header_bc, &residual_bc); - corrupt_tokens |= xd->corrupted; // keep track of the last coded dimensions pc->last_width = pc->width; @@ -1624,7 +1611,7 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { // 1. Check first boolean decoder for errors. // 2. Check the macroblock information pc->yv12_fb[pc->new_fb_idx].corrupted = vp9_reader_has_error(&header_bc) | - corrupt_tokens; + xd->corrupted; if (!pbi->decoded_key_frame) { if (pc->frame_type == KEY_FRAME && !pc->yv12_fb[pc->new_fb_idx].corrupted) @@ -1634,15 +1621,13 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { "A stream must start with a complete key frame"); } + // Adaptation if (!pc->error_resilient_mode && !pc->frame_parallel_decoding_mode) { vp9_adapt_coef_probs(pc); #if CONFIG_CODE_ZEROGROUP vp9_adapt_zpc_probs(pc); #endif - } - - if (pc->frame_type != KEY_FRAME) { - if (!pc->error_resilient_mode && !pc->frame_parallel_decoding_mode) { + if (pc->frame_type != KEY_FRAME) { vp9_adapt_mode_probs(pc); vp9_adapt_nmv_probs(pc, xd->allow_high_precision_mv); vp9_adapt_mode_context(&pbi->common); @@ -1654,16 +1639,6 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { sizeof(pc->fc)); } -#ifdef PACKET_TESTING - { - FILE *f = fopen("decompressor.VP8", "ab"); - unsigned int size = residual_bc.pos + header_bc.pos + 8; - fwrite((void *) &size, 4, 1, f); - fwrite((void *) pbi->Source, size, 1, f); - fclose(f); - } -#endif - *p_data_end = vp9_reader_find_end(&residual_bc); return 0; } diff --git a/vp9/decoder/vp9_detokenize.c b/vp9/decoder/vp9_detokenize.c index 18ef51ace..02ee7c3d6 100644 --- a/vp9/decoder/vp9_detokenize.c +++ b/vp9/decoder/vp9_detokenize.c @@ -165,17 +165,7 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd, case TX_4X4: { tx_type = (type == PLANE_TYPE_Y_WITH_DC) ? get_tx_type_4x4(xd, block_idx) : DCT_DCT; - switch (tx_type) { - default: - scan = vp9_default_zig_zag1d_4x4; - break; - case ADST_DCT: - scan = vp9_row_scan_4x4; - break; - case DCT_ADST: - scan = vp9_col_scan_4x4; - break; - } + scan = get_scan_4x4(tx_type); above_ec = A0[aidx] != 0; left_ec = L0[lidx] != 0; coef_probs = fc->coef_probs_4x4; @@ -194,17 +184,7 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd, const int y = block_idx - x; tx_type = (type == PLANE_TYPE_Y_WITH_DC) ? get_tx_type_8x8(xd, y + (x >> 1)) : DCT_DCT; - switch (tx_type) { - default: - scan = vp9_default_zig_zag1d_8x8; - break; - case ADST_DCT: - scan = vp9_row_scan_8x8; - break; - case DCT_ADST: - scan = vp9_col_scan_8x8; - break; - } + scan = get_scan_8x8(tx_type); coef_probs = fc->coef_probs_8x8; coef_counts = fc->coef_counts_8x8; above_ec = (A0[aidx] + A0[aidx + 1]) != 0; @@ -223,17 +203,7 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd, const int y = block_idx - x; tx_type = (type == PLANE_TYPE_Y_WITH_DC) ? get_tx_type_16x16(xd, y + (x >> 2)) : DCT_DCT; - switch (tx_type) { - default: - scan = vp9_default_zig_zag1d_16x16; - break; - case ADST_DCT: - scan = vp9_row_scan_16x16; - break; - case DCT_ADST: - scan = vp9_col_scan_16x16; - break; - } + scan = get_scan_16x16(tx_type); coef_probs = fc->coef_probs_16x16; coef_counts = fc->coef_counts_16x16; if (type == PLANE_TYPE_UV) { diff --git a/vp9/decoder/vp9_onyxd_if.c b/vp9/decoder/vp9_onyxd_if.c index b64b7e4dc..a07a8fd45 100644 --- a/vp9/decoder/vp9_onyxd_if.c +++ b/vp9/decoder/vp9_onyxd_if.c @@ -365,20 +365,23 @@ int vp9_receive_compressed_data(VP9D_PTR ptr, vp9_clear_system_state(); + cm->last_show_frame = cm->show_frame; if (cm->show_frame) { - vpx_memcpy(cm->prev_mip, cm->mip, - (cm->mb_cols + 1) * (cm->mb_rows + 1)* sizeof(MODE_INFO)); - } else { - vpx_memset(cm->prev_mip, 0, - (cm->mb_cols + 1) * (cm->mb_rows + 1)* sizeof(MODE_INFO)); + // current mip will be the prev_mip for the next frame + MODE_INFO *temp = cm->prev_mip; + cm->prev_mip = cm->mip; + cm->mip = temp; + + // update the upper left visible macroblock ptrs + cm->mi = cm->mip + cm->mode_info_stride + 1; + cm->prev_mi = cm->prev_mip + cm->mode_info_stride + 1; + + cm->current_video_frame++; } /*vp9_print_modes_and_motion_vectors(cm->mi, cm->mb_rows,cm->mb_cols, cm->current_video_frame);*/ - if (cm->show_frame) - cm->current_video_frame++; - pbi->ready_for_new_data = 0; pbi->last_time_stamp = time_stamp; pbi->source_sz = 0; |