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"
|
2015-07-20 00:02:56 +02:00
|
|
|
#include "./vpx_dsp_rtcd.h"
|
2013-08-14 19:35:56 +02:00
|
|
|
|
2015-07-22 19:40:42 +02:00
|
|
|
#if CONFIG_VP9_HIGHBITDEPTH
|
|
|
|
#include "vpx_dsp/vpx_dsp_common.h"
|
|
|
|
#endif // CONFIG_VP9_HIGHBITDEPTH
|
2013-08-14 19:35:56 +02:00
|
|
|
#include "vpx_mem/vpx_mem.h"
|
2015-05-12 04:09:22 +02:00
|
|
|
#include "vpx_ports/mem.h"
|
2015-03-03 01:19:23 +01:00
|
|
|
#include "vpx_ports/vpx_once.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
|
|
|
|
2014-03-13 01:23:26 +01:00
|
|
|
const TX_TYPE intra_mode_to_tx_type_lookup[INTRA_MODES] = {
|
2014-02-28 00:46:48 +01:00
|
|
|
DCT_DCT, // DC
|
|
|
|
ADST_DCT, // V
|
|
|
|
DCT_ADST, // H
|
|
|
|
DCT_DCT, // D45
|
|
|
|
ADST_ADST, // D135
|
|
|
|
ADST_DCT, // D117
|
|
|
|
DCT_ADST, // D153
|
|
|
|
DCT_ADST, // D207
|
|
|
|
ADST_DCT, // D63
|
|
|
|
ADST_ADST, // TM
|
2013-06-26 03:15:42 +02:00
|
|
|
};
|
|
|
|
|
2015-03-17 22:08:16 +01:00
|
|
|
enum {
|
|
|
|
NEED_LEFT = 1 << 1,
|
|
|
|
NEED_ABOVE = 1 << 2,
|
|
|
|
NEED_ABOVERIGHT = 1 << 3,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const uint8_t extend_modes[INTRA_MODES] = {
|
|
|
|
NEED_ABOVE | NEED_LEFT, // DC
|
|
|
|
NEED_ABOVE, // V
|
|
|
|
NEED_LEFT, // H
|
|
|
|
NEED_ABOVERIGHT, // D45
|
|
|
|
NEED_LEFT | NEED_ABOVE, // D135
|
|
|
|
NEED_LEFT | NEED_ABOVE, // D117
|
|
|
|
NEED_LEFT | NEED_ABOVE, // D153
|
|
|
|
NEED_LEFT, // D207
|
|
|
|
NEED_ABOVERIGHT, // D63
|
|
|
|
NEED_LEFT | NEED_ABOVE, // TM
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
2014-08-29 01:48:42 +02:00
|
|
|
static intra_pred_fn pred[INTRA_MODES][TX_SIZES];
|
|
|
|
static intra_pred_fn dc_pred[2][2][TX_SIZES];
|
|
|
|
|
2014-09-15 21:59:19 +02:00
|
|
|
#if CONFIG_VP9_HIGHBITDEPTH
|
|
|
|
typedef void (*intra_high_pred_fn)(uint16_t *dst, ptrdiff_t stride,
|
|
|
|
const uint16_t *above, const uint16_t *left,
|
|
|
|
int bd);
|
|
|
|
static intra_high_pred_fn pred_high[INTRA_MODES][4];
|
|
|
|
static intra_high_pred_fn dc_pred_high[2][2][4];
|
|
|
|
#endif // CONFIG_VP9_HIGHBITDEPTH
|
|
|
|
|
2015-03-05 00:34:55 +01:00
|
|
|
static void vp9_init_intra_predictors_internal(void) {
|
2014-08-29 01:48:42 +02:00
|
|
|
#define INIT_ALL_SIZES(p, type) \
|
2015-07-21 18:39:46 +02:00
|
|
|
p[TX_4X4] = vpx_##type##_predictor_4x4; \
|
|
|
|
p[TX_8X8] = vpx_##type##_predictor_8x8; \
|
|
|
|
p[TX_16X16] = vpx_##type##_predictor_16x16; \
|
|
|
|
p[TX_32X32] = vpx_##type##_predictor_32x32
|
2014-08-29 01:48:42 +02:00
|
|
|
|
|
|
|
INIT_ALL_SIZES(pred[V_PRED], v);
|
|
|
|
INIT_ALL_SIZES(pred[H_PRED], h);
|
|
|
|
INIT_ALL_SIZES(pred[D207_PRED], d207);
|
|
|
|
INIT_ALL_SIZES(pred[D45_PRED], d45);
|
|
|
|
INIT_ALL_SIZES(pred[D63_PRED], d63);
|
|
|
|
INIT_ALL_SIZES(pred[D117_PRED], d117);
|
|
|
|
INIT_ALL_SIZES(pred[D135_PRED], d135);
|
|
|
|
INIT_ALL_SIZES(pred[D153_PRED], d153);
|
|
|
|
INIT_ALL_SIZES(pred[TM_PRED], tm);
|
|
|
|
|
|
|
|
INIT_ALL_SIZES(dc_pred[0][0], dc_128);
|
|
|
|
INIT_ALL_SIZES(dc_pred[0][1], dc_top);
|
|
|
|
INIT_ALL_SIZES(dc_pred[1][0], dc_left);
|
|
|
|
INIT_ALL_SIZES(dc_pred[1][1], dc);
|
|
|
|
|
2014-09-15 21:59:19 +02:00
|
|
|
#if CONFIG_VP9_HIGHBITDEPTH
|
2014-10-08 21:43:22 +02:00
|
|
|
INIT_ALL_SIZES(pred_high[V_PRED], highbd_v);
|
|
|
|
INIT_ALL_SIZES(pred_high[H_PRED], highbd_h);
|
|
|
|
INIT_ALL_SIZES(pred_high[D207_PRED], highbd_d207);
|
|
|
|
INIT_ALL_SIZES(pred_high[D45_PRED], highbd_d45);
|
|
|
|
INIT_ALL_SIZES(pred_high[D63_PRED], highbd_d63);
|
|
|
|
INIT_ALL_SIZES(pred_high[D117_PRED], highbd_d117);
|
|
|
|
INIT_ALL_SIZES(pred_high[D135_PRED], highbd_d135);
|
|
|
|
INIT_ALL_SIZES(pred_high[D153_PRED], highbd_d153);
|
|
|
|
INIT_ALL_SIZES(pred_high[TM_PRED], highbd_tm);
|
|
|
|
|
|
|
|
INIT_ALL_SIZES(dc_pred_high[0][0], highbd_dc_128);
|
|
|
|
INIT_ALL_SIZES(dc_pred_high[0][1], highbd_dc_top);
|
|
|
|
INIT_ALL_SIZES(dc_pred_high[1][0], highbd_dc_left);
|
|
|
|
INIT_ALL_SIZES(dc_pred_high[1][1], highbd_dc);
|
2014-09-15 21:59:19 +02:00
|
|
|
#endif // CONFIG_VP9_HIGHBITDEPTH
|
|
|
|
|
|
|
|
#undef intra_pred_allsizes
|
2013-07-09 23:52:20 +02:00
|
|
|
}
|
2013-07-09 02:25:51 +02:00
|
|
|
|
2014-09-15 21:59:19 +02:00
|
|
|
#if CONFIG_VP9_HIGHBITDEPTH
|
|
|
|
static void build_intra_predictors_high(const MACROBLOCKD *xd,
|
|
|
|
const uint8_t *ref8,
|
|
|
|
int ref_stride,
|
|
|
|
uint8_t *dst8,
|
|
|
|
int dst_stride,
|
|
|
|
PREDICTION_MODE mode,
|
|
|
|
TX_SIZE tx_size,
|
|
|
|
int up_available,
|
|
|
|
int left_available,
|
|
|
|
int right_available,
|
|
|
|
int x, int y,
|
|
|
|
int plane, int bd) {
|
|
|
|
int i;
|
|
|
|
uint16_t *dst = CONVERT_TO_SHORTPTR(dst8);
|
|
|
|
uint16_t *ref = CONVERT_TO_SHORTPTR(ref8);
|
2015-05-08 01:16:42 +02:00
|
|
|
DECLARE_ALIGNED(16, uint16_t, left_col[32]);
|
2015-05-09 05:17:20 +02:00
|
|
|
DECLARE_ALIGNED(16, uint16_t, above_data[64 + 16]);
|
2014-09-15 21:59:19 +02:00
|
|
|
uint16_t *above_row = above_data + 16;
|
|
|
|
const uint16_t *const_above_row = above_row;
|
|
|
|
const int bs = 4 << tx_size;
|
|
|
|
int frame_width, frame_height;
|
|
|
|
int x0, y0;
|
|
|
|
const struct macroblockd_plane *const pd = &xd->plane[plane];
|
2015-10-31 01:15:49 +01:00
|
|
|
const int need_left = extend_modes[mode] & NEED_LEFT;
|
|
|
|
const int need_above = extend_modes[mode] & NEED_ABOVE;
|
|
|
|
const int need_aboveright = extend_modes[mode] & NEED_ABOVERIGHT;
|
2014-09-15 21:59:19 +02:00
|
|
|
int base = 128 << (bd - 8);
|
|
|
|
// 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
|
|
|
|
|
|
|
|
// Get current frame pointer, width and height.
|
|
|
|
if (plane == 0) {
|
|
|
|
frame_width = xd->cur_buf->y_width;
|
|
|
|
frame_height = xd->cur_buf->y_height;
|
|
|
|
} else {
|
|
|
|
frame_width = xd->cur_buf->uv_width;
|
|
|
|
frame_height = xd->cur_buf->uv_height;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get block position in current frame.
|
|
|
|
x0 = (-xd->mb_to_left_edge >> (3 + pd->subsampling_x)) + x;
|
|
|
|
y0 = (-xd->mb_to_top_edge >> (3 + pd->subsampling_y)) + y;
|
|
|
|
|
2015-10-31 01:15:49 +01:00
|
|
|
// NEED_LEFT
|
|
|
|
if (need_left) {
|
|
|
|
if (left_available) {
|
|
|
|
if (xd->mb_to_bottom_edge < 0) {
|
|
|
|
/* slower path if the block needs border extension */
|
|
|
|
if (y0 + bs <= frame_height) {
|
|
|
|
for (i = 0; i < bs; ++i)
|
|
|
|
left_col[i] = ref[i * ref_stride - 1];
|
|
|
|
} else {
|
|
|
|
const int extend_bottom = frame_height - y0;
|
|
|
|
for (i = 0; i < extend_bottom; ++i)
|
|
|
|
left_col[i] = ref[i * ref_stride - 1];
|
|
|
|
for (; i < bs; ++i)
|
|
|
|
left_col[i] = ref[(extend_bottom - 1) * ref_stride - 1];
|
|
|
|
}
|
2014-09-15 21:59:19 +02:00
|
|
|
} else {
|
2015-10-31 01:15:49 +01:00
|
|
|
/* faster path if the block does not need extension */
|
|
|
|
for (i = 0; i < bs; ++i)
|
2014-09-15 21:59:19 +02:00
|
|
|
left_col[i] = ref[i * ref_stride - 1];
|
|
|
|
}
|
|
|
|
} else {
|
2015-10-31 01:15:49 +01:00
|
|
|
// TODO(Peter): this value should probably change for high bitdepth
|
|
|
|
vpx_memset16(left_col, base + 1, bs);
|
2014-09-15 21:59:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-31 01:15:49 +01:00
|
|
|
// NEED_ABOVE
|
|
|
|
if (need_above) {
|
|
|
|
if (up_available) {
|
|
|
|
const uint16_t *above_ref = ref - ref_stride;
|
|
|
|
if (xd->mb_to_right_edge < 0) {
|
|
|
|
/* slower path if the block needs border extension */
|
|
|
|
if (x0 + bs <= frame_width) {
|
|
|
|
memcpy(above_row, above_ref, bs * sizeof(above_row[0]));
|
|
|
|
} else if (x0 <= frame_width) {
|
|
|
|
const int r = frame_width - x0;
|
|
|
|
memcpy(above_row, above_ref, r * sizeof(above_row[0]));
|
|
|
|
vpx_memset16(above_row + r, above_row[r - 1], x0 + bs - frame_width);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* faster path if the block does not need extension */
|
|
|
|
if (bs == 4 && right_available && left_available) {
|
|
|
|
const_above_row = above_ref;
|
2014-09-15 21:59:19 +02:00
|
|
|
} else {
|
2015-08-12 19:41:51 +02:00
|
|
|
memcpy(above_row, above_ref, bs * sizeof(above_row[0]));
|
2014-09-15 21:59:19 +02:00
|
|
|
}
|
2015-10-31 01:15:49 +01:00
|
|
|
}
|
|
|
|
above_row[-1] = left_available ? above_ref[-1] : (base + 1);
|
|
|
|
} else {
|
|
|
|
vpx_memset16(above_row, base - 1, bs);
|
|
|
|
above_row[-1] = base - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NEED_ABOVERIGHT
|
|
|
|
if (need_aboveright) {
|
|
|
|
if (up_available) {
|
|
|
|
const uint16_t *above_ref = ref - ref_stride;
|
|
|
|
if (xd->mb_to_right_edge < 0) {
|
|
|
|
/* slower path if the block needs border extension */
|
|
|
|
if (x0 + 2 * bs <= frame_width) {
|
|
|
|
if (right_available && bs == 4) {
|
|
|
|
memcpy(above_row, above_ref, 2 * bs * sizeof(above_row[0]));
|
|
|
|
} else {
|
|
|
|
memcpy(above_row, above_ref, bs * sizeof(above_row[0]));
|
|
|
|
vpx_memset16(above_row + bs, above_row[bs - 1], bs);
|
|
|
|
}
|
|
|
|
} else if (x0 + bs <= frame_width) {
|
|
|
|
const int r = frame_width - x0;
|
|
|
|
if (right_available && bs == 4) {
|
|
|
|
memcpy(above_row, above_ref, r * sizeof(above_row[0]));
|
|
|
|
vpx_memset16(above_row + r, above_row[r - 1],
|
|
|
|
x0 + 2 * bs - frame_width);
|
|
|
|
} else {
|
|
|
|
memcpy(above_row, above_ref, bs * sizeof(above_row[0]));
|
|
|
|
vpx_memset16(above_row + bs, above_row[bs - 1], bs);
|
|
|
|
}
|
|
|
|
} else if (x0 <= frame_width) {
|
|
|
|
const int r = frame_width - x0;
|
2015-08-12 19:41:51 +02:00
|
|
|
memcpy(above_row, above_ref, r * sizeof(above_row[0]));
|
2014-09-15 21:59:19 +02:00
|
|
|
vpx_memset16(above_row + r, above_row[r - 1],
|
|
|
|
x0 + 2 * bs - frame_width);
|
2015-10-31 01:15:49 +01:00
|
|
|
}
|
|
|
|
// TODO(Peter) this value should probably change for high bitdepth
|
|
|
|
above_row[-1] = left_available ? above_ref[-1] : (base + 1);
|
|
|
|
} else {
|
|
|
|
/* faster path if the block does not need extension */
|
|
|
|
if (bs == 4 && right_available && left_available) {
|
|
|
|
const_above_row = above_ref;
|
2014-09-15 21:59:19 +02:00
|
|
|
} else {
|
2015-08-12 19:41:51 +02:00
|
|
|
memcpy(above_row, above_ref, bs * sizeof(above_row[0]));
|
2015-10-31 01:15:49 +01:00
|
|
|
if (bs == 4 && right_available)
|
|
|
|
memcpy(above_row + bs, above_ref + bs, bs * sizeof(above_row[0]));
|
|
|
|
else
|
|
|
|
vpx_memset16(above_row + bs, above_row[bs - 1], bs);
|
|
|
|
// TODO(Peter): this value should probably change for high bitdepth
|
|
|
|
above_row[-1] = left_available ? above_ref[-1] : (base + 1);
|
2014-09-15 21:59:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2015-10-31 01:15:49 +01:00
|
|
|
vpx_memset16(above_row, base - 1, bs * 2);
|
|
|
|
// TODO(Peter): this value should probably change for high bitdepth
|
|
|
|
above_row[-1] = base - 1;
|
2014-09-15 21:59:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// predict
|
|
|
|
if (mode == DC_PRED) {
|
|
|
|
dc_pred_high[left_available][up_available][tx_size](dst, dst_stride,
|
|
|
|
const_above_row,
|
|
|
|
left_col, xd->bd);
|
|
|
|
} else {
|
|
|
|
pred_high[mode][tx_size](dst, dst_stride, const_above_row, left_col,
|
|
|
|
xd->bd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // CONFIG_VP9_HIGHBITDEPTH
|
|
|
|
|
2013-12-13 05:33:06 +01:00
|
|
|
static void build_intra_predictors(const MACROBLOCKD *xd, const uint8_t *ref,
|
|
|
|
int ref_stride, uint8_t *dst, int dst_stride,
|
2014-04-12 00:26:24 +02:00
|
|
|
PREDICTION_MODE mode, TX_SIZE tx_size,
|
2013-07-09 02:25:51 +02:00
|
|
|
int up_available, int left_available,
|
2013-12-13 05:33:06 +01:00
|
|
|
int right_available, int x, int y,
|
|
|
|
int plane) {
|
2013-07-09 02:25:51 +02:00
|
|
|
int i;
|
2015-05-08 01:16:42 +02:00
|
|
|
DECLARE_ALIGNED(16, uint8_t, left_col[32]);
|
2015-05-09 05:17:20 +02:00
|
|
|
DECLARE_ALIGNED(16, uint8_t, above_data[64 + 16]);
|
2013-08-14 19:35:56 +02:00
|
|
|
uint8_t *above_row = above_data + 16;
|
|
|
|
const uint8_t *const_above_row = above_row;
|
|
|
|
const int bs = 4 << tx_size;
|
2013-12-13 05:33:06 +01:00
|
|
|
int frame_width, frame_height;
|
|
|
|
int x0, y0;
|
|
|
|
const struct macroblockd_plane *const pd = &xd->plane[plane];
|
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-12-13 05:33:06 +01:00
|
|
|
// Get current frame pointer, width and height.
|
|
|
|
if (plane == 0) {
|
|
|
|
frame_width = xd->cur_buf->y_width;
|
|
|
|
frame_height = xd->cur_buf->y_height;
|
|
|
|
} else {
|
|
|
|
frame_width = xd->cur_buf->uv_width;
|
|
|
|
frame_height = xd->cur_buf->uv_height;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get block position in current frame.
|
|
|
|
x0 = (-xd->mb_to_left_edge >> (3 + pd->subsampling_x)) + x;
|
|
|
|
y0 = (-xd->mb_to_top_edge >> (3 + pd->subsampling_y)) + y;
|
|
|
|
|
2015-03-17 22:08:16 +01:00
|
|
|
// NEED_LEFT
|
|
|
|
if (extend_modes[mode] & NEED_LEFT) {
|
|
|
|
if (left_available) {
|
|
|
|
if (xd->mb_to_bottom_edge < 0) {
|
|
|
|
/* slower path if the block needs border extension */
|
|
|
|
if (y0 + bs <= frame_height) {
|
|
|
|
for (i = 0; i < bs; ++i)
|
|
|
|
left_col[i] = ref[i * ref_stride - 1];
|
|
|
|
} else {
|
|
|
|
const int extend_bottom = frame_height - y0;
|
|
|
|
for (i = 0; i < extend_bottom; ++i)
|
|
|
|
left_col[i] = ref[i * ref_stride - 1];
|
|
|
|
for (; i < bs; ++i)
|
|
|
|
left_col[i] = ref[(extend_bottom - 1) * ref_stride - 1];
|
|
|
|
}
|
2013-12-13 05:33:06 +01:00
|
|
|
} else {
|
2015-03-17 22:08:16 +01:00
|
|
|
/* faster path if the block does not need extension */
|
|
|
|
for (i = 0; i < bs; ++i)
|
2013-12-13 05:33:06 +01:00
|
|
|
left_col[i] = ref[i * ref_stride - 1];
|
|
|
|
}
|
|
|
|
} else {
|
2015-04-24 05:47:40 +02:00
|
|
|
memset(left_col, 129, bs);
|
2013-12-13 05:33:06 +01: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
|
|
|
}
|
|
|
|
|
2015-03-17 22:08:16 +01:00
|
|
|
// NEED_ABOVE
|
|
|
|
if (extend_modes[mode] & NEED_ABOVE) {
|
|
|
|
if (up_available) {
|
|
|
|
const uint8_t *above_ref = ref - ref_stride;
|
|
|
|
if (xd->mb_to_right_edge < 0) {
|
|
|
|
/* slower path if the block needs border extension */
|
|
|
|
if (x0 + bs <= frame_width) {
|
2015-04-24 05:42:19 +02:00
|
|
|
memcpy(above_row, above_ref, bs);
|
2015-03-17 22:08:16 +01:00
|
|
|
} else if (x0 <= frame_width) {
|
|
|
|
const int r = frame_width - x0;
|
2015-04-24 05:42:19 +02:00
|
|
|
memcpy(above_row, above_ref, r);
|
2015-04-24 05:47:40 +02:00
|
|
|
memset(above_row + r, above_row[r - 1], x0 + bs - frame_width);
|
2015-03-17 22:08:16 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* faster path if the block does not need extension */
|
|
|
|
if (bs == 4 && right_available && left_available) {
|
|
|
|
const_above_row = above_ref;
|
2013-12-13 05:33:06 +01:00
|
|
|
} else {
|
2015-04-24 05:42:19 +02:00
|
|
|
memcpy(above_row, above_ref, bs);
|
2013-12-13 05:33:06 +01:00
|
|
|
}
|
2015-03-17 22:08:16 +01:00
|
|
|
}
|
|
|
|
above_row[-1] = left_available ? above_ref[-1] : 129;
|
|
|
|
} else {
|
2015-04-24 05:47:40 +02:00
|
|
|
memset(above_row, 127, bs);
|
2015-03-17 22:08:16 +01:00
|
|
|
above_row[-1] = 127;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NEED_ABOVERIGHT
|
|
|
|
if (extend_modes[mode] & NEED_ABOVERIGHT) {
|
|
|
|
if (up_available) {
|
|
|
|
const uint8_t *above_ref = ref - ref_stride;
|
|
|
|
if (xd->mb_to_right_edge < 0) {
|
|
|
|
/* slower path if the block needs border extension */
|
|
|
|
if (x0 + 2 * bs <= frame_width) {
|
|
|
|
if (right_available && bs == 4) {
|
2015-04-24 05:42:19 +02:00
|
|
|
memcpy(above_row, above_ref, 2 * bs);
|
2015-03-17 22:08:16 +01:00
|
|
|
} else {
|
2015-04-24 05:42:19 +02:00
|
|
|
memcpy(above_row, above_ref, bs);
|
2015-04-24 05:47:40 +02:00
|
|
|
memset(above_row + bs, above_row[bs - 1], bs);
|
2015-03-17 22:08:16 +01:00
|
|
|
}
|
|
|
|
} else if (x0 + bs <= frame_width) {
|
|
|
|
const int r = frame_width - x0;
|
|
|
|
if (right_available && bs == 4) {
|
2015-04-24 05:42:19 +02:00
|
|
|
memcpy(above_row, above_ref, r);
|
2015-04-24 05:47:40 +02:00
|
|
|
memset(above_row + r, above_row[r - 1], x0 + 2 * bs - frame_width);
|
2015-03-17 22:08:16 +01:00
|
|
|
} else {
|
2015-04-24 05:42:19 +02:00
|
|
|
memcpy(above_row, above_ref, bs);
|
2015-04-24 05:47:40 +02:00
|
|
|
memset(above_row + bs, above_row[bs - 1], bs);
|
2015-03-17 22:08:16 +01:00
|
|
|
}
|
|
|
|
} else if (x0 <= frame_width) {
|
|
|
|
const int r = frame_width - x0;
|
2015-04-24 05:42:19 +02:00
|
|
|
memcpy(above_row, above_ref, r);
|
2015-04-24 05:47:40 +02:00
|
|
|
memset(above_row + r, above_row[r - 1], x0 + 2 * bs - frame_width);
|
2015-03-17 22:08:16 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* faster path if the block does not need extension */
|
|
|
|
if (bs == 4 && right_available && left_available) {
|
|
|
|
const_above_row = above_ref;
|
2013-12-13 05:33:06 +01:00
|
|
|
} else {
|
2015-04-24 05:42:19 +02:00
|
|
|
memcpy(above_row, above_ref, bs);
|
2015-03-17 22:08:16 +01:00
|
|
|
if (bs == 4 && right_available)
|
2015-04-24 05:42:19 +02:00
|
|
|
memcpy(above_row + bs, above_ref + bs, bs);
|
2015-03-17 22:08:16 +01:00
|
|
|
else
|
2015-04-24 05:47:40 +02:00
|
|
|
memset(above_row + bs, above_row[bs - 1], bs);
|
2013-12-13 05:33:06 +01:00
|
|
|
}
|
|
|
|
}
|
2014-02-26 02:54:33 +01:00
|
|
|
above_row[-1] = left_available ? above_ref[-1] : 129;
|
2013-07-09 02:25:51 +02:00
|
|
|
} else {
|
2015-04-24 05:47:40 +02:00
|
|
|
memset(above_row, 127, bs * 2);
|
2015-03-17 22:08:16 +01:00
|
|
|
above_row[-1] = 127;
|
2013-07-09 02:25:51 +02:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2015-07-13 19:40:01 +02:00
|
|
|
void vp9_predict_intra_block(const MACROBLOCKD *xd, int bwl_in,
|
2014-04-12 00:26:24 +02:00
|
|
|
TX_SIZE tx_size, PREDICTION_MODE mode,
|
2013-12-13 05:33:06 +01:00
|
|
|
const uint8_t *ref, int ref_stride,
|
|
|
|
uint8_t *dst, int dst_stride,
|
|
|
|
int aoff, int loff, int plane) {
|
2015-07-13 19:40:01 +02:00
|
|
|
const int bw = (1 << bwl_in);
|
|
|
|
const int txw = (1 << tx_size);
|
|
|
|
const int have_top = loff || xd->up_available;
|
|
|
|
const int have_left = aoff || xd->left_available;
|
|
|
|
const int have_right = (aoff + txw) < bw;
|
2013-12-13 05:33:06 +01:00
|
|
|
const int x = aoff * 4;
|
|
|
|
const int y = loff * 4;
|
2011-08-05 01:30:27 +02:00
|
|
|
|
2014-09-15 21:59:19 +02:00
|
|
|
#if CONFIG_VP9_HIGHBITDEPTH
|
|
|
|
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
|
|
|
|
build_intra_predictors_high(xd, ref, ref_stride, dst, dst_stride, mode,
|
|
|
|
tx_size, have_top, have_left, have_right,
|
|
|
|
x, y, plane, xd->bd);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
2013-12-13 05:33:06 +01:00
|
|
|
build_intra_predictors(xd, ref, ref_stride, dst, dst_stride, mode, tx_size,
|
|
|
|
have_top, have_left, have_right, x, y, plane);
|
2013-04-23 20:06:11 +02:00
|
|
|
}
|
2015-03-03 01:19:23 +01:00
|
|
|
|
2015-05-15 05:18:45 +02:00
|
|
|
void vp9_init_intra_predictors(void) {
|
2015-03-03 01:19:23 +01:00
|
|
|
once(vp9_init_intra_predictors_internal);
|
|
|
|
}
|