vp9_pred_common.h 5.18 KB
Newer Older
1
/*
Paul Wilkins's avatar
Paul Wilkins committed
2
 *  Copyright (c) 2012 The WebM project authors. All Rights Reserved.
3
4
5
6
7
8
9
10
 *
 *  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.
 */

11
12
#ifndef VP9_COMMON_VP9_PRED_COMMON_H_
#define VP9_COMMON_VP9_PRED_COMMON_H_
13

Dmitry Kovalev's avatar
Dmitry Kovalev committed
14
15
#include "vp9/common/vp9_blockd.h"
#include "vp9/common/vp9_onyxc_int.h"
16

17
18
int vp9_get_segment_id(VP9_COMMON *cm, const uint8_t *segment_ids,
                       BLOCK_SIZE_TYPE bsize, int mi_row, int mi_col);
19

20

21
22
23
24
25
26
27
static INLINE int vp9_get_pred_context_seg_id(const MACROBLOCKD *xd) {
  const MODE_INFO *const mi = xd->mode_info_context;
  const MB_MODE_INFO *const above_mbmi = &mi[-xd->mode_info_stride].mbmi;
  const MB_MODE_INFO *const left_mbmi = &mi[-1].mbmi;

  return above_mbmi->seg_id_predicted +
             (xd->left_available ? left_mbmi->seg_id_predicted : 0);
28
}
29
30
31

static INLINE vp9_prob vp9_get_pred_prob_seg_id(const MACROBLOCKD *xd) {
  return xd->seg.pred_probs[vp9_get_pred_context_seg_id(xd)];
32
33
}

34
35
void vp9_set_pred_flag_seg_id(VP9_COMMON *cm, BLOCK_SIZE_TYPE bsize,
                              int mi_row, int mi_col, uint8_t pred_flag);
36
37
38
39
40
41
42
43

static INLINE int vp9_get_pred_context_mbskip(const MACROBLOCKD *xd) {
  const MODE_INFO *const mi = xd->mode_info_context;
  const MB_MODE_INFO *const above_mbmi = &mi[-xd->mode_info_stride].mbmi;
  const MB_MODE_INFO *const left_mbmi = &mi[-1].mbmi;

  return above_mbmi->mb_skip_coeff +
             (xd->left_available ? left_mbmi->mb_skip_coeff : 0);
44
}
45

46
47
static INLINE vp9_prob vp9_get_pred_prob_mbskip(const VP9_COMMON *cm,
                                                const MACROBLOCKD *xd) {
48
  return cm->fc.mbskip_probs[vp9_get_pred_context_mbskip(xd)];
49
}
50
51

static INLINE unsigned char vp9_get_pred_flag_mbskip(const MACROBLOCKD *xd) {
52
53
  return xd->mode_info_context->mbmi.mb_skip_coeff;
}
54

55
56
void vp9_set_pred_flag_mbskip(VP9_COMMON *cm, BLOCK_SIZE_TYPE bsize,
                              int mi_row, int mi_col, uint8_t pred_flag);
57
58
59
60
61

unsigned char vp9_get_pred_context_switchable_interp(const VP9_COMMON *cm,
                                                     const MACROBLOCKD *xd);

static INLINE const vp9_prob *vp9_get_pred_probs_switchable_interp(
62
    const VP9_COMMON *cm, const MACROBLOCKD *xd) {
63
64
65
66
67
68
  const int pred_context = vp9_get_pred_context_switchable_interp(cm, xd);
  return &cm->fc.switchable_interp_prob[pred_context][0];
}

unsigned char vp9_get_pred_context_intra_inter(const VP9_COMMON *cm,
                                               const MACROBLOCKD *xd);
69

70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
static INLINE vp9_prob vp9_get_pred_prob_intra_inter(const VP9_COMMON *cm,
                                                     const MACROBLOCKD *xd) {
  const int pred_context = vp9_get_pred_context_intra_inter(cm, xd);
  return cm->fc.intra_inter_prob[pred_context];
}

unsigned char vp9_get_pred_context_comp_inter_inter(const VP9_COMMON *cm,
                                                    const MACROBLOCKD *xd);


static INLINE vp9_prob vp9_get_pred_prob_comp_inter_inter(const VP9_COMMON *cm,
                                                          const MACROBLOCKD *xd) {
  const int pred_context = vp9_get_pred_context_comp_inter_inter(cm, xd);
  return cm->fc.comp_inter_prob[pred_context];
}

unsigned char vp9_get_pred_context_comp_ref_p(const VP9_COMMON *cm,
                                              const MACROBLOCKD *xd);

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];
}

unsigned char vp9_get_pred_context_single_ref_p1(const VP9_COMMON *cm,
                                                 const MACROBLOCKD *xd);

static INLINE vp9_prob vp9_get_pred_prob_single_ref_p1(const VP9_COMMON *cm,
                                                       const MACROBLOCKD *xd) {
  const int pred_context = vp9_get_pred_context_single_ref_p1(cm, xd);
  return cm->fc.single_ref_prob[pred_context][0];
}

unsigned char vp9_get_pred_context_single_ref_p2(const VP9_COMMON *cm,
                                                 const MACROBLOCKD *xd);

static INLINE vp9_prob vp9_get_pred_prob_single_ref_p2(const VP9_COMMON *cm,
                                                       const MACROBLOCKD *xd) {
  const int pred_context = vp9_get_pred_context_single_ref_p2(cm, xd);
  return cm->fc.single_ref_prob[pred_context][1];
}

113
unsigned char vp9_get_pred_context_tx_size(const MACROBLOCKD *xd);
114

115
116
static const vp9_prob *vp9_get_pred_probs_tx_size(const MACROBLOCKD *xd,
                           const struct tx_probs *tx_probs) {
117
  const MODE_INFO *const mi = xd->mode_info_context;
118
  const int pred_context = vp9_get_pred_context_tx_size(xd);
119
  if (mi->mbmi.sb_type < BLOCK_SIZE_MB16X16)
120
    return tx_probs->p8x8[pred_context];
121
  else if (mi->mbmi.sb_type < BLOCK_SIZE_SB32X32)
122
    return tx_probs->p16x16[pred_context];
123
  else
124
    return tx_probs->p32x32[pred_context];
125
126
}

127
#endif  // VP9_COMMON_VP9_PRED_COMMON_H_