Home | History | Annotate | Download | only in common
      1 /*
      2  *  Copyright (c) 2010 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  */
     10 
     11 
     12 #ifndef __INC_FINDNEARMV_H
     13 #define __INC_FINDNEARMV_H
     14 
     15 #include "mv.h"
     16 #include "blockd.h"
     17 #include "modecont.h"
     18 #include "treecoder.h"
     19 
     20 typedef union
     21 {
     22     unsigned int as_int;
     23     MV           as_mv;
     24 } int_mv;        /* facilitates rapid equality tests */
     25 
     26 static void mv_bias(int refmb_ref_frame_sign_bias, int refframe, int_mv *mvp, const int *ref_frame_sign_bias)
     27 {
     28     MV xmv;
     29     xmv = mvp->as_mv;
     30 
     31     if (refmb_ref_frame_sign_bias != ref_frame_sign_bias[refframe])
     32     {
     33         xmv.row *= -1;
     34         xmv.col *= -1;
     35     }
     36 
     37     mvp->as_mv = xmv;
     38 }
     39 
     40 #define LEFT_TOP_MARGIN (16 << 3)
     41 #define RIGHT_BOTTOM_MARGIN (16 << 3)
     42 static void vp8_clamp_mv(MV *mv, const MACROBLOCKD *xd)
     43 {
     44     if (mv->col < (xd->mb_to_left_edge - LEFT_TOP_MARGIN))
     45         mv->col = xd->mb_to_left_edge - LEFT_TOP_MARGIN;
     46     else if (mv->col > xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN)
     47         mv->col = xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN;
     48 
     49     if (mv->row < (xd->mb_to_top_edge - LEFT_TOP_MARGIN))
     50         mv->row = xd->mb_to_top_edge - LEFT_TOP_MARGIN;
     51     else if (mv->row > xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN)
     52         mv->row = xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN;
     53 }
     54 
     55 void vp8_find_near_mvs
     56 (
     57     MACROBLOCKD *xd,
     58     const MODE_INFO *here,
     59     MV *nearest, MV *nearby, MV *best,
     60     int near_mv_ref_cts[4],
     61     int refframe,
     62     int *ref_frame_sign_bias
     63 );
     64 
     65 vp8_prob *vp8_mv_ref_probs(
     66     vp8_prob p[VP8_MVREFS-1], const int near_mv_ref_ct[4]
     67 );
     68 
     69 const B_MODE_INFO *vp8_left_bmi(const MODE_INFO *cur_mb, int b);
     70 
     71 const B_MODE_INFO *vp8_above_bmi(const MODE_INFO *cur_mb, int b, int mi_stride);
     72 
     73 extern const unsigned char vp8_mbsplit_offset[4][16];
     74 
     75 #endif
     76