[vlc-commits] demux: cdg: factorize the code to compute the DTS
Steve Lhomme
git at videolan.org
Wed Sep 19 15:46:24 CEST 2018
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Jun 4 10:24:20 2018 +0200| [95bd547e6ff7a48ea0a223bb06a9c7ee7fb2131d] | committer: Steve Lhomme
demux: cdg: factorize the code to compute the DTS
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=95bd547e6ff7a48ea0a223bb06a9c7ee7fb2131d
---
modules/demux/cdg.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/modules/demux/cdg.c b/modules/demux/cdg.c
index 92315af875..e2aa8eaa4b 100644
--- a/modules/demux/cdg.c
+++ b/modules/demux/cdg.c
@@ -63,6 +63,7 @@ typedef struct
#define CDG_FRAME_SIZE (96)
#define CDG_FRAME_RATE (75)
+#define CDG_FRAME_DELTA (CLOCK_FREQ / CDG_FRAME_RATE)
/*****************************************************************************
* Open: check file and initializes structures
@@ -108,6 +109,11 @@ static int Open( vlc_object_t * p_this )
return VLC_SUCCESS;
}
+static vlc_tick_t PosToDate( demux_t *p_demux )
+{
+ return vlc_stream_Tell( p_demux->s ) / CDG_FRAME_SIZE * CDG_FRAME_DELTA;
+}
+
/*****************************************************************************
* Demux: read packet and send them to decoders
*****************************************************************************
@@ -118,9 +124,6 @@ static int Demux( demux_t *p_demux )
demux_sys_t *p_sys = p_demux->p_sys;
block_t *p_block;
vlc_tick_t i_date;
- vlc_tick_t i_delta;
-
- i_delta = CLOCK_FREQ / CDG_FRAME_RATE;
p_block = vlc_stream_Block( p_demux->s, CDG_FRAME_SIZE );
if( p_block == NULL )
@@ -129,8 +132,8 @@ static int Demux( demux_t *p_demux )
return VLC_DEMUXER_EOF;
}
- i_date = vlc_stream_Tell( p_demux->s ) / CDG_FRAME_SIZE * i_delta;
- if( i_date >= date_Get( &p_sys->pts ) + i_delta )
+ i_date = PosToDate( p_demux );
+ if( i_date >= date_Get( &p_sys->pts ) + CDG_FRAME_DELTA )
{
p_block->i_dts = p_block->i_pts = VLC_TICK_0 + i_date;
date_Set( &p_sys->pts, VLC_TICK_0 + i_date );
@@ -158,8 +161,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
i_query, args );
if( !i_ret && ( i_query == DEMUX_SET_POSITION || i_query == DEMUX_SET_TIME ) )
{
- date_Set( &p_sys->pts, vlc_stream_Tell( p_demux->s ) / CDG_FRAME_SIZE *
- CLOCK_FREQ / CDG_FRAME_RATE );
+ date_Set( &p_sys->pts, PosToDate( p_demux ) );
if ( i_old_offset > vlc_stream_Tell( p_demux->s ) )
i_ret = vlc_stream_Seek( p_demux->s, 0 );
else
More information about the vlc-commits
mailing list