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.
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 #ifndef VP9_COMMON_VP9_COMMON_H_
12 #define VP9_COMMON_VP9_COMMON_H_
14 /* Interface header for common constant data structures and lookup tables */
16 #include <assert.h>
18 #include "./vpx_config.h"
19 #include "vpx_mem/vpx_mem.h"
20 #include "vpx/vpx_integer.h"
22 #define MIN(x, y) (((x) < (y)) ? (x) : (y))
23 #define MAX(x, y) (((x) > (y)) ? (x) : (y))
25 #define ROUND_POWER_OF_TWO(value, n) \
26 (((value) + (1 << ((n) - 1))) >> (n))
28 #define ALIGN_POWER_OF_TWO(value, n) \
29 (((value) + ((1 << (n)) - 1)) & ~((1 << (n)) - 1))
31 // Only need this for fixed-size arrays, for structs just assign.
32 #define vp9_copy(dest, src) { \
33 assert(sizeof(dest) == sizeof(src)); \
34 vpx_memcpy(dest, src, sizeof(src)); \
35 }
37 // Use this for variably-sized arrays.
38 #define vp9_copy_array(dest, src, n) { \
39 assert(sizeof(*dest) == sizeof(*src)); \
40 vpx_memcpy(dest, src, n * sizeof(*src)); \
41 }
43 #define vp9_zero(dest) vpx_memset(&dest, 0, sizeof(dest))
44 #define vp9_zero_array(dest, n) vpx_memset(dest, 0, n * sizeof(*dest))
46 static INLINE uint8_t clip_pixel(int val) {
47 return (val > 255) ? 255u : (val < 0) ? 0u : val;
48 }
50 static INLINE int clamp(int value, int low, int high) {
51 return value < low ? low : (value > high ? high : value);
52 }
54 static INLINE double fclamp(double value, double low, double high) {
55 return value < low ? low : (value > high ? high : value);
56 }
58 static int get_unsigned_bits(unsigned int num_values) {
59 int cat = 0;
60 if (num_values <= 1)
61 return 0;
62 num_values--;
63 while (num_values > 0) {
64 cat++;
65 num_values >>= 1;
66 }
67 return cat;
68 }
70 #if CONFIG_DEBUG
71 #define CHECK_MEM_ERROR(cm, lval, expr) do { \
72 lval = (expr); \
73 if (!lval) \
74 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, \
75 "Failed to allocate "#lval" at %s:%d", \
76 __FILE__, __LINE__); \
77 } while (0)
78 #else
79 #define CHECK_MEM_ERROR(cm, lval, expr) do { \
80 lval = (expr); \
81 if (!lval) \
82 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, \
83 "Failed to allocate "#lval); \
84 } while (0)
85 #endif
87 #define VP9_SYNC_CODE_0 0x49
88 #define VP9_SYNC_CODE_1 0x83
89 #define VP9_SYNC_CODE_2 0x42
91 #define VP9_FRAME_MARKER 0x2
94 #endif // VP9_COMMON_VP9_COMMON_H_