lavc/libaribb24: use integer math to calculate font scaling
authorJan Ekström <jeebjp@gmail.com>
Mon, 11 Feb 2019 01:01:51 +0000 (03:01 +0200)
committerJan Ekström <jeebjp@gmail.com>
Tue, 12 Feb 2019 18:16:40 +0000 (20:16 +0200)
libavcodec/libaribb24.c

index 28f20ca..3a59938 100644 (file)
@@ -249,11 +249,11 @@ static int libaribb24_handle_regions(AVCodecContext *avctx, AVSubtitle *sub)
         // font size
         if (region->i_fontwidth  != profile_font_size ||
             region->i_fontheight != profile_font_size) {
-            av_bprintf(&buf, "{\\fscx%d\\fscy%d}",
-                       (int)round(((double)region->i_fontwidth /
-                                   (double)profile_font_size) * 100),
-                       (int)round(((double)region->i_fontheight /
-                                   (double)profile_font_size) * 100));
+            av_bprintf(&buf, "{\\fscx%"PRId64"\\fscy%"PRId64"}",
+                       av_rescale(region->i_fontwidth, 100,
+                                  profile_font_size),
+                       av_rescale(region->i_fontheight, 100,
+                                  profile_font_size));
         }
 
         // TODO: positioning