Commit 144f49c6 authored by Dmitry Kovalev's avatar Dmitry Kovalev
Browse files

Simple cleanup inside vp9_decodframe.c and vp9_entropymode.c.

Change-Id: I62dde981f5201c5fbc22001609ee4b5fd0a9bdf5
parent 276a1106
...@@ -578,93 +578,102 @@ static void update_mode_probs(int n_modes, ...@@ -578,93 +578,102 @@ static void update_mode_probs(int n_modes,
// #define MODE_COUNT_TESTING // #define MODE_COUNT_TESTING
void vp9_adapt_mode_probs(VP9_COMMON *cm) { void vp9_adapt_mode_probs(VP9_COMMON *cm) {
int i; int i;
FRAME_CONTEXT *fc = &cm->fc;
#ifdef MODE_COUNT_TESTING #ifdef MODE_COUNT_TESTING
int t; int t;
printf("static const unsigned int\nymode_counts" printf("static const unsigned int\nymode_counts"
"[VP9_YMODES] = {\n"); "[VP9_YMODES] = {\n");
for (t = 0; t < VP9_YMODES; ++t) printf("%d, ", cm->fc.ymode_counts[t]); for (t = 0; t < VP9_YMODES; ++t)
printf("%d, ", fc->ymode_counts[t]);
printf("};\n"); printf("};\n");
printf("static const unsigned int\nuv_mode_counts" printf("static const unsigned int\nuv_mode_counts"
"[VP9_YMODES] [VP9_UV_MODES] = {\n"); "[VP9_YMODES] [VP9_UV_MODES] = {\n");
for (i = 0; i < VP9_YMODES; ++i) { for (i = 0; i < VP9_YMODES; ++i) {
printf(" {"); printf(" {");
for (t = 0; t < VP9_UV_MODES; ++t) printf("%d, ", cm->fc.uv_mode_counts[i][t]); for (t = 0; t < VP9_UV_MODES; ++t)
printf("%d, ", fc->uv_mode_counts[i][t]);
printf("},\n"); printf("},\n");
} }
printf("};\n"); printf("};\n");
printf("static const unsigned int\nbmode_counts" printf("static const unsigned int\nbmode_counts"
"[VP9_NKF_BINTRAMODES] = {\n"); "[VP9_NKF_BINTRAMODES] = {\n");
for (t = 0; t < VP9_NKF_BINTRAMODES; ++t) for (t = 0; t < VP9_NKF_BINTRAMODES; ++t)
printf("%d, ", cm->fc.bmode_counts[t]); printf("%d, ", fc->bmode_counts[t]);
printf("};\n"); printf("};\n");
printf("static const unsigned int\ni8x8_mode_counts" printf("static const unsigned int\ni8x8_mode_counts"
"[VP9_I8X8_MODES] = {\n"); "[VP9_I8X8_MODES] = {\n");
for (t = 0; t < VP9_I8X8_MODES; ++t) printf("%d, ", cm->fc.i8x8_mode_counts[t]); for (t = 0; t < VP9_I8X8_MODES; ++t)
printf("%d, ", fc->i8x8_mode_counts[t]);
printf("};\n"); printf("};\n");
printf("static const unsigned int\nsub_mv_ref_counts" printf("static const unsigned int\nsub_mv_ref_counts"
"[SUBMVREF_COUNT] [VP9_SUBMVREFS] = {\n"); "[SUBMVREF_COUNT] [VP9_SUBMVREFS] = {\n");
for (i = 0; i < SUBMVREF_COUNT; ++i) { for (i = 0; i < SUBMVREF_COUNT; ++i) {
printf(" {"); printf(" {");
for (t = 0; t < VP9_SUBMVREFS; ++t) printf("%d, ", cm->fc.sub_mv_ref_counts[i][t]); for (t = 0; t < VP9_SUBMVREFS; ++t)
printf("%d, ", fc->sub_mv_ref_counts[i][t]);
printf("},\n"); printf("},\n");
} }
printf("};\n"); printf("};\n");
printf("static const unsigned int\nmbsplit_counts" printf("static const unsigned int\nmbsplit_counts"
"[VP9_NUMMBSPLITS] = {\n"); "[VP9_NUMMBSPLITS] = {\n");
for (t = 0; t < VP9_NUMMBSPLITS; ++t) printf("%d, ", cm->fc.mbsplit_counts[t]); for (t = 0; t < VP9_NUMMBSPLITS; ++t)
printf("%d, ", fc->mbsplit_counts[t]);
printf("};\n"); printf("};\n");
#if CONFIG_COMP_INTERINTRA_PRED #if CONFIG_COMP_INTERINTRA_PRED
printf("static const unsigned int\ninterintra_counts" printf("static const unsigned int\ninterintra_counts"
"[2] = {\n"); "[2] = {\n");
for (t = 0; t < 2; ++t) printf("%d, ", cm->fc.interintra_counts[t]); for (t = 0; t < 2; ++t)
printf("%d, ", fc->interintra_counts[t]);
printf("};\n"); printf("};\n");
#endif #endif
#endif #endif
update_mode_probs(VP9_YMODES, vp9_ymode_tree, update_mode_probs(VP9_YMODES, vp9_ymode_tree,
cm->fc.ymode_counts, cm->fc.pre_ymode_prob, fc->ymode_counts, fc->pre_ymode_prob,
cm->fc.ymode_prob, 0); fc->ymode_prob, 0);
update_mode_probs(VP9_I32X32_MODES, vp9_sb_ymode_tree, update_mode_probs(VP9_I32X32_MODES, vp9_sb_ymode_tree,
cm->fc.sb_ymode_counts, cm->fc.pre_sb_ymode_prob, fc->sb_ymode_counts, fc->pre_sb_ymode_prob,
cm->fc.sb_ymode_prob, 0); fc->sb_ymode_prob, 0);
for (i = 0; i < VP9_YMODES; ++i) {
for (i = 0; i < VP9_YMODES; ++i)
update_mode_probs(VP9_UV_MODES, vp9_uv_mode_tree, update_mode_probs(VP9_UV_MODES, vp9_uv_mode_tree,
cm->fc.uv_mode_counts[i], cm->fc.pre_uv_mode_prob[i], fc->uv_mode_counts[i], fc->pre_uv_mode_prob[i],
cm->fc.uv_mode_prob[i], 0); fc->uv_mode_prob[i], 0);
}
update_mode_probs(VP9_NKF_BINTRAMODES, vp9_bmode_tree, update_mode_probs(VP9_NKF_BINTRAMODES, vp9_bmode_tree,
cm->fc.bmode_counts, cm->fc.pre_bmode_prob, fc->bmode_counts, fc->pre_bmode_prob,
cm->fc.bmode_prob, 0); fc->bmode_prob, 0);
update_mode_probs(VP9_I8X8_MODES, update_mode_probs(VP9_I8X8_MODES,
vp9_i8x8_mode_tree, cm->fc.i8x8_mode_counts, vp9_i8x8_mode_tree, fc->i8x8_mode_counts,
cm->fc.pre_i8x8_mode_prob, cm->fc.i8x8_mode_prob, 0); fc->pre_i8x8_mode_prob, fc->i8x8_mode_prob, 0);
for (i = 0; i < SUBMVREF_COUNT; ++i) {
for (i = 0; i < SUBMVREF_COUNT; ++i)
update_mode_probs(VP9_SUBMVREFS, update_mode_probs(VP9_SUBMVREFS,
vp9_sub_mv_ref_tree, cm->fc.sub_mv_ref_counts[i], vp9_sub_mv_ref_tree, fc->sub_mv_ref_counts[i],
cm->fc.pre_sub_mv_ref_prob[i], cm->fc.sub_mv_ref_prob[i], fc->pre_sub_mv_ref_prob[i], fc->sub_mv_ref_prob[i],
LEFT4X4); LEFT4X4);
}
update_mode_probs(VP9_NUMMBSPLITS, vp9_mbsplit_tree, update_mode_probs(VP9_NUMMBSPLITS, vp9_mbsplit_tree,
cm->fc.mbsplit_counts, cm->fc.pre_mbsplit_prob, fc->mbsplit_counts, fc->pre_mbsplit_prob,
cm->fc.mbsplit_prob, 0); fc->mbsplit_prob, 0);
#if CONFIG_COMP_INTERINTRA_PRED #if CONFIG_COMP_INTERINTRA_PRED
if (cm->use_interintra) { if (cm->use_interintra) {
int factor, interintra_prob, count; int factor, interintra_prob, count;
interintra_prob = get_binary_prob(cm->fc.interintra_counts[0], interintra_prob = get_binary_prob(fc->interintra_counts[0],
cm->fc.interintra_counts[1]); fc->interintra_counts[1]);
count = cm->fc.interintra_counts[0] + cm->fc.interintra_counts[1]; count = fc->interintra_counts[0] + fc->interintra_counts[1];
count = count > MODE_COUNT_SAT ? MODE_COUNT_SAT : count; count = count > MODE_COUNT_SAT ? MODE_COUNT_SAT : count;
factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT); factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT);
cm->fc.interintra_prob = weighted_prob(cm->fc.pre_interintra_prob, fc->interintra_prob = weighted_prob(fc->pre_interintra_prob,
interintra_prob, factor); interintra_prob, factor);
} }
#endif #endif
for (i = 0; i < PARTITION_PLANES; i++) for (i = 0; i < PARTITION_PLANES; i++)
update_mode_probs(PARTITION_TYPES, vp9_partition_tree, update_mode_probs(PARTITION_TYPES, vp9_partition_tree,
cm->fc.partition_counts[i], cm->fc.pre_partition_prob[i], fc->partition_counts[i], fc->pre_partition_prob[i],
cm->fc.partition_prob[i], 0); fc->partition_prob[i], 0);
} }
static void set_default_lf_deltas(MACROBLOCKD *xd) { static void set_default_lf_deltas(MACROBLOCKD *xd) {
...@@ -691,7 +700,7 @@ void vp9_setup_past_independence(VP9_COMMON *cm, MACROBLOCKD *xd) { ...@@ -691,7 +700,7 @@ void vp9_setup_past_independence(VP9_COMMON *cm, MACROBLOCKD *xd) {
if (cm->last_frame_seg_map) if (cm->last_frame_seg_map)
vpx_memset(cm->last_frame_seg_map, 0, (cm->mb_rows * cm->mb_cols)); vpx_memset(cm->last_frame_seg_map, 0, (cm->mb_rows * cm->mb_cols));
/* reset the mode ref deltas for loop filter */ // Reset the mode ref deltas for loop filter
vpx_memset(xd->last_ref_lf_deltas, 0, sizeof(xd->last_ref_lf_deltas)); vpx_memset(xd->last_ref_lf_deltas, 0, sizeof(xd->last_ref_lf_deltas));
vpx_memset(xd->last_mode_lf_deltas, 0, sizeof(xd->last_mode_lf_deltas)); vpx_memset(xd->last_mode_lf_deltas, 0, sizeof(xd->last_mode_lf_deltas));
set_default_lf_deltas(xd); set_default_lf_deltas(xd);
...@@ -701,14 +710,14 @@ void vp9_setup_past_independence(VP9_COMMON *cm, MACROBLOCKD *xd) { ...@@ -701,14 +710,14 @@ void vp9_setup_past_independence(VP9_COMMON *cm, MACROBLOCKD *xd) {
vp9_default_bmode_probs(cm->fc.bmode_prob); vp9_default_bmode_probs(cm->fc.bmode_prob);
vp9_kf_default_bmode_probs(cm->kf_bmode_prob); vp9_kf_default_bmode_probs(cm->kf_bmode_prob);
vp9_init_mv_probs(cm); vp9_init_mv_probs(cm);
// To force update of the sharpness // To force update of the sharpness
cm->last_sharpness_level = -1; cm->last_sharpness_level = -1;
vp9_init_mode_contexts(cm); vp9_init_mode_contexts(cm);
for (i = 0; i < NUM_FRAME_CONTEXTS; i++) { for (i = 0; i < NUM_FRAME_CONTEXTS; i++)
vpx_memcpy(&cm->frame_contexts[i], &cm->fc, sizeof(cm->fc)); vpx_memcpy(&cm->frame_contexts[i], &cm->fc, sizeof(cm->fc));
}
vpx_memset(cm->prev_mip, 0, vpx_memset(cm->prev_mip, 0,
(cm->mb_cols + 1) * (cm->mb_rows + 1)* sizeof(MODE_INFO)); (cm->mb_cols + 1) * (cm->mb_rows + 1)* sizeof(MODE_INFO));
......
...@@ -37,8 +37,6 @@ ...@@ -37,8 +37,6 @@
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
#define COEFCOUNT_TESTING
// #define DEC_DEBUG // #define DEC_DEBUG
#ifdef DEC_DEBUG #ifdef DEC_DEBUG
int dec_debug = 0; int dec_debug = 0;
...@@ -58,11 +56,20 @@ static int read_is_valid(const uint8_t *start, size_t len, ...@@ -58,11 +56,20 @@ static int read_is_valid(const uint8_t *start, size_t len,
return start + len > start && start + len <= end; return start + len > start && start + len <= end;
} }
static TXFM_MODE read_txfm_mode(vp9_reader *r) { static void setup_txfm_mode(VP9_COMMON *pc, int lossless, vp9_reader *r) {
TXFM_MODE mode = vp9_read_literal(r, 2); if (lossless) {
if (mode == ALLOW_32X32) pc->txfm_mode = ONLY_4X4;
mode += vp9_read_bit(r); } else {
return mode; pc->txfm_mode = vp9_read_literal(r, 2);
if (pc->txfm_mode == ALLOW_32X32)
pc->txfm_mode += vp9_read_bit(r);
if (pc->txfm_mode == TX_MODE_SELECT) {
pc->prob_tx[0] = vp9_read_prob(r);
pc->prob_tx[1] = vp9_read_prob(r);
pc->prob_tx[2] = vp9_read_prob(r);
}
}
} }
static int get_unsigned_bits(unsigned int num_values) { static int get_unsigned_bits(unsigned int num_values) {
...@@ -165,10 +172,11 @@ void vp9_init_de_quantizer(VP9D_COMP *pbi) { ...@@ -165,10 +172,11 @@ void vp9_init_de_quantizer(VP9D_COMP *pbi) {
VP9_COMMON *const pc = &pbi->common; VP9_COMMON *const pc = &pbi->common;
for (q = 0; q < QINDEX_RANGE; q++) { for (q = 0; q < QINDEX_RANGE; q++) {
// DC value
pc->y_dequant[q][0] = (int16_t)vp9_dc_quant(q, pc->y_dc_delta_q); pc->y_dequant[q][0] = (int16_t)vp9_dc_quant(q, pc->y_dc_delta_q);
pc->uv_dequant[q][0] = (int16_t)vp9_dc_uv_quant(q, pc->uv_dc_delta_q); pc->uv_dequant[q][0] = (int16_t)vp9_dc_uv_quant(q, pc->uv_dc_delta_q);
/* all the ac values =; */ // AC values
for (i = 1; i < 16; i++) { for (i = 1; i < 16; i++) {
const int rc = vp9_default_zig_zag1d_4x4[i]; const int rc = vp9_default_zig_zag1d_4x4[i];
...@@ -954,7 +962,6 @@ static void init_frame(VP9D_COMP *pbi) { ...@@ -954,7 +962,6 @@ static void init_frame(VP9D_COMP *pbi) {
xd->frame_type = pc->frame_type; xd->frame_type = pc->frame_type;
xd->mode_info_context->mbmi.mode = DC_PRED; xd->mode_info_context->mbmi.mode = DC_PRED;
xd->mode_info_stride = pc->mode_info_stride; xd->mode_info_stride = pc->mode_info_stride;
xd->corrupted = 0;
} }
#if CONFIG_CODE_ZEROGROUP #if CONFIG_CODE_ZEROGROUP
...@@ -1088,57 +1095,58 @@ static void setup_segmentation(VP9_COMMON *pc, MACROBLOCKD *xd, vp9_reader *r) { ...@@ -1088,57 +1095,58 @@ static void setup_segmentation(VP9_COMMON *pc, MACROBLOCKD *xd, vp9_reader *r) {
xd->update_mb_segmentation_data = 0; xd->update_mb_segmentation_data = 0;
xd->segmentation_enabled = vp9_read_bit(r); xd->segmentation_enabled = vp9_read_bit(r);
if (xd->segmentation_enabled) { if (!xd->segmentation_enabled)
// Segmentation map update return;
xd->update_mb_segmentation_map = vp9_read_bit(r);
if (xd->update_mb_segmentation_map) { // Segmentation map update
for (i = 0; i < MB_FEATURE_TREE_PROBS; i++) xd->update_mb_segmentation_map = vp9_read_bit(r);
xd->mb_segment_tree_probs[i] = vp9_read_bit(r) ? vp9_read_prob(r) if (xd->update_mb_segmentation_map) {
: MAX_PROB; for (i = 0; i < MB_FEATURE_TREE_PROBS; i++)
xd->mb_segment_tree_probs[i] = vp9_read_bit(r) ? vp9_read_prob(r)
pc->temporal_update = vp9_read_bit(r); : MAX_PROB;
if (pc->temporal_update) {
const vp9_prob *p = xd->mb_segment_tree_probs; pc->temporal_update = vp9_read_bit(r);
vp9_prob *mispred_p = xd->mb_segment_mispred_tree_probs; if (pc->temporal_update) {
const vp9_prob *p = xd->mb_segment_tree_probs;
const int c0 = p[0] * p[1]; vp9_prob *mispred_p = xd->mb_segment_mispred_tree_probs;
const int c1 = p[0] * (256 - p[1]);
const int c2 = (256 - p[0]) * p[2]; const int c0 = p[0] * p[1];
const int c3 = (256 - p[0]) * (256 - p[2]); const int c1 = p[0] * (256 - p[1]);
const int c2 = (256 - p[0]) * p[2];
mispred_p[0] = get_binary_prob(c1, c2 + c3); const int c3 = (256 - p[0]) * (256 - p[2]);
mispred_p[1] = get_binary_prob(c0, c2 + c3);
mispred_p[2] = get_binary_prob(c0 + c1, c3); mispred_p[0] = get_binary_prob(c1, c2 + c3);
mispred_p[3] = get_binary_prob(c0 + c1, c2); mispred_p[1] = get_binary_prob(c0, c2 + c3);
mispred_p[2] = get_binary_prob(c0 + c1, c3);
for (i = 0; i < PREDICTION_PROBS; i++) mispred_p[3] = get_binary_prob(c0 + c1, c2);
pc->segment_pred_probs[i] = vp9_read_bit(r) ? vp9_read_prob(r)
: MAX_PROB; for (i = 0; i < PREDICTION_PROBS; i++)
} else { pc->segment_pred_probs[i] = vp9_read_bit(r) ? vp9_read_prob(r)
for (i = 0; i < PREDICTION_PROBS; i++) : MAX_PROB;
pc->segment_pred_probs[i] = MAX_PROB; } else {
} for (i = 0; i < PREDICTION_PROBS; i++)
pc->segment_pred_probs[i] = MAX_PROB;
} }
}
// Segmentation data update // Segmentation data update
xd->update_mb_segmentation_data = vp9_read_bit(r); xd->update_mb_segmentation_data = vp9_read_bit(r);
if (xd->update_mb_segmentation_data) { if (xd->update_mb_segmentation_data) {
xd->mb_segment_abs_delta = vp9_read_bit(r); xd->mb_segment_abs_delta = vp9_read_bit(r);
vp9_clearall_segfeatures(xd); vp9_clearall_segfeatures(xd);
for (i = 0; i < MAX_MB_SEGMENTS; i++) { for (i = 0; i < MAX_MB_SEGMENTS; i++) {
for (j = 0; j < SEG_LVL_MAX; j++) { for (j = 0; j < SEG_LVL_MAX; j++) {
int data = 0; int data = 0;
const int feature_enabled = vp9_read_bit(r); const int feature_enabled = vp9_read_bit(r);
if (feature_enabled) { if (feature_enabled) {
vp9_enable_segfeature(xd, i, j); vp9_enable_segfeature(xd, i, j);
data = decode_unsigned_max(r, vp9_seg_feature_data_max(j)); data = decode_unsigned_max(r, vp9_seg_feature_data_max(j));
if (vp9_is_segfeature_signed(j)) if (vp9_is_segfeature_signed(j))
data = vp9_read_and_apply_sign(r, data); data = vp9_read_and_apply_sign(r, data);
}
vp9_set_segdata(xd, i, j, data);
} }
vp9_set_segdata(xd, i, j, data);
} }
} }
} }
...@@ -1175,8 +1183,8 @@ static void setup_loopfilter(VP9_COMMON *pc, MACROBLOCKD *xd, vp9_reader *r) { ...@@ -1175,8 +1183,8 @@ static void setup_loopfilter(VP9_COMMON *pc, MACROBLOCKD *xd, vp9_reader *r) {
// Read in loop filter deltas applied at the MB level based on mode or ref // Read in loop filter deltas applied at the MB level based on mode or ref
// frame. // frame.
xd->mode_ref_lf_delta_update = 0; xd->mode_ref_lf_delta_update = 0;
xd->mode_ref_lf_delta_enabled = vp9_read_bit(r);
xd->mode_ref_lf_delta_enabled = vp9_read_bit(r);
if (xd->mode_ref_lf_delta_enabled) { if (xd->mode_ref_lf_delta_enabled) {
xd->mode_ref_lf_delta_update = vp9_read_bit(r); xd->mode_ref_lf_delta_update = vp9_read_bit(r);
if (xd->mode_ref_lf_delta_update) { if (xd->mode_ref_lf_delta_update) {
...@@ -1212,6 +1220,11 @@ static void setup_quantization(VP9D_COMP *pbi, vp9_reader *r) { ...@@ -1212,6 +1220,11 @@ static void setup_quantization(VP9D_COMP *pbi, vp9_reader *r) {
mb_init_dequantizer(pbi, &pbi->mb); // MB level dequantizer setup mb_init_dequantizer(pbi, &pbi->mb); // MB level dequantizer setup
} }
static INTERPOLATIONFILTERTYPE read_mcomp_filter_type(vp9_reader *r) {
return vp9_read_bit(r) ? SWITCHABLE
: vp9_read_literal(r, 2);
}
static const uint8_t *read_frame_size(VP9_COMMON *const pc, const uint8_t *data, static const uint8_t *read_frame_size(VP9_COMMON *const pc, const uint8_t *data,
const uint8_t *data_end, const uint8_t *data_end,
int *width, int *height) { int *width, int *height) {
...@@ -1418,12 +1431,11 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { ...@@ -1418,12 +1431,11 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
const uint8_t *data = pbi->source; const uint8_t *data = pbi->source;
const uint8_t *data_end = data + pbi->source_sz; const uint8_t *data_end = data + pbi->source_sz;
size_t first_partition_size = 0; size_t first_partition_size = 0;
YV12_BUFFER_CONFIG *new_fb = &pc->yv12_fb[pc->new_fb_idx];
int i; int i;
// printf("Decoding frame %d\n", pc->current_video_frame);
xd->corrupted = 0; // start with no corruption of current frame xd->corrupted = 0; // start with no corruption of current frame
pc->yv12_fb[pc->new_fb_idx].corrupted = 0; new_fb->corrupted = 0;
if (data_end - data < 3) { if (data_end - data < 3) {
vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME, "Truncated packet"); vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME, "Truncated packet");
...@@ -1466,8 +1478,7 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { ...@@ -1466,8 +1478,7 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
init_frame(pbi); init_frame(pbi);
// Reset the frame pointers to the current frame size // Reset the frame pointers to the current frame size
vp8_yv12_realloc_frame_buffer(&pc->yv12_fb[pc->new_fb_idx], vp8_yv12_realloc_frame_buffer(new_fb, pc->width, pc->height,
pc->width, pc->height,
VP9BORDERINPIXELS); VP9BORDERINPIXELS);
if (vp9_reader_init(&header_bc, data, first_partition_size)) if (vp9_reader_init(&header_bc, data, first_partition_size))
...@@ -1482,8 +1493,7 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { ...@@ -1482,8 +1493,7 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
setup_loopfilter(pc, xd, &header_bc); setup_loopfilter(pc, xd, &header_bc);
// Dummy read for now vp9_read_literal(&header_bc, 2); // unused
vp9_read_literal(&header_bc, 2);
setup_quantization(pbi, &header_bc); setup_quantization(pbi, &header_bc);
...@@ -1505,14 +1515,8 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { ...@@ -1505,14 +1515,8 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
pc->ref_frame_sign_bias[GOLDEN_FRAME] = vp9_read_bit(&header_bc); pc->ref_frame_sign_bias[GOLDEN_FRAME] = vp9_read_bit(&header_bc);
pc->ref_frame_sign_bias[ALTREF_FRAME] = vp9_read_bit(&header_bc); pc->ref_frame_sign_bias[ALTREF_FRAME] = vp9_read_bit(&header_bc);
// Is high precision mv allowed
xd->allow_high_precision_mv = vp9_read_bit(&header_bc); xd->allow_high_precision_mv = vp9_read_bit(&header_bc);
pc->mcomp_filter_type = read_mcomp_filter_type(&header_bc);
// Read the type of subpel filter to use
pc->mcomp_filter_type = vp9_read_bit(&header_bc)
? SWITCHABLE
: vp9_read_literal(&header_bc, 2);
#if CONFIG_COMP_INTERINTRA_PRED #if CONFIG_COMP_INTERINTRA_PRED
pc->use_interintra = vp9_read_bit(&header_bc); pc->use_interintra = vp9_read_bit(&header_bc);
...@@ -1540,6 +1544,7 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { ...@@ -1540,6 +1544,7 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
pc->refresh_entropy_probs = 0; pc->refresh_entropy_probs = 0;
pc->frame_parallel_decoding_mode = 1; pc->frame_parallel_decoding_mode = 1;
} }
pc->frame_context_idx = vp9_read_literal(&header_bc, NUM_FRAME_CONTEXTS_LG2); pc->frame_context_idx = vp9_read_literal(&header_bc, NUM_FRAME_CONTEXTS_LG2);
vpx_memcpy(&pc->fc, &pc->frame_contexts[pc->frame_context_idx], vpx_memcpy(&pc->fc, &pc->frame_contexts[pc->frame_context_idx],
sizeof(pc->fc)); sizeof(pc->fc));
...@@ -1548,12 +1553,7 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { ...@@ -1548,12 +1553,7 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
setup_pred_probs(pc, &header_bc); setup_pred_probs(pc, &header_bc);
pc->txfm_mode = xd->lossless ? ONLY_4X4 : read_txfm_mode(&header_bc); setup_txfm_mode(pc, xd->lossless, &header_bc);
if (pc->txfm_mode == TX_MODE_SELECT) {
pc->prob_tx[0] = vp9_read_prob(&header_bc);
pc->prob_tx[1] = vp9_read_prob(&header_bc);
pc->prob_tx[2] = vp9_read_prob(&header_bc);
}
// Read inter mode probability context updates // Read inter mode probability context updates
if (pc->frame_type != KEY_FRAME) { if (pc->frame_type != KEY_FRAME) {
...@@ -1564,22 +1564,21 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { ...@@ -1564,22 +1564,21 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
pc->fc.vp9_mode_contexts[i][j] = vp9_read_prob(&header_bc); pc->fc.vp9_mode_contexts[i][j] = vp9_read_prob(&header_bc);
} }
#if CONFIG_MODELCOEFPROB #if CONFIG_MODELCOEFPROB
if (pc->frame_type == KEY_FRAME) { if (pc->frame_type == KEY_FRAME)
vp9_default_coef_probs(pc); vp9_default_coef_probs(pc);
}
#endif #endif
update_frame_context(pbi); update_frame_context(pbi);
read_coef_probs(pbi, &header_bc); read_coef_probs(pbi, &header_bc);
#if CONFIG_CODE_ZEROGROUP #if CONFIG_CODE_ZEROGROUP
read_zpc_probs(&pbi->common, &header_bc); read_zpc_probs(pc, &header_bc);
#endif #endif
// Initialize xd pointers. Any reference should do for xd->pre, so use 0. // Initialize xd pointers. Any reference should do for xd->pre, so use 0.
setup_pre_planes(xd, &pc->yv12_fb[pc->active_ref_idx[0]], NULL, setup_pre_planes(xd, &pc->yv12_fb[pc->active_ref_idx[0]], NULL,
0, 0, NULL, NULL); 0, 0, NULL, NULL);
setup_dst_planes(xd, &pc->yv12_fb[pc->new_fb_idx], 0, 0); setup_dst_planes(xd, new_fb, 0, 0);
// Create the segmentation map structure and set to 0 // Create the segmentation map structure and set to 0
if (!pc->last_frame_seg_map) if (!pc->last_frame_seg_map)
...@@ -1587,7 +1586,7 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { ...@@ -1587,7 +1586,7 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
vpx_calloc((pc->mb_rows * pc->mb_cols), 1)); vpx_calloc((pc->mb_rows * pc->mb_cols), 1));
// set up frame new frame for intra coded blocks // set up frame new frame for intra coded blocks
vp9_setup_intra_recon(&pc->yv12_fb[pc->new_fb_idx]); vp9_setup_intra_recon(new_fb);
vp9_setup_block_dptrs(xd); vp9_setup_block_dptrs(xd);
vp9_build_block_doffsets(xd); vp9_build_block_doffsets(xd);
...@@ -1603,21 +1602,16 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { ...@@ -1603,21 +1602,16 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
decode_tiles(pbi, data, first_partition_size, &header_bc, &residual_bc); decode_tiles(pbi, data, first_partition_size, &header_bc, &residual_bc);
// keep track of the last coded dimensions
pc->last_width = pc->width;