summaryrefslogtreecommitdiff
path: root/vp9/common
diff options
context:
space:
mode:
authorJohn Koleszar <jkoleszar@google.com>2013-04-19 15:52:17 -0700
committerJohn Koleszar <jkoleszar@google.com>2013-04-19 16:16:10 -0700
commitd12376aa2c71a7e3ecca479ab436457ec4ba79a3 (patch)
treed04f23516a5769515fac339fa5a2b08678a8bfda /vp9/common
parent9ec0f658a15ebfa1509fb60c90a0d19f81eb8df5 (diff)
downloadlibvpx-d12376aa2c71a7e3ecca479ab436457ec4ba79a3.tar
libvpx-d12376aa2c71a7e3ecca479ab436457ec4ba79a3.tar.gz
libvpx-d12376aa2c71a7e3ecca479ab436457ec4ba79a3.tar.bz2
libvpx-d12376aa2c71a7e3ecca479ab436457ec4ba79a3.zip
Move dst to per-plane MACROBLOCKD data
First in a series of commits moving the framebuffers pointers to per-plane data, so that they can be indexed numerically rather than by name. Change-Id: I6e0d60fd4d51e6375c384eb7321776564df21775
Diffstat (limited to 'vp9/common')
-rw-r--r--vp9/common/vp9_blockd.h8
-rw-r--r--vp9/common/vp9_mbpitch.c10
-rw-r--r--vp9/common/vp9_recon.c10
-rw-r--r--vp9/common/vp9_reconinter.c30
-rw-r--r--vp9/common/vp9_reconinter.h35
-rw-r--r--vp9/common/vp9_reconintra.c30
-rw-r--r--vp9/common/x86/vp9_recon_wrapper_sse2.c22
7 files changed, 91 insertions, 54 deletions
diff --git a/vp9/common/vp9_blockd.h b/vp9/common/vp9_blockd.h
index 265c1f21a..be48ab31b 100644
--- a/vp9/common/vp9_blockd.h
+++ b/vp9/common/vp9_blockd.h
@@ -338,6 +338,11 @@ struct scale_factors {
enum { MAX_MB_PLANE = 3 };
+struct buf_2d {
+ uint8_t *buf;
+ int stride;
+};
+
struct mb_plane {
DECLARE_ALIGNED(16, int16_t, qcoeff[64 * 64]);
DECLARE_ALIGNED(16, int16_t, dqcoeff[64 * 64]);
@@ -346,6 +351,8 @@ struct mb_plane {
PLANE_TYPE plane_type;
int subsampling_x;
int subsampling_y;
+ struct buf_2d dst;
+ struct buf_2d pre[2];
};
#define BLOCK_OFFSET(x, i, n) ((x) + (i) * (n))
@@ -366,7 +373,6 @@ typedef struct macroblockd {
YV12_BUFFER_CONFIG pre; /* Filtered copy of previous frame reconstruction */
YV12_BUFFER_CONFIG second_pre;
- YV12_BUFFER_CONFIG dst;
struct scale_factors scale_factor[2];
struct scale_factors scale_factor_uv[2];
diff --git a/vp9/common/vp9_mbpitch.c b/vp9/common/vp9_mbpitch.c
index 00fe9aa15..957068f01 100644
--- a/vp9/common/vp9_mbpitch.c
+++ b/vp9/common/vp9_mbpitch.c
@@ -36,9 +36,9 @@ static void setup_macroblock(MACROBLOCKD *mb, BLOCKSET bs) {
int i, stride;
if (bs == DEST) {
- y = &mb->dst.y_buffer;
- u = &mb->dst.u_buffer;
- v = &mb->dst.v_buffer;
+ y = &mb->plane[0].dst.buf;
+ u = &mb->plane[1].dst.buf;
+ v = &mb->plane[2].dst.buf;
y2 = NULL;
u2 = NULL;
@@ -54,14 +54,14 @@ static void setup_macroblock(MACROBLOCKD *mb, BLOCKSET bs) {
}
// luma
- stride = mb->dst.y_stride;
+ stride = mb->plane[0].dst.stride;
for (i = 0; i < 16; ++i) {
const int offset = (i >> 2) * 4 * stride + (i & 3) * 4;
setup_block(&blockd[i], y, y2, stride, offset, bs);
}
// chroma
- stride = mb->dst.uv_stride;
+ stride = mb->plane[1].dst.stride;
for (i = 16; i < 20; i++) {
const int offset = ((i - 16) >> 1) * 4 * stride + (i & 1) * 4;
setup_block(&blockd[i], u, u2, stride, offset, bs);
diff --git a/vp9/common/vp9_recon.c b/vp9/common/vp9_recon.c
index 08cd5f807..cc44afed8 100644
--- a/vp9/common/vp9_recon.c
+++ b/vp9/common/vp9_recon.c
@@ -53,8 +53,8 @@ void vp9_recon2b_c(uint8_t *pred_ptr, int16_t *diff_ptr, uint8_t *dst_ptr,
void vp9_recon_sby_c(MACROBLOCKD *mb, BLOCK_SIZE_TYPE bsize) {
const int bw = 16 << mb_width_log2(bsize), bh = 16 << mb_height_log2(bsize);
int x, y;
- const int stride = mb->dst.y_stride;
- uint8_t *dst = mb->dst.y_buffer;
+ const int stride = mb->plane[0].dst.stride;
+ uint8_t *dst = mb->plane[0].dst.buf;
const int16_t *diff = mb->plane[0].diff;
for (y = 0; y < bh; y++) {
@@ -70,9 +70,9 @@ void vp9_recon_sbuv_c(MACROBLOCKD *mb, BLOCK_SIZE_TYPE bsize) {
const int bwl = mb_width_log2(bsize), bhl = mb_height_log2(bsize);
const int bw = 8 << bwl, bh = 8 << bhl;
int x, y;
- const int stride = mb->dst.uv_stride;
- uint8_t *u_dst = mb->dst.u_buffer;
- uint8_t *v_dst = mb->dst.v_buffer;
+ const int stride = mb->plane[1].dst.stride;
+ uint8_t *u_dst = mb->plane[1].dst.buf;
+ uint8_t *v_dst = mb->plane[2].dst.buf;
const int16_t *u_diff = mb->plane[1].diff;
const int16_t *v_diff = mb->plane[2].diff;
diff --git a/vp9/common/vp9_reconinter.c b/vp9/common/vp9_reconinter.c
index 549993200..c5b677f0f 100644
--- a/vp9/common/vp9_reconinter.c
+++ b/vp9/common/vp9_reconinter.c
@@ -614,11 +614,11 @@ void vp9_build_inter_predictors_sbuv(MACROBLOCKD *xd,
void vp9_build_inter_predictors_sb(MACROBLOCKD *xd,
int mb_row, int mb_col,
BLOCK_SIZE_TYPE bsize) {
- uint8_t *const y = xd->dst.y_buffer;
- uint8_t *const u = xd->dst.u_buffer;
- uint8_t *const v = xd->dst.v_buffer;
- const int y_stride = xd->dst.y_stride;
- const int uv_stride = xd->dst.uv_stride;
+ uint8_t *const y = xd->plane[0].dst.buf;
+ uint8_t *const u = xd->plane[1].dst.buf;
+ uint8_t *const v = xd->plane[2].dst.buf;
+ const int y_stride = xd->plane[0].dst.stride;
+ const int uv_stride = xd->plane[1].dst.stride;
vp9_build_inter_predictors_sby(xd, y, y_stride, mb_row, mb_col, bsize);
vp9_build_inter_predictors_sbuv(xd, u, v, uv_stride, mb_row, mb_col, bsize);
@@ -670,8 +670,8 @@ static void clamp_mv_to_umv_border(MV *mv, const MACROBLOCKD *xd) {
static int64_t get_consistency_metric(MACROBLOCKD *xd,
uint8_t *tmp_y, int tmp_ystride) {
int block_size = 16 << xd->mode_info_context->mbmi.sb_type;
- uint8_t *rec_y = xd->dst.y_buffer;
- int rec_ystride = xd->dst.y_stride;
+ uint8_t *rec_y = xd->plane[0].dst.buf;
+ int rec_ystride = xd->plane[0].dst.stride;
int64_t metric = 0;
int i;
if (xd->up_available) {
@@ -1182,11 +1182,11 @@ void vp9_build_inter_predictors_sbuv(MACROBLOCKD *xd,
void vp9_build_inter_predictors_sb(MACROBLOCKD *mb,
int mb_row, int mb_col,
BLOCK_SIZE_TYPE bsize) {
- uint8_t *const y = mb->dst.y_buffer;
- uint8_t *const u = mb->dst.u_buffer;
- uint8_t *const v = mb->dst.v_buffer;
- const int y_stride = mb->dst.y_stride;
- const int uv_stride = mb->dst.uv_stride;
+ uint8_t *const y = mb->plane[0].dst.buf;
+ uint8_t *const u = mb->plane[1].dst.buf;
+ uint8_t *const v = mb->plane[2].dst.buf;
+ const int y_stride = mb->plane[0].dst.stride;
+ const int uv_stride = mb->plane[1].dst.stride;
vp9_build_inter_predictors_sby(mb, y, y_stride, mb_row, mb_col, bsize);
vp9_build_inter_predictors_sbuv(mb, u, v, uv_stride, mb_row, mb_col, bsize);
@@ -1233,9 +1233,9 @@ void vp9_build_inter_predictors_mb(MACROBLOCKD *xd,
/*encoder only*/
void vp9_build_inter4x4_predictors_mbuv(MACROBLOCKD *xd,
int mb_row, int mb_col) {
- uint8_t *const u = xd->dst.u_buffer;
- uint8_t *const v = xd->dst.v_buffer;
- const int uv_stride = xd->dst.uv_stride;
+ uint8_t *const u = xd->plane[1].dst.buf;
+ uint8_t *const v = xd->plane[2].dst.buf;
+ const int uv_stride = xd->plane[1].dst.stride;
vp9_build_inter_predictors_sbuv(xd, u, v, uv_stride, mb_row, mb_col,
BLOCK_SIZE_MB16X16);
diff --git a/vp9/common/vp9_reconinter.h b/vp9/common/vp9_reconinter.h
index ee34fc5d2..8ffdfd13b 100644
--- a/vp9/common/vp9_reconinter.h
+++ b/vp9/common/vp9_reconinter.h
@@ -83,8 +83,39 @@ static int scaled_buffer_offset(int x_offset,
int y_offset,
int stride,
const struct scale_factors *scale) {
- return scale->scale_value_y(y_offset, scale) * stride +
- scale->scale_value_x(x_offset, scale);
+ if (scale)
+ return scale->scale_value_y(y_offset, scale) * stride +
+ scale->scale_value_x(x_offset, scale);
+ return y_offset * stride + x_offset;
+}
+
+static void setup_pred_plane(struct buf_2d *dst,
+ uint8_t *src, int stride,
+ int mb_row, int mb_col,
+ const struct scale_factors *scale,
+ int subsampling_x, int subsampling_y) {
+ const int x = (16 * mb_col) >> subsampling_x;
+ const int y = (16 * mb_row) >> subsampling_y;
+ dst->buf = src + scaled_buffer_offset(x, y, stride, scale);
+ dst->stride = stride;
+}
+
+// TODO(jkoleszar): audit all uses of this that don't set mb_row, mb_col
+static void setup_dst_planes(MACROBLOCKD *xd,
+ const YV12_BUFFER_CONFIG *src,
+ int mb_row, int mb_col) {
+ setup_pred_plane(&xd->plane[0].dst,
+ src->y_buffer, src->y_stride,
+ mb_row, mb_col, NULL,
+ xd->plane[0].subsampling_x, xd->plane[0].subsampling_y);
+ setup_pred_plane(&xd->plane[1].dst,
+ src->u_buffer, src->uv_stride,
+ mb_row, mb_col, NULL,
+ xd->plane[1].subsampling_x, xd->plane[1].subsampling_y);
+ setup_pred_plane(&xd->plane[2].dst,
+ src->v_buffer, src->uv_stride,
+ mb_row, mb_col, NULL,
+ xd->plane[2].subsampling_x, xd->plane[2].subsampling_y);
}
static void setup_pred_block(YV12_BUFFER_CONFIG *dst,
diff --git a/vp9/common/vp9_reconintra.c b/vp9/common/vp9_reconintra.c
index 88c3f191e..1031be7ba 100644
--- a/vp9/common/vp9_reconintra.c
+++ b/vp9/common/vp9_reconintra.c
@@ -609,7 +609,7 @@ void vp9_build_interintra_16x16_predictors_mby(MACROBLOCKD *xd,
int ystride) {
uint8_t intrapredictor[256];
vp9_build_intra_predictors(
- xd->dst.y_buffer, xd->dst.y_stride,
+ xd->plane[0].dst.buf, xd->plane[0].dst.stride,
intrapredictor, 16,
xd->mode_info_context->mbmi.interintra_mode, 16, 16,
xd->up_available, xd->left_available, xd->right_available);
@@ -624,12 +624,12 @@ void vp9_build_interintra_16x16_predictors_mbuv(MACROBLOCKD *xd,
uint8_t uintrapredictor[64];
uint8_t vintrapredictor[64];
vp9_build_intra_predictors(
- xd->dst.u_buffer, xd->dst.uv_stride,
+ xd->plane[1].dst.buf, xd->plane[1].dst.stride,
uintrapredictor, 8,
xd->mode_info_context->mbmi.interintra_uv_mode, 8, 8,
xd->up_available, xd->left_available, xd->right_available);
vp9_build_intra_predictors(
- xd->dst.v_buffer, xd->dst.uv_stride,
+ xd->plane[2].dst.buf, xd->plane[1].dst.stride,
vintrapredictor, 8,
xd->mode_info_context->mbmi.interintra_uv_mode, 8, 8,
xd->up_available, xd->left_available, xd->right_available);
@@ -644,7 +644,7 @@ void vp9_build_interintra_32x32_predictors_sby(MACROBLOCKD *xd,
int ystride) {
uint8_t intrapredictor[1024];
vp9_build_intra_predictors(
- xd->dst.y_buffer, xd->dst.y_stride,
+ xd->plane[0].dst.buf, xd->plane[0].dst.stride,
intrapredictor, 32,
xd->mode_info_context->mbmi.interintra_mode, 32, 32,
xd->up_available, xd->left_available, xd->right_available);
@@ -659,12 +659,12 @@ void vp9_build_interintra_32x32_predictors_sbuv(MACROBLOCKD *xd,
uint8_t uintrapredictor[256];
uint8_t vintrapredictor[256];
vp9_build_intra_predictors(
- xd->dst.u_buffer, xd->dst.uv_stride,
+ xd->plane[1].dst.buf, xd->plane[1].dst.stride,
uintrapredictor, 16,
xd->mode_info_context->mbmi.interintra_uv_mode, 16, 16,
xd->up_available, xd->left_available, xd->right_available);
vp9_build_intra_predictors(
- xd->dst.v_buffer, xd->dst.uv_stride,
+ xd->plane[2].dst.buf, xd->plane[1].dst.stride,
vintrapredictor, 16,
xd->mode_info_context->mbmi.interintra_uv_mode, 16, 16,
xd->up_available, xd->left_available, xd->right_available);
@@ -689,7 +689,7 @@ void vp9_build_interintra_64x64_predictors_sby(MACROBLOCKD *xd,
int ystride) {
uint8_t intrapredictor[4096];
const int mode = xd->mode_info_context->mbmi.interintra_mode;
- vp9_build_intra_predictors(xd->dst.y_buffer, xd->dst.y_stride,
+ vp9_build_intra_predictors(xd->plane[0].dst.buf, xd->plane[0].dst.stride,
intrapredictor, 64, mode, 64, 64,
xd->up_available, xd->left_available,
xd->right_available);
@@ -704,11 +704,11 @@ void vp9_build_interintra_64x64_predictors_sbuv(MACROBLOCKD *xd,
uint8_t uintrapredictor[1024];
uint8_t vintrapredictor[1024];
const int mode = xd->mode_info_context->mbmi.interintra_uv_mode;
- vp9_build_intra_predictors(xd->dst.u_buffer, xd->dst.uv_stride,
+ vp9_build_intra_predictors(xd->plane[1].dst.buf, xd->plane[1].dst.stride,
uintrapredictor, 32, mode, 32, 32,
xd->up_available, xd->left_available,
xd->right_available);
- vp9_build_intra_predictors(xd->dst.v_buffer, xd->dst.uv_stride,
+ vp9_build_intra_predictors(xd->plane[2].dst.buf, xd->plane[1].dst.stride,
vintrapredictor, 32, mode, 32, 32,
xd->up_available, xd->left_available,
xd->right_available);
@@ -734,8 +734,8 @@ void vp9_build_intra_predictors_sby_s(MACROBLOCKD *xd,
const int bwl = b_width_log2(bsize), bw = 4 << bwl;
const int bhl = b_height_log2(bsize), bh = 4 << bhl;
- vp9_build_intra_predictors(xd->dst.y_buffer, xd->dst.y_stride,
- xd->dst.y_buffer, xd->dst.y_stride,
+ vp9_build_intra_predictors(xd->plane[0].dst.buf, xd->plane[0].dst.stride,
+ xd->plane[0].dst.buf, xd->plane[0].dst.stride,
xd->mode_info_context->mbmi.mode,
bw, bh,
xd->up_available, xd->left_available,
@@ -747,13 +747,13 @@ void vp9_build_intra_predictors_sbuv_s(MACROBLOCKD *xd,
const int bwl = b_width_log2(bsize) - 1, bw = 4 << bwl;
const int bhl = b_height_log2(bsize) - 1, bh = 4 << bhl;
- vp9_build_intra_predictors(xd->dst.u_buffer, xd->dst.uv_stride,
- xd->dst.u_buffer, xd->dst.uv_stride,
+ vp9_build_intra_predictors(xd->plane[1].dst.buf, xd->plane[1].dst.stride,
+ xd->plane[1].dst.buf, xd->plane[1].dst.stride,
xd->mode_info_context->mbmi.uv_mode,
bw, bh, xd->up_available,
xd->left_available, xd->right_available);
- vp9_build_intra_predictors(xd->dst.v_buffer, xd->dst.uv_stride,
- xd->dst.v_buffer, xd->dst.uv_stride,
+ vp9_build_intra_predictors(xd->plane[2].dst.buf, xd->plane[1].dst.stride,
+ xd->plane[2].dst.buf, xd->plane[1].dst.stride,
xd->mode_info_context->mbmi.uv_mode,
bw, bh, xd->up_available,
xd->left_available, xd->right_available);
diff --git a/vp9/common/x86/vp9_recon_wrapper_sse2.c b/vp9/common/x86/vp9_recon_wrapper_sse2.c
index 12d2f970c..97148fbb8 100644
--- a/vp9/common/x86/vp9_recon_wrapper_sse2.c
+++ b/vp9/common/x86/vp9_recon_wrapper_sse2.c
@@ -35,7 +35,7 @@ static void build_intra_predictors_mbuv_x86(MACROBLOCKD *xd,
build_intra_pred_mbuv_fn_t ho_fn) {
int mode = xd->mode_info_context->mbmi.uv_mode;
build_intra_pred_mbuv_fn_t fn;
- int src_stride = xd->dst.uv_stride;
+ int src_stride = xd->plane[1].dst.stride;
switch (mode) {
case V_PRED:
@@ -68,34 +68,34 @@ static void build_intra_predictors_mbuv_x86(MACROBLOCKD *xd,
return;
}
- fn(dst_u, dst_stride, xd->dst.u_buffer, src_stride);
- fn(dst_v, dst_stride, xd->dst.v_buffer, src_stride);
+ fn(dst_u, dst_stride, xd->plane[1].dst.buf, src_stride);
+ fn(dst_v, dst_stride, xd->plane[2].dst.buf, src_stride);
}
void vp9_build_intra_predictors_mbuv_sse2(MACROBLOCKD *xd) {
- build_intra_predictors_mbuv_x86(xd, xd->dst.u_buffer,
- xd->dst.v_buffer, xd->dst.uv_stride,
+ build_intra_predictors_mbuv_x86(xd, xd->plane[1].dst.buf,
+ xd->plane[2].dst.buf, xd->plane[1].dst.stride,
vp9_intra_pred_uv_tm_sse2,
vp9_intra_pred_uv_ho_mmx2);
}
void vp9_build_intra_predictors_mbuv_ssse3(MACROBLOCKD *xd) {
- build_intra_predictors_mbuv_x86(xd, xd->dst.u_buffer,
- xd->dst.v_buffer, xd->dst.uv_stride,
+ build_intra_predictors_mbuv_x86(xd, xd->plane[1].dst.buf,
+ xd->plane[2].dst.buf, xd->plane[1].dst.stride,
vp9_intra_pred_uv_tm_ssse3,
vp9_intra_pred_uv_ho_ssse3);
}
void vp9_build_intra_predictors_mbuv_s_sse2(MACROBLOCKD *xd) {
- build_intra_predictors_mbuv_x86(xd, xd->dst.u_buffer,
- xd->dst.v_buffer, xd->dst.uv_stride,
+ build_intra_predictors_mbuv_x86(xd, xd->plane[1].dst.buf,
+ xd->plane[2].dst.buf, xd->plane[1].dst.stride,
vp9_intra_pred_uv_tm_sse2,
vp9_intra_pred_uv_ho_mmx2);
}
void vp9_build_intra_predictors_mbuv_s_ssse3(MACROBLOCKD *xd) {
- build_intra_predictors_mbuv_x86(xd, xd->dst.u_buffer,
- xd->dst.v_buffer, xd->dst.uv_stride,
+ build_intra_predictors_mbuv_x86(xd, xd->plane[1].dst.buf,
+ xd->plane[2].dst.buf, xd->plane[1].dst.stride,
vp9_intra_pred_uv_tm_ssse3,
vp9_intra_pred_uv_ho_ssse3);
}