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 VP9_COMMON_VP9_ENTROPYMV_H_ |
michael@0 | 13 | #define VP9_COMMON_VP9_ENTROPYMV_H_ |
michael@0 | 14 | |
michael@0 | 15 | #include "vp9/common/vp9_treecoder.h" |
michael@0 | 16 | #include "./vpx_config.h" |
michael@0 | 17 | #include "vp9/common/vp9_blockd.h" |
michael@0 | 18 | |
michael@0 | 19 | struct VP9Common; |
michael@0 | 20 | |
michael@0 | 21 | void vp9_entropy_mv_init(); |
michael@0 | 22 | void vp9_init_mv_probs(struct VP9Common *cm); |
michael@0 | 23 | |
michael@0 | 24 | void vp9_adapt_mv_probs(struct VP9Common *cm, int usehp); |
michael@0 | 25 | int vp9_use_mv_hp(const MV *ref); |
michael@0 | 26 | |
michael@0 | 27 | #define NMV_UPDATE_PROB 252 |
michael@0 | 28 | |
michael@0 | 29 | /* Symbols for coding which components are zero jointly */ |
michael@0 | 30 | #define MV_JOINTS 4 |
michael@0 | 31 | typedef enum { |
michael@0 | 32 | MV_JOINT_ZERO = 0, /* Zero vector */ |
michael@0 | 33 | MV_JOINT_HNZVZ = 1, /* Vert zero, hor nonzero */ |
michael@0 | 34 | MV_JOINT_HZVNZ = 2, /* Hor zero, vert nonzero */ |
michael@0 | 35 | MV_JOINT_HNZVNZ = 3, /* Both components nonzero */ |
michael@0 | 36 | } MV_JOINT_TYPE; |
michael@0 | 37 | |
michael@0 | 38 | static INLINE int mv_joint_vertical(MV_JOINT_TYPE type) { |
michael@0 | 39 | return type == MV_JOINT_HZVNZ || type == MV_JOINT_HNZVNZ; |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | static INLINE int mv_joint_horizontal(MV_JOINT_TYPE type) { |
michael@0 | 43 | return type == MV_JOINT_HNZVZ || type == MV_JOINT_HNZVNZ; |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | /* Symbols for coding magnitude class of nonzero components */ |
michael@0 | 47 | #define MV_CLASSES 11 |
michael@0 | 48 | typedef enum { |
michael@0 | 49 | MV_CLASS_0 = 0, /* (0, 2] integer pel */ |
michael@0 | 50 | MV_CLASS_1 = 1, /* (2, 4] integer pel */ |
michael@0 | 51 | MV_CLASS_2 = 2, /* (4, 8] integer pel */ |
michael@0 | 52 | MV_CLASS_3 = 3, /* (8, 16] integer pel */ |
michael@0 | 53 | MV_CLASS_4 = 4, /* (16, 32] integer pel */ |
michael@0 | 54 | MV_CLASS_5 = 5, /* (32, 64] integer pel */ |
michael@0 | 55 | MV_CLASS_6 = 6, /* (64, 128] integer pel */ |
michael@0 | 56 | MV_CLASS_7 = 7, /* (128, 256] integer pel */ |
michael@0 | 57 | MV_CLASS_8 = 8, /* (256, 512] integer pel */ |
michael@0 | 58 | MV_CLASS_9 = 9, /* (512, 1024] integer pel */ |
michael@0 | 59 | MV_CLASS_10 = 10, /* (1024,2048] integer pel */ |
michael@0 | 60 | } MV_CLASS_TYPE; |
michael@0 | 61 | |
michael@0 | 62 | #define CLASS0_BITS 1 /* bits at integer precision for class 0 */ |
michael@0 | 63 | #define CLASS0_SIZE (1 << CLASS0_BITS) |
michael@0 | 64 | #define MV_OFFSET_BITS (MV_CLASSES + CLASS0_BITS - 2) |
michael@0 | 65 | |
michael@0 | 66 | #define MV_MAX_BITS (MV_CLASSES + CLASS0_BITS + 2) |
michael@0 | 67 | #define MV_MAX ((1 << MV_MAX_BITS) - 1) |
michael@0 | 68 | #define MV_VALS ((MV_MAX << 1) + 1) |
michael@0 | 69 | |
michael@0 | 70 | #define MV_IN_USE_BITS 14 |
michael@0 | 71 | #define MV_UPP ((1 << MV_IN_USE_BITS) - 1) |
michael@0 | 72 | #define MV_LOW (-(1 << MV_IN_USE_BITS)) |
michael@0 | 73 | |
michael@0 | 74 | extern const vp9_tree_index vp9_mv_joint_tree[TREE_SIZE(MV_JOINTS)]; |
michael@0 | 75 | extern struct vp9_token vp9_mv_joint_encodings[MV_JOINTS]; |
michael@0 | 76 | |
michael@0 | 77 | extern const vp9_tree_index vp9_mv_class_tree[TREE_SIZE(MV_CLASSES)]; |
michael@0 | 78 | extern struct vp9_token vp9_mv_class_encodings[MV_CLASSES]; |
michael@0 | 79 | |
michael@0 | 80 | extern const vp9_tree_index vp9_mv_class0_tree[TREE_SIZE(CLASS0_SIZE)]; |
michael@0 | 81 | extern struct vp9_token vp9_mv_class0_encodings[CLASS0_SIZE]; |
michael@0 | 82 | |
michael@0 | 83 | extern const vp9_tree_index vp9_mv_fp_tree[TREE_SIZE(4)]; |
michael@0 | 84 | extern struct vp9_token vp9_mv_fp_encodings[4]; |
michael@0 | 85 | |
michael@0 | 86 | typedef struct { |
michael@0 | 87 | vp9_prob sign; |
michael@0 | 88 | vp9_prob classes[MV_CLASSES - 1]; |
michael@0 | 89 | vp9_prob class0[CLASS0_SIZE - 1]; |
michael@0 | 90 | vp9_prob bits[MV_OFFSET_BITS]; |
michael@0 | 91 | vp9_prob class0_fp[CLASS0_SIZE][4 - 1]; |
michael@0 | 92 | vp9_prob fp[4 - 1]; |
michael@0 | 93 | vp9_prob class0_hp; |
michael@0 | 94 | vp9_prob hp; |
michael@0 | 95 | } nmv_component; |
michael@0 | 96 | |
michael@0 | 97 | typedef struct { |
michael@0 | 98 | vp9_prob joints[MV_JOINTS - 1]; |
michael@0 | 99 | nmv_component comps[2]; |
michael@0 | 100 | } nmv_context; |
michael@0 | 101 | |
michael@0 | 102 | static INLINE MV_JOINT_TYPE vp9_get_mv_joint(const MV *mv) { |
michael@0 | 103 | if (mv->row == 0) { |
michael@0 | 104 | return mv->col == 0 ? MV_JOINT_ZERO : MV_JOINT_HNZVZ; |
michael@0 | 105 | } else { |
michael@0 | 106 | return mv->col == 0 ? MV_JOINT_HZVNZ : MV_JOINT_HNZVNZ; |
michael@0 | 107 | } |
michael@0 | 108 | } |
michael@0 | 109 | |
michael@0 | 110 | MV_CLASS_TYPE vp9_get_mv_class(int z, int *offset); |
michael@0 | 111 | int vp9_get_mv_mag(MV_CLASS_TYPE c, int offset); |
michael@0 | 112 | |
michael@0 | 113 | |
michael@0 | 114 | typedef struct { |
michael@0 | 115 | unsigned int sign[2]; |
michael@0 | 116 | unsigned int classes[MV_CLASSES]; |
michael@0 | 117 | unsigned int class0[CLASS0_SIZE]; |
michael@0 | 118 | unsigned int bits[MV_OFFSET_BITS][2]; |
michael@0 | 119 | unsigned int class0_fp[CLASS0_SIZE][4]; |
michael@0 | 120 | unsigned int fp[4]; |
michael@0 | 121 | unsigned int class0_hp[2]; |
michael@0 | 122 | unsigned int hp[2]; |
michael@0 | 123 | } nmv_component_counts; |
michael@0 | 124 | |
michael@0 | 125 | typedef struct { |
michael@0 | 126 | unsigned int joints[MV_JOINTS]; |
michael@0 | 127 | nmv_component_counts comps[2]; |
michael@0 | 128 | } nmv_context_counts; |
michael@0 | 129 | |
michael@0 | 130 | void vp9_inc_mv(const MV *mv, nmv_context_counts *mvctx); |
michael@0 | 131 | |
michael@0 | 132 | #endif // VP9_COMMON_VP9_ENTROPYMV_H_ |