media/libvpx/vp8/common/findnearmv.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/libvpx/vp8/common/findnearmv.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,182 @@
     1.4 +/*
     1.5 + *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
     1.6 + *
     1.7 + *  Use of this source code is governed by a BSD-style license
     1.8 + *  that can be found in the LICENSE file in the root of the source
     1.9 + *  tree. An additional intellectual property rights grant can be found
    1.10 + *  in the file PATENTS.  All contributing project authors may
    1.11 + *  be found in the AUTHORS file in the root of the source tree.
    1.12 + */
    1.13 +
    1.14 +
    1.15 +#ifndef __INC_FINDNEARMV_H
    1.16 +#define __INC_FINDNEARMV_H
    1.17 +
    1.18 +#include "mv.h"
    1.19 +#include "blockd.h"
    1.20 +#include "modecont.h"
    1.21 +#include "treecoder.h"
    1.22 +
    1.23 +
    1.24 +static void mv_bias(int refmb_ref_frame_sign_bias, int refframe, int_mv *mvp,
    1.25 +                    const int *ref_frame_sign_bias)
    1.26 +{
    1.27 +    if (refmb_ref_frame_sign_bias != ref_frame_sign_bias[refframe])
    1.28 +    {
    1.29 +        mvp->as_mv.row *= -1;
    1.30 +        mvp->as_mv.col *= -1;
    1.31 +    }
    1.32 +}
    1.33 +
    1.34 +#define LEFT_TOP_MARGIN (16 << 3)
    1.35 +#define RIGHT_BOTTOM_MARGIN (16 << 3)
    1.36 +static void vp8_clamp_mv2(int_mv *mv, const MACROBLOCKD *xd)
    1.37 +{
    1.38 +    if (mv->as_mv.col < (xd->mb_to_left_edge - LEFT_TOP_MARGIN))
    1.39 +        mv->as_mv.col = xd->mb_to_left_edge - LEFT_TOP_MARGIN;
    1.40 +    else if (mv->as_mv.col > xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN)
    1.41 +        mv->as_mv.col = xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN;
    1.42 +
    1.43 +    if (mv->as_mv.row < (xd->mb_to_top_edge - LEFT_TOP_MARGIN))
    1.44 +        mv->as_mv.row = xd->mb_to_top_edge - LEFT_TOP_MARGIN;
    1.45 +    else if (mv->as_mv.row > xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN)
    1.46 +        mv->as_mv.row = xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN;
    1.47 +}
    1.48 +
    1.49 +static void vp8_clamp_mv(int_mv *mv, int mb_to_left_edge, int mb_to_right_edge,
    1.50 +                         int mb_to_top_edge, int mb_to_bottom_edge)
    1.51 +{
    1.52 +    mv->as_mv.col = (mv->as_mv.col < mb_to_left_edge) ?
    1.53 +        mb_to_left_edge : mv->as_mv.col;
    1.54 +    mv->as_mv.col = (mv->as_mv.col > mb_to_right_edge) ?
    1.55 +        mb_to_right_edge : mv->as_mv.col;
    1.56 +    mv->as_mv.row = (mv->as_mv.row < mb_to_top_edge) ?
    1.57 +        mb_to_top_edge : mv->as_mv.row;
    1.58 +    mv->as_mv.row = (mv->as_mv.row > mb_to_bottom_edge) ?
    1.59 +        mb_to_bottom_edge : mv->as_mv.row;
    1.60 +}
    1.61 +static unsigned int vp8_check_mv_bounds(int_mv *mv, int mb_to_left_edge,
    1.62 +                                int mb_to_right_edge, int mb_to_top_edge,
    1.63 +                                int mb_to_bottom_edge)
    1.64 +{
    1.65 +    unsigned int need_to_clamp;
    1.66 +    need_to_clamp = (mv->as_mv.col < mb_to_left_edge);
    1.67 +    need_to_clamp |= (mv->as_mv.col > mb_to_right_edge);
    1.68 +    need_to_clamp |= (mv->as_mv.row < mb_to_top_edge);
    1.69 +    need_to_clamp |= (mv->as_mv.row > mb_to_bottom_edge);
    1.70 +    return need_to_clamp;
    1.71 +}
    1.72 +
    1.73 +void vp8_find_near_mvs
    1.74 +(
    1.75 +    MACROBLOCKD *xd,
    1.76 +    const MODE_INFO *here,
    1.77 +    int_mv *nearest, int_mv *nearby, int_mv *best,
    1.78 +    int near_mv_ref_cts[4],
    1.79 +    int refframe,
    1.80 +    int *ref_frame_sign_bias
    1.81 +);
    1.82 +
    1.83 +
    1.84 +int vp8_find_near_mvs_bias
    1.85 +(
    1.86 +    MACROBLOCKD *xd,
    1.87 +    const MODE_INFO *here,
    1.88 +    int_mv mode_mv_sb[2][MB_MODE_COUNT],
    1.89 +    int_mv best_mv_sb[2],
    1.90 +    int cnt[4],
    1.91 +    int refframe,
    1.92 +    int *ref_frame_sign_bias
    1.93 +);
    1.94 +
    1.95 +
    1.96 +vp8_prob *vp8_mv_ref_probs(
    1.97 +    vp8_prob p[VP8_MVREFS-1], const int near_mv_ref_ct[4]
    1.98 +);
    1.99 +
   1.100 +extern const unsigned char vp8_mbsplit_offset[4][16];
   1.101 +
   1.102 +
   1.103 +static int left_block_mv(const MODE_INFO *cur_mb, int b)
   1.104 +{
   1.105 +    if (!(b & 3))
   1.106 +    {
   1.107 +        /* On L edge, get from MB to left of us */
   1.108 +        --cur_mb;
   1.109 +
   1.110 +        if(cur_mb->mbmi.mode != SPLITMV)
   1.111 +            return cur_mb->mbmi.mv.as_int;
   1.112 +        b += 4;
   1.113 +    }
   1.114 +
   1.115 +    return (cur_mb->bmi + b - 1)->mv.as_int;
   1.116 +}
   1.117 +
   1.118 +static int above_block_mv(const MODE_INFO *cur_mb, int b, int mi_stride)
   1.119 +{
   1.120 +    if (!(b >> 2))
   1.121 +    {
   1.122 +        /* On top edge, get from MB above us */
   1.123 +        cur_mb -= mi_stride;
   1.124 +
   1.125 +        if(cur_mb->mbmi.mode != SPLITMV)
   1.126 +            return cur_mb->mbmi.mv.as_int;
   1.127 +        b += 16;
   1.128 +    }
   1.129 +
   1.130 +    return (cur_mb->bmi + (b - 4))->mv.as_int;
   1.131 +}
   1.132 +static B_PREDICTION_MODE left_block_mode(const MODE_INFO *cur_mb, int b)
   1.133 +{
   1.134 +    if (!(b & 3))
   1.135 +    {
   1.136 +        /* On L edge, get from MB to left of us */
   1.137 +        --cur_mb;
   1.138 +        switch (cur_mb->mbmi.mode)
   1.139 +        {
   1.140 +            case B_PRED:
   1.141 +              return (cur_mb->bmi + b + 3)->as_mode;
   1.142 +            case DC_PRED:
   1.143 +                return B_DC_PRED;
   1.144 +            case V_PRED:
   1.145 +                return B_VE_PRED;
   1.146 +            case H_PRED:
   1.147 +                return B_HE_PRED;
   1.148 +            case TM_PRED:
   1.149 +                return B_TM_PRED;
   1.150 +            default:
   1.151 +                return B_DC_PRED;
   1.152 +        }
   1.153 +    }
   1.154 +
   1.155 +    return (cur_mb->bmi + b - 1)->as_mode;
   1.156 +}
   1.157 +
   1.158 +static B_PREDICTION_MODE above_block_mode(const MODE_INFO *cur_mb, int b, int mi_stride)
   1.159 +{
   1.160 +    if (!(b >> 2))
   1.161 +    {
   1.162 +        /* On top edge, get from MB above us */
   1.163 +        cur_mb -= mi_stride;
   1.164 +
   1.165 +        switch (cur_mb->mbmi.mode)
   1.166 +        {
   1.167 +            case B_PRED:
   1.168 +              return (cur_mb->bmi + b + 12)->as_mode;
   1.169 +            case DC_PRED:
   1.170 +                return B_DC_PRED;
   1.171 +            case V_PRED:
   1.172 +                return B_VE_PRED;
   1.173 +            case H_PRED:
   1.174 +                return B_HE_PRED;
   1.175 +            case TM_PRED:
   1.176 +                return B_TM_PRED;
   1.177 +            default:
   1.178 +                return B_DC_PRED;
   1.179 +        }
   1.180 +    }
   1.181 +
   1.182 +    return (cur_mb->bmi + b - 4)->as_mode;
   1.183 +}
   1.184 +
   1.185 +#endif

mercurial