[FFmpeg-devel] [PATCH]Force gif aspect ratio multiplication to 64bit

Carl Eugen Hoyos cehoyos at ag.or.at
Sat Apr 5 01:07:28 CEST 2014


On Thursday 03 April 2014 12:36:41 pm Michael Niedermayer wrote:
> > -        aspect = sar.num * 64 / sar.den - 15;
> >
> > +        aspect = sar.num * 64ULL / sar.den - 15;
> >          if (aspect < 0 || aspect > 255)
>
> thats not sufficient, aspect is just an int and this might not fit
> in it also the <0 check needs int64 not uint64

Is attached better?

Thank you, Carl Eugen
-------------- next part --------------
diff --git a/libavformat/gif.c b/libavformat/gif.c
index 68320c6..5182137 100644
--- a/libavformat/gif.c
+++ b/libavformat/gif.c
@@ -33,10 +33,11 @@ static int gif_image_write_header(AVFormatContext *s, int width, int height,
 {
     AVIOContext *pb = s->pb;
     AVRational sar = s->streams[0]->codec->sample_aspect_ratio;
-    int i, aspect = 0;
+    int i;
+    int64_t aspect = 0;
 
     if (sar.num > 0 && sar.den > 0) {
-        aspect = sar.num * 64 / sar.den - 15;
+        aspect = sar.num * 64LL / sar.den - 15;
         if (aspect < 0 || aspect > 255)
             aspect = 0;
     }


More information about the ffmpeg-devel mailing list