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_VP8_H |
michael@0 | 13 | #define __INC_VP8_H |
michael@0 | 14 | |
michael@0 | 15 | #ifdef __cplusplus |
michael@0 | 16 | extern "C" |
michael@0 | 17 | { |
michael@0 | 18 | #endif |
michael@0 | 19 | |
michael@0 | 20 | #include "vpx_config.h" |
michael@0 | 21 | #include "vpx/internal/vpx_codec_internal.h" |
michael@0 | 22 | #include "vpx/vp8cx.h" |
michael@0 | 23 | #include "vpx/vpx_encoder.h" |
michael@0 | 24 | #include "vpx_scale/yv12config.h" |
michael@0 | 25 | #include "ppflags.h" |
michael@0 | 26 | |
michael@0 | 27 | struct VP8_COMP; |
michael@0 | 28 | |
michael@0 | 29 | /* Create/destroy static data structures. */ |
michael@0 | 30 | |
michael@0 | 31 | typedef enum |
michael@0 | 32 | { |
michael@0 | 33 | NORMAL = 0, |
michael@0 | 34 | FOURFIVE = 1, |
michael@0 | 35 | THREEFIVE = 2, |
michael@0 | 36 | ONETWO = 3 |
michael@0 | 37 | |
michael@0 | 38 | } VPX_SCALING; |
michael@0 | 39 | |
michael@0 | 40 | typedef enum |
michael@0 | 41 | { |
michael@0 | 42 | USAGE_STREAM_FROM_SERVER = 0x0, |
michael@0 | 43 | USAGE_LOCAL_FILE_PLAYBACK = 0x1, |
michael@0 | 44 | USAGE_CONSTRAINED_QUALITY = 0x2, |
michael@0 | 45 | USAGE_CONSTANT_QUALITY = 0x3 |
michael@0 | 46 | } END_USAGE; |
michael@0 | 47 | |
michael@0 | 48 | |
michael@0 | 49 | typedef enum |
michael@0 | 50 | { |
michael@0 | 51 | MODE_REALTIME = 0x0, |
michael@0 | 52 | MODE_GOODQUALITY = 0x1, |
michael@0 | 53 | MODE_BESTQUALITY = 0x2, |
michael@0 | 54 | MODE_FIRSTPASS = 0x3, |
michael@0 | 55 | MODE_SECONDPASS = 0x4, |
michael@0 | 56 | MODE_SECONDPASS_BEST = 0x5 |
michael@0 | 57 | } MODE; |
michael@0 | 58 | |
michael@0 | 59 | typedef enum |
michael@0 | 60 | { |
michael@0 | 61 | FRAMEFLAGS_KEY = 1, |
michael@0 | 62 | FRAMEFLAGS_GOLDEN = 2, |
michael@0 | 63 | FRAMEFLAGS_ALTREF = 4 |
michael@0 | 64 | } FRAMETYPE_FLAGS; |
michael@0 | 65 | |
michael@0 | 66 | |
michael@0 | 67 | #include <assert.h> |
michael@0 | 68 | static void Scale2Ratio(int mode, int *hr, int *hs) |
michael@0 | 69 | { |
michael@0 | 70 | switch (mode) |
michael@0 | 71 | { |
michael@0 | 72 | case NORMAL: |
michael@0 | 73 | *hr = 1; |
michael@0 | 74 | *hs = 1; |
michael@0 | 75 | break; |
michael@0 | 76 | case FOURFIVE: |
michael@0 | 77 | *hr = 4; |
michael@0 | 78 | *hs = 5; |
michael@0 | 79 | break; |
michael@0 | 80 | case THREEFIVE: |
michael@0 | 81 | *hr = 3; |
michael@0 | 82 | *hs = 5; |
michael@0 | 83 | break; |
michael@0 | 84 | case ONETWO: |
michael@0 | 85 | *hr = 1; |
michael@0 | 86 | *hs = 2; |
michael@0 | 87 | break; |
michael@0 | 88 | default: |
michael@0 | 89 | *hr = 1; |
michael@0 | 90 | *hs = 1; |
michael@0 | 91 | assert(0); |
michael@0 | 92 | break; |
michael@0 | 93 | } |
michael@0 | 94 | } |
michael@0 | 95 | |
michael@0 | 96 | typedef struct |
michael@0 | 97 | { |
michael@0 | 98 | /* 4 versions of bitstream defined: |
michael@0 | 99 | * 0 best quality/slowest decode, 3 lowest quality/fastest decode |
michael@0 | 100 | */ |
michael@0 | 101 | int Version; |
michael@0 | 102 | int Width; |
michael@0 | 103 | int Height; |
michael@0 | 104 | struct vpx_rational timebase; |
michael@0 | 105 | unsigned int target_bandwidth; /* kilobits per second */ |
michael@0 | 106 | |
michael@0 | 107 | /* parameter used for applying pre processing blur: recommendation 0 */ |
michael@0 | 108 | int noise_sensitivity; |
michael@0 | 109 | |
michael@0 | 110 | /* parameter used for sharpening output: recommendation 0: */ |
michael@0 | 111 | int Sharpness; |
michael@0 | 112 | int cpu_used; |
michael@0 | 113 | unsigned int rc_max_intra_bitrate_pct; |
michael@0 | 114 | |
michael@0 | 115 | /* mode -> |
michael@0 | 116 | *(0)=Realtime/Live Encoding. This mode is optimized for realtim |
michael@0 | 117 | * encoding (for example, capturing a television signal or feed |
michael@0 | 118 | * from a live camera). ( speed setting controls how fast ) |
michael@0 | 119 | *(1)=Good Quality Fast Encoding. The encoder balances quality with |
michael@0 | 120 | * the amount of time it takes to encode the output. ( speed |
michael@0 | 121 | * setting controls how fast ) |
michael@0 | 122 | *(2)=One Pass - Best Quality. The encoder places priority on the |
michael@0 | 123 | * quality of the output over encoding speed. The output is |
michael@0 | 124 | * compressed at the highest possible quality. This option takes |
michael@0 | 125 | * the longest amount of time to encode. ( speed setting ignored |
michael@0 | 126 | * ) |
michael@0 | 127 | *(3)=Two Pass - First Pass. The encoder generates a file of |
michael@0 | 128 | * statistics for use in the second encoding pass. ( speed |
michael@0 | 129 | * setting controls how fast ) |
michael@0 | 130 | *(4)=Two Pass - Second Pass. The encoder uses the statistics that |
michael@0 | 131 | * were generated in the first encoding pass to create the |
michael@0 | 132 | * compressed output. ( speed setting controls how fast ) |
michael@0 | 133 | *(5)=Two Pass - Second Pass Best. The encoder uses the statistics |
michael@0 | 134 | * that were generated in the first encoding pass to create the |
michael@0 | 135 | * compressed output using the highest possible quality, and |
michael@0 | 136 | * taking a longer amount of time to encode.. ( speed setting |
michael@0 | 137 | * ignored ) |
michael@0 | 138 | */ |
michael@0 | 139 | int Mode; |
michael@0 | 140 | |
michael@0 | 141 | /* Key Framing Operations */ |
michael@0 | 142 | int auto_key; /* automatically detect cut scenes */ |
michael@0 | 143 | int key_freq; /* maximum distance to key frame. */ |
michael@0 | 144 | |
michael@0 | 145 | /* lagged compression (if allow_lag == 0 lag_in_frames is ignored) */ |
michael@0 | 146 | int allow_lag; |
michael@0 | 147 | int lag_in_frames; /* how many frames lag before we start encoding */ |
michael@0 | 148 | |
michael@0 | 149 | /* |
michael@0 | 150 | * DATARATE CONTROL OPTIONS |
michael@0 | 151 | */ |
michael@0 | 152 | |
michael@0 | 153 | int end_usage; /* vbr or cbr */ |
michael@0 | 154 | |
michael@0 | 155 | /* buffer targeting aggressiveness */ |
michael@0 | 156 | int under_shoot_pct; |
michael@0 | 157 | int over_shoot_pct; |
michael@0 | 158 | |
michael@0 | 159 | /* buffering parameters */ |
michael@0 | 160 | int64_t starting_buffer_level; |
michael@0 | 161 | int64_t optimal_buffer_level; |
michael@0 | 162 | int64_t maximum_buffer_size; |
michael@0 | 163 | |
michael@0 | 164 | int64_t starting_buffer_level_in_ms; |
michael@0 | 165 | int64_t optimal_buffer_level_in_ms; |
michael@0 | 166 | int64_t maximum_buffer_size_in_ms; |
michael@0 | 167 | |
michael@0 | 168 | /* controlling quality */ |
michael@0 | 169 | int fixed_q; |
michael@0 | 170 | int worst_allowed_q; |
michael@0 | 171 | int best_allowed_q; |
michael@0 | 172 | int cq_level; |
michael@0 | 173 | |
michael@0 | 174 | /* allow internal resizing */ |
michael@0 | 175 | int allow_spatial_resampling; |
michael@0 | 176 | int resample_down_water_mark; |
michael@0 | 177 | int resample_up_water_mark; |
michael@0 | 178 | |
michael@0 | 179 | /* allow internal frame rate alterations */ |
michael@0 | 180 | int allow_df; |
michael@0 | 181 | int drop_frames_water_mark; |
michael@0 | 182 | |
michael@0 | 183 | /* two pass datarate control */ |
michael@0 | 184 | int two_pass_vbrbias; |
michael@0 | 185 | int two_pass_vbrmin_section; |
michael@0 | 186 | int two_pass_vbrmax_section; |
michael@0 | 187 | |
michael@0 | 188 | /* |
michael@0 | 189 | * END DATARATE CONTROL OPTIONS |
michael@0 | 190 | */ |
michael@0 | 191 | |
michael@0 | 192 | /* these parameters aren't to be used in final build don't use!!! */ |
michael@0 | 193 | int play_alternate; |
michael@0 | 194 | int alt_freq; |
michael@0 | 195 | int alt_q; |
michael@0 | 196 | int key_q; |
michael@0 | 197 | int gold_q; |
michael@0 | 198 | |
michael@0 | 199 | |
michael@0 | 200 | int multi_threaded; /* how many threads to run the encoder on */ |
michael@0 | 201 | int token_partitions; /* how many token partitions to create */ |
michael@0 | 202 | |
michael@0 | 203 | /* early breakout threshold: for video conf recommend 800 */ |
michael@0 | 204 | int encode_breakout; |
michael@0 | 205 | |
michael@0 | 206 | /* Bitfield defining the error resiliency features to enable. |
michael@0 | 207 | * Can provide decodable frames after losses in previous |
michael@0 | 208 | * frames and decodable partitions after losses in the same frame. |
michael@0 | 209 | */ |
michael@0 | 210 | unsigned int error_resilient_mode; |
michael@0 | 211 | |
michael@0 | 212 | int arnr_max_frames; |
michael@0 | 213 | int arnr_strength; |
michael@0 | 214 | int arnr_type; |
michael@0 | 215 | |
michael@0 | 216 | struct vpx_fixed_buf two_pass_stats_in; |
michael@0 | 217 | struct vpx_codec_pkt_list *output_pkt_list; |
michael@0 | 218 | |
michael@0 | 219 | vp8e_tuning tuning; |
michael@0 | 220 | |
michael@0 | 221 | /* Temporal scaling parameters */ |
michael@0 | 222 | unsigned int number_of_layers; |
michael@0 | 223 | unsigned int target_bitrate[VPX_TS_MAX_PERIODICITY]; |
michael@0 | 224 | unsigned int rate_decimator[VPX_TS_MAX_PERIODICITY]; |
michael@0 | 225 | unsigned int periodicity; |
michael@0 | 226 | unsigned int layer_id[VPX_TS_MAX_PERIODICITY]; |
michael@0 | 227 | |
michael@0 | 228 | #if CONFIG_MULTI_RES_ENCODING |
michael@0 | 229 | /* Number of total resolutions encoded */ |
michael@0 | 230 | unsigned int mr_total_resolutions; |
michael@0 | 231 | |
michael@0 | 232 | /* Current encoder ID */ |
michael@0 | 233 | unsigned int mr_encoder_id; |
michael@0 | 234 | |
michael@0 | 235 | /* Down-sampling factor */ |
michael@0 | 236 | vpx_rational_t mr_down_sampling_factor; |
michael@0 | 237 | |
michael@0 | 238 | /* Memory location to store low-resolution encoder's mode info */ |
michael@0 | 239 | void* mr_low_res_mode_info; |
michael@0 | 240 | #endif |
michael@0 | 241 | } VP8_CONFIG; |
michael@0 | 242 | |
michael@0 | 243 | |
michael@0 | 244 | void vp8_initialize(); |
michael@0 | 245 | |
michael@0 | 246 | struct VP8_COMP* vp8_create_compressor(VP8_CONFIG *oxcf); |
michael@0 | 247 | void vp8_remove_compressor(struct VP8_COMP* *comp); |
michael@0 | 248 | |
michael@0 | 249 | void vp8_init_config(struct VP8_COMP* onyx, VP8_CONFIG *oxcf); |
michael@0 | 250 | void vp8_change_config(struct VP8_COMP* onyx, VP8_CONFIG *oxcf); |
michael@0 | 251 | |
michael@0 | 252 | int vp8_receive_raw_frame(struct VP8_COMP* comp, unsigned int frame_flags, YV12_BUFFER_CONFIG *sd, int64_t time_stamp, int64_t end_time_stamp); |
michael@0 | 253 | int vp8_get_compressed_data(struct VP8_COMP* comp, unsigned int *frame_flags, unsigned long *size, unsigned char *dest, unsigned char *dest_end, int64_t *time_stamp, int64_t *time_end, int flush); |
michael@0 | 254 | int vp8_get_preview_raw_frame(struct VP8_COMP* comp, YV12_BUFFER_CONFIG *dest, vp8_ppflags_t *flags); |
michael@0 | 255 | |
michael@0 | 256 | int vp8_use_as_reference(struct VP8_COMP* comp, int ref_frame_flags); |
michael@0 | 257 | int vp8_update_reference(struct VP8_COMP* comp, int ref_frame_flags); |
michael@0 | 258 | int vp8_get_reference(struct VP8_COMP* comp, enum vpx_ref_frame_type ref_frame_flag, YV12_BUFFER_CONFIG *sd); |
michael@0 | 259 | int vp8_set_reference(struct VP8_COMP* comp, enum vpx_ref_frame_type ref_frame_flag, YV12_BUFFER_CONFIG *sd); |
michael@0 | 260 | int vp8_update_entropy(struct VP8_COMP* comp, int update); |
michael@0 | 261 | int vp8_set_roimap(struct VP8_COMP* comp, unsigned char *map, unsigned int rows, unsigned int cols, int delta_q[4], int delta_lf[4], unsigned int threshold[4]); |
michael@0 | 262 | int vp8_set_active_map(struct VP8_COMP* comp, unsigned char *map, unsigned int rows, unsigned int cols); |
michael@0 | 263 | int vp8_set_internal_size(struct VP8_COMP* comp, VPX_SCALING horiz_mode, VPX_SCALING vert_mode); |
michael@0 | 264 | int vp8_get_quantizer(struct VP8_COMP* c); |
michael@0 | 265 | |
michael@0 | 266 | #ifdef __cplusplus |
michael@0 | 267 | } |
michael@0 | 268 | #endif |
michael@0 | 269 | |
michael@0 | 270 | #endif |