summaryrefslogtreecommitdiff
path: root/libavcodec/bitstream.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-07-13 02:53:26 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-07-29 16:48:41 +0200
commita9903f7ec123582d3adc3939854ab98d12fb10df (patch)
tree2a5be5dee4b405ba6097aec2bd62d3998f67cd3c /libavcodec/bitstream.c
parent2786ac777d2c50320e3b939a9bfeaf9fb5ce53a8 (diff)
Revert "bitstream: make vlc init of static tables thread safe."
This reverts commit 4b6869d6e0120c92253d525921f0e04361888e10. Conflicts: libavcodec/bitstream.c This code can cause assertion failures on artificial OOM situations It will be replaced by a solution that doesnt have this issue in the following commits. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/bitstream.c')
-rw-r--r--libavcodec/bitstream.c23
1 files changed, 6 insertions, 17 deletions
diff --git a/libavcodec/bitstream.c b/libavcodec/bitstream.c
index bbd9491ca0..3c4d176f30 100644
--- a/libavcodec/bitstream.c
+++ b/libavcodec/bitstream.c
@@ -272,24 +272,11 @@ int ff_init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
vlc->bits = nb_bits;
if (flags & INIT_VLC_USE_NEW_STATIC) {
- VLC dyn_vlc = *vlc;
-
- if (vlc->table_size)
+ if (vlc->table_size && vlc->table_size == vlc->table_allocated) {
return 0;
-
- ret = ff_init_vlc_sparse(&dyn_vlc, nb_bits, nb_codes,
- bits, bits_wrap, bits_size,
- codes, codes_wrap, codes_size,
- symbols, symbols_wrap, symbols_size,
- flags & ~INIT_VLC_USE_NEW_STATIC);
- av_assert0(ret >= 0);
- av_assert0(dyn_vlc.table_size <= vlc->table_allocated);
- if (dyn_vlc.table_size < vlc->table_allocated)
- av_log(NULL, AV_LOG_ERROR, "needed %d had %d\n", dyn_vlc.table_size, vlc->table_allocated);
- memcpy(vlc->table, dyn_vlc.table, dyn_vlc.table_size * sizeof(*vlc->table));
- vlc->table_size = dyn_vlc.table_size;
- ff_free_vlc(&dyn_vlc);
- return 0;
+ } else if(vlc->table_size) {
+ abort(); // fatal error, we are called on a partially initialized table
+ }
} else {
vlc->table = NULL;
vlc->table_allocated = 0;
@@ -343,6 +330,8 @@ int ff_init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
av_freep(&vlc->table);
return ret;
}
+ if((flags & INIT_VLC_USE_NEW_STATIC) && vlc->table_size != vlc->table_allocated)
+ av_log(NULL, AV_LOG_ERROR, "needed %d had %d\n", vlc->table_size, vlc->table_allocated);
return 0;
}