media/libvpx/vp8/common/findnearmv.h

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /*
michael@0 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
michael@0 3 *
michael@0 4 * Use of this source code is governed by a BSD-style license
michael@0 5 * that can be found in the LICENSE file in the root of the source
michael@0 6 * tree. An additional intellectual property rights grant can be found
michael@0 7 * in the file PATENTS. All contributing project authors may
michael@0 8 * be found in the AUTHORS file in the root of the source tree.
michael@0 9 */
michael@0 10
michael@0 11
michael@0 12 #ifndef __INC_FINDNEARMV_H
michael@0 13 #define __INC_FINDNEARMV_H
michael@0 14
michael@0 15 #include "mv.h"
michael@0 16 #include "blockd.h"
michael@0 17 #include "modecont.h"
michael@0 18 #include "treecoder.h"
michael@0 19
michael@0 20
michael@0 21 static void mv_bias(int refmb_ref_frame_sign_bias, int refframe, int_mv *mvp,
michael@0 22 const int *ref_frame_sign_bias)
michael@0 23 {
michael@0 24 if (refmb_ref_frame_sign_bias != ref_frame_sign_bias[refframe])
michael@0 25 {
michael@0 26 mvp->as_mv.row *= -1;
michael@0 27 mvp->as_mv.col *= -1;
michael@0 28 }
michael@0 29 }
michael@0 30
michael@0 31 #define LEFT_TOP_MARGIN (16 << 3)
michael@0 32 #define RIGHT_BOTTOM_MARGIN (16 << 3)
michael@0 33 static void vp8_clamp_mv2(int_mv *mv, const MACROBLOCKD *xd)
michael@0 34 {
michael@0 35 if (mv->as_mv.col < (xd->mb_to_left_edge - LEFT_TOP_MARGIN))
michael@0 36 mv->as_mv.col = xd->mb_to_left_edge - LEFT_TOP_MARGIN;
michael@0 37 else if (mv->as_mv.col > xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN)
michael@0 38 mv->as_mv.col = xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN;
michael@0 39
michael@0 40 if (mv->as_mv.row < (xd->mb_to_top_edge - LEFT_TOP_MARGIN))
michael@0 41 mv->as_mv.row = xd->mb_to_top_edge - LEFT_TOP_MARGIN;
michael@0 42 else if (mv->as_mv.row > xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN)
michael@0 43 mv->as_mv.row = xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN;
michael@0 44 }
michael@0 45
michael@0 46 static void vp8_clamp_mv(int_mv *mv, int mb_to_left_edge, int mb_to_right_edge,
michael@0 47 int mb_to_top_edge, int mb_to_bottom_edge)
michael@0 48 {
michael@0 49 mv->as_mv.col = (mv->as_mv.col < mb_to_left_edge) ?
michael@0 50 mb_to_left_edge : mv->as_mv.col;
michael@0 51 mv->as_mv.col = (mv->as_mv.col > mb_to_right_edge) ?
michael@0 52 mb_to_right_edge : mv->as_mv.col;
michael@0 53 mv->as_mv.row = (mv->as_mv.row < mb_to_top_edge) ?
michael@0 54 mb_to_top_edge : mv->as_mv.row;
michael@0 55 mv->as_mv.row = (mv->as_mv.row > mb_to_bottom_edge) ?
michael@0 56 mb_to_bottom_edge : mv->as_mv.row;
michael@0 57 }
michael@0 58 static unsigned int vp8_check_mv_bounds(int_mv *mv, int mb_to_left_edge,
michael@0 59 int mb_to_right_edge, int mb_to_top_edge,
michael@0 60 int mb_to_bottom_edge)
michael@0 61 {
michael@0 62 unsigned int need_to_clamp;
michael@0 63 need_to_clamp = (mv->as_mv.col < mb_to_left_edge);
michael@0 64 need_to_clamp |= (mv->as_mv.col > mb_to_right_edge);
michael@0 65 need_to_clamp |= (mv->as_mv.row < mb_to_top_edge);
michael@0 66 need_to_clamp |= (mv->as_mv.row > mb_to_bottom_edge);
michael@0 67 return need_to_clamp;
michael@0 68 }
michael@0 69
michael@0 70 void vp8_find_near_mvs
michael@0 71 (
michael@0 72 MACROBLOCKD *xd,
michael@0 73 const MODE_INFO *here,
michael@0 74 int_mv *nearest, int_mv *nearby, int_mv *best,
michael@0 75 int near_mv_ref_cts[4],
michael@0 76 int refframe,
michael@0 77 int *ref_frame_sign_bias
michael@0 78 );
michael@0 79
michael@0 80
michael@0 81 int vp8_find_near_mvs_bias
michael@0 82 (
michael@0 83 MACROBLOCKD *xd,
michael@0 84 const MODE_INFO *here,
michael@0 85 int_mv mode_mv_sb[2][MB_MODE_COUNT],
michael@0 86 int_mv best_mv_sb[2],
michael@0 87 int cnt[4],
michael@0 88 int refframe,
michael@0 89 int *ref_frame_sign_bias
michael@0 90 );
michael@0 91
michael@0 92
michael@0 93 vp8_prob *vp8_mv_ref_probs(
michael@0 94 vp8_prob p[VP8_MVREFS-1], const int near_mv_ref_ct[4]
michael@0 95 );
michael@0 96
michael@0 97 extern const unsigned char vp8_mbsplit_offset[4][16];
michael@0 98
michael@0 99
michael@0 100 static int left_block_mv(const MODE_INFO *cur_mb, int b)
michael@0 101 {
michael@0 102 if (!(b & 3))
michael@0 103 {
michael@0 104 /* On L edge, get from MB to left of us */
michael@0 105 --cur_mb;
michael@0 106
michael@0 107 if(cur_mb->mbmi.mode != SPLITMV)
michael@0 108 return cur_mb->mbmi.mv.as_int;
michael@0 109 b += 4;
michael@0 110 }
michael@0 111
michael@0 112 return (cur_mb->bmi + b - 1)->mv.as_int;
michael@0 113 }
michael@0 114
michael@0 115 static int above_block_mv(const MODE_INFO *cur_mb, int b, int mi_stride)
michael@0 116 {
michael@0 117 if (!(b >> 2))
michael@0 118 {
michael@0 119 /* On top edge, get from MB above us */
michael@0 120 cur_mb -= mi_stride;
michael@0 121
michael@0 122 if(cur_mb->mbmi.mode != SPLITMV)
michael@0 123 return cur_mb->mbmi.mv.as_int;
michael@0 124 b += 16;
michael@0 125 }
michael@0 126
michael@0 127 return (cur_mb->bmi + (b - 4))->mv.as_int;
michael@0 128 }
michael@0 129 static B_PREDICTION_MODE left_block_mode(const MODE_INFO *cur_mb, int b)
michael@0 130 {
michael@0 131 if (!(b & 3))
michael@0 132 {
michael@0 133 /* On L edge, get from MB to left of us */
michael@0 134 --cur_mb;
michael@0 135 switch (cur_mb->mbmi.mode)
michael@0 136 {
michael@0 137 case B_PRED:
michael@0 138 return (cur_mb->bmi + b + 3)->as_mode;
michael@0 139 case DC_PRED:
michael@0 140 return B_DC_PRED;
michael@0 141 case V_PRED:
michael@0 142 return B_VE_PRED;
michael@0 143 case H_PRED:
michael@0 144 return B_HE_PRED;
michael@0 145 case TM_PRED:
michael@0 146 return B_TM_PRED;
michael@0 147 default:
michael@0 148 return B_DC_PRED;
michael@0 149 }
michael@0 150 }
michael@0 151
michael@0 152 return (cur_mb->bmi + b - 1)->as_mode;
michael@0 153 }
michael@0 154
michael@0 155 static B_PREDICTION_MODE above_block_mode(const MODE_INFO *cur_mb, int b, int mi_stride)
michael@0 156 {
michael@0 157 if (!(b >> 2))
michael@0 158 {
michael@0 159 /* On top edge, get from MB above us */
michael@0 160 cur_mb -= mi_stride;
michael@0 161
michael@0 162 switch (cur_mb->mbmi.mode)
michael@0 163 {
michael@0 164 case B_PRED:
michael@0 165 return (cur_mb->bmi + b + 12)->as_mode;
michael@0 166 case DC_PRED:
michael@0 167 return B_DC_PRED;
michael@0 168 case V_PRED:
michael@0 169 return B_VE_PRED;
michael@0 170 case H_PRED:
michael@0 171 return B_HE_PRED;
michael@0 172 case TM_PRED:
michael@0 173 return B_TM_PRED;
michael@0 174 default:
michael@0 175 return B_DC_PRED;
michael@0 176 }
michael@0 177 }
michael@0 178
michael@0 179 return (cur_mb->bmi + b - 4)->as_mode;
michael@0 180 }
michael@0 181
michael@0 182 #endif

mercurial