summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/libspeex/bits.c
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2024-05-08 10:36:38 -0400
committerSolomon Peachy <pizza@shaftnet.org>2024-06-20 07:08:35 -0400
commit547b6a570dbad844e79b4ba5eb934f043bab6318 (patch)
tree0cbdb670d73a2544d33985166c5abfa69e20a590 /lib/rbcodec/codecs/libspeex/bits.c
parent8ef20383b1e5025f7724e750832de6e28e50680d (diff)
downloadrockbox-547b6a570dbad844e79b4ba5eb934f043bab6318.tar.gz
rockbox-547b6a570dbad844e79b4ba5eb934f043bab6318.zip
codecs: Update libspeex from 1.2beta3 to 1.2rc1
This is a relatively minor bump, but it's the first step towards bringing this current. Change-Id: Iab6c9b0c77f0ba705280434ea74b513364719499
Diffstat (limited to 'lib/rbcodec/codecs/libspeex/bits.c')
-rw-r--r--lib/rbcodec/codecs/libspeex/bits.c51
1 files changed, 26 insertions, 25 deletions
diff --git a/lib/rbcodec/codecs/libspeex/bits.c b/lib/rbcodec/codecs/libspeex/bits.c
index c7a5c14ede..2580e700fe 100644
--- a/lib/rbcodec/codecs/libspeex/bits.c
+++ b/lib/rbcodec/codecs/libspeex/bits.c
@@ -1,4 +1,4 @@
1/* Copyright (C) 2002 Jean-Marc Valin 1/* Copyright (C) 2002 Jean-Marc Valin
2 File: speex_bits.c 2 File: speex_bits.c
3 3
4 Handles bit packing/unpacking 4 Handles bit packing/unpacking
@@ -6,18 +6,18 @@
6 Redistribution and use in source and binary forms, with or without 6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions 7 modification, are permitted provided that the following conditions
8 are met: 8 are met:
9 9
10 - Redistributions of source code must retain the above copyright 10 - Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer. 11 notice, this list of conditions and the following disclaimer.
12 12
13 - Redistributions in binary form must reproduce the above copyright 13 - Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in the 14 notice, this list of conditions and the following disclaimer in the
15 documentation and/or other materials provided with the distribution. 15 documentation and/or other materials provided with the distribution.
16 16
17 - Neither the name of the Xiph.org Foundation nor the names of its 17 - Neither the name of the Xiph.org Foundation nor the names of its
18 contributors may be used to endorse or promote products derived from 18 contributors may be used to endorse or promote products derived from
19 this software without specific prior written permission. 19 this software without specific prior written permission.
20 20
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -46,7 +46,7 @@
46#endif 46#endif
47 47
48#ifdef ROCKBOX_VOICE_ENCODER 48#ifdef ROCKBOX_VOICE_ENCODER
49void speex_bits_init(SpeexBits *bits) 49EXPORT void speex_bits_init(SpeexBits *bits)
50{ 50{
51 bits->chars = (char*)speex_alloc(MAX_CHARS_PER_FRAME); 51 bits->chars = (char*)speex_alloc(MAX_CHARS_PER_FRAME);
52 if (!bits->chars) 52 if (!bits->chars)
@@ -62,7 +62,7 @@ void speex_bits_init(SpeexBits *bits)
62 62
63#if 0 63#if 0
64/* Rockbox: unused */ 64/* Rockbox: unused */
65void speex_bits_init_buffer(SpeexBits *bits, void *buff, int buf_size) 65EXPORT void speex_bits_init_buffer(SpeexBits *bits, void *buff, int buf_size)
66{ 66{
67 bits->chars = (char*)buff; 67 bits->chars = (char*)buff;
68 bits->buf_size = buf_size; 68 bits->buf_size = buf_size;
@@ -73,7 +73,7 @@ void speex_bits_init_buffer(SpeexBits *bits, void *buff, int buf_size)
73} 73}
74#endif 74#endif
75 75
76void speex_bits_set_bit_buffer(SpeexBits *bits, void *buff, int buf_size) 76EXPORT void speex_bits_set_bit_buffer(SpeexBits *bits, void *buff, int buf_size)
77{ 77{
78 bits->chars = (char*)buff; 78 bits->chars = (char*)buff;
79 bits->buf_size = buf_size; 79 bits->buf_size = buf_size;
@@ -84,11 +84,11 @@ void speex_bits_set_bit_buffer(SpeexBits *bits, void *buff, int buf_size)
84 bits->charPtr=0; 84 bits->charPtr=0;
85 bits->bitPtr=0; 85 bits->bitPtr=0;
86 bits->overflow=0; 86 bits->overflow=0;
87 87
88} 88}
89 89
90#ifndef ROCKBOX_VOICE_CODEC 90#ifndef ROCKBOX_VOICE_CODEC
91void speex_bits_destroy(SpeexBits *bits) 91EXPORT void speex_bits_destroy(SpeexBits *bits)
92{ 92{
93 if (bits->owner) 93 if (bits->owner)
94 speex_free(bits->chars); 94 speex_free(bits->chars);
@@ -97,7 +97,7 @@ void speex_bits_destroy(SpeexBits *bits)
97#endif 97#endif
98 98
99#ifdef ROCKBOX_VOICE_ENCODER 99#ifdef ROCKBOX_VOICE_ENCODER
100void speex_bits_reset(SpeexBits *bits) 100EXPORT void speex_bits_reset(SpeexBits *bits)
101{ 101{
102 /* We only need to clear the first byte now */ 102 /* We only need to clear the first byte now */
103 bits->chars[0]=0; 103 bits->chars[0]=0;
@@ -110,7 +110,7 @@ void speex_bits_reset(SpeexBits *bits)
110 110
111#if 0 111#if 0
112/* Rockbox: unused */ 112/* Rockbox: unused */
113void speex_bits_rewind(SpeexBits *bits) 113EXPORT void speex_bits_rewind(SpeexBits *bits)
114{ 114{
115 bits->charPtr=0; 115 bits->charPtr=0;
116 bits->bitPtr=0; 116 bits->bitPtr=0;
@@ -119,7 +119,7 @@ void speex_bits_rewind(SpeexBits *bits)
119#endif 119#endif
120 120
121#if !defined(SPEEX_VOICE_ENCODER) && !defined(ROCKBOX_VOICE_CODEC) 121#if !defined(SPEEX_VOICE_ENCODER) && !defined(ROCKBOX_VOICE_CODEC)
122void speex_bits_read_from(SpeexBits *bits, char *chars, int len) 122EXPORT void speex_bits_read_from(SpeexBits *bits, char *chars, int len)
123{ 123{
124 int i; 124 int i;
125 int nchars = len / BYTES_PER_CHAR; 125 int nchars = len / BYTES_PER_CHAR;
@@ -166,9 +166,10 @@ static void speex_bits_flush(SpeexBits *bits)
166 bits->charPtr=0; 166 bits->charPtr=0;
167} 167}
168 168
169void speex_bits_read_whole_bytes(SpeexBits *bits, char *chars, int nbytes) 169EXPORT void speex_bits_read_whole_bytes(SpeexBits *bits, char *chars, int nbytes)
170{ 170{
171 int i,pos; 171 int i,pos;
172
172 int nchars = nbytes/BYTES_PER_CHAR; 173 int nchars = nbytes/BYTES_PER_CHAR;
173 174
174 if (((bits->nbBits+BITS_PER_CHAR-1)>>LOG2_BITS_PER_CHAR)+nchars > bits->buf_size) 175 if (((bits->nbBits+BITS_PER_CHAR-1)>>LOG2_BITS_PER_CHAR)+nchars > bits->buf_size)
@@ -200,7 +201,7 @@ void speex_bits_read_whole_bytes(SpeexBits *bits, char *chars, int nbytes)
200#endif 201#endif
201 202
202#ifndef SPEEX_DISABLE_ENCODER 203#ifndef SPEEX_DISABLE_ENCODER
203int speex_bits_write(SpeexBits *bits, char *chars, int max_nbytes) 204EXPORT int speex_bits_write(SpeexBits *bits, char *chars, int max_nbytes)
204{ 205{
205 int i; 206 int i;
206 int max_nchars = max_nbytes/BYTES_PER_CHAR; 207 int max_nchars = max_nbytes/BYTES_PER_CHAR;
@@ -223,7 +224,7 @@ int speex_bits_write(SpeexBits *bits, char *chars, int max_nbytes)
223 return max_nchars*BYTES_PER_CHAR; 224 return max_nchars*BYTES_PER_CHAR;
224} 225}
225 226
226int speex_bits_write_whole_bytes(SpeexBits *bits, char *chars, int max_nbytes) 227EXPORT int speex_bits_write_whole_bytes(SpeexBits *bits, char *chars, int max_nbytes)
227{ 228{
228 int max_nchars = max_nbytes/BYTES_PER_CHAR; 229 int max_nchars = max_nbytes/BYTES_PER_CHAR;
229 int i; 230 int i;
@@ -241,7 +242,7 @@ int speex_bits_write_whole_bytes(SpeexBits *bits, char *chars, int max_nbytes)
241 return max_nchars*BYTES_PER_CHAR; 242 return max_nchars*BYTES_PER_CHAR;
242} 243}
243 244
244void speex_bits_pack(SpeexBits *bits, int data, int nbBits) 245EXPORT void speex_bits_pack(SpeexBits *bits, int data, int nbBits)
245{ 246{
246 unsigned int d=data; 247 unsigned int d=data;
247 248
@@ -287,7 +288,7 @@ void speex_bits_pack(SpeexBits *bits, int data, int nbBits)
287 288
288#if 0 289#if 0
289/* Rockbox: unused */ 290/* Rockbox: unused */
290int speex_bits_unpack_signed(SpeexBits *bits, int nbBits) 291EXPORT int speex_bits_unpack_signed(SpeexBits *bits, int nbBits)
291{ 292{
292 unsigned int d=speex_bits_unpack_unsigned(bits,nbBits); 293 unsigned int d=speex_bits_unpack_unsigned(bits,nbBits);
293 /* If number is negative */ 294 /* If number is negative */
@@ -299,7 +300,7 @@ int speex_bits_unpack_signed(SpeexBits *bits, int nbBits)
299} 300}
300#endif 301#endif
301 302
302unsigned int speex_bits_unpack_unsigned(SpeexBits *bits, int nbBits) 303EXPORT unsigned int speex_bits_unpack_unsigned(SpeexBits *bits, int nbBits)
303{ 304{
304 unsigned int d=0; 305 unsigned int d=0;
305 if ((bits->charPtr<<LOG2_BITS_PER_CHAR)+bits->bitPtr+nbBits>bits->nbBits) 306 if ((bits->charPtr<<LOG2_BITS_PER_CHAR)+bits->bitPtr+nbBits>bits->nbBits)
@@ -323,7 +324,7 @@ unsigned int speex_bits_unpack_unsigned(SpeexBits *bits, int nbBits)
323 324
324#if 0 325#if 0
325/* Rockbox: unused */ 326/* Rockbox: unused */
326unsigned int speex_bits_peek_unsigned(SpeexBits *bits, int nbBits) 327EXPORT unsigned int speex_bits_peek_unsigned(SpeexBits *bits, int nbBits)
327{ 328{
328 unsigned int d=0; 329 unsigned int d=0;
329 int bitPtr, charPtr; 330 int bitPtr, charPtr;
@@ -353,7 +354,7 @@ unsigned int speex_bits_peek_unsigned(SpeexBits *bits, int nbBits)
353} 354}
354#endif 355#endif
355 356
356int speex_bits_peek(SpeexBits *bits) 357EXPORT int speex_bits_peek(SpeexBits *bits)
357{ 358{
358 if ((bits->charPtr<<LOG2_BITS_PER_CHAR)+bits->bitPtr+1>bits->nbBits) 359 if ((bits->charPtr<<LOG2_BITS_PER_CHAR)+bits->bitPtr+1>bits->nbBits)
359 bits->overflow=1; 360 bits->overflow=1;
@@ -362,7 +363,7 @@ int speex_bits_peek(SpeexBits *bits)
362 return (bits->chars[bits->charPtr]>>(BITS_PER_CHAR-1 - bits->bitPtr))&1; 363 return (bits->chars[bits->charPtr]>>(BITS_PER_CHAR-1 - bits->bitPtr))&1;
363} 364}
364 365
365void speex_bits_advance(SpeexBits *bits, int n) 366EXPORT void speex_bits_advance(SpeexBits *bits, int n)
366{ 367{
367 if (((bits->charPtr<<LOG2_BITS_PER_CHAR)+bits->bitPtr+n>bits->nbBits) || bits->overflow){ 368 if (((bits->charPtr<<LOG2_BITS_PER_CHAR)+bits->bitPtr+n>bits->nbBits) || bits->overflow){
368 bits->overflow=1; 369 bits->overflow=1;
@@ -372,7 +373,7 @@ void speex_bits_advance(SpeexBits *bits, int n)
372 bits->bitPtr = (bits->bitPtr+n) & (BITS_PER_CHAR-1); /* modulo by BITS_PER_CHAR */ 373 bits->bitPtr = (bits->bitPtr+n) & (BITS_PER_CHAR-1); /* modulo by BITS_PER_CHAR */
373} 374}
374 375
375int speex_bits_remaining(SpeexBits *bits) 376EXPORT int speex_bits_remaining(SpeexBits *bits)
376{ 377{
377 if (bits->overflow) 378 if (bits->overflow)
378 return -1; 379 return -1;
@@ -382,14 +383,14 @@ int speex_bits_remaining(SpeexBits *bits)
382 383
383#if 0 384#if 0
384/* Rockbox: unused */ 385/* Rockbox: unused */
385int speex_bits_nbytes(SpeexBits *bits) 386EXPORT int speex_bits_nbytes(SpeexBits *bits)
386{ 387{
387 return ((bits->nbBits+BITS_PER_CHAR-1)>>LOG2_BITS_PER_CHAR); 388 return ((bits->nbBits+BITS_PER_CHAR-1)>>LOG2_BITS_PER_CHAR);
388} 389}
389#endif 390#endif
390 391
391#ifndef SPEEX_DISABLE_ENCODER 392#ifndef SPEEX_DISABLE_ENCODER
392void speex_bits_insert_terminator(SpeexBits *bits) 393EXPORT void speex_bits_insert_terminator(SpeexBits *bits)
393{ 394{
394 if (bits->bitPtr) 395 if (bits->bitPtr)
395 speex_bits_pack(bits, 0, 1); 396 speex_bits_pack(bits, 0, 1);