ref: a21359cbead9a68ba3b2e15088c925824d620406
parent: 9b8fcd40df0cbc7fa2c065e1503b35f3b7f3cd58
parent: d5413a8e821573164b3e8c74a60522c09d26f17e
author: Dmitry Kovalev <[email protected]>
date: Tue Apr 23 09:53:14 EDT 2013
Merge "Adding select_txfm_size function + vp9_decode_frame cleanup." into experimental
--- a/vp9/decoder/vp9_decodemv.c
+++ b/vp9/decoder/vp9_decodemv.c
@@ -116,6 +116,17 @@
}
}
+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,
@@ -174,15 +185,11 @@
}
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 int read_nmv_component(vp9_reader *r,
int rv,
const nmv_component *mvcomp) {
@@ -980,14 +988,9 @@
((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;
--- a/vp9/decoder/vp9_decodframe.c
+++ b/vp9/decoder/vp9_decodframe.c
@@ -771,11 +771,6 @@
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(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 @@
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)
@@ -1423,7 +1418,7 @@
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);
@@ -1574,16 +1569,6 @@
}
#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);
@@ -1617,7 +1602,6 @@
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;
@@ -1627,7 +1611,7 @@
// 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)
@@ -1637,15 +1621,13 @@
"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);
@@ -1656,16 +1638,6 @@
vpx_memcpy(&pc->frame_contexts[pc->frame_context_idx], &pc->fc,
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;