Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
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 | * * |
michael@0 | 3 | * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * |
michael@0 | 4 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * |
michael@0 | 5 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * |
michael@0 | 6 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * |
michael@0 | 7 | * * |
michael@0 | 8 | * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * |
michael@0 | 9 | * by the Xiph.Org Foundation http://www.xiph.org/ * |
michael@0 | 10 | * * |
michael@0 | 11 | ******************************************************************** |
michael@0 | 12 | |
michael@0 | 13 | function: libvorbis codec headers |
michael@0 | 14 | last mod: $Id: codec_internal.h 16227 2009-07-08 06:58:46Z xiphmont $ |
michael@0 | 15 | |
michael@0 | 16 | ********************************************************************/ |
michael@0 | 17 | |
michael@0 | 18 | #ifndef _V_CODECI_H_ |
michael@0 | 19 | #define _V_CODECI_H_ |
michael@0 | 20 | |
michael@0 | 21 | #include "envelope.h" |
michael@0 | 22 | #include "codebook.h" |
michael@0 | 23 | |
michael@0 | 24 | #define BLOCKTYPE_IMPULSE 0 |
michael@0 | 25 | #define BLOCKTYPE_PADDING 1 |
michael@0 | 26 | #define BLOCKTYPE_TRANSITION 0 |
michael@0 | 27 | #define BLOCKTYPE_LONG 1 |
michael@0 | 28 | |
michael@0 | 29 | #define PACKETBLOBS 15 |
michael@0 | 30 | |
michael@0 | 31 | typedef struct vorbis_block_internal{ |
michael@0 | 32 | float **pcmdelay; /* this is a pointer into local storage */ |
michael@0 | 33 | float ampmax; |
michael@0 | 34 | int blocktype; |
michael@0 | 35 | |
michael@0 | 36 | oggpack_buffer *packetblob[PACKETBLOBS]; /* initialized, must be freed; |
michael@0 | 37 | blob [PACKETBLOBS/2] points to |
michael@0 | 38 | the oggpack_buffer in the |
michael@0 | 39 | main vorbis_block */ |
michael@0 | 40 | } vorbis_block_internal; |
michael@0 | 41 | |
michael@0 | 42 | typedef void vorbis_look_floor; |
michael@0 | 43 | typedef void vorbis_look_residue; |
michael@0 | 44 | typedef void vorbis_look_transform; |
michael@0 | 45 | |
michael@0 | 46 | /* mode ************************************************************/ |
michael@0 | 47 | typedef struct { |
michael@0 | 48 | int blockflag; |
michael@0 | 49 | int windowtype; |
michael@0 | 50 | int transformtype; |
michael@0 | 51 | int mapping; |
michael@0 | 52 | } vorbis_info_mode; |
michael@0 | 53 | |
michael@0 | 54 | typedef void vorbis_info_floor; |
michael@0 | 55 | typedef void vorbis_info_residue; |
michael@0 | 56 | typedef void vorbis_info_mapping; |
michael@0 | 57 | |
michael@0 | 58 | #include "psy.h" |
michael@0 | 59 | #include "bitrate.h" |
michael@0 | 60 | |
michael@0 | 61 | typedef struct private_state { |
michael@0 | 62 | /* local lookup storage */ |
michael@0 | 63 | envelope_lookup *ve; /* envelope lookup */ |
michael@0 | 64 | int window[2]; |
michael@0 | 65 | vorbis_look_transform **transform[2]; /* block, type */ |
michael@0 | 66 | drft_lookup fft_look[2]; |
michael@0 | 67 | |
michael@0 | 68 | int modebits; |
michael@0 | 69 | vorbis_look_floor **flr; |
michael@0 | 70 | vorbis_look_residue **residue; |
michael@0 | 71 | vorbis_look_psy *psy; |
michael@0 | 72 | vorbis_look_psy_global *psy_g_look; |
michael@0 | 73 | |
michael@0 | 74 | /* local storage, only used on the encoding side. This way the |
michael@0 | 75 | application does not need to worry about freeing some packets' |
michael@0 | 76 | memory and not others'; packet storage is always tracked. |
michael@0 | 77 | Cleared next call to a _dsp_ function */ |
michael@0 | 78 | unsigned char *header; |
michael@0 | 79 | unsigned char *header1; |
michael@0 | 80 | unsigned char *header2; |
michael@0 | 81 | |
michael@0 | 82 | bitrate_manager_state bms; |
michael@0 | 83 | |
michael@0 | 84 | ogg_int64_t sample_count; |
michael@0 | 85 | } private_state; |
michael@0 | 86 | |
michael@0 | 87 | /* codec_setup_info contains all the setup information specific to the |
michael@0 | 88 | specific compression/decompression mode in progress (eg, |
michael@0 | 89 | psychoacoustic settings, channel setup, options, codebook |
michael@0 | 90 | etc). |
michael@0 | 91 | *********************************************************************/ |
michael@0 | 92 | |
michael@0 | 93 | #include "highlevel.h" |
michael@0 | 94 | typedef struct codec_setup_info { |
michael@0 | 95 | |
michael@0 | 96 | /* Vorbis supports only short and long blocks, but allows the |
michael@0 | 97 | encoder to choose the sizes */ |
michael@0 | 98 | |
michael@0 | 99 | long blocksizes[2]; |
michael@0 | 100 | |
michael@0 | 101 | /* modes are the primary means of supporting on-the-fly different |
michael@0 | 102 | blocksizes, different channel mappings (LR or M/A), |
michael@0 | 103 | different residue backends, etc. Each mode consists of a |
michael@0 | 104 | blocksize flag and a mapping (along with the mapping setup */ |
michael@0 | 105 | |
michael@0 | 106 | int modes; |
michael@0 | 107 | int maps; |
michael@0 | 108 | int floors; |
michael@0 | 109 | int residues; |
michael@0 | 110 | int books; |
michael@0 | 111 | int psys; /* encode only */ |
michael@0 | 112 | |
michael@0 | 113 | vorbis_info_mode *mode_param[64]; |
michael@0 | 114 | int map_type[64]; |
michael@0 | 115 | vorbis_info_mapping *map_param[64]; |
michael@0 | 116 | int floor_type[64]; |
michael@0 | 117 | vorbis_info_floor *floor_param[64]; |
michael@0 | 118 | int residue_type[64]; |
michael@0 | 119 | vorbis_info_residue *residue_param[64]; |
michael@0 | 120 | static_codebook *book_param[256]; |
michael@0 | 121 | codebook *fullbooks; |
michael@0 | 122 | |
michael@0 | 123 | vorbis_info_psy *psy_param[4]; /* encode only */ |
michael@0 | 124 | vorbis_info_psy_global psy_g_param; |
michael@0 | 125 | |
michael@0 | 126 | bitrate_manager_info bi; |
michael@0 | 127 | highlevel_encode_setup hi; /* used only by vorbisenc.c. It's a |
michael@0 | 128 | highly redundant structure, but |
michael@0 | 129 | improves clarity of program flow. */ |
michael@0 | 130 | int halfrate_flag; /* painless downsample for decode */ |
michael@0 | 131 | } codec_setup_info; |
michael@0 | 132 | |
michael@0 | 133 | extern vorbis_look_psy_global *_vp_global_look(vorbis_info *vi); |
michael@0 | 134 | extern void _vp_global_free(vorbis_look_psy_global *look); |
michael@0 | 135 | |
michael@0 | 136 | |
michael@0 | 137 | |
michael@0 | 138 | typedef struct { |
michael@0 | 139 | int sorted_index[VIF_POSIT+2]; |
michael@0 | 140 | int forward_index[VIF_POSIT+2]; |
michael@0 | 141 | int reverse_index[VIF_POSIT+2]; |
michael@0 | 142 | |
michael@0 | 143 | int hineighbor[VIF_POSIT]; |
michael@0 | 144 | int loneighbor[VIF_POSIT]; |
michael@0 | 145 | int posts; |
michael@0 | 146 | |
michael@0 | 147 | int n; |
michael@0 | 148 | int quant_q; |
michael@0 | 149 | vorbis_info_floor1 *vi; |
michael@0 | 150 | |
michael@0 | 151 | long phrasebits; |
michael@0 | 152 | long postbits; |
michael@0 | 153 | long frames; |
michael@0 | 154 | } vorbis_look_floor1; |
michael@0 | 155 | |
michael@0 | 156 | |
michael@0 | 157 | |
michael@0 | 158 | extern int *floor1_fit(vorbis_block *vb,vorbis_look_floor1 *look, |
michael@0 | 159 | const float *logmdct, /* in */ |
michael@0 | 160 | const float *logmask); |
michael@0 | 161 | extern int *floor1_interpolate_fit(vorbis_block *vb,vorbis_look_floor1 *look, |
michael@0 | 162 | int *A,int *B, |
michael@0 | 163 | int del); |
michael@0 | 164 | extern int floor1_encode(oggpack_buffer *opb,vorbis_block *vb, |
michael@0 | 165 | vorbis_look_floor1 *look, |
michael@0 | 166 | int *post,int *ilogmask); |
michael@0 | 167 | #endif |