summaryrefslogtreecommitdiff
path: root/libavformat/aiffenc.c
diff options
context:
space:
mode:
authorMans Rullgard <mans@mansr.com>2011-11-27 14:04:16 +0000
committerMans Rullgard <mans@mansr.com>2011-12-11 18:47:19 +0000
commit3383a53e7d0abb9639c3ea3481f0eda9dca61a26 (patch)
treed53f0c38d95d4256b727dc4f4c5add488aabe501 /libavformat/aiffenc.c
parent5b3265a7181889b53ff8217c1bdccdf966c86955 (diff)
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 <mans@mansr.com>
Diffstat (limited to 'libavformat/aiffenc.c')
-rw-r--r--libavformat/aiffenc.c9
1 files changed, 5 insertions, 4 deletions
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);