vlc | branch: master | Rémi Denis-Courmont <[email protected]> | Tue Aug 19 22:16:42 2014 +0300| [e0e1f0fce33f18dd288151fb8a3ffa05e971d5c8] | committer: Rémi Denis-Courmont
adjust: stick to single precision The VLC object variables are stored in single precision anyway. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e0e1f0fce33f18dd288151fb8a3ffa05e971d5c8 --- modules/video_filter/adjust.c | 55 ++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/modules/video_filter/adjust.c b/modules/video_filter/adjust.c index eb28fe7..2963016 100644 --- a/modules/video_filter/adjust.c +++ b/modules/video_filter/adjust.c @@ -119,16 +119,16 @@ static const char *const ppsz_filter_options[] = { struct filter_sys_t { vlc_mutex_t lock; - double f_contrast; - double f_brightness; - float f_hue; - double f_saturation; - double f_gamma; - bool b_brightness_threshold; - int (* pf_process_sat_hue)( picture_t *, picture_t *, int, int, int, - int, int ); - int (* pf_process_sat_hue_clip)( picture_t *, picture_t *, int, int, - int, int, int ); + float f_contrast; + float f_brightness; + float f_hue; + float f_saturation; + float f_gamma; + bool b_brightness_threshold; + int (*pf_process_sat_hue)( picture_t *, picture_t *, int, int, int, + int, int ); + int (*pf_process_sat_hue_clip)( picture_t *, picture_t *, int, int, + int, int, int ); }; /***************************************************************************** @@ -232,13 +232,6 @@ static picture_t *FilterPlanar( filter_t *p_filter, picture_t *p_pic ) uint8_t *p_in, *p_in_end, *p_line_end; uint8_t *p_out; - bool b_thres; - double f_hue; - double f_gamma; - int32_t i_cont, i_lum; - int i_sat, i_sin, i_cos, i_x, i_y; - int i; - filter_sys_t *p_sys = p_filter->p_sys; if( !p_pic ) return NULL; @@ -252,12 +245,12 @@ static picture_t *FilterPlanar( filter_t *p_filter, picture_t *p_pic ) /* Get variables */ vlc_mutex_lock( &p_sys->lock ); - i_cont = (int)( p_sys->f_contrast * 255 ); - i_lum = (int)( (p_sys->f_brightness - 1.0)*255 ); - f_hue = p_sys->f_hue * (float)(M_PI / 180.); - i_sat = (int)( p_sys->f_saturation * 256 ); - f_gamma = 1.0 / p_sys->f_gamma; - b_thres = p_sys->b_brightness_threshold; + int32_t i_cont = lroundf( p_sys->f_contrast * 255.f ); + int32_t i_lum = lroundf( (p_sys->f_brightness - 1.f) * 255.f ); + float f_hue = p_sys->f_hue * (float)(M_PI / 180.); + int i_sat = (int)( p_sys->f_saturation * 256.f ); + float f_gamma = 1.f / p_sys->f_gamma; + bool b_thres = p_sys->b_brightness_threshold; vlc_mutex_unlock( &p_sys->lock ); /* @@ -271,13 +264,13 @@ static picture_t *FilterPlanar( filter_t *p_filter, picture_t *p_pic ) i_lum += 128 - i_cont / 2; /* Fill the gamma lookup table */ - for( i = 0 ; i < 256 ; i++ ) + for( unsigned i = 0 ; i < 256 ; i++ ) { - pi_gamma[ i ] = clip_uint8_vlc( pow(i / 255.0, f_gamma) * 255.0); + pi_gamma[ i ] = clip_uint8_vlc( powf(i / 255.f, f_gamma) * 255.f); } /* Fill the luma lookup table */ - for( i = 0 ; i < 256 ; i++ ) + for( unsigned i = 0 ; i < 256 ; i++ ) { pi_luma[ i ] = pi_gamma[clip_uint8_vlc( i_lum + i_cont * i / 256)]; } @@ -288,7 +281,7 @@ static picture_t *FilterPlanar( filter_t *p_filter, picture_t *p_pic ) * We get luma as threshold value: the higher it is, the darker is * the image. Should I reverse this? */ - for( i = 0 ; i < 256 ; i++ ) + for( int i = 0 ; i < 256 ; i++ ) { pi_luma[ i ] = (i < i_lum) ? 0 : 255; } @@ -339,11 +332,11 @@ static picture_t *FilterPlanar( filter_t *p_filter, picture_t *p_pic ) * Do the U and V planes */ - i_sin = sin(f_hue) * 256; - i_cos = cos(f_hue) * 256; + int i_sin = sinf(f_hue) * 256.f; + int i_cos = cosf(f_hue) * 256.f; - i_x = ( cos(f_hue) + sin(f_hue) ) * 32768; - i_y = ( cos(f_hue) - sin(f_hue) ) * 32768; + int i_x = ( cosf(f_hue) + sinf(f_hue) ) * 32768.f; + int i_y = ( cosf(f_hue) - sinf(f_hue) ) * 32768.f; if ( i_sat > 256 ) { _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
