vlc/vlc-2.0 | branch: master | Sébastien Escudier <[email protected]> | Fri Feb 24 15:28:28 2012 +0100| [fcd42e663464458cf64d09abbea108e231f362e4] | committer: Sébastien Escudier
avformat : fix overflow in timestamp computation (cherry picked from commit b19614ae62c2083ae7f5b34cd7b7a5d3ca7e250a) Signed-off-by: Sébastien Escudier <[email protected]> > http://git.videolan.org/gitweb.cgi/vlc/vlc-2.0.git/?a=commit;h=fcd42e663464458cf64d09abbea108e231f362e4 --- modules/demux/avformat/demux.c | 42 +++++++++++++++++++++++++++++---------- 1 files changed, 31 insertions(+), 11 deletions(-) diff --git a/modules/demux/avformat/demux.c b/modules/demux/avformat/demux.c index 4785ff5..bab3ea6 100644 --- a/modules/demux/avformat/demux.c +++ b/modules/demux/avformat/demux.c @@ -594,17 +594,37 @@ static int Demux( demux_t *p_demux ) if( pkt.flags & AV_PKT_FLAG_KEY ) p_frame->i_flags |= BLOCK_FLAG_TYPE_I; - i_start_time = ( p_sys->ic->start_time != (int64_t)AV_NOPTS_VALUE ) ? - ( p_sys->ic->start_time * 1000000 / AV_TIME_BASE ) : 0; - - p_frame->i_dts = ( pkt.dts == (int64_t)AV_NOPTS_VALUE ) ? - VLC_TS_INVALID : (pkt.dts) * 1000000 * - p_stream->time_base.num / - p_stream->time_base.den - i_start_time + VLC_TS_0; - p_frame->i_pts = ( pkt.pts == (int64_t)AV_NOPTS_VALUE ) ? - VLC_TS_INVALID : (pkt.pts) * 1000000 * - p_stream->time_base.num / - p_stream->time_base.den - i_start_time + VLC_TS_0; + /* Used to avoid timestamps overlow */ + lldiv_t q; + if( p_sys->ic->start_time != (int64_t)AV_NOPTS_VALUE ) + { + q = lldiv( p_sys->ic->start_time, AV_TIME_BASE); + i_start_time = q.quot * (int64_t)1000000 + q.rem * (int64_t)1000000 / AV_TIME_BASE; + } + else + i_start_time = 0; + + if( pkt.dts == (int64_t)AV_NOPTS_VALUE ) + p_frame->i_dts = VLC_TS_INVALID; + else + { + q = lldiv( pkt.dts, p_stream->time_base.den ); + p_frame->i_dts = q.quot * (int64_t)1000000 * + p_stream->time_base.num + q.rem * (int64_t)1000000 * + p_stream->time_base.num / + p_stream->time_base.den - i_start_time + VLC_TS_0; + } + + if( pkt.pts == (int64_t)AV_NOPTS_VALUE ) + p_frame->i_pts = VLC_TS_INVALID; + else + { + q = lldiv( pkt.pts, p_stream->time_base.den ); + p_frame->i_pts = q.quot * (int64_t)1000000 * + p_stream->time_base.num + q.rem * (int64_t)1000000 * + p_stream->time_base.num / + p_stream->time_base.den - i_start_time + VLC_TS_0; + } if( pkt.duration > 0 && p_frame->i_length <= 0 ) p_frame->i_length = pkt.duration * 1000000 * p_stream->time_base.num / _______________________________________________ vlc-commits mailing list [email protected] http://mailman.videolan.org/listinfo/vlc-commits
