Adding select_txfm_size function + vp9_decode_frame cleanup.
Change-Id: I7594ca84106ee48f83e6fc3098c0de7a28d5a183
This commit is contained in:
Родитель
f12509f640
Коммит
d5413a8e82
|
@ -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,
|
||||
|
@ -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) {
|
||||
|
@ -981,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;
|
||||
|
|
|
@ -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)
|
||||
|
@ -1421,7 +1416,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);
|
||||
|
||||
|
@ -1571,16 +1566,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 +1599,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 +1608,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 +1618,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 +1636,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;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче