diff options
Diffstat (limited to 'apps/codecs/libspeex/bits.c')
-rw-r--r-- | apps/codecs/libspeex/bits.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/apps/codecs/libspeex/bits.c b/apps/codecs/libspeex/bits.c index 6173246380..379fe748d4 100644 --- a/apps/codecs/libspeex/bits.c +++ b/apps/codecs/libspeex/bits.c | |||
@@ -67,6 +67,20 @@ void speex_bits_init_buffer(SpeexBits *bits, void *buff, int buf_size) | |||
67 | speex_bits_reset(bits); | 67 | speex_bits_reset(bits); |
68 | } | 68 | } |
69 | 69 | ||
70 | void speex_bits_set_bit_buffer(SpeexBits *bits, void *buff, int buf_size) | ||
71 | { | ||
72 | bits->chars = (char*)buff; | ||
73 | bits->buf_size = buf_size; | ||
74 | |||
75 | bits->owner=0; | ||
76 | |||
77 | bits->nbBits=buf_size<<LOG2_BITS_PER_CHAR; | ||
78 | bits->charPtr=0; | ||
79 | bits->bitPtr=0; | ||
80 | bits->overflow=0; | ||
81 | |||
82 | } | ||
83 | |||
70 | void speex_bits_destroy(SpeexBits *bits) | 84 | void speex_bits_destroy(SpeexBits *bits) |
71 | { | 85 | { |
72 | if (bits->owner) | 86 | if (bits->owner) |
@@ -97,7 +111,7 @@ void speex_bits_read_from(SpeexBits *bits, char *chars, int len) | |||
97 | int nchars = len / BYTES_PER_CHAR; | 111 | int nchars = len / BYTES_PER_CHAR; |
98 | if (nchars > bits->buf_size) | 112 | if (nchars > bits->buf_size) |
99 | { | 113 | { |
100 | speex_warning_int("Packet is larger than allocated buffer: ", len); | 114 | speex_notify("Packet is larger than allocated buffer"); |
101 | if (bits->owner) | 115 | if (bits->owner) |
102 | { | 116 | { |
103 | char *tmp = (char*)speex_realloc(bits->chars, nchars); | 117 | char *tmp = (char*)speex_realloc(bits->chars, nchars); |
@@ -110,7 +124,7 @@ void speex_bits_read_from(SpeexBits *bits, char *chars, int len) | |||
110 | speex_warning("Could not resize input buffer: truncating input"); | 124 | speex_warning("Could not resize input buffer: truncating input"); |
111 | } | 125 | } |
112 | } else { | 126 | } else { |
113 | speex_warning("Do not own input buffer: truncating input"); | 127 | speex_warning("Do not own input buffer: truncating oversize input"); |
114 | nchars=bits->buf_size; | 128 | nchars=bits->buf_size; |
115 | } | 129 | } |
116 | } | 130 | } |
@@ -159,10 +173,10 @@ void speex_bits_read_whole_bytes(SpeexBits *bits, char *chars, int nbytes) | |||
159 | bits->chars=tmp; | 173 | bits->chars=tmp; |
160 | } else { | 174 | } else { |
161 | nchars=bits->buf_size-(bits->nbBits>>LOG2_BITS_PER_CHAR)-1; | 175 | nchars=bits->buf_size-(bits->nbBits>>LOG2_BITS_PER_CHAR)-1; |
162 | speex_warning("Could not resize input buffer: truncating input"); | 176 | speex_warning("Could not resize input buffer: truncating oversize input"); |
163 | } | 177 | } |
164 | } else { | 178 | } else { |
165 | speex_warning("Do not own input buffer: truncating input"); | 179 | speex_warning("Do not own input buffer: truncating oversize input"); |
166 | nchars=bits->buf_size; | 180 | nchars=bits->buf_size; |
167 | } | 181 | } |
168 | } | 182 | } |
@@ -223,7 +237,7 @@ void speex_bits_pack(SpeexBits *bits, int data, int nbBits) | |||
223 | 237 | ||
224 | if (bits->charPtr+((nbBits+bits->bitPtr)>>LOG2_BITS_PER_CHAR) >= bits->buf_size) | 238 | if (bits->charPtr+((nbBits+bits->bitPtr)>>LOG2_BITS_PER_CHAR) >= bits->buf_size) |
225 | { | 239 | { |
226 | speex_warning("Buffer too small to pack bits"); | 240 | speex_notify("Buffer too small to pack bits"); |
227 | if (bits->owner) | 241 | if (bits->owner) |
228 | { | 242 | { |
229 | int new_nchars = ((bits->buf_size+5)*3)>>1; | 243 | int new_nchars = ((bits->buf_size+5)*3)>>1; |