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.

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

mercurial