[vlc-commits] transcode: avoid conversion to double

Rémi Denis-Courmont git at videolan.org
Wed Aug 13 22:23:08 CEST 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Aug 13 23:00:33 2014 +0300| [1ba32fb7eb95c0040adc62e823411f947a2386c7] | committer: Rémi Denis-Courmont

transcode: avoid conversion to double

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1ba32fb7eb95c0040adc62e823411f947a2386c7
---

 modules/stream_out/Modules.am        |    1 +
 modules/stream_out/transcode/video.c |   15 ++++++++-------
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/modules/stream_out/Modules.am b/modules/stream_out/Modules.am
index b581152..d307c34 100644
--- a/modules/stream_out/Modules.am
+++ b/modules/stream_out/Modules.am
@@ -20,6 +20,7 @@ libstream_out_transcode_plugin_la_SOURCES = \
 	transcode/transcode.c transcode/transcode.h \
 	transcode/osd.c transcode/spu.c transcode/audio.c transcode/video.c
 libstream_out_transcode_plugin_la_CFLAGS = $(AM_CFLAGS)
+libstream_out_transcode_plugin_la_LIBADD = $(LIBM)
 
 
 stream_out_LTLIBRARIES += \
diff --git a/modules/stream_out/transcode/video.c b/modules/stream_out/transcode/video.c
index 97a568f..baad2b6 100644
--- a/modules/stream_out/transcode/video.c
+++ b/modules/stream_out/transcode/video.c
@@ -30,6 +30,7 @@
 
 #include "transcode.h"
 
+#include <math.h>
 #include <vlc_meta.h>
 #include <vlc_spu.h>
 #include <vlc_modules.h>
@@ -398,11 +399,11 @@ static void transcode_video_encoder_init( sout_stream_t *p_stream,
                      p_fmt_out->video.i_sar_den /
                      p_fmt_out->video.i_height;
 
-    msg_Dbg( p_stream, "decoder aspect is %f:1", f_aspect );
+    msg_Dbg( p_stream, "decoder aspect is %f:1", (double) f_aspect );
 
     /* Change f_aspect from source frame to source pixel */
     f_aspect = f_aspect * i_src_visible_height / i_src_visible_width;
-    msg_Dbg( p_stream, "source pixel aspect is %f:1", f_aspect );
+    msg_Dbg( p_stream, "source pixel aspect is %f:1", (double) f_aspect );
 
     /* Calculate scaling factor for specified parameters */
     if( id->p_encoder->fmt_out.video.i_visible_width <= 0 &&
@@ -463,17 +464,17 @@ static void transcode_video_encoder_init( sout_stream_t *p_stream,
 
      /* Change aspect ratio from source pixel to scaled pixel */
      f_aspect = f_aspect * f_scale_height / f_scale_width;
-     msg_Dbg( p_stream, "scaled pixel aspect is %f:1", f_aspect );
+     msg_Dbg( p_stream, "scaled pixel aspect is %f:1", (double) f_aspect );
 
      /* f_scale_width and f_scale_height are now final */
      /* Calculate width, height from scaling
       * Make sure its multiple of 2
       */
      /* width/height of output stream */
-     int i_dst_visible_width =  2 * (int)(f_scale_width*i_src_visible_width/2+0.5);
-     int i_dst_visible_height = 2 * (int)(f_scale_height*i_src_visible_height/2+0.5);
-     int i_dst_width =  2 * (int)(f_scale_width*p_fmt_out->video.i_width/2+0.5);
-     int i_dst_height = 2 * (int)(f_scale_height*p_fmt_out->video.i_height/2+0.5);
+     int i_dst_visible_width =  2 * lroundf(f_scale_width*i_src_visible_width/2);
+     int i_dst_visible_height = 2 * lroundf(f_scale_height*i_src_visible_height/2);
+     int i_dst_width =  2 * lroundf(f_scale_width*p_fmt_out->video.i_width/2);
+     int i_dst_height = 2 * lroundf(f_scale_height*p_fmt_out->video.i_height/2);
 
      /* Change aspect ratio from scaled pixel to output frame */
      f_aspect = f_aspect * i_dst_visible_width / i_dst_visible_height;



More information about the vlc-commits mailing list