[vlc-commits] modules: transform vlc_tick_t value from seconds with vlc_tick_from_sec
Steve Lhomme
git at videolan.org
Wed Sep 19 13:23:48 CEST 2018
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Thu May 31 15:20:52 2018 +0200| [ca5fc95f6366d4c079ec574411934ac52ed8683e] | committer: Steve Lhomme
modules: transform vlc_tick_t value from seconds with vlc_tick_from_sec
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ca5fc95f6366d4c079ec574411934ac52ed8683e
---
modules/demux/subtitle.c | 52 +++++++++++++++----------------------------
modules/demux/vobsub.c | 10 ++-------
modules/demux/xiph_metadata.c | 3 +--
3 files changed, 21 insertions(+), 44 deletions(-)
diff --git a/modules/demux/subtitle.c b/modules/demux/subtitle.c
index 5c5c5f9113..2b83e69632 100644
--- a/modules/demux/subtitle.c
+++ b/modules/demux/subtitle.c
@@ -1322,9 +1322,7 @@ static int ParseVplayer( vlc_object_t *p_obj, subs_properties_t *p_props,
if( sscanf( s, "%d:%d:%d%*c%[^\r\n]",
&h1, &m1, &s1, psz_text ) == 4 )
{
- p_subtitle->i_start = ( (int64_t)h1 * 3600*1000 +
- (int64_t)m1 * 60*1000 +
- (int64_t)s1 * 1000 ) * 1000;
+ p_subtitle->i_start = vlc_tick_from_sec( h1 * 3600 + m1 * 60 + s1 );
p_subtitle->i_stop = -1;
break;
}
@@ -1815,21 +1813,19 @@ static int ParseJSS( vlc_object_t *p_obj, subs_properties_t *p_props,
if( sscanf( s, "%d:%d:%d.%d %d:%d:%d.%d %[^\n\r]",
&h1, &m1, &s1, &f1, &h2, &m2, &s2, &f2, psz_text ) == 9 )
{
- p_subtitle->i_start = ( ( (int64_t) h1 *3600 + m1 * 60 + s1 ) +
- (int64_t)( ( f1 + p_props->jss.i_time_shift ) / p_props->jss.i_time_resolution ) )
- * CLOCK_FREQ;
- p_subtitle->i_stop = ( ( (int64_t) h2 *3600 + m2 * 60 + s2 ) +
- (int64_t)( ( f2 + p_props->jss.i_time_shift ) / p_props->jss.i_time_resolution ) )
- * CLOCK_FREQ;
+ p_subtitle->i_start = vlc_tick_from_sec( ( h1 *3600 + m1 * 60 + s1 ) +
+ (int64_t)( ( f1 + p_props->jss.i_time_shift ) / p_props->jss.i_time_resolution ) );
+ p_subtitle->i_stop = vlc_tick_from_sec( ( h2 *3600 + m2 * 60 + s2 ) +
+ (int64_t)( ( f2 + p_props->jss.i_time_shift ) / p_props->jss.i_time_resolution ) );
break;
}
/* Short time lines */
else if( sscanf( s, "@%d @%d %[^\n\r]", &f1, &f2, psz_text ) == 3 )
{
- p_subtitle->i_start = ((int64_t)
- ( f1 + p_props->jss.i_time_shift ) / p_props->jss.i_time_resolution * 1000000.0 );
- p_subtitle->i_stop = ((int64_t)
- ( f2 + p_props->jss.i_time_shift ) / p_props->jss.i_time_resolution * 1000000.0 );
+ p_subtitle->i_start =
+ vlc_tick_from_sec( (f1 + p_props->jss.i_time_shift ) / p_props->jss.i_time_resolution );
+ p_subtitle->i_stop =
+ vlc_tick_from_sec( (f2 + p_props->jss.i_time_shift ) / p_props->jss.i_time_resolution );
break;
}
/* General Directive lines */
@@ -2054,12 +2050,8 @@ static int ParsePSB( vlc_object_t *p_obj, subs_properties_t *p_props,
if( sscanf( s, "{%d:%d:%d}{%d:%d:%d}%[^\r\n]",
&h1, &m1, &s1, &h2, &m2, &s2, psz_text ) == 7 )
{
- p_subtitle->i_start = ( (int64_t)h1 * 3600*1000 +
- (int64_t)m1 * 60*1000 +
- (int64_t)s1 * 1000 ) * 1000;
- p_subtitle->i_stop = ( (int64_t)h2 * 3600*1000 +
- (int64_t)m2 * 60*1000 +
- (int64_t)s2 * 1000 ) * 1000;
+ p_subtitle->i_start = vlc_tick_from_sec( h1 * 3600 + m1 * 60 + s1 );
+ p_subtitle->i_stop = vlc_tick_from_sec( h2 * 3600 + m2 * 60 + s2 );
break;
}
free( psz_text );
@@ -2084,7 +2076,7 @@ static int64_t ParseRealTime( char *psz, int *h, int *m, int *s, int *f )
sscanf( psz, "%d:%d", m, s ) == 2 ||
sscanf( psz, "%d", s ) == 1 )
{
- return (int64_t)((( *h * 60 + *m ) * 60 ) + *s ) * 1000 * 1000
+ return vlc_tick_from_sec((( *h * 60 + *m ) * 60 ) + *s )
+ VLC_TICK_FROM_MS(*f * 10);
}
else return VLC_EGENERIC;
@@ -2205,9 +2197,7 @@ static int ParseDKS( vlc_object_t *p_obj, subs_properties_t *p_props,
if( sscanf( s, "[%d:%d:%d]%[^\r\n]",
&h1, &m1, &s1, psz_text ) == 4 )
{
- p_subtitle->i_start = ( (int64_t)h1 * 3600 +
- (int64_t)m1 * 60 +
- (int64_t)s1 ) * CLOCK_FREQ;
+ p_subtitle->i_start = vlc_tick_from_sec( h1 * 3600 + m1 * 60 + s1 );
s = TextGetLine( txt );
if( !s )
@@ -2217,9 +2207,7 @@ static int ParseDKS( vlc_object_t *p_obj, subs_properties_t *p_props,
}
if( sscanf( s, "[%d:%d:%d]", &h2, &m2, &s2 ) == 3 )
- p_subtitle->i_stop = ( (int64_t)h2 * 3600*1000 +
- (int64_t)m2 * 60*1000 +
- (int64_t)s2 * 1000 ) * 1000;
+ p_subtitle->i_stop = vlc_tick_from_sec(h2 * 3600 + m2 * 60 + s2 );
else
p_subtitle->i_stop = -1;
break;
@@ -2258,9 +2246,7 @@ static int ParseSubViewer1( vlc_object_t *p_obj, subs_properties_t *p_props,
if( sscanf( s, "[%d:%d:%d]", &h1, &m1, &s1 ) == 3 )
{
- p_subtitle->i_start = ( (int64_t)h1 * 3600 +
- (int64_t)m1 * 60 +
- (int64_t)s1 ) * CLOCK_FREQ;
+ p_subtitle->i_start = vlc_tick_from_sec( h1 * 3600 + m1 * 60 + s1 );
s = TextGetLine( txt );
if( !s )
@@ -2278,9 +2264,7 @@ static int ParseSubViewer1( vlc_object_t *p_obj, subs_properties_t *p_props,
}
if( sscanf( s, "[%d:%d:%d]", &h2, &m2, &s2 ) == 3 )
- p_subtitle->i_stop = ( (int64_t)h2 * 3600 +
- (int64_t)m2 * 60 +
- (int64_t)s2 ) * CLOCK_FREQ;
+ p_subtitle->i_stop = vlc_tick_from_sec( h2 * 3600 + m2 * 60 + s2 );
else
p_subtitle->i_stop = -1;
@@ -2401,7 +2385,7 @@ static int ParseSCC( vlc_object_t *p_obj, subs_properties_t *p_props,
continue;
/* convert everything to seconds */
- vlc_tick_t i_frames = h * 3600 + m * 60 + s;
+ uint64_t i_frames = h * 3600 + m * 60 + s;
if( c == ';' && p_rate->b_drop_allowed ) /* dropframe */
{
@@ -2416,7 +2400,7 @@ static int ParseSCC( vlc_object_t *p_obj, subs_properties_t *p_props,
/* convert to frame # at 29.97 */
i_frames = i_frames * framerates[3].rate.num / framerates[3].rate.den + f;
}
- p_subtitle->i_start = VLC_TICK_0 + i_frames * CLOCK_FREQ *
+ p_subtitle->i_start = VLC_TICK_0 + vlc_tick_from_sec(i_frames)*
p_rate->rate.den / p_rate->rate.num;
p_subtitle->i_stop = -1;
diff --git a/modules/demux/vobsub.c b/modules/demux/vobsub.c
index 3de858fee1..ad935320ef 100644
--- a/modules/demux/vobsub.c
+++ b/modules/demux/vobsub.c
@@ -592,10 +592,7 @@ static int ParseVobSubIDX( demux_t *p_demux )
i_sign = -1;
h = -h;
}
- i_start = (int64_t) ( h * 3600*1000 +
- m * 60*1000 +
- s * 1000 +
- ms ) * 1000;
+ i_start = vlc_tick_from_sec( h * 3600 + m * 60 + s ) + VLC_TICK_FROM_MS( ms );
i_location = loc;
current_tk->i_subtitles++;
@@ -632,10 +629,7 @@ static int ParseVobSubIDX( demux_t *p_demux )
i_sign = -1;
h = -h;
}
- i_gap = (int64_t) ( h * 3600*1000 +
- m * 60*1000 +
- s * 1000 +
- ms ) * 1000;
+ i_gap = vlc_tick_from_sec( h * 3600 + m * 60 + s ) + VLC_TICK_FROM_MS( ms );
current_tk->i_delay = current_tk->i_delay + (i_gap * i_sign);
msg_Dbg( p_demux, "sign: %+d gap: %+"PRId64" global delay: %+"PRId64"",
diff --git a/modules/demux/xiph_metadata.c b/modules/demux/xiph_metadata.c
index 29cc4eb48b..3137dbc296 100644
--- a/modules/demux/xiph_metadata.c
+++ b/modules/demux/xiph_metadata.c
@@ -539,8 +539,7 @@ void vorbis_ParseComment( es_format_t *p_fmt, vlc_meta_t **pp_meta,
{
p_seekpoint = getChapterEntry( i_chapt, &chapters_array );
if ( ! p_seekpoint ) goto next_comment;
- p_seekpoint->i_time_offset =
- (((int64_t)h * 3600 + (int64_t)m * 60 + (int64_t)s) * 1000 + ms) * 1000;
+ p_seekpoint->i_time_offset = vlc_tick_from_sec(h * 3600 + m * 60 + s) + VLC_TICK_FROM_MS(ms);
}
}
}
More information about the vlc-commits
mailing list