2010-05-18 11:58:33 -04:00
|
|
|
/*
|
2010-09-09 08:16:39 -04:00
|
|
|
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
2010-05-18 11:58:33 -04:00
|
|
|
*
|
2010-06-18 12:39:21 -04:00
|
|
|
* Use of this source code is governed by a BSD-style license
|
2010-06-04 16:19:40 -04:00
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
2010-06-18 12:39:21 -04:00
|
|
|
* in the file PATENTS. All contributing project authors may
|
2010-06-04 16:19:40 -04:00
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
2010-05-18 11:58:33 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2012-11-28 10:41:40 -08:00
|
|
|
#include "vp9/common/vp9_blockd.h"
|
2010-05-18 11:58:33 -04:00
|
|
|
|
2012-07-13 15:21:29 -07:00
|
|
|
typedef enum {
|
|
|
|
PRED = 0,
|
|
|
|
DEST = 1
|
2010-05-18 11:58:33 -04:00
|
|
|
} BLOCKSET;
|
|
|
|
|
2012-12-18 15:31:19 -08:00
|
|
|
static void setup_block(BLOCKD *b,
|
|
|
|
int mv_stride,
|
|
|
|
uint8_t **base,
|
|
|
|
uint8_t **base2,
|
|
|
|
int Stride,
|
|
|
|
int offset,
|
|
|
|
BLOCKSET bs) {
|
2012-07-13 15:21:29 -07:00
|
|
|
if (bs == DEST) {
|
|
|
|
b->dst_stride = Stride;
|
|
|
|
b->dst = offset;
|
|
|
|
b->base_dst = base;
|
|
|
|
} else {
|
|
|
|
b->pre_stride = Stride;
|
|
|
|
b->pre = offset;
|
|
|
|
b->base_pre = base;
|
|
|
|
b->base_second_pre = base2;
|
|
|
|
}
|
2010-05-18 11:58:33 -04:00
|
|
|
}
|
|
|
|
|
2012-08-14 11:32:29 +01:00
|
|
|
static void setup_macroblock(MACROBLOCKD *xd, BLOCKSET bs) {
|
2012-07-13 15:21:29 -07:00
|
|
|
int block;
|
2010-05-18 11:58:33 -04:00
|
|
|
|
2012-12-18 15:31:19 -08:00
|
|
|
uint8_t **y, **u, **v;
|
2013-01-08 10:11:26 -08:00
|
|
|
uint8_t **y2 = NULL, **u2 = NULL, **v2 = NULL;
|
2012-08-14 11:32:29 +01:00
|
|
|
BLOCKD *blockd = xd->block;
|
|
|
|
int stride;
|
2010-05-18 11:58:33 -04:00
|
|
|
|
2012-07-13 15:21:29 -07:00
|
|
|
if (bs == DEST) {
|
2012-08-14 11:32:29 +01:00
|
|
|
y = &xd->dst.y_buffer;
|
|
|
|
u = &xd->dst.u_buffer;
|
|
|
|
v = &xd->dst.v_buffer;
|
2012-07-13 15:21:29 -07:00
|
|
|
} else {
|
2012-08-14 11:32:29 +01:00
|
|
|
y = &xd->pre.y_buffer;
|
|
|
|
u = &xd->pre.u_buffer;
|
|
|
|
v = &xd->pre.v_buffer;
|
2010-05-18 11:58:33 -04:00
|
|
|
|
2012-08-14 11:32:29 +01:00
|
|
|
y2 = &xd->second_pre.y_buffer;
|
|
|
|
u2 = &xd->second_pre.u_buffer;
|
|
|
|
v2 = &xd->second_pre.v_buffer;
|
2012-07-13 15:21:29 -07:00
|
|
|
}
|
2010-05-18 11:58:33 -04:00
|
|
|
|
2012-08-14 11:32:29 +01:00
|
|
|
stride = xd->dst.y_stride;
|
2012-07-13 15:21:29 -07:00
|
|
|
for (block = 0; block < 16; block++) { /* y blocks */
|
2012-08-14 11:32:29 +01:00
|
|
|
setup_block(&blockd[block], stride, y, y2, stride,
|
|
|
|
(block >> 2) * 4 * stride + (block & 3) * 4, bs);
|
2012-07-13 15:21:29 -07:00
|
|
|
}
|
2010-05-18 11:58:33 -04:00
|
|
|
|
2012-08-14 11:32:29 +01:00
|
|
|
stride = xd->dst.uv_stride;
|
2012-07-13 15:21:29 -07:00
|
|
|
for (block = 16; block < 20; block++) { /* U and V blocks */
|
2012-08-14 11:32:29 +01:00
|
|
|
setup_block(&blockd[block], stride, u, u2, stride,
|
|
|
|
((block - 16) >> 1) * 4 * stride + (block & 1) * 4, bs);
|
2012-07-13 15:21:29 -07:00
|
|
|
|
2012-08-14 11:32:29 +01:00
|
|
|
setup_block(&blockd[block + 4], stride, v, v2, stride,
|
|
|
|
((block - 16) >> 1) * 4 * stride + (block & 1) * 4, bs);
|
2012-07-13 15:21:29 -07:00
|
|
|
}
|
2013-02-08 17:49:44 -08:00
|
|
|
|
|
|
|
// TODO(jkoleszar): this will move once we're actually scaling.
|
|
|
|
xd->scale_factor[0].x_num = 1;
|
|
|
|
xd->scale_factor[0].x_den = 1;
|
|
|
|
xd->scale_factor[0].y_num = 1;
|
|
|
|
xd->scale_factor[0].y_den = 1;
|
|
|
|
xd->scale_factor[0].x_offset_q4 = 0;
|
|
|
|
xd->scale_factor[0].y_offset_q4 = 0;
|
|
|
|
xd->scale_factor[1]= xd->scale_factor[0];
|
|
|
|
xd->scale_factor_uv[0] = xd->scale_factor[0];
|
|
|
|
xd->scale_factor_uv[1] = xd->scale_factor[1];
|
2010-05-18 11:58:33 -04:00
|
|
|
}
|
|
|
|
|
2012-10-30 16:25:53 -07:00
|
|
|
void vp9_setup_block_dptrs(MACROBLOCKD *xd) {
|
2012-07-13 15:21:29 -07:00
|
|
|
int r, c;
|
2012-08-14 11:32:29 +01:00
|
|
|
BLOCKD *blockd = xd->block;
|
2012-07-13 15:21:29 -07:00
|
|
|
|
|
|
|
for (r = 0; r < 4; r++) {
|
|
|
|
for (c = 0; c < 4; c++) {
|
2012-08-14 11:32:29 +01:00
|
|
|
blockd[r * 4 + c].diff = &xd->diff[r * 4 * 16 + c * 4];
|
|
|
|
blockd[r * 4 + c].predictor = xd->predictor + r * 4 * 16 + c * 4;
|
2010-05-18 11:58:33 -04:00
|
|
|
}
|
2012-07-13 15:21:29 -07:00
|
|
|
}
|
2010-05-18 11:58:33 -04:00
|
|
|
|
2012-07-13 15:21:29 -07:00
|
|
|
for (r = 0; r < 2; r++) {
|
|
|
|
for (c = 0; c < 2; c++) {
|
2012-08-14 11:32:29 +01:00
|
|
|
blockd[16 + r * 2 + c].diff = &xd->diff[256 + r * 4 * 8 + c * 4];
|
|
|
|
blockd[16 + r * 2 + c].predictor =
|
|
|
|
xd->predictor + 256 + r * 4 * 8 + c * 4;
|
2010-05-18 11:58:33 -04:00
|
|
|
|
|
|
|
}
|
2012-07-13 15:21:29 -07:00
|
|
|
}
|
2010-05-18 11:58:33 -04:00
|
|
|
|
2012-07-13 15:21:29 -07:00
|
|
|
for (r = 0; r < 2; r++) {
|
|
|
|
for (c = 0; c < 2; c++) {
|
2012-08-14 11:32:29 +01:00
|
|
|
blockd[20 + r * 2 + c].diff = &xd->diff[320 + r * 4 * 8 + c * 4];
|
|
|
|
blockd[20 + r * 2 + c].predictor =
|
|
|
|
xd->predictor + 320 + r * 4 * 8 + c * 4;
|
2010-05-18 11:58:33 -04:00
|
|
|
|
|
|
|
}
|
2012-07-13 15:21:29 -07:00
|
|
|
}
|
2010-05-18 11:58:33 -04:00
|
|
|
|
2013-02-15 10:15:42 -08:00
|
|
|
for (r = 0; r < 24; r++) {
|
2012-08-14 11:32:29 +01:00
|
|
|
blockd[r].qcoeff = xd->qcoeff + r * 16;
|
|
|
|
blockd[r].dqcoeff = xd->dqcoeff + r * 16;
|
2012-07-13 15:21:29 -07:00
|
|
|
}
|
2010-05-18 11:58:33 -04:00
|
|
|
}
|
|
|
|
|
2012-10-30 16:25:53 -07:00
|
|
|
void vp9_build_block_doffsets(MACROBLOCKD *xd) {
|
2012-07-13 15:21:29 -07:00
|
|
|
/* handle the destination pitch features */
|
2012-08-14 11:32:29 +01:00
|
|
|
setup_macroblock(xd, DEST);
|
|
|
|
setup_macroblock(xd, PRED);
|
2010-05-18 11:58:33 -04:00
|
|
|
}
|