summaryrefslogtreecommitdiff
path: root/apps/codecs/libcook/bitstream.c
diff options
context:
space:
mode:
authorMohamed Tarek <mt@rockbox.org>2009-05-12 20:50:35 +0000
committerMohamed Tarek <mt@rockbox.org>2009-05-12 20:50:35 +0000
commit49ba646d579a89d5ff0e4f3d5eea237eea22aafd (patch)
tree32aa872eb82b16c22f1915543c1512b116513209 /apps/codecs/libcook/bitstream.c
parent49fccaf2d925def5cc57fff4a09b98a8fe318cc8 (diff)
downloadrockbox-49ba646d579a89d5ff0e4f3d5eea237eea22aafd.tar.gz
rockbox-49ba646d579a89d5ff0e4f3d5eea237eea22aafd.zip
-Remove all dynamic allocations, hence remove cook_decode_close() which was basically
needed for freeing allocated memory. -Remove any ffmpeg-specific attributes (av_const,av_always_inline .. etc.). -Move some math functions to cook_fixpoint.h - libavutil/common.h is no longer needed. -Remove libavutil/mem.[c/h], libavutil/common.h and libavutil/internal.h. -Fix a warning in cookdata_fixpoint.h. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20922 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libcook/bitstream.c')
-rw-r--r--apps/codecs/libcook/bitstream.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/apps/codecs/libcook/bitstream.c b/apps/codecs/libcook/bitstream.c
index 3b0c0a7b55..4bc706ffb7 100644
--- a/apps/codecs/libcook/bitstream.c
+++ b/apps/codecs/libcook/bitstream.c
@@ -45,6 +45,8 @@ const uint8_t ff_log2_run[32]={
45 * @deprecated. Code which uses ff_realloc_static is broken/misdesigned 45 * @deprecated. Code which uses ff_realloc_static is broken/misdesigned
46 * and should correctly use static arrays 46 * and should correctly use static arrays
47 */ 47 */
48
49#if 0
48attribute_deprecated av_alloc_size(2) 50attribute_deprecated av_alloc_size(2)
49static void *ff_realloc_static(void *ptr, unsigned int size); 51static void *ff_realloc_static(void *ptr, unsigned int size);
50 52
@@ -61,6 +63,7 @@ void align_put_bits(PutBitContext *s)
61 put_bits(s,s->bit_left & 7,0); 63 put_bits(s,s->bit_left & 7,0);
62#endif 64#endif
63} 65}
66#endif
64 67
65void ff_put_string(PutBitContext * pbc, const char *s, int put_zero) 68void ff_put_string(PutBitContext * pbc, const char *s, int put_zero)
66{ 69{
@@ -123,15 +126,11 @@ static int alloc_table(VLC *vlc, int size, int use_static)
123 index = vlc->table_size; 126 index = vlc->table_size;
124 vlc->table_size += size; 127 vlc->table_size += size;
125 if (vlc->table_size > vlc->table_allocated) { 128 if (vlc->table_size > vlc->table_allocated) {
126 if(use_static>1) 129 if(use_static>1){
130 printf("init_vlc() used with too little memory : table_size > allocated_memory\n");
127 abort(); //cant do anything, init_vlc() is used with too little memory 131 abort(); //cant do anything, init_vlc() is used with too little memory
128 vlc->table_allocated += (1 << vlc->bits); 132 }
129 if(use_static) 133
130 vlc->table = ff_realloc_static(vlc->table,
131 sizeof(VLC_TYPE) * 2 * vlc->table_allocated);
132 else
133 vlc->table = av_realloc(vlc->table,
134 sizeof(VLC_TYPE) * 2 * vlc->table_allocated);
135 if (!vlc->table) 134 if (!vlc->table)
136 return -1; 135 return -1;
137 } 136 }
@@ -305,10 +304,13 @@ int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
305 codes, codes_wrap, codes_size, 304 codes, codes_wrap, codes_size,
306 symbols, symbols_wrap, symbols_size, 305 symbols, symbols_wrap, symbols_size,
307 0, 0, flags) < 0) { 306 0, 0, flags) < 0) {
308 av_freep(&vlc->table); 307 free(&vlc->table);
309 return -1; 308 return -1;
310 } 309 }
311 if((flags & INIT_VLC_USE_NEW_STATIC) && vlc->table_size != vlc->table_allocated) 310 /* Changed the following condition to be true if table_size > table_allocated. *
311 * This would be more sensible for static tables since we want warnings for *
312 * memory shortages only. */
313 if((flags & INIT_VLC_USE_NEW_STATIC) && vlc->table_size > vlc->table_allocated)
312 printf("needed %d had %d\n", vlc->table_size, vlc->table_allocated); 314 printf("needed %d had %d\n", vlc->table_size, vlc->table_allocated);
313 return 0; 315 return 0;
314} 316}
@@ -316,6 +318,6 @@ int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
316 318
317void free_vlc(VLC *vlc) 319void free_vlc(VLC *vlc)
318{ 320{
319 av_freep(&vlc->table); 321 free(&vlc->table);
320} 322}
321 323