2012-01-28 10:07:08 +00:00
|
|
|
/*
|
2012-01-31 12:45:30 +00:00
|
|
|
* Copyright (c) 2012 The WebM project authors. All Rights Reserved.
|
2012-01-28 10:07:08 +00:00
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
*/
|
|
|
|
|
2012-11-29 16:36:10 -08:00
|
|
|
#ifndef VP9_COMMON_VP9_PRED_COMMON_H_
|
|
|
|
#define VP9_COMMON_VP9_PRED_COMMON_H_
|
2012-01-28 10:07:08 +00:00
|
|
|
|
2013-03-05 14:12:16 -08:00
|
|
|
#include "vp9/common/vp9_blockd.h"
|
|
|
|
#include "vp9/common/vp9_onyxc_int.h"
|
2012-01-28 10:07:08 +00:00
|
|
|
|
2014-01-18 12:16:11 -08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2013-10-16 18:33:43 +02:00
|
|
|
static INLINE const MODE_INFO *get_above_mi(const MACROBLOCKD *const xd) {
|
2014-04-01 16:18:47 -07:00
|
|
|
return xd->up_available ? xd->mi[-xd->mi_stride] : NULL;
|
2013-10-16 18:33:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static INLINE const MODE_INFO *get_left_mi(const MACROBLOCKD *const xd) {
|
2014-04-01 16:18:47 -07:00
|
|
|
return xd->left_available ? xd->mi[-1] : NULL;
|
2013-10-16 18:33:43 +02:00
|
|
|
}
|
|
|
|
|
2013-06-26 10:27:28 -07:00
|
|
|
int vp9_get_segment_id(VP9_COMMON *cm, const uint8_t *segment_ids,
|
2013-08-26 11:33:16 -07:00
|
|
|
BLOCK_SIZE bsize, int mi_row, int mi_col);
|
2012-01-28 10:07:08 +00:00
|
|
|
|
2013-07-11 18:39:10 -07:00
|
|
|
static INLINE int vp9_get_pred_context_seg_id(const MACROBLOCKD *xd) {
|
2013-10-16 18:33:43 +02:00
|
|
|
const MODE_INFO *const above_mi = get_above_mi(xd);
|
|
|
|
const MODE_INFO *const left_mi = get_left_mi(xd);
|
|
|
|
const int above_sip = (above_mi != NULL) ?
|
|
|
|
above_mi->mbmi.seg_id_predicted : 0;
|
|
|
|
const int left_sip = (left_mi != NULL) ? left_mi->mbmi.seg_id_predicted : 0;
|
2013-07-11 18:39:10 -07:00
|
|
|
|
2013-10-16 18:33:43 +02:00
|
|
|
return above_sip + left_sip;
|
2013-07-09 19:55:07 -07:00
|
|
|
}
|
2013-07-11 18:39:10 -07:00
|
|
|
|
2014-02-13 17:55:03 -08:00
|
|
|
static INLINE vp9_prob vp9_get_pred_prob_seg_id(const struct segmentation *seg,
|
2013-08-14 11:20:33 -07:00
|
|
|
const MACROBLOCKD *xd) {
|
|
|
|
return seg->pred_probs[vp9_get_pred_context_seg_id(xd)];
|
2013-07-09 19:55:07 -07:00
|
|
|
}
|
|
|
|
|
2013-12-10 14:11:26 -08:00
|
|
|
static INLINE int vp9_get_skip_context(const MACROBLOCKD *xd) {
|
2013-10-16 18:33:43 +02:00
|
|
|
const MODE_INFO *const above_mi = get_above_mi(xd);
|
|
|
|
const MODE_INFO *const left_mi = get_left_mi(xd);
|
2014-02-12 17:44:12 -08:00
|
|
|
const int above_skip = (above_mi != NULL) ? above_mi->mbmi.skip : 0;
|
|
|
|
const int left_skip = (left_mi != NULL) ? left_mi->mbmi.skip : 0;
|
2013-12-10 14:11:26 -08:00
|
|
|
return above_skip + left_skip;
|
2013-07-09 19:55:07 -07:00
|
|
|
}
|
2013-07-11 18:39:10 -07:00
|
|
|
|
2013-12-10 14:11:26 -08:00
|
|
|
static INLINE vp9_prob vp9_get_skip_prob(const VP9_COMMON *cm,
|
|
|
|
const MACROBLOCKD *xd) {
|
2014-01-29 14:48:42 -08:00
|
|
|
return cm->fc.skip_probs[vp9_get_skip_context(xd)];
|
2013-07-09 19:55:07 -07:00
|
|
|
}
|
2013-07-11 18:39:10 -07:00
|
|
|
|
2013-12-09 17:02:38 -08:00
|
|
|
int vp9_get_pred_context_switchable_interp(const MACROBLOCKD *xd);
|
2013-07-09 19:55:07 -07:00
|
|
|
|
2013-12-05 17:01:03 -08:00
|
|
|
int vp9_get_intra_inter_context(const MACROBLOCKD *xd);
|
2013-07-11 18:39:10 -07:00
|
|
|
|
2013-12-05 17:01:03 -08:00
|
|
|
static INLINE vp9_prob vp9_get_intra_inter_prob(const VP9_COMMON *cm,
|
|
|
|
const MACROBLOCKD *xd) {
|
|
|
|
return cm->fc.intra_inter_prob[vp9_get_intra_inter_context(xd)];
|
2013-07-09 19:55:07 -07:00
|
|
|
}
|
|
|
|
|
2013-12-06 11:23:01 -08:00
|
|
|
int vp9_get_reference_mode_context(const VP9_COMMON *cm, const MACROBLOCKD *xd);
|
2013-07-09 19:55:07 -07:00
|
|
|
|
2013-12-06 11:23:01 -08:00
|
|
|
static INLINE vp9_prob vp9_get_reference_mode_prob(const VP9_COMMON *cm,
|
|
|
|
const MACROBLOCKD *xd) {
|
|
|
|
return cm->fc.comp_inter_prob[vp9_get_reference_mode_context(cm, xd)];
|
2013-07-09 19:55:07 -07:00
|
|
|
}
|
|
|
|
|
2013-12-10 18:31:46 -08:00
|
|
|
int vp9_get_pred_context_comp_ref_p(const VP9_COMMON *cm,
|
|
|
|
const MACROBLOCKD *xd);
|
2013-07-09 19:55:07 -07:00
|
|
|
|
|
|
|
static INLINE vp9_prob vp9_get_pred_prob_comp_ref_p(const VP9_COMMON *cm,
|
|
|
|
const MACROBLOCKD *xd) {
|
|
|
|
const int pred_context = vp9_get_pred_context_comp_ref_p(cm, xd);
|
|
|
|
return cm->fc.comp_ref_prob[pred_context];
|
|
|
|
}
|
|
|
|
|
2013-12-10 18:31:46 -08:00
|
|
|
int vp9_get_pred_context_single_ref_p1(const MACROBLOCKD *xd);
|
2013-07-09 19:55:07 -07:00
|
|
|
|
|
|
|
static INLINE vp9_prob vp9_get_pred_prob_single_ref_p1(const VP9_COMMON *cm,
|
|
|
|
const MACROBLOCKD *xd) {
|
2013-12-10 18:31:46 -08:00
|
|
|
return cm->fc.single_ref_prob[vp9_get_pred_context_single_ref_p1(xd)][0];
|
2013-07-09 19:55:07 -07:00
|
|
|
}
|
|
|
|
|
2013-12-10 18:31:46 -08:00
|
|
|
int vp9_get_pred_context_single_ref_p2(const MACROBLOCKD *xd);
|
2013-07-09 19:55:07 -07:00
|
|
|
|
|
|
|
static INLINE vp9_prob vp9_get_pred_prob_single_ref_p2(const VP9_COMMON *cm,
|
|
|
|
const MACROBLOCKD *xd) {
|
2013-12-10 18:31:46 -08:00
|
|
|
return cm->fc.single_ref_prob[vp9_get_pred_context_single_ref_p2(xd)][1];
|
2013-07-09 19:55:07 -07:00
|
|
|
}
|
|
|
|
|
2013-12-06 15:31:06 -08:00
|
|
|
int vp9_get_tx_size_context(const MACROBLOCKD *xd);
|
2013-07-09 19:55:07 -07:00
|
|
|
|
2014-02-09 20:12:04 -08:00
|
|
|
static INLINE const vp9_prob *get_tx_probs(TX_SIZE max_tx_size, int ctx,
|
|
|
|
const struct tx_probs *tx_probs) {
|
2013-11-05 17:36:43 -08:00
|
|
|
switch (max_tx_size) {
|
|
|
|
case TX_8X8:
|
|
|
|
return tx_probs->p8x8[ctx];
|
|
|
|
case TX_16X16:
|
|
|
|
return tx_probs->p16x16[ctx];
|
|
|
|
case TX_32X32:
|
|
|
|
return tx_probs->p32x32[ctx];
|
|
|
|
default:
|
2013-12-12 19:44:08 -08:00
|
|
|
assert(0 && "Invalid max_tx_size.");
|
2013-11-05 17:36:43 -08:00
|
|
|
return NULL;
|
|
|
|
}
|
2013-07-22 14:57:43 -07:00
|
|
|
}
|
|
|
|
|
2014-02-09 20:12:04 -08:00
|
|
|
static INLINE const vp9_prob *get_tx_probs2(TX_SIZE max_tx_size,
|
|
|
|
const MACROBLOCKD *xd,
|
|
|
|
const struct tx_probs *tx_probs) {
|
2013-12-06 15:31:06 -08:00
|
|
|
return get_tx_probs(max_tx_size, vp9_get_tx_size_context(xd), tx_probs);
|
2013-07-22 14:57:43 -07:00
|
|
|
}
|
|
|
|
|
2014-02-09 20:12:04 -08:00
|
|
|
static INLINE unsigned int *get_tx_counts(TX_SIZE max_tx_size, int ctx,
|
|
|
|
struct tx_counts *tx_counts) {
|
2013-11-05 17:36:43 -08:00
|
|
|
switch (max_tx_size) {
|
|
|
|
case TX_8X8:
|
|
|
|
return tx_counts->p8x8[ctx];
|
|
|
|
case TX_16X16:
|
|
|
|
return tx_counts->p16x16[ctx];
|
|
|
|
case TX_32X32:
|
|
|
|
return tx_counts->p32x32[ctx];
|
|
|
|
default:
|
2013-12-12 19:44:08 -08:00
|
|
|
assert(0 && "Invalid max_tx_size.");
|
2013-11-05 17:36:43 -08:00
|
|
|
return NULL;
|
|
|
|
}
|
2013-07-09 19:55:07 -07:00
|
|
|
}
|
|
|
|
|
2014-01-18 12:16:11 -08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
} // extern "C"
|
|
|
|
#endif
|
|
|
|
|
2012-12-18 15:31:19 -08:00
|
|
|
#endif // VP9_COMMON_VP9_PRED_COMMON_H_
|