[vlc-commits] demux: nuv: simplify the GET_LENGTH calculation

Steve Lhomme git at videolan.org
Wed Sep 19 15:46:15 CEST 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Fri Jun  1 13:28:12 2018 +0200| [cc5523bcaa384baddf9ac714312a5f4ed5d325f1] | committer: Steve Lhomme

demux: nuv: simplify the GET_LENGTH calculation

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=cc5523bcaa384baddf9ac714312a5f4ed5d325f1
---

 modules/demux/nuv.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/modules/demux/nuv.c b/modules/demux/nuv.c
index cf16e59fc7..cc057d3c46 100644
--- a/modules/demux/nuv.c
+++ b/modules/demux/nuv.c
@@ -531,9 +531,13 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             else if( vlc_stream_Tell( p_demux->s ) > p_sys->i_first_frame_offset )
             {
                 /* This should give an approximation of the total duration */
-                *pi64 = (double)( stream_Size( p_demux->s ) - p_sys->i_first_frame_offset ) /
-                        (double)( vlc_stream_Tell( p_demux->s ) - p_sys->i_first_frame_offset )
-                        * (double)( p_sys->i_pcr >= 0 ? p_sys->i_pcr : 0 );
+                if (p_sys->i_pcr <= 0)
+                    *pi64 = 0;
+                else
+                    *pi64 = p_sys->i_pcr *
+                            (double)( stream_Size( p_demux->s ) - p_sys->i_first_frame_offset ) /
+                            (double)( vlc_stream_Tell( p_demux->s ) - p_sys->i_first_frame_offset );
+
                 return VLC_SUCCESS;
             }
             else



More information about the vlc-commits mailing list