diff options
author | hkuang <hkuang@google.com> | 2013-09-16 15:09:58 -0700 |
---|---|---|
committer | Hangyu Kuang <hkuang@google.com> | 2013-09-17 22:05:28 +0000 |
commit | 1184aebb761cbeac9124c37189a80a1a58f04b6b (patch) | |
tree | b1ce6b3d29c43ffd22eb18999c5c3bad26513a48 /libvpx/vp9/decoder/vp9_decodframe.c | |
parent | f3bed9137f66ef693bd406e43b17e9a1114f1e14 (diff) | |
download | android_external_libvpx-1184aebb761cbeac9124c37189a80a1a58f04b6b.tar.gz android_external_libvpx-1184aebb761cbeac9124c37189a80a1a58f04b6b.tar.bz2 android_external_libvpx-1184aebb761cbeac9124c37189a80a1a58f04b6b.zip |
Roll latest libvpx into Android.
The latest libvpx has more neon optimizations and a lot of
algorithm optimizations which make the vp9 decode much more faster.
bug:10804666
Change-Id: I75eaacea57ecc7542a780be778f0e9e157978524
(cherry picked from commit 3df0563f1b24dac6c0bd122fc922a48211269061)
Diffstat (limited to 'libvpx/vp9/decoder/vp9_decodframe.c')
-rw-r--r-- | libvpx/vp9/decoder/vp9_decodframe.c | 352 |
1 files changed, 170 insertions, 182 deletions
diff --git a/libvpx/vp9/decoder/vp9_decodframe.c b/libvpx/vp9/decoder/vp9_decodframe.c index feb6024..34ed0c7 100644 --- a/libvpx/vp9/decoder/vp9_decodframe.c +++ b/libvpx/vp9/decoder/vp9_decodframe.c @@ -63,44 +63,40 @@ static void read_tx_probs(struct tx_probs *tx_probs, vp9_reader *r) { for (i = 0; i < TX_SIZE_CONTEXTS; ++i) for (j = 0; j < TX_SIZES - 3; ++j) - if (vp9_read(r, VP9_MODE_UPDATE_PROB)) + if (vp9_read(r, MODE_UPDATE_PROB)) vp9_diff_update_prob(r, &tx_probs->p8x8[i][j]); for (i = 0; i < TX_SIZE_CONTEXTS; ++i) for (j = 0; j < TX_SIZES - 2; ++j) - if (vp9_read(r, VP9_MODE_UPDATE_PROB)) + if (vp9_read(r, MODE_UPDATE_PROB)) vp9_diff_update_prob(r, &tx_probs->p16x16[i][j]); for (i = 0; i < TX_SIZE_CONTEXTS; ++i) for (j = 0; j < TX_SIZES - 1; ++j) - if (vp9_read(r, VP9_MODE_UPDATE_PROB)) + if (vp9_read(r, MODE_UPDATE_PROB)) vp9_diff_update_prob(r, &tx_probs->p32x32[i][j]); } -static void init_dequantizer(VP9_COMMON *cm, MACROBLOCKD *xd) { +static void setup_plane_dequants(VP9_COMMON *cm, MACROBLOCKD *xd, int q_index) { int i; - const int segment_id = xd->mode_info_context->mbmi.segment_id; - xd->q_index = vp9_get_qindex(xd, segment_id, cm->base_qindex); + xd->plane[0].dequant = cm->y_dequant[q_index]; - xd->plane[0].dequant = cm->y_dequant[xd->q_index]; for (i = 1; i < MAX_MB_PLANE; i++) - xd->plane[i].dequant = cm->uv_dequant[xd->q_index]; + xd->plane[i].dequant = cm->uv_dequant[q_index]; } -static void decode_block(int plane, int block, BLOCK_SIZE_TYPE bsize, - int ss_txfrm_size, void *arg) { +static void decode_block(int plane, int block, BLOCK_SIZE plane_bsize, + TX_SIZE tx_size, void *arg) { MACROBLOCKD* const xd = arg; - struct macroblockd_plane *pd = &xd->plane[plane]; - int16_t* const qcoeff = BLOCK_OFFSET(pd->qcoeff, block, 16); + struct macroblockd_plane *const pd = &xd->plane[plane]; + int16_t* const qcoeff = BLOCK_OFFSET(pd->qcoeff, block); const int stride = pd->dst.stride; const int eob = pd->eobs[block]; - const int raster_block = txfrm_block_to_raster_block(xd, bsize, plane, - block, ss_txfrm_size); - uint8_t* const dst = raster_block_offset_uint8(xd, bsize, plane, - raster_block, + const int raster_block = txfrm_block_to_raster_block(plane_bsize, tx_size, + block); + uint8_t* const dst = raster_block_offset_uint8(plane_bsize, raster_block, pd->dst.buf, stride); - - switch (ss_txfrm_size / 2) { + switch (tx_size) { case TX_4X4: { const TX_TYPE tx_type = get_tx_type_4x4(pd->plane_type, xd, raster_block); if (tx_type == DCT_DCT) @@ -120,87 +116,78 @@ static void decode_block(int plane, int block, BLOCK_SIZE_TYPE bsize, case TX_32X32: vp9_idct_add_32x32(qcoeff, dst, stride, eob); break; + default: + assert(!"Invalid transform size"); } } -static void decode_block_intra(int plane, int block, BLOCK_SIZE_TYPE bsize, - int ss_txfrm_size, void *arg) { +static void decode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize, + TX_SIZE tx_size, void *arg) { MACROBLOCKD* const xd = arg; - struct macroblockd_plane *pd = &xd->plane[plane]; - MODE_INFO *const mi = xd->mode_info_context; - - const int raster_block = txfrm_block_to_raster_block(xd, bsize, plane, - block, ss_txfrm_size); - uint8_t* const dst = raster_block_offset_uint8(xd, bsize, plane, - raster_block, + struct macroblockd_plane *const pd = &xd->plane[plane]; + MODE_INFO *const mi = xd->this_mi; + const int raster_block = txfrm_block_to_raster_block(plane_bsize, tx_size, + block); + uint8_t* const dst = raster_block_offset_uint8(plane_bsize, raster_block, pd->dst.buf, pd->dst.stride); - const TX_SIZE tx_size = (TX_SIZE)(ss_txfrm_size / 2); - int b_mode; - int plane_b_size; - const int tx_ib = raster_block >> tx_size; - const int mode = plane == 0 ? mi->mbmi.mode - : mi->mbmi.uv_mode; - - if (plane == 0 && mi->mbmi.sb_type < BLOCK_8X8) { - assert(bsize == BLOCK_8X8); - b_mode = mi->bmi[raster_block].as_mode; - } else { - b_mode = mode; - } + const MB_PREDICTION_MODE mode = (plane == 0) + ? ((mi->mbmi.sb_type < BLOCK_8X8) ? mi->bmi[raster_block].as_mode + : mi->mbmi.mode) + : mi->mbmi.uv_mode; if (xd->mb_to_right_edge < 0 || xd->mb_to_bottom_edge < 0) - extend_for_intra(xd, plane, block, bsize, ss_txfrm_size); + extend_for_intra(xd, plane_bsize, plane, block, tx_size); - plane_b_size = b_width_log2(bsize) - pd->subsampling_x; - vp9_predict_intra_block(xd, tx_ib, plane_b_size, tx_size, b_mode, - dst, pd->dst.stride, - dst, pd->dst.stride); + vp9_predict_intra_block(xd, raster_block >> tx_size, + b_width_log2(plane_bsize), tx_size, mode, + dst, pd->dst.stride, dst, pd->dst.stride); - // Early exit if there are no coefficients - if (mi->mbmi.mb_skip_coeff) - return; - - decode_block(plane, block, bsize, ss_txfrm_size, arg); + if (!mi->mbmi.skip_coeff) + decode_block(plane, block, plane_bsize, tx_size, arg); } -static int decode_tokens(VP9D_COMP *pbi, BLOCK_SIZE_TYPE bsize, vp9_reader *r) { +static int decode_tokens(VP9D_COMP *pbi, BLOCK_SIZE bsize, vp9_reader *r) { + VP9_COMMON *const cm = &pbi->common; MACROBLOCKD *const xd = &pbi->mb; + MB_MODE_INFO *const mbmi = &xd->this_mi->mbmi; - if (xd->mode_info_context->mbmi.mb_skip_coeff) { - vp9_reset_sb_tokens_context(xd, bsize); + if (mbmi->skip_coeff) { + reset_skip_context(xd, bsize); return -1; } else { - if (xd->seg.enabled) - init_dequantizer(&pbi->common, xd); + if (cm->seg.enabled) + setup_plane_dequants(cm, xd, vp9_get_qindex(&cm->seg, mbmi->segment_id, + cm->base_qindex)); // TODO(dkovalev) if (!vp9_reader_has_error(r)) return vp9_decode_tokens(pbi, r, bsize); } } -static void set_offsets(VP9D_COMP *pbi, BLOCK_SIZE_TYPE bsize, +static void set_offsets(VP9D_COMP *pbi, BLOCK_SIZE bsize, int mi_row, int mi_col) { VP9_COMMON *const cm = &pbi->common; MACROBLOCKD *const xd = &pbi->mb; - const int bh = 1 << mi_height_log2(bsize); - const int bw = 1 << mi_width_log2(bsize); - const int mi_idx = mi_row * cm->mode_info_stride + mi_col; - int i; + const int bh = num_8x8_blocks_high_lookup[bsize]; + const int bw = num_8x8_blocks_wide_lookup[bsize]; + const int offset = mi_row * cm->mode_info_stride + mi_col; + + xd->mode_info_stride = cm->mode_info_stride; + + xd->mi_8x8 = cm->mi_grid_visible + offset; + xd->prev_mi_8x8 = cm->prev_mi_grid_visible + offset; + + // we are using the mode info context stream here + xd->this_mi = + xd->mi_8x8[0] = xd->mic_stream_ptr; + xd->this_mi->mbmi.sb_type = bsize; + xd->mic_stream_ptr++; - xd->mode_info_context = cm->mi + mi_idx; - xd->mode_info_context->mbmi.sb_type = bsize; // Special case: if prev_mi is NULL, the previous mode info context // cannot be used. - xd->prev_mode_info_context = cm->prev_mi ? cm->prev_mi + mi_idx : NULL; - - for (i = 0; i < MAX_MB_PLANE; i++) { - struct macroblockd_plane *pd = &xd->plane[i]; - pd->above_context = cm->above_context[i] + - (mi_col * 2 >> pd->subsampling_x); - pd->left_context = cm->left_context[i] + - (((mi_row * 2) & 15) >> pd->subsampling_y); - } + xd->last_mi = cm->prev_mi ? xd->prev_mi_8x8[0] : NULL; + set_skip_context(cm, xd, mi_row, mi_col); set_partition_seg_context(cm, xd, mi_row, mi_col); // Distance of Mb to the various image edges. These are specified to 8th pel @@ -213,17 +200,21 @@ static void set_offsets(VP9D_COMP *pbi, BLOCK_SIZE_TYPE bsize, static void set_ref(VP9D_COMP *pbi, int i, int mi_row, int mi_col) { VP9_COMMON *const cm = &pbi->common; MACROBLOCKD *const xd = &pbi->mb; - MB_MODE_INFO *const mbmi = &xd->mode_info_context->mbmi; - const int ref = mbmi->ref_frame[i] - 1; - + MB_MODE_INFO *const mbmi = &xd->this_mi->mbmi; + const int ref = mbmi->ref_frame[i] - LAST_FRAME; const YV12_BUFFER_CONFIG *cfg = &cm->yv12_fb[cm->active_ref_idx[ref]]; - xd->scale_factor[i] = cm->active_ref_scale[ref]; - setup_pre_planes(xd, i, cfg, mi_row, mi_col, &xd->scale_factor[i]); + const struct scale_factors *sf = &cm->active_ref_scale[ref]; + if (!vp9_is_valid_scale(sf)) + vpx_internal_error(&cm->error, VPX_CODEC_UNSUP_BITSTREAM, + "Invalid scale factors"); + + xd->scale_factor[i] = *sf; + setup_pre_planes(xd, i, cfg, mi_row, mi_col, sf); xd->corrupted |= cfg->corrupted; } static void decode_modes_b(VP9D_COMP *pbi, int mi_row, int mi_col, - vp9_reader *r, BLOCK_SIZE_TYPE bsize) { + vp9_reader *r, BLOCK_SIZE bsize) { VP9_COMMON *const cm = &pbi->common; MACROBLOCKD *const xd = &pbi->mb; const int less8x8 = bsize < BLOCK_8X8; @@ -240,7 +231,7 @@ static void decode_modes_b(VP9D_COMP *pbi, int mi_row, int mi_col, bsize = BLOCK_8X8; // Has to be called after set_offsets - mbmi = &xd->mode_info_context->mbmi; + mbmi = &xd->this_mi->mbmi; if (!is_inter_block(mbmi)) { // Intra reconstruction @@ -251,7 +242,7 @@ static void decode_modes_b(VP9D_COMP *pbi, int mi_row, int mi_col, int eobtotal; set_ref(pbi, 0, mi_row, mi_col); - if (mbmi->ref_frame[1] > INTRA_FRAME) + if (has_second_ref(mbmi)) set_ref(pbi, 1, mi_row, mi_col); vp9_setup_interp_filters(xd, mbmi->interp_filter, cm); @@ -264,7 +255,7 @@ static void decode_modes_b(VP9D_COMP *pbi, int mi_row, int mi_col, assert(mbmi->sb_type == bsize); if (eobtotal == 0) // skip loopfilter - vp9_set_pred_flag_mbskip(cm, bsize, mi_row, mi_col, 1); + vp9_set_pred_flag_mbskip(xd, bsize, 1); else if (eobtotal > 0) foreach_transformed_block(xd, bsize, decode_block, xd); } @@ -273,14 +264,14 @@ static void decode_modes_b(VP9D_COMP *pbi, int mi_row, int mi_col, } static void decode_modes_sb(VP9D_COMP *pbi, int mi_row, int mi_col, - vp9_reader* r, BLOCK_SIZE_TYPE bsize) { - VP9_COMMON *const pc = &pbi->common; + vp9_reader* r, BLOCK_SIZE bsize) { + VP9_COMMON *const cm = &pbi->common; MACROBLOCKD *const xd = &pbi->mb; - int bs = (1 << mi_width_log2(bsize)) / 2, n; + const int hbs = num_8x8_blocks_wide_lookup[bsize] / 2; PARTITION_TYPE partition = PARTITION_NONE; - BLOCK_SIZE_TYPE subsize; + BLOCK_SIZE subsize; - if (mi_row >= pc->mi_rows || mi_col >= pc->mi_cols) + if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) return; if (bsize < BLOCK_8X8) { @@ -288,24 +279,25 @@ static void decode_modes_sb(VP9D_COMP *pbi, int mi_row, int mi_col, return; } else { int pl; - const int idx = check_bsize_coverage(pc, mi_row, mi_col, bsize); - set_partition_seg_context(pc, xd, mi_row, mi_col); + const int idx = check_bsize_coverage(hbs, cm->mi_rows, cm->mi_cols, + mi_row, mi_col); + set_partition_seg_context(cm, xd, mi_row, mi_col); pl = partition_plane_context(xd, bsize); if (idx == 0) partition = treed_read(r, vp9_partition_tree, - pc->fc.partition_prob[pc->frame_type][pl]); + cm->fc.partition_prob[cm->frame_type][pl]); else if (idx > 0 && - !vp9_read(r, pc->fc.partition_prob[pc->frame_type][pl][idx])) + !vp9_read(r, cm->fc.partition_prob[cm->frame_type][pl][idx])) partition = (idx == 1) ? PARTITION_HORZ : PARTITION_VERT; else partition = PARTITION_SPLIT; - pc->counts.partition[pl][partition]++; + cm->counts.partition[pl][partition]++; } subsize = get_subsize(bsize, partition); - *(get_sb_index(xd, subsize)) = 0; + *get_sb_index(xd, subsize) = 0; switch (partition) { case PARTITION_NONE: @@ -313,23 +305,24 @@ static void decode_modes_sb(VP9D_COMP *pbi, int mi_row, int mi_col, break; case PARTITION_HORZ: decode_modes_b(pbi, mi_row, mi_col, r, subsize); - *(get_sb_index(xd, subsize)) = 1; - if (mi_row + bs < pc->mi_rows) - decode_modes_b(pbi, mi_row + bs, mi_col, r, subsize); + *get_sb_index(xd, subsize) = 1; + if (mi_row + hbs < cm->mi_rows) + decode_modes_b(pbi, mi_row + hbs, mi_col, r, subsize); break; case PARTITION_VERT: decode_modes_b(pbi, mi_row, mi_col, r, subsize); - *(get_sb_index(xd, subsize)) = 1; - if (mi_col + bs < pc->mi_cols) - decode_modes_b(pbi, mi_row, mi_col + bs, r, subsize); + *get_sb_index(xd, subsize) = 1; + if (mi_col + hbs < cm->mi_cols) + decode_modes_b(pbi, mi_row, mi_col + hbs, r, subsize); break; - case PARTITION_SPLIT: + case PARTITION_SPLIT: { + int n; for (n = 0; n < 4; n++) { - int j = n >> 1, i = n & 0x01; - *(get_sb_index(xd, subsize)) = n; - decode_modes_sb(pbi, mi_row + j * bs, mi_col + i * bs, r, subsize); + const int j = n >> 1, i = n & 1; + *get_sb_index(xd, subsize) = n; + decode_modes_sb(pbi, mi_row + j * hbs, mi_col + i * hbs, r, subsize); } - break; + } break; default: assert(!"Invalid partition type"); } @@ -337,7 +330,7 @@ static void decode_modes_sb(VP9D_COMP *pbi, int mi_row, int mi_col, // update partition context if (bsize >= BLOCK_8X8 && (bsize == BLOCK_8X8 || partition != PARTITION_SPLIT)) { - set_partition_seg_context(pc, xd, mi_row, mi_col); + set_partition_seg_context(cm, xd, mi_row, mi_col); update_partition_context(xd, subsize, bsize); } } @@ -345,18 +338,18 @@ static void decode_modes_sb(VP9D_COMP *pbi, int mi_row, int mi_col, static void setup_token_decoder(VP9D_COMP *pbi, const uint8_t *data, size_t read_size, vp9_reader *r) { - VP9_COMMON *pc = &pbi->common; + VP9_COMMON *cm = &pbi->common; const uint8_t *data_end = pbi->source + pbi->source_sz; // Validate the calculated partition length. If the buffer // described by the partition can't be fully read, then restrict // it to the portion that can be (for EC mode) or throw an error. if (!read_is_valid(data, read_size, data_end)) - vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME, + vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, "Truncated packet or corrupt tile length"); if (vp9_reader_init(r, data, read_size)) - vpx_internal_error(&pc->error, VPX_CODEC_MEM_ERROR, + vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, "Failed to allocate bool decoder %d", 1); } @@ -470,8 +463,7 @@ static void setup_loopfilter(struct loopfilter *lf, static int read_delta_q(struct vp9_read_bit_buffer *rb, int *delta_q) { const int old = *delta_q; - if (vp9_rb_read_bit(rb)) - *delta_q = vp9_rb_read_signed_literal(rb, 4); + *delta_q = vp9_rb_read_bit(rb) ? vp9_rb_read_signed_literal(rb, 4) : 0; return old != *delta_q; } @@ -498,8 +490,11 @@ static void setup_quantization(VP9D_COMP *pbi, struct vp9_read_bit_buffer *rb) { static INTERPOLATIONFILTERTYPE read_interp_filter_type( struct vp9_read_bit_buffer *rb) { + const INTERPOLATIONFILTERTYPE literal_to_type[] = { EIGHTTAP_SMOOTH, + EIGHTTAP, + EIGHTTAP_SHARP }; return vp9_rb_read_bit(rb) ? SWITCHABLE - : vp9_rb_read_literal(rb, 2); + : literal_to_type[vp9_rb_read_literal(rb, 2)]; } static void read_frame_size(struct vp9_read_bit_buffer *rb, @@ -552,8 +547,8 @@ static void setup_frame_size(VP9D_COMP *pbi, struct vp9_read_bit_buffer *rb) { int width, height; read_frame_size(rb, &width, &height); - setup_display_size(&pbi->common, rb); apply_frame_size(pbi, width, height); + setup_display_size(&pbi->common, rb); } static void setup_frame_size_with_refs(VP9D_COMP *pbi, @@ -579,35 +574,36 @@ static void setup_frame_size_with_refs(VP9D_COMP *pbi, vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, "Referenced frame with invalid size"); - setup_display_size(cm, rb); apply_frame_size(pbi, width, height); + setup_display_size(cm, rb); } static void decode_tile(VP9D_COMP *pbi, vp9_reader *r) { const int num_threads = pbi->oxcf.max_threads; - VP9_COMMON *const pc = &pbi->common; + VP9_COMMON *const cm = &pbi->common; int mi_row, mi_col; + YV12_BUFFER_CONFIG *const fb = &cm->yv12_fb[cm->new_fb_idx]; if (pbi->do_loopfilter_inline) { if (num_threads > 1) { LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1; - lf_data->frame_buffer = &pbi->common.yv12_fb[pbi->common.new_fb_idx]; - lf_data->cm = pc; + lf_data->frame_buffer = fb; + lf_data->cm = cm; lf_data->xd = pbi->mb; + lf_data->stop = 0; lf_data->y_only = 0; } - vp9_loop_filter_frame_init(pc, &pbi->mb, pbi->mb.lf.filter_level); + vp9_loop_filter_frame_init(cm, cm->lf.filter_level); } - for (mi_row = pc->cur_tile_mi_row_start; mi_row < pc->cur_tile_mi_row_end; + for (mi_row = cm->cur_tile_mi_row_start; mi_row < cm->cur_tile_mi_row_end; mi_row += MI_BLOCK_SIZE) { // For a SB there are 2 left contexts, each pertaining to a MB row within - vpx_memset(&pc->left_context, 0, sizeof(pc->left_context)); - vpx_memset(pc->left_seg_context, 0, sizeof(pc->left_seg_context)); - for (mi_col = pc->cur_tile_mi_col_start; mi_col < pc->cur_tile_mi_col_end; - mi_col += MI_BLOCK_SIZE) { + vp9_zero(cm->left_context); + vp9_zero(cm->left_seg_context); + for (mi_col = cm->cur_tile_mi_col_start; mi_col < cm->cur_tile_mi_col_end; + mi_col += MI_BLOCK_SIZE) decode_modes_sb(pbi, mi_row, mi_col, r, BLOCK_64X64); - } if (pbi->do_loopfilter_inline) { // delay the loopfilter by 1 macroblock row. @@ -617,28 +613,32 @@ static void decode_tile(VP9D_COMP *pbi, vp9_reader *r) { if (num_threads > 1) { LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1; + // decoding has completed: finish up the loop filter in this thread. + if (mi_row + MI_BLOCK_SIZE >= cm->cur_tile_mi_row_end) continue; + vp9_worker_sync(&pbi->lf_worker); lf_data->start = lf_start; lf_data->stop = mi_row; pbi->lf_worker.hook = vp9_loop_filter_worker; vp9_worker_launch(&pbi->lf_worker); } else { - YV12_BUFFER_CONFIG *const fb = - &pbi->common.yv12_fb[pbi->common.new_fb_idx]; - vp9_loop_filter_rows(fb, pc, &pbi->mb, lf_start, mi_row, 0); + vp9_loop_filter_rows(fb, cm, &pbi->mb, lf_start, mi_row, 0); } } } if (pbi->do_loopfilter_inline) { - YV12_BUFFER_CONFIG *const fb = &pbi->common.yv12_fb[pbi->common.new_fb_idx]; + int lf_start; if (num_threads > 1) { - // TODO(jzern): since the loop filter is delayed one mb row, this will be - // forced to wait for the last row scheduled in the for loop. + LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1; + vp9_worker_sync(&pbi->lf_worker); + lf_start = lf_data->stop; + } else { + lf_start = mi_row - MI_BLOCK_SIZE; } - vp9_loop_filter_rows(fb, pc, &pbi->mb, - mi_row - MI_BLOCK_SIZE, pc->mi_rows, 0); + vp9_loop_filter_rows(fb, cm, &pbi->mb, + lf_start, cm->mi_rows, 0); } } @@ -661,20 +661,20 @@ static void setup_tile_info(VP9_COMMON *cm, struct vp9_read_bit_buffer *rb) { static const uint8_t *decode_tiles(VP9D_COMP *pbi, const uint8_t *data) { vp9_reader residual_bc; - VP9_COMMON *const pc = &pbi->common; + VP9_COMMON *const cm = &pbi->common; const uint8_t *const data_end = pbi->source + pbi->source_sz; - const int aligned_mi_cols = mi_cols_aligned_to_sb(pc->mi_cols); - const int tile_cols = 1 << pc->log2_tile_cols; - const int tile_rows = 1 << pc->log2_tile_rows; + const int aligned_mi_cols = mi_cols_aligned_to_sb(cm->mi_cols); + const int tile_cols = 1 << cm->log2_tile_cols; + const int tile_rows = 1 << cm->log2_tile_rows; int tile_row, tile_col; // Note: this memset assumes above_context[0], [1] and [2] // are allocated as part of the same buffer. - vpx_memset(pc->above_context[0], 0, - sizeof(ENTROPY_CONTEXT) * 2 * MAX_MB_PLANE * aligned_mi_cols); + vpx_memset(cm->above_context[0], 0, + sizeof(ENTROPY_CONTEXT) * MAX_MB_PLANE * (2 * aligned_mi_cols)); - vpx_memset(pc->above_seg_context, 0, + vpx_memset(cm->above_seg_context, 0, sizeof(PARTITION_CONTEXT) * aligned_mi_cols); if (pbi->oxcf.inv_tile_order) { @@ -699,9 +699,9 @@ static const uint8_t *decode_tiles(VP9D_COMP *pbi, const uint8_t *data) { } for (tile_row = 0; tile_row < tile_rows; tile_row++) { - vp9_get_tile_row_offsets(pc, tile_row); + vp9_get_tile_row_offsets(cm, tile_row); for (tile_col = tile_cols - 1; tile_col >= 0; tile_col--) { - vp9_get_tile_col_offsets(pc, tile_col); + vp9_get_tile_col_offsets(cm, tile_col); setup_token_decoder(pbi, data_ptr2[tile_row][tile_col], data_end - data_ptr2[tile_row][tile_col], &residual_bc); @@ -715,16 +715,16 @@ static const uint8_t *decode_tiles(VP9D_COMP *pbi, const uint8_t *data) { int has_more; for (tile_row = 0; tile_row < tile_rows; tile_row++) { - vp9_get_tile_row_offsets(pc, tile_row); + vp9_get_tile_row_offsets(cm, tile_row); for (tile_col = 0; tile_col < tile_cols; tile_col++) { size_t size; - vp9_get_tile_col_offsets(pc, tile_col); + vp9_get_tile_col_offsets(cm, tile_col); has_more = tile_col < tile_cols - 1 || tile_row < tile_rows - 1; if (has_more) { if (!read_is_valid(data, 4, data_end)) - vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME, + vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, "Truncated packet or corrupt tile length"); size = read_be32(data); @@ -810,7 +810,7 @@ static size_t read_uncompressed_header(VP9D_COMP *pbi, int frame_to_show = cm->ref_frame_map[vp9_rb_read_literal(rb, 3)]; ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->new_fb_idx, frame_to_show); pbi->refresh_frame_flags = 0; - xd->lf.filter_level = 0; + cm->lf.filter_level = 0; return 0; } @@ -861,7 +861,7 @@ static size_t read_uncompressed_header(VP9D_COMP *pbi, pbi->refresh_frame_flags = vp9_rb_read_literal(rb, NUM_REF_FRAMES); setup_frame_size(pbi, rb); } else { - pbi->refresh_frame_flags = vp9_rb_read_literal(rb, NUM_REF_FRAMES); + pbi->refresh_frame_flags = vp9_rb_read_literal(rb, NUM_REF_FRAMES); for (i = 0; i < ALLOWED_REFS_PER_FRAME; ++i) { const int ref = vp9_rb_read_literal(rb, NUM_REF_FRAMES_LOG2); @@ -892,11 +892,11 @@ static size_t read_uncompressed_header(VP9D_COMP *pbi, cm->frame_context_idx = vp9_rb_read_literal(rb, NUM_FRAME_CONTEXTS_LOG2); if (cm->frame_type == KEY_FRAME || cm->error_resilient_mode || cm->intra_only) - vp9_setup_past_independence(cm, xd); + vp9_setup_past_independence(cm); - setup_loopfilter(&xd->lf, rb); + setup_loopfilter(&cm->lf, rb); setup_quantization(pbi, rb); - setup_segmentation(&xd->seg, rb); + setup_segmentation(&cm->seg, rb); setup_tile_info(cm, rb); @@ -937,17 +937,17 @@ void vp9_init_dequantizer(VP9_COMMON *cm) { int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { int i; - VP9_COMMON *const pc = &pbi->common; + VP9_COMMON *const cm = &pbi->common; MACROBLOCKD *const xd = &pbi->mb; const uint8_t *data = pbi->source; const uint8_t *data_end = pbi->source + pbi->source_sz; struct vp9_read_bit_buffer rb = { data, data_end, 0, - pc, error_handler }; + cm, error_handler }; const size_t first_partition_size = read_uncompressed_header(pbi, &rb); - const int keyframe = pc->frame_type == KEY_FRAME; - YV12_BUFFER_CONFIG *new_fb = &pc->yv12_fb[pc->new_fb_idx]; + const int keyframe = cm->frame_type == KEY_FRAME; + YV12_BUFFER_CONFIG *new_fb = &cm->yv12_fb[cm->new_fb_idx]; if (!first_partition_size) { // showing a frame directly @@ -958,51 +958,39 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { xd->corrupted = 0; new_fb->corrupted = 0; pbi->do_loopfilter_inline = - (pc->log2_tile_rows | pc->log2_tile_cols) == 0 && pbi->mb.lf.filter_level; + (cm->log2_tile_rows | cm->log2_tile_cols) == 0 && cm->lf.filter_level; if (!pbi->decoded_key_frame && !keyframe) return -1; if (!read_is_valid(data, first_partition_size, data_end)) - vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME, + vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, "Truncated packet or corrupt header length"); - xd->mode_info_context = pc->mi; - xd->prev_mode_info_context = pc->prev_mi; - xd->mode_info_stride = pc->mode_info_stride; - - init_dequantizer(pc, &pbi->mb); + setup_plane_dequants(cm, &pbi->mb, cm->base_qindex); - if (!keyframe) - vp9_setup_interp_filters(xd, pc->mcomp_filter_type, pc); + xd->mi_8x8 = cm->mi_grid_visible; + xd->mic_stream_ptr = cm->mi; + xd->mode_info_stride = cm->mode_info_stride; - pc->fc = pc->frame_contexts[pc->frame_context_idx]; + cm->fc = cm->frame_contexts[cm->frame_context_idx]; - vp9_zero(pc->counts); - - // Initialize xd pointers. Any reference should do for xd->pre, so use 0. - setup_pre_planes(xd, 0, &pc->yv12_fb[pc->active_ref_idx[0]], 0, 0, NULL); - setup_dst_planes(xd, new_fb, 0, 0); + vp9_zero(cm->counts); new_fb->corrupted |= read_compressed_header(pbi, data, first_partition_size); - // Create the segmentation map structure and set to 0 - if (!pc->last_frame_seg_map) - CHECK_MEM_ERROR(pc, pc->last_frame_seg_map, - vpx_calloc((pc->mi_rows * pc->mi_cols), 1)); - - setup_block_dptrs(xd, pc->subsampling_x, pc->subsampling_y); + setup_block_dptrs(xd, cm->subsampling_x, cm->subsampling_y); // clear out the coeff buffer for (i = 0; i < MAX_MB_PLANE; ++i) vp9_zero(xd->plane[i].qcoeff); - set_prev_mi(pc); + set_prev_mi(cm); *p_data_end = decode_tiles(pbi, data + first_partition_size); - pc->last_width = pc->width; - pc->last_height = pc->height; + cm->last_width = cm->width; + cm->last_height = cm->height; new_fb->corrupted |= xd->corrupted; @@ -1010,21 +998,21 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { if (keyframe && !new_fb->corrupted) pbi->decoded_key_frame = 1; else - vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME, + vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, "A stream must start with a complete key frame"); } - if (!pc->error_resilient_mode && !pc->frame_parallel_decoding_mode) { - vp9_adapt_coef_probs(pc); + if (!cm->error_resilient_mode && !cm->frame_parallel_decoding_mode) { + vp9_adapt_coef_probs(cm); - if (!keyframe && !pc->intra_only) { - vp9_adapt_mode_probs(pc); - vp9_adapt_mv_probs(pc, xd->allow_high_precision_mv); + if (!keyframe && !cm->intra_only) { + vp9_adapt_mode_probs(cm); + vp9_adapt_mv_probs(cm, xd->allow_high_precision_mv); } } - if (pc->refresh_frame_context) - pc->frame_contexts[pc->frame_context_idx] = pc->fc; + if (cm->refresh_frame_context) + cm->frame_contexts[cm->frame_context_idx] = cm->fc; return 0; } |