summaryrefslogtreecommitdiff
path: root/libavcodec/vorbisdec.c
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2013-05-19 19:06:54 +0200
committerLuca Barbato <lu_zero@gentoo.org>2013-05-19 22:56:37 +0200
commitdb347280eb3746d7b70888db97f1efe5f06f5624 (patch)
treee0e7755b03c1916d76c192a1baeb4596a70fa81f /libavcodec/vorbisdec.c
parentddf1b4a2f8a680126eb611428e4f47e6e5b8c6c0 (diff)
vorbis: fallback to normal division instead of crashing
The use of ff_inverse speeds up slightly arches + compilers that do not provide a division faster than the whole machinery, such as ppc32 + gcc4.7, but has operational limits. Drop the always-enable assert and provide a fallback.
Diffstat (limited to 'libavcodec/vorbisdec.c')
-rw-r--r--libavcodec/vorbisdec.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c
index caf36eb3f2..80051b9493 100644
--- a/libavcodec/vorbisdec.c
+++ b/libavcodec/vorbisdec.c
@@ -42,9 +42,6 @@
#define V_MAX_VLCS (1 << 16)
#define V_MAX_PARTITIONS (1 << 20)
-#undef NDEBUG
-#include <assert.h>
-
typedef struct {
uint8_t dimensions;
uint8_t lookup_type;
@@ -1319,14 +1316,22 @@ static av_always_inline int setup_classifs(vorbis_context *vc,
av_dlog(NULL, "Classword: %u\n", temp);
- assert(vr->classifications > 1 && temp <= 65536); //needed for inverse[]
+ if (temp <= 65536) {
+ for (i = partition_count + c_p_c - 1; i >= partition_count; i--) {
+ temp2 = (((uint64_t)temp) * inverse_class) >> 32;
- for (i = partition_count + c_p_c - 1; i >= partition_count; i--) {
- temp2 = (((uint64_t)temp) * inverse_class) >> 32;
+ if (i < vr->ptns_to_read)
+ vr->classifs[p + i] = temp - temp2 * vr->classifications;
+ temp = temp2;
+ }
+ } else {
+ for (i = partition_count + c_p_c - 1; i >= partition_count; i--) {
+ temp2 = temp / vr->classifications;
- if (i < vr->ptns_to_read)
- vr->classifs[p + i] = temp - temp2 * vr->classifications;
- temp = temp2;
+ if (i < vr->ptns_to_read)
+ vr->classifs[p + i] = temp - temp2 * vr->classifications;
+ temp = temp2;
+ }
}
}
p += vr->ptns_to_read;