diff options
Diffstat (limited to 'apps/codecs/libcook/bitstream.c')
-rw-r--r-- | apps/codecs/libcook/bitstream.c | 24 |
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 | ||
48 | attribute_deprecated av_alloc_size(2) | 50 | attribute_deprecated av_alloc_size(2) |
49 | static void *ff_realloc_static(void *ptr, unsigned int size); | 51 | static 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 | ||
65 | void ff_put_string(PutBitContext * pbc, const char *s, int put_zero) | 68 | void 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 | ||
317 | void free_vlc(VLC *vlc) | 319 | void free_vlc(VLC *vlc) |
318 | { | 320 | { |
319 | av_freep(&vlc->table); | 321 | free(&vlc->table); |
320 | } | 322 | } |
321 | 323 | ||