media/libvpx/vp9/common/vp9_pred_common.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /*
     2  *  Copyright (c) 2012 The WebM project authors. All Rights Reserved.
     3  *
     4  *  Use of this source code is governed by a BSD-style license
     5  *  that can be found in the LICENSE file in the root of the source
     6  *  tree. An additional intellectual property rights grant can be found
     7  *  in the file PATENTS.  All contributing project authors may
     8  *  be found in the AUTHORS file in the root of the source tree.
     9  */
    11 #ifndef VP9_COMMON_VP9_PRED_COMMON_H_
    12 #define VP9_COMMON_VP9_PRED_COMMON_H_
    14 #include "vp9/common/vp9_blockd.h"
    15 #include "vp9/common/vp9_onyxc_int.h"
    17 static INLINE const MODE_INFO *get_above_mi(const MACROBLOCKD *const xd) {
    18   return xd->up_available ? xd->mi_8x8[-xd->mode_info_stride] : NULL;
    19 }
    21 static INLINE const MODE_INFO *get_left_mi(const MACROBLOCKD *const xd) {
    22   return xd->left_available ? xd->mi_8x8[-1] : NULL;
    23 }
    25 int vp9_get_segment_id(VP9_COMMON *cm, const uint8_t *segment_ids,
    26                        BLOCK_SIZE bsize, int mi_row, int mi_col);
    28 static INLINE int vp9_get_pred_context_seg_id(const MACROBLOCKD *xd) {
    29   const MODE_INFO *const above_mi = get_above_mi(xd);
    30   const MODE_INFO *const left_mi = get_left_mi(xd);
    31   const int above_sip = (above_mi != NULL) ?
    32                         above_mi->mbmi.seg_id_predicted : 0;
    33   const int left_sip = (left_mi != NULL) ? left_mi->mbmi.seg_id_predicted : 0;
    35   return above_sip + left_sip;
    36 }
    38 static INLINE vp9_prob vp9_get_pred_prob_seg_id(struct segmentation *seg,
    39                                                 const MACROBLOCKD *xd) {
    40   return seg->pred_probs[vp9_get_pred_context_seg_id(xd)];
    41 }
    43 void vp9_set_pred_flag_seg_id(MACROBLOCKD *xd, uint8_t pred_flag);
    45 static INLINE int vp9_get_pred_context_mbskip(const MACROBLOCKD *xd) {
    46   const MODE_INFO *const above_mi = get_above_mi(xd);
    47   const MODE_INFO *const left_mi = get_left_mi(xd);
    48   const int above_skip_coeff = (above_mi != NULL) ?
    49                                above_mi->mbmi.skip_coeff : 0;
    50   const int left_skip_coeff = (left_mi != NULL) ? left_mi->mbmi.skip_coeff : 0;
    52   return above_skip_coeff + left_skip_coeff;
    53 }
    55 static INLINE vp9_prob vp9_get_pred_prob_mbskip(const VP9_COMMON *cm,
    56                                                 const MACROBLOCKD *xd) {
    57   return cm->fc.mbskip_probs[vp9_get_pred_context_mbskip(xd)];
    58 }
    60 static INLINE unsigned char vp9_get_pred_flag_mbskip(const MACROBLOCKD *xd) {
    61   return xd->mi_8x8[0]->mbmi.skip_coeff;
    62 }
    64 unsigned char vp9_get_pred_context_switchable_interp(const MACROBLOCKD *xd);
    66 unsigned char vp9_get_pred_context_intra_inter(const MACROBLOCKD *xd);
    68 static INLINE vp9_prob vp9_get_pred_prob_intra_inter(const VP9_COMMON *cm,
    69                                                      const MACROBLOCKD *xd) {
    70   const int pred_context = vp9_get_pred_context_intra_inter(xd);
    71   return cm->fc.intra_inter_prob[pred_context];
    72 }
    74 unsigned char vp9_get_pred_context_comp_inter_inter(const VP9_COMMON *cm,
    75                                                     const MACROBLOCKD *xd);
    78 static INLINE
    79 vp9_prob vp9_get_pred_prob_comp_inter_inter(const VP9_COMMON *cm,
    80                                             const MACROBLOCKD *xd) {
    81   const int pred_context = vp9_get_pred_context_comp_inter_inter(cm, xd);
    82   return cm->fc.comp_inter_prob[pred_context];
    83 }
    85 unsigned char vp9_get_pred_context_comp_ref_p(const VP9_COMMON *cm,
    86                                               const MACROBLOCKD *xd);
    88 static INLINE vp9_prob vp9_get_pred_prob_comp_ref_p(const VP9_COMMON *cm,
    89                                                     const MACROBLOCKD *xd) {
    90   const int pred_context = vp9_get_pred_context_comp_ref_p(cm, xd);
    91   return cm->fc.comp_ref_prob[pred_context];
    92 }
    94 unsigned char vp9_get_pred_context_single_ref_p1(const MACROBLOCKD *xd);
    96 static INLINE vp9_prob vp9_get_pred_prob_single_ref_p1(const VP9_COMMON *cm,
    97                                                        const MACROBLOCKD *xd) {
    98   const int pred_context = vp9_get_pred_context_single_ref_p1(xd);
    99   return cm->fc.single_ref_prob[pred_context][0];
   100 }
   102 unsigned char vp9_get_pred_context_single_ref_p2(const MACROBLOCKD *xd);
   104 static INLINE vp9_prob vp9_get_pred_prob_single_ref_p2(const VP9_COMMON *cm,
   105                                                        const MACROBLOCKD *xd) {
   106   const int pred_context = vp9_get_pred_context_single_ref_p2(xd);
   107   return cm->fc.single_ref_prob[pred_context][1];
   108 }
   110 unsigned char vp9_get_pred_context_tx_size(const MACROBLOCKD *xd);
   112 static const vp9_prob *get_tx_probs(TX_SIZE max_tx_size, int ctx,
   113                                     const struct tx_probs *tx_probs) {
   114   switch (max_tx_size) {
   115     case TX_8X8:
   116       return tx_probs->p8x8[ctx];
   117     case TX_16X16:
   118       return tx_probs->p16x16[ctx];
   119     case TX_32X32:
   120       return tx_probs->p32x32[ctx];
   121     default:
   122       assert(!"Invalid max_tx_size.");
   123       return NULL;
   124   }
   125 }
   127 static const vp9_prob *get_tx_probs2(TX_SIZE max_tx_size, const MACROBLOCKD *xd,
   128                                      const struct tx_probs *tx_probs) {
   129   const int ctx = vp9_get_pred_context_tx_size(xd);
   130   return get_tx_probs(max_tx_size, ctx, tx_probs);
   131 }
   133 static unsigned int *get_tx_counts(TX_SIZE max_tx_size, int ctx,
   134                                    struct tx_counts *tx_counts) {
   135   switch (max_tx_size) {
   136     case TX_8X8:
   137       return tx_counts->p8x8[ctx];
   138     case TX_16X16:
   139       return tx_counts->p16x16[ctx];
   140     case TX_32X32:
   141       return tx_counts->p32x32[ctx];
   142     default:
   143       assert(!"Invalid max_tx_size.");
   144       return NULL;
   145   }
   146 }
   148 #endif  // VP9_COMMON_VP9_PRED_COMMON_H_

mercurial