From 3383a53e7d0abb9639c3ea3481f0eda9dca61a26 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 27 Nov 2011 14:04:16 +0000 Subject: lavu: replace int/float punning functions The existing functions defined in intfloat_readwrite.[ch] are both slow and incorrect (infinities are not handled). This introduces a new header with fast, inline conversion functions using direct union punning assuming an IEEE-754 system, an assumption already made throughout the code. The one use of Intel/Motorola extended 80-bit format is replaced by simpler code sufficient under the present constraints (positive normal values). The old functions are marked deprecated and retained for compatibility. Signed-off-by: Mans Rullgard --- libavformat/aiffdec.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'libavformat/aiffdec.c') diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c index f54a7ffafe..0e69d02c8c 100644 --- a/libavformat/aiffdec.c +++ b/libavformat/aiffdec.c @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavutil/intfloat_readwrite.h" +#include "libavutil/mathematics.h" #include "libavutil/dict.h" #include "avformat.h" #include "internal.h" @@ -88,7 +88,8 @@ static void get_meta(AVFormatContext *s, const char *key, int size) static unsigned int get_aiff_header(AVIOContext *pb, AVCodecContext *codec, int size, unsigned version) { - AVExtFloat ext; + int exp; + uint64_t val; double sample_rate; unsigned int num_frames; @@ -99,8 +100,9 @@ static unsigned int get_aiff_header(AVIOContext *pb, AVCodecContext *codec, num_frames = avio_rb32(pb); codec->bits_per_coded_sample = avio_rb16(pb); - avio_read(pb, (uint8_t*)&ext, sizeof(ext));/* Sample rate is in */ - sample_rate = av_ext2dbl(ext); /* 80 bits BE IEEE extended float */ + exp = avio_rb16(pb); + val = avio_rb64(pb); + sample_rate = ldexp(val, exp - 16383 - 63); codec->sample_rate = sample_rate; size -= 18; -- cgit v1.2.3