summaryrefslogtreecommitdiff
path: root/vp9
diff options
context:
space:
mode:
Diffstat (limited to 'vp9')
-rw-r--r--vp9/common/vp9_entropymode.c2
-rw-r--r--vp9/common/vp9_entropymode.h2
-rw-r--r--vp9/common/vp9_onyx.h28
-rw-r--r--vp9/decoder/vp9_decodframe.c37
-rw-r--r--vp9/encoder/vp9_encodeframe.c26
-rw-r--r--vp9/encoder/vp9_onyx_if.c26
6 files changed, 59 insertions, 62 deletions
diff --git a/vp9/common/vp9_entropymode.c b/vp9/common/vp9_entropymode.c
index f66f2f317..b625caaf0 100644
--- a/vp9/common/vp9_entropymode.c
+++ b/vp9/common/vp9_entropymode.c
@@ -536,7 +536,7 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) {
tx_counts_to_branch_counts_16x16(fc->tx_counts.p16x16[i],
branch_ct_16x16p);
for (j = 0; j < TX_SIZE_MAX_SB - 2; ++j)
- fc->tx_probs.p16x16[i][j] = update_tx_ct(fc->tx_probs.p16x16[i][j],
+ fc->tx_probs.p16x16[i][j] = update_tx_ct(fc->pre_tx_probs.p16x16[i][j],
branch_ct_16x16p[j]);
tx_counts_to_branch_counts_32x32(fc->tx_counts.p32x32[i],
diff --git a/vp9/common/vp9_entropymode.h b/vp9/common/vp9_entropymode.h
index fa6722c8d..35ec9c412 100644
--- a/vp9/common/vp9_entropymode.h
+++ b/vp9/common/vp9_entropymode.h
@@ -26,7 +26,7 @@ struct VP9Common;
struct tx_probs {
vp9_prob p32x32[TX_SIZE_CONTEXTS][TX_SIZE_MAX_SB - 1];
vp9_prob p16x16[TX_SIZE_CONTEXTS][TX_SIZE_MAX_SB - 2];
- vp9_prob p8x8[TX_SIZE_CONTEXTS][TX_SIZE_MAX_SB - 2];
+ vp9_prob p8x8[TX_SIZE_CONTEXTS][TX_SIZE_MAX_SB - 3];
};
struct tx_counts {
diff --git a/vp9/common/vp9_onyx.h b/vp9/common/vp9_onyx.h
index d266c1567..fe8122b46 100644
--- a/vp9/common/vp9_onyx.h
+++ b/vp9/common/vp9_onyx.h
@@ -64,34 +64,6 @@ extern "C"
FRAMEFLAGS_ALTREF = 4,
} FRAMETYPE_FLAGS;
-
-#include <assert.h>
- static INLINE void Scale2Ratio(int mode, int *hr, int *hs) {
- switch (mode) {
- case NORMAL:
- *hr = 1;
- *hs = 1;
- break;
- case FOURFIVE:
- *hr = 4;
- *hs = 5;
- break;
- case THREEFIVE:
- *hr = 3;
- *hs = 5;
- break;
- case ONETWO:
- *hr = 1;
- *hs = 2;
- break;
- default:
- *hr = 1;
- *hs = 1;
- assert(0);
- break;
- }
- }
-
typedef struct {
int version; // 4 versions of bitstream defined:
// 0 - best quality/slowest decode,
diff --git a/vp9/decoder/vp9_decodframe.c b/vp9/decoder/vp9_decodframe.c
index 40308c8e0..82c869ee5 100644
--- a/vp9/decoder/vp9_decodframe.c
+++ b/vp9/decoder/vp9_decodframe.c
@@ -645,12 +645,11 @@ static void setup_tile_info(VP9_COMMON *cm, struct vp9_read_bit_buffer *rb) {
cm->log2_tile_rows += vp9_rb_read_bit(rb);
}
-static void decode_tiles(VP9D_COMP *pbi,
- const uint8_t *data, size_t first_partition_size,
- vp9_reader *residual_bc) {
+static const uint8_t *decode_tiles(VP9D_COMP *pbi, const uint8_t *data) {
+ vp9_reader residual_bc;
+
VP9_COMMON *const pc = &pbi->common;
- const uint8_t *data_ptr = data + first_partition_size;
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;
@@ -670,7 +669,7 @@ static void decode_tiles(VP9D_COMP *pbi,
vp9_reader bc_bak = {0};
// pre-initialize the offsets, we're going to read in inverse order
- data_ptr2[0][0] = data_ptr;
+ data_ptr2[0][0] = data;
for (tile_row = 0; tile_row < tile_rows; tile_row++) {
if (tile_row) {
const int size = read_be32(data_ptr2[tile_row - 1][tile_cols - 1]);
@@ -692,13 +691,13 @@ static void decode_tiles(VP9D_COMP *pbi,
vp9_get_tile_col_offsets(pc, tile_col);
setup_token_decoder(pbi, data_ptr2[tile_row][tile_col],
data_end - data_ptr2[tile_row][tile_col],
- residual_bc);
- decode_tile(pbi, residual_bc);
+ &residual_bc);
+ decode_tile(pbi, &residual_bc);
if (tile_row == tile_rows - 1 && tile_col == tile_cols - 1)
- bc_bak = *residual_bc;
+ bc_bak = residual_bc;
}
}
- *residual_bc = bc_bak;
+ residual_bc = bc_bak;
} else {
int has_more;
@@ -711,22 +710,24 @@ static void decode_tiles(VP9D_COMP *pbi,
has_more = tile_col < tile_cols - 1 || tile_row < tile_rows - 1;
if (has_more) {
- if (!read_is_valid(data_ptr, 4, data_end))
+ if (!read_is_valid(data, 4, data_end))
vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
"Truncated packet or corrupt tile length");
- size = read_be32(data_ptr);
- data_ptr += 4;
+ size = read_be32(data);
+ data += 4;
} else {
- size = data_end - data_ptr;
+ size = data_end - data;
}
- setup_token_decoder(pbi, data_ptr, size, residual_bc);
- decode_tile(pbi, residual_bc);
- data_ptr += size;
+ setup_token_decoder(pbi, data, size, &residual_bc);
+ decode_tile(pbi, &residual_bc);
+ data += size;
}
}
}
+
+ return vp9_reader_find_end(&residual_bc);
}
static void check_sync_code(VP9_COMMON *cm, struct vp9_read_bit_buffer *rb) {
@@ -923,7 +924,6 @@ void vp9_init_dequantizer(VP9_COMMON *cm) {
int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
int i;
- vp9_reader residual_bc;
VP9_COMMON *const pc = &pbi->common;
MACROBLOCKD *const xd = &pbi->mb;
@@ -985,7 +985,7 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
set_prev_mi(pc);
- decode_tiles(pbi, data, first_partition_size, &residual_bc);
+ *p_data_end = decode_tiles(pbi, data + first_partition_size);
pc->last_width = pc->width;
pc->last_height = pc->height;
@@ -1013,6 +1013,5 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
if (pc->refresh_frame_context)
pc->frame_contexts[pc->frame_context_idx] = pc->fc;
- *p_data_end = vp9_reader_find_end(&residual_bc);
return 0;
}
diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c
index 503c6a829..ae10ffc2e 100644
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -1248,9 +1248,6 @@ static void rd_use_partition(VP9_COMP *cpi, MODE_INFO *m, TOKENEXTRA **tp,
case PARTITION_NONE:
pick_sb_modes(cpi, mi_row, mi_col, &last_part_rate, &last_part_dist,
bsize, get_block_context(x, bsize), INT64_MAX);
- set_partition_seg_context(cm, xd, mi_row, mi_col);
- pl = partition_plane_context(xd, bsize);
- last_part_rate += x->partition_cost[pl][PARTITION_NONE];
break;
case PARTITION_HORZ:
*(get_sb_index(xd, subsize)) = 0;
@@ -1267,9 +1264,6 @@ static void rd_use_partition(VP9_COMP *cpi, MODE_INFO *m, TOKENEXTRA **tp,
last_part_rate += rt;
last_part_dist += dt;
}
- set_partition_seg_context(cm, xd, mi_row, mi_col);
- pl = partition_plane_context(xd, bsize);
- last_part_rate += x->partition_cost[pl][PARTITION_HORZ];
break;
case PARTITION_VERT:
*(get_sb_index(xd, subsize)) = 0;
@@ -1286,9 +1280,6 @@ static void rd_use_partition(VP9_COMP *cpi, MODE_INFO *m, TOKENEXTRA **tp,
last_part_rate += rt;
last_part_dist += dt;
}
- set_partition_seg_context(cm, xd, mi_row, mi_col);
- pl = partition_plane_context(xd, bsize);
- last_part_rate += x->partition_cost[pl][PARTITION_VERT];
break;
case PARTITION_SPLIT:
// Split partition.
@@ -1308,16 +1299,23 @@ static void rd_use_partition(VP9_COMP *cpi, MODE_INFO *m, TOKENEXTRA **tp,
rd_use_partition(cpi, m + jj * bss * mis + ii * bss, tp, mi_row + y_idx,
mi_col + x_idx, subsize, &rt, &dt, i != 3);
+ if (rt == INT_MAX || dt == INT_MAX) {
+ last_part_rate = INT_MAX;
+ last_part_dist = INT_MAX;
+ break;
+ }
last_part_rate += rt;
last_part_dist += dt;
}
- set_partition_seg_context(cm, xd, mi_row, mi_col);
- pl = partition_plane_context(xd, bsize);
- last_part_rate += x->partition_cost[pl][PARTITION_SPLIT];
break;
default:
assert(0);
}
+ set_partition_seg_context(cm, xd, mi_row, mi_col);
+ pl = partition_plane_context(xd, bsize);
+ if (last_part_rate < INT_MAX)
+ last_part_rate += x->partition_cost[pl][partition];
+
if (cpi->sf.adjust_partitioning_from_last_frame
&& partition != PARTITION_SPLIT && bsize > BLOCK_SIZE_SB8X8
&& (mi_row + ms < cm->mi_rows || mi_row + (ms >> 1) == cm->mi_rows)
@@ -1392,10 +1390,12 @@ static void rd_use_partition(VP9_COMP *cpi, MODE_INFO *m, TOKENEXTRA **tp,
// We must have chosen a partitioning and encoding or we'll fail later on.
// No other opportunities for success.
- assert(chosen_rate < INT_MAX && chosen_dist < INT_MAX);
+ if ( bsize == BLOCK_SIZE_SB64X64)
+ assert(chosen_rate < INT_MAX && chosen_dist < INT_MAX);
if (do_recon)
encode_sb(cpi, tp, mi_row, mi_col, bsize == BLOCK_SIZE_SB64X64, bsize);
+
*rate = chosen_rate;
*dist = chosen_dist;
}
diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c
index 2afcd27b1..0d48c0756 100644
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -131,6 +131,32 @@ static int gf_low_motion_minq[QINDEX_RANGE];
static int gf_high_motion_minq[QINDEX_RANGE];
static int inter_minq[QINDEX_RANGE];
+static INLINE void Scale2Ratio(int mode, int *hr, int *hs) {
+ switch (mode) {
+ case NORMAL:
+ *hr = 1;
+ *hs = 1;
+ break;
+ case FOURFIVE:
+ *hr = 4;
+ *hs = 5;
+ break;
+ case THREEFIVE:
+ *hr = 3;
+ *hs = 5;
+ break;
+ case ONETWO:
+ *hr = 1;
+ *hs = 2;
+ break;
+ default:
+ *hr = 1;
+ *hs = 1;
+ assert(0);
+ break;
+ }
+}
+
// Functions to compute the active minq lookup table entries based on a
// formulaic approach to facilitate easier adjustment of the Q tables.
// The formulae were derived from computing a 3rd order polynomial best