summaryrefslogtreecommitdiff
path: root/vp9
diff options
context:
space:
mode:
Diffstat (limited to 'vp9')
-rw-r--r--vp9/common/vp9_onyxc_int.h6
-rw-r--r--vp9/common/vp9_pred_common.c35
-rw-r--r--vp9/common/vp9_reconinter.c80
-rw-r--r--vp9/common/vp9_treecoder.c21
-rw-r--r--vp9/common/vp9_treecoder.h9
-rw-r--r--vp9/decoder/vp9_decodeframe.c6
-rw-r--r--vp9/decoder/vp9_onyxd_if.c3
-rw-r--r--vp9/encoder/vp9_encodeframe.c18
-rw-r--r--vp9/encoder/vp9_tokenize.h2
-rw-r--r--vp9/encoder/vp9_treewriter.c21
-rw-r--r--vp9/encoder/vp9_treewriter.h8
-rw-r--r--vp9/vp9_cx_iface.c4
12 files changed, 94 insertions, 119 deletions
diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h
index 751accf02..2c410669a 100644
--- a/vp9/common/vp9_onyxc_int.h
+++ b/vp9/common/vp9_onyxc_int.h
@@ -238,8 +238,10 @@ static int get_free_fb(VP9_COMMON *cm) {
}
static void ref_cnt_fb(int *buf, int *idx, int new_idx) {
- if (buf[*idx] > 0)
- buf[*idx]--;
+ const int ref_index = *idx;
+
+ if (ref_index >= 0 && buf[ref_index] > 0)
+ buf[ref_index]--;
*idx = new_idx;
diff --git a/vp9/common/vp9_pred_common.c b/vp9/common/vp9_pred_common.c
index 22b66b57a..a367f0b5d 100644
--- a/vp9/common/vp9_pred_common.c
+++ b/vp9/common/vp9_pred_common.c
@@ -369,31 +369,22 @@ unsigned char vp9_get_pred_context_single_ref_p2(const MACROBLOCKD *xd) {
// left of the entries corresponding to real blocks.
// The prediction flags in these dummy entries are initialized to 0.
unsigned char vp9_get_pred_context_tx_size(const MACROBLOCKD *xd) {
- const MODE_INFO *const above_mi = get_above_mi(xd);
- const MODE_INFO *const left_mi = get_left_mi(xd);
- const MB_MODE_INFO *const above_mbmi = get_above_mbmi(above_mi);
- const MB_MODE_INFO *const left_mbmi = get_left_mbmi(left_mi);
- const int above_in_image = above_mi != NULL;
- const int left_in_image = left_mi != NULL;
const int max_tx_size = max_txsize_lookup[xd->mi_8x8[0]->mbmi.sb_type];
- int above_context = max_tx_size;
- int left_context = max_tx_size;
-
- if (above_in_image)
- above_context = above_mbmi->skip_coeff ? max_tx_size
- : above_mbmi->tx_size;
-
- if (left_in_image)
- left_context = left_mbmi->skip_coeff ? max_tx_size
- : left_mbmi->tx_size;
-
- if (!left_in_image)
- left_context = above_context;
+ const MB_MODE_INFO *const above_mbmi = get_above_mbmi(get_above_mi(xd));
+ const MB_MODE_INFO *const left_mbmi = get_left_mbmi(get_left_mi(xd));
+ const int has_above = above_mbmi != NULL;
+ const int has_left = left_mbmi != NULL;
+ int above_ctx = (has_above && !above_mbmi->skip_coeff) ? above_mbmi->tx_size
+ : max_tx_size;
+ int left_ctx = (has_left && !left_mbmi->skip_coeff) ? left_mbmi->tx_size
+ : max_tx_size;
+ if (!has_left)
+ left_ctx = above_ctx;
- if (!above_in_image)
- above_context = left_context;
+ if (!has_above)
+ above_ctx = left_ctx;
- return above_context + left_context > max_tx_size;
+ return (above_ctx + left_ctx) > max_tx_size;
}
int vp9_get_segment_id(VP9_COMMON *cm, const uint8_t *segment_ids,
diff --git a/vp9/common/vp9_reconinter.c b/vp9/common/vp9_reconinter.c
index 09a4fc826..6e54cf3fd 100644
--- a/vp9/common/vp9_reconinter.c
+++ b/vp9/common/vp9_reconinter.c
@@ -102,24 +102,14 @@ MV clamp_mv_to_umv_border_sb(const MACROBLOCKD *xd, const MV *src_mv,
// calculate the subsampled BLOCK_SIZE, but that type isn't defined for
// sizes smaller than 16x16 yet.
static void build_inter_predictors(MACROBLOCKD *xd, int plane, int block,
- BLOCK_SIZE bsize, int pred_w, int pred_h,
+ int bw, int bh,
+ int x, int y, int w, int h,
int mi_x, int mi_y) {
struct macroblockd_plane *const pd = &xd->plane[plane];
- const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd);
- const int bwl = b_width_log2(plane_bsize);
- const int bw = 4 << bwl;
- const int bh = 4 * num_4x4_blocks_high_lookup[plane_bsize];
- const int x = 4 * (block & ((1 << bwl) - 1));
- const int y = 4 * (block >> bwl);
const MODE_INFO *mi = xd->mi_8x8[0];
const int is_compound = has_second_ref(&mi->mbmi);
int ref;
- assert(x < bw);
- assert(y < bh);
- assert(mi->mbmi.sb_type < BLOCK_8X8 || 4 << pred_w == bw);
- assert(mi->mbmi.sb_type < BLOCK_8X8 || 4 << pred_h == bh);
-
for (ref = 0; ref < 1 + is_compound; ++ref) {
struct scale_factors *const scale = &xd->scale_factor[ref];
struct buf_2d *const pre_buf = &pd->pre[ref];
@@ -162,9 +152,7 @@ static void build_inter_predictors(MACROBLOCKD *xd, int plane, int block,
}
inter_predictor(pre, pre_buf->stride, dst, dst_buf->stride,
- &scaled_mv, scale,
- 4 << pred_w, 4 << pred_h, ref,
- &xd->subpix, xs, ys);
+ &scaled_mv, scale, w, h, ref, &xd->subpix, xs, ys);
}
}
@@ -172,20 +160,26 @@ static void build_inter_predictors_for_planes(MACROBLOCKD *xd, BLOCK_SIZE bsize,
int mi_row, int mi_col,
int plane_from, int plane_to) {
int plane;
+ const int mi_x = mi_col * MI_SIZE;
+ const int mi_y = mi_row * MI_SIZE;
for (plane = plane_from; plane <= plane_to; ++plane) {
- const int mi_x = mi_col * MI_SIZE;
- const int mi_y = mi_row * MI_SIZE;
- const int bwl = b_width_log2(bsize) - xd->plane[plane].subsampling_x;
- const int bhl = b_height_log2(bsize) - xd->plane[plane].subsampling_y;
+ const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize,
+ &xd->plane[plane]);
+ const int num_4x4_w = num_4x4_blocks_wide_lookup[plane_bsize];
+ const int num_4x4_h = num_4x4_blocks_high_lookup[plane_bsize];
+ const int bw = 4 * num_4x4_w;
+ const int bh = 4 * num_4x4_h;
if (xd->mi_8x8[0]->mbmi.sb_type < BLOCK_8X8) {
int i = 0, x, y;
assert(bsize == BLOCK_8X8);
- for (y = 0; y < 1 << bhl; ++y)
- for (x = 0; x < 1 << bwl; ++x)
- build_inter_predictors(xd, plane, i++, bsize, 0, 0, mi_x, mi_y);
+ for (y = 0; y < num_4x4_h; ++y)
+ for (x = 0; x < num_4x4_w; ++x)
+ build_inter_predictors(xd, plane, i++, bw, bh,
+ 4 * x, 4 * y, 4, 4, mi_x, mi_y);
} else {
- build_inter_predictors(xd, plane, 0, bsize, bwl, bhl, mi_x, mi_y);
+ build_inter_predictors(xd, plane, 0, bw, bh,
+ 0, 0, bw, bh, mi_x, mi_y);
}
}
}
@@ -208,24 +202,14 @@ void vp9_build_inter_predictors_sb(MACROBLOCKD *xd, int mi_row, int mi_col,
// TODO(jingning): This function serves as a placeholder for decoder prediction
// using on demand border extension. It should be moved to /decoder/ directory.
static void dec_build_inter_predictors(MACROBLOCKD *xd, int plane, int block,
- BLOCK_SIZE bsize, int pred_w, int pred_h,
+ int bw, int bh,
+ int x, int y, int w, int h,
int mi_x, int mi_y) {
struct macroblockd_plane *const pd = &xd->plane[plane];
- const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd);
- const int bwl = b_width_log2(plane_bsize);
- const int bw = 4 << bwl;
- const int bh = 4 * num_4x4_blocks_high_lookup[plane_bsize];
- const int x = 4 * (block & ((1 << bwl) - 1));
- const int y = 4 * (block >> bwl);
const MODE_INFO *mi = xd->mi_8x8[0];
const int is_compound = has_second_ref(&mi->mbmi);
int ref;
- assert(x < bw);
- assert(y < bh);
- assert(mi->mbmi.sb_type < BLOCK_8X8 || 4 << pred_w == bw);
- assert(mi->mbmi.sb_type < BLOCK_8X8 || 4 << pred_h == bh);
-
for (ref = 0; ref < 1 + is_compound; ++ref) {
struct scale_factors *const scale = &xd->scale_factor[ref];
struct buf_2d *const pre_buf = &pd->pre[ref];
@@ -268,29 +252,33 @@ static void dec_build_inter_predictors(MACROBLOCKD *xd, int plane, int block,
}
inter_predictor(pre, pre_buf->stride, dst, dst_buf->stride,
- &scaled_mv, scale,
- 4 << pred_w, 4 << pred_h, ref,
- &xd->subpix, xs, ys);
+ &scaled_mv, scale, w, h, ref, &xd->subpix, xs, ys);
}
}
void vp9_dec_build_inter_predictors_sb(MACROBLOCKD *xd, int mi_row, int mi_col,
BLOCK_SIZE bsize) {
int plane;
+ const int mi_x = mi_col * MI_SIZE;
+ const int mi_y = mi_row * MI_SIZE;
for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
- const int mi_x = mi_col * MI_SIZE;
- const int mi_y = mi_row * MI_SIZE;
- const int bwl = b_width_log2(bsize) - xd->plane[plane].subsampling_x;
- const int bhl = b_height_log2(bsize) - xd->plane[plane].subsampling_y;
+ const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize,
+ &xd->plane[plane]);
+ const int num_4x4_w = num_4x4_blocks_wide_lookup[plane_bsize];
+ const int num_4x4_h = num_4x4_blocks_high_lookup[plane_bsize];
+ const int bw = 4 * num_4x4_w;
+ const int bh = 4 * num_4x4_h;
if (xd->mi_8x8[0]->mbmi.sb_type < BLOCK_8X8) {
int i = 0, x, y;
assert(bsize == BLOCK_8X8);
- for (y = 0; y < 1 << bhl; ++y)
- for (x = 0; x < 1 << bwl; ++x)
- dec_build_inter_predictors(xd, plane, i++, bsize, 0, 0, mi_x, mi_y);
+ for (y = 0; y < num_4x4_h; ++y)
+ for (x = 0; x < num_4x4_w; ++x)
+ dec_build_inter_predictors(xd, plane, i++, bw, bh,
+ 4 * x, 4 * y, 4, 4, mi_x, mi_y);
} else {
- dec_build_inter_predictors(xd, plane, 0, bsize, bwl, bhl, mi_x, mi_y);
+ dec_build_inter_predictors(xd, plane, 0, bw, bh,
+ 0, 0, bw, bh, mi_x, mi_y);
}
}
}
diff --git a/vp9/common/vp9_treecoder.c b/vp9/common/vp9_treecoder.c
index e2a5b9faa..dca3076f3 100644
--- a/vp9/common/vp9_treecoder.c
+++ b/vp9/common/vp9_treecoder.c
@@ -14,27 +14,6 @@
#include "./vpx_config.h"
#include "vp9/common/vp9_treecoder.h"
-static void tree2tok(struct vp9_token *const p, vp9_tree t,
- int i, int v, int l) {
- v += v;
- ++l;
-
- do {
- const vp9_tree_index j = t[i++];
-
- if (j <= 0) {
- p[-j].value = v;
- p[-j].len = l;
- } else {
- tree2tok(p, t, j, v, l);
- }
- } while (++v & 1);
-}
-
-void vp9_tokens_from_tree(struct vp9_token *p, vp9_tree t) {
- tree2tok(p, t, 0, 0, 0);
-}
-
static unsigned int convert_distribution(unsigned int i, vp9_tree tree,
unsigned int branch_ct[][2],
const unsigned int num_events[]) {
diff --git a/vp9/common/vp9_treecoder.h b/vp9/common/vp9_treecoder.h
index a79b1564a..bbe4e8f6a 100644
--- a/vp9/common/vp9_treecoder.h
+++ b/vp9/common/vp9_treecoder.h
@@ -34,15 +34,6 @@ typedef int8_t vp9_tree_index;
typedef const vp9_tree_index vp9_tree[];
-struct vp9_token {
- int value;
- int len;
-};
-
-/* Construct encoding array from tree. */
-
-void vp9_tokens_from_tree(struct vp9_token*, vp9_tree);
-
/* Convert array of token occurrence counts into a table of probabilities
for the associated binary encoding tree. Also writes count of branches
taken for each node on the tree; this facilitiates decisions as to
diff --git a/vp9/decoder/vp9_decodeframe.c b/vp9/decoder/vp9_decodeframe.c
index 82bace00d..516aa88cb 100644
--- a/vp9/decoder/vp9_decodeframe.c
+++ b/vp9/decoder/vp9_decodeframe.c
@@ -687,12 +687,6 @@ static void apply_frame_size(VP9D_COMP *pbi, int width, int height) {
if (cm->width != width || cm->height != height) {
// Change in frame size.
- if (cm->width == 0 || cm->height == 0) {
- // Assign new frame buffer on first call.
- cm->new_fb_idx = NUM_YV12_BUFFERS - 1;
- cm->fb_idx_ref_cnt[cm->new_fb_idx] = 1;
- }
-
// TODO(agrange) Don't test width/height, check overall size.
if (width > cm->width || height > cm->height) {
// Rescale frame buffers only if they're not big enough already.
diff --git a/vp9/decoder/vp9_onyxd_if.c b/vp9/decoder/vp9_onyxd_if.c
index 25fb3d6d2..4c0cd45a9 100644
--- a/vp9/decoder/vp9_onyxd_if.c
+++ b/vp9/decoder/vp9_onyxd_if.c
@@ -125,6 +125,9 @@ VP9D_PTR vp9_create_decompressor(VP9D_CONFIG *oxcf) {
vp9_zero(*pbi);
+ // Initialize the references to not point to any frame buffers.
+ memset(&cm->ref_frame_map, -1, sizeof(cm->ref_frame_map));
+
if (setjmp(cm->error.jmp)) {
cm->error.setjmp = 0;
vp9_remove_decompressor(pbi);
diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c
index f53c3c962..bc71d0259 100644
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -2592,27 +2592,19 @@ static void encode_superblock(VP9_COMP *cpi, TOKENEXTRA **t, int output_enabled,
context, &cm->counts.tx)[mbmi->tx_size];
} else {
int x, y;
- TX_SIZE sz = tx_mode_to_biggest_tx_size[cm->tx_mode];
- assert(sizeof(tx_mode_to_biggest_tx_size) /
- sizeof(tx_mode_to_biggest_tx_size[0]) == TX_MODES);
+ TX_SIZE tx_size;
// The new intra coding scheme requires no change of transform size
if (is_inter_block(&mi->mbmi)) {
- if (sz == TX_32X32 && bsize < BLOCK_32X32)
- sz = TX_16X16;
- if (sz == TX_16X16 && bsize < BLOCK_16X16)
- sz = TX_8X8;
- if (sz == TX_8X8 && bsize < BLOCK_8X8)
- sz = TX_4X4;
- } else if (bsize >= BLOCK_8X8) {
- sz = mbmi->tx_size;
+ tx_size = MIN(tx_mode_to_biggest_tx_size[cm->tx_mode],
+ max_txsize_lookup[bsize]);
} else {
- sz = TX_4X4;
+ tx_size = (bsize >= BLOCK_8X8) ? mbmi->tx_size : TX_4X4;
}
for (y = 0; y < mi_height; y++)
for (x = 0; x < mi_width; x++)
if (mi_col + x < cm->mi_cols && mi_row + y < cm->mi_rows)
- mi_8x8[mis * y + x]->mbmi.tx_size = sz;
+ mi_8x8[mis * y + x]->mbmi.tx_size = tx_size;
}
}
}
diff --git a/vp9/encoder/vp9_tokenize.h b/vp9/encoder/vp9_tokenize.h
index 482ea6cb4..67e6c9d3d 100644
--- a/vp9/encoder/vp9_tokenize.h
+++ b/vp9/encoder/vp9_tokenize.h
@@ -12,7 +12,9 @@
#define VP9_ENCODER_VP9_TOKENIZE_H_
#include "vp9/common/vp9_entropy.h"
+
#include "vp9/encoder/vp9_block.h"
+#include "vp9/encoder/vp9_treewriter.h"
void vp9_tokenize_initialize();
diff --git a/vp9/encoder/vp9_treewriter.c b/vp9/encoder/vp9_treewriter.c
index e4aed5374..5b0c17fe7 100644
--- a/vp9/encoder/vp9_treewriter.c
+++ b/vp9/encoder/vp9_treewriter.c
@@ -36,3 +36,24 @@ void vp9_cost_tokens_skip(int *costs, const vp9_prob *probs, vp9_tree tree) {
costs[-tree[0]] = vp9_cost_bit(probs[0], 0);
cost(costs, tree, probs, 2, 0);
}
+
+static void tree2tok(struct vp9_token *tokens, const vp9_tree_index *tree,
+ int i, int v, int l) {
+ v += v;
+ ++l;
+
+ do {
+ const vp9_tree_index j = tree[i++];
+ if (j <= 0) {
+ tokens[-j].value = v;
+ tokens[-j].len = l;
+ } else {
+ tree2tok(tokens, tree, j, v, l);
+ }
+ } while (++v & 1);
+}
+
+void vp9_tokens_from_tree(struct vp9_token *tokens,
+ const vp9_tree_index *tree) {
+ tree2tok(tokens, tree, 0, 0, 0);
+}
diff --git a/vp9/encoder/vp9_treewriter.h b/vp9/encoder/vp9_treewriter.h
index 3245960ac..94f3eb987 100644
--- a/vp9/encoder/vp9_treewriter.h
+++ b/vp9/encoder/vp9_treewriter.h
@@ -44,6 +44,14 @@ static INLINE void treed_write(vp9_writer *w,
} while (len);
}
+struct vp9_token {
+ int value;
+ int len;
+};
+
+
+void vp9_tokens_from_tree(struct vp9_token*, const vp9_tree_index *);
+
static INLINE void write_token(vp9_writer *w, vp9_tree tree,
const vp9_prob *probs,
const struct vp9_token *token) {
diff --git a/vp9/vp9_cx_iface.c b/vp9/vp9_cx_iface.c
index 9a23ebd53..5d53a4149 100644
--- a/vp9/vp9_cx_iface.c
+++ b/vp9/vp9_cx_iface.c
@@ -198,6 +198,10 @@ static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx,
RANGE_CHECK(vp8_cfg, arnr_type, 1, 3);
RANGE_CHECK(vp8_cfg, cq_level, 0, 63);
+ // TODO(yaowu): remove this when ssim tuning is implemented for vp9
+ if (vp8_cfg->tuning == VP8_TUNE_SSIM)
+ ERROR("Option --tune=ssim is not currently supported in VP9.");
+
if (cfg->g_pass == VPX_RC_LAST_PASS) {
size_t packet_sz = sizeof(FIRSTPASS_STATS);
int n_packets = (int)(cfg->rc_twopass_stats_in.sz / packet_sz);