Thu, 15 Jan 2015 15:59:08 +0100
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_TREECODER_H |
michael@0 | 13 | #define __INC_TREECODER_H |
michael@0 | 14 | |
michael@0 | 15 | typedef unsigned char vp8bc_index_t; /* probability index */ |
michael@0 | 16 | |
michael@0 | 17 | |
michael@0 | 18 | typedef unsigned char vp8_prob; |
michael@0 | 19 | |
michael@0 | 20 | #define vp8_prob_half ( (vp8_prob) 128) |
michael@0 | 21 | |
michael@0 | 22 | typedef signed char vp8_tree_index; |
michael@0 | 23 | struct bool_coder_spec; |
michael@0 | 24 | |
michael@0 | 25 | typedef struct bool_coder_spec bool_coder_spec; |
michael@0 | 26 | typedef struct bool_writer bool_writer; |
michael@0 | 27 | typedef struct bool_reader bool_reader; |
michael@0 | 28 | |
michael@0 | 29 | typedef const bool_coder_spec c_bool_coder_spec; |
michael@0 | 30 | typedef const bool_writer c_bool_writer; |
michael@0 | 31 | typedef const bool_reader c_bool_reader; |
michael@0 | 32 | |
michael@0 | 33 | |
michael@0 | 34 | |
michael@0 | 35 | # define vp8_complement( x) (255 - x) |
michael@0 | 36 | |
michael@0 | 37 | |
michael@0 | 38 | /* We build coding trees compactly in arrays. |
michael@0 | 39 | Each node of the tree is a pair of vp8_tree_indices. |
michael@0 | 40 | Array index often references a corresponding probability table. |
michael@0 | 41 | Index <= 0 means done encoding/decoding and value = -Index, |
michael@0 | 42 | Index > 0 means need another bit, specification at index. |
michael@0 | 43 | Nonnegative indices are always even; processing begins at node 0. */ |
michael@0 | 44 | |
michael@0 | 45 | typedef const vp8_tree_index vp8_tree[], *vp8_tree_p; |
michael@0 | 46 | |
michael@0 | 47 | |
michael@0 | 48 | typedef const struct vp8_token_struct |
michael@0 | 49 | { |
michael@0 | 50 | int value; |
michael@0 | 51 | int Len; |
michael@0 | 52 | } vp8_token; |
michael@0 | 53 | |
michael@0 | 54 | /* Construct encoding array from tree. */ |
michael@0 | 55 | |
michael@0 | 56 | void vp8_tokens_from_tree(struct vp8_token_struct *, vp8_tree); |
michael@0 | 57 | void vp8_tokens_from_tree_offset(struct vp8_token_struct *, vp8_tree, |
michael@0 | 58 | int offset); |
michael@0 | 59 | |
michael@0 | 60 | |
michael@0 | 61 | /* Convert array of token occurrence counts into a table of probabilities |
michael@0 | 62 | for the associated binary encoding tree. Also writes count of branches |
michael@0 | 63 | taken for each node on the tree; this facilitiates decisions as to |
michael@0 | 64 | probability updates. */ |
michael@0 | 65 | |
michael@0 | 66 | void vp8_tree_probs_from_distribution( |
michael@0 | 67 | int n, /* n = size of alphabet */ |
michael@0 | 68 | vp8_token tok [ /* n */ ], |
michael@0 | 69 | vp8_tree tree, |
michael@0 | 70 | vp8_prob probs [ /* n-1 */ ], |
michael@0 | 71 | unsigned int branch_ct [ /* n-1 */ ] [2], |
michael@0 | 72 | const unsigned int num_events[ /* n */ ], |
michael@0 | 73 | unsigned int Pfactor, |
michael@0 | 74 | int Round |
michael@0 | 75 | ); |
michael@0 | 76 | |
michael@0 | 77 | /* Variant of above using coder spec rather than hardwired 8-bit probs. */ |
michael@0 | 78 | |
michael@0 | 79 | void vp8bc_tree_probs_from_distribution( |
michael@0 | 80 | int n, /* n = size of alphabet */ |
michael@0 | 81 | vp8_token tok [ /* n */ ], |
michael@0 | 82 | vp8_tree tree, |
michael@0 | 83 | vp8_prob probs [ /* n-1 */ ], |
michael@0 | 84 | unsigned int branch_ct [ /* n-1 */ ] [2], |
michael@0 | 85 | const unsigned int num_events[ /* n */ ], |
michael@0 | 86 | c_bool_coder_spec *s |
michael@0 | 87 | ); |
michael@0 | 88 | |
michael@0 | 89 | |
michael@0 | 90 | #endif |