[vlc-commits] avcodec: avoid double upconversion

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 22:38:17 2014 +0300| [600e3556efd41d366fbd1f89ef4c455ed4c9ba91] | committer: Rémi Denis-Courmont

avcodec: avoid double upconversion

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

 modules/codec/avcodec/encoder.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index 8f2b898..3704e0f 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -32,6 +32,8 @@
 # include "config.h"
 #endif
 
+#include <math.h>
+
 #include <vlc_common.h>
 #include <vlc_aout.h>
 #include <vlc_sout.h>
@@ -379,10 +381,10 @@ int OpenEncoder( vlc_object_t *p_this )
     f_val = var_GetFloat( p_enc, ENC_CFG_PREFIX "qscale" );
 
     p_sys->i_quality = 0;
-    if( f_val < 0.01 || f_val > 255.0 )
-        f_val = 0;
+    if( f_val < .01f || f_val > 255.f )
+        f_val = 0.f;
     else
-        p_sys->i_quality = (int)(FF_QP2LAMBDA * f_val + 0.5);
+        p_sys->i_quality = lroundf(FF_QP2LAMBDA * f_val);
 
     psz_val = var_GetString( p_enc, ENC_CFG_PREFIX "hq" );
     p_sys->i_hq = FF_MB_DECISION_RD;
@@ -536,7 +538,7 @@ int OpenEncoder( vlc_object_t *p_this )
         }
 
 
-        if ( p_sys->f_i_quant_factor != 0.0 )
+        if ( p_sys->f_i_quant_factor != 0.f )
             p_context->i_quant_factor = p_sys->f_i_quant_factor;
 
         p_context->noise_reduction = p_sys->i_noise_reduction;



More information about the vlc-commits mailing list