Commit 0e623d01 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

subtitle demux: avoid upconversion to double precision

parent dce22e69
...@@ -57,6 +57,7 @@ libmjpeg_plugin_la_SOURCES = demux/mjpeg.c demux/mxpeg_helper.h ...@@ -57,6 +57,7 @@ libmjpeg_plugin_la_SOURCES = demux/mjpeg.c demux/mxpeg_helper.h
demux_LTLIBRARIES += libmjpeg_plugin.la demux_LTLIBRARIES += libmjpeg_plugin.la
libsubtitle_plugin_la_SOURCES = demux/subtitle.c libsubtitle_plugin_la_SOURCES = demux/subtitle.c
libsubtitle_plugin_la_LIBADD = $(LIBM)
demux_LTLIBRARIES += libsubtitle_plugin.la demux_LTLIBRARIES += libsubtitle_plugin.la
libty_plugin_la_SOURCES = demux/ty.c codec/cc.h libty_plugin_la_SOURCES = demux/ty.c codec/cc.h
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <vlc_memory.h> #include <vlc_memory.h>
#include <ctype.h> #include <ctype.h>
#include <math.h>
#include <vlc_demux.h> #include <vlc_demux.h>
#include <vlc_charset.h> #include <vlc_charset.h>
...@@ -261,17 +262,17 @@ static int Open ( vlc_object_t *p_this ) ...@@ -261,17 +262,17 @@ static int Open ( vlc_object_t *p_this )
/* Get the FPS */ /* Get the FPS */
f_fps = var_CreateGetFloat( p_demux, "sub-original-fps" ); /* FIXME */ f_fps = var_CreateGetFloat( p_demux, "sub-original-fps" ); /* FIXME */
if( f_fps >= 1.0 ) if( f_fps >= 1.f )
p_sys->i_microsecperframe = (int64_t)( (float)1000000 / f_fps ); p_sys->i_microsecperframe = llroundf( 1000000.f / f_fps );
msg_Dbg( p_demux, "Movie fps: %f", f_fps ); msg_Dbg( p_demux, "Movie fps: %f", (double) f_fps );
/* Check for override of the fps */ /* Check for override of the fps */
f_fps = var_CreateGetFloat( p_demux, "sub-fps" ); f_fps = var_CreateGetFloat( p_demux, "sub-fps" );
if( f_fps >= 1.0 ) if( f_fps >= 1.f )
{ {
p_sys->i_microsecperframe = (int64_t)( (float)1000000 / f_fps ); p_sys->i_microsecperframe = llroundf( 1000000.f / f_fps );
msg_Dbg( p_demux, "Override subtitle fps %f", f_fps ); msg_Dbg( p_demux, "Override subtitle fps %f", (double) f_fps );
} }
/* Get or probe the type */ /* Get or probe the type */
...@@ -872,15 +873,14 @@ static int ParseMicroDvd( demux_t *p_demux, subtitle_t *p_subtitle, ...@@ -872,15 +873,14 @@ static int ParseMicroDvd( demux_t *p_demux, subtitle_t *p_subtitle,
if( sscanf( s, "{%d}{}%[^\r\n]", &i_start, psz_text ) == 2 || if( sscanf( s, "{%d}{}%[^\r\n]", &i_start, psz_text ) == 2 ||
sscanf( s, "{%d}{%d}%[^\r\n]", &i_start, &i_stop, psz_text ) == 3) sscanf( s, "{%d}{%d}%[^\r\n]", &i_start, &i_stop, psz_text ) == 3)
{ {
float f_fps;
if( i_start != 1 || i_stop != 1 ) if( i_start != 1 || i_stop != 1 )
break; break;
/* We found a possible setting of the framerate "{1}{1}23.976" */ /* We found a possible setting of the framerate "{1}{1}23.976" */
/* Check if it's usable, and if the sub-fps is not set */ /* Check if it's usable, and if the sub-fps is not set */
f_fps = us_strtod( psz_text, NULL ); float f_fps = us_strtof( psz_text, NULL );
if( f_fps > 0.0 && var_GetFloat( p_demux, "sub-fps" ) <= 0.0 ) if( f_fps > 0.f && var_GetFloat( p_demux, "sub-fps" ) <= 0.f )
p_sys->i_microsecperframe = (int64_t)((float)1000000 / f_fps); p_sys->i_microsecperframe = llroundf(1000000.f / f_fps);
} }
free( psz_text ); free( psz_text );
} }
...@@ -1573,7 +1573,6 @@ static int ParseMPSub( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx ) ...@@ -1573,7 +1573,6 @@ static int ParseMPSub( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx )
for( ;; ) for( ;; )
{ {
float f1, f2;
char p_dummy; char p_dummy;
char *psz_temp; char *psz_temp;
...@@ -1601,26 +1600,27 @@ static int ParseMPSub( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx ) ...@@ -1601,26 +1600,27 @@ static int ParseMPSub( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx )
if( sscanf( s, "FORMAT=%[^\r\n]", psz_temp ) ) if( sscanf( s, "FORMAT=%[^\r\n]", psz_temp ) )
{ {
float f_fps; float f_fps = us_strtof( psz_temp, NULL );
f_fps = us_strtod( psz_temp, NULL );
if( f_fps > 0.0 && var_GetFloat( p_demux, "sub-fps" ) <= 0.0 ) if( f_fps > 0.f && var_GetFloat( p_demux, "sub-fps" ) <= 0.f )
var_SetFloat( p_demux, "sub-fps", f_fps ); var_SetFloat( p_demux, "sub-fps", f_fps );
p_sys->mpsub.f_factor = 1.0; p_sys->mpsub.f_factor = 1.f;
free( psz_temp ); free( psz_temp );
break; break;
} }
free( psz_temp ); free( psz_temp );
} }
/* Data Lines */ /* Data Lines */
f1 = us_strtod( s, &psz_temp ); float f1 = us_strtof( s, &psz_temp );
if( *psz_temp ) if( *psz_temp )
{ {
f2 = us_strtod( psz_temp, NULL ); float f2 = us_strtof( psz_temp, NULL );
p_sys->mpsub.f_total += f1 * p_sys->mpsub.f_factor; p_sys->mpsub.f_total += f1 * p_sys->mpsub.f_factor;
p_subtitle->i_start = (int64_t)(10000.0 * p_sys->mpsub.f_total); p_subtitle->i_start = llroundf(10000.f * p_sys->mpsub.f_total);
p_sys->mpsub.f_total += f2 * p_sys->mpsub.f_factor; p_sys->mpsub.f_total += f2 * p_sys->mpsub.f_factor;
p_subtitle->i_stop = (int64_t)(10000.0 * p_sys->mpsub.f_total); p_subtitle->i_stop = llroundf(10000.f * p_sys->mpsub.f_total);
break; break;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment