diff options
Diffstat (limited to 'apps/codecs/libwmapro/bitstream.c')
-rw-r--r-- | apps/codecs/libwmapro/bitstream.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/apps/codecs/libwmapro/bitstream.c b/apps/codecs/libwmapro/bitstream.c index deb1d631e2..4ae9727ac0 100644 --- a/apps/codecs/libwmapro/bitstream.c +++ b/apps/codecs/libwmapro/bitstream.c | |||
@@ -32,6 +32,8 @@ | |||
32 | #include "get_bits.h" | 32 | #include "get_bits.h" |
33 | #include "put_bits.h" | 33 | #include "put_bits.h" |
34 | 34 | ||
35 | #define av_log(...) | ||
36 | |||
35 | const uint8_t ff_log2_run[32]={ | 37 | const uint8_t ff_log2_run[32]={ |
36 | 0, 0, 0, 0, 1, 1, 1, 1, | 38 | 0, 0, 0, 0, 1, 1, 1, 1, |
37 | 2, 2, 2, 2, 3, 3, 3, 3, | 39 | 2, 2, 2, 2, 3, 3, 3, 3, |
@@ -108,10 +110,10 @@ static int alloc_table(VLC *vlc, int size, int use_static) | |||
108 | vlc->table_size += size; | 110 | vlc->table_size += size; |
109 | if (vlc->table_size > vlc->table_allocated) { | 111 | if (vlc->table_size > vlc->table_allocated) { |
110 | if(use_static) | 112 | if(use_static) |
111 | abort(); //cant do anything, init_vlc() is used with too little memory | 113 | return -1; //cant do anything, init_vlc() is used with too little memory |
112 | vlc->table_allocated += (1 << vlc->bits); | 114 | vlc->table_allocated += (1 << vlc->bits); |
113 | vlc->table = av_realloc(vlc->table, | 115 | //vlc->table = av_realloc(vlc->table, |
114 | sizeof(VLC_TYPE) * 2 * vlc->table_allocated); | 116 | // sizeof(VLC_TYPE) * 2 * vlc->table_allocated); |
115 | if (!vlc->table) | 117 | if (!vlc->table) |
116 | return -1; | 118 | return -1; |
117 | } | 119 | } |
@@ -218,14 +220,14 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, | |||
218 | if (n <= 0) | 220 | if (n <= 0) |
219 | break; | 221 | break; |
220 | code = codes[k].code; | 222 | code = codes[k].code; |
221 | if (code >> (32 - table_nb_bits) != code_prefix) | 223 | if (code >> (32 - table_nb_bits) != (unsigned)code_prefix) |
222 | break; | 224 | break; |
223 | codes[k].bits = n; | 225 | codes[k].bits = n; |
224 | codes[k].code = code << table_nb_bits; | 226 | codes[k].code = code << table_nb_bits; |
225 | subtable_bits = FFMAX(subtable_bits, n); | 227 | subtable_bits = FFMAX(subtable_bits, n); |
226 | } | 228 | } |
227 | subtable_bits = FFMIN(subtable_bits, table_nb_bits); | 229 | subtable_bits = FFMIN(subtable_bits, table_nb_bits); |
228 | j = (flags & INIT_VLC_LE) ? bitswap_32(code_prefix) >> (32 - table_nb_bits) : code_prefix; | 230 | j = (flags & INIT_VLC_LE) ? bitswap_32(code_prefix) >> (32 - table_nb_bits) : (unsigned)code_prefix; |
229 | table[j][1] = -subtable_bits; | 231 | table[j][1] = -subtable_bits; |
230 | #ifdef DEBUG_VLC | 232 | #ifdef DEBUG_VLC |
231 | av_log(NULL,AV_LOG_DEBUG,"%4x: n=%d (subtable)\n", | 233 | av_log(NULL,AV_LOG_DEBUG,"%4x: n=%d (subtable)\n", |
@@ -284,7 +286,7 @@ int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, | |||
284 | if(vlc->table_size && vlc->table_size == vlc->table_allocated){ | 286 | if(vlc->table_size && vlc->table_size == vlc->table_allocated){ |
285 | return 0; | 287 | return 0; |
286 | }else if(vlc->table_size){ | 288 | }else if(vlc->table_size){ |
287 | abort(); // fatal error, we are called on a partially initialized table | 289 | return -1; // fatal error, we are called on a partially initialized table |
288 | } | 290 | } |
289 | }else { | 291 | }else { |
290 | vlc->table = NULL; | 292 | vlc->table = NULL; |
@@ -321,17 +323,11 @@ int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, | |||
321 | nb_codes = j; | 323 | nb_codes = j; |
322 | 324 | ||
323 | if (build_table(vlc, nb_bits, nb_codes, buf, flags) < 0) { | 325 | if (build_table(vlc, nb_bits, nb_codes, buf, flags) < 0) { |
324 | av_freep(&vlc->table); | 326 | //av_freep(&vlc->table); |
325 | return -1; | 327 | return -1; |
326 | } | 328 | } |
327 | if((flags & INIT_VLC_USE_NEW_STATIC) && vlc->table_size != vlc->table_allocated) | 329 | //if((flags & INIT_VLC_USE_NEW_STATIC) && vlc->table_size != vlc->table_allocated) |
328 | av_log(NULL, AV_LOG_ERROR, "needed %d had %d\n", vlc->table_size, vlc->table_allocated); | 330 | // av_log(NULL, AV_LOG_ERROR, "needed %d had %d\n", vlc->table_size, vlc->table_allocated); |
329 | return 0; | 331 | return 0; |
330 | } | 332 | } |
331 | 333 | ||
332 | |||
333 | void free_vlc(VLC *vlc) | ||
334 | { | ||
335 | av_freep(&vlc->table); | ||
336 | } | ||
337 | |||