diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-05-29 12:36:55 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-05-29 12:46:58 +0200 |
commit | 14bc5704422415fddf1db5f5ae8e105183e0b582 (patch) | |
tree | 513da1c898474afa5add8c0a705b538dbd8c10f5 /libavformat/movenc.c | |
parent | 3331213e2ac5a0fe5c574e9cd3da44df5e0d1d18 (diff) | |
download | ffmpeg-14bc5704422415fddf1db5f5ae8e105183e0b582.tar.gz |
avformat/movenc: avoid floats in width/height/aspect ratio computations
This avoids the possibility for rounding/precision differences between platforms
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/movenc.c')
-rw-r--r-- | libavformat/movenc.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 6a4e16a727..8b0a57995e 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -2368,10 +2368,12 @@ static int mov_write_tkhd_tag(AVIOContext *pb, MOVMuxContext *mov, avio_wb32(pb, track->enc->width << 16); avio_wb32(pb, track->height << 16); } else { - double sample_aspect_ratio = av_q2d(st->sample_aspect_ratio); - if (!sample_aspect_ratio || track->height != track->enc->height) - sample_aspect_ratio = 1; - avio_wb32(pb, sample_aspect_ratio * track->enc->width * 0x10000); + int64_t track_width_1616 = av_rescale(st->sample_aspect_ratio.num, + track->enc->width * 0x10000LL, + st->sample_aspect_ratio.den); + if (!track_width_1616 || track->height != track->enc->height) + track_width_1616 = track->enc->width * 0x10000; + avio_wb32(pb, track_width_1616); avio_wb32(pb, track->height * 0x10000); } } else { |