2010-05-18 17:58:33 +02:00
|
|
|
/*
|
2010-09-09 14:16:39 +02:00
|
|
|
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
2010-05-18 17:58:33 +02:00
|
|
|
*
|
2010-06-18 18:39:21 +02:00
|
|
|
* Use of this source code is governed by a BSD-style license
|
2010-06-04 22:19:40 +02: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 18:39:21 +02:00
|
|
|
* in the file PATENTS. All contributing project authors may
|
2010-06-04 22:19:40 +02:00
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
2010-05-18 17:58:33 +02:00
|
|
|
*/
|
|
|
|
|
2012-05-15 01:21:01 +02:00
|
|
|
#include <stdio.h>
|
2010-05-18 17:58:33 +02:00
|
|
|
#include "vpx_ports/config.h"
|
2012-11-09 02:09:30 +01:00
|
|
|
#include "vp9_rtcd.h"
|
2012-11-28 19:41:40 +01:00
|
|
|
#include "vp9/common/vp9_reconintra.h"
|
2010-05-18 17:58:33 +02:00
|
|
|
#include "vpx_mem/vpx_mem.h"
|
|
|
|
|
2012-10-31 00:25:53 +01:00
|
|
|
/* For skip_recon_mb(), add vp9_build_intra_predictors_mby_s(MACROBLOCKD *xd)
|
|
|
|
* and vp9_build_intra_predictors_mbuv_s(MACROBLOCKD *xd).
|
2010-10-28 01:04:02 +02:00
|
|
|
*/
|
2012-05-15 01:21:01 +02:00
|
|
|
|
2012-10-30 02:15:04 +01:00
|
|
|
static void d27_predictor(uint8_t *ypred_ptr, int y_stride, int n,
|
|
|
|
uint8_t *yabove_row, uint8_t *yleft_col) {
|
2012-07-14 00:21:29 +02:00
|
|
|
int r, c, h, w, v;
|
|
|
|
int a, b;
|
|
|
|
r = 0;
|
|
|
|
for (c = 0; c < n - 2; c++) {
|
|
|
|
if (c & 1)
|
|
|
|
a = yleft_col[r + 1];
|
|
|
|
else
|
|
|
|
a = (yleft_col[r] + yleft_col[r + 1] + 1) >> 1;
|
|
|
|
b = yabove_row[c + 2];
|
|
|
|
ypred_ptr[c] = (2 * a + (c + 1) * b + (c + 3) / 2) / (c + 3);
|
|
|
|
}
|
|
|
|
for (r = 1; r < n / 2 - 1; r++) {
|
|
|
|
for (c = 0; c < n - 2 - 2 * r; c++) {
|
|
|
|
if (c & 1)
|
|
|
|
a = yleft_col[r + 1];
|
|
|
|
else
|
|
|
|
a = (yleft_col[r] + yleft_col[r + 1] + 1) >> 1;
|
|
|
|
b = ypred_ptr[(r - 1) * y_stride + c + 2];
|
|
|
|
ypred_ptr[r * y_stride + c] = (2 * a + (c + 1) * b + (c + 3) / 2) / (c + 3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (; r < n - 1; ++r) {
|
|
|
|
for (c = 0; c < n; c++) {
|
|
|
|
v = (c & 1 ? yleft_col[r + 1] : (yleft_col[r] + yleft_col[r + 1] + 1) >> 1);
|
|
|
|
h = r - c / 2;
|
|
|
|
ypred_ptr[h * y_stride + c] = v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
c = 0;
|
|
|
|
r = n - 1;
|
|
|
|
ypred_ptr[r * y_stride] = (ypred_ptr[(r - 1) * y_stride] +
|
|
|
|
yleft_col[r] + 1) >> 1;
|
|
|
|
for (r = n - 2; r >= n / 2; --r) {
|
|
|
|
w = c + (n - 1 - r) * 2;
|
|
|
|
ypred_ptr[r * y_stride + w] = (ypred_ptr[(r - 1) * y_stride + w] +
|
|
|
|
ypred_ptr[r * y_stride + w - 1] + 1) >> 1;
|
|
|
|
}
|
|
|
|
for (c = 1; c < n; c++) {
|
|
|
|
for (r = n - 1; r >= n / 2 + c / 2; --r) {
|
|
|
|
w = c + (n - 1 - r) * 2;
|
|
|
|
ypred_ptr[r * y_stride + w] = (ypred_ptr[(r - 1) * y_stride + w] +
|
|
|
|
ypred_ptr[r * y_stride + w - 1] + 1) >> 1;
|
|
|
|
}
|
|
|
|
}
|
2012-05-15 01:21:01 +02:00
|
|
|
}
|
|
|
|
|
2012-10-30 02:15:04 +01:00
|
|
|
static void d63_predictor(uint8_t *ypred_ptr, int y_stride, int n,
|
|
|
|
uint8_t *yabove_row, uint8_t *yleft_col) {
|
2012-07-14 00:21:29 +02:00
|
|
|
int r, c, h, w, v;
|
|
|
|
int a, b;
|
|
|
|
c = 0;
|
|
|
|
for (r = 0; r < n - 2; r++) {
|
|
|
|
if (r & 1)
|
|
|
|
a = yabove_row[c + 1];
|
|
|
|
else
|
|
|
|
a = (yabove_row[c] + yabove_row[c + 1] + 1) >> 1;
|
|
|
|
b = yleft_col[r + 2];
|
|
|
|
ypred_ptr[r * y_stride] = (2 * a + (r + 1) * b + (r + 3) / 2) / (r + 3);
|
|
|
|
}
|
|
|
|
for (c = 1; c < n / 2 - 1; c++) {
|
|
|
|
for (r = 0; r < n - 2 - 2 * c; r++) {
|
|
|
|
if (r & 1)
|
|
|
|
a = yabove_row[c + 1];
|
|
|
|
else
|
|
|
|
a = (yabove_row[c] + yabove_row[c + 1] + 1) >> 1;
|
|
|
|
b = ypred_ptr[(r + 2) * y_stride + c - 1];
|
|
|
|
ypred_ptr[r * y_stride + c] = (2 * a + (c + 1) * b + (c + 3) / 2) / (c + 3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (; c < n - 1; ++c) {
|
|
|
|
for (r = 0; r < n; r++) {
|
|
|
|
v = (r & 1 ? yabove_row[c + 1] : (yabove_row[c] + yabove_row[c + 1] + 1) >> 1);
|
|
|
|
w = c - r / 2;
|
|
|
|
ypred_ptr[r * y_stride + w] = v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
r = 0;
|
|
|
|
c = n - 1;
|
|
|
|
ypred_ptr[c] = (ypred_ptr[(c - 1)] + yabove_row[c] + 1) >> 1;
|
|
|
|
for (c = n - 2; c >= n / 2; --c) {
|
|
|
|
h = r + (n - 1 - c) * 2;
|
|
|
|
ypred_ptr[h * y_stride + c] = (ypred_ptr[h * y_stride + c - 1] +
|
|
|
|
ypred_ptr[(h - 1) * y_stride + c] + 1) >> 1;
|
|
|
|
}
|
|
|
|
for (r = 1; r < n; r++) {
|
|
|
|
for (c = n - 1; c >= n / 2 + r / 2; --c) {
|
|
|
|
h = r + (n - 1 - c) * 2;
|
|
|
|
ypred_ptr[h * y_stride + c] = (ypred_ptr[h * y_stride + c - 1] +
|
|
|
|
ypred_ptr[(h - 1) * y_stride + c] + 1) >> 1;
|
|
|
|
}
|
|
|
|
}
|
2012-05-15 01:21:01 +02:00
|
|
|
}
|
|
|
|
|
2012-10-30 02:15:04 +01:00
|
|
|
static void d45_predictor(uint8_t *ypred_ptr, int y_stride, int n,
|
|
|
|
uint8_t *yabove_row, uint8_t *yleft_col) {
|
2012-07-14 00:21:29 +02:00
|
|
|
int r, c;
|
|
|
|
for (r = 0; r < n - 1; ++r) {
|
|
|
|
for (c = 0; c <= r; ++c) {
|
|
|
|
ypred_ptr[(r - c) * y_stride + c] =
|
|
|
|
(yabove_row[r + 1] * (c + 1) +
|
|
|
|
yleft_col[r + 1] * (r - c + 1) + r / 2 + 1) / (r + 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (c = 0; c <= r; ++c) {
|
|
|
|
int yabove_ext = yabove_row[r]; // 2*yabove_row[r] - yabove_row[r-1];
|
|
|
|
int yleft_ext = yleft_col[r]; // 2*yleft_col[r] - yleft_col[r-1];
|
|
|
|
yabove_ext = (yabove_ext > 255 ? 255 : (yabove_ext < 0 ? 0 : yabove_ext));
|
|
|
|
yleft_ext = (yleft_ext > 255 ? 255 : (yleft_ext < 0 ? 0 : yleft_ext));
|
|
|
|
ypred_ptr[(r - c) * y_stride + c] =
|
|
|
|
(yabove_ext * (c + 1) +
|
|
|
|
yleft_ext * (r - c + 1) + r / 2 + 1) / (r + 2);
|
|
|
|
}
|
|
|
|
for (r = 1; r < n; ++r) {
|
|
|
|
for (c = n - r; c < n; ++c)
|
|
|
|
ypred_ptr[r * y_stride + c] = (ypred_ptr[(r - 1) * y_stride + c] +
|
|
|
|
ypred_ptr[r * y_stride + c - 1] + 1) >> 1;
|
|
|
|
}
|
2012-05-15 01:21:01 +02:00
|
|
|
}
|
|
|
|
|
2012-10-30 02:15:04 +01:00
|
|
|
static void d117_predictor(uint8_t *ypred_ptr, int y_stride, int n,
|
|
|
|
uint8_t *yabove_row, uint8_t *yleft_col) {
|
2012-07-14 00:21:29 +02:00
|
|
|
int r, c;
|
|
|
|
for (c = 0; c < n; c++)
|
|
|
|
ypred_ptr[c] = (yabove_row[c - 1] + yabove_row[c] + 1) >> 1;
|
|
|
|
ypred_ptr += y_stride;
|
|
|
|
for (c = 0; c < n; c++)
|
|
|
|
ypred_ptr[c] = yabove_row[c - 1];
|
|
|
|
ypred_ptr += y_stride;
|
|
|
|
for (r = 2; r < n; ++r) {
|
|
|
|
ypred_ptr[0] = yleft_col[r - 2];
|
|
|
|
for (c = 1; c < n; c++)
|
|
|
|
ypred_ptr[c] = ypred_ptr[-2 * y_stride + c - 1];
|
2012-05-15 01:21:01 +02:00
|
|
|
ypred_ptr += y_stride;
|
2012-07-14 00:21:29 +02:00
|
|
|
}
|
2012-05-15 01:21:01 +02:00
|
|
|
}
|
|
|
|
|
2012-10-30 02:15:04 +01:00
|
|
|
static void d135_predictor(uint8_t *ypred_ptr, int y_stride, int n,
|
|
|
|
uint8_t *yabove_row, uint8_t *yleft_col) {
|
2012-07-14 00:21:29 +02:00
|
|
|
int r, c;
|
|
|
|
ypred_ptr[0] = yabove_row[-1];
|
|
|
|
for (c = 1; c < n; c++)
|
|
|
|
ypred_ptr[c] = yabove_row[c - 1];
|
|
|
|
for (r = 1; r < n; ++r)
|
|
|
|
ypred_ptr[r * y_stride] = yleft_col[r - 1];
|
|
|
|
|
|
|
|
ypred_ptr += y_stride;
|
|
|
|
for (r = 1; r < n; ++r) {
|
|
|
|
for (c = 1; c < n; c++) {
|
|
|
|
ypred_ptr[c] = ypred_ptr[-y_stride + c - 1];
|
2012-05-15 01:21:01 +02:00
|
|
|
}
|
2012-07-14 00:21:29 +02:00
|
|
|
ypred_ptr += y_stride;
|
|
|
|
}
|
2012-05-15 01:21:01 +02:00
|
|
|
}
|
|
|
|
|
2012-10-30 02:15:04 +01:00
|
|
|
static void d153_predictor(uint8_t *ypred_ptr, int y_stride, int n,
|
|
|
|
uint8_t *yabove_row, uint8_t *yleft_col) {
|
2012-07-14 00:21:29 +02:00
|
|
|
int r, c;
|
|
|
|
ypred_ptr[0] = (yabove_row[-1] + yleft_col[0] + 1) >> 1;
|
|
|
|
for (r = 1; r < n; r++)
|
|
|
|
ypred_ptr[r * y_stride] = (yleft_col[r - 1] + yleft_col[r] + 1) >> 1;
|
|
|
|
ypred_ptr++;
|
|
|
|
ypred_ptr[0] = yabove_row[-1];
|
|
|
|
for (r = 1; r < n; r++)
|
|
|
|
ypred_ptr[r * y_stride] = yleft_col[r - 1];
|
|
|
|
ypred_ptr++;
|
|
|
|
|
|
|
|
for (c = 0; c < n - 2; c++)
|
|
|
|
ypred_ptr[c] = yabove_row[c];
|
|
|
|
ypred_ptr += y_stride;
|
|
|
|
for (r = 1; r < n; ++r) {
|
2012-05-15 01:21:01 +02:00
|
|
|
for (c = 0; c < n - 2; c++)
|
2012-07-14 00:21:29 +02:00
|
|
|
ypred_ptr[c] = ypred_ptr[-y_stride + c - 2];
|
2012-05-15 01:21:01 +02:00
|
|
|
ypred_ptr += y_stride;
|
2012-07-14 00:21:29 +02:00
|
|
|
}
|
2012-05-15 01:21:01 +02:00
|
|
|
}
|
|
|
|
|
2012-10-09 22:19:15 +02:00
|
|
|
static void corner_predictor(unsigned char *ypred_ptr, int y_stride, int n,
|
|
|
|
unsigned char *yabove_row,
|
|
|
|
unsigned char *yleft_col) {
|
2012-11-12 18:21:10 +01:00
|
|
|
int mh, mv, maxgradh, maxgradv, x, y, nx, ny;
|
2012-10-09 22:19:15 +02:00
|
|
|
int i, j;
|
|
|
|
int top_left = yabove_row[-1];
|
|
|
|
mh = mv = 0;
|
|
|
|
maxgradh = yabove_row[1] - top_left;
|
|
|
|
maxgradv = yleft_col[1] - top_left;
|
|
|
|
for (i = 2; i < n; ++i) {
|
|
|
|
int gh = yabove_row[i] - yabove_row[i - 2];
|
|
|
|
int gv = yleft_col[i] - yleft_col[i - 2];
|
|
|
|
if (gh > maxgradh) {
|
|
|
|
maxgradh = gh;
|
|
|
|
mh = i - 1;
|
|
|
|
}
|
|
|
|
if (gv > maxgradv) {
|
|
|
|
maxgradv = gv;
|
|
|
|
mv = i - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nx = mh + mv + 3;
|
|
|
|
ny = 2 * n + 1 - nx;
|
|
|
|
|
|
|
|
x = top_left;
|
|
|
|
for (i = 0; i <= mh; ++i) x += yabove_row[i];
|
|
|
|
for (i = 0; i <= mv; ++i) x += yleft_col[i];
|
|
|
|
x += (nx >> 1);
|
|
|
|
x /= nx;
|
|
|
|
y = 0;
|
|
|
|
for (i = mh + 1; i < n; ++i) y += yabove_row[i];
|
|
|
|
for (i = mv + 1; i < n; ++i) y += yleft_col[i];
|
|
|
|
y += (ny >> 1);
|
|
|
|
y /= ny;
|
|
|
|
|
|
|
|
for (i = 0; i < n; ++i) {
|
|
|
|
for (j = 0; j < n; ++j)
|
|
|
|
ypred_ptr[j] = (i <= mh && j <= mv ? x : y);
|
|
|
|
ypred_ptr += y_stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-31 00:25:53 +01:00
|
|
|
void vp9_recon_intra_mbuv(MACROBLOCKD *xd) {
|
2012-07-14 00:21:29 +02:00
|
|
|
int i;
|
|
|
|
for (i = 16; i < 24; i += 2) {
|
2012-08-14 12:32:29 +02:00
|
|
|
BLOCKD *b = &xd->block[i];
|
2012-11-01 00:09:17 +01:00
|
|
|
vp9_recon2b(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
|
2012-07-14 00:21:29 +02:00
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
2012-10-31 00:25:53 +01:00
|
|
|
void vp9_build_intra_predictors_internal(unsigned char *src, int src_stride,
|
2012-08-20 23:43:34 +02:00
|
|
|
unsigned char *ypred_ptr,
|
2012-08-23 01:05:21 +02:00
|
|
|
int y_stride, int mode, int bsize,
|
|
|
|
int up_available, int left_available) {
|
2012-07-14 00:21:29 +02:00
|
|
|
|
2012-08-20 23:43:34 +02:00
|
|
|
unsigned char *yabove_row = src - src_stride;
|
|
|
|
unsigned char yleft_col[32];
|
2012-07-14 00:21:29 +02:00
|
|
|
unsigned char ytop_left = yabove_row[-1];
|
|
|
|
int r, c, i;
|
|
|
|
|
2012-08-20 23:43:34 +02:00
|
|
|
for (i = 0; i < bsize; i++) {
|
2012-08-22 01:45:51 +02:00
|
|
|
yleft_col[i] = src[i * src_stride - 1];
|
2012-07-14 00:21:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* for Y */
|
|
|
|
switch (mode) {
|
|
|
|
case DC_PRED: {
|
|
|
|
int expected_dc;
|
|
|
|
int i;
|
|
|
|
int shift;
|
|
|
|
int average = 0;
|
2012-08-20 23:43:34 +02:00
|
|
|
int log2_bsize_minus_1;
|
|
|
|
|
2012-08-23 01:05:21 +02:00
|
|
|
assert(bsize == 4 || bsize == 8 || bsize == 16 || bsize == 32);
|
|
|
|
if (bsize == 4) {
|
|
|
|
log2_bsize_minus_1 = 1;
|
|
|
|
} else if (bsize == 8) {
|
2012-08-20 23:43:34 +02:00
|
|
|
log2_bsize_minus_1 = 2;
|
|
|
|
} else if (bsize == 16) {
|
|
|
|
log2_bsize_minus_1 = 3;
|
|
|
|
} else /* bsize == 32 */ {
|
|
|
|
log2_bsize_minus_1 = 4;
|
|
|
|
}
|
2012-07-14 00:21:29 +02:00
|
|
|
|
2012-08-23 01:05:21 +02:00
|
|
|
if (up_available || left_available) {
|
|
|
|
if (up_available) {
|
2012-08-20 23:43:34 +02:00
|
|
|
for (i = 0; i < bsize; i++) {
|
2012-07-14 00:21:29 +02:00
|
|
|
average += yabove_row[i];
|
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
2012-08-23 01:05:21 +02:00
|
|
|
if (left_available) {
|
2012-08-20 23:43:34 +02:00
|
|
|
for (i = 0; i < bsize; i++) {
|
2012-07-14 00:21:29 +02:00
|
|
|
average += yleft_col[i];
|
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
2012-08-23 01:05:21 +02:00
|
|
|
shift = log2_bsize_minus_1 + up_available + left_available;
|
2012-07-14 00:21:29 +02:00
|
|
|
expected_dc = (average + (1 << (shift - 1))) >> shift;
|
|
|
|
} else {
|
|
|
|
expected_dc = 128;
|
|
|
|
}
|
|
|
|
|
2012-08-20 23:43:34 +02:00
|
|
|
for (r = 0; r < bsize; r++) {
|
|
|
|
vpx_memset(ypred_ptr, expected_dc, bsize);
|
|
|
|
ypred_ptr += y_stride;
|
2012-07-14 00:21:29 +02:00
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
break;
|
2012-07-14 00:21:29 +02:00
|
|
|
case V_PRED: {
|
2012-08-20 23:43:34 +02:00
|
|
|
for (r = 0; r < bsize; r++) {
|
|
|
|
memcpy(ypred_ptr, yabove_row, bsize);
|
2012-07-14 00:21:29 +02:00
|
|
|
ypred_ptr += y_stride;
|
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
break;
|
2012-07-14 00:21:29 +02:00
|
|
|
case H_PRED: {
|
2012-08-20 23:43:34 +02:00
|
|
|
for (r = 0; r < bsize; r++) {
|
|
|
|
vpx_memset(ypred_ptr, yleft_col[r], bsize);
|
2012-07-14 00:21:29 +02:00
|
|
|
ypred_ptr += y_stride;
|
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
break;
|
2012-07-14 00:21:29 +02:00
|
|
|
case TM_PRED: {
|
2012-08-20 23:43:34 +02:00
|
|
|
for (r = 0; r < bsize; r++) {
|
|
|
|
for (c = 0; c < bsize; c++) {
|
2012-07-14 00:21:29 +02:00
|
|
|
int pred = yleft_col[r] + yabove_row[ c] - ytop_left;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
if (pred < 0)
|
|
|
|
pred = 0;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
if (pred > 255)
|
|
|
|
pred = 255;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
ypred_ptr[c] = pred;
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
ypred_ptr += y_stride;
|
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
break;
|
2012-07-14 00:21:29 +02:00
|
|
|
case D45_PRED: {
|
2012-08-20 23:43:34 +02:00
|
|
|
d45_predictor(ypred_ptr, y_stride, bsize, yabove_row, yleft_col);
|
2012-05-15 01:21:01 +02:00
|
|
|
}
|
|
|
|
break;
|
2012-07-14 00:21:29 +02:00
|
|
|
case D135_PRED: {
|
2012-08-20 23:43:34 +02:00
|
|
|
d135_predictor(ypred_ptr, y_stride, bsize, yabove_row, yleft_col);
|
2012-05-15 01:21:01 +02:00
|
|
|
}
|
|
|
|
break;
|
2012-07-14 00:21:29 +02:00
|
|
|
case D117_PRED: {
|
2012-08-20 23:43:34 +02:00
|
|
|
d117_predictor(ypred_ptr, y_stride, bsize, yabove_row, yleft_col);
|
2012-05-15 01:21:01 +02:00
|
|
|
}
|
|
|
|
break;
|
2012-07-14 00:21:29 +02:00
|
|
|
case D153_PRED: {
|
2012-08-20 23:43:34 +02:00
|
|
|
d153_predictor(ypred_ptr, y_stride, bsize, yabove_row, yleft_col);
|
2012-05-15 01:21:01 +02:00
|
|
|
}
|
|
|
|
break;
|
2012-07-14 00:21:29 +02:00
|
|
|
case D27_PRED: {
|
2012-08-20 23:43:34 +02:00
|
|
|
d27_predictor(ypred_ptr, y_stride, bsize, yabove_row, yleft_col);
|
2012-05-15 01:21:01 +02:00
|
|
|
}
|
|
|
|
break;
|
2012-07-14 00:21:29 +02:00
|
|
|
case D63_PRED: {
|
2012-08-20 23:43:34 +02:00
|
|
|
d63_predictor(ypred_ptr, y_stride, bsize, yabove_row, yleft_col);
|
2012-05-15 01:21:01 +02:00
|
|
|
}
|
|
|
|
break;
|
2012-02-29 02:12:08 +01:00
|
|
|
case I8X8_PRED:
|
2010-05-18 17:58:33 +02:00
|
|
|
case B_PRED:
|
|
|
|
case NEARESTMV:
|
|
|
|
case NEARMV:
|
|
|
|
case ZEROMV:
|
|
|
|
case NEWMV:
|
|
|
|
case SPLITMV:
|
|
|
|
case MB_MODE_COUNT:
|
2012-07-14 00:21:29 +02:00
|
|
|
break;
|
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
2012-11-07 15:50:25 +01:00
|
|
|
#if CONFIG_COMP_INTERINTRA_PRED
|
|
|
|
static void combine_interintra(MB_PREDICTION_MODE mode,
|
|
|
|
unsigned char *interpred,
|
|
|
|
int interstride,
|
|
|
|
unsigned char *intrapred,
|
|
|
|
int intrastride,
|
|
|
|
int size) {
|
|
|
|
// TODO(debargha): Explore different ways of combining predictors
|
|
|
|
// or designing the tables below
|
|
|
|
static const int scale_bits = 8;
|
2012-11-16 00:14:38 +01:00
|
|
|
static const int scale_max = 256; // 1 << scale_bits;
|
|
|
|
static const int scale_round = 127; // (1 << (scale_bits - 1));
|
2012-11-07 15:50:25 +01:00
|
|
|
// This table is a function A + B*exp(-kx), where x is hor. index
|
|
|
|
static const int weights1d[32] = {
|
|
|
|
128, 122, 116, 111, 107, 103, 99, 96,
|
|
|
|
93, 90, 88, 85, 83, 81, 80, 78,
|
|
|
|
77, 76, 75, 74, 73, 72, 71, 70,
|
|
|
|
70, 69, 69, 68, 68, 68, 67, 67,
|
|
|
|
};
|
|
|
|
// This table is a function A + B*exp(-k.sqrt(xy)), where x, y are
|
|
|
|
// hor. and vert. indices
|
|
|
|
static const int weights2d[1024] = {
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 122, 120, 118, 116, 115, 114, 113,
|
|
|
|
112, 111, 111, 110, 109, 109, 108, 107,
|
|
|
|
107, 106, 106, 105, 105, 104, 104, 104,
|
|
|
|
103, 103, 102, 102, 102, 101, 101, 101,
|
|
|
|
128, 120, 116, 114, 112, 111, 109, 108,
|
|
|
|
107, 106, 105, 104, 103, 102, 102, 101,
|
|
|
|
100, 100, 99, 99, 98, 97, 97, 96,
|
|
|
|
96, 96, 95, 95, 94, 94, 93, 93,
|
|
|
|
128, 118, 114, 111, 109, 107, 106, 104,
|
|
|
|
103, 102, 101, 100, 99, 98, 97, 97,
|
|
|
|
96, 95, 95, 94, 93, 93, 92, 92,
|
|
|
|
91, 91, 90, 90, 90, 89, 89, 88,
|
|
|
|
128, 116, 112, 109, 107, 105, 103, 102,
|
|
|
|
100, 99, 98, 97, 96, 95, 94, 93,
|
|
|
|
93, 92, 91, 91, 90, 90, 89, 89,
|
|
|
|
88, 88, 87, 87, 86, 86, 85, 85,
|
|
|
|
128, 115, 111, 107, 105, 103, 101, 99,
|
|
|
|
98, 97, 96, 94, 93, 93, 92, 91,
|
|
|
|
90, 89, 89, 88, 88, 87, 86, 86,
|
|
|
|
85, 85, 84, 84, 84, 83, 83, 82,
|
|
|
|
128, 114, 109, 106, 103, 101, 99, 97,
|
|
|
|
96, 95, 93, 92, 91, 90, 90, 89,
|
|
|
|
88, 87, 87, 86, 85, 85, 84, 84,
|
|
|
|
83, 83, 82, 82, 82, 81, 81, 80,
|
|
|
|
128, 113, 108, 104, 102, 99, 97, 96,
|
|
|
|
94, 93, 92, 91, 90, 89, 88, 87,
|
|
|
|
86, 85, 85, 84, 84, 83, 83, 82,
|
|
|
|
82, 81, 81, 80, 80, 79, 79, 79,
|
|
|
|
128, 112, 107, 103, 100, 98, 96, 94,
|
|
|
|
93, 91, 90, 89, 88, 87, 86, 85,
|
|
|
|
85, 84, 83, 83, 82, 82, 81, 80,
|
|
|
|
80, 80, 79, 79, 78, 78, 78, 77,
|
|
|
|
128, 111, 106, 102, 99, 97, 95, 93,
|
|
|
|
91, 90, 89, 88, 87, 86, 85, 84,
|
|
|
|
83, 83, 82, 81, 81, 80, 80, 79,
|
|
|
|
79, 78, 78, 77, 77, 77, 76, 76,
|
|
|
|
128, 111, 105, 101, 98, 96, 93, 92,
|
|
|
|
90, 89, 88, 86, 85, 84, 84, 83,
|
|
|
|
82, 81, 81, 80, 80, 79, 79, 78,
|
|
|
|
78, 77, 77, 76, 76, 76, 75, 75,
|
|
|
|
128, 110, 104, 100, 97, 94, 92, 91,
|
|
|
|
89, 88, 86, 85, 84, 83, 83, 82,
|
|
|
|
81, 80, 80, 79, 79, 78, 78, 77,
|
|
|
|
77, 76, 76, 75, 75, 75, 74, 74,
|
|
|
|
128, 109, 103, 99, 96, 93, 91, 90,
|
|
|
|
88, 87, 85, 84, 83, 82, 82, 81,
|
|
|
|
80, 79, 79, 78, 78, 77, 77, 76,
|
|
|
|
76, 75, 75, 75, 74, 74, 74, 73,
|
|
|
|
128, 109, 102, 98, 95, 93, 90, 89,
|
|
|
|
87, 86, 84, 83, 82, 81, 81, 80,
|
|
|
|
79, 78, 78, 77, 77, 76, 76, 75,
|
|
|
|
75, 75, 74, 74, 73, 73, 73, 73,
|
|
|
|
128, 108, 102, 97, 94, 92, 90, 88,
|
|
|
|
86, 85, 84, 83, 82, 81, 80, 79,
|
|
|
|
78, 78, 77, 77, 76, 76, 75, 75,
|
|
|
|
74, 74, 73, 73, 73, 73, 72, 72,
|
|
|
|
128, 107, 101, 97, 93, 91, 89, 87,
|
|
|
|
85, 84, 83, 82, 81, 80, 79, 78,
|
|
|
|
78, 77, 76, 76, 75, 75, 74, 74,
|
|
|
|
74, 73, 73, 73, 72, 72, 72, 71,
|
|
|
|
128, 107, 100, 96, 93, 90, 88, 86,
|
|
|
|
85, 83, 82, 81, 80, 79, 78, 78,
|
|
|
|
77, 76, 76, 75, 75, 74, 74, 73,
|
|
|
|
73, 73, 72, 72, 72, 71, 71, 71,
|
|
|
|
128, 106, 100, 95, 92, 89, 87, 85,
|
|
|
|
84, 83, 81, 80, 79, 78, 78, 77,
|
|
|
|
76, 76, 75, 75, 74, 74, 73, 73,
|
|
|
|
72, 72, 72, 72, 71, 71, 71, 70,
|
|
|
|
128, 106, 99, 95, 91, 89, 87, 85,
|
|
|
|
83, 82, 81, 80, 79, 78, 77, 76,
|
|
|
|
76, 75, 75, 74, 74, 73, 73, 72,
|
|
|
|
72, 72, 71, 71, 71, 71, 70, 70,
|
|
|
|
128, 105, 99, 94, 91, 88, 86, 84,
|
|
|
|
83, 81, 80, 79, 78, 77, 77, 76,
|
|
|
|
75, 75, 74, 74, 73, 73, 72, 72,
|
|
|
|
72, 71, 71, 71, 70, 70, 70, 70,
|
|
|
|
128, 105, 98, 93, 90, 88, 85, 84,
|
|
|
|
82, 81, 80, 79, 78, 77, 76, 75,
|
|
|
|
75, 74, 74, 73, 73, 72, 72, 71,
|
|
|
|
71, 71, 71, 70, 70, 70, 70, 69,
|
|
|
|
128, 104, 97, 93, 90, 87, 85, 83,
|
|
|
|
82, 80, 79, 78, 77, 76, 76, 75,
|
|
|
|
74, 74, 73, 73, 72, 72, 71, 71,
|
|
|
|
71, 70, 70, 70, 70, 69, 69, 69,
|
|
|
|
128, 104, 97, 92, 89, 86, 84, 83,
|
|
|
|
81, 80, 79, 78, 77, 76, 75, 74,
|
|
|
|
74, 73, 73, 72, 72, 71, 71, 71,
|
|
|
|
70, 70, 70, 70, 69, 69, 69, 69,
|
|
|
|
128, 104, 96, 92, 89, 86, 84, 82,
|
|
|
|
80, 79, 78, 77, 76, 75, 75, 74,
|
|
|
|
73, 73, 72, 72, 71, 71, 71, 70,
|
|
|
|
70, 70, 70, 69, 69, 69, 69, 68,
|
|
|
|
128, 103, 96, 91, 88, 85, 83, 82,
|
|
|
|
80, 79, 78, 77, 76, 75, 74, 74,
|
|
|
|
73, 72, 72, 72, 71, 71, 70, 70,
|
|
|
|
70, 70, 69, 69, 69, 69, 68, 68,
|
|
|
|
128, 103, 96, 91, 88, 85, 83, 81,
|
|
|
|
80, 78, 77, 76, 75, 75, 74, 73,
|
|
|
|
73, 72, 72, 71, 71, 70, 70, 70,
|
|
|
|
70, 69, 69, 69, 69, 68, 68, 68,
|
|
|
|
128, 102, 95, 90, 87, 84, 82, 81,
|
|
|
|
79, 78, 77, 76, 75, 74, 73, 73,
|
|
|
|
72, 72, 71, 71, 71, 70, 70, 70,
|
|
|
|
69, 69, 69, 69, 68, 68, 68, 68,
|
|
|
|
128, 102, 95, 90, 87, 84, 82, 80,
|
|
|
|
79, 77, 76, 75, 75, 74, 73, 73,
|
|
|
|
72, 72, 71, 71, 70, 70, 70, 69,
|
|
|
|
69, 69, 69, 68, 68, 68, 68, 68,
|
|
|
|
128, 102, 94, 90, 86, 84, 82, 80,
|
|
|
|
78, 77, 76, 75, 74, 73, 73, 72,
|
|
|
|
72, 71, 71, 70, 70, 70, 69, 69,
|
|
|
|
69, 69, 68, 68, 68, 68, 68, 67,
|
|
|
|
128, 101, 94, 89, 86, 83, 81, 79,
|
|
|
|
78, 77, 76, 75, 74, 73, 73, 72,
|
|
|
|
71, 71, 71, 70, 70, 69, 69, 69,
|
|
|
|
69, 68, 68, 68, 68, 68, 67, 67,
|
|
|
|
128, 101, 93, 89, 85, 83, 81, 79,
|
|
|
|
78, 76, 75, 74, 74, 73, 72, 72,
|
|
|
|
71, 71, 70, 70, 70, 69, 69, 69,
|
|
|
|
68, 68, 68, 68, 68, 67, 67, 67,
|
|
|
|
128, 101, 93, 88, 85, 82, 80, 79,
|
|
|
|
77, 76, 75, 74, 73, 73, 72, 71,
|
|
|
|
71, 70, 70, 70, 69, 69, 69, 68,
|
|
|
|
68, 68, 68, 68, 67, 67, 67, 67,
|
|
|
|
};
|
|
|
|
int size_scale = (size == 32 ? 1 :
|
|
|
|
size == 16 ? 2 :
|
|
|
|
size == 8 ? 4 : 8);
|
|
|
|
int i, j;
|
|
|
|
switch (mode) {
|
|
|
|
case V_PRED:
|
|
|
|
for (i = 0; i < size; ++i) {
|
|
|
|
for (j = 0; j < size; ++j) {
|
|
|
|
int k = i * interstride + j;
|
|
|
|
int scale = weights1d[i * size_scale];
|
|
|
|
interpred[k] =
|
|
|
|
((scale_max - scale) * interpred[k] +
|
|
|
|
scale * intrapred[i * intrastride + j] + scale_round)
|
|
|
|
>> scale_bits;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case H_PRED:
|
|
|
|
for (i = 0; i < size; ++i) {
|
|
|
|
for (j = 0; j < size; ++j) {
|
|
|
|
int k = i * interstride + j;
|
|
|
|
int scale = weights1d[j * size_scale];
|
|
|
|
interpred[k] =
|
|
|
|
((scale_max - scale) * interpred[k] +
|
|
|
|
scale * intrapred[i * intrastride + j] + scale_round)
|
|
|
|
>> scale_bits;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D63_PRED:
|
|
|
|
case D117_PRED:
|
|
|
|
for (i = 0; i < size; ++i) {
|
|
|
|
for (j = 0; j < size; ++j) {
|
|
|
|
int k = i * interstride + j;
|
|
|
|
int scale = (weights2d[i * size_scale * 32 + j * size_scale] +
|
|
|
|
weights1d[i * size_scale]) >> 1;
|
|
|
|
interpred[k] =
|
|
|
|
((scale_max - scale) * interpred[k] +
|
|
|
|
scale * intrapred[i * intrastride + j] + scale_round)
|
|
|
|
>> scale_bits;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D27_PRED:
|
|
|
|
case D153_PRED:
|
|
|
|
for (i = 0; i < size; ++i) {
|
|
|
|
for (j = 0; j < size; ++j) {
|
|
|
|
int k = i * interstride + j;
|
|
|
|
int scale = (weights2d[i * size_scale * 32 + j * size_scale] +
|
|
|
|
weights1d[j * size_scale]) >> 1;
|
|
|
|
interpred[k] =
|
|
|
|
((scale_max - scale) * interpred[k] +
|
|
|
|
scale * intrapred[i * intrastride + j] + scale_round)
|
|
|
|
>> scale_bits;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D135_PRED:
|
|
|
|
for (i = 0; i < size; ++i) {
|
|
|
|
for (j = 0; j < size; ++j) {
|
|
|
|
int k = i * interstride + j;
|
|
|
|
int scale = weights2d[i * size_scale * 32 + j * size_scale];
|
|
|
|
interpred[k] =
|
|
|
|
((scale_max - scale) * interpred[k] +
|
|
|
|
scale * intrapred[i * intrastride + j] + scale_round)
|
|
|
|
>> scale_bits;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D45_PRED:
|
|
|
|
case DC_PRED:
|
|
|
|
case TM_PRED:
|
|
|
|
default:
|
|
|
|
// simple average
|
|
|
|
for (i = 0; i < size; ++i) {
|
|
|
|
for (j = 0; j < size; ++j) {
|
|
|
|
int k = i * interstride + j;
|
|
|
|
interpred[k] = (interpred[k] + intrapred[i * intrastride + j]) >> 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void vp9_build_interintra_16x16_predictors_mb(MACROBLOCKD *xd,
|
|
|
|
unsigned char *ypred,
|
|
|
|
unsigned char *upred,
|
|
|
|
unsigned char *vpred,
|
|
|
|
int ystride, int uvstride) {
|
|
|
|
vp9_build_interintra_16x16_predictors_mby(xd, ypred, ystride);
|
|
|
|
vp9_build_interintra_16x16_predictors_mbuv(xd, upred, vpred, uvstride);
|
|
|
|
}
|
|
|
|
|
|
|
|
void vp9_build_interintra_16x16_predictors_mby(MACROBLOCKD *xd,
|
|
|
|
unsigned char *ypred,
|
|
|
|
int ystride) {
|
|
|
|
unsigned char intrapredictor[256];
|
|
|
|
vp9_build_intra_predictors_internal(
|
|
|
|
xd->dst.y_buffer, xd->dst.y_stride,
|
|
|
|
intrapredictor, 16,
|
|
|
|
xd->mode_info_context->mbmi.interintra_mode, 16,
|
|
|
|
xd->up_available, xd->left_available);
|
|
|
|
combine_interintra(xd->mode_info_context->mbmi.interintra_mode,
|
|
|
|
ypred, ystride, intrapredictor, 16, 16);
|
|
|
|
}
|
|
|
|
|
|
|
|
void vp9_build_interintra_16x16_predictors_mbuv(MACROBLOCKD *xd,
|
|
|
|
unsigned char *upred,
|
|
|
|
unsigned char *vpred,
|
|
|
|
int uvstride) {
|
|
|
|
unsigned char uintrapredictor[64];
|
|
|
|
unsigned char vintrapredictor[64];
|
|
|
|
vp9_build_intra_predictors_internal(
|
|
|
|
xd->dst.u_buffer, xd->dst.uv_stride,
|
|
|
|
uintrapredictor, 8,
|
|
|
|
xd->mode_info_context->mbmi.interintra_uv_mode, 8,
|
|
|
|
xd->up_available, xd->left_available);
|
|
|
|
vp9_build_intra_predictors_internal(
|
|
|
|
xd->dst.v_buffer, xd->dst.uv_stride,
|
|
|
|
vintrapredictor, 8,
|
|
|
|
xd->mode_info_context->mbmi.interintra_uv_mode, 8,
|
|
|
|
xd->up_available, xd->left_available);
|
|
|
|
combine_interintra(xd->mode_info_context->mbmi.interintra_uv_mode,
|
|
|
|
upred, uvstride, uintrapredictor, 8, 8);
|
|
|
|
combine_interintra(xd->mode_info_context->mbmi.interintra_uv_mode,
|
|
|
|
vpred, uvstride, vintrapredictor, 8, 8);
|
|
|
|
}
|
2012-11-30 20:46:20 +01:00
|
|
|
|
|
|
|
#if CONFIG_SUPERBLOCKS
|
|
|
|
void vp9_build_interintra_32x32_predictors_sby(MACROBLOCKD *xd,
|
|
|
|
unsigned char *ypred,
|
|
|
|
int ystride) {
|
|
|
|
unsigned char intrapredictor[1024];
|
|
|
|
vp9_build_intra_predictors_internal(
|
|
|
|
xd->dst.y_buffer, xd->dst.y_stride,
|
|
|
|
intrapredictor, 32,
|
|
|
|
xd->mode_info_context->mbmi.interintra_mode, 32,
|
|
|
|
xd->up_available, xd->left_available);
|
|
|
|
combine_interintra(xd->mode_info_context->mbmi.interintra_mode,
|
|
|
|
ypred, ystride, intrapredictor, 32, 32);
|
|
|
|
}
|
|
|
|
|
|
|
|
void vp9_build_interintra_32x32_predictors_sbuv(MACROBLOCKD *xd,
|
|
|
|
unsigned char *upred,
|
|
|
|
unsigned char *vpred,
|
|
|
|
int uvstride) {
|
|
|
|
unsigned char uintrapredictor[256];
|
|
|
|
unsigned char vintrapredictor[256];
|
|
|
|
vp9_build_intra_predictors_internal(
|
|
|
|
xd->dst.u_buffer, xd->dst.uv_stride,
|
|
|
|
uintrapredictor, 16,
|
|
|
|
xd->mode_info_context->mbmi.interintra_uv_mode, 16,
|
|
|
|
xd->up_available, xd->left_available);
|
|
|
|
vp9_build_intra_predictors_internal(
|
|
|
|
xd->dst.v_buffer, xd->dst.uv_stride,
|
|
|
|
vintrapredictor, 16,
|
|
|
|
xd->mode_info_context->mbmi.interintra_uv_mode, 16,
|
|
|
|
xd->up_available, xd->left_available);
|
|
|
|
combine_interintra(xd->mode_info_context->mbmi.interintra_uv_mode,
|
|
|
|
upred, uvstride, uintrapredictor, 16, 16);
|
|
|
|
combine_interintra(xd->mode_info_context->mbmi.interintra_uv_mode,
|
|
|
|
vpred, uvstride, vintrapredictor, 16, 16);
|
|
|
|
}
|
|
|
|
|
|
|
|
void vp9_build_interintra_32x32_predictors_sb(MACROBLOCKD *xd,
|
|
|
|
unsigned char *ypred,
|
|
|
|
unsigned char *upred,
|
|
|
|
unsigned char *vpred,
|
|
|
|
int ystride,
|
|
|
|
int uvstride) {
|
|
|
|
vp9_build_interintra_32x32_predictors_sby(xd, ypred, ystride);
|
|
|
|
vp9_build_interintra_32x32_predictors_sbuv(xd, upred, vpred, uvstride);
|
|
|
|
}
|
|
|
|
#endif
|
2012-11-07 15:50:25 +01:00
|
|
|
#endif
|
|
|
|
|
2012-10-31 00:25:53 +01:00
|
|
|
void vp9_build_intra_predictors_mby(MACROBLOCKD *xd) {
|
|
|
|
vp9_build_intra_predictors_internal(xd->dst.y_buffer, xd->dst.y_stride,
|
2012-08-20 23:43:34 +02:00
|
|
|
xd->predictor, 16,
|
2012-08-23 01:05:21 +02:00
|
|
|
xd->mode_info_context->mbmi.mode, 16,
|
|
|
|
xd->up_available, xd->left_available);
|
2012-02-29 02:12:08 +01:00
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-10-31 00:25:53 +01:00
|
|
|
void vp9_build_intra_predictors_mby_s(MACROBLOCKD *xd) {
|
|
|
|
vp9_build_intra_predictors_internal(xd->dst.y_buffer, xd->dst.y_stride,
|
2012-08-20 23:43:34 +02:00
|
|
|
xd->dst.y_buffer, xd->dst.y_stride,
|
2012-08-23 01:05:21 +02:00
|
|
|
xd->mode_info_context->mbmi.mode, 16,
|
|
|
|
xd->up_available, xd->left_available);
|
2012-08-20 23:43:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#if CONFIG_SUPERBLOCKS
|
2012-10-31 00:25:53 +01:00
|
|
|
void vp9_build_intra_predictors_sby_s(MACROBLOCKD *xd) {
|
|
|
|
vp9_build_intra_predictors_internal(xd->dst.y_buffer, xd->dst.y_stride,
|
2012-08-23 01:05:21 +02:00
|
|
|
xd->dst.y_buffer, xd->dst.y_stride,
|
|
|
|
xd->mode_info_context->mbmi.mode, 32,
|
|
|
|
xd->up_available, xd->left_available);
|
2012-02-29 02:12:08 +01:00
|
|
|
}
|
2012-08-20 23:43:34 +02:00
|
|
|
#endif
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-02-29 02:12:08 +01:00
|
|
|
#if CONFIG_COMP_INTRA_PRED
|
2012-10-31 22:40:53 +01:00
|
|
|
void vp9_build_comp_intra_predictors_mby(MACROBLOCKD *xd) {
|
2012-07-14 00:21:29 +02:00
|
|
|
unsigned char predictor[2][256];
|
|
|
|
int i;
|
|
|
|
|
2012-10-31 00:25:53 +01:00
|
|
|
vp9_build_intra_predictors_internal(xd->dst.y_buffer, xd->dst.y_stride,
|
2012-08-20 23:43:34 +02:00
|
|
|
predictor[0], 16,
|
2012-08-21 02:38:44 +02:00
|
|
|
xd->mode_info_context->mbmi.mode,
|
2012-08-23 01:05:21 +02:00
|
|
|
16, xd->up_available,
|
|
|
|
xd->left_available);
|
2012-10-31 00:25:53 +01:00
|
|
|
vp9_build_intra_predictors_internal(xd->dst.y_buffer, xd->dst.y_stride,
|
2012-08-20 23:43:34 +02:00
|
|
|
predictor[1], 16,
|
2012-08-21 02:38:44 +02:00
|
|
|
xd->mode_info_context->mbmi.second_mode,
|
2012-08-23 01:05:21 +02:00
|
|
|
16, xd->up_available,
|
|
|
|
xd->left_available);
|
2012-07-14 00:21:29 +02:00
|
|
|
|
|
|
|
for (i = 0; i < 256; i++) {
|
2012-08-14 12:32:29 +02:00
|
|
|
xd->predictor[i] = (predictor[0][i] + predictor[1][i] + 1) >> 1;
|
2012-07-14 00:21:29 +02:00
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
2012-02-29 02:12:08 +01:00
|
|
|
#endif
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-10-31 00:25:53 +01:00
|
|
|
void vp9_build_intra_predictors_mbuv_internal(MACROBLOCKD *xd,
|
2012-02-29 02:12:08 +01:00
|
|
|
unsigned char *upred_ptr,
|
|
|
|
unsigned char *vpred_ptr,
|
|
|
|
int uv_stride,
|
2012-08-20 23:43:34 +02:00
|
|
|
int mode, int bsize) {
|
2012-10-31 00:25:53 +01:00
|
|
|
vp9_build_intra_predictors_internal(xd->dst.u_buffer, xd->dst.uv_stride,
|
2012-08-23 01:05:21 +02:00
|
|
|
upred_ptr, uv_stride, mode, bsize,
|
|
|
|
xd->up_available, xd->left_available);
|
2012-10-31 00:25:53 +01:00
|
|
|
vp9_build_intra_predictors_internal(xd->dst.v_buffer, xd->dst.uv_stride,
|
2012-08-23 01:05:21 +02:00
|
|
|
vpred_ptr, uv_stride, mode, bsize,
|
|
|
|
xd->up_available, xd->left_available);
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
2012-02-29 02:12:08 +01:00
|
|
|
|
2012-10-31 00:25:53 +01:00
|
|
|
void vp9_build_intra_predictors_mbuv(MACROBLOCKD *xd) {
|
|
|
|
vp9_build_intra_predictors_mbuv_internal(xd, &xd->predictor[256],
|
2012-08-20 23:43:34 +02:00
|
|
|
&xd->predictor[320], 8,
|
|
|
|
xd->mode_info_context->mbmi.uv_mode,
|
|
|
|
8);
|
2012-02-29 02:12:08 +01:00
|
|
|
}
|
|
|
|
|
2012-10-31 00:25:53 +01:00
|
|
|
void vp9_build_intra_predictors_mbuv_s(MACROBLOCKD *xd) {
|
|
|
|
vp9_build_intra_predictors_mbuv_internal(xd, xd->dst.u_buffer,
|
2012-08-20 23:43:34 +02:00
|
|
|
xd->dst.v_buffer,
|
|
|
|
xd->dst.uv_stride,
|
|
|
|
xd->mode_info_context->mbmi.uv_mode,
|
|
|
|
8);
|
2012-02-29 02:12:08 +01:00
|
|
|
}
|
|
|
|
|
2012-08-20 23:43:34 +02:00
|
|
|
#if CONFIG_SUPERBLOCKS
|
2012-10-31 00:25:53 +01:00
|
|
|
void vp9_build_intra_predictors_sbuv_s(MACROBLOCKD *xd) {
|
|
|
|
vp9_build_intra_predictors_mbuv_internal(xd, xd->dst.u_buffer,
|
2012-08-20 23:43:34 +02:00
|
|
|
xd->dst.v_buffer, xd->dst.uv_stride,
|
|
|
|
xd->mode_info_context->mbmi.uv_mode,
|
|
|
|
16);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-02-29 02:12:08 +01:00
|
|
|
#if CONFIG_COMP_INTRA_PRED
|
2012-10-31 22:40:53 +01:00
|
|
|
void vp9_build_comp_intra_predictors_mbuv(MACROBLOCKD *xd) {
|
2012-07-14 00:21:29 +02:00
|
|
|
unsigned char predictor[2][2][64];
|
|
|
|
int i;
|
|
|
|
|
2012-10-31 00:25:53 +01:00
|
|
|
vp9_build_intra_predictors_mbuv_internal(
|
2012-11-07 15:50:25 +01:00
|
|
|
xd, predictor[0][0], predictor[1][0], 8,
|
|
|
|
xd->mode_info_context->mbmi.uv_mode, 8);
|
2012-10-31 00:25:53 +01:00
|
|
|
vp9_build_intra_predictors_mbuv_internal(
|
2012-11-07 15:50:25 +01:00
|
|
|
xd, predictor[0][1], predictor[1][1], 8,
|
|
|
|
xd->mode_info_context->mbmi.second_uv_mode, 8);
|
2012-07-14 00:21:29 +02:00
|
|
|
for (i = 0; i < 64; i++) {
|
2012-08-14 12:32:29 +02:00
|
|
|
xd->predictor[256 + i] = (predictor[0][0][i] + predictor[0][1][i] + 1) >> 1;
|
2012-08-20 23:43:34 +02:00
|
|
|
xd->predictor[256 + 64 + i] = (predictor[1][0][i] +
|
|
|
|
predictor[1][1][i] + 1) >> 1;
|
2012-07-14 00:21:29 +02:00
|
|
|
}
|
2012-02-29 02:12:08 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-10-31 00:25:53 +01:00
|
|
|
void vp9_intra8x8_predict(BLOCKD *xd,
|
2011-08-05 01:30:27 +02:00
|
|
|
int mode,
|
2012-07-14 00:21:29 +02:00
|
|
|
unsigned char *predictor) {
|
2012-10-31 00:25:53 +01:00
|
|
|
vp9_build_intra_predictors_internal(*(xd->base_dst) + xd->dst,
|
2012-08-23 01:05:21 +02:00
|
|
|
xd->dst_stride, predictor, 16,
|
|
|
|
mode, 8, 1, 1);
|
2011-08-05 01:30:27 +02:00
|
|
|
}
|
|
|
|
|
2012-02-29 02:12:08 +01:00
|
|
|
#if CONFIG_COMP_INTRA_PRED
|
2012-10-31 22:40:53 +01:00
|
|
|
void vp9_comp_intra8x8_predict(BLOCKD *xd,
|
2012-02-29 02:12:08 +01:00
|
|
|
int mode, int second_mode,
|
2012-07-14 00:21:29 +02:00
|
|
|
unsigned char *out_predictor) {
|
|
|
|
unsigned char predictor[2][8 * 16];
|
|
|
|
int i, j;
|
|
|
|
|
2012-10-31 00:25:53 +01:00
|
|
|
vp9_intra8x8_predict(xd, mode, predictor[0]);
|
|
|
|
vp9_intra8x8_predict(xd, second_mode, predictor[1]);
|
2012-07-14 00:21:29 +02:00
|
|
|
|
|
|
|
for (i = 0; i < 8 * 16; i += 16) {
|
|
|
|
for (j = i; j < i + 8; j++) {
|
|
|
|
out_predictor[j] = (predictor[0][j] + predictor[1][j] + 1) >> 1;
|
2012-02-29 02:12:08 +01:00
|
|
|
}
|
2012-07-14 00:21:29 +02:00
|
|
|
}
|
2012-02-29 02:12:08 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-10-31 00:25:53 +01:00
|
|
|
void vp9_intra_uv4x4_predict(BLOCKD *xd,
|
2011-08-05 01:30:27 +02:00
|
|
|
int mode,
|
2012-07-14 00:21:29 +02:00
|
|
|
unsigned char *predictor) {
|
2012-10-31 00:25:53 +01:00
|
|
|
vp9_build_intra_predictors_internal(*(xd->base_dst) + xd->dst,
|
2012-08-23 01:05:21 +02:00
|
|
|
xd->dst_stride, predictor, 8,
|
|
|
|
mode, 4, 1, 1);
|
2011-08-05 01:30:27 +02:00
|
|
|
}
|
|
|
|
|
2012-02-29 02:12:08 +01:00
|
|
|
#if CONFIG_COMP_INTRA_PRED
|
2012-10-31 22:40:53 +01:00
|
|
|
void vp9_comp_intra_uv4x4_predict(BLOCKD *xd,
|
2012-02-29 02:12:08 +01:00
|
|
|
int mode, int mode2,
|
2012-07-14 00:21:29 +02:00
|
|
|
unsigned char *out_predictor) {
|
|
|
|
unsigned char predictor[2][8 * 4];
|
|
|
|
int i, j;
|
|
|
|
|
2012-10-31 00:25:53 +01:00
|
|
|
vp9_intra_uv4x4_predict(xd, mode, predictor[0]);
|
|
|
|
vp9_intra_uv4x4_predict(xd, mode2, predictor[1]);
|
2012-07-14 00:21:29 +02:00
|
|
|
|
|
|
|
for (i = 0; i < 4 * 8; i += 8) {
|
|
|
|
for (j = i; j < i + 4; j++) {
|
|
|
|
out_predictor[j] = (predictor[0][j] + predictor[1][j] + 1) >> 1;
|
2012-02-29 02:12:08 +01:00
|
|
|
}
|
2012-07-14 00:21:29 +02:00
|
|
|
}
|
2012-02-29 02:12:08 +01:00
|
|
|
}
|
|
|
|
#endif
|
2011-08-05 01:30:27 +02:00
|
|
|
|
|
|
|
/* TODO: try different ways of use Y-UV mode correlation
|
2012-11-07 15:50:25 +01:00
|
|
|
Current code assumes that a uv 4x4 block use same mode
|
|
|
|
as corresponding Y 8x8 area
|
|
|
|
*/
|