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-12-23 16:20:10 +01:00
|
|
|
#include "./vpx_config.h"
|
2013-08-14 19:35:56 +02:00
|
|
|
|
|
|
|
#include "vpx_mem/vpx_mem.h"
|
|
|
|
#include "vpx_ports/vpx_once.h"
|
|
|
|
|
2013-09-30 03:02:42 +02:00
|
|
|
#include "./vp9_rtcd.h"
|
2013-08-14 19:35:56 +02:00
|
|
|
|
2012-11-28 19:41:40 +01:00
|
|
|
#include "vp9/common/vp9_reconintra.h"
|
2013-05-16 02:21:15 +02:00
|
|
|
#include "vp9/common/vp9_onyxc_int.h"
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2013-06-26 03:15:42 +02:00
|
|
|
const TX_TYPE mode2txfm_map[MB_MODE_COUNT] = {
|
|
|
|
DCT_DCT, // DC
|
|
|
|
ADST_DCT, // V
|
|
|
|
DCT_ADST, // H
|
|
|
|
DCT_DCT, // D45
|
|
|
|
ADST_ADST, // D135
|
|
|
|
ADST_DCT, // D117
|
|
|
|
DCT_ADST, // D153
|
2013-08-24 02:33:48 +02:00
|
|
|
DCT_ADST, // D207
|
2013-06-26 03:15:42 +02:00
|
|
|
ADST_DCT, // D63
|
|
|
|
ADST_ADST, // TM
|
|
|
|
DCT_DCT, // NEARESTMV
|
|
|
|
DCT_DCT, // NEARMV
|
|
|
|
DCT_DCT, // ZEROMV
|
|
|
|
DCT_DCT // NEWMV
|
|
|
|
};
|
|
|
|
|
2013-07-09 23:52:20 +02:00
|
|
|
#define intra_pred_sized(type, size) \
|
2013-08-14 19:35:56 +02:00
|
|
|
void vp9_##type##_predictor_##size##x##size##_c(uint8_t *dst, \
|
|
|
|
ptrdiff_t stride, \
|
|
|
|
const uint8_t *above, \
|
|
|
|
const uint8_t *left) { \
|
|
|
|
type##_predictor(dst, stride, size, above, left); \
|
|
|
|
}
|
|
|
|
|
2013-07-09 23:52:20 +02:00
|
|
|
#define intra_pred_allsizes(type) \
|
|
|
|
intra_pred_sized(type, 4) \
|
|
|
|
intra_pred_sized(type, 8) \
|
|
|
|
intra_pred_sized(type, 16) \
|
|
|
|
intra_pred_sized(type, 32)
|
|
|
|
|
2013-08-15 20:09:49 +02:00
|
|
|
static INLINE void d207_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
|
|
|
|
const uint8_t *above, const uint8_t *left) {
|
2013-03-07 21:24:35 +01:00
|
|
|
int r, c;
|
2013-08-14 19:35:56 +02:00
|
|
|
|
2013-04-23 20:06:11 +02:00
|
|
|
// first column
|
2013-08-08 23:52:39 +02:00
|
|
|
for (r = 0; r < bs - 1; ++r)
|
2013-08-14 19:35:56 +02:00
|
|
|
dst[r * stride] = ROUND_POWER_OF_TWO(left[r] + left[r + 1], 1);
|
|
|
|
dst[(bs - 1) * stride] = left[bs - 1];
|
|
|
|
dst++;
|
2013-08-08 23:52:39 +02:00
|
|
|
|
2013-04-23 20:06:11 +02:00
|
|
|
// second column
|
2013-08-08 23:52:39 +02:00
|
|
|
for (r = 0; r < bs - 2; ++r)
|
2013-08-14 19:35:56 +02:00
|
|
|
dst[r * stride] = ROUND_POWER_OF_TWO(left[r] + left[r + 1] * 2 +
|
|
|
|
left[r + 2], 2);
|
|
|
|
dst[(bs - 2) * stride] = ROUND_POWER_OF_TWO(left[bs - 2] +
|
|
|
|
left[bs - 1] * 3, 2);
|
|
|
|
dst[(bs - 1) * stride] = left[bs - 1];
|
|
|
|
dst++;
|
2013-03-07 21:24:35 +01:00
|
|
|
|
2013-04-23 20:06:11 +02:00
|
|
|
// rest of last row
|
2013-08-08 23:52:39 +02:00
|
|
|
for (c = 0; c < bs - 2; ++c)
|
2013-08-14 19:35:56 +02:00
|
|
|
dst[(bs - 1) * stride + c] = left[bs - 1];
|
2013-03-07 21:24:35 +01:00
|
|
|
|
2013-08-08 23:52:39 +02:00
|
|
|
for (r = bs - 2; r >= 0; --r)
|
|
|
|
for (c = 0; c < bs - 2; ++c)
|
2013-08-14 19:35:56 +02:00
|
|
|
dst[r * stride + c] = dst[(r + 1) * stride + c - 2];
|
2012-05-15 01:21:01 +02:00
|
|
|
}
|
2013-08-15 20:09:49 +02:00
|
|
|
intra_pred_allsizes(d207)
|
2012-05-15 01:21:01 +02:00
|
|
|
|
2013-08-14 19:35:56 +02:00
|
|
|
static INLINE void d63_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
|
|
|
|
const uint8_t *above, const uint8_t *left) {
|
2013-03-07 21:24:35 +01:00
|
|
|
int r, c;
|
2013-07-09 02:25:51 +02:00
|
|
|
for (r = 0; r < bs; ++r) {
|
2013-08-08 23:52:39 +02:00
|
|
|
for (c = 0; c < bs; ++c)
|
2013-08-14 19:35:56 +02:00
|
|
|
dst[c] = r & 1 ? ROUND_POWER_OF_TWO(above[r/2 + c] +
|
|
|
|
above[r/2 + c + 1] * 2 +
|
|
|
|
above[r/2 + c + 2], 2)
|
|
|
|
: ROUND_POWER_OF_TWO(above[r/2 + c] +
|
|
|
|
above[r/2 + c + 1], 1);
|
|
|
|
dst += stride;
|
2012-07-14 00:21:29 +02:00
|
|
|
}
|
2012-05-15 01:21:01 +02:00
|
|
|
}
|
2013-07-09 23:52:20 +02:00
|
|
|
intra_pred_allsizes(d63)
|
2012-05-15 01:21:01 +02:00
|
|
|
|
2013-08-14 19:35:56 +02:00
|
|
|
static INLINE void d45_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
|
|
|
|
const uint8_t *above, const uint8_t *left) {
|
2012-07-14 00:21:29 +02:00
|
|
|
int r, c;
|
2013-07-09 02:25:51 +02:00
|
|
|
for (r = 0; r < bs; ++r) {
|
2013-08-14 19:35:56 +02:00
|
|
|
for (c = 0; c < bs; ++c)
|
|
|
|
dst[c] = r + c + 2 < bs * 2 ? ROUND_POWER_OF_TWO(above[r + c] +
|
|
|
|
above[r + c + 1] * 2 +
|
|
|
|
above[r + c + 2], 2)
|
|
|
|
: above[bs * 2 - 1];
|
|
|
|
dst += stride;
|
2012-07-14 00:21:29 +02:00
|
|
|
}
|
2012-05-15 01:21:01 +02:00
|
|
|
}
|
2013-07-09 23:52:20 +02:00
|
|
|
intra_pred_allsizes(d45)
|
2012-05-15 01:21:01 +02:00
|
|
|
|
2013-08-14 19:35:56 +02:00
|
|
|
static INLINE void d117_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
|
|
|
|
const uint8_t *above, const uint8_t *left) {
|
2012-07-14 00:21:29 +02:00
|
|
|
int r, c;
|
2013-08-14 19:35:56 +02:00
|
|
|
|
2013-04-23 20:06:11 +02:00
|
|
|
// first row
|
2013-07-09 02:25:51 +02:00
|
|
|
for (c = 0; c < bs; c++)
|
2013-08-14 19:35:56 +02:00
|
|
|
dst[c] = ROUND_POWER_OF_TWO(above[c - 1] + above[c], 1);
|
|
|
|
dst += stride;
|
2013-04-23 20:06:11 +02:00
|
|
|
|
|
|
|
// second row
|
2013-08-14 19:35:56 +02:00
|
|
|
dst[0] = ROUND_POWER_OF_TWO(left[0] + above[-1] * 2 + above[0], 2);
|
2013-07-09 02:25:51 +02:00
|
|
|
for (c = 1; c < bs; c++)
|
2013-08-14 19:35:56 +02:00
|
|
|
dst[c] = ROUND_POWER_OF_TWO(above[c - 2] + above[c - 1] * 2 + above[c], 2);
|
|
|
|
dst += stride;
|
2013-04-23 20:06:11 +02:00
|
|
|
|
|
|
|
// the rest of first col
|
2013-08-14 19:35:56 +02:00
|
|
|
dst[0] = ROUND_POWER_OF_TWO(above[-1] + left[0] * 2 + left[1], 2);
|
2013-07-09 02:25:51 +02:00
|
|
|
for (r = 3; r < bs; ++r)
|
2013-08-14 19:35:56 +02:00
|
|
|
dst[(r - 2) * stride] = ROUND_POWER_OF_TWO(left[r - 3] + left[r - 2] * 2 +
|
|
|
|
left[r - 1], 2);
|
|
|
|
|
2013-04-23 20:06:11 +02:00
|
|
|
// the rest of the block
|
2013-07-09 02:25:51 +02:00
|
|
|
for (r = 2; r < bs; ++r) {
|
|
|
|
for (c = 1; c < bs; c++)
|
2013-08-14 19:35:56 +02:00
|
|
|
dst[c] = dst[-2 * stride + c - 1];
|
|
|
|
dst += stride;
|
2012-07-14 00:21:29 +02:00
|
|
|
}
|
2012-05-15 01:21:01 +02:00
|
|
|
}
|
2013-07-09 23:52:20 +02:00
|
|
|
intra_pred_allsizes(d117)
|
2012-05-15 01:21:01 +02:00
|
|
|
|
2013-08-14 19:35:56 +02:00
|
|
|
static INLINE void d135_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
|
|
|
|
const uint8_t *above, const uint8_t *left) {
|
2012-07-14 00:21:29 +02:00
|
|
|
int r, c;
|
2013-08-14 19:35:56 +02:00
|
|
|
dst[0] = ROUND_POWER_OF_TWO(left[0] + above[-1] * 2 + above[0], 2);
|
2013-07-09 02:25:51 +02:00
|
|
|
for (c = 1; c < bs; c++)
|
2013-08-14 19:35:56 +02:00
|
|
|
dst[c] = ROUND_POWER_OF_TWO(above[c - 2] + above[c - 1] * 2 + above[c], 2);
|
2013-04-23 20:06:11 +02:00
|
|
|
|
2013-08-14 19:35:56 +02:00
|
|
|
dst[stride] = ROUND_POWER_OF_TWO(above[-1] + left[0] * 2 + left[1], 2);
|
2013-07-09 02:25:51 +02:00
|
|
|
for (r = 2; r < bs; ++r)
|
2013-08-14 19:35:56 +02:00
|
|
|
dst[r * stride] = ROUND_POWER_OF_TWO(left[r - 2] + left[r - 1] * 2 +
|
|
|
|
left[r], 2);
|
2012-07-14 00:21:29 +02:00
|
|
|
|
2013-08-14 19:35:56 +02:00
|
|
|
dst += stride;
|
2013-07-09 02:25:51 +02:00
|
|
|
for (r = 1; r < bs; ++r) {
|
|
|
|
for (c = 1; c < bs; c++)
|
2013-08-14 19:35:56 +02:00
|
|
|
dst[c] = dst[-stride + c - 1];
|
|
|
|
dst += stride;
|
2012-07-14 00:21:29 +02:00
|
|
|
}
|
2012-05-15 01:21:01 +02:00
|
|
|
}
|
2013-07-09 23:52:20 +02:00
|
|
|
intra_pred_allsizes(d135)
|
2012-05-15 01:21:01 +02:00
|
|
|
|
2013-08-14 19:35:56 +02:00
|
|
|
static INLINE void d153_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
|
|
|
|
const uint8_t *above, const uint8_t *left) {
|
2012-07-14 00:21:29 +02:00
|
|
|
int r, c;
|
2013-08-14 19:35:56 +02:00
|
|
|
dst[0] = ROUND_POWER_OF_TWO(above[-1] + left[0], 1);
|
2013-07-09 02:25:51 +02:00
|
|
|
for (r = 1; r < bs; r++)
|
2013-08-14 19:35:56 +02:00
|
|
|
dst[r * stride] = ROUND_POWER_OF_TWO(left[r - 1] + left[r], 1);
|
|
|
|
dst++;
|
|
|
|
|
|
|
|
dst[0] = ROUND_POWER_OF_TWO(left[0] + above[-1] * 2 + above[0], 2);
|
|
|
|
dst[stride] = ROUND_POWER_OF_TWO(above[-1] + left[0] * 2 + left[1], 2);
|
2013-07-09 02:25:51 +02:00
|
|
|
for (r = 2; r < bs; r++)
|
2013-08-14 19:35:56 +02:00
|
|
|
dst[r * stride] = ROUND_POWER_OF_TWO(left[r - 2] + left[r - 1] * 2 +
|
|
|
|
left[r], 2);
|
|
|
|
dst++;
|
2012-07-14 00:21:29 +02:00
|
|
|
|
2013-07-09 02:25:51 +02:00
|
|
|
for (c = 0; c < bs - 2; c++)
|
2013-08-14 19:35:56 +02:00
|
|
|
dst[c] = ROUND_POWER_OF_TWO(above[c - 1] + above[c] * 2 + above[c + 1], 2);
|
|
|
|
dst += stride;
|
|
|
|
|
2013-07-09 02:25:51 +02:00
|
|
|
for (r = 1; r < bs; ++r) {
|
|
|
|
for (c = 0; c < bs - 2; c++)
|
2013-08-14 19:35:56 +02:00
|
|
|
dst[c] = dst[-stride + c - 2];
|
|
|
|
dst += stride;
|
2012-07-14 00:21:29 +02:00
|
|
|
}
|
2012-05-15 01:21:01 +02:00
|
|
|
}
|
2013-07-09 23:52:20 +02:00
|
|
|
intra_pred_allsizes(d153)
|
2012-05-15 01:21:01 +02:00
|
|
|
|
2013-08-14 19:35:56 +02:00
|
|
|
static INLINE void v_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
|
|
|
|
const uint8_t *above, const uint8_t *left) {
|
2013-07-09 02:25:51 +02:00
|
|
|
int r;
|
|
|
|
|
|
|
|
for (r = 0; r < bs; r++) {
|
2013-08-14 19:35:56 +02:00
|
|
|
vpx_memcpy(dst, above, bs);
|
|
|
|
dst += stride;
|
2013-07-09 02:25:51 +02:00
|
|
|
}
|
|
|
|
}
|
2013-07-09 23:52:20 +02:00
|
|
|
intra_pred_allsizes(v)
|
2013-07-09 02:25:51 +02:00
|
|
|
|
2013-08-14 19:35:56 +02:00
|
|
|
static INLINE void h_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
|
|
|
|
const uint8_t *above, const uint8_t *left) {
|
2013-07-09 02:25:51 +02:00
|
|
|
int r;
|
|
|
|
|
|
|
|
for (r = 0; r < bs; r++) {
|
2013-08-14 19:35:56 +02:00
|
|
|
vpx_memset(dst, left[r], bs);
|
|
|
|
dst += stride;
|
2013-07-09 02:25:51 +02:00
|
|
|
}
|
|
|
|
}
|
2013-07-09 23:52:20 +02:00
|
|
|
intra_pred_allsizes(h)
|
2013-07-09 02:25:51 +02:00
|
|
|
|
2013-08-14 19:35:56 +02:00
|
|
|
static INLINE void tm_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
|
|
|
|
const uint8_t *above, const uint8_t *left) {
|
2013-07-09 02:25:51 +02:00
|
|
|
int r, c;
|
2013-08-14 19:35:56 +02:00
|
|
|
int ytop_left = above[-1];
|
2013-07-09 02:25:51 +02:00
|
|
|
|
|
|
|
for (r = 0; r < bs; r++) {
|
|
|
|
for (c = 0; c < bs; c++)
|
2013-08-14 19:35:56 +02:00
|
|
|
dst[c] = clip_pixel(left[r] + above[c] - ytop_left);
|
|
|
|
dst += stride;
|
2013-07-09 02:25:51 +02:00
|
|
|
}
|
|
|
|
}
|
2013-07-09 23:52:20 +02:00
|
|
|
intra_pred_allsizes(tm)
|
2013-07-09 02:25:51 +02:00
|
|
|
|
2013-08-14 19:35:56 +02:00
|
|
|
static INLINE void dc_128_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
|
|
|
|
const uint8_t *above, const uint8_t *left) {
|
2013-07-09 02:25:51 +02:00
|
|
|
int r;
|
|
|
|
|
|
|
|
for (r = 0; r < bs; r++) {
|
2013-08-14 19:35:56 +02:00
|
|
|
vpx_memset(dst, 128, bs);
|
|
|
|
dst += stride;
|
2013-07-09 02:25:51 +02:00
|
|
|
}
|
|
|
|
}
|
2013-07-09 23:52:20 +02:00
|
|
|
intra_pred_allsizes(dc_128)
|
2013-07-09 02:25:51 +02:00
|
|
|
|
2013-08-14 19:35:56 +02:00
|
|
|
static INLINE void dc_left_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
|
|
|
|
const uint8_t *above,
|
|
|
|
const uint8_t *left) {
|
|
|
|
int i, r, expected_dc, sum = 0;
|
2013-07-09 02:25:51 +02:00
|
|
|
|
|
|
|
for (i = 0; i < bs; i++)
|
2013-08-14 19:35:56 +02:00
|
|
|
sum += left[i];
|
|
|
|
expected_dc = (sum + (bs >> 1)) / bs;
|
2013-07-09 02:25:51 +02:00
|
|
|
|
|
|
|
for (r = 0; r < bs; r++) {
|
2013-08-14 19:35:56 +02:00
|
|
|
vpx_memset(dst, expected_dc, bs);
|
|
|
|
dst += stride;
|
2013-07-09 02:25:51 +02:00
|
|
|
}
|
|
|
|
}
|
2013-07-09 23:52:20 +02:00
|
|
|
intra_pred_allsizes(dc_left)
|
2013-07-09 02:25:51 +02:00
|
|
|
|
2013-08-14 19:35:56 +02:00
|
|
|
static INLINE void dc_top_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
|
|
|
|
const uint8_t *above, const uint8_t *left) {
|
|
|
|
int i, r, expected_dc, sum = 0;
|
2013-07-09 02:25:51 +02:00
|
|
|
|
|
|
|
for (i = 0; i < bs; i++)
|
2013-08-14 19:35:56 +02:00
|
|
|
sum += above[i];
|
|
|
|
expected_dc = (sum + (bs >> 1)) / bs;
|
2013-07-09 02:25:51 +02:00
|
|
|
|
|
|
|
for (r = 0; r < bs; r++) {
|
2013-08-14 19:35:56 +02:00
|
|
|
vpx_memset(dst, expected_dc, bs);
|
|
|
|
dst += stride;
|
2013-07-09 02:25:51 +02:00
|
|
|
}
|
|
|
|
}
|
2013-07-09 23:52:20 +02:00
|
|
|
intra_pred_allsizes(dc_top)
|
2013-07-09 02:25:51 +02:00
|
|
|
|
2013-08-14 19:35:56 +02:00
|
|
|
static INLINE void dc_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
|
|
|
|
const uint8_t *above, const uint8_t *left) {
|
|
|
|
int i, r, expected_dc, sum = 0;
|
2013-07-09 02:25:51 +02:00
|
|
|
const int count = 2 * bs;
|
|
|
|
|
2013-08-14 19:35:56 +02:00
|
|
|
for (i = 0; i < bs; i++) {
|
|
|
|
sum += above[i];
|
|
|
|
sum += left[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
expected_dc = (sum + (count >> 1)) / count;
|
2013-07-09 02:25:51 +02:00
|
|
|
|
|
|
|
for (r = 0; r < bs; r++) {
|
2013-08-14 19:35:56 +02:00
|
|
|
vpx_memset(dst, expected_dc, bs);
|
|
|
|
dst += stride;
|
2013-07-09 02:25:51 +02:00
|
|
|
}
|
|
|
|
}
|
2013-07-09 23:52:20 +02:00
|
|
|
intra_pred_allsizes(dc)
|
|
|
|
#undef intra_pred_allsizes
|
|
|
|
|
2013-08-14 19:35:56 +02:00
|
|
|
typedef void (*intra_pred_fn)(uint8_t *dst, ptrdiff_t stride,
|
|
|
|
const uint8_t *above, const uint8_t *left);
|
2013-07-09 23:52:20 +02:00
|
|
|
|
2013-08-23 03:40:34 +02:00
|
|
|
static intra_pred_fn pred[INTRA_MODES][4];
|
2013-07-09 23:52:20 +02:00
|
|
|
static intra_pred_fn dc_pred[2][2][4];
|
|
|
|
|
|
|
|
static void init_intra_pred_fn_ptrs(void) {
|
|
|
|
#define intra_pred_allsizes(l, type) \
|
|
|
|
l[0] = vp9_##type##_predictor_4x4; \
|
|
|
|
l[1] = vp9_##type##_predictor_8x8; \
|
|
|
|
l[2] = vp9_##type##_predictor_16x16; \
|
|
|
|
l[3] = vp9_##type##_predictor_32x32
|
|
|
|
|
|
|
|
intra_pred_allsizes(pred[V_PRED], v);
|
|
|
|
intra_pred_allsizes(pred[H_PRED], h);
|
2013-08-24 02:33:48 +02:00
|
|
|
intra_pred_allsizes(pred[D207_PRED], d207);
|
2013-07-09 23:52:20 +02:00
|
|
|
intra_pred_allsizes(pred[D45_PRED], d45);
|
|
|
|
intra_pred_allsizes(pred[D63_PRED], d63);
|
|
|
|
intra_pred_allsizes(pred[D117_PRED], d117);
|
|
|
|
intra_pred_allsizes(pred[D135_PRED], d135);
|
|
|
|
intra_pred_allsizes(pred[D153_PRED], d153);
|
|
|
|
intra_pred_allsizes(pred[TM_PRED], tm);
|
|
|
|
|
|
|
|
intra_pred_allsizes(dc_pred[0][0], dc_128);
|
|
|
|
intra_pred_allsizes(dc_pred[0][1], dc_top);
|
|
|
|
intra_pred_allsizes(dc_pred[1][0], dc_left);
|
|
|
|
intra_pred_allsizes(dc_pred[1][1], dc);
|
|
|
|
|
|
|
|
#undef intra_pred_allsizes
|
|
|
|
}
|
2013-07-09 02:25:51 +02:00
|
|
|
|
2013-08-14 19:35:56 +02:00
|
|
|
static void build_intra_predictors(const uint8_t *ref, int ref_stride,
|
|
|
|
uint8_t *dst, int dst_stride,
|
|
|
|
MB_PREDICTION_MODE mode, TX_SIZE tx_size,
|
2013-07-09 02:25:51 +02:00
|
|
|
int up_available, int left_available,
|
|
|
|
int right_available) {
|
|
|
|
int i;
|
2013-07-09 23:52:20 +02:00
|
|
|
DECLARE_ALIGNED_ARRAY(16, uint8_t, left_col, 64);
|
2013-08-14 19:35:56 +02:00
|
|
|
DECLARE_ALIGNED_ARRAY(16, uint8_t, above_data, 128 + 16);
|
|
|
|
uint8_t *above_row = above_data + 16;
|
|
|
|
const uint8_t *const_above_row = above_row;
|
|
|
|
const int bs = 4 << tx_size;
|
2013-04-13 01:53:04 +02:00
|
|
|
|
|
|
|
// 127 127 127 .. 127 127 127 127 127 127
|
|
|
|
// 129 A B .. Y Z
|
|
|
|
// 129 C D .. W X
|
|
|
|
// 129 E F .. U V
|
|
|
|
// 129 G H .. S T T T T T
|
|
|
|
// ..
|
2012-07-14 00:21:29 +02:00
|
|
|
|
2013-07-09 23:52:20 +02:00
|
|
|
once(init_intra_pred_fn_ptrs);
|
2013-08-14 19:35:56 +02:00
|
|
|
|
|
|
|
// left
|
[WIP] Add column-based tiling.
This patch adds column-based tiling. The idea is to make each tile
independently decodable (after reading the common frame header) and
also independendly encodable (minus within-frame cost adjustments in
the RD loop) to speed-up hardware & software en/decoders if they used
multi-threading. Column-based tiling has the added advantage (over
other tiling methods) that it minimizes realtime use-case latency,
since all threads can start encoding data as soon as the first SB-row
worth of data is available to the encoder.
There is some test code that does random tile ordering in the decoder,
to confirm that each tile is indeed independently decodable from other
tiles in the same frame. At tile edges, all contexts assume default
values (i.e. 0, 0 motion vector, no coefficients, DC intra4x4 mode),
and motion vector search and ordering do not cross tiles in the same
frame.
t log
Tile independence is not maintained between frames ATM, i.e. tile 0 of
frame 1 is free to use motion vectors that point into any tile of frame
0. We support 1 (i.e. no tiling), 2 or 4 column-tiles.
The loopfilter crosses tile boundaries. I discussed this briefly with Aki
and he says that's OK. An in-loop loopfilter would need to do some sync
between tile threads, but that shouldn't be a big issue.
Resuls: with tiling disabled, we go up slightly because of improved edge
use in the intra4x4 prediction. With 2 tiles, we lose about ~1% on derf,
~0.35% on HD and ~0.55% on STD/HD. With 4 tiles, we lose another ~1.5%
on derf ~0.77% on HD and ~0.85% on STD/HD. Most of this loss is
concentrated in the low-bitrate end of clips, and most of it is because
of the loss of edges at tile boundaries and the resulting loss of intra
predictors.
TODO:
- more tiles (perhaps allow row-based tiling also, and max. 8 tiles)?
- maybe optionally (for EC purposes), motion vectors themselves
should not cross tile edges, or we should emulate such borders as
if they were off-frame, to limit error propagation to within one
tile only. This doesn't have to be the default behaviour but could
be an optional bitstream flag.
Change-Id: I5951c3a0742a767b20bc9fb5af685d9892c2c96f
2013-02-01 18:35:28 +01:00
|
|
|
if (left_available) {
|
2013-07-09 02:25:51 +02:00
|
|
|
for (i = 0; i < bs; i++)
|
2013-08-14 19:35:56 +02:00
|
|
|
left_col[i] = ref[i * ref_stride - 1];
|
[WIP] Add column-based tiling.
This patch adds column-based tiling. The idea is to make each tile
independently decodable (after reading the common frame header) and
also independendly encodable (minus within-frame cost adjustments in
the RD loop) to speed-up hardware & software en/decoders if they used
multi-threading. Column-based tiling has the added advantage (over
other tiling methods) that it minimizes realtime use-case latency,
since all threads can start encoding data as soon as the first SB-row
worth of data is available to the encoder.
There is some test code that does random tile ordering in the decoder,
to confirm that each tile is indeed independently decodable from other
tiles in the same frame. At tile edges, all contexts assume default
values (i.e. 0, 0 motion vector, no coefficients, DC intra4x4 mode),
and motion vector search and ordering do not cross tiles in the same
frame.
t log
Tile independence is not maintained between frames ATM, i.e. tile 0 of
frame 1 is free to use motion vectors that point into any tile of frame
0. We support 1 (i.e. no tiling), 2 or 4 column-tiles.
The loopfilter crosses tile boundaries. I discussed this briefly with Aki
and he says that's OK. An in-loop loopfilter would need to do some sync
between tile threads, but that shouldn't be a big issue.
Resuls: with tiling disabled, we go up slightly because of improved edge
use in the intra4x4 prediction. With 2 tiles, we lose about ~1% on derf,
~0.35% on HD and ~0.55% on STD/HD. With 4 tiles, we lose another ~1.5%
on derf ~0.77% on HD and ~0.85% on STD/HD. Most of this loss is
concentrated in the low-bitrate end of clips, and most of it is because
of the loss of edges at tile boundaries and the resulting loss of intra
predictors.
TODO:
- more tiles (perhaps allow row-based tiling also, and max. 8 tiles)?
- maybe optionally (for EC purposes), motion vectors themselves
should not cross tile edges, or we should emulate such borders as
if they were off-frame, to limit error propagation to within one
tile only. This doesn't have to be the default behaviour but could
be an optional bitstream flag.
Change-Id: I5951c3a0742a767b20bc9fb5af685d9892c2c96f
2013-02-01 18:35:28 +01:00
|
|
|
} else {
|
2013-07-09 23:52:20 +02:00
|
|
|
vpx_memset(left_col, 129, bs);
|
[WIP] Add column-based tiling.
This patch adds column-based tiling. The idea is to make each tile
independently decodable (after reading the common frame header) and
also independendly encodable (minus within-frame cost adjustments in
the RD loop) to speed-up hardware & software en/decoders if they used
multi-threading. Column-based tiling has the added advantage (over
other tiling methods) that it minimizes realtime use-case latency,
since all threads can start encoding data as soon as the first SB-row
worth of data is available to the encoder.
There is some test code that does random tile ordering in the decoder,
to confirm that each tile is indeed independently decodable from other
tiles in the same frame. At tile edges, all contexts assume default
values (i.e. 0, 0 motion vector, no coefficients, DC intra4x4 mode),
and motion vector search and ordering do not cross tiles in the same
frame.
t log
Tile independence is not maintained between frames ATM, i.e. tile 0 of
frame 1 is free to use motion vectors that point into any tile of frame
0. We support 1 (i.e. no tiling), 2 or 4 column-tiles.
The loopfilter crosses tile boundaries. I discussed this briefly with Aki
and he says that's OK. An in-loop loopfilter would need to do some sync
between tile threads, but that shouldn't be a big issue.
Resuls: with tiling disabled, we go up slightly because of improved edge
use in the intra4x4 prediction. With 2 tiles, we lose about ~1% on derf,
~0.35% on HD and ~0.55% on STD/HD. With 4 tiles, we lose another ~1.5%
on derf ~0.77% on HD and ~0.85% on STD/HD. Most of this loss is
concentrated in the low-bitrate end of clips, and most of it is because
of the loss of edges at tile boundaries and the resulting loss of intra
predictors.
TODO:
- more tiles (perhaps allow row-based tiling also, and max. 8 tiles)?
- maybe optionally (for EC purposes), motion vectors themselves
should not cross tile edges, or we should emulate such borders as
if they were off-frame, to limit error propagation to within one
tile only. This doesn't have to be the default behaviour but could
be an optional bitstream flag.
Change-Id: I5951c3a0742a767b20bc9fb5af685d9892c2c96f
2013-02-01 18:35:28 +01:00
|
|
|
}
|
|
|
|
|
2013-08-14 19:35:56 +02:00
|
|
|
// above
|
[WIP] Add column-based tiling.
This patch adds column-based tiling. The idea is to make each tile
independently decodable (after reading the common frame header) and
also independendly encodable (minus within-frame cost adjustments in
the RD loop) to speed-up hardware & software en/decoders if they used
multi-threading. Column-based tiling has the added advantage (over
other tiling methods) that it minimizes realtime use-case latency,
since all threads can start encoding data as soon as the first SB-row
worth of data is available to the encoder.
There is some test code that does random tile ordering in the decoder,
to confirm that each tile is indeed independently decodable from other
tiles in the same frame. At tile edges, all contexts assume default
values (i.e. 0, 0 motion vector, no coefficients, DC intra4x4 mode),
and motion vector search and ordering do not cross tiles in the same
frame.
t log
Tile independence is not maintained between frames ATM, i.e. tile 0 of
frame 1 is free to use motion vectors that point into any tile of frame
0. We support 1 (i.e. no tiling), 2 or 4 column-tiles.
The loopfilter crosses tile boundaries. I discussed this briefly with Aki
and he says that's OK. An in-loop loopfilter would need to do some sync
between tile threads, but that shouldn't be a big issue.
Resuls: with tiling disabled, we go up slightly because of improved edge
use in the intra4x4 prediction. With 2 tiles, we lose about ~1% on derf,
~0.35% on HD and ~0.55% on STD/HD. With 4 tiles, we lose another ~1.5%
on derf ~0.77% on HD and ~0.85% on STD/HD. Most of this loss is
concentrated in the low-bitrate end of clips, and most of it is because
of the loss of edges at tile boundaries and the resulting loss of intra
predictors.
TODO:
- more tiles (perhaps allow row-based tiling also, and max. 8 tiles)?
- maybe optionally (for EC purposes), motion vectors themselves
should not cross tile edges, or we should emulate such borders as
if they were off-frame, to limit error propagation to within one
tile only. This doesn't have to be the default behaviour but could
be an optional bitstream flag.
Change-Id: I5951c3a0742a767b20bc9fb5af685d9892c2c96f
2013-02-01 18:35:28 +01:00
|
|
|
if (up_available) {
|
2013-08-14 19:35:56 +02:00
|
|
|
const uint8_t *above_ref = ref - ref_stride;
|
2013-07-09 02:25:51 +02:00
|
|
|
if (bs == 4 && right_available && left_available) {
|
2013-08-14 19:35:56 +02:00
|
|
|
const_above_row = above_ref;
|
2013-07-09 02:25:51 +02:00
|
|
|
} else {
|
2013-08-14 19:35:56 +02:00
|
|
|
vpx_memcpy(above_row, above_ref, bs);
|
2013-07-09 02:25:51 +02:00
|
|
|
if (bs == 4 && right_available)
|
2013-08-14 19:35:56 +02:00
|
|
|
vpx_memcpy(above_row + bs, above_ref + bs, bs);
|
2013-07-09 02:25:51 +02:00
|
|
|
else
|
2013-07-09 23:52:20 +02:00
|
|
|
vpx_memset(above_row + bs, above_row[bs - 1], bs);
|
2013-08-14 19:35:56 +02:00
|
|
|
above_row[-1] = left_available ? above_ref[-1] : 129;
|
2013-07-09 02:25:51 +02:00
|
|
|
}
|
[WIP] Add column-based tiling.
This patch adds column-based tiling. The idea is to make each tile
independently decodable (after reading the common frame header) and
also independendly encodable (minus within-frame cost adjustments in
the RD loop) to speed-up hardware & software en/decoders if they used
multi-threading. Column-based tiling has the added advantage (over
other tiling methods) that it minimizes realtime use-case latency,
since all threads can start encoding data as soon as the first SB-row
worth of data is available to the encoder.
There is some test code that does random tile ordering in the decoder,
to confirm that each tile is indeed independently decodable from other
tiles in the same frame. At tile edges, all contexts assume default
values (i.e. 0, 0 motion vector, no coefficients, DC intra4x4 mode),
and motion vector search and ordering do not cross tiles in the same
frame.
t log
Tile independence is not maintained between frames ATM, i.e. tile 0 of
frame 1 is free to use motion vectors that point into any tile of frame
0. We support 1 (i.e. no tiling), 2 or 4 column-tiles.
The loopfilter crosses tile boundaries. I discussed this briefly with Aki
and he says that's OK. An in-loop loopfilter would need to do some sync
between tile threads, but that shouldn't be a big issue.
Resuls: with tiling disabled, we go up slightly because of improved edge
use in the intra4x4 prediction. With 2 tiles, we lose about ~1% on derf,
~0.35% on HD and ~0.55% on STD/HD. With 4 tiles, we lose another ~1.5%
on derf ~0.77% on HD and ~0.85% on STD/HD. Most of this loss is
concentrated in the low-bitrate end of clips, and most of it is because
of the loss of edges at tile boundaries and the resulting loss of intra
predictors.
TODO:
- more tiles (perhaps allow row-based tiling also, and max. 8 tiles)?
- maybe optionally (for EC purposes), motion vectors themselves
should not cross tile edges, or we should emulate such borders as
if they were off-frame, to limit error propagation to within one
tile only. This doesn't have to be the default behaviour but could
be an optional bitstream flag.
Change-Id: I5951c3a0742a767b20bc9fb5af685d9892c2c96f
2013-02-01 18:35:28 +01:00
|
|
|
} else {
|
2013-07-09 23:52:20 +02:00
|
|
|
vpx_memset(above_row, 127, bs * 2);
|
|
|
|
above_row[-1] = 127;
|
2012-07-14 00:21:29 +02:00
|
|
|
}
|
2013-07-09 02:25:51 +02:00
|
|
|
|
2013-08-14 19:35:56 +02:00
|
|
|
// predict
|
2013-07-09 02:25:51 +02:00
|
|
|
if (mode == DC_PRED) {
|
2013-08-14 19:35:56 +02:00
|
|
|
dc_pred[left_available][up_available][tx_size](dst, dst_stride,
|
|
|
|
const_above_row, left_col);
|
2013-07-09 02:25:51 +02:00
|
|
|
} else {
|
2013-08-14 19:35:56 +02:00
|
|
|
pred[mode][tx_size](dst, dst_stride, const_above_row, left_col);
|
2012-07-14 00:21:29 +02:00
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
2013-08-14 19:35:56 +02:00
|
|
|
void vp9_predict_intra_block(MACROBLOCKD *xd, int block_idx, int bwl_in,
|
|
|
|
TX_SIZE tx_size, int mode,
|
|
|
|
const uint8_t *ref, int ref_stride,
|
|
|
|
uint8_t *dst, int dst_stride) {
|
2013-05-17 21:50:40 +02:00
|
|
|
const int bwl = bwl_in - tx_size;
|
2013-05-05 00:49:41 +02:00
|
|
|
const int wmask = (1 << bwl) - 1;
|
2013-05-31 21:30:32 +02:00
|
|
|
const int have_top = (block_idx >> bwl) || xd->up_available;
|
|
|
|
const int have_left = (block_idx & wmask) || xd->left_available;
|
|
|
|
const int have_right = ((block_idx & wmask) != wmask);
|
2011-08-05 01:30:27 +02:00
|
|
|
|
2013-05-16 02:21:15 +02:00
|
|
|
assert(bwl >= 0);
|
2013-08-14 19:35:56 +02:00
|
|
|
build_intra_predictors(ref, ref_stride, dst, dst_stride, mode, tx_size,
|
|
|
|
have_top, have_left, have_right);
|
2013-04-23 20:06:11 +02:00
|
|
|
}
|