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/aiffenc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'libavformat/aiffenc.c') diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c index df43688d40..2916d26fc6 100644 --- a/libavformat/aiffenc.c +++ b/libavformat/aiffenc.c @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavutil/intfloat_readwrite.h" +#include "libavutil/intfloat.h" #include "avformat.h" #include "internal.h" #include "aiff.h" @@ -36,7 +36,7 @@ static int aiff_write_header(AVFormatContext *s) AIFFOutputContext *aiff = s->priv_data; AVIOContext *pb = s->pb; AVCodecContext *enc = s->streams[0]->codec; - AVExtFloat sample_rate; + uint64_t sample_rate; int aifc = 0; /* First verify if format is ok */ @@ -82,8 +82,9 @@ static int aiff_write_header(AVFormatContext *s) avio_wb16(pb, enc->bits_per_coded_sample); /* Sample size */ - sample_rate = av_dbl2ext((double)enc->sample_rate); - avio_write(pb, (uint8_t*)&sample_rate, sizeof(sample_rate)); + sample_rate = av_double2int(enc->sample_rate); + avio_wb16(pb, (sample_rate >> 52) + (16383 - 1023)); + avio_wb64(pb, UINT64_C(1) << 63 | sample_rate << 11); if (aifc) { avio_wl32(pb, enc->codec_tag); -- cgit v1.2.3