Skip to content

Commit

Permalink
avformat/movenc: avoid floats in width/height/aspect ratio computations
Browse files Browse the repository at this point in the history
This avoids the possibility for rounding/precision differences between platforms

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
  • Loading branch information
michaelni committed May 29, 2015
1 parent 3331213 commit 14bc570
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions libavformat/movenc.c
Expand Up @@ -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 {
Expand Down

0 comments on commit 14bc570

Please sign in to comment.