media/libvpx/vp8/common/entropymode.c

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 #define USE_PREBUILT_TABLES
michael@0 12
michael@0 13 #include "entropymode.h"
michael@0 14 #include "entropy.h"
michael@0 15 #include "vpx_mem/vpx_mem.h"
michael@0 16
michael@0 17 #include "vp8_entropymodedata.h"
michael@0 18
michael@0 19 int vp8_mv_cont(const int_mv *l, const int_mv *a)
michael@0 20 {
michael@0 21 int lez = (l->as_int == 0);
michael@0 22 int aez = (a->as_int == 0);
michael@0 23 int lea = (l->as_int == a->as_int);
michael@0 24
michael@0 25 if (lea && lez)
michael@0 26 return SUBMVREF_LEFT_ABOVE_ZED;
michael@0 27
michael@0 28 if (lea)
michael@0 29 return SUBMVREF_LEFT_ABOVE_SAME;
michael@0 30
michael@0 31 if (aez)
michael@0 32 return SUBMVREF_ABOVE_ZED;
michael@0 33
michael@0 34 if (lez)
michael@0 35 return SUBMVREF_LEFT_ZED;
michael@0 36
michael@0 37 return SUBMVREF_NORMAL;
michael@0 38 }
michael@0 39
michael@0 40 static const vp8_prob sub_mv_ref_prob [VP8_SUBMVREFS-1] = { 180, 162, 25};
michael@0 41
michael@0 42 const vp8_prob vp8_sub_mv_ref_prob2 [SUBMVREF_COUNT][VP8_SUBMVREFS-1] =
michael@0 43 {
michael@0 44 { 147, 136, 18 },
michael@0 45 { 106, 145, 1 },
michael@0 46 { 179, 121, 1 },
michael@0 47 { 223, 1 , 34 },
michael@0 48 { 208, 1 , 1 }
michael@0 49 };
michael@0 50
michael@0 51
michael@0 52
michael@0 53 const vp8_mbsplit vp8_mbsplits [VP8_NUMMBSPLITS] =
michael@0 54 {
michael@0 55 {
michael@0 56 0, 0, 0, 0,
michael@0 57 0, 0, 0, 0,
michael@0 58 1, 1, 1, 1,
michael@0 59 1, 1, 1, 1,
michael@0 60 },
michael@0 61 {
michael@0 62 0, 0, 1, 1,
michael@0 63 0, 0, 1, 1,
michael@0 64 0, 0, 1, 1,
michael@0 65 0, 0, 1, 1,
michael@0 66 },
michael@0 67 {
michael@0 68 0, 0, 1, 1,
michael@0 69 0, 0, 1, 1,
michael@0 70 2, 2, 3, 3,
michael@0 71 2, 2, 3, 3,
michael@0 72 },
michael@0 73 {
michael@0 74 0, 1, 2, 3,
michael@0 75 4, 5, 6, 7,
michael@0 76 8, 9, 10, 11,
michael@0 77 12, 13, 14, 15,
michael@0 78 }
michael@0 79 };
michael@0 80
michael@0 81 const int vp8_mbsplit_count [VP8_NUMMBSPLITS] = { 2, 2, 4, 16};
michael@0 82
michael@0 83 const vp8_prob vp8_mbsplit_probs [VP8_NUMMBSPLITS-1] = { 110, 111, 150};
michael@0 84
michael@0 85
michael@0 86 /* Array indices are identical to previously-existing INTRAMODECONTEXTNODES. */
michael@0 87
michael@0 88 const vp8_tree_index vp8_bmode_tree[18] = /* INTRAMODECONTEXTNODE value */
michael@0 89 {
michael@0 90 -B_DC_PRED, 2, /* 0 = DC_NODE */
michael@0 91 -B_TM_PRED, 4, /* 1 = TM_NODE */
michael@0 92 -B_VE_PRED, 6, /* 2 = VE_NODE */
michael@0 93 8, 12, /* 3 = COM_NODE */
michael@0 94 -B_HE_PRED, 10, /* 4 = HE_NODE */
michael@0 95 -B_RD_PRED, -B_VR_PRED, /* 5 = RD_NODE */
michael@0 96 -B_LD_PRED, 14, /* 6 = LD_NODE */
michael@0 97 -B_VL_PRED, 16, /* 7 = VL_NODE */
michael@0 98 -B_HD_PRED, -B_HU_PRED /* 8 = HD_NODE */
michael@0 99 };
michael@0 100
michael@0 101 /* Again, these trees use the same probability indices as their
michael@0 102 explicitly-programmed predecessors. */
michael@0 103
michael@0 104 const vp8_tree_index vp8_ymode_tree[8] =
michael@0 105 {
michael@0 106 -DC_PRED, 2,
michael@0 107 4, 6,
michael@0 108 -V_PRED, -H_PRED,
michael@0 109 -TM_PRED, -B_PRED
michael@0 110 };
michael@0 111
michael@0 112 const vp8_tree_index vp8_kf_ymode_tree[8] =
michael@0 113 {
michael@0 114 -B_PRED, 2,
michael@0 115 4, 6,
michael@0 116 -DC_PRED, -V_PRED,
michael@0 117 -H_PRED, -TM_PRED
michael@0 118 };
michael@0 119
michael@0 120 const vp8_tree_index vp8_uv_mode_tree[6] =
michael@0 121 {
michael@0 122 -DC_PRED, 2,
michael@0 123 -V_PRED, 4,
michael@0 124 -H_PRED, -TM_PRED
michael@0 125 };
michael@0 126
michael@0 127 const vp8_tree_index vp8_mbsplit_tree[6] =
michael@0 128 {
michael@0 129 -3, 2,
michael@0 130 -2, 4,
michael@0 131 -0, -1
michael@0 132 };
michael@0 133
michael@0 134 const vp8_tree_index vp8_mv_ref_tree[8] =
michael@0 135 {
michael@0 136 -ZEROMV, 2,
michael@0 137 -NEARESTMV, 4,
michael@0 138 -NEARMV, 6,
michael@0 139 -NEWMV, -SPLITMV
michael@0 140 };
michael@0 141
michael@0 142 const vp8_tree_index vp8_sub_mv_ref_tree[6] =
michael@0 143 {
michael@0 144 -LEFT4X4, 2,
michael@0 145 -ABOVE4X4, 4,
michael@0 146 -ZERO4X4, -NEW4X4
michael@0 147 };
michael@0 148
michael@0 149 const vp8_tree_index vp8_small_mvtree [14] =
michael@0 150 {
michael@0 151 2, 8,
michael@0 152 4, 6,
michael@0 153 -0, -1,
michael@0 154 -2, -3,
michael@0 155 10, 12,
michael@0 156 -4, -5,
michael@0 157 -6, -7
michael@0 158 };
michael@0 159
michael@0 160 void vp8_init_mbmode_probs(VP8_COMMON *x)
michael@0 161 {
michael@0 162 vpx_memcpy(x->fc.ymode_prob, vp8_ymode_prob, sizeof(vp8_ymode_prob));
michael@0 163 vpx_memcpy(x->fc.uv_mode_prob, vp8_uv_mode_prob, sizeof(vp8_uv_mode_prob));
michael@0 164 vpx_memcpy(x->fc.sub_mv_ref_prob, sub_mv_ref_prob, sizeof(sub_mv_ref_prob));
michael@0 165 }
michael@0 166
michael@0 167 void vp8_default_bmode_probs(vp8_prob p [VP8_BINTRAMODES-1])
michael@0 168 {
michael@0 169 vpx_memcpy(p, vp8_bmode_prob, sizeof(vp8_bmode_prob));
michael@0 170 }
michael@0 171

mercurial