[FFmpeg-devel] [PATCH] avformat/aiffdec: avoid double and ldexp()
Michael Niedermayer
michaelni at gmx.at
Sun Jun 7 23:50:13 CEST 2015
There is no support for non integer sample rates, using doubles/floats currently could
only lead to rounding differences between platforms
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
libavformat/aiffdec.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c
index ff04c2b..729e45b 100644
--- a/libavformat/aiffdec.c
+++ b/libavformat/aiffdec.c
@@ -99,7 +99,7 @@ static unsigned int get_aiff_header(AVFormatContext *s, int size,
AIFFInputContext *aiff = s->priv_data;
int exp;
uint64_t val;
- double sample_rate;
+ int sample_rate;
unsigned int num_frames;
if (size & 1)
@@ -109,9 +109,12 @@ static unsigned int get_aiff_header(AVFormatContext *s, int size,
num_frames = avio_rb32(pb);
codec->bits_per_coded_sample = avio_rb16(pb);
- exp = avio_rb16(pb);
+ exp = avio_rb16(pb) - 16383 - 63;
val = avio_rb64(pb);
- sample_rate = ldexp(val, exp - 16383 - 63);
+ if (exp >= 0)
+ sample_rate = val << exp;
+ else
+ sample_rate = (val + (1<<(-exp/2))) >> -exp;
codec->sample_rate = sample_rate;
size -= 18;
--
1.7.9.5
More information about the ffmpeg-devel
mailing list